cgma
|
00001 //- Class: CADeferredAttrib 00002 //- Owner: Tim Tautges 00003 //- Description: Cubit attribute for storing attributes that will be used later, 00004 //- i.e. for entities which don't yet exist in the model 00005 //- Checked by: 00006 //- Version: 00007 //- 00008 //- Deferred attributes are used to store data on one solid model entity 00009 //- which actually apply to a different entity, one which doesn't exist 00010 //- in the solid model as stored (usually something like virtual geometry) 00011 //- 00012 //- This attribute saves/updates something like this: 00013 //- 1) Normal attribute (mesh interval, scheme, etc.) updates 00014 //- 2) Normal attribute writes: 00015 //- - creates simple attribute, csa_ptr, and passes to 00016 //- GeometryEntity::append_simple_attrib 00017 //- - For virtual entities, this is implemented in 00018 //- VirtualEntity::append_simple_attrib_virt 00019 //- 3) Inside VE::append_simple_attrib_virt, the simple attribute is combined 00020 //- with a uid for the owning ref entity and the two are used to make a 00021 //- new *simple* deferred attribute 00022 //- 4) The simple deferred attribute is put onto the first underlying entity 00023 //- using TopologyBridge::append_simple_attrib 00024 //- 00025 //- To restore: 00026 //- 1) Take dcsa, create CADeferredAttrib from it, and put it on owning entity: 00027 //- - CADA stores uid from dcsa 00028 //- - Then the dcsa is converted to a csa (CADA stuff removed) and stored 00029 //- in CADA on owning entity 00030 //- 2) When virtual geometry is created from actuating an attribute, CADA is notified; 00031 //- CADA goes through the list of CADA's, looking for any that apply to the 00032 //- new entity (based on uid) 00033 //- 3) If any CADA's are found for the new entity, their csa data are converted to 00034 //- a real CA, and that CA is put on the unactuatedCAs list in CADA. 00035 //- 4) At the end of CubitAttribUser::auto_actuate_cubit_attrib, CADA::cleanup_cadas 00036 //- is called, which keeps going through the unactuatedCAs list until nothing 00037 //- new happens (no new unactuated cas) 00038 //- 00039 00040 #ifndef CA_DEFERRED_ATTRIB_HPP 00041 #define CA_DEFERRED_ATTRIB_HPP 00042 00043 #include "CubitAttrib.hpp" 00044 #include <vector> 00045 00046 #include "CADefines.hpp" 00047 00048 class RefEntity; 00049 class CubitSimpleAttrib; 00050 00051 class CUBIT_GEOM_EXPORT CADeferredAttrib: public CubitAttrib 00052 { 00053 private: 00054 00055 int uniqueId; 00056 //- the deferred id tag for an entity 00057 00058 CubitSimpleAttrib thisCSA; 00059 //- the deferred attribute information 00060 00061 static std::vector<CADeferredAttrib*> allCADeferredAttribs; 00062 //- list of all CADA's; used in actuate_all function 00063 00064 static std::vector<CubitAttrib*> unactuatedCAs; 00065 //- list of new CubitAttrib's that haven't yet been actuated 00066 00067 static CubitStatus cleanup_cadas_private(const CubitBoolean from_constructor, 00068 const CubitBoolean after_geom_changes); 00069 //- moves between the global CADA list and the unactuated list: 00070 //- 00071 //- 1. tries to actuate all CADAs on unactuated list 00072 //- 2. tries to assign_to_owner all CADAs on global list 00073 public: 00074 virtual ~CADeferredAttrib(); 00075 00076 // CADeferredAttrib(RefEntity*); 00077 00078 CADeferredAttrib(RefEntity*, const CubitSimpleAttrib&); 00079 //- make a CADA from a simple attribute 00080 00081 CubitStatus actuate(); 00082 00083 CubitStatus update(); 00084 00085 CubitStatus reset(); 00086 00087 CubitSimpleAttrib cubit_simple_attrib(); 00088 00089 int unique_id() { return uniqueId;} 00090 00091 void unique_id (int id) {uniqueId = id;} 00092 private: 00093 // CubitSimpleAttrib *this_csa() {return thisCSA;}; 00094 00095 CubitStatus init_csa(const CubitSimpleAttrib &csa_ptr); 00096 00097 int int_attrib_type() {return CA_DEFERRED_ATTRIB;}; 00098 00099 CubitStatus assign_to_owner(CubitAttribUser *owner = NULL); 00100 //- looks for an entity with the right uid, assigns itself to 00101 //- that entity if found 00102 00103 static CubitStatus get_deferred_attribs(const int uid, 00104 std::vector<CADeferredAttrib*> &cada_list); 00105 //- given a uid, return a list of CADAs with corresponding uid 00106 00107 public: 00108 static std::vector<CubitAttrib*> get_unactuated_deferred_attribs() { return unactuatedCAs; } 00109 //- get all unactuated deferred attribs 00110 00111 static CubitStatus cleanup_cadas(const CubitBoolean from_constructor, 00112 const CubitBoolean after_geom_changes); 00113 //- moves between the global CADA list and the unactuated list: 00114 //- 00115 //- 1. tries to actuate all CADAs on unactuated list 00116 //- 2. tries to assign_to_owner all CADAs on global list 00117 00118 static CubitStatus owner_created(RefEntity *new_owner, const int uid); 00119 //- for a newly created ref entity, assigns any CADA with the same uid to the 00120 //- new entity 00121 private: 00122 // static CubitBoolean is_match(CubitSimpleAttrib *csa_ptr, const int uid); 00123 //- returns true if the simple attribute is deferred type and matches 00124 //- uid 00125 00126 static CubitSimpleAttrib csa_from_dcsa(const CubitSimpleAttrib &csa_ptr, 00127 const int uid = 0); 00128 //- given a deferred csa, convert it to a normal csa by removing 00129 //- first type string and first int; if first int doesn't match 00130 //- uid passed in, NULL is returned 00131 00132 public: 00133 static CubitBoolean add_unactuated_ca(CubitAttrib *ca_ptr); 00134 //- adds an unactuated ca (usually one that didn't actuate because it 00135 //- depends on some piece of geometry that doesn't exist yet) 00136 00137 static CubitBoolean remove_unactuated_ca(CubitAttrib* ca_ptr); 00138 //- If attribute gets destroted before it actuates, remove it 00139 //- from the list. 00140 }; 00141 00142 CubitAttrib* CADeferredAttrib_creator(RefEntity* entity, const CubitSimpleAttrib &p_csa); 00143 00144 #endif 00145