dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
Polyline.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_POLYLINE_H
34#define DIME_POLYLINE_H
35
36#include <dime/Basic.h>
37#include <dime/entities/ExtrusionEntity.h>
38#include <dime/util/Array.h>
39#include <dime/util/Linear.h>
40
41
42class dimeVertex;
43
44class DIME_DLL_API dimePolyline : public dimeExtrusionEntity
45{
46public:
48 virtual ~dimePolyline();
49
50 enum Type {
51 POLYLINE,
52 POLYFACE_MESH,
53 POLYGON_MESH
54 };
55
56 enum Flags {
57 CLOSED = 0x01,
58 POLYMESH_CLOSED_M = 0x01,
59 CURVE_FIT = 0x02,
60 SPLINE_FIT = 0x04,
61 IS_POLYLINE_3D = 0x08,
62 IS_POLYMESH_3D = 0x10,
63 POLYMESH_CLOSED_N = 0x20,
64 IS_POLYFACE_MESH = 0x40,
65 CONTINOUS_PATTERN = 0x80
66 };
67
68 enum SurfaceType {
69 NONE = 0,
70 QUADRIC_BSPLINE = 5,
71 CUBIC_BSPLINE = 6,
72 BEZIER = 8
73 };
74
75 int16 getFlags() const;
76 void setFlags(const int16 flags);
77
78 int getType() const;
79
80 const dimeVec3f &getElevation() const;
81 void setElevation(const dimeVec3f &e);
82
83 int16 getPolymeshCountN() const;
84 int16 getPolymeshCountM() const;
85 int16 getSmoothSurfaceMdensity() const;
86 int16 getSmoothSurfaceNdensity() const;
87
88 int getNumCoordVertices() const;
89 int getNumIndexVertices() const;
90 int getNumSplineFrameControlPoints() const;
91
92 int16 getSurfaceType() const;
93 void setSurfaceType(const int16 type);
94
95 dimeVertex *getCoordVertex(const int index);
96 dimeVertex *getIndexVertex(const int index);
97 dimeVertex *getSplineFrameControlPoint(const int index);
98
99 void setCoordVertices(dimeVertex **vertices, const int num,
100 dimeMemHandler * const memhandler = NULL);
101 void setIndexVertices(dimeVertex **vertices, const int num,
102 dimeMemHandler * const memhandler = NULL);
103 void setSplineFrameControlPoints(dimeVertex **vertices, const int num,
104 dimeMemHandler * const memhandler = NULL);
105
106 // KRF, 02-16-2006, added to enable ::copy of new polyline
107 void setSeqend(const dimeEntity *ent);
108
109 virtual dimeEntity *copy(dimeModel *const model) const;
110 virtual bool getRecord(const int groupcode,
111 dimeParam &param,
112 const int index = 0) const;
113
114 virtual void setLayer(const dimeLayer * const layer);
115 virtual const char *getEntityName() const;
116
117 virtual bool read(dimeInput * const in);
118 virtual bool write(dimeOutput * const out);
119 virtual int typeId() const;
120 virtual int countRecords() const;
121
122 virtual GeometryType extractGeometry(dimeArray <dimeVec3f> &verts,
123 dimeArray <int> &indices,
124 dimeVec3f &extrusionDir,
125 dxfdouble &thickness);
126
127 void clearSurfaceData();
128
129protected:
130 virtual bool handleRecord(const int groupcode,
131 const dimeParam &param,
132 dimeMemHandler * const memhandler);
133 virtual bool traverse(const dimeState * const state,
134 dimeCallback callback,
135 void *userdata);
136
137private:
138
139 int numCoordVertices() const;
140 int numIndexVertices() const;
141
142 int16 flags;
143
144#ifdef DIME_FIXBIG
145 int32 countM;
146 int32 countN;
147 int32 smoothCountM;
148 int32 smoothCountN;
149#else
150 int16 countM;
151 int16 countN;
152 int16 smoothCountM;
153 int16 smoothCountN;
154#endif
155
156 int16 surfaceType;
157
158 int32 coordCnt; // real # of coordinate vertices
159 int32 indexCnt; // real # of index vertices
160 int32 frameCnt;
161
162 dimeVertex **coordVertices;
163 dimeVertex **indexVertices;
164 dimeVertex **frameVertices;
165 dimeEntity *seqend;
166 dimeVec3f elevation;
167}; // class dimePolyline
168
169inline int16
170dimePolyline::getFlags() const
171{
172 return this->flags;
173}
174
175inline void
176dimePolyline::setFlags(const int16 flags)
177{
178 this->flags = flags;
179}
180
181inline const dimeVec3f &
182dimePolyline::getElevation() const
183{
184 return elevation;
185}
186
187inline void
188dimePolyline::setElevation(const dimeVec3f &e)
189{
190 this->elevation = e;
191}
192
193inline int16
194dimePolyline::getPolymeshCountN() const
195{
196 return this->countN;
197}
198
199inline int16
200dimePolyline::getPolymeshCountM() const
201{
202 return this->countM;
203}
204
205inline int16
206dimePolyline::getSmoothSurfaceMdensity() const
207{
208 return this->smoothCountM;
209}
210
211inline int16
212dimePolyline::getSmoothSurfaceNdensity() const
213{
214 return this->smoothCountN;
215}
216
217inline int
218dimePolyline::getNumCoordVertices() const
219{
220 return this->coordCnt;
221}
222
223inline int
224dimePolyline::getNumIndexVertices() const
225{
226 return this->indexCnt;
227}
228
229inline int
230dimePolyline::getNumSplineFrameControlPoints() const
231{
232 return this->frameCnt;
233}
234
235inline dimeVertex *
236dimePolyline::getCoordVertex(const int index)
237{
238 return this->coordVertices[index];
239}
240
241inline dimeVertex *
242dimePolyline::getIndexVertex(const int index)
243{
244 return this->indexVertices[index];
245}
246
247inline dimeVertex *
248dimePolyline::getSplineFrameControlPoint(const int index)
249{
250 return this->frameVertices[index];
251}
252
253inline int16
254dimePolyline::getSurfaceType() const
255{
256 return this->surfaceType;
257}
258
259inline void
260dimePolyline::setSurfaceType(const int16 type)
261{
262 this->surfaceType = type;
263}
264
265
266#endif // ! DIME_POLYLINE_H
267
The dimeEntity class is the superclass of all entity classes.
Definition Entity.h:61
virtual bool write(dimeOutput *const out)
Definition Entity.cpp:271
virtual bool read(dimeInput *const in)
Definition Entity.cpp:612
virtual void setLayer(const dimeLayer *const layer)
Definition Entity.cpp:648
virtual const char * getEntityName() const =0
virtual GeometryType extractGeometry(dimeArray< dimeVec3f > &verts, dimeArray< int > &indices, dimeVec3f &extrusionDir, dxfdouble &thickness)
Definition Entity.cpp:583
virtual dimeEntity * copy(dimeModel *const model) const =0
virtual bool traverse(const dimeState *const state, dimeCallback callback, void *userdata)
Definition Entity.cpp:541
The dimeExtrusionEntity class is the superclass of all entity classes with extrusion data.
Definition ExtrusionEntity.h:39
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition ExtrusionEntity.cpp:135
virtual int typeId() const
Definition ExtrusionEntity.cpp:96
virtual int countRecords() const
Definition ExtrusionEntity.cpp:113
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition ExtrusionEntity.cpp:155
The dimeInput class offers transparent file I/O for DXF and DXB.
Definition Input.h:42
The dimeLayer class handles layers.
Definition Layer.h:39
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 dimePolyline class handles a POLYLINE entity.
Definition Polyline.h:45
The dimeState class manages various state variables while the model is traversed.
Definition State.h:41
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition Linear.h:62
The dimeVertex class handles a VERTEX entity.
Definition Vertex.h:43
The dimeParam class is a union of the different parameter types.
Definition Basic.h:102