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 class dimeModel;
00056
00057 class DIME_DLL_API dimeEntity : public dimeRecordHolder
00058 {
00059 friend class dimeEntitiesSection;
00060 friend class dimeModel;
00061 friend class dimePolyline;
00062 friend class dimeBlock;
00063 friend class dimeInsert;
00064
00065 public:
00066 dimeEntity();
00067 virtual ~dimeEntity();
00068
00069 int16 getEntityFlags() const;
00070 void setEntityFlags(const int16 flags);
00071
00072 int16 getColorNumber() const;
00073 void setColorNumber(const int16 c);
00074
00075 virtual void setLayer(const dimeLayer * const layer);
00076 virtual const char *getEntityName() const = 0;
00077
00078 const dimeLayer *getLayer() const;
00079 const char *getLayerName() const;
00080
00081 virtual dimeEntity *copy(dimeModel * const model) const = 0;
00082 virtual bool read(dimeInput * const in);
00083 virtual bool write(dimeOutput * const out);
00084 virtual bool isOfType(const int thetypeid) const;
00085 virtual int countRecords() const;
00086 virtual void print() const {}
00087
00088
00089 bool isDeleted() const;
00090 void setDeleted(const bool onOff = true);
00091
00092 bool isTagged() const;
00093 void setTagged(const bool onOff = true);
00094
00095 virtual bool getRecord(const int groupcode,
00096 dimeParam ¶m,
00097 const int index = 0) const;
00098
00099 enum GeometryType {
00100 NONE,
00101 POLYGONS,
00102 LINES,
00103 POINTS
00104 };
00105
00106 virtual GeometryType extractGeometry(dimeArray <dimeVec3f> &verts,
00107 dimeArray <int> &indices,
00108 dimeVec3f &extrusionDir,
00109 dxfdouble &thickness);
00110 protected:
00111
00112 bool preWrite(dimeOutput * const file);
00113
00114 virtual bool traverse(const dimeState * const state,
00115 dimeCallback callback,
00116 void *userdata);
00117
00118 virtual void fixReferences(dimeModel * const model);
00119 virtual bool handleRecord(const int groupcode,
00120 const dimeParam ¶m,
00121 dimeMemHandler * const memhandler);
00122 virtual bool shouldWriteRecord(const int groupcode) const;
00123
00124 public:
00125 static dimeEntity *createEntity(const char * const name,
00126 dimeMemHandler * const memhandler = NULL);
00127 static bool readEntities(dimeInput * const file,
00128 dimeArray <dimeEntity*> &array,
00129 const char * const stopat);
00130
00131 static bool copyEntityArray(const dimeEntity *const*const array,
00132 const int nument,
00133 dimeModel * const model,
00134 dimeArray <dimeEntity*> &destarray);
00135 static dimeEntity **copyEntityArray(const dimeEntity *const*const array,
00136 int &nument,
00137 dimeModel * const model);
00138
00139 static void arbitraryAxis(const dimeVec3f &givenaxis, dimeVec3f &newaxis);
00140 static void generateUCS(const dimeVec3f &givenaxis, dimeMatrix &m);
00141
00142 protected:
00143 bool copyRecords(dimeEntity * const entity, dimeModel * const model) const;
00144
00145 private:
00146 const dimeLayer *layer;
00147 int16 entityFlags;
00148 int16 colorNumber;
00149 };
00150
00151 inline const dimeLayer *
00152 dimeEntity::getLayer() const
00153 {
00154 return this->layer;
00155 }
00156
00157 inline int16
00158 dimeEntity::getColorNumber() const
00159 {
00160 return this->colorNumber;
00161 }
00162
00163 inline void
00164 dimeEntity::setColorNumber(const int16 c)
00165 {
00166 this->colorNumber = c;
00167 }
00168
00169 inline int16
00170 dimeEntity::getEntityFlags() const
00171 {
00172 return this->entityFlags;
00173 }
00174
00175 inline void
00176 dimeEntity::setEntityFlags(const int16 flags)
00177 {
00178 this->entityFlags = flags;
00179 }
00180
00181
00182
00183 #endif // ! DIME_ENTITY_H
00184