cgma
|
00001 #include "PartitionPoint.hpp" 00002 #include "PartitionCurve.hpp" 00003 #include "VirtualQueryEngine.hpp" 00004 #include "PartitionEngine.hpp" 00005 00006 #include "CubitPointData.hpp" 00007 #include "TDVGFacetOwner.hpp" 00008 #include "CubitTransformMatrix.hpp" 00009 #include "Surface.hpp" 00010 00011 PartitionPoint::PartitionPoint( const CubitVector& position, 00012 PartitionEntity* owner ) 00013 : firstCurve(0), curveCount(0), myPosition( position ), facetPoint(0) 00014 { 00015 owner->sub_entity_set().add_lower_order( this ); 00016 } 00017 00018 PartitionPoint::PartitionPoint( TBPoint* real_point ) 00019 : firstCurve(0), curveCount(0), 00020 myPosition( real_point->coordinates() ), 00021 facetPoint(0) 00022 { 00023 assert( dynamic_cast<SubEntitySet*>(real_point->owner()) == 0 ); 00024 new SubEntitySet( real_point, this ); 00025 } 00026 00027 PartitionPoint::PartitionPoint( const CubitSimpleAttrib& attrib, 00028 PartitionEntity* owner ) 00029 : firstCurve(0), curveCount(0), facetPoint(0) 00030 { 00031 DLIList<int> junk; 00032 DLIList<CubitVector*> pt; 00033 owner->sub_entity_set().add_lower_order( this, attrib, 0, pt, junk, junk, junk); 00034 assert(pt.size() == 1); 00035 myPosition = *pt.get(); 00036 delete pt.get(); 00037 } 00038 00039 00040 PartitionPoint::~PartitionPoint() 00041 { 00042 while( firstCurve ) 00043 { 00044 PartitionCurve* curve = firstCurve; 00045 if( curve->start_point() == this ) 00046 curve->start_point(0); 00047 if( curve->end_point() == this ) 00048 curve->end_point(0); 00049 assert( firstCurve != curve ); 00050 } 00051 assert( curveCount == 0 ); 00052 facet_point(0); 00053 } 00054 00055 CubitVector PartitionPoint::coordinates() const 00056 { return myPosition; } 00057 /* 00058 int PartitionPoint::num_curves() const 00059 { 00060 int count = 0; 00061 for( PartitionCurve* curve = firstCurve; curve; curve=curve->next_curve(this) ) 00062 count++; 00063 return count; 00064 } 00065 */ 00066 PartitionCurve* PartitionPoint::next_curve( PartitionCurve* prev ) const 00067 { return prev ? prev->next_curve(this) : firstCurve; } 00068 00069 PartitionCurve* PartitionPoint::common_curve( PartitionPoint* other ) const 00070 { 00071 PartitionCurve* curve = 0; 00072 if( other == this ) 00073 { 00074 while( (curve = next_curve(curve)) ) 00075 if( curve->start_point() == curve->end_point() ) 00076 return curve; 00077 } 00078 else 00079 { 00080 while( (curve = next_curve(curve)) ) 00081 if( curve->other_point(other) ) 00082 return curve; 00083 } 00084 return 0; 00085 } 00086 00087 CubitStatus PartitionPoint::move( CubitVector& /*delta*/ ) 00088 { 00089 //if( curveSet.size() ) 00090 return CUBIT_FAILURE; 00091 00092 //myPosition += delta; 00093 //return CUBIT_SUCCESS; 00094 } 00095 00096 void PartitionPoint::get_parents_virt( DLIList<TopologyBridge*>& parents ) 00097 { 00098 parents.clean_out(); 00099 if( real_point() ) 00100 { 00101 // Get all the real point's parent curves. 00102 sub_entity_set().get_entity()->get_parents_virt( parents ); 00103 00104 // Remove all real parents hidden by partitions. We will add 00105 // the partitions hiding these curves later. 00106 for( int i = parents.size(); i--; ) 00107 if( dynamic_cast<SubEntitySet*>(parents.step_and_get()->owner() ) ) 00108 parents.change_to(0); 00109 parents.remove_all_with_value(0); 00110 } 00111 00112 // Now add any parent partition curves 00113 for( PartitionCurve* curve = firstCurve; curve; curve = curve->next_curve(this) ) 00114 parents.append( curve ); 00115 00116 } 00117 00118 void PartitionPoint::get_children_virt( DLIList<TopologyBridge*>& ) 00119 { 00120 } 00121 00122 TBPoint* PartitionPoint::real_point() const 00123 { 00124 return dynamic_cast<TBPoint*>(sub_entity_set().get_entity()); 00125 } 00126 00127 GeometryQueryEngine* PartitionPoint::get_geometry_query_engine() const 00128 { 00129 return VirtualQueryEngine::instance(); 00130 } 00131 00132 void PartitionPoint::print_debug_info( const char* prefix, 00133 bool ent_set ) const 00134 { 00135 if( !prefix ) prefix = ""; 00136 char* new_prefix = new char[strlen(prefix)+3]; 00137 strcpy( new_prefix, prefix ); 00138 strcat( new_prefix, " "); 00139 CubitVector p = coordinates(); 00140 PRINT_INFO("%sPartitionPoint %p at (%f,%f,%f)\n", 00141 prefix, (void*)this, p.x(), p.y(), p.z() ); 00142 DLIList<Curve*> curve_list; 00143 const_cast<PartitionPoint*>(this)->TopologyBridge::curves( curve_list ); 00144 PRINT_INFO("%s %d Curves (%d PartitionCurves).\n", prefix, 00145 curve_list.size(), num_curves() ); 00146 00147 if ( facet_point() ) { 00148 p = facet_point()->coordinates(); 00149 PRINT_INFO("%s CubitPoint %p at [%f,%f,%f] (%f)\n", prefix, 00150 (void*)facet_point(), p.x(), p.y(), p.z(), 00151 (coordinates() - facet_point()->coordinates()).length()); 00152 } 00153 00154 if( ent_set ) 00155 sub_entity_set().print_debug_info( new_prefix ); 00156 else 00157 print_partitioned_entity(new_prefix); 00158 delete [] new_prefix; 00159 } 00160 00161 00162 void PartitionPoint::append_simple_attribute_virt(const CubitSimpleAttrib& csa) 00163 { sub_entity_set().add_attribute( this, csa ); } 00164 void PartitionPoint::remove_simple_attribute_virt(const CubitSimpleAttrib& csa) 00165 { sub_entity_set().rem_attribute( this, csa ); } 00166 void PartitionPoint::remove_all_simple_attribute_virt() 00167 { sub_entity_set().rem_all_attrib( this ); } 00168 CubitStatus PartitionPoint::get_simple_attribute(DLIList<CubitSimpleAttrib>& list) 00169 { 00170 sub_entity_set().get_attributes( this, list ); 00171 return CUBIT_SUCCESS; 00172 } 00173 CubitStatus PartitionPoint::get_simple_attribute(const CubitString& name, 00174 DLIList<CubitSimpleAttrib>& list) 00175 { 00176 sub_entity_set().get_attributes( this, name.c_str(), list ); 00177 return CUBIT_SUCCESS; 00178 } 00179 00180 void PartitionPoint::reverse_sense() 00181 { } 00182 00183 void PartitionPoint::notify_split( FacetEntity* , FacetEntity* ) 00184 { assert(0); } 00185 00186 void PartitionPoint::facet_point( CubitPointData* set ) 00187 { 00188 if( facetPoint ) 00189 TDVGFacetOwner::remove(facetPoint); 00190 facetPoint = set; 00191 if( set ) 00192 { 00193 assert((set->coordinates() - coordinates()).length_squared() 00194 < GEOMETRY_RESABS*GEOMETRY_RESABS); 00195 TDVGFacetOwner::set(facetPoint,this); 00196 } 00197 } 00198 00199 CubitStatus PartitionPoint::save( CubitSimpleAttrib& attrib ) 00200 { 00201 int id = sub_entity_set().get_id(this); 00202 if( id <= 0 ) 00203 return CUBIT_FAILURE; 00204 00205 DLIList<CubitVector*> pt_list(1); 00206 pt_list.append( new CubitVector(coordinates()) ); 00207 00208 return sub_entity_set().save_geometry( id, 0, &pt_list, 0, 0, 0, attrib ); 00209 } 00210 00211 CubitBox PartitionPoint::bounding_box() const 00212 { return CubitBox(coordinates()); } 00213 00214 CubitStatus PartitionPoint::move_to_geometry( CubitVector& pos ) 00215 { 00216 pos = coordinates(); 00217 return CUBIT_SUCCESS; 00218 } 00219 00220 void PartitionPoint::transform( const CubitTransformMatrix& xform ) 00221 { 00222 if( TBPoint* point = dynamic_cast<TBPoint*>(partitioned_entity()) ) 00223 myPosition = point->coordinates(); 00224 else 00225 myPosition = xform * myPosition; 00226 00227 if( facetPoint ) 00228 facetPoint->set(myPosition); 00229 }