|
http://www.sim.no http://www.coin3d.org |
00001 /**************************************************************************\ 00002 * 00003 * FILE: Entity.h 00004 * 00005 * This source file is part of DIME. 00006 * Copyright (C) 1998-1999 by Systems In Motion. All rights reserved. 00007 * 00008 * This library is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License, version 2, as 00010 * published by the Free Software Foundation. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License (the accompanying file named COPYING) for more 00016 * details. 00017 * 00018 ************************************************************************** 00019 * 00020 * If you need DIME for a non-GPL project, contact Systems In Motion 00021 * to acquire a Professional Edition License: 00022 * 00023 * Systems In Motion http://www.sim.no/ 00024 * Prof. Brochs gate 6 sales@sim.no 00025 * N-7030 Trondheim Voice: +47 22114160 00026 * NORWAY Fax: +47 67172912 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 // misc flag values used in entityFlags. 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 }; // class dimeEntity 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
Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.
Generated on Tue Dec 2 23:27:14 2008 for DIME by Doxygen. 1.4.7