Entity.h
1 /**************************************************************************\
2  *
3  * FILE: Entity.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_ENTITY_H
31 #define DIME_ENTITY_H
32 
33 #include <dime/Base.h>
34 #include <dime/Basic.h>
35 #include <dime/util/Array.h>
36 #include <dime/util/Linear.h>
37 #include <dime/RecordHolder.h>
38 
39 
40 // misc flag values used in entityFlags.
41 #define FLAG_DELETED 0x0001 // used by dimeEntity
42 #define FLAG_TMP_BUFFER_SET 0x0002 // see dimeEntity::read()
43 #define FLAG_VERTICES_FOLLOW 0x0004 // used by dimePolyline
44 #define FLAG_TAGGED 0x0008 // used by dimeEntity
45 #define FLAG_COLOR_NUMBER 0x0010 // signals a color number was read
46 #define FLAG_SUBCLASS_MARKER 0x0020 // will subclass marker need to be written
47 #define FLAG_HANDLE 0x0040 // entity has handle in RecordHolder
48 #define FLAG_ACAD_REACTORS 0x0080 // ACAD reactors in entity
49 #define FLAG_ACAD_XDICTIONARY 0x0100 // ACAD xdictionary in entity
50 #define FLAG_PAPERSPACE 0x0200 // entity is in paperspace
51 #define FLAG_LINETYPE 0x0400 // linetype specified in entity
52 #define FLAG_FIRST_FREE 0x0800 // use this if you want to define your own flags
53 
54 class dimeLayer;
55 class dimeModel;
56 
57 class DIME_DLL_API dimeEntity : public dimeRecordHolder
58 {
59  friend class dimeEntitiesSection;
60  friend class dimeModel;
61  friend class dimePolyline;
62  friend class dimeBlock;
63  friend class dimeInsert;
64 
65 public:
66  dimeEntity();
67  virtual ~dimeEntity();
68 
69  int16 getEntityFlags() const;
70  void setEntityFlags(const int16 flags);
71 
72  int16 getColorNumber() const;
73  void setColorNumber(const int16 c);
74 
75  virtual void setLayer(const dimeLayer * const layer);
76  virtual const char *getEntityName() const = 0;
77 
78  const dimeLayer *getLayer() const;
79  const char *getLayerName() const;
80 
81  virtual dimeEntity *copy(dimeModel * const model) const = 0;
82  virtual bool read(dimeInput * const in);
83  virtual bool write(dimeOutput * const out);
84  virtual bool isOfType(const int thetypeid) const;
85  virtual int countRecords() const;
86  virtual void print() const {}
87 
88 
89  bool isDeleted() const;
90  void setDeleted(const bool onOff = true);
91 
92  bool isTagged() const;
93  void setTagged(const bool onOff = true);
94 
95  virtual bool getRecord(const int groupcode,
96  dimeParam &param,
97  const int index = 0) const;
98 
99  enum GeometryType {
100  NONE,
101  POLYGONS,
102  LINES,
103  POINTS
104  };
105 
106  virtual GeometryType extractGeometry(dimeArray <dimeVec3f> &verts,
107  dimeArray <int> &indices,
108  dimeVec3f &extrusionDir,
109  dxfdouble &thickness);
110 protected:
111 
112  bool preWrite(dimeOutput * const file);
113 
114  virtual bool traverse(const dimeState * const state,
115  dimeCallback callback,
116  void *userdata);
117 
118  virtual void fixReferences(dimeModel * const model);
119  virtual bool handleRecord(const int groupcode,
120  const dimeParam &param,
121  dimeMemHandler * const memhandler);
122  virtual bool shouldWriteRecord(const int groupcode) const;
123 
124 public:
125  static dimeEntity *createEntity(const char * const name,
126  dimeMemHandler * const memhandler = NULL);
127  static bool readEntities(dimeInput * const file,
128  dimeArray <dimeEntity*> &array,
129  const char * const stopat);
130 
131  static bool copyEntityArray(const dimeEntity *const*const array,
132  const int nument,
133  dimeModel * const model,
134  dimeArray <dimeEntity*> &destarray);
135  static dimeEntity **copyEntityArray(const dimeEntity *const*const array,
136  int &nument,
137  dimeModel * const model);
138 
139  static void arbitraryAxis(const dimeVec3f &givenaxis, dimeVec3f &newaxis);
140  static void generateUCS(const dimeVec3f &givenaxis, dimeMatrix &m);
141 
142 protected:
143  bool copyRecords(dimeEntity * const entity, dimeModel * const model) const;
144 
145 private:
146  const dimeLayer *layer;
147  int16 entityFlags;
148  int16 colorNumber;
149 }; // class dimeEntity
150 
151 inline const dimeLayer *
153 {
154  return this->layer;
155 }
156 
157 inline int16
159 {
160  return this->colorNumber;
161 }
162 
163 inline void
165 {
166  this->colorNumber = c;
167 }
168 
169 inline int16
170 dimeEntity::getEntityFlags() const
171 {
172  return this->entityFlags;
173 }
174 
175 inline void
176 dimeEntity::setEntityFlags(const int16 flags)
177 {
178  this->entityFlags = flags;
179 }
180 
181 
182 
183 #endif // ! DIME_ENTITY_H
184 

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