Spline.h
1 /**************************************************************************\
2  *
3  * FILE: Spline.h
4  *
5  * This source file is part of DIME.
6  * Copyright (C) 1998-1999 by Systems In Motion. All rights reserved.
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License, version 2, as
10  * published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License (the accompanying file named COPYING) for more
16  * details.
17  *
18  **************************************************************************
19  *
20  * If you need DIME for a non-GPL project, contact Systems In Motion
21  * to acquire a Professional Edition License:
22  *
23  * Systems In Motion http://www.sim.no/
24  * Prof. Brochs gate 6 sales@sim.no
25  * N-7030 Trondheim Voice: +47 22114160
26  * NORWAY Fax: +47 67172912
27  *
28 \**************************************************************************/
29 
30 #ifndef DIME_SPLINE_H
31 #define DIME_SPLINE_H
32 
33 #include <dime/entities/ExtrusionEntity.h>
34 #include <assert.h>
35 
36 class DIME_DLL_API dimeSpline : public dimeEntity
37 {
38 public:
39  dimeSpline();
40  virtual ~dimeSpline();
41 
42  enum Flags {
43  CLOSED = 0x01,
44  PERIODIC = 0x02,
45  RATIONAL = 0x04,
46  PLANAR = 0x08,
47  LINEAR = 0x10
48  };
49 
50  bool hasWeights() const;
51 
52  int16 getFlags() const;
53  void setFlags(const int16 flags);
54 
55  int16 getDegree() const;
56  void setDegree(const int16 degree);
57 
58  dxfdouble getControlPointTolerance() const;
59  void setControlPointTolerance(const dxfdouble tol);
60  dxfdouble getFitPointTolerance() const;
61  void setFitPointTolerance(const dxfdouble tol);
62  dxfdouble getKnotTolerance() const;
63  void setKnotTolerance(const dxfdouble tol);
64 
65  int getNumKnots() const;
66  dxfdouble getKnotValue(const int idx) const;
67  void setKnotValue(const int idx, const dxfdouble value);
68  void setKnotValues(const dxfdouble * const values, const int numvalues,
69  dimeMemHandler * const memhandler = NULL);
70 
71  int getNumControlPoints() const;
72  const dimeVec3f &getControlPoint(const int idx) const;
73  void setControlPoint(const int idx, const dimeVec3f &v);
74  void setControlPoints(const dimeVec3f * const pts, const int numpts,
75  dimeMemHandler * const memhandler = NULL);
76 
77  int getNumWeights() const;
78  dxfdouble getWeight(const int idx) const;
79  void setWeight(const int idx, const dxfdouble w,
80  dimeMemHandler * const memhandler = NULL);
81 
82  int getNumFitPoints() const;
83  const dimeVec3f &getFitPoint(const int idx) const;
84  void setFitPoint(const int idx, const dimeVec3f &pt);
85  void setFitPoints(const dimeVec3f * const pts, const int numpts,
86  dimeMemHandler * const memhandler = NULL);
87 
88  virtual dimeEntity *copy(dimeModel * const model) const;
89  virtual bool getRecord(const int groupcode,
90  dimeParam &param,
91  const int index) const;
92  virtual const char *getEntityName() const;
93 
94  virtual void print() const;
95  virtual bool write(dimeOutput * const out);
96  virtual int typeId() const;
97  virtual int countRecords() const;
98 
99 protected:
100  virtual bool handleRecord(const int groupcode,
101  const dimeParam &param,
102  dimeMemHandler * const memhandler);
103 
104 private:
105  int16 flags;
106 #ifdef DIME_FIXBIG
107  int32 degree;
108  int32 numKnots;
109  int32 numControlPoints;
110  int32 numFitPoints;
111 #else
112  int16 degree;
113  int16 numKnots;
114  int16 numControlPoints;
115  int16 numFitPoints;
116 #endif
117  dxfdouble knotTolerance;
118  dxfdouble fitTolerance;
119  dxfdouble cpTolerance;
120  dxfdouble *knots;
121  dxfdouble *weights;
122  dimeVec3f *controlPoints;
123  dimeVec3f *fitPoints;
124 
125  // read/handle counters
126  int16 knotCnt;
127  int16 fitCnt;
128  int16 cpCnt;
129  int16 weightCnt;
130 
131 }; // class dimeSpline
132 
133 inline int16
134 dimeSpline::getFlags() const
135 {
136  return this->flags;
137 }
138 
139 inline void
140 dimeSpline::setFlags(const int16 flags)
141 {
142  this->flags = flags;
143 }
144 
145 inline int16
146 dimeSpline::getDegree() const
147 {
148  return this->degree;
149 }
150 
151 inline void
152 dimeSpline::setDegree(const int16 degree)
153 {
154  this->degree = degree;
155 }
156 
157 inline dxfdouble
158 dimeSpline::getControlPointTolerance() const
159 {
160  return this->cpTolerance;
161 }
162 
163 inline void
164 dimeSpline::setControlPointTolerance(const dxfdouble tol)
165 {
166  this->cpTolerance = tol;
167 }
168 
169 inline dxfdouble
170 dimeSpline::getFitPointTolerance() const
171 {
172  return this->fitTolerance;
173 }
174 
175 inline void
176 dimeSpline::setFitPointTolerance(const dxfdouble tol)
177 {
178  this->fitTolerance = tol;
179 }
180 
181 inline dxfdouble
182 dimeSpline::getKnotTolerance() const
183 {
184  return this->knotTolerance;
185 }
186 
187 inline void
188 dimeSpline::setKnotTolerance(const dxfdouble tol)
189 {
190  this->knotTolerance = tol;
191 }
192 
193 inline int
194 dimeSpline::getNumKnots() const
195 {
196  return this->numKnots;
197 }
198 
199 inline dxfdouble
200 dimeSpline::getKnotValue(const int idx) const
201 {
202  assert(idx >= 0 && idx < this->numKnots);
203  return this->knots[idx];
204 }
205 
206 inline void
207 dimeSpline::setKnotValue(const int idx, const dxfdouble value)
208 {
209  assert(idx >= 0 && idx < this->numKnots);
210  this->knots[idx] = value;
211 }
212 
213 inline int
214 dimeSpline::getNumControlPoints() const
215 {
216  return this->numControlPoints;
217 }
218 
219 inline const dimeVec3f &
220 dimeSpline::getControlPoint(const int idx) const
221 {
222  assert(idx >= 0 && idx < this->numControlPoints);
223  return this->controlPoints[idx];
224 }
225 
226 inline void
227 dimeSpline::setControlPoint(const int idx, const dimeVec3f &v)
228 {
229  assert(idx >= 0 && idx < this->numControlPoints);
230  this->controlPoints[idx] = v;
231 }
232 
233 inline int
234 dimeSpline::getNumWeights() const
235 {
236  return this->getNumControlPoints();
237 }
238 
239 inline dxfdouble
240 dimeSpline::getWeight(const int idx) const
241 {
242  if (this->hasWeights()) {
243  assert(idx >= 0 && idx < this->numControlPoints);
244  return this->weights[idx];
245  }
246  return 1.0;
247 }
248 
249 inline int
250 dimeSpline::getNumFitPoints() const
251 {
252  return this->numFitPoints;
253 }
254 
255 inline const dimeVec3f &
256 dimeSpline::getFitPoint(const int idx) const
257 {
258  assert(idx >= 0 && idx < this->numFitPoints);
259  return this->fitPoints[idx];
260 }
261 
262 inline void
263 dimeSpline::setFitPoint(const int idx, const dimeVec3f &pt)
264 {
265  assert(idx >= 0 && idx < this->numFitPoints);
266  this->fitPoints[idx] = pt;
267 }
268 
269 #endif // ! DIME_SPLINE_H
270 

Copyright © 1998-1999, Systems In Motion <sales@sim.no>. All rights reserved.
System documentation was generated using doxygen.