| http://www.coin3d.org/ http://www.kongsberg.com/kogt/

Entity.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_ENTITY_H
34 #define DIME_ENTITY_H
35
36 #include <dime/Base.h>
37 #include <dime/Basic.h>
38 #include <dime/util/Array.h>
39 #include <dime/util/Linear.h>
40 #include <dime/RecordHolder.h>
41
42
43 // misc flag values used in entityFlags.
44 #define FLAG_DELETED 0x0001 // used by dimeEntity
45 #define FLAG_TMP_BUFFER_SET 0x0002 // see dimeEntity::read()
46 #define FLAG_VERTICES_FOLLOW 0x0004 // used by dimePolyline
47 #define FLAG_TAGGED 0x0008 // used by dimeEntity
48 #define FLAG_COLOR_NUMBER 0x0010 // signals a color number was read
49 #define FLAG_SUBCLASS_MARKER 0x0020 // will subclass marker need to be written
50 #define FLAG_HANDLE 0x0040 // entity has handle in RecordHolder
51 #define FLAG_ACAD_REACTORS 0x0080 // ACAD reactors in entity
52 #define FLAG_ACAD_XDICTIONARY 0x0100 // ACAD xdictionary in entity
53 #define FLAG_PAPERSPACE 0x0200 // entity is in paperspace
54 #define FLAG_LINETYPE 0x0400 // linetype specified in entity
55 #define FLAG_FIRST_FREE 0x0800 // use this if you want to define your own flags
56
57 class dimeLayer;
58 class dimeModel;
59
60 class DIME_DLL_API dimeEntity : public dimeRecordHolder
61 {
62 friend class dimeEntitiesSection;
63 friend class dimeModel;
64 friend class dimePolyline;
65 friend class dimeBlock;
66 friend class dimeInsert;
67
68 public:
69 dimeEntity();
70 virtual ~dimeEntity();
71
72 int16 getEntityFlags() const;
73 void setEntityFlags(const int16 flags);
74
75 int16 getColorNumber() const;
76 void setColorNumber(const int16 c);
77
78 virtual void setLayer(const dimeLayer * const layer);
79 virtual const char *getEntityName() const = 0;
80
81 const dimeLayer *getLayer() const;
82 const char *getLayerName() const;
83
84 virtual dimeEntity *copy(dimeModel * const model) const = 0;
85 virtual bool read(dimeInput * const in);
86 virtual bool write(dimeOutput * const out);
87 virtual bool isOfType(const int thetypeid) const;
88 virtual int countRecords() const;
89 virtual void print() const {}
90
91
92 bool isDeleted() const;
93 void setDeleted(const bool onOff = true);
94
95 bool isTagged() const;
96 void setTagged(const bool onOff = true);
97
98 virtual bool getRecord(const int groupcode,
99 dimeParam &param,
100 const int index = 0) const;
101
102 enum GeometryType {
103 NONE,
104 POLYGONS,
105 LINES,
106 POINTS
107 };
108
109 virtual GeometryType extractGeometry(dimeArray <dimeVec3f> &verts,
110 dimeArray <int> &indices,
111 dimeVec3f &extrusionDir,
112 dxfdouble &thickness);
113 protected:
114
115 bool preWrite(dimeOutput * const file);
116
117 virtual bool traverse(const dimeState * const state,
118 dimeCallback callback,
119 void *userdata);
120
121 virtual void fixReferences(dimeModel * const model);
122 virtual bool handleRecord(const int groupcode,
123 const dimeParam &param,
124 dimeMemHandler * const memhandler);
125 virtual bool shouldWriteRecord(const int groupcode) const;
126
127 public:
128 static dimeEntity *createEntity(const char * const name,
129 dimeMemHandler * const memhandler = NULL);
130 static bool readEntities(dimeInput * const file,
131 dimeArray <dimeEntity*> &array,
132 const char * const stopat);
133
134 static bool copyEntityArray(const dimeEntity *const*const array,
135 const int nument,
136 dimeModel * const model,
137 dimeArray <dimeEntity*> &destarray);
138 static dimeEntity **copyEntityArray(const dimeEntity *const*const array,
139 int &nument,
140 dimeModel * const model);
141
142 static void arbitraryAxis(const dimeVec3f &givenaxis, dimeVec3f &newaxis);
143 static void generateUCS(const dimeVec3f &givenaxis, dimeMatrix &m);
144
145 protected:
146 bool copyRecords(dimeEntity * const entity, dimeModel * const model) const;
147
148 private:
149 const dimeLayer *layer;
150 int16 entityFlags;
151 int16 colorNumber;
152 }; // class dimeEntity
153
154 inline const dimeLayer *
155 dimeEntity::getLayer() const
156 {
157 return this->layer;
158 }
159
160 inline int16
161 dimeEntity::getColorNumber() const
162 {
163 return this->colorNumber;
164 }
165
166 inline void
167 dimeEntity::setColorNumber(const int16 c)
168 {
169 this->colorNumber = c;
170 }
171
172 inline int16
173 dimeEntity::getEntityFlags() const
174 {
175 return this->entityFlags;
176 }
177
178 inline void
179 dimeEntity::setEntityFlags(const int16 flags)
180 {
181 this->entityFlags = flags;
182 }
183
184
185
186 #endif // ! DIME_ENTITY_H
187
dimeRecordHolder::countRecords
virtual int countRecords() const
Definition: RecordHolder.cpp:348
dimeInsert::copy
virtual dimeEntity * copy(dimeModel *const model) const
Definition: Insert.cpp:86
dimePolyline
The dimePolyline class handles a POLYLINE entity.
Definition: Polyline.h:44
dimeArray< dimeVec3f >
dimeEntity::copyEntityArray
static bool copyEntityArray(const dimeEntity *const *const array, const int nument, dimeModel *const model, dimeArray< dimeEntity *> &destarray)
Definition: Entity.cpp:426
dimeEntity::getLayer
const dimeLayer * getLayer() const
Definition: Entity.h:155
dimeEntity::isTagged
bool isTagged() const
Definition: Entity.cpp:246
dimeInsert::traverse
virtual bool traverse(const dimeState *const state, dimeCallback callback, void *userdata)
Definition: Insert.cpp:402
dimeEntity::readEntities
static bool readEntities(dimeInput *const file, dimeArray< dimeEntity *> &array, const char *const stopat)
Definition: Entity.cpp:340
dimeEntity::arbitraryAxis
static void arbitraryAxis(const dimeVec3f &givenaxis, dimeVec3f &newaxis)
Definition: Entity.cpp:491
dimeEntity::dimeEntity
dimeEntity()
Definition: Entity.cpp:181
dimeInsert::fixReferences
virtual void fixReferences(dimeModel *const model)
Definition: Insert.cpp:442
dimeEntity::preWrite
bool preWrite(dimeOutput *const file)
Definition: Entity.cpp:738
dimeState
The dimeState class manages various state variables while the model is traversed. ...
Definition: State.h:40
dimeMemHandler
The dimeMemHandler class is a special-purpose memory manager.
Definition: MemHandler.h:38
dimeEntity::getColorNumber
int16 getColorNumber() const
Definition: Entity.h:161
dimeRecordHolder
The dimeRecordHolder class is a superclass for objects that store records.
Definition: RecordHolder.h:43
dimeEntity::generateUCS
static void generateUCS(const dimeVec3f &givenaxis, dimeMatrix &m)
Definition: Entity.cpp:513
dimeEntity::setColorNumber
void setColorNumber(const int16 c)
Definition: Entity.h:167
dimeEntity
The dimeEntity class is the superclass of all entity classes.
Definition: Entity.h:60
dimeRecordHolder::shouldWriteRecord
virtual bool shouldWriteRecord(const int groupcode) const
Definition: RecordHolder.cpp:379
dimeInsert::getEntityName
virtual const char * getEntityName() const
Definition: Insert.cpp:342
dimeRecordHolder::write
virtual bool write(dimeOutput *const out)
Definition: RecordHolder.cpp:175
dimeEntity::isDeleted
bool isDeleted() const
Definition: Entity.cpp:220
dimeModel
The dimeModel class organizes a model.
Definition: Model.h:54
dimeRecordHolder::getRecord
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition: RecordHolder.cpp:261
dimeEntitiesSection
The dimeEntitiesSection class handles an ENTITIES section.
Definition: EntitiesSection.h:39
dimeInput
The dimeInput class offers transparent file I/O for DXF and DXB.
Definition: Input.h:41
dimeVec3f
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition: Linear.h:61
dimeEntity::setDeleted
void setDeleted(const bool onOff=true)
Definition: Entity.cpp:231
dimeEntity::getLayerName
const char * getLayerName() const
Definition: Entity.cpp:463
dimeRecordHolder::read
virtual bool read(dimeInput *const in)
Definition: RecordHolder.cpp:119
dimeParam
The dimeParam class is a union of the different parameter types.
Definition: Basic.h:102
dimeEntity::~dimeEntity
virtual ~dimeEntity()
Definition: Entity.cpp:191
dimeRecordHolder::copyRecords
bool copyRecords(dimeRecordHolder *const rh, dimeMemHandler *const memhandler) const
Definition: RecordHolder.cpp:89
dimeInsert
The dimeInsert class handles an INSERT entity.
Definition: Insert.h:42
dimeRecordHolder::handleRecord
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition: RecordHolder.cpp:204
dimeMatrix
The dimeMatrix class is for containing and operating on a four-by-four matrix.
Definition: Linear.h:158
dimeEntity::extractGeometry
virtual GeometryType extractGeometry(dimeArray< dimeVec3f > &verts, dimeArray< int > &indices, dimeVec3f &extrusionDir, dxfdouble &thickness)
Definition: Entity.cpp:583
dimeBlock
The dimeBlock class handles a BLOCK entity.
Definition: Block.h:45
dimeEntity::setLayer
virtual void setLayer(const dimeLayer *const layer)
Definition: Entity.cpp:648
dimeEntity::createEntity
static dimeEntity * createEntity(const char *const name, dimeMemHandler *const memhandler=NULL)
Definition: Entity.cpp:281
dimeOutput
The dimeOutput class handles writing of DXF and DXB files.
Definition: Output.h:41
dimeRecordHolder::isOfType
virtual bool isOfType(const int thetypeid) const
Definition: RecordHolder.cpp:78
dimeLayer
The dimeLayer class handles layers.
Definition: Layer.h:38
dimeEntity::setTagged
void setTagged(const bool onOff=true)
Definition: Entity.cpp:256

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.