cgma
|
00001 //- Class: CubitAttrib 00002 //- Owner: Greg Nielson 00003 //- Description: pure virtual base class from which all the specific 00004 //- cubit attributes are derived. 00005 //- Checked By: 00006 //- Version: 00007 00008 #ifndef CUBIT_ATTRIB_HPP 00009 #define CUBIT_ATTRIB_HPP 00010 00011 #include "CubitString.hpp" 00012 #include "CubitDefines.h" 00013 #include "CubitVector.hpp" 00014 00015 #include "CubitAttribManager.hpp" 00016 #include "CGMApp.hpp" 00017 #include "CGMGeomConfigure.h" 00018 #include "CubitSimpleAttrib.hpp" 00019 00020 class RefEntity; 00021 template <class X> class DLIList; 00022 class CubitSimpleAttrib; 00023 class CubitAttribUser; 00024 00025 // this enum used to index static arrays; first attribute must start at 0, 00026 // last attribute must be CA_LAST_CA (some static arrays dimensioned using 00027 // this item) 00028 /* 00029 enum CubitAttributeType { 00030 CA_UNDEFINED = -1, 00031 CA_MERGE_PARTNER = 0, // must be 0!!! 00032 CA_ENTITY_NAME, 00033 CA_GROUP, 00034 CA_ENTITY_ID, 00035 // CA_PARTITION_VG, 00036 // CA_COMPOSITE_VG, 00037 // CA_VIRTUAL_VG, 00038 CA_UNIQUE_ID, 00039 CA_DEFERRED_ATTRIB, 00040 CA_MESH_INTERVAL, 00041 CA_MESH_RELATIVE_LENGTH, 00042 CA_GENESIS_ENTITY, 00043 CA_MESH_SCHEME, 00044 CA_SMOOTH_SCHEME, 00045 CA_VERTEX_TYPE, 00046 CA_MESH_CONTAINER, 00047 CA_BODIES, 00048 CA_ENTITY_COLOR, 00049 #ifdef CAT 00050 CA_VERTEX_FORCE, 00051 CA_SURFACE_FORCE, 00052 CA_CURVE_FORCE, 00053 CA_VERTEX_DISPLACEMENT, 00054 CA_SURFACE_DISPLACEMENT, 00055 CA_CURVE_DISPLACEMENT, 00056 CA_VOLUME_DISPLACEMENT, 00057 CA_SURFACE_PRESSURE, 00058 CA_CURVE_PRESSURE, 00059 CA_SURFACE_TEMPERATURE, 00060 CA_CURVE_TEMPERATURE, 00061 CA_VERTEX_TEMPERATURE, 00062 CA_SURFACE_HEATFLUX, 00063 CA_CURVE_HEATFLUX, 00064 CA_SURFACE_CONVECTION, 00065 CA_CURVE_CONVECTION, 00066 CA_SURFACE_CONTACT, 00067 CA_CURVE_CONTACT, 00068 #endif 00069 CA_MERGE_STATUS, 00070 CA_LAST_CA // must be last item!!! 00071 }; 00072 */ 00073 class CubitAttrib; 00074 00075 class CUBIT_GEOM_EXPORT CubitAttribFactory 00076 { 00077 public: 00078 friend class CubitAttrib; 00079 00080 protected: 00081 CubitAttribFactory() {}; 00082 00083 virtual ~CubitAttribFactory() {}; 00084 00085 private: 00086 virtual CubitAttrib *create_cubit_attrib(const int attrib_type, 00087 RefEntity *entity) = 0; 00088 00089 virtual CubitAttrib *create_cubit_attrib(CubitSimpleAttrib *csa_ptr, 00090 RefEntity *entity) = 0; 00091 }; 00092 00093 class CUBIT_GEOM_EXPORT CubitAttrib 00094 { 00095 public: 00096 00097 CubitAttrib(RefEntity *attrib_owner); 00098 //- bare constructor 00099 00100 virtual ~CubitAttrib(); 00101 //- destructor 00102 00103 // static CubitAttrib *create_cubit_attrib(const int attrib_type, 00104 // RefEntity *entity); 00105 //- create a cubit attribute of the specified type and pass it back 00106 00107 // static CubitAttrib *create_cubit_attrib(CubitSimpleAttrib *csa_ptr, 00108 // RefEntity *entity); 00109 //- create a cubit attribute from a CSA and pass it back 00110 00111 //HEADER-: get/set functions 00112 00113 RefEntity* attrib_owner() {return attribOwnerEntity;} 00114 void attrib_owner(RefEntity* new_attrib_owner) 00115 {attribOwnerEntity = new_attrib_owner;} 00116 //- get/set the attrib owner 00117 00118 CubitBoolean has_actuated() {return hasActuated;} 00119 void has_actuated(CubitBoolean set_has_actuated) 00120 { hasActuated = set_has_actuated;} 00121 //- get/set hasActuated 00122 00123 CubitBoolean has_updated() {return hasUpdated;} 00124 void has_updated(CubitBoolean set_has_updated) 00125 { hasUpdated = set_has_updated;} 00126 //- get/set hasUpdated 00127 00128 virtual CubitBoolean has_written() const; 00129 virtual void has_written(CubitBoolean set_has_written); 00130 //- get/set hasWritten 00131 00132 void delete_attrib(CubitBoolean set_remove) {deleteAttrib = set_remove;} 00133 CubitBoolean delete_attrib() {return deleteAttrib;} 00134 //- get/set the deleteAttrib flag 00135 00136 CubitAttrib* next_attrib() {return nextAttrib;} 00137 CubitStatus set_next_attrib(CubitAttrib* next_attrib_ptr); 00138 //- get/set the next attribute in the chain 00139 00140 // static CubitStatus auto_create_attribs(CubitAttribUser *cau); 00141 //- create attribs whose auto update flag is set 00142 00143 // static CubitStatus auto_update_attribs(CubitAttribUser *cau); 00144 //- create attribs whose auto update flag is set 00145 00146 // static void auto_actuate_flag(int attrib_type, CubitBoolean value); 00147 // static CubitBoolean auto_actuate_flag(int attrib_type); 00148 // static void auto_update_flag(int attrib_type, CubitBoolean value); 00149 // static CubitBoolean auto_update_flag(int attrib_type); 00150 // static void auto_write_flag(int attrib_type, CubitBoolean value); 00151 // static CubitBoolean auto_write_flag(int attrib_type); 00152 // static void auto_read_flag(int attrib_type, CubitBoolean value); 00153 // static CubitBoolean auto_read_flag(int attrib_type); 00154 //- get/set actuate, update, write, and read flags, static versions 00155 00156 // static CubitBoolean* auto_read_flag_ptr(int attrib_type); 00157 // static CubitBoolean* auto_actuate_flag_ptr(int attrib_type); 00158 // static CubitBoolean* auto_update_flag_ptr(int attrib_type); 00159 // static CubitBoolean* auto_write_flag_ptr(int attrib_type); 00160 //- get array ptr for actuate, update, write, and read flags, static versions 00161 00162 // static void auto_flag(int flag); 00163 // static int auto_flag(); 00164 //- get/set all attribute flags 00165 //- returns -1, 0 or 1. 00166 00167 void auto_actuate_flag(CubitBoolean value); 00168 CubitBoolean auto_actuate_flag(); 00169 void auto_update_flag(CubitBoolean value); 00170 CubitBoolean auto_update_flag(); 00171 void auto_write_flag(CubitBoolean value); 00172 CubitBoolean auto_write_flag(); 00173 void auto_read_flag(CubitBoolean value); 00174 CubitBoolean auto_read_flag(); 00175 //- get/set actuate, update, write, and read flags, non-static versions 00176 00177 CubitBoolean actuate_in_constructor(); 00178 //- return value of actuateInConstructor for this attribute type 00179 00180 CubitBoolean actuate_after_geom_changes(); 00181 //- return value of actuateAfterGeomChanges for this attribute type 00182 00183 // static CubitBoolean overwrite_flag() {return overwriteFlag;} 00184 // static void overwrite_flag(CubitBoolean flag) {overwriteFlag = flag;} 00185 //- get/set overwriteFlag 00186 00187 virtual CubitSimpleAttrib cubit_simple_attrib() = 0; 00188 //- return a cubitSimpleAttrib for this CA 00189 00190 virtual CubitStatus actuate() = 0; 00191 //- actuate this attrib 00192 00193 virtual CubitStatus actuate_list(DLIList<RefEntity*>); 00194 //- actuate this attrib on each of the entities passed in 00195 00196 virtual CubitStatus update() = 0; 00197 //- update this attrib 00198 00199 virtual CubitStatus reset() = 0; 00200 //- reset any lists or other info in this attribute 00201 00202 virtual CubitSimpleAttrib split_owner(); 00203 //- split this attrib; pass back a new simple attrib if desired 00204 00205 virtual void merge_owner(CubitAttrib *deletable_ca_ptr); 00206 //- merge this attrib with deletable_ca_ptr (keep this) 00207 00208 virtual void transf_owner(const CubitVector &matrow1, 00209 const CubitVector &matrow2, 00210 const CubitVector &matrow3, 00211 const CubitVector &translate_vec, 00212 const double scale_factor); 00213 //- transform this attrib with the data passed in 00214 00215 virtual int int_attrib_type() = 0; 00216 //- return the enumerated type of attribute 00217 00218 const char *att_internal_name() { 00219 return CGMApp::instance()->attrib_manager()->att_internal_name( int_attrib_type() ); 00220 } 00221 //- return the internal name of this attribute 00222 00223 // static const char *att_internal_name(CubitAttributeType attrib_type) { 00224 // return (attrib_type < 0 || attrib_type > CA_LAST_CA) 00225 // ? NULL : attInternalNames[attrib_type]; 00226 // } 00227 //- return the internal name of this CA given the enumerated attribute type 00228 00229 // static const char *att_name(CubitAttributeType attrib_type) { 00230 // return (attrib_type < 0 || attrib_type > CA_LAST_CA) 00231 // ? NULL : attTypeNames[attrib_type]; 00232 // } 00233 //- return the internal name of this CA given the enumerated attribute type 00234 00235 // static CubitAttributeType attrib_type(const char* name); 00236 //- Converts a string to the corresponding int 00237 00238 // static CubitAttributeType attrib_type_from_internal_name(const char* name); 00239 //- Converts an "internal name" string to the corresponding int 00240 00241 // static CubitAttributeType attrib_type(CubitSimpleAttrib *csa_ptr); 00242 //- returns the type given a simple attribute 00243 00244 // static int equivalent(CubitAttrib* first_attrib_ptr, 00245 // CubitAttrib* second_attrib_ptr); 00246 //- return true if the two ca's are equivalent 00247 00248 int equivalent(const CubitSimpleAttrib& csa_ptr); 00249 //- return true if the csa and this are equivalent 00250 00251 // static CubitBoolean attrib_exists(int attrib_type, CubitBoolean print = CUBIT_TRUE); 00252 //- find if the attrib exists, and print some details 00253 00254 virtual void print(); 00255 //- print some details about this attrib 00256 00257 // static CubitStatus import_actuate(DLIList<RefEntity*> &entity_list); 00258 //- given a Body list, actuates first the merge partner attribute 00259 //- on all entities in the list, then actuates all other types of 00260 //- attributes 00261 00262 // static void set_cubit_attrib_factory(CubitAttribFactory *factory) 00263 // {cubitAttribFactory = factory;} 00264 //- user-provided attribute factory 00265 00266 // static int number_of_attributes(); 00267 //- Returns number of defined attributes 00268 00269 // static void clear_attrib_importeds(); 00270 //- clear the attribImported array 00271 00272 // static void report_attrib_importeds(); 00273 //- print info on the attribImported array 00274 00275 protected: 00276 00277 virtual void remove_attribute(); 00278 //- Removes 'this' attribute 00279 virtual void add_attribute(); 00280 //- and adds a new one with the changed data. 00281 00282 CubitBoolean hasActuated; 00283 //- flag telling whether this CA has actuated 00284 00285 CubitBoolean hasUpdated; 00286 //- flag telling whether this CA has updated 00287 00288 CubitBoolean hasWritten; 00289 //- flag telling whether this CA has a corresponding geometry attribute 00290 //- (on the geometric entity assoc'd with the owner) 00291 00292 CubitBoolean deleteAttrib; 00293 //- flag telling whether this CA should be deleted 00294 00295 RefEntity* attribOwnerEntity; 00296 //- ref entity to which this CA is associated 00297 00298 CubitAttrib* nextAttrib; 00299 //- next attribute in the chain 00300 00301 // static const char* attTypeNames[]; 00302 //- names of attribute types 00303 00304 // static const char* attInternalNames[]; 00305 //- names of attributes, used in acis files; can't be the same as 00306 //- attTypeNames because those have to be user-recognizable and can 00307 //- be multiple words (e.g. "entity name") 00308 00309 // static CubitBoolean autoActuateFlag[CA_LAST_CA]; 00310 // static CubitBoolean autoUpdateFlag[CA_LAST_CA]; 00311 // static CubitBoolean autoWriteFlag[CA_LAST_CA]; 00312 // static CubitBoolean autoReadFlag[CA_LAST_CA]; 00313 // static CubitBoolean actuateInConstructor[CA_LAST_CA]; 00314 // static CubitBoolean actuateAfterGeomChanges[CA_LAST_CA]; 00315 //- auto flags for each type of CA 00316 00317 // static bool attribImported[CA_LAST_CA]; 00318 //- static flag used in import type reporting 00319 00320 // static CubitBoolean overwriteFlag; 00321 //- if CUBIT_TRUE, any attribute can overwrite default files 00322 //- (used for mesh container attribute default filenames) 00323 00324 private: 00325 00326 // static CubitAttribFactory *cubitAttribFactory; 00327 //- application-provided attribute factory 00328 00329 }; 00330 00331 // static versions 00332 //inline CubitBoolean CubitAttrib::auto_actuate_flag(int attrib_type) 00333 //{return autoActuateFlag[attrib_type];} 00334 00335 //inline CubitBoolean CubitAttrib::auto_update_flag(int attrib_type) 00336 //{return autoUpdateFlag[attrib_type];} 00337 00338 //inline CubitBoolean CubitAttrib::auto_write_flag(int attrib_type) 00339 //{return autoWriteFlag[attrib_type];} 00340 00341 //inline CubitBoolean CubitAttrib::auto_read_flag(int attrib_type) 00342 //{return autoReadFlag[attrib_type];} 00343 00344 //inline CubitBoolean* CubitAttrib::auto_read_flag_ptr(int attrib_type) 00345 //{return &autoReadFlag[attrib_type];} 00346 00347 //inline CubitBoolean* CubitAttrib::auto_actuate_flag_ptr(int attrib_type) 00348 //{return &autoActuateFlag[attrib_type];} 00349 00350 //inline CubitBoolean* CubitAttrib::auto_update_flag_ptr(int attrib_type) 00351 //{return &autoUpdateFlag[attrib_type];} 00352 00353 //inline CubitBoolean* CubitAttrib::auto_write_flag_ptr(int attrib_type) 00354 //{return &autoWriteFlag[attrib_type];} 00355 00356 // non-static versions 00357 inline void CubitAttrib::auto_actuate_flag(CubitBoolean value) 00358 { 00359 CGMApp::instance()->attrib_manager()->set_auto_actuate_flag(int_attrib_type(), value); 00360 } 00361 00362 inline CubitBoolean CubitAttrib::auto_actuate_flag() 00363 { 00364 return CGMApp::instance()->attrib_manager()->auto_actuate_flag(int_attrib_type()); 00365 } 00366 00367 inline CubitBoolean CubitAttrib::actuate_in_constructor() 00368 { 00369 return CGMApp::instance()->attrib_manager()->actuate_in_constructor(int_attrib_type()); 00370 } 00371 //- get/set actuate, update, write, and read flags, non-static versions 00372 00373 inline CubitBoolean CubitAttrib::actuate_after_geom_changes() 00374 { 00375 return CGMApp::instance()->attrib_manager()->actuate_after_geom_changes(int_attrib_type()); 00376 } 00377 //- get/set actuate, update, write, and read flags, non-static versions 00378 00379 inline CubitStatus CubitAttrib::set_next_attrib(CubitAttrib* next_attrib_ptr) 00380 { 00381 nextAttrib = next_attrib_ptr; 00382 return CUBIT_SUCCESS; 00383 } 00384 00385 inline CubitSimpleAttrib CubitAttrib::split_owner() 00386 { 00387 //- split this attrib; pass back a new simple attrib if desired 00388 00389 // by default, get rid of this attribute and don't copy to new entity 00390 deleteAttrib = CUBIT_TRUE; 00391 return CubitSimpleAttrib(); 00392 } 00393 00394 inline void CubitAttrib::merge_owner(CubitAttrib *) 00395 { 00396 //- merge this attrib with deletable_ca_ptr (keep this) 00397 00398 // by default, get rid of this attribute 00399 deleteAttrib = CUBIT_TRUE; 00400 return; 00401 } 00402 00403 inline void CubitAttrib::transf_owner(const CubitVector &, 00404 const CubitVector &, 00405 const CubitVector &, 00406 const CubitVector &, 00407 const double) 00408 { 00409 //- by default, do nothing 00410 } 00411 00412 //inline int CubitAttrib::number_of_attributes() 00413 //{return CA_LAST_CA;} 00414 00415 #endif 00416