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 #ifndef DIME_SPLINE_H
00031 #define DIME_SPLINE_H
00032
00033 #include <dime/entities/ExtrusionEntity.h>
00034 #include <assert.h>
00035
00036 class dimeSpline : public dimeEntity
00037 {
00038 public:
00039 dimeSpline();
00040 virtual ~dimeSpline();
00041
00042 enum Flags {
00043 CLOSED = 0x01,
00044 PERIODIC = 0x02,
00045 RATIONAL = 0x04,
00046 PLANAR = 0x08,
00047 LINEAR = 0x10
00048 };
00049
00050 bool hasWeights() const;
00051
00052 int16 getFlags() const;
00053 void setFlags(const int16 flags);
00054
00055 int16 getDegree() const;
00056 void setDegree(const int16 degree);
00057
00058 dxfdouble getControlPointTolerance() const;
00059 void setControlPointTolerance(const dxfdouble tol);
00060 dxfdouble getFitPointTolerance() const;
00061 void setFitPointTolerance(const dxfdouble tol);
00062 dxfdouble getKnotTolerance() const;
00063 void setKnotTolerance(const dxfdouble tol);
00064
00065 int getNumKnots() const;
00066 dxfdouble getKnotValue(const int idx) const;
00067 void setKnotValue(const int idx, const dxfdouble value);
00068 void setKnotValues(const dxfdouble * const values, const int numvalues,
00069 dimeMemHandler * const memhandler = NULL);
00070
00071 int getNumControlPoints() const;
00072 const dimeVec3f &getControlPoint(const int idx) const;
00073 void setControlPoint(const int idx, const dimeVec3f &v);
00074 void setControlPoints(const dimeVec3f * const pts, const int numpts,
00075 dimeMemHandler * const memhandler = NULL);
00076
00077 int getNumWeights() const;
00078 dxfdouble getWeight(const int idx) const;
00079 void setWeight(const int idx, const dxfdouble w,
00080 dimeMemHandler * const memhandler = NULL);
00081
00082 int getNumFitPoints() const;
00083 const dimeVec3f &getFitPoint(const int idx) const;
00084 void setFitPoint(const int idx, const dimeVec3f &pt);
00085 void setFitPoints(const dimeVec3f * const pts, const int numpts,
00086 dimeMemHandler * const memhandler = NULL);
00087
00088 virtual dimeEntity *copy(dimeModel * const model) const;
00089 virtual bool getRecord(const int groupcode,
00090 dimeParam ¶m,
00091 const int index) const;
00092 virtual const char *getEntityName() const;
00093
00094 virtual void print() const;
00095 virtual bool write(dimeOutput * const out);
00096 virtual int typeId() const;
00097 virtual int countRecords() const;
00098
00099 protected:
00100 virtual bool handleRecord(const int groupcode,
00101 const dimeParam ¶m,
00102 dimeMemHandler * const memhandler);
00103
00104 private:
00105 int16 flags;
00106 #ifdef DIME_FIXBIG
00107 int32 degree;
00108 int32 numKnots;
00109 int32 numControlPoints;
00110 int32 numFitPoints;
00111 #else
00112 int16 degree;
00113 int16 numKnots;
00114 int16 numControlPoints;
00115 int16 numFitPoints;
00116 #endif
00117 dxfdouble knotTolerance;
00118 dxfdouble fitTolerance;
00119 dxfdouble cpTolerance;
00120 dxfdouble *knots;
00121 dxfdouble *weights;
00122 dimeVec3f *controlPoints;
00123 dimeVec3f *fitPoints;
00124
00125
00126 int16 knotCnt;
00127 int16 fitCnt;
00128 int16 cpCnt;
00129 int16 weightCnt;
00130
00131 };
00132
00133 inline int16
00134 dimeSpline::getFlags() const
00135 {
00136 return this->flags;
00137 }
00138
00139 inline void
00140 dimeSpline::setFlags(const int16 flags)
00141 {
00142 this->flags = flags;
00143 }
00144
00145 inline int16
00146 dimeSpline::getDegree() const
00147 {
00148 return this->degree;
00149 }
00150
00151 inline void
00152 dimeSpline::setDegree(const int16 degree)
00153 {
00154 this->degree = degree;
00155 }
00156
00157 inline dxfdouble
00158 dimeSpline::getControlPointTolerance() const
00159 {
00160 return this->cpTolerance;
00161 }
00162
00163 inline void
00164 dimeSpline::setControlPointTolerance(const dxfdouble tol)
00165 {
00166 this->cpTolerance = tol;
00167 }
00168
00169 inline dxfdouble
00170 dimeSpline::getFitPointTolerance() const
00171 {
00172 return this->fitTolerance;
00173 }
00174
00175 inline void
00176 dimeSpline::setFitPointTolerance(const dxfdouble tol)
00177 {
00178 this->fitTolerance = tol;
00179 }
00180
00181 inline dxfdouble
00182 dimeSpline::getKnotTolerance() const
00183 {
00184 return this->knotTolerance;
00185 }
00186
00187 inline void
00188 dimeSpline::setKnotTolerance(const dxfdouble tol)
00189 {
00190 this->knotTolerance = tol;
00191 }
00192
00193 inline int
00194 dimeSpline::getNumKnots() const
00195 {
00196 return this->numKnots;
00197 }
00198
00199 inline dxfdouble
00200 dimeSpline::getKnotValue(const int idx) const
00201 {
00202 assert(idx >= 0 && idx < this->numKnots);
00203 return this->knots[idx];
00204 }
00205
00206 inline void
00207 dimeSpline::setKnotValue(const int idx, const dxfdouble value)
00208 {
00209 assert(idx >= 0 && idx < this->numKnots);
00210 this->knots[idx] = value;
00211 }
00212
00213 inline int
00214 dimeSpline::getNumControlPoints() const
00215 {
00216 return this->numControlPoints;
00217 }
00218
00219 inline const dimeVec3f &
00220 dimeSpline::getControlPoint(const int idx) const
00221 {
00222 assert(idx >= 0 && idx < this->numControlPoints);
00223 return this->controlPoints[idx];
00224 }
00225
00226 inline void
00227 dimeSpline::setControlPoint(const int idx, const dimeVec3f &v)
00228 {
00229 assert(idx >= 0 && idx < this->numControlPoints);
00230 this->controlPoints[idx] = v;
00231 }
00232
00233 inline int
00234 dimeSpline::getNumWeights() const
00235 {
00236 return this->getNumControlPoints();
00237 }
00238
00239 inline dxfdouble
00240 dimeSpline::getWeight(const int idx) const
00241 {
00242 if (this->hasWeights()) {
00243 assert(idx >= 0 && idx < this->numControlPoints);
00244 return this->weights[idx];
00245 }
00246 return 1.0;
00247 }
00248
00249 inline int
00250 dimeSpline::getNumFitPoints() const
00251 {
00252 return this->numFitPoints;
00253 }
00254
00255 inline const dimeVec3f &
00256 dimeSpline::getFitPoint(const int idx) const
00257 {
00258 assert(idx >= 0 && idx < this->numFitPoints);
00259 return this->fitPoints[idx];
00260 }
00261
00262 inline void
00263 dimeSpline::setFitPoint(const int idx, const dimeVec3f &pt)
00264 {
00265 assert(idx >= 0 && idx < this->numFitPoints);
00266 this->fitPoints[idx] = pt;
00267 }
00268
00269 #endif // ! DIME_SPLINE_H
00270