cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : CompositeGeom.hpp 00003 // 00004 // Purpose : Object used by CompositeSurface and CompositeCurve 00005 // to manage underlying entities. 00006 // 00007 // Special Notes : 00008 // 00009 // Creator : Jason Kraftcheck 00010 // 00011 // Creation Date : 12/19/01 00012 //------------------------------------------------------------------------- 00013 00014 #ifndef COMPOSITE_GEOM_HPP 00015 #define COMPOSITE_GEOM_HPP 00016 00017 #include "DLIList.hpp" 00018 #include "VGArray.hpp" 00019 #include "CubitBox.hpp" 00020 00021 class GeometryEntity; 00022 class CubitSimpleAttrib; 00023 class CompositeAttrib; 00024 class TopologyBridge; 00025 00026 struct CompositeEntry 00027 { 00028 public: 00029 00030 GeometryEntity* entity; // underlying entity 00031 CubitSense sense; // sense relative to composite 00032 double measure; // cached value of entity->measure() 00033 CubitBox bbox; // cached value of entity->bounding_box() 00034 double dist_sqr; // temporary data used in closest_point() calc. 00035 00036 inline CompositeEntry() 00037 : entity(0), sense(CUBIT_UNKNOWN), measure(0.0), dist_sqr(0.0) {} 00038 }; 00039 00040 00041 class CompositeGeom 00042 { 00043 00044 public: 00045 00046 CompositeGeom( int size = 0 ); 00047 00048 ~CompositeGeom(); 00049 00050 int num_entities() const 00051 { return entityList.size(); } 00052 00053 int index_of( TopologyBridge* geom_ptr ) const; 00054 inline GeometryEntity* entity( int index ) const; 00055 00056 inline CubitSense sense( int index ) const; 00057 inline double measure( int index ); 00058 void reverse_sense( int index ); 00059 00060 CubitStatus insert( int index, GeometryEntity* geom_ptr, CubitSense sense ); 00061 00062 CubitStatus append( GeometryEntity* geom_ptr, CubitSense sense ) 00063 { return insert( entityList.size(), geom_ptr, sense ); } 00064 00065 CubitStatus remove( int index, bool dead ); 00066 CompositeGeom* split( int index ); 00067 CompositeGeom* split( VGArray<int>& index_array ); 00068 CubitStatus swap( int index, GeometryEntity* new_geom ); 00069 CubitStatus reverse(); 00070 CubitStatus reverse_order(); 00071 CubitStatus reverse_rel_senses(); 00072 00073 CubitStatus merge( CompositeGeom& dead, bool prepend = false ); 00074 00075 CubitBox bounding_box(); 00076 double measure(); 00077 00078 int next_box_within_dist( double dist_squared ); 00079 int closest_box( const CubitVector& position ); 00080 00081 void update_cached_data() 00082 { needToUpdateBbox = true; needToUpdateMeasure = true; } 00083 00084 void add_attribute( const CubitSimpleAttrib& csa ); 00085 void rem_attribute( const CubitSimpleAttrib& csa ); 00086 void rem_all_attributes(); 00087 void get_attributes( DLIList<CubitSimpleAttrib>& list ); 00088 void get_attributes( const char* name, 00089 DLIList<CubitSimpleAttrib>& list ); 00090 00091 void print_debug_info( const char* line_prefix = 0 ); 00092 00093 void read_attributes( GeometryEntity* entity = 0 ); 00094 void write_attributes( GeometryEntity* entity = 0 ); 00095 00096 private: 00097 00098 static void clean_up_attribs( GeometryEntity* ent ); 00099 00100 // these have no implementation, just private delcarations 00101 // to prevent the compiler from generating default implementations 00102 CompositeGeom& operator=(const CompositeGeom&); 00103 CompositeGeom(const CompositeGeom&); 00104 00105 void update_data_bbox(); 00106 void update_data_measure(); 00107 00108 VGArray<CompositeEntry> entityList; 00109 int currentIndex; 00110 int firstIndex; 00111 00112 bool needToUpdateBbox; 00113 bool needToUpdateMeasure; 00114 00115 CompositeAttrib* listHead; 00116 }; 00117 00118 00119 inline GeometryEntity* CompositeGeom::entity( int index ) const 00120 { 00121 return entityList[index].entity; 00122 } 00123 00124 inline CubitSense CompositeGeom::sense( int index ) const 00125 { 00126 return entityList[index].sense; 00127 } 00128 00129 inline double CompositeGeom::measure( int index ) 00130 { 00131 if( needToUpdateMeasure ) 00132 update_data_measure(); 00133 return entityList[index].measure; 00134 } 00135 00136 #endif 00137 00138 00139 00140 00141