LCOV - code coverage report
Current view: top level - geom - OldUnmergeCode.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 4 705 0.6 %
Date: 2020-06-30 00:58:45 Functions: 3 25 12.0 %
Branches: 2 2158 0.1 %

           Branch data     Line data    Source code
       1                 :            : #include "OldUnmergeCode.hpp"
       2                 :            : 
       3                 :            : #include "Body.hpp"
       4                 :            : #include "CoVolume.hpp"
       5                 :            : #include "RefVolume.hpp"
       6                 :            : #include "Shell.hpp"
       7                 :            : #include "CoFace.hpp"
       8                 :            : #include "RefFace.hpp"
       9                 :            : #include "Loop.hpp"
      10                 :            : #include "CoEdge.hpp"
      11                 :            : #include "RefEdge.hpp"
      12                 :            : #include "Chain.hpp"
      13                 :            : #include "CoVertex.hpp"
      14                 :            : #include "RefVertex.hpp"
      15                 :            : 
      16                 :            : #include "BodySM.hpp"
      17                 :            : #include "Lump.hpp"
      18                 :            : #include "ShellSM.hpp"
      19                 :            : #include "Surface.hpp"
      20                 :            : #include "LoopSM.hpp"
      21                 :            : #include "CoEdgeSM.hpp"
      22                 :            : #include "Curve.hpp"
      23                 :            : #include "Point.hpp"
      24                 :            : 
      25                 :            : #include "GeometryQueryTool.hpp"
      26                 :            : #include "RefEntityFactory.hpp"
      27                 :            : #include "CpuTimer.hpp"
      28                 :            : #include "ProgressTool.hpp"
      29                 :            : #include "AppUtil.hpp"
      30                 :            : 
      31                 :            : #include "MergeTool.hpp"
      32                 :            : #include "MergeToolAssistant.hpp"
      33                 :            : #include "SettingHandler.hpp"
      34                 :            : 
      35                 :            : 
      36                 :        874 : void OldUnmergeCode::initialize_settings()
      37                 :            : {
      38                 :            :   SettingHandler::instance()->add_setting("unmerge new ids",
      39                 :            :                                           OldUnmergeCode::set_use_old_unmerge_code,
      40                 :        874 :                                           OldUnmergeCode::get_use_old_unmerge_code);
      41                 :        874 : }
      42                 :            : 
      43                 :            : bool OldUnmergeCode::useOldUnmergeCode = false;
      44                 :            : 
      45                 :            :    
      46                 :          0 : bool OldUnmergeCode::get_use_old_unmerge_code()
      47                 :          0 :     { return useOldUnmergeCode; }
      48                 :            :     
      49                 :          0 : void OldUnmergeCode::set_use_old_unmerge_code( bool value )
      50                 :          0 :     { useOldUnmergeCode = value; }
      51                 :            : 
      52                 :            : 
      53                 :            : 
      54                 :            : 
      55                 :          0 : OldUnmergeCode& OldUnmergeCode::instance()
      56                 :            : {
      57 [ #  # ][ #  # ]:          0 :   static OldUnmergeCode instance_;
         [ #  # ][ #  # ]
      58                 :          0 :   return instance_;
      59                 :            : }
      60                 :            : 
      61                 :            : //-------------------------------------------------------------------------
      62                 :            : // Purpose       : Unmerge everything
      63                 :            : //
      64                 :            : // Special Notes : 
      65                 :            : //
      66                 :            : // Creator       : Jason Kraftcheck
      67                 :            : //
      68                 :            : // Creation Date : 03/27/01
      69                 :            : //-------------------------------------------------------------------------
      70                 :          0 : CubitStatus OldUnmergeCode::unmerge_all()
      71                 :            : {
      72 [ #  # ][ #  # ]:          0 :   if (!get_use_old_unmerge_code())
      73 [ #  # ][ #  # ]:          0 :     return MergeTool::instance()->unmerge_all();
      74                 :            :   
      75                 :            :   int i;
      76                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
      77         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
      78                 :            :   
      79                 :            :   
      80         [ #  # ]:          0 :   DLIList<RefFace*>  face_list;
      81 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*>  edge_list;
      82 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> vtx_list;
      83                 :            :   
      84 [ #  # ][ #  # ]:          0 :   GeometryQueryTool::instance()->ref_faces( face_list );
      85 [ #  # ][ #  # ]:          0 :   GeometryQueryTool::instance()->ref_edges( edge_list );
      86 [ #  # ][ #  # ]:          0 :   GeometryQueryTool::instance()->ref_vertices( vtx_list );
      87                 :            :   
      88 [ #  # ][ #  # ]:          0 :   for( i = face_list.size(); (i > 0) && !AppUtil::instance()->interrupt(); i-- )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      89 [ #  # ][ #  # ]:          0 :     if( ! unmerge(face_list.get_and_step(),CUBIT_FALSE) )
                 [ #  # ]
      90                 :          0 :       result = CUBIT_FAILURE;
      91                 :            :  
      92 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); (i > 0) && !AppUtil::instance()->interrupt(); i-- )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      93 [ #  # ][ #  # ]:          0 :     if( ! unmerge(edge_list.get_and_step(),CUBIT_FALSE) ) 
                 [ #  # ]
      94                 :          0 :       result = CUBIT_FAILURE;
      95                 :            :   
      96 [ #  # ][ #  # ]:          0 :   for( i = vtx_list.size(); (i > 0) && !AppUtil::instance()->interrupt(); i-- )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      97 [ #  # ][ #  # ]:          0 :     if( ! unmerge(vtx_list.get_and_step()) )
                 [ #  # ]
      98                 :          0 :       result = CUBIT_FAILURE;
      99                 :            :   
     100         [ #  # ]:          0 :   end_unmerge(top);
     101         [ #  # ]:          0 :   return result;
     102                 :            : }
     103                 :            : 
     104                 :            : 
     105                 :            : //-------------------------------------------------------------------------
     106                 :            : // Purpose       : Unmerge RefEntities
     107                 :            : //
     108                 :            : // Special Notes : 
     109                 :            : //
     110                 :            : // Creator       : Jason Kraftcheck
     111                 :            : //
     112                 :            : // Creation Date : 01/18/01
     113                 :            : //-------------------------------------------------------------------------
     114                 :          0 : CubitStatus OldUnmergeCode::unmerge( DLIList<RefEntity*> &entity_list,
     115                 :            :                                 CubitBoolean descend )
     116                 :            : {
     117         [ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     118                 :          0 :     return MergeTool::instance()->unmerge(entity_list, descend);
     119                 :            :   
     120                 :          0 :   CubitBoolean top = start_unmerge();
     121                 :            :   
     122 [ #  # ][ #  # ]:          0 :   for( int i = entity_list.size(); (i > 0) && !AppUtil::instance()->interrupt(); i-- )
                 [ #  # ]
     123                 :          0 :     unmerge( entity_list.get_and_step(), descend );
     124                 :            :   
     125                 :          0 :   end_unmerge(top);
     126                 :          0 :   return CUBIT_SUCCESS;
     127                 :            : }
     128                 :            : 
     129                 :            : //-------------------------------------------------------------------------
     130                 :            : // Purpose       : Unmerge a RefEntity
     131                 :            : //
     132                 :            : // Special Notes : All parents must be unmerged.
     133                 :            : //
     134                 :            : // Creator       : Jason Kraftcheck
     135                 :            : //
     136                 :            : // Creation Date : 01/18/01
     137                 :            : //-------------------------------------------------------------------------
     138                 :          0 : CubitStatus OldUnmergeCode::unmerge( RefEntity* entity_ptr, CubitBoolean descend )
     139                 :            : {
     140         [ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     141                 :          0 :     return MergeTool::instance()->unmerge(entity_ptr, descend);
     142                 :            :   
     143 [ #  # ][ #  # ]:          0 :   if( CAST_TO( entity_ptr, Body ) )
                 [ #  # ]
     144 [ #  # ][ #  # ]:          0 :      return descend ? unmerge(CAST_TO(entity_ptr,Body)) : CUBIT_FAILURE;
     145 [ #  # ][ #  # ]:          0 :   else if( CAST_TO( entity_ptr, RefVolume ) )
                 [ #  # ]
     146 [ #  # ][ #  # ]:          0 :      return descend ? unmerge(CAST_TO(entity_ptr,RefVolume)) : CUBIT_FAILURE;
     147 [ #  # ][ #  # ]:          0 :   else if( CAST_TO( entity_ptr, RefFace ) )
                 [ #  # ]
     148         [ #  # ]:          0 :      return unmerge( CAST_TO(entity_ptr,RefFace), descend );
     149 [ #  # ][ #  # ]:          0 :   else if( CAST_TO( entity_ptr, RefEdge ) )
                 [ #  # ]
     150         [ #  # ]:          0 :      return unmerge( CAST_TO(entity_ptr,RefEdge), descend );
     151 [ #  # ][ #  # ]:          0 :   else if( CAST_TO( entity_ptr, RefVertex ) )
                 [ #  # ]
     152         [ #  # ]:          0 :      return unmerge( CAST_TO(entity_ptr,RefVertex) );
     153                 :            :   else
     154                 :            :   {
     155         [ #  # ]:          0 :     PRINT_ERROR("Bad Entity \"%s\" in "
     156                 :            :                 "OldUnmergeCode::unmerge(RefEntity*,CubitBoolean)\n",
     157         [ #  # ]:          0 :                 entity_ptr->class_name());
     158                 :          0 :       return CUBIT_FAILURE;
     159                 :            :   }
     160                 :            : }
     161                 :            : 
     162                 :          0 : CubitStatus OldUnmergeCode::unmerge( Body* body_ptr )
     163                 :            : {
     164 [ #  # ][ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     165 [ #  # ][ #  # ]:          0 :     return MergeTool::instance()->unmerge(body_ptr);
     166                 :            :   
     167         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     168                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
     169         [ #  # ]:          0 :   DLIList<RefVolume*> vol_list;
     170         [ #  # ]:          0 :   body_ptr->ref_volumes(vol_list);
     171 [ #  # ][ #  # ]:          0 :   for( int i = vol_list.size(); (i > 0) && !AppUtil::instance()->interrupt(); i-- )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     172 [ #  # ][ #  # ]:          0 :     if( !unmerge(vol_list.get_and_step()) )
                 [ #  # ]
     173                 :          0 :       result = CUBIT_FAILURE;
     174         [ #  # ]:          0 :   end_unmerge(top);
     175         [ #  # ]:          0 :   return result;
     176                 :            : }
     177                 :            : 
     178                 :          0 : CubitStatus OldUnmergeCode::unmerge( RefVolume* vol_ptr )
     179                 :            : {
     180 [ #  # ][ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     181 [ #  # ][ #  # ]:          0 :     return MergeTool::instance()->unmerge(vol_ptr);
     182                 :            :   
     183         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     184                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
     185 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> face_list, new_faces;
                 [ #  # ]
     186 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list, new_edges;
         [ #  # ][ #  # ]
     187 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> vtx_list;
     188         [ #  # ]:          0 :   vol_ptr->ref_faces(face_list);
     189         [ #  # ]:          0 :   vol_ptr->ref_edges(edge_list);
     190         [ #  # ]:          0 :   vol_ptr->ref_vertices(vtx_list);
     191         [ #  # ]:          0 :   face_list.reset();
     192 [ #  # ][ #  # ]:          0 :   while( face_list.size() && !AppUtil::instance()->interrupt() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     193                 :            :   {
     194         [ #  # ]:          0 :     RefFace* old_face = face_list.extract();
     195         [ #  # ]:          0 :     RefFace* new_face = unmerge(old_face,vol_ptr);
     196         [ #  # ]:          0 :     if( new_face ) 
     197         [ #  # ]:          0 :       new_faces.append(new_face);
     198                 :            :     else
     199                 :          0 :       result = CUBIT_FAILURE;
     200                 :            :   }
     201                 :            :   
     202 [ #  # ][ #  # ]:          0 :   while( edge_list.size() && !AppUtil::instance()->interrupt() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     203                 :            :   {
     204         [ #  # ]:          0 :     RefEdge* old_edge = edge_list.extract();
     205         [ #  # ]:          0 :     face_list.clean_out();
     206         [ #  # ]:          0 :     old_edge->ref_faces(face_list);
     207 [ #  # ][ #  # ]:          0 :     while( face_list.size() )
     208                 :            :     {
     209         [ #  # ]:          0 :       RefFace* face_ptr = face_list.extract();
     210 [ #  # ][ #  # ]:          0 :       if( new_faces.is_in_list(face_ptr) )
     211                 :            :       {
     212         [ #  # ]:          0 :         RefEdge* new_edge = unmerge(old_edge,face_ptr);
     213         [ #  # ]:          0 :         if( new_edge )
     214         [ #  # ]:          0 :           new_edges.append(new_edge);
     215                 :            :         else
     216                 :          0 :           result = CUBIT_FAILURE;
     217                 :          0 :         break;
     218                 :            :       }
     219                 :            :     }
     220                 :            :   }
     221                 :            :   
     222                 :            :   
     223 [ #  # ][ #  # ]:          0 :   while( vtx_list.size() && !AppUtil::instance()->interrupt() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     224                 :            :   {
     225         [ #  # ]:          0 :     RefVertex* old_vtx = vtx_list.extract();
     226         [ #  # ]:          0 :     edge_list.clean_out();
     227         [ #  # ]:          0 :     old_vtx->ref_edges(edge_list);
     228 [ #  # ][ #  # ]:          0 :     while( edge_list.size() )
     229                 :            :     {
     230         [ #  # ]:          0 :       RefEdge* edge_ptr = edge_list.extract();
     231 [ #  # ][ #  # ]:          0 :       if( new_edges.is_in_list(edge_ptr) )
     232                 :            :       {
     233         [ #  # ]:          0 :         RefVertex* new_vtx = unmerge(old_vtx,edge_ptr);
     234         [ #  # ]:          0 :         if( !new_vtx )
     235                 :          0 :           result = CUBIT_FAILURE;
     236                 :          0 :         break;
     237                 :            :       }
     238                 :            :     }
     239                 :            :   }
     240                 :            :   
     241         [ #  # ]:          0 :   end_unmerge(top);
     242         [ #  # ]:          0 :   return result;
     243                 :            : }
     244                 :            : 
     245                 :          0 : CubitStatus OldUnmergeCode::unmerge( RefFace* face_ptr, CubitBoolean descend )
     246                 :            : {
     247 [ #  # ][ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     248 [ #  # ][ #  # ]:          0 :     return MergeTool::instance()->unmerge(face_ptr, descend);
     249                 :            :   
     250         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     251                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
     252                 :            :   CubitBoolean reversed;
     253                 :            :   int i;
     254                 :            :   
     255                 :            : //  if( !face_ptr->can_modify() )
     256                 :            : //    return CUBIT_FAILURE;
     257                 :            :   
     258         [ #  # ]:          0 :   DLIList<RefFace*> unmerged_faces;
     259 [ #  # ][ #  # ]:          0 :   DLIList<RefVolume*> vol_list;
     260         [ #  # ]:          0 :   face_ptr->ref_volumes(vol_list);
     261 [ #  # ][ #  # ]:          0 :   if( vol_list.size() )
     262                 :            :   {
     263 [ #  # ][ #  # ]:          0 :     for( i = vol_list.size(); i > 0; i-- )
     264                 :            :     {
     265 [ #  # ][ #  # ]:          0 :       RefFace* new_face = unmerge(face_ptr,vol_list.get_and_step());
     266         [ #  # ]:          0 :       if( new_face )
     267         [ #  # ]:          0 :         unmerged_faces.append_unique(new_face);
     268                 :            :       else
     269                 :          0 :         result = CUBIT_FAILURE;
     270                 :            :     }
     271                 :            :   }
     272                 :            :   else
     273                 :            :   {
     274         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
     275 [ #  # ][ #  # ]:          0 :     face_ptr->bridge_manager()->get_bridge_list( bridge_list );
     276                 :            :     
     277                 :            :     //Try top remove each bridge
     278 [ #  # ][ #  # ]:          0 :     for( i = bridge_list.size(); i > 0; i-- )
     279                 :            :     {
     280                 :            :       //but stop if there is only one left
     281 [ #  # ][ #  # ]:          0 :       if( face_ptr->bridge_manager()->number_of_bridges() == 1 )
                 [ #  # ]
     282                 :            :       {
     283         [ #  # ]:          0 :         unmerged_faces.append(face_ptr);
     284                 :          0 :         break;
     285                 :            :       }
     286                 :            :       
     287         [ #  # ]:          0 :       TopologyBridge* bridge_ptr = bridge_list.get_and_step();
     288         [ #  # ]:          0 :       Surface* surf_ptr = CAST_TO(bridge_ptr,Surface);
     289         [ #  # ]:          0 :       assert(surf_ptr != 0);
     290         [ #  # ]:          0 :       RefFace* new_face = split_out_Surface(surf_ptr, reversed);
     291         [ #  # ]:          0 :       if( new_face )
     292                 :            :       {
     293         [ #  # ]:          0 :         unmerged_faces.append(new_face);
     294                 :            :   
     295                 :            :           //Notify merge assistants of unmerge
     296         [ #  # ]:          0 :         DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
     297 [ #  # ][ #  # ]:          0 :         for( int a = assistant_list_.size(); a > 0; a-- )
     298         [ #  # ]:          0 :           assistant_list_.get_and_step()->
     299 [ #  # ][ #  # ]:          0 :             unmerged( face_ptr, new_face, reversed );
                 [ #  # ]
     300                 :            :       }
     301                 :            :       else
     302                 :          0 :         result = CUBIT_FAILURE;
     303                 :            :     }
     304 [ #  # ][ #  # ]:          0 :     if( !unmerged_faces.is_in_list(face_ptr) )
     305         [ #  # ]:          0 :       result = CUBIT_FAILURE;
     306                 :            :   }
     307                 :            :   
     308         [ #  # ]:          0 :   if( !descend ) 
     309                 :            :   {
     310         [ #  # ]:          0 :     end_unmerge(top);
     311                 :          0 :     return result;
     312                 :            :   }
     313                 :            :   
     314 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list, unmerged_edges;
         [ #  # ][ #  # ]
     315 [ #  # ][ #  # ]:          0 :   for( i = unmerged_faces.size(); i > 0; i-- )
     316                 :            :   {
     317         [ #  # ]:          0 :     face_ptr = unmerged_faces.get_and_step();
     318         [ #  # ]:          0 :     edge_list.clean_out();
     319         [ #  # ]:          0 :     face_ptr->ref_edges(edge_list);
     320 [ #  # ][ #  # ]:          0 :     for( int j = edge_list.size(); j > 0; j-- )
     321                 :            :     {
     322 [ #  # ][ #  # ]:          0 :       RefEdge* new_edge = unmerge(edge_list.get_and_step(),face_ptr);
     323         [ #  # ]:          0 :       if( new_edge )
     324         [ #  # ]:          0 :         unmerged_edges.append_unique(new_edge);
     325                 :            :       else
     326                 :          0 :         result = CUBIT_FAILURE;
     327                 :            :     }
     328                 :            :   }
     329                 :            :   
     330 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> vtx_list;
     331 [ #  # ][ #  # ]:          0 :   for( i = unmerged_edges.size(); i > 0; i-- )
     332                 :            :   {
     333         [ #  # ]:          0 :     RefEdge* edge_ptr = unmerged_edges.get_and_step();
     334         [ #  # ]:          0 :     vtx_list.clean_out();
     335         [ #  # ]:          0 :     edge_ptr->ref_vertices(vtx_list);
     336 [ #  # ][ #  # ]:          0 :     for( int j = vtx_list.size(); j > 0; j-- )
     337                 :            :     {
     338 [ #  # ][ #  # ]:          0 :       RefVertex* new_vtx = unmerge(vtx_list.get_and_step(),edge_ptr);
     339         [ #  # ]:          0 :       if( !new_vtx ) result = CUBIT_FAILURE;
     340                 :            :     }
     341                 :            :   }
     342                 :            :        
     343         [ #  # ]:          0 :   end_unmerge(top);
     344         [ #  # ]:          0 :   return result;
     345                 :            : }
     346                 :            : 
     347                 :            : 
     348                 :          0 : CubitStatus OldUnmergeCode::unmerge( RefEdge* edge_ptr, CubitBoolean descend )
     349                 :            : {
     350 [ #  # ][ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     351 [ #  # ][ #  # ]:          0 :     return MergeTool::instance()->unmerge(edge_ptr, descend);
     352                 :            :   
     353         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     354                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
     355                 :            :   CubitBoolean reversed;
     356                 :            :   int i;
     357                 :            :   
     358                 :            : //  if( !edge_ptr->can_modify() )
     359                 :            : //    return CUBIT_FAILURE;
     360                 :            :   
     361         [ #  # ]:          0 :   DLIList<RefEdge*> unmerged_edges;
     362 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> face_list;
     363         [ #  # ]:          0 :   edge_ptr->ref_faces(face_list);
     364 [ #  # ][ #  # ]:          0 :   if( face_list.size() )
     365                 :            :   {
     366 [ #  # ][ #  # ]:          0 :     for( i = face_list.size(); i > 0; i-- )
     367                 :            :     {
     368 [ #  # ][ #  # ]:          0 :       RefEdge* new_edge = unmerge(edge_ptr,face_list.get_and_step());
     369         [ #  # ]:          0 :       if( new_edge )
     370         [ #  # ]:          0 :         unmerged_edges.append_unique(new_edge);
     371                 :            :       else
     372                 :          0 :         result = CUBIT_FAILURE;
     373                 :            :     }
     374                 :            :   }
     375                 :            :   else
     376                 :            :   {
     377         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
     378 [ #  # ][ #  # ]:          0 :     DLIList<Curve*> curve_list;
     379 [ #  # ][ #  # ]:          0 :     edge_ptr->bridge_manager()->get_bridge_list( bridge_list );
     380                 :            :     
     381                 :            :     //Try top remove each bridge
     382 [ #  # ][ #  # ]:          0 :     for( i = bridge_list.size(); i > 0; i-- )
     383                 :            :     {
     384                 :            :       //but stop if there is only one left
     385 [ #  # ][ #  # ]:          0 :       if( edge_ptr->bridge_manager()->number_of_bridges() == 1 )
                 [ #  # ]
     386                 :            :       {
     387         [ #  # ]:          0 :         unmerged_edges.append(edge_ptr);
     388                 :          0 :         break;
     389                 :            :       }
     390                 :            :       
     391         [ #  # ]:          0 :       TopologyBridge* bridge_ptr = bridge_list.get_and_step();
     392         [ #  # ]:          0 :       curve_list.clean_out();
     393 [ #  # ][ #  # ]:          0 :       curve_list.append( CAST_TO(bridge_ptr,Curve) );
     394         [ #  # ]:          0 :       RefEdge* new_edge = split_out_Curves(curve_list, reversed);
     395         [ #  # ]:          0 :       if( new_edge )
     396                 :            :       {
     397         [ #  # ]:          0 :         unmerged_edges.append(new_edge);
     398                 :            :   
     399                 :            :           //Notify merge assistants of unmerge
     400         [ #  # ]:          0 :         DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
     401 [ #  # ][ #  # ]:          0 :         for( int a = assistant_list_.size(); a > 0; a-- )
     402         [ #  # ]:          0 :           assistant_list_.get_and_step()->
     403 [ #  # ][ #  # ]:          0 :             unmerged( edge_ptr, new_edge, reversed );
                 [ #  # ]
     404                 :            :       }
     405                 :            :       else
     406                 :          0 :         result = CUBIT_FAILURE;
     407                 :            :     }
     408 [ #  # ][ #  # ]:          0 :     if( !unmerged_edges.is_in_list(edge_ptr) )
     409         [ #  # ]:          0 :       result = CUBIT_FAILURE;
     410                 :            :   }
     411                 :            :   
     412         [ #  # ]:          0 :   if( !descend ) 
     413                 :            :   {
     414         [ #  # ]:          0 :     end_unmerge(top);
     415                 :          0 :     return result;
     416                 :            :   }
     417                 :            :   
     418 [ #  # ][ #  # ]:          0 :   DLIList<RefVertex*> vtx_list;
     419 [ #  # ][ #  # ]:          0 :   for( i = unmerged_edges.size(); i > 0; i-- )
     420                 :            :   {
     421         [ #  # ]:          0 :     edge_ptr = unmerged_edges.get_and_step();
     422         [ #  # ]:          0 :     vtx_list.clean_out();
     423         [ #  # ]:          0 :     edge_ptr->ref_vertices(vtx_list);
     424 [ #  # ][ #  # ]:          0 :     for( int j = vtx_list.size(); j > 0; j-- )
     425                 :            :     {
     426 [ #  # ][ #  # ]:          0 :       RefVertex* new_vtx = unmerge(vtx_list.get_and_step(),edge_ptr);
     427         [ #  # ]:          0 :       if( !new_vtx )
     428                 :          0 :         result = CUBIT_FAILURE;
     429                 :            :     }
     430                 :            :   }
     431                 :            :   
     432         [ #  # ]:          0 :   end_unmerge(top);
     433         [ #  # ]:          0 :   return result;
     434                 :            : }
     435                 :            : 
     436                 :            : 
     437                 :          0 : CubitStatus OldUnmergeCode::unmerge( RefVertex* vtx_ptr )
     438                 :            : {
     439 [ #  # ][ #  # ]:          0 :   if (!get_use_old_unmerge_code())
     440 [ #  # ][ #  # ]:          0 :     return MergeTool::instance()->unmerge(vtx_ptr);
     441                 :            :   
     442         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     443                 :          0 :   CubitStatus result = CUBIT_SUCCESS;
     444                 :            :   int i;
     445                 :            :   
     446                 :            : //  if( !vtx_ptr->can_modify() )
     447                 :            : //    return CUBIT_FAILURE;
     448                 :            :   
     449         [ #  # ]:          0 :   DLIList<RefVertex*> unmerged_vtxs;
     450 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list;
     451         [ #  # ]:          0 :   vtx_ptr->ref_edges(edge_list);
     452 [ #  # ][ #  # ]:          0 :   if( edge_list.size() )
     453                 :            :   {
     454 [ #  # ][ #  # ]:          0 :     for( i = edge_list.size(); i > 0; i-- )
     455                 :            :     {
     456 [ #  # ][ #  # ]:          0 :       RefVertex* new_vtx = unmerge(vtx_ptr,edge_list.get_and_step());
     457         [ #  # ]:          0 :       if( new_vtx )
     458         [ #  # ]:          0 :         unmerged_vtxs.append_unique(new_vtx);
     459                 :            :       else
     460                 :          0 :         result = CUBIT_FAILURE;
     461                 :            :     }
     462                 :            :   }
     463                 :            :   else
     464                 :            :   {
     465         [ #  # ]:          0 :     DLIList<TopologyBridge*> bridge_list;
     466 [ #  # ][ #  # ]:          0 :     DLIList<TBPoint*> point_list;
     467 [ #  # ][ #  # ]:          0 :     vtx_ptr->bridge_manager()->get_bridge_list( bridge_list );
     468                 :            :     
     469                 :            :     //Try top remove each bridge
     470 [ #  # ][ #  # ]:          0 :     for( i = bridge_list.size(); i > 0; i-- )
     471                 :            :     {
     472                 :            :       //but stop if there is only one left
     473 [ #  # ][ #  # ]:          0 :       if( vtx_ptr->bridge_manager()->number_of_bridges() == 1 )
                 [ #  # ]
     474                 :            :       {
     475         [ #  # ]:          0 :         unmerged_vtxs.append(vtx_ptr);
     476                 :          0 :         break;
     477                 :            :       }
     478                 :            :       
     479         [ #  # ]:          0 :       TopologyBridge* bridge_ptr = bridge_list.get_and_step();
     480         [ #  # ]:          0 :       point_list.clean_out();
     481 [ #  # ][ #  # ]:          0 :       point_list.append( CAST_TO(bridge_ptr,TBPoint) );
     482         [ #  # ]:          0 :       RefVertex* new_vtx = split_out_Points(point_list);
     483         [ #  # ]:          0 :       if( new_vtx )
     484                 :            :       {
     485         [ #  # ]:          0 :         unmerged_vtxs.append(new_vtx);
     486                 :            :   
     487                 :            :           //Notify merge assistants of unmerge
     488         [ #  # ]:          0 :         DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
     489 [ #  # ][ #  # ]:          0 :         for( int a = assistant_list_.size(); a > 0; a-- )
     490         [ #  # ]:          0 :           assistant_list_.get_and_step()->
     491 [ #  # ][ #  # ]:          0 :             unmerged( vtx_ptr, new_vtx, CUBIT_FALSE );
                 [ #  # ]
     492                 :            :       }
     493                 :            :       else
     494                 :          0 :         result = CUBIT_FAILURE;
     495                 :            :     }
     496 [ #  # ][ #  # ]:          0 :     if( !unmerged_vtxs.is_in_list(vtx_ptr) )
     497         [ #  # ]:          0 :       result = CUBIT_FAILURE;
     498                 :            :   }
     499                 :            :   
     500         [ #  # ]:          0 :   end_unmerge(top);
     501         [ #  # ]:          0 :   return result;
     502                 :            : }
     503                 :            : 
     504                 :            : 
     505                 :            : //-------------------------------------------------------------------------
     506                 :            : // Purpose       : Given an unmerged parent, and a merged child, 
     507                 :            : //                 unmerge the topology bridge of the child that 
     508                 :            : //                 corresponds to the passed parent.
     509                 :            : //
     510                 :            : // Special Notes : 
     511                 :            : //
     512                 :            : // Creator       : Jason Kraftcheck
     513                 :            : //
     514                 :            : // Creation Date : 01/18/01
     515                 :            : //-------------------------------------------------------------------------
     516                 :          0 : RefFace* OldUnmergeCode::unmerge( RefFace* face_ptr, RefVolume* vol_ptr )
     517                 :            : {  
     518 [ #  # ][ #  # ]:          0 :   assert( face_ptr && vol_ptr );
     519         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     520                 :            :   CubitBoolean reversed;
     521                 :            :   int i;
     522                 :            :   
     523                 :            : //  if( !face_ptr->can_modify() )
     524                 :            : //  {
     525                 :            : //    end_unmerge(top);
     526                 :            : //    return 0;
     527                 :            : //  }
     528                 :            :   
     529                 :            :   //If passed entity is not merged, just return it.
     530 [ #  # ][ #  # ]:          0 :   if( face_ptr->bridge_manager()->number_of_bridges() < 2 )
                 [ #  # ]
     531                 :            :   {
     532         [ #  # ]:          0 :     end_unmerge(top);
     533                 :          0 :     return face_ptr;
     534                 :            :   }
     535                 :            :   
     536                 :            :   //Find the Surfaces of face_ptr that go with vol_ptr
     537         [ #  # ]:          0 :   DLIList<Lump*> surf_lumps;
     538 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> surface_list;
     539 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
     540 [ #  # ][ #  # ]:          0 :   face_ptr->bridge_manager()->get_bridge_list(bridge_list);
     541 [ #  # ][ #  # ]:          0 :   for( i = bridge_list.size(); i > 0; i-- )
     542                 :            :   {
     543         [ #  # ]:          0 :     TopologyBridge* bridge_ptr = bridge_list.get_and_step();
     544         [ #  # ]:          0 :     surf_lumps.clean_out();
     545         [ #  # ]:          0 :     bridge_ptr->lumps(surf_lumps);
     546 [ #  # ][ #  # ]:          0 :     for( int j = surf_lumps.size(); j> 0; j-- )
     547                 :            :     {
     548 [ #  # ][ #  # ]:          0 :       if( surf_lumps.get_and_step()->topology_entity() == vol_ptr )
                 [ #  # ]
     549                 :            :       {
     550 [ #  # ][ #  # ]:          0 :         surface_list.append(CAST_TO(bridge_ptr,Surface));
     551                 :          0 :         break;
     552                 :            :       }
     553                 :            :     }
     554                 :            :   }
     555                 :            :   //face_ptr and vol_ptr have no association in SM topology!!
     556 [ #  # ][ #  # ]:          0 :   if( ! surface_list.size() )
     557                 :            :   {
     558         [ #  # ]:          0 :     end_unmerge(top);
     559                 :          0 :     return 0;
     560                 :            :   }
     561                 :            :   
     562                 :            :   //Assuming this is true, until this assert fails
     563 [ #  # ][ #  # ]:          0 :   assert(surface_list.size() == 1);
     564         [ #  # ]:          0 :   Surface* surface_ptr = surface_list.get();
     565                 :            : 
     566                 :            :   // Unmerge any child GroupingEntities and SenseEntities,
     567                 :            :   // and reconstruct a new owner.
     568                 :            :   RefFace* new_entity 
     569         [ #  # ]:          0 :     = split_out_Surface( surface_ptr, reversed );
     570         [ #  # ]:          0 :   if( !new_entity )
     571                 :            :   {
     572         [ #  # ]:          0 :     end_unmerge(top);
     573                 :          0 :     return 0;
     574                 :            :   }
     575                 :            : 
     576                 :            :   // Find any links from parent to old entity, and move them
     577                 :            :   // to the new, unmerged entity.
     578 [ #  # ][ #  # ]:          0 :   DLIList<CoFace*> coface_list;
     579 [ #  # ][ #  # ]:          0 :   DLIList<ShellSM*> shellsm_list;
     580         [ #  # ]:          0 :   surface_ptr->shellsms( shellsm_list );
     581 [ #  # ][ #  # ]:          0 :   for( i = shellsm_list.size(); i > 0; i-- )
     582                 :            :   {
     583         [ #  # ]:          0 :     ShellSM* shellsm = shellsm_list.get_and_step();
     584 [ #  # ][ #  # ]:          0 :     Shell* shell_ptr = CAST_TO(shellsm->topology_entity(),Shell);
     585         [ #  # ]:          0 :     if( !shell_ptr ) continue;
     586                 :            :     
     587         [ #  # ]:          0 :     coface_list.clean_out();
     588         [ #  # ]:          0 :     shell_ptr->co_faces(coface_list);
     589 [ #  # ][ #  # ]:          0 :     for( int j = coface_list.size(); j > 0; j-- )
     590                 :            :     {
     591         [ #  # ]:          0 :       CoFace* cof_ptr = coface_list.get_and_step();
     592 [ #  # ][ #  # ]:          0 :       if( cof_ptr->get_ref_face_ptr() == face_ptr )
     593                 :            :       {
     594         [ #  # ]:          0 :         cof_ptr->switch_basic_topology_entity(new_entity);
     595 [ #  # ][ #  # ]:          0 :         if( reversed ) cof_ptr->reverse_sense();
     596                 :            :       }
     597                 :            :     }
     598                 :            :   }
     599                 :            :   
     600                 :            :   //We have changed the topology of the passed RefVolume.
     601                 :            :   //Note this for later.
     602 [ #  # ][ #  # ]:          0 :   unmerge_modified.append( face_ptr );
     603                 :            :   
     604                 :            :   //Notify merge assistants of unmerge
     605         [ #  # ]:          0 :   DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
     606 [ #  # ][ #  # ]:          0 :   for( int a = assistant_list_.size(); a > 0; a-- )
     607         [ #  # ]:          0 :     assistant_list_.get_and_step()->
     608 [ #  # ][ #  # ]:          0 :       unmerged( face_ptr, new_entity, reversed );
                 [ #  # ]
     609                 :            :   
     610         [ #  # ]:          0 :   end_unmerge(top);  
     611         [ #  # ]:          0 :   return new_entity;
     612                 :            : }
     613                 :            : 
     614                 :            : 
     615                 :          0 : RefEdge* OldUnmergeCode::unmerge( RefEdge* edge_ptr, RefFace* face_ptr )
     616                 :            : {  
     617 [ #  # ][ #  # ]:          0 :   assert( face_ptr && edge_ptr );
     618         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     619                 :            :   CubitBoolean reversed;
     620                 :            :   int i;
     621                 :            :   
     622                 :            : //  if( !edge_ptr->can_modify() )
     623                 :            : //  {
     624                 :            : //    end_unmerge(top);
     625                 :            : //    return 0;
     626                 :            : //  }
     627                 :            :   
     628                 :            :   //If passed entity is not merged, just return it.
     629 [ #  # ][ #  # ]:          0 :   if( edge_ptr->bridge_manager()->number_of_bridges() < 2 )
                 [ #  # ]
     630                 :            :   {
     631         [ #  # ]:          0 :     end_unmerge(top);
     632                 :          0 :     return edge_ptr;
     633                 :            :   }
     634                 :            :   
     635                 :            :   //If parent is merged, cannot proceed.
     636 [ #  # ][ #  # ]:          0 :   if( face_ptr->bridge_manager()->number_of_bridges() != 1 )
                 [ #  # ]
     637                 :            :   {
     638         [ #  # ]:          0 :     end_unmerge(top);
     639                 :          0 :     return 0;
     640                 :            :   }
     641                 :            :   
     642                 :            :   //Parent is not merged.  This is the only Surface
     643 [ #  # ][ #  # ]:          0 :   Surface* surf_ptr = CAST_TO( face_ptr->get_geometry_entity_ptr(), Surface );
     644         [ #  # ]:          0 :   assert(surf_ptr != 0);
     645                 :            :   
     646                 :            :   //Find curves in edge_ptr associated with surf_ptr.
     647                 :            :   //We need to check links in both directions becuase with virtual
     648                 :            :   //geometry, links may only exist in one direction.
     649                 :            :   //
     650                 :            :   //Check downward links.
     651 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> curve_list, surf_curves;
                 [ #  # ]
     652         [ #  # ]:          0 :   surf_ptr->curves(surf_curves);
     653 [ #  # ][ #  # ]:          0 :   for( i = surf_curves.size(); i > 0; i-- )
     654                 :            :   {
     655         [ #  # ]:          0 :     Curve* curve_ptr = surf_curves.get_and_step();
     656 [ #  # ][ #  # ]:          0 :     if( curve_ptr->topology_entity() == edge_ptr )
     657         [ #  # ]:          0 :       curve_list.append(curve_ptr);
     658                 :            : //    else if( curve_ptr->topology_entity()->is_parasite(edge_ptr) )
     659                 :            : //      curve_list.append(curve_ptr);
     660                 :            :   }
     661                 :            :   //Check upward links.
     662 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> bridge_list;
     663 [ #  # ][ #  # ]:          0 :   DLIList<Surface*> curve_surfs;
     664 [ #  # ][ #  # ]:          0 :   edge_ptr->bridge_manager()->get_bridge_list(bridge_list);
     665 [ #  # ][ #  # ]:          0 :   for( i = bridge_list.size(); i > 0; i-- )
     666                 :            :   {
     667         [ #  # ]:          0 :     TopologyBridge* bridge_ptr = bridge_list.get_and_step();
     668         [ #  # ]:          0 :     curve_surfs.clean_out();
     669         [ #  # ]:          0 :     bridge_ptr->surfaces(curve_surfs);
     670 [ #  # ][ #  # ]:          0 :     for( int j = curve_surfs.size(); j > 0; j-- )
     671                 :            :     {
     672 [ #  # ][ #  # ]:          0 :       TopologyEntity* te_ptr = curve_surfs.get_and_step()->topology_entity();
     673                 :            :       //if( te_ptr == face_ptr )
     674         [ #  # ]:          0 :       if (te_ptr == face_ptr) /*|| face_ptr->is_host(te_ptr)*/
     675                 :            :       {
     676 [ #  # ][ #  # ]:          0 :         curve_list.append_unique(CAST_TO(bridge_ptr,Curve));
     677                 :          0 :         break;
     678                 :            :       }
     679                 :            :     }
     680                 :            :   }
     681                 :            :   
     682                 :            :   //If there is no association between the passed edge_ptr and
     683                 :            :   //face_ptr in the SM topology
     684 [ #  # ][ #  # ]:          0 :   if( ! curve_list.size() )
     685                 :            :   {
     686         [ #  # ]:          0 :     end_unmerge(top);
     687                 :          0 :     return 0;
     688                 :            :   }
     689                 :            :   
     690                 :            :   // Unmerge any child GroupingEntities and SenseEntities,
     691                 :            :   // and reconstruct a new owner.
     692                 :            :   RefEdge* new_entity 
     693         [ #  # ]:          0 :     = split_out_Curves( curve_list, reversed );
     694         [ #  # ]:          0 :   if( !new_entity )
     695                 :            :   {
     696         [ #  # ]:          0 :     end_unmerge(top);
     697                 :          0 :     return 0;
     698                 :            :   }
     699                 :            :   
     700                 :            :   //We have changed the topology of the passed RefFace.
     701                 :            :   //Note this for later.
     702 [ #  # ][ #  # ]:          0 :   unmerge_modified.append( edge_ptr );
     703                 :            : 
     704                 :            :   // Find any links from parent to old entity, and move them
     705                 :            :   // to the new, unmerged entity.
     706 [ #  # ][ #  # ]:          0 :   DLIList<CoEdge*> coedge_list;
     707 [ #  # ][ #  # ]:          0 :   DLIList<Curve*> coe_curves, tmp_list;
         [ #  # ][ #  # ]
     708 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> tb_list;
     709         [ #  # ]:          0 :   edge_ptr->get_co_edges (coedge_list);
     710 [ #  # ][ #  # ]:          0 :   for( i = coedge_list.size(); i > 0; i-- )
     711                 :            :   {
     712         [ #  # ]:          0 :     tb_list.clean_out();
     713         [ #  # ]:          0 :     coe_curves.clean_out();
     714         [ #  # ]:          0 :     CoEdge* coe_ptr = coedge_list.get_and_step();
     715 [ #  # ][ #  # ]:          0 :     coe_ptr->bridge_manager()->get_bridge_list(tb_list);
     716 [ #  # ][ #  # ]:          0 :     for( int j = tb_list.size(); j> 0; j-- )
     717                 :            :     {
     718         [ #  # ]:          0 :       tmp_list.clean_out();
     719 [ #  # ][ #  # ]:          0 :       tb_list.get_and_step()->curves(tmp_list);
     720         [ #  # ]:          0 :       coe_curves.merge_unique(tmp_list);
     721                 :            :     }
     722         [ #  # ]:          0 :     coe_curves.intersect(curve_list);
     723                 :            :     
     724 [ #  # ][ #  # ]:          0 :     if( coe_curves.size() )
     725                 :            :     {
     726         [ #  # ]:          0 :       coe_ptr->switch_basic_topology_entity(new_entity);
     727         [ #  # ]:          0 :       if( reversed ) 
     728         [ #  # ]:          0 :         coe_ptr->reverse_sense();
     729                 :            :     }
     730                 :            :   }
     731                 :            :   
     732                 :            :   //Notify merge assistants of unmerge
     733         [ #  # ]:          0 :   DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
     734 [ #  # ][ #  # ]:          0 :   for( int a = assistant_list_.size(); a > 0; a-- )
     735         [ #  # ]:          0 :     assistant_list_.get_and_step()->
     736 [ #  # ][ #  # ]:          0 :       unmerged( edge_ptr, new_entity, reversed );
                 [ #  # ]
     737                 :            :   
     738                 :            :   
     739         [ #  # ]:          0 :   end_unmerge(top);  
     740         [ #  # ]:          0 :   return new_entity;
     741                 :            : }
     742                 :            : 
     743                 :          0 : RefVertex* OldUnmergeCode::unmerge( RefVertex* vtx_ptr, RefEdge* edge_ptr )
     744                 :            : {  
     745 [ #  # ][ #  # ]:          0 :   assert( vtx_ptr && edge_ptr );
     746         [ #  # ]:          0 :   CubitBoolean top = start_unmerge();
     747                 :            :   int i;
     748                 :            :   
     749                 :            : //  if( !vtx_ptr->can_modify() )
     750                 :            : //  {
     751                 :            : //    end_unmerge(top);
     752                 :            : //    return 0;
     753                 :            : //  }
     754                 :            :   
     755                 :            :   //If passed entity is not merged, just return it.
     756 [ #  # ][ #  # ]:          0 :   if( vtx_ptr->bridge_manager()->number_of_bridges() < 2 )
                 [ #  # ]
     757                 :            :   {
     758         [ #  # ]:          0 :     end_unmerge(top);
     759                 :          0 :     return vtx_ptr;
     760                 :            :   }
     761                 :            :   
     762                 :            :   //If parent is merged, cannot proceed.
     763 [ #  # ][ #  # ]:          0 :   if( edge_ptr->bridge_manager()->number_of_bridges() != 1 )
                 [ #  # ]
     764                 :            :   {
     765         [ #  # ]:          0 :     end_unmerge(top);
     766                 :          0 :     return 0;
     767                 :            :   }
     768                 :            :   
     769                 :            :   //Parent is not merged,  This is the only Curve.
     770 [ #  # ][ #  # ]:          0 :   Curve* curve_ptr = CAST_TO( edge_ptr->get_geometry_entity_ptr(), Curve );
     771         [ #  # ]:          0 :   assert(curve_ptr != 0);
     772                 :            : 
     773                 :            :   //Find points in vtx_ptr associated with curve_ptr.
     774 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> curve_points, point_list;
                 [ #  # ]
     775         [ #  # ]:          0 :   curve_ptr->points(curve_points);
     776 [ #  # ][ #  # ]:          0 :   for( i = curve_points.size(); i > 0; i-- )
     777                 :            :   {
     778         [ #  # ]:          0 :     TBPoint* point_ptr = curve_points.get_and_step();
     779 [ #  # ][ #  # ]:          0 :     if( point_ptr->topology_entity() == vtx_ptr )
     780         [ #  # ]:          0 :       point_list.append(point_ptr);
     781                 :            :   }
     782                 :            : 
     783                 :            :   //If parent and child are not related in the SolidModelingEngine,
     784                 :            :   //return failure.
     785 [ #  # ][ #  # ]:          0 :   if( ! point_list.size() )
     786                 :            :   {
     787         [ #  # ]:          0 :     end_unmerge(top);
     788                 :          0 :     return 0;
     789                 :            :   }
     790                 :            : 
     791                 :            :   // Find any links from parent to old entity, and move them
     792                 :            :   // to the new, unmerged entity.
     793 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> edge_list; 
     794 [ #  # ][ #  # ]:          0 :   DLIList<TBPoint*> curve_pts;
     795 [ #  # ][ #  # ]:          0 :   DLIList<CoVertex*> cvtx_to_change;
     796                 :            :   
     797         [ #  # ]:          0 :   vtx_ptr->ref_edges( edge_list );
     798 [ #  # ][ #  # ]:          0 :   for( i = edge_list.size(); i > 0; i-- )
     799                 :            :   {
     800         [ #  # ]:          0 :     edge_ptr = edge_list.get_and_step();
     801 [ #  # ][ #  # ]:          0 :     if( edge_ptr->bridge_manager()->number_of_bridges() > 1 )
                 [ #  # ]
     802                 :          0 :       continue;
     803                 :            :     
     804         [ #  # ]:          0 :     curve_ptr = edge_ptr->get_curve_ptr();
     805         [ #  # ]:          0 :     assert( curve_ptr != 0 );
     806         [ #  # ]:          0 :     curve_pts.clean_out();
     807         [ #  # ]:          0 :     curve_ptr->points(curve_pts);
     808         [ #  # ]:          0 :     curve_pts.intersect(point_list);
     809 [ #  # ][ #  # ]:          0 :     if( ! curve_pts.size() )
     810                 :          0 :       continue;
     811                 :            :       
     812 [ #  # ][ #  # ]:          0 :     CoVertex* start_cvtx = edge_ptr->get_chain_ptr()->start_co_vertex();
     813 [ #  # ][ #  # ]:          0 :     CoVertex*   end_cvtx = edge_ptr->get_chain_ptr()->  end_co_vertex();
     814 [ #  # ][ #  # ]:          0 :     if (start_cvtx && start_cvtx->get_ref_vertex_ptr() == vtx_ptr)
         [ #  # ][ #  # ]
     815         [ #  # ]:          0 :       cvtx_to_change.append( start_cvtx );
     816 [ #  # ][ #  # ]:          0 :     if (end_cvtx && end_cvtx->get_ref_vertex_ptr() == vtx_ptr)
         [ #  # ][ #  # ]
     817         [ #  # ]:          0 :       cvtx_to_change.append( end_cvtx );
     818                 :            :       
     819                 :            :   }
     820                 :            : 
     821                 :            :   // Make new RefVertex with points.
     822         [ #  # ]:          0 :   RefVertex* new_entity = split_out_Points( point_list );
     823         [ #  # ]:          0 :   if( !new_entity )
     824                 :            :   {
     825         [ #  # ]:          0 :     end_unmerge(top);
     826                 :          0 :     return 0;
     827                 :            :   }
     828                 :            : 
     829 [ #  # ][ #  # ]:          0 :   for( i = cvtx_to_change.size(); i--; )
     830                 :            :   {
     831 [ #  # ][ #  # ]:          0 :     cvtx_to_change.get_and_step()->switch_basic_topology_entity(new_entity);
     832                 :            :   }
     833                 :            :   
     834                 :            :   //We have changed the topology of the passed RefEdge.
     835                 :            :   //Note this for later.
     836 [ #  # ][ #  # ]:          0 :   unmerge_modified.append( vtx_ptr );
     837                 :            :   
     838                 :            :   //Notify merge assistants of unmerge
     839         [ #  # ]:          0 :   DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
     840 [ #  # ][ #  # ]:          0 :   for( int a = assistant_list_.size(); a > 0; a-- )
     841         [ #  # ]:          0 :     assistant_list_.get_and_step()->
     842 [ #  # ][ #  # ]:          0 :       unmerged( vtx_ptr, new_entity, CUBIT_FALSE );
                 [ #  # ]
     843                 :            :   
     844                 :            :   
     845         [ #  # ]:          0 :   end_unmerge(top);  
     846         [ #  # ]:          0 :   return new_entity;
     847                 :            : }
     848                 :            : 
     849                 :            : 
     850                 :          0 : void OldUnmergeCode::remove_CAEntityId_attrib( TopologyBridge* tb_ptr )
     851                 :            : {
     852         [ #  # ]:          0 :   DLIList<CubitSimpleAttrib> attrib_list;
     853         [ #  # ]:          0 :   tb_ptr->get_simple_attribute( attrib_list );
     854 [ #  # ][ #  # ]:          0 :   for( int i = attrib_list.size(); i > 0; i-- )
     855                 :            :   {
     856         [ #  # ]:          0 :     const CubitSimpleAttrib& attrib = attrib_list.get_and_step();
     857 [ #  # ][ #  # ]:          0 :     if( attrib.character_type() == "ENTITY_ID" )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     858                 :            :     {
     859         [ #  # ]:          0 :       tb_ptr->remove_simple_attribute_virt( attrib );
     860                 :            :     }
     861         [ #  # ]:          0 :   }
     862                 :          0 : }  
     863                 :            : 
     864                 :            : 
     865                 :            : //-------------------------------------------------------------------------
     866                 :            : // Purpose       : Remove a surface from its owning RefFace, and make a new
     867                 :            : //                 RefFace with the Surface.
     868                 :            : //
     869                 :            : // Special Notes : 
     870                 :            : //
     871                 :            : // Creator       : Jason Kraftcheck
     872                 :            : //
     873                 :            : // Creation Date : 01/18/01
     874                 :            : //-------------------------------------------------------------------------
     875                 :          0 : RefFace* OldUnmergeCode::split_out_Surface( Surface* surface, CubitBoolean& reversed )
     876                 :            : {
     877                 :            :   // Remove the child from the old owner.
     878                 :          0 :   reversed = false;
     879         [ #  # ]:          0 :   TopologyEntity* te_ptr = surface->topology_entity();
     880         [ #  # ]:          0 :   RefFace* old_entity = CAST_TO( te_ptr, RefFace );
     881         [ #  # ]:          0 :   if( te_ptr )
     882                 :            :   {
     883         [ #  # ]:          0 :     assert( old_entity != 0 );
     884                 :            :     
     885 [ #  # ][ #  # ]:          0 :     te_ptr->bridge_manager()->remove_bridge( surface );
     886         [ #  # ]:          0 :     remove_CAEntityId_attrib( surface );
     887 [ #  # ][ #  # ]:          0 :     old_unmerged.append( old_entity );
     888                 :            :     
     889 [ #  # ][ #  # ]:          0 :     if (te_ptr->bridge_manager()->topology_bridge()->bridge_sense() == CUBIT_REVERSED)
         [ #  # ][ #  # ]
     890                 :            :     { 
     891         [ #  # ]:          0 :       te_ptr->reverse_topology();
     892 [ #  # ][ #  # ]:          0 :       te_ptr->bridge_manager()->reverse_bridge_senses();
     893                 :          0 :       reversed = !reversed;
     894                 :            :     }
     895 [ #  # ][ #  # ]:          0 :     if (surface->bridge_sense() == CUBIT_REVERSED)
     896                 :            :     {
     897         [ #  # ]:          0 :       surface->reverse_bridge_sense();
     898                 :          0 :       reversed = !reversed;
     899                 :            :     }
     900                 :            :   }
     901                 :            :   
     902         [ #  # ]:          0 :   surface->set_saved_id(0);
     903                 :            :   
     904                 :            :   // make new refface
     905 [ #  # ][ #  # ]:          0 :   RefFace* new_entity = RefEntityFactory::instance()->construct_RefFace( surface );
     906                 :            : 
     907                 :            :   // Unmerge Loops
     908         [ #  # ]:          0 :   DLIList<LoopSM*> loopsms;
     909         [ #  # ]:          0 :   surface->loopsms( loopsms );
     910 [ #  # ][ #  # ]:          0 :   for( int i = loopsms.size(); i > 0; i-- )
     911                 :            :   {
     912 [ #  # ][ #  # ]:          0 :     Loop* new_loop = split_out_Loop(loopsms.get_and_step(), new_entity, reversed);
     913         [ #  # ]:          0 :     new_entity->add_grouping_entity( new_loop );
     914                 :            :   }
     915                 :            :   
     916 [ #  # ][ #  # ]:          0 :   new_unmerged.append(new_entity);
     917 [ #  # ][ #  # ]:          0 :   event_list.append( new UnMergeEvent( old_entity, new_entity ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     918                 :            :   
     919         [ #  # ]:          0 :   return new_entity;
     920                 :            : }
     921                 :            : 
     922                 :            : //-------------------------------------------------------------------------
     923                 :            : // Purpose       : Unmerge Loop and CoEdges
     924                 :            : //
     925                 :            : // Special Notes : 
     926                 :            : //
     927                 :            : // Creator       : Jason Kraftcheck
     928                 :            : //
     929                 :            : // Creation Date : 01/23/01
     930                 :            : //-------------------------------------------------------------------------
     931                 :          0 : Loop* OldUnmergeCode::split_out_Loop( LoopSM* loopsm, RefFace* /*new_entity*/, CubitBoolean reverse )
     932                 :            : {
     933                 :            :   // Remove from existing TopologyEntity
     934         [ #  # ]:          0 :   TopologyEntity* topo = loopsm->topology_entity();
     935 [ #  # ][ #  # ]:          0 :   loopsm->bridge_manager()->remove_bridge( loopsm );
     936                 :            : 
     937                 :            :   int i;
     938         [ #  # ]:          0 :   Loop* old_loop = CAST_TO( topo, Loop );  
     939         [ #  # ]:          0 :   assert( old_loop != 0 );
     940                 :            :   //RefFace* old_face = old_loop->get_ref_face_ptr();
     941 [ #  # ][ #  # ]:          0 :   Loop* new_loop = new Loop( loopsm );
     942         [ #  # ]:          0 :   DLIList<TopologyBridge*> tb_list;
     943 [ #  # ][ #  # ]:          0 :   DLIList<CoEdge*> coedges;
     944         [ #  # ]:          0 :   old_loop->ordered_co_edges( coedges );
     945 [ #  # ][ #  # ]:          0 :   if( !reverse ) coedges.reverse();
     946                 :            :   
     947                 :          0 :   CoEdge* prev = 0;
     948 [ #  # ][ #  # ]:          0 :   while( coedges.size() > 0 )
     949                 :            :   {
     950         [ #  # ]:          0 :     coedges.last();
     951         [ #  # ]:          0 :     CoEdge* coedge_ptr = coedges.remove();
     952                 :            :     
     953                 :            :     // Find the corresponding CoEdgeSM to unmerge.
     954         [ #  # ]:          0 :     tb_list.clean_out();
     955 [ #  # ][ #  # ]:          0 :     coedge_ptr->bridge_manager()->get_bridge_list(tb_list);
     956                 :          0 :     CoEdgeSM* coedgesm = NULL;  //Match to LoopSM
     957 [ #  # ][ #  # ]:          0 :     for( i = tb_list.size(); i > 0; i-- )
     958                 :            :     {
     959         [ #  # ]:          0 :       TopologyBridge* tb_ptr = tb_list.get_and_step();
     960 [ #  # ][ #  # ]:          0 :       if( tb_ptr->loopsm() == loopsm )
     961                 :            :       {
     962         [ #  # ]:          0 :         coedgesm = CAST_TO(tb_ptr,CoEdgeSM);
     963                 :          0 :         break;
     964                 :            :       }
     965                 :            :     }
     966                 :            :     
     967         [ #  # ]:          0 :     assert(coedgesm != 0);
     968                 :            :     
     969                 :            :     // Unmerge CoEdge
     970 [ #  # ][ #  # ]:          0 :     coedge_ptr->bridge_manager()->remove_bridge( coedgesm );
     971         [ #  # ]:          0 :     RefEdge* edge_ptr = coedge_ptr->get_ref_edge_ptr();
     972         [ #  # ]:          0 :     CubitSense sense = coedge_ptr->get_sense();
     973         [ #  # ]:          0 :     if( reverse ) 
     974         [ #  # ]:          0 :       sense = CubitUtil::opposite_sense( sense );
     975 [ #  # ][ #  # ]:          0 :     CoEdge* new_coedge = new CoEdge( edge_ptr, sense );
     976         [ #  # ]:          0 :     new_coedge->set_co_edge_sm_ptr( coedgesm );
     977         [ #  # ]:          0 :     new_loop->add_sense_entity( new_coedge, prev );
     978                 :          0 :     prev = new_coedge;
     979                 :            :   }
     980                 :            :   
     981         [ #  # ]:          0 :   return new_loop;
     982                 :            : }
     983                 :            : 
     984                 :            : 
     985                 :            :     
     986                 :            : //-------------------------------------------------------------------------
     987                 :            : // Purpose       : VG provides downward query of TopologyBridges, but
     988                 :            : //                 not always upward queries.  So to do upward queries,
     989                 :            : //                 do downward queries and search for source object.
     990                 :            : //
     991                 :            : // Special Notes : 
     992                 :            : //
     993                 :            : // Creator       : Jason Kraftcheck
     994                 :            : //
     995                 :            : // Creation Date : 03/26/01
     996                 :            : //-------------------------------------------------------------------------
     997                 :          0 : void OldUnmergeCode::find_curves( TBPoint* point_ptr, DLIList<Curve*>& result_set )
     998                 :            : {
     999                 :            :   //Do normal TB query for real geometry
    1000                 :          0 :   point_ptr->curves(result_set);
    1001                 :            :   
    1002                 :            :   //Now account for missing TB links due to virtual geometry
    1003         [ #  # ]:          0 :   RefVertex* vtx_ptr = CAST_TO(point_ptr->topology_entity(),RefVertex);
    1004         [ #  # ]:          0 :   if( vtx_ptr )
    1005                 :            :   {
    1006         [ #  # ]:          0 :     DLIList<RefEdge*> vtx_edges;
    1007 [ #  # ][ #  # ]:          0 :     DLIList<TBPoint*> curve_pts;
    1008 [ #  # ][ #  # ]:          0 :     DLIList<TopologyBridge*> edge_bridges;
    1009         [ #  # ]:          0 :     vtx_ptr->ref_edges(vtx_edges);
    1010 [ #  # ][ #  # ]:          0 :     for( int i = vtx_edges.size(); i > 0; i-- )
    1011                 :            :     {
    1012         [ #  # ]:          0 :       RefEdge* edge_ptr = vtx_edges.get_and_step();
    1013         [ #  # ]:          0 :       edge_bridges.clean_out();
    1014 [ #  # ][ #  # ]:          0 :       edge_ptr->bridge_manager()->get_bridge_list( edge_bridges );
    1015 [ #  # ][ #  # ]:          0 :       for( int j = edge_bridges.size(); j > 0; j-- )
    1016                 :            :       {
    1017         [ #  # ]:          0 :         TopologyBridge* bridge_ptr = edge_bridges.get_and_step();
    1018         [ #  # ]:          0 :         curve_pts.clean_out();
    1019         [ #  # ]:          0 :         bridge_ptr->points(curve_pts);
    1020 [ #  # ][ #  # ]:          0 :         if( curve_pts.is_in_list( point_ptr ) )
    1021                 :            :         {
    1022         [ #  # ]:          0 :           Curve* curve_ptr = CAST_TO(bridge_ptr,Curve);
    1023         [ #  # ]:          0 :           assert(curve_ptr != 0);
    1024         [ #  # ]:          0 :           result_set.append_unique(curve_ptr);
    1025                 :            :         }
    1026                 :            :       }
    1027         [ #  # ]:          0 :     }
    1028                 :            :   }
    1029                 :          0 : }
    1030                 :            :     
    1031                 :            : //-------------------------------------------------------------------------
    1032                 :            : // Purpose       : VG provides downward query of TopologyBridges, but
    1033                 :            : //                 not always upward queries.  So to do upward queries,
    1034                 :            : //                 do downward queries and search for source object.
    1035                 :            : //
    1036                 :            : // Special Notes : 
    1037                 :            : //
    1038                 :            : // Creator       : Jason Kraftcheck
    1039                 :            : //
    1040                 :            : // Creation Date : 03/26/01
    1041                 :            : //-------------------------------------------------------------------------
    1042                 :          0 : void OldUnmergeCode::find_surfaces( Curve* curve_ptr, DLIList<Surface*>& result_set )
    1043                 :            : {
    1044                 :            :   //Do normal TB query for real geometry
    1045                 :          0 :   curve_ptr->surfaces(result_set);
    1046                 :          0 : }
    1047                 :            : 
    1048                 :            : 
    1049                 :            : //-------------------------------------------------------------------------
    1050                 :            : // Purpose       : Unmerge a Curve from its owning RefEdge, and make a new
    1051                 :            : //                 RefEdge
    1052                 :            : //
    1053                 :            : // Special Notes : 
    1054                 :            : //
    1055                 :            : // Creator       : Jason Kraftcheck
    1056                 :            : //
    1057                 :            : // Creation Date : 01/18/01
    1058                 :            : //-------------------------------------------------------------------------
    1059                 :          0 : RefEdge* OldUnmergeCode::split_out_Curves( DLIList<Curve*>& curve_list, CubitBoolean& reversed )
    1060                 :            : {
    1061                 :            :   int i;
    1062                 :            :   
    1063                 :            :   // If any parent Surfaces are still merged, we
    1064                 :            :   // cannot continue.
    1065         [ #  # ]:          0 :   DLIList<Surface*> surface_list;
    1066 [ #  # ][ #  # ]:          0 :   for( i = curve_list.size(); i > 0; i-- )
    1067                 :            :   {
    1068         [ #  # ]:          0 :     surface_list.clean_out();
    1069 [ #  # ][ #  # ]:          0 :     find_surfaces( curve_list.get_and_step(), surface_list );
    1070 [ #  # ][ #  # ]:          0 :     for( int j = surface_list.size(); j > 0; j-- )
    1071 [ #  # ][ #  # ]:          0 :       if( surface_list.get_and_step()->bridge_manager()
    1072 [ #  # ][ #  # ]:          0 :         ->number_of_bridges() != curve_list.size() )
                 [ #  # ]
    1073                 :          0 :         return NULL;
    1074                 :            :   }
    1075                 :            :   
    1076                 :            :   // Remove the curves from the old owner.
    1077         [ #  # ]:          0 :   curve_list.reset();
    1078         [ #  # ]:          0 :   Curve* curve = curve_list.get();
    1079         [ #  # ]:          0 :   TopologyEntity* te_ptr = curve->topology_entity();
    1080 [ #  # ][ #  # ]:          0 :   for( i = curve_list.size(); i > 0; i-- )
    1081 [ #  # ][ #  # ]:          0 :     if( curve_list.get_and_step()->topology_entity() != te_ptr )
                 [ #  # ]
    1082                 :          0 :       return 0;
    1083                 :            :       
    1084 [ #  # ][ #  # ]:          0 :   assert( te_ptr->bridge_manager()->number_of_bridges() > curve_list.size() );
         [ #  # ][ #  # ]
    1085                 :            :   
    1086                 :          0 :   reversed = false;
    1087         [ #  # ]:          0 :   RefEdge* old_entity = CAST_TO( te_ptr, RefEdge );
    1088         [ #  # ]:          0 :   if( te_ptr )
    1089                 :            :   {
    1090         [ #  # ]:          0 :     assert( old_entity != 0 );
    1091                 :            :     
    1092         [ #  # ]:          0 :     curve_list.reset();
    1093 [ #  # ][ #  # ]:          0 :     for( i = curve_list.size(); i > 0; i-- )
    1094                 :            :     {
    1095         [ #  # ]:          0 :       Curve* ptr = curve_list.get_and_step();
    1096 [ #  # ][ #  # ]:          0 :       te_ptr->bridge_manager()->remove_bridge( ptr );
    1097         [ #  # ]:          0 :       remove_CAEntityId_attrib( ptr );
    1098                 :            :     }
    1099 [ #  # ][ #  # ]:          0 :     old_unmerged.append( old_entity );
    1100                 :            : 
    1101         [ #  # ]:          0 :     curve_list.reset();
    1102 [ #  # ][ #  # ]:          0 :     if (te_ptr->bridge_manager()->topology_bridge()->bridge_sense() == CUBIT_REVERSED)
         [ #  # ][ #  # ]
    1103                 :            :     {
    1104         [ #  # ]:          0 :       te_ptr->reverse_topology();
    1105 [ #  # ][ #  # ]:          0 :       te_ptr->bridge_manager()->reverse_bridge_senses();
    1106                 :          0 :       reversed = !reversed;
    1107                 :            :     }
    1108                 :            :     
    1109 [ #  # ][ #  # ]:          0 :     if (curve->bridge_sense() == CUBIT_REVERSED)
    1110                 :            :     {
    1111 [ #  # ][ #  # ]:          0 :       for (i = curve_list.size(); i--; )
    1112 [ #  # ][ #  # ]:          0 :         curve_list.get_and_step()->reverse_bridge_sense();
    1113                 :          0 :       reversed = !reversed;
    1114                 :            :     }
    1115                 :            :   }
    1116                 :            :   
    1117         [ #  # ]:          0 :   curve_list.reset();
    1118 [ #  # ][ #  # ]:          0 :   for ( i = curve_list.size(); i--; )
    1119 [ #  # ][ #  # ]:          0 :     curve_list.get_and_step()->set_saved_id(0);
    1120                 :            :   
    1121 [ #  # ][ #  # ]:          0 :   RefEdge* new_entity = RefEntityFactory::instance()->construct_RefEdge( curve );
    1122 [ #  # ][ #  # ]:          0 :   Chain* chain = new Chain;
    1123         [ #  # ]:          0 :   new_entity->add_grouping_entity(chain);
    1124                 :            : 
    1125 [ #  # ][ #  # ]:          0 :   DLIList<TopologyBridge*> points(2);
    1126         [ #  # ]:          0 :   curve->get_children(points);
    1127         [ #  # ]:          0 :   points.reset();
    1128         [ #  # ]:          0 :   for (i = 0; i < 2; i++)
    1129                 :            :   {
    1130 [ #  # ][ #  # ]:          0 :     CoVertex* cvtx = new CoVertex;
    1131 [ #  # ][ #  # ]:          0 :     TopologyEntity* owner = points.get_and_step()->topology_entity();
    1132 [ #  # ][ #  # ]:          0 :     cvtx->attach_basic_topology_entity( dynamic_cast<RefVertex*>(owner) );
    1133         [ #  # ]:          0 :     chain->add_sense_entity(cvtx);
    1134                 :            :   }
    1135                 :            :   
    1136 [ #  # ][ #  # ]:          0 :   for( i = curve_list.size(); i > 0; i-- )
    1137                 :            :   {
    1138         [ #  # ]:          0 :     Curve* a_curve = curve_list.get_and_step();
    1139         [ #  # ]:          0 :     if( curve != a_curve )
    1140 [ #  # ][ #  # ]:          0 :       new_entity->bridge_manager()->add_bridge(a_curve);
    1141                 :            :   }  
    1142                 :            : 
    1143 [ #  # ][ #  # ]:          0 :   PRINT_DEBUG_19("  Unmerged %s from %s.\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1144                 :            :              new_entity->entity_name().c_str(), 
    1145         [ #  # ]:          0 :              old_entity->entity_name().c_str() );
    1146                 :            :   
    1147                 :            :   
    1148                 :            :   
    1149 [ #  # ][ #  # ]:          0 :   new_unmerged.append( new_entity );
    1150 [ #  # ][ #  # ]:          0 :   event_list.append( new UnMergeEvent( old_entity, new_entity ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1151                 :            : 
    1152         [ #  # ]:          0 :   return new_entity;
    1153                 :            : }
    1154                 :            : 
    1155                 :            : //-------------------------------------------------------------------------
    1156                 :            : // Purpose       : Unmerge a TBPoint from its Vertex and make new Vertex
    1157                 :            : //
    1158                 :            : // Special Notes : 
    1159                 :            : //
    1160                 :            : // Creator       : Jason Kraftcheck
    1161                 :            : //
    1162                 :            : // Creation Date : 01/18/01
    1163                 :            : //-------------------------------------------------------------------------
    1164                 :          0 : RefVertex* OldUnmergeCode::split_out_Points( DLIList<TBPoint*>& point_list )
    1165                 :            : {
    1166                 :            :   int i;
    1167                 :            :   
    1168                 :            :   // If any parent Curves are still merged, we 
    1169                 :            :   // cannot continue.
    1170         [ #  # ]:          0 :   DLIList<Curve*> curve_list;
    1171 [ #  # ][ #  # ]:          0 :   for( i = point_list.size(); i > 0; i-- )
    1172                 :            :   {
    1173         [ #  # ]:          0 :     curve_list.clean_out();
    1174 [ #  # ][ #  # ]:          0 :     find_curves(point_list.get_and_step(),curve_list);
    1175 [ #  # ][ #  # ]:          0 :     for( int j = curve_list.size(); j > 0; j-- )
    1176 [ #  # ][ #  # ]:          0 :       if( curve_list.get_and_step()->bridge_manager()
    1177 [ #  # ][ #  # ]:          0 :         ->number_of_bridges() != point_list.size() )
                 [ #  # ]
    1178                 :          0 :         return NULL;
    1179                 :            :   }
    1180                 :            :   
    1181                 :            :   // Remove the child from the old owner.
    1182 [ #  # ][ #  # ]:          0 :   TopologyEntity* te_ptr = point_list.get()->topology_entity();
    1183                 :            :   
    1184                 :            :   // All points must have same bridge manager.
    1185 [ #  # ][ #  # ]:          0 :   for( i = point_list.size(); i > 0; i-- )
    1186 [ #  # ][ #  # ]:          0 :     if( point_list.get_and_step()->topology_entity() != te_ptr )
                 [ #  # ]
    1187                 :          0 :       return NULL;
    1188                 :            :   
    1189         [ #  # ]:          0 :   RefVertex* old_entity = CAST_TO( te_ptr, RefVertex );
    1190         [ #  # ]:          0 :   if( te_ptr )
    1191                 :            :   {
    1192         [ #  # ]:          0 :     assert(old_entity != 0);
    1193 [ #  # ][ #  # ]:          0 :     for( i = point_list.size(); i > 0; i-- )
    1194                 :            :     {
    1195         [ #  # ]:          0 :       TBPoint* ptr = point_list.get_and_step();
    1196 [ #  # ][ #  # ]:          0 :       te_ptr->bridge_manager()->remove_bridge( ptr );
    1197         [ #  # ]:          0 :       remove_CAEntityId_attrib( ptr );
    1198                 :            :     }
    1199 [ #  # ][ #  # ]:          0 :     old_unmerged.append( old_entity );
    1200                 :            :   }
    1201                 :            : 
    1202         [ #  # ]:          0 :   point_list.reset();
    1203 [ #  # ][ #  # ]:          0 :   for (i = point_list.size(); i--; )
    1204 [ #  # ][ #  # ]:          0 :     point_list.get_and_step()->set_saved_id(0);
    1205                 :            : 
    1206         [ #  # ]:          0 :   RefVertex* new_entity = RefEntityFactory::instance()
    1207 [ #  # ][ #  # ]:          0 :     ->construct_RefVertex(point_list.get_and_step());
    1208 [ #  # ][ #  # ]:          0 :   for( i = point_list.size(); i > 1; i-- )
    1209 [ #  # ][ #  # ]:          0 :     new_entity->bridge_manager()->add_bridge(point_list.get_and_step());
                 [ #  # ]
    1210                 :            :     
    1211 [ #  # ][ #  # ]:          0 :   PRINT_DEBUG_19("    Unmerged %s from %s.\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1212                 :            :              new_entity->entity_name().c_str(), 
    1213         [ #  # ]:          0 :              old_entity->entity_name().c_str() );
    1214                 :            :   
    1215 [ #  # ][ #  # ]:          0 :   new_unmerged.append( new_entity );
    1216 [ #  # ][ #  # ]:          0 :   event_list.append( new UnMergeEvent( old_entity, new_entity ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1217                 :            : 
    1218         [ #  # ]:          0 :   return new_entity;
    1219                 :            : }
    1220                 :            : 
    1221                 :            : //-------------------------------------------------------------------------
    1222                 :            : // Purpose       : Handle sending various events as a result of unmerging.
    1223                 :            : //
    1224                 :            : // Special Notes : 
    1225                 :            : //
    1226                 :            : // Creator       : Jason Kraftcheck
    1227                 :            : //
    1228                 :            : // Creation Date : 01/18/01
    1229                 :            : //-------------------------------------------------------------------------
    1230                 :          0 : void OldUnmergeCode::cleanup_unmerge()
    1231                 :            : {
    1232 [ #  # ][ #  # ]:          0 :   DLIList<RefEntity*> temp_list, marked_list;
                 [ #  # ]
    1233                 :            :   int i, j;
    1234         [ #  # ]:          0 :   CpuTimer timer;
    1235                 :            :   
    1236                 :            :   //Remove entities from unmerge_modified that
    1237                 :            :   // a) are duplicate entries in the list
    1238                 :            :   // b) also exist in new_unmerged
    1239                 :            :   // c) have parent entities already in unmerge_modified.
    1240                 :            :   
    1241                 :            :   //Change unmerge_modified to be a list of the immediate
    1242                 :            :   //parents of the entities currently in the list
    1243         [ #  # ]:          0 :   marked_list = unmerge_modified;
    1244         [ #  # ]:          0 :   unmerge_modified.clean_out();
    1245 [ #  # ][ #  # ]:          0 :   for( i = marked_list.size(); i--; )
    1246                 :            :   {
    1247         [ #  # ]:          0 :     temp_list.clean_out();
    1248 [ #  # ][ #  # ]:          0 :     marked_list.get_and_step()->get_parent_ref_entities( temp_list );
    1249         [ #  # ]:          0 :     unmerge_modified += temp_list;
    1250                 :            :   }
    1251 [ #  # ][ #  # ]:          0 :   for( i = new_unmerged.size(); i > 0; i-- )
    1252                 :            :   {
    1253         [ #  # ]:          0 :     temp_list.clean_out();
    1254 [ #  # ][ #  # ]:          0 :     new_unmerged.get_and_step()->get_parent_ref_entities( temp_list );
    1255         [ #  # ]:          0 :     unmerge_modified += temp_list;
    1256                 :            :   }
    1257                 :            :   
    1258                 :            :   //Reset marks on all entities in list
    1259 [ #  # ][ #  # ]:          0 :   for( i = unmerge_modified.size(); i > 0; i-- )
    1260 [ #  # ][ #  # ]:          0 :     unmerge_modified.get_and_step()->marked(0);
    1261                 :            : 
    1262                 :            :   //Set instance count (mark) to one for all in new_unmerged
    1263 [ #  # ][ #  # ]:          0 :   for( i = new_unmerged.size(); i > 0; i-- )
    1264 [ #  # ][ #  # ]:          0 :     new_unmerged.get_and_step()->marked(1);
    1265                 :            :     
    1266                 :            :   
    1267                 :            :     
    1268                 :            :   //Increment instance count (mark) for each occurance
    1269                 :            :   //in unmerge_modified.
    1270 [ #  # ][ #  # ]:          0 :   for( i = unmerge_modified.size(); i > 0; i-- )
    1271                 :            :   {
    1272 [ #  # ][ #  # ]:          0 :     unmerge_modified.get()->marked( unmerge_modified.get()->marked()+1 );
         [ #  # ][ #  # ]
    1273         [ #  # ]:          0 :     temp_list.clean_out();
    1274 [ #  # ][ #  # ]:          0 :     unmerge_modified.get()->get_all_child_ref_entities(temp_list);
    1275         [ #  # ]:          0 :     marked_list += temp_list; 
    1276         [ #  # ]:          0 :     unmerge_modified.step();
    1277                 :            :   }
    1278                 :            :   
    1279 [ #  # ][ #  # ]:          0 :   for( i = marked_list.size(); i > 0; i-- )
    1280                 :            :   {
    1281 [ #  # ][ #  # ]:          0 :     marked_list.get()->marked( marked_list.get()->marked() + 1 );
         [ #  # ][ #  # ]
    1282         [ #  # ]:          0 :     marked_list.step();
    1283                 :            :   }
    1284                 :            :   
    1285                 :            :   //If the entity's mark is non-zero after decrementing
    1286                 :            :   //the mark, remove it because it occurs again later in
    1287                 :            :   //the list.
    1288         [ #  # ]:          0 :   unmerge_modified.reset();
    1289 [ #  # ][ #  # ]:          0 :   for( i = unmerge_modified.size(); i > 0; i-- )
    1290                 :            :   {
    1291 [ #  # ][ #  # ]:          0 :     unmerge_modified.get()->marked( unmerge_modified.get()->marked() - 1 );
         [ #  # ][ #  # ]
    1292 [ #  # ][ #  # ]:          0 :     if( unmerge_modified.get()->marked() )
                 [ #  # ]
    1293         [ #  # ]:          0 :       unmerge_modified.extract();
    1294                 :            :     else
    1295         [ #  # ]:          0 :       unmerge_modified.step();
    1296                 :            :   }
    1297                 :            : 
    1298                 :            :   //Clear out other marks we set.
    1299 [ #  # ][ #  # ]:          0 :   for( i = new_unmerged.size(); i > 0; i-- )
    1300 [ #  # ][ #  # ]:          0 :     new_unmerged.get_and_step()->marked(0);
    1301 [ #  # ][ #  # ]:          0 :   for( i = marked_list.size(); i > 0; i-- )
    1302 [ #  # ][ #  # ]:          0 :     marked_list.get_and_step()->marked(0);
    1303                 :            :   
    1304                 :            :   
    1305                 :            :   //Now remove duplicates from old_unmerged. 
    1306 [ #  # ][ #  # ]:          0 :   for( i = old_unmerged.size(); i > 0; i-- )
    1307 [ #  # ][ #  # ]:          0 :     old_unmerged.get_and_step()->marked(1);
    1308         [ #  # ]:          0 :   old_unmerged.reset();
    1309 [ #  # ][ #  # ]:          0 :   for( i = old_unmerged.size(); i > 0; i-- )
    1310                 :            :   {
    1311 [ #  # ][ #  # ]:          0 :     if( old_unmerged.get()->marked() )
                 [ #  # ]
    1312 [ #  # ][ #  # ]:          0 :       old_unmerged.get_and_step()->marked(0);
    1313                 :            :     else
    1314         [ #  # ]:          0 :       old_unmerged.extract();
    1315                 :            :   }
    1316                 :            :   
    1317                 :            :   
    1318                 :            :   // Finally, done rearranging lists.  Now actually do
    1319                 :            :   // the important stuff.
    1320                 :            :   
    1321                 :            :   // Count occurances of each type of entity, and 
    1322                 :            :   // output counts.
    1323                 :          0 :   int face_count = 0, edge_count = 0, vtx_count = 0;
    1324         [ #  # ]:          0 :   new_unmerged.reset();
    1325 [ #  # ][ #  # ]:          0 :   for( i = new_unmerged.size(); i > 0; i-- )
    1326                 :            :   {
    1327 [ #  # ][ #  # ]:          0 :     if( CAST_TO( new_unmerged.get(), RefFace ) )
         [ #  # ][ #  # ]
    1328                 :          0 :        face_count++;
    1329 [ #  # ][ #  # ]:          0 :     else if( CAST_TO( new_unmerged.get(), RefEdge ) )
         [ #  # ][ #  # ]
    1330                 :          0 :        edge_count++;
    1331 [ #  # ][ #  # ]:          0 :     else if( CAST_TO( new_unmerged.get(), RefVertex ) )
         [ #  # ][ #  # ]
    1332                 :          0 :        vtx_count++;
    1333                 :            :     else
    1334                 :          0 :       assert( 0 /*Bad EntityType*/ );
    1335                 :            : 
    1336         [ #  # ]:          0 :     new_unmerged.step();
    1337                 :            :   }
    1338                 :            :   
    1339 [ #  # ][ #  # ]:          0 :   if( AppUtil::instance()->interrupt() ) PRINT_WARNING("Unmerge aborted.\n");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1340 [ #  # ][ #  # ]:          0 :   if( face_count ) PRINT_INFO("%4d surfaces unmerged.\n",face_count);
         [ #  # ][ #  # ]
                 [ #  # ]
    1341 [ #  # ][ #  # ]:          0 :   if( edge_count ) PRINT_INFO("%4d  curves  unmerged.\n",edge_count);
         [ #  # ][ #  # ]
                 [ #  # ]
    1342 [ #  # ][ #  # ]:          0 :   if( vtx_count )  PRINT_INFO("%4d vertices unmerged.\n",vtx_count);
         [ #  # ][ #  # ]
                 [ #  # ]
    1343 [ #  # ][ #  # ]:          0 :   PRINT_DEBUG_19("Unmerge completed in %0.2f seconds.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1344         [ #  # ]:          0 :                                          timer.cpu_secs() );
    1345                 :            :   
    1346                 :            :   //Let the user know if we actually unmerged anything.
    1347 [ #  # ][ #  # ]:          0 :   if( !new_unmerged.size() )
    1348 [ #  # ][ #  # ]:          0 :     PRINT_INFO("No entities unmerged.\n");
         [ #  # ][ #  # ]
    1349                 :            :  
    1350 [ #  # ][ #  # ]:          0 :   int event_count = new_unmerged.size() + event_list.size() + unmerge_modified.size();
                 [ #  # ]
    1351                 :          0 :   ProgressTool* progress = 0;
    1352         [ #  # ]:          0 :   if (event_count > 20)
    1353 [ #  # ][ #  # ]:          0 :     progress = AppUtil::instance()->progress_tool();
    1354         [ #  # ]:          0 :   if (progress)
    1355         [ #  # ]:          0 :     progress->start( 0, event_count, "Updating Graphics" );
    1356                 :            :  
    1357                 :            :   //Info for DEBUG output
    1358                 :          0 :   const char* entity_names[] = { "Vertices", "Curves", "Surfaces" };
    1359         [ #  # ]:          0 :   timer.cpu_secs();
    1360                 :            :   
    1361                 :            :   //Add all new entities to the graphics.  Do lowest-dimension
    1362                 :            :   //entities first, so that they exist in the graphics when the
    1363                 :            :   //higher-dimension entities owning them are added.
    1364         [ #  # ]:          0 :   for( j = 0; j < 3; j++ )
    1365                 :            :   {
    1366                 :          0 :     int count = 0; //for PRINT_DEBUG statement below.
    1367                 :            :       
    1368 [ #  # ][ #  # ]:          0 :     for( i = new_unmerged.size(); i > 0; i-- )
    1369                 :            :     {
    1370         [ #  # ]:          0 :       RefEntity* entity = new_unmerged.get_and_step();
    1371 [ #  # ][ #  # ]:          0 :       if( entity->dimension() != j ) 
    1372                 :          0 :         continue;
    1373                 :            :       
    1374                 :          0 :       count++;
    1375                 :            :       
    1376                 :            :       //Is this a free RefEntity?
    1377         [ #  # ]:          0 :       temp_list.clean_out();
    1378         [ #  # ]:          0 :       entity->get_parent_ref_entities( temp_list );
    1379                 :            :       
    1380 [ #  # ][ #  # ]:          0 :       if( temp_list.size() == 0 )
    1381 [ #  # ][ #  # ]:          0 :         AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::FREE_REF_ENTITY_GENERATED, entity));
         [ #  # ][ #  # ]
    1382                 :            : 
    1383         [ #  # ]:          0 :       if (progress)
    1384         [ #  # ]:          0 :         progress->step();
    1385 [ #  # ][ #  # ]:          0 :       PRINT_DEBUG_19("\t\tAdded %s to graphics\n", entity->entity_name().c_str() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1386                 :            : 
    1387                 :            :       //entity->notify_all_observers( NEW_ENTITY_UNMERGED );
    1388                 :            :     }
    1389 [ #  # ][ #  # ]:          0 :     PRINT_DEBUG_19("\tAdded %d new %s to graphics in %0.2f seconds.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1390         [ #  # ]:          0 :       count, entity_names[j], timer.cpu_secs() );
    1391                 :            :   }
    1392                 :            :   
    1393 [ #  # ][ #  # ]:          0 :   while( event_list.size() )
    1394                 :            :   {
    1395         [ #  # ]:          0 :     UnMergeEvent* event = event_list.pop();
    1396                 :            :     //event->new_entity->notify_observers(event)
    1397 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event( *event );
    1398 [ #  # ][ #  # ]:          0 :     delete event;
    1399         [ #  # ]:          0 :     if (progress)
    1400         [ #  # ]:          0 :       progress->step();
    1401                 :            :   }
    1402                 :            :   
    1403                 :            :   //Update for other non-new entities that got modified
    1404                 :            :   //as a part of unmerging.
    1405 [ #  # ][ #  # ]:          0 :   for( i = unmerge_modified.size(); i > 0; i-- )
    1406                 :            :   {
    1407 [ #  # ][ #  # ]:          0 :     PRINT_DEBUG_19("\t\tUpdated graphics for %s.\n", unmerge_modified.get()->entity_name().c_str() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1408 [ #  # ][ #  # ]:          0 :     AppUtil::instance()->send_event(GeometryEvent(GeometryEvent::TOPOLOGY_MODIFIED, unmerge_modified.get_and_step()));
         [ #  # ][ #  # ]
                 [ #  # ]
    1409         [ #  # ]:          0 :     if (progress)
    1410         [ #  # ]:          0 :       progress->step();  
    1411                 :            :   }
    1412         [ #  # ]:          0 :   if (progress)
    1413         [ #  # ]:          0 :     progress->end();
    1414                 :            :   
    1415 [ #  # ][ #  # ]:          0 :   PRINT_DEBUG_19("Sent TOPOLOGY_MODIFIED event for %d entities in %0.2f "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1416         [ #  # ]:          0 :                  "seconds\n",unmerge_modified.size(), timer.cpu_secs());
    1417 [ #  # ][ #  # ]:          0 :   PRINT_DEBUG_19("Total time to update after unmerge: %0.2f seconds.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1418         [ #  # ]:          0 :     timer.elapsed() );
    1419                 :            : 
    1420         [ #  # ]:          0 :   DLIList<MergeToolAssistant*>& assistant_list_ = MergeTool::instance()->assistant_list_;
    1421 [ #  # ][ #  # ]:          0 :   for( int a = assistant_list_.size(); a--; )
    1422 [ #  # ][ #  # ]:          0 :     assistant_list_.get_and_step()->finish_unmerge();
                 [ #  # ]
    1423 [ +  - ][ +  - ]:       6540 : }
    1424                 :            : 
    1425                 :            :     
    1426                 :            : 

Generated by: LCOV version 1.11