dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
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
57class dimeLayer;
58class dimeModel;
59
60class 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
68public:
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);
113protected:
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
127public:
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
145protected:
146 bool copyRecords(dimeEntity * const entity, dimeModel * const model) const;
147
148private:
149 const dimeLayer *layer;
150 int16 entityFlags;
151 int16 colorNumber;
152}; // class dimeEntity
153
154inline const dimeLayer *
156{
157 return this->layer;
158}
159
160inline int16
162{
163 return this->colorNumber;
164}
165
166inline void
168{
169 this->colorNumber = c;
170}
171
172inline int16
173dimeEntity::getEntityFlags() const
174{
175 return this->entityFlags;
176}
177
178inline void
179dimeEntity::setEntityFlags(const int16 flags)
180{
181 this->entityFlags = flags;
182}
183
184
185
186#endif // ! DIME_ENTITY_H
187
The dimeBlock class handles a BLOCK entity.
Definition Block.h:46
The dimeEntitiesSection class handles an ENTITIES section.
Definition EntitiesSection.h:40
The dimeEntity class is the superclass of all entity classes.
Definition Entity.h:61
const dimeLayer * getLayer() const
Definition Entity.h:155
virtual const char * getEntityName() const =0
void setColorNumber(const int16 c)
Definition Entity.h:167
virtual dimeEntity * copy(dimeModel *const model) const =0
int16 getColorNumber() const
Definition Entity.h:161
The dimeInput class offers transparent file I/O for DXF and DXB.
Definition Input.h:42
The dimeInsert class handles an INSERT entity.
Definition Insert.h:43
The dimeLayer class handles layers.
Definition Layer.h:39
The dimeMatrix class is for containing and operating on a four-by-four matrix.
Definition Linear.h:159
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 dimeRecordHolder class is a superclass for objects that store records.
Definition RecordHolder.h:44
bool copyRecords(dimeRecordHolder *const rh, dimeMemHandler *const memhandler) const
Definition RecordHolder.cpp:89
virtual bool read(dimeInput *const in)
Definition RecordHolder.cpp:119
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition RecordHolder.cpp:204
virtual bool isOfType(const int thetypeid) const
Definition RecordHolder.cpp:78
virtual bool write(dimeOutput *const out)
Definition RecordHolder.cpp:175
virtual bool shouldWriteRecord(const int groupcode) const
Definition RecordHolder.cpp:380
virtual int countRecords() const
Definition RecordHolder.cpp:348
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition RecordHolder.cpp:261
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 dimeParam class is a union of the different parameter types.
Definition Basic.h:102