00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DIME_ENTITY_H
00031 #define DIME_ENTITY_H
00032
00033 #include <dime/Base.h>
00034 #include <dime/Basic.h>
00035 #include <dime/util/Array.h>
00036 #include <dime/util/Linear.h>
00037 #include <dime/RecordHolder.h>
00038
00039
00040
00041 #define FLAG_DELETED 0x0001 // used by dimeEntity
00042 #define FLAG_TMP_BUFFER_SET 0x0002 // see dimeEntity::read()
00043 #define FLAG_VERTICES_FOLLOW 0x0004 // used by dimePolyline
00044 #define FLAG_TAGGED 0x0008 // used by dimeEntity
00045 #define FLAG_COLOR_NUMBER 0x0010 // signals a color number was read
00046 #define FLAG_SUBCLASS_MARKER 0x0020 // will subclass marker need to be written
00047 #define FLAG_HANDLE 0x0040 // entity has handle in RecordHolder
00048 #define FLAG_ACAD_REACTORS 0x0080 // ACAD reactors in entity
00049 #define FLAG_ACAD_XDICTIONARY 0x0100 // ACAD xdictionary in entity
00050 #define FLAG_PAPERSPACE 0x0200 // entity is in paperspace
00051 #define FLAG_LINETYPE 0x0400 // linetype specified in entity
00052 #define FLAG_FIRST_FREE 0x0800 // use this if you want to define your own flags
00053
00054 class dimeLayer;
00055
00056 class DIME_DLL_API dimeEntity : public dimeRecordHolder
00057 {
00058 friend class dimeEntitiesSection;
00059 friend class dimeModel;
00060 friend class dimePolyline;
00061 friend class dimeBlock;
00062 friend class dimeInsert;
00063
00064 public:
00065 dimeEntity();
00066 virtual ~dimeEntity();
00067
00068 int16 getEntityFlags() const;
00069 void setEntityFlags(const int16 flags);
00070
00071 int16 getColorNumber() const;
00072 void setColorNumber(const int16 c);
00073
00074 virtual void setLayer(const dimeLayer * const layer);
00075 virtual const char *getEntityName() const = 0;
00076
00077 const dimeLayer *getLayer() const;
00078 const char *getLayerName() const;
00079
00080 virtual dimeEntity *copy(dimeModel * const model) const = 0;
00081 virtual bool read(dimeInput * const in);
00082 virtual bool write(dimeOutput * const out);
00083 virtual bool isOfType(const int thetypeid) const;
00084 virtual int countRecords() const;
00085 virtual void print() const {}
00086
00087
00088 bool isDeleted() const;
00089 void setDeleted(const bool onOff = true);
00090
00091 bool isTagged() const;
00092 void setTagged(const bool onOff = true);
00093
00094 virtual bool getRecord(const int groupcode,
00095 dimeParam ¶m,
00096 const int index = 0) const;
00097
00098 enum GeometryType {
00099 NONE,
00100 POLYGONS,
00101 LINES,
00102 POINTS
00103 };
00104
00105 virtual GeometryType extractGeometry(dimeArray <dimeVec3f> &verts,
00106 dimeArray <int> &indices,
00107 dimeVec3f &extrusionDir,
00108 dxfdouble &thickness);
00109 protected:
00110
00111 bool preWrite(dimeOutput * const file);
00112
00113 virtual bool traverse(const dimeState * const state,
00114 dimeCallback callback,
00115 void *userdata);
00116
00117 virtual void fixReferences(dimeModel * const model);
00118 virtual bool handleRecord(const int groupcode,
00119 const dimeParam ¶m,
00120 dimeMemHandler * const memhandler);
00121 virtual bool shouldWriteRecord(const int groupcode) const;
00122
00123 public:
00124 static dimeEntity *createEntity(const char * const name,
00125 dimeMemHandler * const memhandler = NULL);
00126 static bool readEntities(dimeInput * const file,
00127 dimeArray <dimeEntity*> &array,
00128 const char * const stopat);
00129
00130 static bool copyEntityArray(const dimeEntity *const*const array,
00131 const int nument,
00132 dimeModel * const model,
00133 dimeArray <dimeEntity*> &destarray);
00134 static dimeEntity **copyEntityArray(const dimeEntity *const*const array,
00135 int &nument,
00136 dimeModel * const model);
00137
00138 static void arbitraryAxis(const dimeVec3f &givenaxis, dimeVec3f &newaxis);
00139 static void generateUCS(const dimeVec3f &givenaxis, dimeMatrix &m);
00140
00141 protected:
00142 bool copyRecords(dimeEntity * const entity, dimeModel * const model) const;
00143
00144 private:
00145 const dimeLayer *layer;
00146 int16 entityFlags;
00147 int16 colorNumber;
00148 };
00149
00150 inline const dimeLayer *
00151 dimeEntity::getLayer() const
00152 {
00153 return this->layer;
00154 }
00155
00156 inline int16
00157 dimeEntity::getColorNumber() const
00158 {
00159 return this->colorNumber;
00160 }
00161
00162 inline void
00163 dimeEntity::setColorNumber(const int16 c)
00164 {
00165 this->colorNumber = c;
00166 }
00167
00168 inline int16
00169 dimeEntity::getEntityFlags() const
00170 {
00171 return this->entityFlags;
00172 }
00173
00174 inline void
00175 dimeEntity::setEntityFlags(const int16 flags)
00176 {
00177 this->entityFlags = flags;
00178 }
00179
00180
00181
00182 #endif // ! DIME_ENTITY_H
00183