dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
Spline.h
1/**************************************************************************\
2 * Copyright (c) Kongsberg Oil & Gas Technologies AS
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31\**************************************************************************/
32
33#ifndef DIME_SPLINE_H
34#define DIME_SPLINE_H
35
36#include <dime/entities/ExtrusionEntity.h>
37#include <assert.h>
38
39class DIME_DLL_API dimeSpline : public dimeEntity
40{
41public:
42 dimeSpline();
43 virtual ~dimeSpline();
44
45 enum Flags {
46 CLOSED = 0x01,
47 PERIODIC = 0x02,
48 RATIONAL = 0x04,
49 PLANAR = 0x08,
50 LINEAR = 0x10
51 };
52
53 bool hasWeights() const;
54
55 int16 getFlags() const;
56 void setFlags(const int16 flags);
57
58 int16 getDegree() const;
59 void setDegree(const int16 degree);
60
61 dxfdouble getControlPointTolerance() const;
62 void setControlPointTolerance(const dxfdouble tol);
63 dxfdouble getFitPointTolerance() const;
64 void setFitPointTolerance(const dxfdouble tol);
65 dxfdouble getKnotTolerance() const;
66 void setKnotTolerance(const dxfdouble tol);
67
68 int getNumKnots() const;
69 dxfdouble getKnotValue(const int idx) const;
70 void setKnotValue(const int idx, const dxfdouble value);
71 void setKnotValues(const dxfdouble * const values, const int numvalues,
72 dimeMemHandler * const memhandler = NULL);
73
74 int getNumControlPoints() const;
75 const dimeVec3f &getControlPoint(const int idx) const;
76 void setControlPoint(const int idx, const dimeVec3f &v);
77 void setControlPoints(const dimeVec3f * const pts, const int numpts,
78 dimeMemHandler * const memhandler = NULL);
79
80 int getNumWeights() const;
81 dxfdouble getWeight(const int idx) const;
82 void setWeight(const int idx, const dxfdouble w,
83 dimeMemHandler * const memhandler = NULL);
84
85 int getNumFitPoints() const;
86 const dimeVec3f &getFitPoint(const int idx) const;
87 void setFitPoint(const int idx, const dimeVec3f &pt);
88 void setFitPoints(const dimeVec3f * const pts, const int numpts,
89 dimeMemHandler * const memhandler = NULL);
90
91 virtual dimeEntity *copy(dimeModel * const model) const;
92 virtual bool getRecord(const int groupcode,
93 dimeParam &param,
94 const int index) const;
95 virtual const char *getEntityName() const;
96
97 virtual void print() const;
98 virtual bool write(dimeOutput * const out);
99 virtual int typeId() const;
100 virtual int countRecords() const;
101
102protected:
103 virtual bool handleRecord(const int groupcode,
104 const dimeParam &param,
105 dimeMemHandler * const memhandler);
106
107private:
108 int16 flags;
109#ifdef DIME_FIXBIG
110 int32 degree;
111 int32 numKnots;
112 int32 numControlPoints;
113 int32 numFitPoints;
114#else
115 int16 degree;
116 int16 numKnots;
117 int16 numControlPoints;
118 int16 numFitPoints;
119#endif
120 dxfdouble knotTolerance;
121 dxfdouble fitTolerance;
122 dxfdouble cpTolerance;
123 dxfdouble *knots;
124 dxfdouble *weights;
125 dimeVec3f *controlPoints;
126 dimeVec3f *fitPoints;
127
128 // read/handle counters
129 int16 knotCnt;
130 int16 fitCnt;
131 int16 cpCnt;
132 int16 weightCnt;
133
134}; // class dimeSpline
135
136inline int16
137dimeSpline::getFlags() const
138{
139 return this->flags;
140}
141
142inline void
143dimeSpline::setFlags(const int16 flags)
144{
145 this->flags = flags;
146}
147
148inline int16
149dimeSpline::getDegree() const
150{
151 return this->degree;
152}
153
154inline void
155dimeSpline::setDegree(const int16 degree)
156{
157 this->degree = degree;
158}
159
160inline dxfdouble
161dimeSpline::getControlPointTolerance() const
162{
163 return this->cpTolerance;
164}
165
166inline void
167dimeSpline::setControlPointTolerance(const dxfdouble tol)
168{
169 this->cpTolerance = tol;
170}
171
172inline dxfdouble
173dimeSpline::getFitPointTolerance() const
174{
175 return this->fitTolerance;
176}
177
178inline void
179dimeSpline::setFitPointTolerance(const dxfdouble tol)
180{
181 this->fitTolerance = tol;
182}
183
184inline dxfdouble
185dimeSpline::getKnotTolerance() const
186{
187 return this->knotTolerance;
188}
189
190inline void
191dimeSpline::setKnotTolerance(const dxfdouble tol)
192{
193 this->knotTolerance = tol;
194}
195
196inline int
197dimeSpline::getNumKnots() const
198{
199 return this->numKnots;
200}
201
202inline dxfdouble
203dimeSpline::getKnotValue(const int idx) const
204{
205 assert(idx >= 0 && idx < this->numKnots);
206 return this->knots[idx];
207}
208
209inline void
210dimeSpline::setKnotValue(const int idx, const dxfdouble value)
211{
212 assert(idx >= 0 && idx < this->numKnots);
213 this->knots[idx] = value;
214}
215
216inline int
217dimeSpline::getNumControlPoints() const
218{
219 return this->numControlPoints;
220}
221
222inline const dimeVec3f &
223dimeSpline::getControlPoint(const int idx) const
224{
225 assert(idx >= 0 && idx < this->numControlPoints);
226 return this->controlPoints[idx];
227}
228
229inline void
230dimeSpline::setControlPoint(const int idx, const dimeVec3f &v)
231{
232 assert(idx >= 0 && idx < this->numControlPoints);
233 this->controlPoints[idx] = v;
234}
235
236inline int
237dimeSpline::getNumWeights() const
238{
239 return this->getNumControlPoints();
240}
241
242inline dxfdouble
243dimeSpline::getWeight(const int idx) const
244{
245 if (this->hasWeights()) {
246 assert(idx >= 0 && idx < this->numControlPoints);
247 return this->weights[idx];
248 }
249 return 1.0;
250}
251
252inline int
253dimeSpline::getNumFitPoints() const
254{
255 return this->numFitPoints;
256}
257
258inline const dimeVec3f &
259dimeSpline::getFitPoint(const int idx) const
260{
261 assert(idx >= 0 && idx < this->numFitPoints);
262 return this->fitPoints[idx];
263}
264
265inline void
266dimeSpline::setFitPoint(const int idx, const dimeVec3f &pt)
267{
268 assert(idx >= 0 && idx < this->numFitPoints);
269 this->fitPoints[idx] = pt;
270}
271
272#endif // ! DIME_SPLINE_H
273
virtual int typeId() const =0
The dimeEntity class is the superclass of all entity classes.
Definition Entity.h:61
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition Entity.cpp:715
virtual bool write(dimeOutput *const out)
Definition Entity.cpp:271
virtual const char * getEntityName() const =0
virtual int countRecords() const
Definition Entity.cpp:526
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition Entity.cpp:659
virtual dimeEntity * copy(dimeModel *const model) const =0
The dimeMemHandler class is a special-purpose memory manager.
Definition MemHandler.h:39
The dimeModel class organizes a model.
Definition Model.h:55
The dimeOutput class handles writing of DXF and DXB files.
Definition Output.h:42
The dimeSpline class handles a SPLINE entity.
Definition Spline.h:40
bool hasWeights() const
Definition Spline.cpp:88
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition Linear.h:62
The dimeParam class is a union of the different parameter types.
Definition Basic.h:102