cgma
CubitAttribUser.cpp
Go to the documentation of this file.
00001 //- class:          CubitAttribUser
00002 //- Owner:          Greg Nielson
00003 //- Description:    implementation of CubitAttribUser class.
00004 //- Checked By:
00005 //- Version: $Id:
00006 
00007 
00008 // #include "CubitSimpleAttrib.hpp"
00009 #include "CubitAttribUser.hpp"
00010 #include "CastTo.hpp"
00011 #include "Body.hpp"
00012 #include "GeometryEntity.hpp"
00013 #include "BasicTopologyEntity.hpp"
00014 #include "BodySM.hpp"
00015 #include "CAGroup.hpp"
00016 #include "CAMergePartner.hpp"
00017 //#include "CADeferredAttrib.hpp"
00018 #include "RefFace.hpp"
00019 #include "RefEdge.hpp"
00020 #include "RefVertex.hpp"
00021 // #include "DLIList.hpp"
00022 // #include "CubitString.hpp"
00023 #include "GeometryModifyTool.hpp"
00024 #include "BridgeManager.hpp"
00025 #include "CubitMessage.hpp"
00026 
00027 
00028 CubitAttribUser::CubitAttribUser(CubitAttrib* cubit_attrib_ptr)
00029 {
00030   headAttrib = cubit_attrib_ptr;
00031 }
00032 
00033 CubitAttribUser::~CubitAttribUser()
00034 {
00035   //delete all ToolData's chained off this user.
00036   CubitAttrib *ca_ptr = headAttrib;
00037   
00038   while ( ca_ptr) {
00039     CubitAttrib *next = ca_ptr->next_attrib();
00040     delete ca_ptr;
00041     ca_ptr = next;
00042   }
00043 
00044   headAttrib = NULL;
00045 }
00046 
00047 CubitAttrib* CubitAttribUser::get_cubit_attrib (int attrib_type,
00048                                                 CubitBoolean create_if_missing)
00049 {
00050   CubitAttrib* cubit_attrib_ptr = NULL;
00051   RefEntity* entity = NULL;
00052   DLIList<CubitAttrib*> attrib_list;
00053   find_cubit_attrib_type (attrib_type, attrib_list);
00054   if (attrib_list.size() > 0)
00055     cubit_attrib_ptr =  attrib_list.get();
00056   else if ( create_if_missing == CUBIT_TRUE )
00057   {
00058     entity = CAST_TO(this, RefEntity);
00059     cubit_attrib_ptr = CGMApp::instance()->attrib_manager()->create_cubit_attrib(attrib_type, entity, CubitSimpleAttrib());
00060   }
00061 
00062   return cubit_attrib_ptr;
00063 }
00064 
00065 CubitStatus CubitAttribUser::add_cubit_attrib (CubitAttrib* cubit_attrib_ptr)
00066 {
00067   if (cubit_attrib_ptr == NULL)
00068     return CUBIT_FAILURE;
00069 
00070   CubitStatus cubit_attribute_status = CUBIT_FAILURE;
00071   CubitAttrib *temp_ptr;
00072   
00073   if (headAttrib == NULL)
00074   {
00075     headAttrib = cubit_attrib_ptr;
00076     cubit_attribute_status = CUBIT_SUCCESS;
00077   }
00078   else
00079   {
00080     for(temp_ptr = headAttrib;
00081         temp_ptr->next_attrib() != NULL;
00082         temp_ptr = temp_ptr->next_attrib());
00083     temp_ptr->set_next_attrib(cubit_attrib_ptr);
00084     cubit_attribute_status = CUBIT_SUCCESS;
00085   }
00086   return cubit_attribute_status;
00087 }
00088 
00089 CubitStatus CubitAttribUser::put_simple_attrib 
00090   (const CubitSimpleAttrib& new_csattrib_ptr, CubitBoolean append_it)
00091 {
00092   Body* Body_ptr;
00093   Body_ptr = CAST_TO(this, Body);
00094   BasicTopologyEntity* BTE_ptr;
00095   BTE_ptr = CAST_TO(this, BasicTopologyEntity);
00096   if ( Body_ptr != NULL )
00097   {
00098       // Get the OSME pointer
00099     BodySM* OSME_ptr = Body_ptr->get_body_sm_ptr();
00100     
00101       // check for duplicates
00102     if (DEBUG_FLAG(94))
00103     {
00104       DLIList<CubitSimpleAttrib> cs_list;
00105       OSME_ptr->get_simple_attribute(cs_list);
00106       for (int i = cs_list.size(); i > 0; i--)
00107       {
00108         const CubitSimpleAttrib cs_attrib = cs_list.get_and_step();
00109         if (cs_attrib == new_csattrib_ptr)
00110           PRINT_INFO("Trying to add equivalent attribute of type %s on Body %d.\n",
00111                      new_csattrib_ptr.character_type().c_str(), Body_ptr->id());
00112         else if (cs_attrib.character_type() == new_csattrib_ptr.character_type())
00113           PRINT_INFO("Trying to add attribute of same type %s on Body %d.\n",
00114                      new_csattrib_ptr.character_type().c_str(), Body_ptr->id());
00115       }
00116     }
00117     
00118 //________  Change Code by DZ of Cat,  3/11/99 12:25:30 PM  ________
00119       // Attach this name to it
00120     if ( append_it )
00121        append_simple_attribute(OSME_ptr, new_csattrib_ptr);
00122 //________  Change End by DZ of Cat,  3/11/99 12:25:30 PM  ________
00123   }
00124     // Deal with BasicTopologyEntities
00125   else if ( BTE_ptr != NULL )
00126   {
00127       // Get the GeometryEntity pointer
00128     GeometryEntity* GE_ptr =
00129       BTE_ptr->get_geometry_entity_ptr();
00130     
00131     if( NULL == GE_ptr )
00132       return CUBIT_FAILURE;
00133 
00134       // check for duplicates
00135     if (DEBUG_FLAG(94))
00136     {
00137       DLIList<CubitSimpleAttrib> cs_list;
00138       GE_ptr->get_simple_attribute(cs_list);
00139       for (int i = cs_list.size(); i > 0; i--)
00140       {
00141         const CubitSimpleAttrib &cs_attrib = cs_list.get_and_step();
00142         if (cs_attrib == new_csattrib_ptr)
00143           PRINT_INFO("Trying to add equivalent attribute of type %s on %s %d.\n",
00144                      new_csattrib_ptr.character_type().c_str(),
00145                      BTE_ptr->class_name(), BTE_ptr->id());
00146         else if (cs_attrib.character_type() == new_csattrib_ptr.character_type())
00147           PRINT_INFO("Trying to add attribute of same type %s on %s %d.\n",
00148                      new_csattrib_ptr.character_type().c_str(),
00149                      BTE_ptr->class_name(), BTE_ptr->id());
00150       }
00151     }
00152 
00153 //_________  Add Code by DZ of Cat,  3/11/99 11:10:29 AM  _________
00154       // Attach this name to it
00155     if ( append_it )
00156        append_simple_attribute(GE_ptr, new_csattrib_ptr);
00157 //_________  Code End by DZ of Cat,  3/11/99 11:10:29 AM  _________
00158    
00159   }
00160     // Deal with all other RefEntities.  As these do not have any
00161     // underlying entities (such as solid model entities) associated
00162     // with them, this block is a do-nothing block.
00163   else
00164   {
00165   }
00166   
00167   if (DEBUG_FLAG(90))
00168   {
00169     RefEntity *ref_entity = CAST_TO(this, RefEntity);
00170     PRINT_DEBUG_90( "Putting simple attribute of type %s on"
00171                 " %s %d.\n", new_csattrib_ptr.character_type().c_str(),
00172                 ref_entity->class_name(), ref_entity->id());
00173   }
00174   
00175   return CUBIT_SUCCESS;
00176 }
00177 
00178 CubitStatus CubitAttribUser::clear_simple_attribs_set_to_actuate()
00179 {
00180   CubitAttrib *cubit_attrib_ptr = NULL;
00181   CubitAttrib *next_attrib_ptr = NULL;
00182   for(cubit_attrib_ptr = headAttrib;
00183       cubit_attrib_ptr != NULL;)
00184   {
00185     //ignore Assembly and Name attributes
00186     next_attrib_ptr = cubit_attrib_ptr->next_attrib();
00187     if( cubit_attrib_ptr->int_attrib_type() != CA_ENTITY_NAME && 
00188         cubit_attrib_ptr->int_attrib_type() != CA_ASSEMBLY_DATA &&
00189         CGMApp::instance()->attrib_manager()->auto_actuate_flag(
00190           cubit_attrib_ptr->int_attrib_type()))
00191     {
00192       remove_cubit_attrib( cubit_attrib_ptr );
00193       delete cubit_attrib_ptr;
00194     }
00195     cubit_attrib_ptr = next_attrib_ptr;
00196   }
00197  
00198   if (DEBUG_FLAG(94))
00199   {
00200     PRINT_DEBUG_94("CubitAttribUser::clear_simple_attribs()\n");
00201   }
00202   TopologyEntity* te_ptr = dynamic_cast<TopologyEntity*>(this);
00203   if( !te_ptr )
00204     return CUBIT_FAILURE;
00205 
00206   remove_all_simple_attribute(te_ptr->bridge_manager()->topology_bridge());
00207   write_cubit_attrib_by_type(CA_ASSEMBLY_DATA);
00208   write_cubit_attrib_by_type( CA_ENTITY_NAME );
00209   set_written_flag(CUBIT_FALSE);
00210   return CUBIT_SUCCESS; 
00211 }
00212 
00213 CubitStatus CubitAttribUser::clear_simple_attribs()
00214 {
00215 
00216   CubitAttrib *cubit_attrib_ptr = NULL;
00217   CubitAttrib *next_attrib_ptr = NULL;
00218   for(cubit_attrib_ptr = headAttrib;
00219       cubit_attrib_ptr != NULL;)
00220   {
00221     //ignore Assembly and Name attributes
00222     next_attrib_ptr = cubit_attrib_ptr->next_attrib();
00223     if( cubit_attrib_ptr->int_attrib_type() != CA_ENTITY_NAME && 
00224         cubit_attrib_ptr->int_attrib_type() != CA_ASSEMBLY_DATA)
00225     {
00226       remove_cubit_attrib( cubit_attrib_ptr );
00227       delete cubit_attrib_ptr;
00228     }
00229     cubit_attrib_ptr = next_attrib_ptr;
00230   }
00231  
00232   if (DEBUG_FLAG(94))
00233   {
00234     PRINT_DEBUG_94("CubitAttribUser::clear_simple_attribs()\n");
00235   }
00236   TopologyEntity* te_ptr = dynamic_cast<TopologyEntity*>(this);
00237   if( !te_ptr )
00238     return CUBIT_FAILURE;
00239   
00240   remove_all_simple_attribute(te_ptr->bridge_manager()->topology_bridge());
00241 
00242   update_cubit_attrib(CA_ASSEMBLY_DATA);
00243   write_cubit_attrib_by_type(CA_ASSEMBLY_DATA);
00244   update_cubit_attrib(CA_ENTITY_NAME);
00245   write_cubit_attrib_by_type( CA_ENTITY_NAME );
00246   set_written_flag(CUBIT_FALSE);
00247   return CUBIT_SUCCESS; 
00248 }
00249 
00250 CubitStatus CubitAttribUser::write_specific_cubit_attrib(CubitAttrib* cubit_attrib_ptr)
00251 {
00252   CubitStatus result = CUBIT_SUCCESS;
00253   
00254     // don't write if this attrib is marked as deleted or it has already been written
00255     // Also, only write if the write flag is on for this attribute type
00256   if ((cubit_attrib_ptr->delete_attrib() != CUBIT_TRUE) &&
00257 //      (cubit_attrib_ptr->has_written() != CUBIT_TRUE) &&
00258       (CGMApp::instance()->attrib_manager()->auto_write_flag(cubit_attrib_ptr->int_attrib_type()) == CUBIT_TRUE)) 
00259   {
00260 
00261     if (DEBUG_FLAG(90)) {
00262       RefEntity *this_entity = CAST_TO(this, RefEntity);
00263       PRINT_DEBUG_90( "Writing attribute for %s %d, type %s\n",
00264                   this_entity->class_name(), this_entity->id(),
00265                   cubit_attrib_ptr->att_internal_name());
00266     }
00267 
00268       // set has_written flag here, before actually writing - a trick to
00269       // allow some attributes to detect they're being written, and do any
00270       // final setup they need to do before the actual write takes place (used
00271       // in CAMeshContainer, for example)
00272     cubit_attrib_ptr->has_written(CUBIT_TRUE);
00273 
00274     const CubitSimpleAttrib &csa_ptr = cubit_attrib_ptr->cubit_simple_attrib();
00275     
00276     result = put_simple_attrib(csa_ptr);
00277 
00278       // if the write wasn't successful, reset the write flag
00279     if (result != CUBIT_SUCCESS) cubit_attrib_ptr->has_written(CUBIT_FALSE);
00280 
00281   }
00282   
00283   return result;
00284 }
00285   
00286 CubitStatus CubitAttribUser::write_cubit_attrib_by_type(int attrib_type)
00287 {
00288   DLIList<CubitAttrib*> attrib_list;
00289   find_cubit_attrib_type(attrib_type, attrib_list);
00290   CubitStatus write_status = write_cubit_attrib_list(attrib_list);
00291   return write_status;
00292 }
00293   
00294 CubitStatus CubitAttribUser::write_cubit_attrib_list(DLIList<CubitAttrib*> 
00295                                                        attrib_list)
00296 {
00297   CubitStatus write_status = CUBIT_SUCCESS;
00298   attrib_list.reset();
00299   for(int i = attrib_list.size(); i > 0; i--)
00300   {
00301     CubitAttrib* cubit_attrib_ptr = attrib_list.get_and_step();
00302     if (write_specific_cubit_attrib(cubit_attrib_ptr) == CUBIT_FAILURE)
00303       write_status = CUBIT_FAILURE;
00304   }
00305   return write_status;
00306 }
00307   
00308 CubitStatus CubitAttribUser::write_cubit_attribs()
00309 {
00310     // write the attributes
00311   CubitStatus write_status = CUBIT_SUCCESS;
00312   DLIList<CubitAttrib*> attrib_list;
00313   CubitAttrib *attrib;
00314   get_cubit_attrib_list(attrib_list);
00315   attrib_list.reset();
00316   int i;
00317   for(i = attrib_list.size(); i != 0; i--)
00318   {
00319     attrib = attrib_list.get_and_step();
00320     if (write_specific_cubit_attrib(attrib) == CUBIT_FAILURE)
00321       write_status = CUBIT_FAILURE;
00322   }
00323   
00324   return write_status;
00325 }
00326  
00327 void CubitAttribUser::split_owner(DLIList<CubitSimpleAttrib> &csa_list)
00328 {
00329   
00330     //- if owner is to be split, get simple attribs for new entity
00331 
00332     // first auto create attributes
00333   /*CubitStatus success = */
00334   CGMApp::instance()->attrib_manager()->auto_update_attribs(CAST_TO(this, RefEntity));
00335 
00336     // call split for each attribute, getting back new csa's
00337   DLIList<CubitAttrib*> ca_list;
00338   get_cubit_attrib_list(ca_list);
00339   int i;
00340   for ( i = ca_list.size(); i > 0; i--) {
00341     CubitAttrib *ca_ptr = ca_list.get_and_step();
00342     CubitSimpleAttrib csa_ptr = ca_ptr->split_owner();
00343     if (!csa_ptr.isEmpty())
00344       csa_list.append(csa_ptr);
00345   }
00346 
00347     // now, check delete flag for each ca_ptr, and delete if necessary
00348   for (i = ca_list.size(); i > 0; i--) {
00349     CubitAttrib *ca_ptr = ca_list.get_and_step();
00350     if (ca_ptr->delete_attrib()) {
00351       remove_cubit_attrib(ca_ptr);
00352       delete ca_ptr;
00353     }
00354   }
00355 
00356     // ok, we're done
00357 }
00358 
00359 void CubitAttribUser::merge_owner(RefEntity *deletable_entity)
00360 {
00361     //- if owner is to be merged, combine attribs from deletable_entity with this
00362 
00363     // if no deletable entity, keep the entity name and delete the other
00364     // attribs on this entity
00365   int i;
00366   if (deletable_entity == NULL) {
00367     DLIList<CubitAttrib*> ca_list;
00368     get_cubit_attrib_list(ca_list);
00369     for (i = ca_list.size(); i > 0; i--) {
00370       CubitAttrib *ca_ptr = ca_list.get_and_step();
00371       if (ca_ptr->int_attrib_type() != CA_ENTITY_NAME &&
00372           ca_ptr->int_attrib_type() != CA_ASSEMBLY_DATA &&
00373           ca_ptr->int_attrib_type() != CA_MESH_OUTPUT_GROUP)
00374       {
00375         remove_cubit_attrib(ca_ptr);
00376         delete ca_ptr;
00377       }
00378     }
00379 
00380     return;
00381   }
00382     
00383     // first auto create attributes
00384   /*CubitStatus success = */
00385   CGMApp::instance()->attrib_manager()->auto_update_attribs(CAST_TO(this, RefEntity));
00386 
00387     // copy any attr's on deletable_entity but not on this
00388   auto_create_for_merge(deletable_entity);
00389 
00390     // call merge for each attribute, passing other as argument
00391   DLIList<CubitAttrib*> ca_list, deletable_ca_list;
00392   get_cubit_attrib_list(ca_list);
00393   deletable_entity->get_cubit_attrib_list(deletable_ca_list);
00394   assert(ca_list.size() >= deletable_ca_list.size());
00395   for (i = ca_list.size(); i > 0; i--) {
00396     CubitAttrib *ca_ptr = ca_list.get_and_step();
00397     deletable_ca_list.reset();
00398     CubitAttrib *deletable_ca_ptr = NULL;
00399     if (deletable_ca_list.size() > 0) {
00400       deletable_ca_ptr = deletable_ca_list.get();
00401         // get the corresponding deletable attribute, then extract it from
00402         //   the list
00403       while (ca_ptr->int_attrib_type() != deletable_ca_ptr->int_attrib_type() &&
00404              !deletable_ca_list.is_at_end()) {
00405         deletable_ca_list.step();
00406         deletable_ca_ptr = deletable_ca_list.get();
00407       }
00408       if (ca_ptr->int_attrib_type() == deletable_ca_ptr->int_attrib_type())
00409         deletable_ca_list.extract();
00410       else deletable_ca_ptr = NULL;
00411     }
00412     ca_ptr->merge_owner(deletable_ca_ptr);
00413   }
00414   
00415     // now, check delete flag for each ca_ptr, and delete if necessary
00416   for (i = ca_list.size(); i > 0; i--) {
00417     CubitAttrib *ca_ptr = ca_list.get_and_step();
00418     if (ca_ptr->delete_attrib()) {
00419       remove_cubit_attrib(ca_ptr);
00420       delete ca_ptr;
00421     }
00422   }
00423 
00424   // ok, we're done
00425 }
00426 
00427 void CubitAttribUser::transf_owner(const CubitVector &matrow1,
00428                                    const CubitVector &matrow2,
00429                                    const CubitVector &matrow3,
00430                                    const CubitVector &translate_vec,
00431                                    const double scale_factor)
00432 {
00433   
00434     //- called if owner is to be transformed; simply passes information
00435     //- to attribs on this entity; does *not* autocreate
00436   
00437   DLIList<CubitAttrib*> ca_list;
00438   get_cubit_attrib_list(ca_list);
00439   for (int i = ca_list.size(); i > 0; i--) {
00440     CubitAttrib *ca_ptr = ca_list.get_and_step();
00441     ca_ptr->transf_owner(matrow1, matrow2, matrow3,
00442                          translate_vec, scale_factor);
00443   }
00444 
00445     // ok, we're done
00446 }
00447 
00448 void CubitAttribUser::auto_create_for_merge(RefEntity *deletable_entity)
00449 {
00450     // copy any attr's on deletable_entity but not on this
00451   DLIList<CubitAttrib*> deletable_ca_list;
00452   deletable_entity->get_cubit_attrib_list(deletable_ca_list);
00453   if (deletable_ca_list.size() == 0) return;
00454   
00455   DLIList<CubitAttrib*> new_list;
00456   RefEntity *entity = CAST_TO(this, RefEntity);
00457   for (int i = deletable_ca_list.size(); i > 0; i--) {
00458     new_list.clean_out();
00459     CubitAttrib *deletable_ca_ptr = deletable_ca_list.get_and_step();
00460     find_cubit_attrib_type(deletable_ca_ptr->int_attrib_type(), new_list);
00461     if (new_list.size() == 0)
00462     {
00463       CGMApp::instance()->attrib_manager()->create_cubit_attrib(
00464                                                 deletable_ca_ptr->int_attrib_type(),
00465             entity, CubitSimpleAttrib());
00466     }
00467   }
00468 }
00469 
00470 CubitStatus CubitAttribUser::actuate_cubit_attrib (CubitAttrib* cubit_attrib_ptr)
00471 {
00472   CubitStatus return_value = CUBIT_FAILURE;
00473   if (cubit_attrib_ptr != NULL )
00474   {
00475     if (cubit_attrib_ptr->has_actuated() == CUBIT_TRUE ||
00476         cubit_attrib_ptr->delete_attrib() == CUBIT_TRUE) {
00477       return CUBIT_FAILURE;
00478     }
00479     
00480     return_value = cubit_attrib_ptr->actuate();
00481     if (cubit_attrib_ptr->delete_attrib() == CUBIT_TRUE)
00482     {
00483       return_value = remove_cubit_attrib(cubit_attrib_ptr);
00484       delete cubit_attrib_ptr;
00485     }
00486   }
00487   return return_value;
00488 }
00489 
00490 CubitStatus CubitAttribUser::actuate_cubit_attrib (int attrib_type)
00491 {
00492   DLIList<CubitAttrib*> attrib_list;
00493   find_cubit_attrib_type(attrib_type, attrib_list);
00494   CubitStatus actuate_status = actuate_cubit_attrib(attrib_list);
00495   return actuate_status;
00496 }
00497 
00498 CubitStatus CubitAttribUser::actuate_cubit_attrib(DLIList<CubitAttrib*>
00499                                                       attrib_list)
00500 {
00501   CubitStatus actuate_status = CUBIT_SUCCESS;
00502   attrib_list.reset();
00503   for(int i = 0; i < attrib_list.size(); i++)
00504   {
00505     CubitAttrib* cubit_attrib_ptr = attrib_list.get_and_step();
00506     if (actuate_cubit_attrib(cubit_attrib_ptr) == CUBIT_FAILURE)
00507       actuate_status = CUBIT_FAILURE;
00508   }
00509   return actuate_status;
00510 } 
00511 
00512 CubitStatus CubitAttribUser::actuate_cubit_attrib(DLIList<RefEntity*> refent_list,
00513                                                   int attrib_type)
00514                                                   
00515 {
00516   CubitStatus actuate_status = CUBIT_SUCCESS;
00517   DLIList<CubitAttrib*> attrib_list;
00518   RefEntity *ref_ent;
00519   for(int i = refent_list.size(); i > 0; i--)
00520   {
00521     ref_ent = refent_list.get_and_step();
00522     TopologyEntity* me_ptr = dynamic_cast<TopologyEntity*>(ref_ent);
00523     if( me_ptr && me_ptr->deactivated() )
00524       continue;
00525     ref_ent->find_cubit_attrib_type(attrib_type, attrib_list);
00526     if (attrib_list.size() > 0)
00527       return ((attrib_list.get())->actuate_list(refent_list));
00528   }
00529   return actuate_status;
00530 }
00531 
00532 //CubitStatus CubitAttribUser::actuate_cubit_attrib ()
00533 //{
00534 //  CubitStatus actuate_status = CUBIT_SUCCESS;
00535 //  DLIList<CubitAttrib*> attrib_list;
00536 //  CubitAttrib *attrib;
00537 //  get_cubit_attrib_list(attrib_list);
00538 //  attrib_list.reset();
00539 //
00540 //  for(int i = attrib_list.size(); i != 0; i--)
00541 //  {
00542 //    attrib = attrib_list.get_and_step();
00543 //      if (attrib->actuate() == CUBIT_FAILURE)
00544 //      {
00545 //        actuate_status = CUBIT_FAILURE;
00546 //      }
00547 //      if (attrib->delete_attrib() == CUBIT_TRUE)
00548 //      {
00549 //        remove_cubit_attrib(attrib);
00550 //        delete attrib;
00551 //      }
00552 //  }
00553 //  return actuate_status;
00554 //}
00555 
00556 CubitStatus CubitAttribUser::auto_actuate_cubit_attrib (CubitBoolean from_constructor,
00557                                                         CubitBoolean after_geom_changes)
00558 {
00559   CubitStatus actuate_status = CUBIT_SUCCESS;
00560   CubitAttrib *attrib;
00561   DLIList<CubitAttrib*> attrib_list;
00562   get_cubit_attrib_list(attrib_list);
00563   attrib_list.reset();
00564   int i;
00565   for( i = attrib_list.size(); i != 0; i--)
00566   {
00567     attrib = attrib_list.get_and_step();
00568       // check first for deletable attribute; this attribute shouldn't really be here,
00569       // but until we figure out why it is...
00570     if (attrib->delete_attrib() == CUBIT_TRUE) {
00571       PRINT_DEBUG_90("Trying to auto actuate deletable attribute - this is bad...\n");
00572     }
00573     else if (attrib->auto_actuate_flag() == CUBIT_TRUE &&
00574         !attrib->has_actuated() &&
00575         (!from_constructor || attrib->actuate_in_constructor()) &&
00576         (after_geom_changes || !attrib->actuate_after_geom_changes()))
00577     {
00578 
00579       PRINT_DEBUG_90("Actuating attribute type %s for %s %d\n",
00580                      attrib->att_internal_name(), attrib->attrib_owner()->class_name(),
00581                      attrib->attrib_owner()->id());
00582       
00583       if(attrib->actuate() == CUBIT_FAILURE)
00584       {
00585         actuate_status = CUBIT_FAILURE;
00586       }
00587 
00588         // need to check again for delete flag, since it might have been set
00589         // in actuate function
00590       if( attrib->delete_attrib() == CUBIT_TRUE)
00591       {
00592         remove_cubit_attrib(attrib);
00593         delete attrib;
00594       }
00595     }
00596   }
00597 
00598 //  if (CADeferredAttrib::cleanup_cadas(from_constructor, after_geom_changes) == CUBIT_FAILURE)
00599 //    actuate_status = CUBIT_FAILURE;
00600 
00601   return actuate_status;
00602 }
00603 
00604 //CubitStatus CubitAttribUser::update_cubit_attrib (CubitAttrib* cubit_attrib_ptr)
00605 //{
00606 //  if (cubit_attrib_ptr != NULL)
00607 //      return cubit_attrib_ptr->update();
00608 //  return CUBIT_FAILURE;
00609 //}
00610 
00611 CubitStatus CubitAttribUser::update_cubit_attrib (int attrib_type)
00612 {
00613   DLIList<CubitAttrib*> attrib_list;
00614   CubitAttrib* new_attrib = NULL;
00615   find_cubit_attrib_type(attrib_type, attrib_list);
00616 
00617   if( attrib_list.size() > 1 )
00618   {
00619     PRINT_WARNING("File contains multiples of the same attrib.\n");
00620     PRINT_INFO("    Something was not written correctly.\n");
00621   }
00622   
00623   if(attrib_list.size() == 0)
00624     new_attrib = get_cubit_attrib(attrib_type);
00625   else
00626     new_attrib = attrib_list.get();
00627 
00628   assert(new_attrib != 0);
00629   CubitStatus update_status = new_attrib->update();
00630   
00631   return update_status;
00632 }
00633 
00634 //CubitStatus CubitAttribUser::update_cubit_attrib(DLIList<CubitAttrib*>
00635 //                                                      attrib_list)
00636 //{
00637 //  CubitStatus update_status = CUBIT_SUCCESS;
00638 //  attrib_list.reset();
00639 //  for(int i = attrib_list.size(); i > 0; i--)
00640 //  {
00641 //    CubitAttrib* cubit_attrib_ptr = attrib_list.get_and_step();
00642 //    if (cubit_attrib_ptr->update() == CUBIT_FAILURE)
00643 //      update_status = CUBIT_FAILURE;
00644 //  }
00645 //  return update_status;
00646 //} 
00647 
00648 //CubitStatus CubitAttribUser::update_cubit_attrib()
00649 //{
00650 //  return CUBIT_FAILURE;
00651 //} 
00652 
00653 CubitStatus CubitAttribUser::auto_update_cubit_attrib ()
00654 {
00655 
00656     // for this cau, automatically create and update ca's
00657 
00658     // first, create ca's for any attribute type which has its auto
00659     // update flag set and which isn't present yet on this entity
00660   /*CubitStatus success = */
00661   CGMApp::instance()->attrib_manager()->auto_update_attribs(CAST_TO(this, RefEntity));
00662 
00663     // now, update all attributes present on this entity
00664   CubitStatus update_status = CUBIT_SUCCESS;
00665   DLIList<CubitAttrib*> attrib_list;
00666   DLIList<CubitAttrib*> attribs_to_delete;
00667   CubitAttrib *attrib;
00668   get_cubit_attrib_list(attrib_list);
00669   attrib_list.reset();
00670   int i;
00671   for( i = attrib_list.size(); i != 0; i--)
00672   {
00673     attrib = attrib_list.get_and_step();
00674     if (!attrib->has_updated()) {
00675         // if this attribute has written already, reset the information in it
00676         // so it gets a "clean" update (otherwise information can be added to
00677         // lists on the attrib more than once)
00678       if (CUBIT_TRUE == attrib->has_written())
00679          attrib->reset();
00680     
00681         // reset the delete flag here, so we don't need to do it in every attribute
00682         // (it'll get set back to delete if the update isn't successful)
00683       attrib->delete_attrib(CUBIT_FALSE);
00684       PRINT_DEBUG_90("Updating attribute type %s for %s %d, delete = ",
00685                      attrib->att_internal_name(), attrib->attrib_owner()->class_name(),
00686                      attrib->attrib_owner()->id());
00687       update_status = attrib->update();
00688 
00689       if( attrib->delete_attrib() )
00690         attribs_to_delete.append( attrib );
00691 
00692       PRINT_DEBUG_90("%s\n",
00693                      (attrib->delete_attrib() == CUBIT_FALSE ? "NO" : "YES"));
00694 
00695         // if update was successful, reset the written flag (assumes that all
00696         // updates are done before writing starts)
00697         // (don't reset if it's the entity_name attrib, since this attrib is
00698         // written automatically every time it's updated)
00699       if (update_status == CUBIT_SUCCESS && attrib->int_attrib_type() != CA_ENTITY_NAME)
00700         attrib->has_written(CUBIT_FALSE);
00701     }
00702     else
00703     {
00704         PRINT_DEBUG_90("Not updating attribute type %s for %s %d, delete = ",
00705                      attrib->att_internal_name(), attrib->attrib_owner()->class_name(),
00706                      attrib->attrib_owner()->id());
00707         PRINT_DEBUG_90("%s\n",
00708                      (attrib->delete_attrib() == CUBIT_FALSE ? "NO" : "YES"));
00709     }
00710   }
00711   
00712   
00713   //remove any attribs that don't need to be there
00714   remove_cubit_attrib( attribs_to_delete ); 
00715 
00716 /*
00717   RefEntity* re_ptr;
00718   re_ptr = CAST_TO(this, RefEntity);
00719   DLIList<RefEntity*> children;
00720   re_ptr->get_child_ref_entities( children );
00721   for ( i = children.size(); i > 0; i-- )
00722   {
00723     children.get()->auto_update_cubit_attrib();
00724     children.step();
00725   }
00726 */
00727   return update_status;
00728 }
00729 
00730 void CubitAttribUser::auto_reset_cubit_attrib (DLIList<RefEntity*> ref_ents)
00731 {
00732     // set the update flag back off for all attribs on these entities and their children
00733   DLIList<RefEntity*> children, temp_list;
00734   int i;
00735   for (i = ref_ents.size(); i > 0; i--) {
00736     temp_list.clean_out();
00737     ref_ents.get_and_step()->get_all_child_ref_entities(temp_list);
00738     children += temp_list;
00739   }
00740   ref_ents.merge_unique(children);
00741   
00742     // ok, have a unique'd list if entities; now reset on each of them
00743   ref_ents.reset();
00744   for (i = ref_ents.size(); i > 0; i--) {
00745     ref_ents.get()->set_written_flag(CUBIT_FALSE);
00746     ref_ents.get_and_step()->set_updated_flag(CUBIT_FALSE);
00747   }
00748 }
00749 
00750 //void CubitAttribUser::auto_reset_cubit_attrib ()
00751 //{
00752 //    // set the update flag back off for all attribs on these entities and their children
00753 //  DLIList<CubitAttrib*> attrib_list;
00754 //  CubitAttrib *attrib;
00755 //  get_cubit_attrib_list(attrib_list);
00756 //  attrib_list.reset();
00757 //  int i;
00758 //  for( i = attrib_list.size(); i != 0; i--)
00759 //  {
00760 //    attrib = attrib_list.get_and_step();
00761 //    if (attrib->has_updated() && attrib->has_written())
00762 //      attrib->has_updated(CUBIT_FALSE);
00763 //  }
00764 //}
00765 
00766 CubitStatus CubitAttribUser::auto_update_cubit_attrib (DLIList<RefEntity*> &entity_list,
00767                                                        CubitBoolean write_too)
00768 {
00769     //- for entity_list, auto create, update and write ca's
00770 
00771     // now, reset the update and write flags for these entities
00772     // and their children
00773   auto_reset_cubit_attrib(entity_list);
00774 
00775     // need to update all then write all in separate loops,
00776     // to prevent duplication of attributes
00777   int i;
00778   for ( i = entity_list.size(); i > 0; i--) 
00779      entity_list.get_and_step()->auto_update_cubit_attrib();
00780 
00781   if (write_too) {
00782     for (i = entity_list.size(); i > 0; i--) 
00783       entity_list.get_and_step()->write_cubit_attribs();
00784   }
00785   
00786   
00787   return CUBIT_SUCCESS;
00788 }
00789 
00790 CubitStatus CubitAttribUser::clear_all_simple_attrib( DLIList<RefEntity*>& entity_list )
00791 {
00792   CubitStatus result = CUBIT_SUCCESS;
00793   for( int i = entity_list.size(); i--; )
00794     if( entity_list.get_and_step()->clear_simple_attribs() != CUBIT_SUCCESS )
00795       result = CUBIT_FAILURE;
00796   return result;
00797 }
00798 
00799 CubitStatus CubitAttribUser::clear_all_simple_attrib_set_to_actuate( DLIList<RefEntity*>& entity_list )
00800 {
00801   CubitStatus result = CUBIT_SUCCESS;
00802   for( int i = entity_list.size(); i--; )
00803     if( entity_list.get_and_step()->clear_simple_attribs_set_to_actuate() != CUBIT_SUCCESS )
00804       result = CUBIT_FAILURE;
00805   return result;
00806 }
00807 
00808 void CubitAttribUser::find_cubit_attrib_type(int type,
00809                                              DLIList<CubitAttrib*>& attrib_list) const
00810 {
00811   for(CubitAttrib* cubit_attrib_ptr = headAttrib;
00812       cubit_attrib_ptr != NULL;
00813       cubit_attrib_ptr = cubit_attrib_ptr->next_attrib())
00814   {
00815     if (type == cubit_attrib_ptr->int_attrib_type())
00816       attrib_list.append_unique(cubit_attrib_ptr);
00817   }
00818 }
00819 
00820 CubitStatus CubitAttribUser::remove_cubit_attrib(DLIList<CubitAttrib*>
00821                                                       attrib_list)
00822 {
00823   CubitStatus remove_status = CUBIT_SUCCESS;
00824   attrib_list.reset();
00825   for(int i = attrib_list.size(); i != 0; i--)
00826   {
00827     CubitAttrib* cubit_attrib_ptr = attrib_list.get_and_step();
00828     if (remove_cubit_attrib(cubit_attrib_ptr) == CUBIT_FAILURE)
00829       remove_status = CUBIT_FAILURE;
00830     delete cubit_attrib_ptr;
00831   }
00832   return remove_status;
00833 } 
00834 
00835 CubitStatus CubitAttribUser::remove_cubit_attrib(int attrib_type)
00836 {
00837   DLIList<CubitAttrib*> attrib_list;
00838   find_cubit_attrib_type(attrib_type, attrib_list);
00839   CubitStatus remove_status = remove_cubit_attrib(attrib_list);
00840   return remove_status;
00841 } 
00842 
00843 CubitStatus CubitAttribUser::remove_cubit_attrib (CubitAttrib*
00844                                                   cubit_attrib_ptr)
00845 {
00846   if (cubit_attrib_ptr == NULL)
00847     return CUBIT_FAILURE;
00848   CubitStatus remove_geom = remove_attrib_geometry_entity(cubit_attrib_ptr);
00849   //CubitStatus remove_cubit = CUBIT_FAILURE;
00850   CubitBoolean once = CUBIT_FALSE;
00851   if (headAttrib == cubit_attrib_ptr) {
00852     headAttrib = cubit_attrib_ptr->next_attrib();
00853     once = CUBIT_TRUE;
00854   }
00855   
00856   CubitAttrib* temp_cubit_attrib_ptr = headAttrib;
00857   while (temp_cubit_attrib_ptr != NULL) {
00858     if (cubit_attrib_ptr == temp_cubit_attrib_ptr->next_attrib()) {
00859       if (once) {
00860         PRINT_DEBUG_90("Removing attribute more than once.\n");
00861       }
00862       temp_cubit_attrib_ptr->set_next_attrib(cubit_attrib_ptr->
00863                                              next_attrib());
00864       once = CUBIT_TRUE;
00865     }
00866       
00867     temp_cubit_attrib_ptr = temp_cubit_attrib_ptr->next_attrib();
00868   }
00869 
00870   return remove_geom;
00871 }
00872 
00873 //CubitStatus CubitAttribUser::remove_cubit_attrib ()
00874 //{
00875 //  CubitAttrib *cubit_attrib_ptr = NULL;
00876 //  for(cubit_attrib_ptr = headAttrib;
00877 //      cubit_attrib_ptr != NULL;)
00878 //  {
00879 //    headAttrib = cubit_attrib_ptr->next_attrib();
00880 //    delete cubit_attrib_ptr;
00881 //    cubit_attrib_ptr = headAttrib;
00882 //  }
00883 //  remove_attrib_geometry_entity();
00884 //  return CUBIT_SUCCESS;
00885 //}
00886   
00887   
00888 
00889 CubitStatus CubitAttribUser::auto_read_cubit_attrib()
00890 {
00891     // auto read all simple attributes on this entity & create CA's for them;
00892     // checks global and CA-specific auto read flag, and puts CSA's back on
00893     // entity if auto read for that type is off
00894   
00895   CubitStatus cubit_assign_status = CUBIT_FAILURE;
00896   
00897     // Get the GeometryEntity of this RefEntity (it could be the OSME
00898     // if it is a Body) and get its name, if it exists
00899   
00900   DLIList<CubitSimpleAttrib> csattrib_list;
00901 
00902     // Deal with a Body entity
00903   Body* Body_ptr = CAST_TO(this, Body);
00904   BasicTopologyEntity* BTE_ptr = CAST_TO(this, BasicTopologyEntity);
00905   if ( Body_ptr != NULL )
00906   {
00907     BodySM* OSME_ptr = Body_ptr->get_body_sm_ptr();
00908     OSME_ptr->get_simple_attribute(csattrib_list);
00909     remove_all_simple_attribute(OSME_ptr);
00910   }
00911   else if ( BTE_ptr != NULL )
00912   {
00913     GeometryEntity* GE_ptr = BTE_ptr->get_geometry_entity_ptr();
00914     GE_ptr->get_simple_attribute(csattrib_list);
00915     remove_all_simple_attribute(GE_ptr);
00916   }
00917   else return CUBIT_SUCCESS;
00918   
00919   csattrib_list.reset();
00920   for(int i = csattrib_list.size(); i != 0; i--)
00921   {
00922     const CubitSimpleAttrib& cubit_simple_attrib_ptr = csattrib_list.get_and_step();
00923     int csa_type = CGMApp::instance()->attrib_manager()->attrib_type(cubit_simple_attrib_ptr);
00924     CubitAttrib *new_attrib = NULL;
00925     if (CGMApp::instance()->attrib_manager()->auto_read_flag(csa_type))
00926         // auto create this CA
00927       new_attrib = CGMApp::instance()->attrib_manager()->create_cubit_attrib(csa_type,
00928                                                     CAST_TO(this, RefEntity), cubit_simple_attrib_ptr);
00929     
00930     if (new_attrib != NULL && new_attrib->delete_attrib() == CUBIT_FALSE) 
00931       cubit_assign_status = CUBIT_SUCCESS;
00932     else if (new_attrib != NULL && new_attrib->delete_attrib() == CUBIT_TRUE) {
00933       remove_cubit_attrib(new_attrib);
00934       delete new_attrib;
00935     }
00936     else
00937       put_simple_attrib(cubit_simple_attrib_ptr);
00938   }
00939   
00940   return cubit_assign_status;
00941 }
00942 
00943 CubitStatus CubitAttribUser::read_cubit_attrib(int attrib_type)
00944 {
00945 
00946   CubitStatus read_status;
00947   
00948     // get all simple attrib's
00949   DLIList<CubitSimpleAttrib> csattrib_list;
00950 
00951     // Deal with a Body entity
00952   Body* Body_ptr = CAST_TO(this, Body);
00953   BasicTopologyEntity* BTE_ptr = CAST_TO(this, BasicTopologyEntity);
00954   if ( Body_ptr != NULL )
00955   {
00956     BodySM* OSME_ptr = Body_ptr->get_body_sm_ptr();
00957     read_status = OSME_ptr->get_simple_attribute(csattrib_list);
00958     remove_all_simple_attribute(OSME_ptr);
00959   }
00960   else if ( BTE_ptr != NULL )
00961   {
00962     GeometryEntity* GE_ptr = BTE_ptr->get_geometry_entity_ptr();
00963     read_status = GE_ptr->get_simple_attribute(csattrib_list);
00964     remove_all_simple_attribute(GE_ptr);
00965   }
00966   else return CUBIT_SUCCESS;
00967   
00968   csattrib_list.reset();
00969   for(int i = csattrib_list.size(); i != 0; i--)
00970   {
00971     const CubitSimpleAttrib& cubit_simple_attrib_ptr = csattrib_list.get_and_step();
00972     int csa_type = CGMApp::instance()->attrib_manager()->attrib_type(cubit_simple_attrib_ptr);
00973     if (attrib_type == CA_ALL_ATTRIBUTES || csa_type == attrib_type) {
00974         // create this CA
00975 //       CubitAttrib *new_attrib =
00976       CGMApp::instance()->attrib_manager()->create_cubit_attrib(csa_type,
00977                                                                 CAST_TO(this, RefEntity), cubit_simple_attrib_ptr);
00978     }
00979     else {
00980         // otherwise we don't want to read this one; since the get_simple_attribute
00981         // took the attribute off, we'll have to put this one back on
00982       put_simple_attrib(cubit_simple_attrib_ptr);
00983     }
00984   }
00985       
00986   return read_status;
00987 }
00988   
00989 //CubitStatus CubitAttribUser::read_cubit_attrib(CubitBoolean read_children)
00990 //{
00991 //  CubitStatus read_status = CUBIT_SUCCESS;
00992 //  if (read_cubit_attrib(CA_ALL_ATTRIBUTES) == CUBIT_FAILURE)
00993 //      read_status = CUBIT_FAILURE;
00994 //
00995 //  if (read_children) {
00996 //      // now, call read for all children
00997 //    DLIList<RefEntity*> children;
00998 //    RefEntity* re_ptr;
00999 //    re_ptr = CAST_TO(this, RefEntity);
01000 //    re_ptr->get_all_child_ref_entities( children );
01001 //    CubitStatus temp_status;
01002 //    for ( int i = children.size(); i > 0; i-- )
01003 //    {
01004 //      temp_status = children.get()->read_cubit_attrib(CA_ALL_ATTRIBUTES);
01005 //      if (temp_status == CUBIT_FAILURE) read_status = CUBIT_FAILURE;
01006 //      children.step();
01007 //    }
01008 //  }
01009 //  
01010 //  return read_status;
01011 //}
01012  
01013 void CubitAttribUser::get_cubit_attrib_list (DLIList<CubitAttrib*>& attrib_list)
01014 {
01015   for(CubitAttrib* cubit_attrib_ptr = headAttrib;
01016       cubit_attrib_ptr != NULL;
01017       cubit_attrib_ptr = cubit_attrib_ptr->next_attrib()) {
01018     assert(NULL != cubit_attrib_ptr);
01019     attrib_list.append_unique(cubit_attrib_ptr);
01020   }
01021 }
01022 
01023 int CubitAttribUser::num_cubit_attrib()
01024 {
01025   int number = 0;
01026   for(CubitAttrib* cubit_attrib_ptr = headAttrib;
01027       cubit_attrib_ptr != NULL;
01028       cubit_attrib_ptr = cubit_attrib_ptr->next_attrib())
01029     number++;
01030 
01031   return number;
01032 }
01033 
01034 CubitStatus CubitAttribUser::remove_attrib_geometry_entity (CubitAttrib*
01035                                                             cubit_attrib_ptr)
01036 {
01037   CubitStatus removed = CUBIT_FAILURE;
01038 
01039   if(cubit_attrib_ptr == NULL)
01040     return removed;
01041 
01042   CubitSimpleAttrib csattrib_ptr = cubit_attrib_ptr->cubit_simple_attrib();
01043   if(!csattrib_ptr.isEmpty())
01044   {
01045     if (DEBUG_FLAG(90)) {
01046       RefEntity *ref_entity = CAST_TO(this, RefEntity);
01047       PRINT_DEBUG_90( "Removing simple attribute of type %s on"
01048                   " %s %d.\n", csattrib_ptr.character_type().c_str(),
01049                   ref_entity->class_name(), ref_entity->id());
01050     }
01051     
01052     TopologyEntity* topo_ptr = CAST_TO(this, TopologyEntity);
01053     if (topo_ptr && topo_ptr->bridge_manager()->topology_bridge())
01054     {
01055         remove_simple_attribute(topo_ptr->bridge_manager()->topology_bridge(), csattrib_ptr);
01056       removed = CUBIT_SUCCESS;
01057     }
01058   }
01059   return removed;
01060 }
01061 
01062 //CubitStatus CubitAttribUser::remove_attrib_geometry_entity ()
01063 //{
01064 //  CubitStatus removed = CUBIT_FAILURE;
01065 //  Body* Body_ptr = CAST_TO(this, Body);
01066 //    
01067 //  BasicTopologyEntity* BTE_ptr = CAST_TO(this, BasicTopologyEntity);
01068 //      //Deal with Bodies
01069 //  if ( Body_ptr != NULL )
01070 //  {
01071 //      // Get the OSME pointer
01072 //    BodySM* OSME_ptr = Body_ptr->get_body_sm_ptr();
01073 //    remove_all_simple_attribute(OSME_ptr);
01074 //    removed = CUBIT_SUCCESS;
01075 //  }
01076 //  
01077 //    // Deal with BasicTopologyEntities
01078 //  else if ( BTE_ptr != NULL )
01079 //  {
01080 //      // Get the GeometryEntity pointer
01081 //    GeometryEntity* GE_ptr = 
01082 //      BTE_ptr->get_geometry_entity_ptr();
01083 //    remove_all_simple_attribute(GE_ptr);
01084 //    removed = CUBIT_SUCCESS;
01085 //  }
01086 //
01087 //    // All other Entities
01088 //  else
01089 //  {
01090 //  }
01091 //  return removed;
01092 //}
01093 
01094 void CubitAttribUser::set_written_flag(CubitBoolean flag)
01095 {
01096   DLIList<CubitAttrib*> ca_list;
01097   get_cubit_attrib_list(ca_list);
01098   for (int i = ca_list.size(); i > 0; i--) {
01099     if (flag == CUBIT_FALSE && ca_list.get()->has_written() == CUBIT_TRUE)
01100       ca_list.get()->reset();
01101     ca_list.get_and_step()->has_written(flag);
01102   }
01103 }
01104 
01105 void CubitAttribUser::set_updated_flag(CubitBoolean flag)
01106 {
01107   DLIList<CubitAttrib*> ca_list;
01108   get_cubit_attrib_list(ca_list);
01109   for (int i = ca_list.size(); i > 0; i--)
01110     ca_list.get_and_step()->has_updated(flag);
01111 }
01112 
01113 //void CubitAttribUser::print_attribs() 
01114 //{
01115 //  PRINT_INFO("Attributes on %s %d:\n", 
01116 //             CAST_TO(this, RefEntity)->entity_name().c_str(),
01117 //             CAST_TO(this, RefEntity)->id());
01118 //  DLIList<CubitAttrib*> attrib_list;
01119 //  get_cubit_attrib_list(attrib_list);
01120 //  int i;
01121 //  for (i = attrib_list.size(); i > 0; i--)
01122 //    attrib_list.get_and_step()->print();
01123 //  
01124 //  if (attrib_list.size() == 0) PRINT_INFO("(none)\n");
01125 //}
01126 
01127 void CubitAttribUser::append_simple_attribute(TopologyBridge *bridge, const CubitSimpleAttrib& attrib_ptr)
01128 {
01129     // for merged objects, put attribute on other entities
01130   if (CubitSimpleAttrib::get_push_attribs() == CUBIT_TRUE ||
01131     CGMApp::instance()->attrib_manager()->auto_update_flag(CA_MERGE_PARTNER) == CUBIT_TRUE) {
01132   
01133     DLIList<TopologyBridge*> tb_list;
01134     bridge->bridge_manager()->get_bridge_list(tb_list);
01135 
01136       // if this entity is merged, it will have > 1 entity in the bridge
01137       // list
01138     tb_list.reset();
01139     assert(tb_list.size() == 0 || tb_list.get() == bridge);
01140 
01141       // Special handling of MergePartner attribute.  
01142       // Need to store the bridge sense in the attribute, which
01143       // is potentially different for different TopologyBridges.
01144     int type = CGMApp::instance()->attrib_manager()->attrib_type_from_internal_name(attrib_ptr.character_type().c_str());
01145     if ( type == CA_MERGE_PARTNER )
01146     {
01147       CubitSimpleAttrib merge_attrib = attrib_ptr;
01148         // now adjust the attrib on each bridge to hold the 
01149         // relative sense for that bridge.
01150       for (int i = tb_list.size(); i > 0; i--) {
01151         TopologyBridge *temp_tb = tb_list.get_and_step();
01152 
01153         CAMergePartner::set_bridge_sense( merge_attrib, temp_tb->bridge_sense() );
01154 
01155         GeometryEntity *geom_ptr = dynamic_cast<GeometryEntity*>(temp_tb);
01156         if (geom_ptr ) 
01157         {
01158           //if we're copying a merged entity, saved id should be zero
01159           if( GeometryModifyTool::instance()->get_copy_entity() ) 
01160             CAMergePartner::set_saved_id( merge_attrib, 0 );
01161           else
01162             CAMergePartner::set_saved_id( merge_attrib, geom_ptr->get_saved_id() );
01163 
01164           //First bridge should be marked as "survivor"
01165           if( i == tb_list.size() )
01166           {
01167             CAMergePartner::set_survivor( merge_attrib, 1 );
01168           }
01169           else
01170             CAMergePartner::set_survivor( merge_attrib, 0 );
01171         }
01172         append_attrib_internal(temp_tb, merge_attrib);
01173       }
01174     }
01175       // For anything other than CAMergePartner, just append the
01176       // unmodified attribute to each bridge.
01177     else
01178     {
01179       for ( int i = tb_list.size(); i--; )
01180         append_attrib_internal( tb_list.get_and_step(), attrib_ptr);
01181     }
01182   }
01183   else
01184   {
01185       // Append this name to the primary bridge
01186     append_attrib_internal(bridge, attrib_ptr);  
01187   }
01188 }
01189 
01190 void CubitAttribUser::append_attrib_internal(TopologyBridge *bridge, const CubitSimpleAttrib& attrib_ptr)
01191 {
01192   DLIList<CubitSimpleAttrib> others;
01193   
01194     // Check for duplicates
01195   if ( attrib_ptr.character_type() != "DEFERRED_ATTRIB" )
01196   {
01197     bridge->get_simple_attribute( attrib_ptr.character_type().c_str(), others );
01198     while ( others.size() )
01199     {
01200       bridge->remove_simple_attribute_virt( others.pop() );
01201     }
01202   }
01203   else
01204   {
01205     CubitString real_name = attrib_ptr.string_data_list()[1];
01206     bridge->get_simple_attribute("DEFERRED_ATTRIB", others);
01207     while ( others.size() )
01208     {
01209       CubitSimpleAttrib dup_attrib = others.pop();
01210       if ( dup_attrib.string_data_list()[1] == real_name )
01211         bridge->remove_simple_attribute_virt(dup_attrib);
01212     }
01213   }
01214   
01215     // append attribute
01216   bridge->append_simple_attribute_virt(attrib_ptr);  
01217 }
01218 
01219 void CubitAttribUser::remove_all_simple_attribute(TopologyBridge* bridge)
01220 {
01221     // remove this name from the primary object
01222   bridge->remove_all_simple_attribute_virt();
01223 
01224     // for merged objects, remove all attributes from other entities
01225   if (CubitSimpleAttrib::get_push_attribs() == CUBIT_TRUE ||
01226       CGMApp::instance()->attrib_manager()->auto_update_flag(CA_MERGE_PARTNER) == CUBIT_TRUE) {
01227     DLIList<TopologyBridge*> tb_list;
01228     bridge->bridge_manager()->get_bridge_list(tb_list);
01229     tb_list.reset();
01230     assert(tb_list.size() == 0 || tb_list.get() == bridge);
01231     for (int i = tb_list.size(); i > 0; i--) {
01232       TopologyBridge *temp_tb = tb_list.get_and_step();
01233       if (temp_tb != bridge) temp_tb->remove_all_simple_attribute_virt();
01234     }
01235   }
01236 }
01237 
01238 void CubitAttribUser::remove_simple_attribute(TopologyBridge* bridge, const CubitSimpleAttrib& attrib_ptr)
01239 {
01240     // remove this name from the primary object
01241   bridge->remove_simple_attribute_virt(attrib_ptr);
01242   
01243     // for merged objects, remove attribute from other entities
01244   if (CubitSimpleAttrib::get_push_attribs() == CUBIT_TRUE ||
01245       CGMApp::instance()->attrib_manager()->auto_update_flag(CA_MERGE_PARTNER) == CUBIT_TRUE) {
01246     DLIList<TopologyBridge*> tb_list;
01247     BridgeManager *bm_ptr = bridge->bridge_manager();
01248     if (bm_ptr != NULL) bm_ptr->get_bridge_list(tb_list);
01249     tb_list.reset();
01250     assert(tb_list.size() == 0 || tb_list.get() == bridge);
01251     for (int i = tb_list.size(); i > 0; i--) {
01252       TopologyBridge *temp_tb = tb_list.get_and_step();
01253       if (temp_tb != bridge) temp_tb->remove_simple_attribute_virt(attrib_ptr);
01254     }
01255   }
01256 }
01257 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines