cgma
SubEntitySet.cpp
Go to the documentation of this file.
00001 #include "VGDefines.h"
00002 #include "SubEntitySet.hpp"
00003 #include "PartitionEntity.hpp"
00004 #include "CoEdgeSM.hpp"
00005 #include "DLIList.hpp"
00006 #include "CubitSimpleAttrib.hpp"
00007 #include "TDUniqueId.hpp"
00008 #include "CubitVector.hpp"
00009 #include "PartitionEngine.hpp"
00010 #include "GeometryEntity.hpp"
00011 #include "PartitionBody.hpp"
00012 #include "PartitionSurface.hpp"
00013 #include "CubitMessage.hpp"
00014 #include <typeinfo>
00015 
00016 
00017 const char* const PARTITION_DATA_ATTRIB_NAME = "PARTITION_ATTRIB";
00018 const char* const PARTITION_GEOM_ATTRIB_NAME = "PARTITION_GEOM";
00019 const char* const PARTITION_UID_ATTRIB_NAME  = "PARTITION_UID";
00020 
00021 void SubEntitySet::strip_attributes( TopologyBridge* bridge )
00022 {
00023   DLIList<CubitSimpleAttrib> list;
00024 
00025   bridge->get_simple_attribute( PARTITION_DATA_ATTRIB_NAME, list );
00026   while ( list.size() )
00027   {
00028     CubitSimpleAttrib csa = list.pop();
00029     bridge->remove_simple_attribute_virt( csa );
00030   }
00031  
00032   bridge->get_simple_attribute( PARTITION_GEOM_ATTRIB_NAME, list );
00033   while ( list.size() )
00034   {
00035     CubitSimpleAttrib csa = list.pop();
00036     bridge->remove_simple_attribute_virt( csa );
00037   }
00038  
00039   bridge->get_simple_attribute( PARTITION_UID_ATTRIB_NAME, list );
00040   while ( list.size() )
00041   {
00042     CubitSimpleAttrib csa = list.pop();
00043     bridge->remove_simple_attribute_virt( csa );
00044   }
00045 }
00046   
00047 
00048 SubEntitySet::SubEntitySet( TopologyBridge* real_entity, 
00049                             PartitionEntity* first_part )
00050   : bodyNext(0), bodyPtr(0), subEntityHead(0), lowerOrderHead(0), lastId(0), 
00051     layerNumber(SUBCOMP_PARTITION_LAYER), uniqueId(0)
00052 {
00053 //  if( real_entity->owner() )
00054 //    real_entity->owner()->swap_bridge( real_entity, 
00055 //        dynamic_cast<TopologyBridge*>(first_part) );
00056   
00057 //  real_entity->owner( this );
00058   myEntity = real_entity;
00059   assert(!!myEntity);
00060   
00061     // Scan for existing partition geometry stored
00062     // in attributes on the real entity.  We need
00063     // to start new Ids after any existing ones
00064     // to avoid conflicts as the stored entities
00065     // are restored.
00066   DLIList<CubitSimpleAttrib> csa_list;
00067   
00068   real_entity->get_simple_attribute( PARTITION_GEOM_ATTRIB_NAME, csa_list );
00069   while( csa_list.size() )
00070   {
00071     CubitSimpleAttrib csa = csa_list.pop();
00072     if( csa.character_type() == PARTITION_GEOM_ATTRIB_NAME )
00073     {
00074       int id = csa.int_data_list()[0];
00075       if( id > lastId )
00076         lastId = id;
00077     }
00078   }
00079   
00080   real_entity->get_simple_attribute( PARTITION_UID_ATTRIB_NAME, csa_list );
00081   if ( csa_list.size() )
00082   {
00083     assert(csa_list.size() == 1);
00084     CubitSimpleAttrib csa = csa_list.pop();
00085     //real_entity->remove_simple_attribute_virt(csa);
00086     assert(csa.int_data_list().size() == 1);
00087     uniqueId = csa.int_data_list()[0];
00088     PartitionEngine::instance().add_to_id_map( this, uniqueId );
00089   }
00090   
00091   // add first partition into the SubEntitySet's linked list
00092   add_partition( first_part, 0 );
00093   
00094   csa_list.clean_out();
00095   real_entity->get_simple_attribute( PARTITION_DATA_ATTRIB_NAME, csa_list );
00096   while ( csa_list.size() )
00097   {
00098     CubitSimpleAttrib csa = csa_list.pop();
00099     real_entity->remove_simple_attribute_virt(csa);
00100     wrap_attribute(csa, first_part->entitySetId );
00101     real_entity->append_simple_attribute_virt(csa);
00102   }
00103 }
00104 
00105 void SubEntitySet::unwrap_attributes()
00106 {
00107   DLIList<CubitSimpleAttrib> csa_list;
00108   if ( myEntity) 
00109     myEntity->get_simple_attribute( PARTITION_DATA_ATTRIB_NAME, csa_list );
00110   while( csa_list.size() )
00111   {
00112     CubitSimpleAttrib csa = csa_list.pop();
00113     myEntity->remove_simple_attribute_virt(csa);
00114     unwrap_attribute(csa);
00115     myEntity->append_simple_attribute_virt(csa);
00116   }
00117 }
00118   
00119 
00120 int SubEntitySet::get_unique_id()
00121 {
00122   if( uniqueId == 0 )
00123   {
00124     uniqueId = TDUniqueId::generate_unique_id();
00125     CubitSimpleAttrib attrib( PARTITION_UID_ATTRIB_NAME, 0, 0, &uniqueId );
00126     myEntity->append_simple_attribute_virt( attrib );
00127     PartitionEngine::instance().add_to_id_map( this, uniqueId );
00128   }
00129   return uniqueId;
00130 }
00131 
00132 SubEntitySet::~SubEntitySet()
00133 {
00134   if( uniqueId )
00135     PartitionEngine::instance().remove_from_id_map(this,uniqueId);
00136   assert( subEntityHead == 0 && lowerOrderHead == 0 );
00137   if( myEntity ) {
00138     strip_attributes(myEntity);
00139     if( myEntity->owner() == this )
00140       myEntity->owner(0);
00141   }
00142     
00143   if( bodyPtr )
00144   {
00145       // keep copy because calling bodyPtr->remove
00146       // means that bodyPtr will become NULL
00147     PartitionBody* body = bodyPtr;
00148     body->remove(*this);
00149 
00150     assert(body->entitySet != this);
00151     if( !body->has_children() )
00152     {
00153       BodySM* real_body = body->real_body();
00154       body->sub_entity_set().remove_bridge(real_body);
00155       if( body->owner() )
00156         body->owner()->swap_bridge( body, real_body, false );
00157       delete body;
00158     }
00159   }
00160 }
00161 
00162 void SubEntitySet::add_lower_order( PartitionEntity* partition )
00163 {
00164   assert( partition->entitySet == 0 &&
00165           partition->entitySetNext == 0 );
00166   partition->entitySet = this;
00167   partition->entitySetNext = lowerOrderHead;
00168   lowerOrderHead = partition;
00169   partition->entitySetId = ++lastId;
00170 }
00171 
00172 void SubEntitySet::add_lower_order( PartitionEntity* partition,
00173                                     const CubitSimpleAttrib& attrib,
00174                                     int dimension,
00175                                     DLIList<CubitVector*>& points,
00176                                     DLIList<int>& facets,
00177                                     DLIList<int>& children,
00178                                     DLIList<int>& point_owners )
00179 {
00180   assert( partition->entitySet == 0 &&
00181           partition->entitySetNext == 0 );
00182           
00183   int id, dim;
00184   CubitStatus result = read_geometry( id, dim, points, facets, children, 
00185                                       point_owners, attrib );
00186   assert( result && dimension == dim );
00187   if (CUBIT_SUCCESS != result || dimension != dim) {
00188     PRINT_ERROR("SubEntitySet::read_geometry failed or returned a mismatched dimension.\n");
00189     return;
00190   }
00191   
00192   partition->entitySet = this;
00193   partition->entitySetNext = lowerOrderHead;
00194   lowerOrderHead = partition;
00195   
00196   partition->entitySetId = id;
00197 }
00198 /*
00199 void SubEntitySet::fix_duplicate_id( int id )
00200 {
00201   for( int i = 0; i < 2; i++ )
00202   {
00203     PartitionEntit* list = i ? subEntityHead : lowerOrderHead;
00204     for( ; list; list = list->entitySetNext )
00205     {
00206       if( list->entitySetId == id )
00207         list->entitySetId = ++lastId;
00208     }
00209   }
00210 }
00211 */
00212 void SubEntitySet::add_partition( PartitionEntity* partition,
00213                                   PartitionEntity* after )
00214 {
00215   assert( partition->entitySet == 0 && partition->entitySetNext == 0 );
00216   partition->entitySet = this;
00217   
00218   if( after )
00219   {
00220     assert( after->entitySet == this );
00221     partition->entitySetNext = after->entitySetNext;
00222     after->entitySetNext = partition;
00223   }
00224   else
00225   {
00226     partition->entitySetNext = subEntityHead;
00227     subEntityHead = partition;
00228   }
00229   partition->entitySetId = ++lastId;
00230 }
00231 
00232 
00233 void SubEntitySet::remove( PartitionEntity* partition )
00234 {
00235   assert( partition->entitySet == this );
00236   partition->entitySet = 0;
00237   
00238   if( lowerOrderHead == partition )
00239   {
00240     lowerOrderHead = partition->entitySetNext;
00241   }
00242   else if( subEntityHead == partition )
00243   {
00244     subEntityHead = partition->entitySetNext;
00245   }
00246   else
00247   {
00248     PartitionEntity* curr = subEntityHead;
00249     while( curr && curr->entitySetNext != partition )
00250       curr = curr->entitySetNext;
00251     if( curr == 0 )
00252     {  
00253       curr = lowerOrderHead;
00254       while( curr && curr->entitySetNext != partition )
00255         curr = curr->entitySetNext;
00256     }
00257     
00258     assert( curr && curr->entitySetNext == partition );
00259     curr->entitySetNext = partition->entitySetNext;
00260   }
00261   
00262   partition->entitySetNext = 0;
00263 
00264   if( !subEntityHead && !lowerOrderHead )
00265   {
00266     delete this;
00267   }
00268   
00269   partition->entitySetId = 0;
00270 }
00271 
00272 CubitStatus SubEntitySet::bridge_destroyed( TopologyBridge* bridge )
00273 {
00274   if( myEntity && myEntity == bridge )
00275   {
00276     if( myEntity->owner() == this )
00277       myEntity->owner(0);
00278     myEntity = 0;
00279     return CUBIT_SUCCESS;
00280   }
00281   return CUBIT_FAILURE;
00282 }
00283 
00284 CubitStatus SubEntitySet::remove_bridge( TopologyBridge* bridge )
00285 {
00286   if (myEntity && myEntity == bridge)
00287   {
00288     strip_attributes(myEntity);
00289     return bridge_destroyed(myEntity);
00290   }
00291   return CUBIT_FAILURE;
00292 }
00293 
00294 CubitStatus SubEntitySet::swap_bridge( TopologyBridge* remove,
00295                                        TopologyBridge* add,
00296                                        bool reversed )
00297 {
00298   if( remove_bridge( remove ) )
00299   {
00300     if( add->owner() )
00301     {
00302       add->owner()->remove_bridge( add );
00303     }
00304     add->owner(this);
00305     myEntity = add;
00306     if (reversed)
00307       notify_reversed(add);
00308     return CUBIT_SUCCESS;
00309   }
00310   return CUBIT_FAILURE;
00311 }
00312 
00313 void SubEntitySet::get_owners( DLIList<TopologyBridge*>& owner_list ) const
00314 {
00315   for( PartitionEntity* ent = subEntityHead; ent; ent = ent->entitySetNext )
00316     owner_list.append( dynamic_cast<TopologyBridge*>(ent) );
00317     
00318   CoEdgeSM* coedge = dynamic_cast<CoEdgeSM*>(get_entity());
00319   if( coedge && coedge->sense() == CUBIT_REVERSED )
00320     owner_list.reverse();
00321 }
00322 
00323     
00324 bool SubEntitySet::has_multiple_sub_entities() const
00325   { return subEntityHead && subEntityHead->entitySetNext; }
00326 
00327 void SubEntitySet::print_debug_info( const char* prefix ) const
00328 {
00329   if( !prefix ) prefix = "";  
00330 
00331   PRINT_INFO("%sSubEntitySet for %s %p\n", prefix, 
00332     myEntity ? fix_type_name(typeid(*myEntity).name()) : "TopologyBridge", 
00333     (void*)myEntity );
00334 
00335   PRINT_INFO("%s  SubEntities:\n", prefix );
00336   PartitionEntity* ent = subEntityHead;
00337   
00338   while( ent )
00339   {
00340     PartitionSurface *partition_surf = dynamic_cast<PartitionSurface*>(ent);
00341     if( partition_surf )
00342       PRINT_INFO("%p is a partition surface\n", (void*)partition_surf);
00343 
00344     PRINT_INFO("%s    %s %d (%p)\n", prefix, 
00345       fix_type_name(typeid(*ent).name()), ent->entitySetId, (void*)ent);
00346     ent = ent->entitySetNext;
00347   }
00348 
00349   PRINT_INFO("%s  Lower-order entities:\n", prefix );
00350   ent = lowerOrderHead;
00351   while( ent )
00352   {
00353     PRINT_INFO("%s    %s %d (%p)\n", prefix, 
00354       fix_type_name(typeid(*ent).name()), ent->entitySetId, (void*)ent);
00355     ent = ent->entitySetNext;
00356   }
00357   
00358   PRINT_INFO("%s  Body: %p\n", prefix, (void*)bodyPtr);
00359 }
00360 
00361 bool SubEntitySet::is_attribute( const CubitSimpleAttrib& csa, int id ) const
00362 {
00363   if( csa.string_data_list().size() < 1 )
00364     return false;
00365 
00366   if( csa.character_type() != PARTITION_DATA_ATTRIB_NAME )
00367     return false;
00368   
00369   assert( csa.int_data_list().size() );
00370   if( id && csa.int_data_list()[0] != id )
00371     return false;
00372   
00373   return true;
00374 }    
00375 
00376 CubitStatus SubEntitySet::wrap_attribute( CubitSimpleAttrib& csa, int id ) const
00377 {
00378   if( is_attribute( csa ) )
00379     return CUBIT_FAILURE;
00380     
00381   csa.string_data_list().insert(csa.string_data_list().begin(), CubitString(PARTITION_DATA_ATTRIB_NAME) );
00382   csa.int_data_list().insert(csa.int_data_list().begin(), id );
00383   return CUBIT_SUCCESS;
00384 }
00385 
00386 int SubEntitySet::unwrap_attribute( CubitSimpleAttrib& csa ) const
00387 {
00388   if( ! is_attribute( csa ) )
00389     return 0;
00390 
00391   csa.string_data_list().erase(csa.string_data_list().begin());
00392   int id = csa.int_data_list()[0];
00393   csa.int_data_list().erase(csa.int_data_list().begin());
00394   
00395   return id;
00396 }
00397 
00398 void SubEntitySet::add_attribute( PartitionEntity* entity, const CubitSimpleAttrib& csa )
00399 {
00400   assert( entity->entitySet == this );
00401   
00402   if( !myEntity )
00403     return;
00404   
00405   CubitSimpleAttrib copy = csa;
00406   if( wrap_attribute( copy, entity->entitySetId ) )
00407   {
00408     myEntity->append_simple_attribute_virt( copy );
00409   }
00410 }
00411 
00412 void SubEntitySet::rem_attribute( PartitionEntity* entity, const CubitSimpleAttrib& csa )
00413 {
00414   assert( entity->entitySet == this );
00415   
00416   if( !myEntity )
00417     return;
00418   
00419   CubitSimpleAttrib copy = csa;
00420   if( wrap_attribute( copy, entity->entitySetId ) )
00421   {
00422     myEntity->remove_simple_attribute_virt( copy );
00423   }
00424 }
00425 
00426 void SubEntitySet::get_attributes( PartitionEntity* entity,
00427                                    DLIList<CubitSimpleAttrib>& list )
00428 {
00429   assert( entity->entitySet == this );
00430   assert( !list.size() );
00431   list.clean_out();
00432   
00433   if( !myEntity )
00434     return;
00435 
00436   DLIList<CubitSimpleAttrib> tmp;
00437   myEntity->get_simple_attribute( PARTITION_DATA_ATTRIB_NAME, tmp );
00438   for(int i=0; i<tmp.size(); i++)
00439   {
00440     CubitSimpleAttrib& csa = tmp[i];
00441     if( is_attribute( csa, entity->entitySetId ) )
00442     {
00443       unwrap_attribute( csa );
00444       list.append(csa);
00445     }
00446   }
00447 }
00448 void SubEntitySet::get_attributes( PartitionEntity* entity, const char* name,
00449                                    DLIList<CubitSimpleAttrib>& list )
00450 {
00451   list.clean_out();
00452 
00453   DLIList<CubitSimpleAttrib> tmp;
00454   get_attributes(entity,tmp);
00455   
00456   for ( int i=0; i<tmp.size(); i++)
00457   {
00458     if(tmp[i].character_type() == name)
00459     {
00460       list.append(tmp[i]);
00461     }
00462   }
00463 }
00464 
00465 void SubEntitySet::rem_all_attrib( PartitionEntity* entity )
00466 {
00467   assert( entity->entitySet == this );
00468   
00469   if( !myEntity )
00470     return;
00471 
00472   DLIList<CubitSimpleAttrib> dead_list;
00473   myEntity->get_simple_attribute( PARTITION_DATA_ATTRIB_NAME, dead_list );
00474   for( int i = dead_list.size(); i--; )
00475   {
00476     const CubitSimpleAttrib& csa = dead_list.get_and_step();
00477     if( is_attribute( csa, entity->entitySetId ) )
00478       myEntity->remove_simple_attribute_virt( csa );
00479   }
00480 }
00481 
00482 int SubEntitySet::get_id( PartitionEntity* entity ) const
00483 {
00484   if( entity->entitySet != this )
00485     return 0;
00486   return entity->entitySetId;
00487 }
00488 
00489 PartitionEntity* SubEntitySet::entity_from_id( int id ) const
00490 {
00491   PartitionEntity* ent;
00492   for( ent = subEntityHead; ent; ent = ent->entitySetNext )
00493     if( ent->entitySetId == id )
00494       return ent;
00495   for( ent = lowerOrderHead; ent; ent = ent->entitySetNext )
00496     if( ent->entitySetId == id )
00497       return ent;
00498   return 0;
00499 }
00500 
00501 void SubEntitySet::get_sub_entities( DLIList<PartitionEntity*>& list ) const
00502 {
00503   for( PartitionEntity* ent = subEntityHead; ent; ent = ent->entitySetNext )
00504     list.append(ent);
00505 }
00506 
00507 
00508 void SubEntitySet::get_lower_order( DLIList<PartitionEntity*>& list ) const
00509 {
00510   for( PartitionEntity* ent = lowerOrderHead; ent; ent = ent->entitySetNext )
00511     list.append(ent);
00512 }
00513 
00514 void SubEntitySet::set_id( PartitionEntity* entity, int id )
00515 {
00516   if( entity->entitySet != this )
00517     assert(0);
00518   else
00519   {
00520     entity->entitySetId = id;
00521     if( id > lastId )
00522       lastId = id;
00523   }
00524 }
00525 
00526 void SubEntitySet::renumerate( int lowest_value, bool higher_only )
00527 {
00528   lastId = lowest_value - 1;
00529   
00530   PartitionEntity* ent;
00531   for( ent = subEntityHead; ent; ent = ent->entitySetNext )
00532     if( !higher_only || ent->entitySetId >= lowest_value )
00533       ent->entitySetId = ++lastId;
00534   for( ent = lowerOrderHead; ent; ent = ent->entitySetNext )
00535     if( !higher_only || ent->entitySetId >= lowest_value )
00536       ent->entitySetId = ++lastId;
00537 }
00538 
00539 void SubEntitySet::notify_reversed( TopologyBridge* bridge )
00540 {
00541   assert( !bridge || bridge == myEntity );
00542   
00543     // reverse list order (only really necessary for curves)
00544   PartitionEntity* entity = subEntityHead;
00545   subEntityHead = 0;
00546   while( entity )
00547   {
00548     PartitionEntity* next = entity->entitySetNext;
00549     entity->entitySetNext = subEntityHead;
00550     subEntityHead = entity;
00551     entity = next;
00552   }
00553   
00554     // reverse the sense of all subentities
00555   for( entity = subEntityHead; entity; entity = entity->entitySetNext )
00556     entity->reverse_sense();  
00557 }    
00558 
00559 
00560 CubitStatus SubEntitySet::save_geometry( int id, int dimension, 
00561                                          DLIList<CubitVector*>* point_list,
00562                                          DLIList<int>* point_connectivity,
00563                                          DLIList<int>* topo_connectivity,
00564                                          DLIList<int>* point_owners,
00565                                          CubitSimpleAttrib& attrib )
00566 {
00567   int i;
00568 
00569   attrib.int_data_list().clear();
00570   attrib.double_data_list().clear();
00571   
00572   attrib.int_data_list().push_back( id);
00573   attrib.int_data_list().push_back( dimension);
00574   int point_list_size = point_list ? point_list->size() : 0;
00575   attrib.int_data_list().push_back( point_list_size);
00576   int point_conn_size = point_connectivity ? point_connectivity->size() : 0;
00577   attrib.int_data_list().push_back( point_conn_size);
00578   int topo_conn_size = topo_connectivity ? topo_connectivity->size() : 0;
00579   attrib.int_data_list().push_back( topo_conn_size);
00580   
00581   if( point_list )
00582   {
00583     point_list->reset();
00584     for( i = point_list->size(); i--; )
00585     {
00586       CubitVector* p = point_list->get_and_step();
00587       attrib.double_data_list().push_back(p->x());
00588       attrib.double_data_list().push_back(p->y());
00589       attrib.double_data_list().push_back(p->z());
00590       delete p;
00591     }
00592     point_list->clean_out();
00593   }
00594     
00595   if( point_connectivity )
00596   {
00597     point_connectivity->reset();
00598     for( i = point_connectivity->size(); i--; )
00599       attrib.int_data_list().push_back(point_connectivity->get_and_step());
00600   }
00601     
00602   if( topo_connectivity )
00603   {
00604     topo_connectivity->reset();
00605     for( i = topo_connectivity->size(); i--; )
00606       attrib.int_data_list().push_back(topo_connectivity->get_and_step());
00607   }
00608   
00609   if ( point_owners )
00610   {
00611     point_owners->reset();
00612     for ( i = point_owners->size(); i--; )
00613       attrib.int_data_list().push_back(point_owners->get_and_step());
00614   }
00615  
00616   myEntity->append_simple_attribute_virt( attrib );
00617 
00618   return CUBIT_SUCCESS;
00619 }
00620 
00621 
00622 CubitStatus SubEntitySet::read_geometry( int& id, int& dimension, 
00623                                          DLIList<CubitVector*>& point_list,
00624                                          DLIList<int>& point_connectivity,
00625                                          DLIList<int>& topo_connectivity,
00626                                          DLIList<int>& point_owners,
00627                                          const CubitSimpleAttrib& attrib )
00628 {
00629   int i;
00630   
00631     // read metadata
00632   int ioffset = 0;
00633   int doffset = 0;
00634   id              = attrib.int_data_list()[ioffset++];
00635   dimension       = attrib.int_data_list()[ioffset++];
00636   int point_count = attrib.int_data_list()[ioffset++];
00637   int conn_count  = attrib.int_data_list()[ioffset++];
00638   int topo_count  = attrib.int_data_list()[ioffset++];
00639   int owner_count = conn_count ? 2 * point_count : 0;
00640   
00641     // consistancy checks
00642   if( id < 0 || dimension < 0 || dimension > 3 ||
00643       point_count < 0 || conn_count < 0 || topo_count < 0 )
00644   {
00645     PRINT_ERROR("Invalid %s attribute read.  Corrupted file?\n"
00646                 "\tId = %d\n\tDimension = %d\n\tPoint Count = %d\n"
00647                 "\tPoint Connectivity Count = %d\n"
00648                 "\tTopology Connectivity Count = %d\n",
00649                 attrib.string_data_list()[0].c_str(),
00650                 id, dimension, point_count, conn_count, topo_count );
00651     return CUBIT_FAILURE;
00652   }
00653   
00654   if( (size_t)(conn_count + topo_count + owner_count + 5) != attrib.int_data_list().size() ||
00655       attrib.int_data_list().size() < 5 )
00656   {
00657     PRINT_ERROR("Invalid %s attribute read.  Corrupted file?\n"
00658                 "\tInsufficient/Excess integer data:\n"
00659                 "\tAvailable integer data: %d\n"
00660                 "\tMetadata              : 5\n"
00661                 "\tPoint Connectivity    : %d\n"
00662                 "\tTopology Connectivity : %d\n"
00663                 "\tFacet Point Assoc.    : %d\n"
00664                 "\tTotal Expected Ints   : %d\n",
00665                 attrib.string_data_list()[0].c_str(),
00666                 (int) attrib.int_data_list().size(),
00667                 conn_count, topo_count, owner_count,
00668                 conn_count + topo_count + owner_count + 5 );
00669     return CUBIT_FAILURE;
00670   }
00671                 
00672   if( (size_t)(point_count * 3) != attrib.double_data_list().size() )
00673   {
00674     PRINT_ERROR("Invalid %s attribute read.  Corrupted file?\n"
00675                 "\tInsufficient/Excess real data: %d for %d points.\n",
00676                 attrib.string_data_list()[0].c_str(),
00677                 (int) attrib.double_data_list().size(), point_count );
00678     return CUBIT_FAILURE;
00679   }
00680   
00681     // read point coordinates
00682   for( i = 0; i < point_count; i++ )
00683   {
00684     double x = attrib.double_data_list()[doffset++];
00685     double y = attrib.double_data_list()[doffset++];
00686     double z = attrib.double_data_list()[doffset++];
00687     point_list.append( new CubitVector(x,y,z) );
00688   }
00689   
00690     // read point connectivity (facets)
00691   for( i = 0; i < conn_count; i++ )
00692     point_connectivity.append( attrib.int_data_list()[ioffset++] );
00693   
00694     // read topology connectivity (children)
00695   for( i = 0; i < topo_count; i++ )
00696     topo_connectivity.append( attrib.int_data_list()[ioffset++] );
00697     
00698     // read facet point owners
00699   for( i = 0; i < owner_count; i++ )
00700     point_owners.append( attrib.int_data_list()[ioffset++] );
00701   
00702   return CUBIT_SUCCESS;
00703 }
00704 
00705 
00706 int SubEntitySet::get_geom_dimension( const CubitSimpleAttrib& attrib )
00707 {
00708   assert(attrib.int_data_list().size() > 1);
00709   return attrib.int_data_list()[1];
00710 }
00711 
00712 int SubEntitySet::get_geom_id( const CubitSimpleAttrib& attrib )
00713 {
00714   assert(attrib.int_data_list().size() > 1);
00715   return attrib.int_data_list()[0];
00716 }
00717 
00718 int SubEntitySet::get_segment_count( const CubitSimpleAttrib& attrib )
00719 {
00720   assert(attrib.int_data_list().size() > 2);
00721 
00722   int point_count = attrib.int_data_list()[2];
00723   if ( point_count == 0 )
00724     return 0;
00725 
00726   assert( point_count > 1 );
00727   return point_count - 1;
00728 }
00729 
00730 CubitStatus SubEntitySet::save_geometry()
00731 {
00732   if( !lowerOrderHead )
00733     return CUBIT_SUCCESS;
00734     
00735   DLIList<CubitSimpleAttrib> old_list;
00736   myEntity->get_simple_attribute(PARTITION_GEOM_ATTRIB_NAME, old_list);
00737   while (old_list.size())
00738   {
00739     CubitSimpleAttrib old_attrib = old_list.pop();
00740     myEntity->remove_simple_attribute_virt(old_attrib);
00741   }  
00742   
00743   CubitSimpleAttrib attrib(PARTITION_GEOM_ATTRIB_NAME);
00744   
00745   CubitStatus result = CUBIT_SUCCESS;
00746   for( int i = 0; i < 2; i++ )
00747   {
00748     PartitionEntity* list_node = i ? subEntityHead : lowerOrderHead;
00749     for( ; list_node; list_node = list_node->entitySetNext )
00750       if(dynamic_cast<GeometryEntity*>(list_node) && !list_node->save(attrib))
00751         result = CUBIT_FAILURE;
00752   }
00753   
00754   return result;
00755 }
00756  
00757 
00758 void SubEntitySet::strip_attributes() 
00759 {
00760   strip_attributes( myEntity );
00761 }
00762       
00763   
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines