00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 #ifndef VRS_NURBS_H
00083 #define VRS_NURBS_H
00084
00085 #include <vrs/container/array.h>
00086 #include <vrs/shape.h>
00087
00088 namespace VRS {
00089
00091 class VRS_CORE_API Nurbs : public Shape {
00092
00093 public:
00094 Nurbs(
00095 int orderU, int orderV,
00096 int nU, int nV,
00097 double tolerance = 25.0
00098 );
00099
00100
00101 virtual void setCharacteristic(int orderU, int orderV, int nU, int nV);
00102 virtual int getNU() const;
00103 virtual int getNV() const;
00104 virtual int getOrderU() const;
00105 virtual int getOrderV() const;
00118 virtual void setVertex(int iu, int iv, const Vector&);
00119 virtual Vector getVertex(int iu, int iv) const;
00120 virtual void setWeight(int ui, int vi, double w);
00121 virtual double getWeight(int ui, int vi) const;
00127 virtual void loadVertices(Iterator<Vector>*);
00128 virtual void loadVertices3fv(int novertices, const double*);
00129 virtual void loadVertices4fv(int novertices, const double*);
00130 virtual void loadWeights(const Array<double>& weights);
00138 virtual void setKnotU(int i, double v);
00139 virtual void setKnotV(int i, double v);
00140 virtual double getKnotU(int i) const;
00141 virtual double getKnotV(int i) const;
00142 virtual void loadKnotsU(const Array<double>& knotsU);
00143 virtual void loadKnotsV(const Array<double>& knotsV);
00144 virtual void loadKnotsUfv(int no, const double*);
00145 virtual void loadKnotsVfv(int no, const double*);
00146 virtual bool knotsConsistent() const;
00148
00149 virtual void setSamplingTolerance(double pixel);
00150 virtual double getSamplingTolerance() const;
00155 virtual double* verticesRep() const;
00156 virtual double* knotsRepU() const;
00157 virtual double* knotsRepV() const;
00159
00160 virtual Bounds boundingBox() const;
00162
00163 VRS_TYPEINFO(Nurbs, Shape);
00164 VRS_SERIALIZABLE(Nurbs);
00165
00166 protected:
00167 Nurbs();
00168
00169 private:
00170 int orderU_, orderV_;
00171 int nU_, nV_;
00172 double tolerance_;
00173 std::vector<double> coords_;
00174 std::vector<double> knotsU_;
00175 std::vector<double> knotsV_;
00176 Vector llf_;
00177 Vector urb_;
00178 };
00179
00180 inline int Nurbs::getOrderU() const { return orderU_; }
00181 inline int Nurbs::getOrderV() const { return orderV_; }
00182 inline int Nurbs::getNU() const { return nU_; }
00183 inline int Nurbs::getNV() const { return nV_; }
00184 inline double Nurbs::getSamplingTolerance() const { return tolerance_; }
00185
00186 inline double* Nurbs::verticesRep() const { return const_cast<double*>(&coords_[0]); }
00187 inline double* Nurbs::knotsRepU() const { return const_cast<double*>(&knotsU_[0]); }
00188 inline double* Nurbs::knotsRepV() const { return const_cast<double*>(&knotsV_[0]); }
00189
00190 }
00191
00192 #endif // VRS_NURBS_H