LCOV - code coverage report
Current view: top level - geom/virtual - HiddenEntitySet.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1 87 1.1 %
Date: 2020-06-30 00:58:45 Functions: 2 14 14.3 %
Branches: 2 270 0.7 %

           Branch data     Line data    Source code
       1                 :            : //-------------------------------------------------------------------------
       2                 :            : // Filename      : HiddenEntitySet.cpp
       3                 :            : //
       4                 :            : // Purpose       : A class to hold a list of hidden entites and act as
       5                 :            : //                 their owner.
       6                 :            : //
       7                 :            : // Special Notes : 
       8                 :            : //
       9                 :            : // Creator       : Jason Kraftcheck
      10                 :            : //
      11                 :            : // Creation Date : 01/14/02
      12                 :            : //-------------------------------------------------------------------------
      13                 :            : 
      14                 :            : #include "VGDefines.h"
      15                 :            : #include "HiddenEntitySet.hpp"
      16                 :            : 
      17                 :            : #include "BodySM.hpp"
      18                 :            : #include "Lump.hpp"
      19                 :            : #include "ShellSM.hpp"
      20                 :            : #include "Surface.hpp"
      21                 :            : #include "LoopSM.hpp"
      22                 :            : #include "CoEdgeSM.hpp"
      23                 :            : #include "Curve.hpp"
      24                 :            : #include "Point.hpp"
      25                 :            : 
      26                 :            : // for debug output
      27                 :            : #include "CompositePoint.hpp"
      28                 :            : #include "CompositeCurve.hpp"
      29                 :            : #include "CompositeCoEdge.hpp"
      30                 :            : #include "CompositeSurface.hpp"
      31                 :            : #include "CubitMessage.hpp"
      32                 :            : 
      33                 :            : 
      34         [ #  # ]:          0 : HiddenEntitySet::~HiddenEntitySet()
      35                 :            : {
      36         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
      37 [ #  # ][ #  # ]:          0 :   for (iter=hiddenList.begin(); iter!=hiddenList.end(); iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
      38 [ #  # ][ #  # ]:          0 :     (*iter)->owner(0);
      39                 :            : 
      40         [ #  # ]:          0 :   hiddenList.clear();
      41         [ #  # ]:          0 : }
      42                 :            : 
      43                 :          0 : CubitStatus HiddenEntitySet::hide( TopologyBridge* bridge )
      44                 :            : {
      45 [ #  # ][ #  # ]:          0 :   if( bridge->owner() && !bridge->owner()->remove_bridge(bridge) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      46                 :          0 :     return CUBIT_FAILURE;
      47                 :            :     
      48         [ #  # ]:          0 :   bridge->owner( this );
      49                 :            : 
      50                 :            :   // It would be simpler to just add new hidden entities at the back of the list
      51                 :            :   // but this code mimics the previous behavior of inserting new entities 
      52                 :            :   // after the first entity in the list.  Changing this changes the ids of
      53                 :            :   // geometry entities when a composite is removed.  BWH - 11/09/05
      54                 :            :   //
      55                 :            :   // TODO - BWH - do we want to change the order now to make things simpler or come up
      56                 :            :   // with a way to keep ids after removing composites
      57                 :            :   //
      58                 :            :   // TODO - BWH - the list functions in HiddenEntitySet are almost identical to the list functions in BridgeManager
      59                 :            :   // the main difference is the order that entities are inserted.  If we want to make the behavior consistent, maybe a TBList class
      60                 :            :   // could be implemented to use in both places.
      61                 :            : 
      62         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
      63         [ #  # ]:          0 :   iter = hiddenList.begin();
      64 [ #  # ][ #  # ]:          0 :   if (hiddenList.size() > 0)
      65         [ #  # ]:          0 :     iter++;
      66         [ #  # ]:          0 :   hiddenList.insert(iter, bridge);
      67                 :            :   
      68                 :          0 :   return CUBIT_SUCCESS;
      69                 :            : }
      70                 :            :  
      71                 :          0 : CubitStatus HiddenEntitySet::restore( TopologyBridge* bridge )
      72                 :            : {
      73 [ #  # ][ #  # ]:          0 :   if( bridge->owner() != this )
      74                 :          0 :     return CUBIT_FAILURE;
      75                 :            :   
      76         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
      77 [ #  # ][ #  # ]:          0 :   iter = std::find(hiddenList.begin(), hiddenList.end(), bridge);
                 [ #  # ]
      78 [ #  # ][ #  # ]:          0 :   if (iter != hiddenList.end())
                 [ #  # ]
      79         [ #  # ]:          0 :     hiddenList.erase(iter);
      80                 :            :   else
      81                 :          0 :     return CUBIT_FAILURE;
      82                 :            : 
      83         [ #  # ]:          0 :   bridge->owner( 0 );
      84                 :            :     
      85                 :          0 :   return CUBIT_SUCCESS;
      86                 :            : }
      87                 :            : 
      88                 :          0 : CubitStatus HiddenEntitySet::remove_bridge( TopologyBridge* bridge )
      89                 :            : {
      90                 :          0 :   return restore(bridge);
      91                 :            : }
      92                 :            : 
      93                 :          0 : CubitStatus HiddenEntitySet::swap_bridge( TopologyBridge* old_tb,
      94                 :            :                                           TopologyBridge* new_tb,
      95                 :            :                                           bool )
      96                 :            : {
      97 [ #  # ][ #  # ]:          0 :   if ( new_tb->owner() || !restore(old_tb) )
                 [ #  # ]
      98                 :            :   {
      99                 :          0 :     assert(0);
     100                 :            :     return CUBIT_FAILURE;
     101                 :            :   }
     102                 :            :   
     103                 :          0 :   return hide(new_tb);
     104                 :            : }
     105                 :            : 
     106                 :          0 : CubitStatus HiddenEntitySet::merge( HiddenEntitySet* other )
     107                 :            : {
     108         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
     109         [ #  # ]:          0 :   std::vector<TopologyBridge*> other_list;
     110                 :            : 
     111                 :            :   // copy the list being merged so we can operate on the real list
     112                 :            :   // without invalidating the iterator
     113         [ #  # ]:          0 :   other_list = other->hiddenList;
     114 [ #  # ][ #  # ]:          0 :   for (iter=other_list.begin(); iter!=other_list.end(); iter++ )
         [ #  # ][ #  # ]
                 [ #  # ]
     115                 :            :   {
     116 [ #  # ][ #  # ]:          0 :     other->restore( *iter );
     117 [ #  # ][ #  # ]:          0 :     hide( *iter );
     118                 :            :   }
     119                 :            : 
     120         [ #  # ]:          0 :   return CUBIT_SUCCESS;
     121                 :            : }
     122                 :            : 
     123                 :            : 
     124                 :          0 : void HiddenEntitySet::hidden_surfaces( DLIList<Surface*>& result )
     125                 :            : {
     126         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
     127 [ #  # ][ #  # ]:          0 :   for (iter=hiddenList.begin(); iter!=hiddenList.end(); iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
     128                 :            :   {
     129 [ #  # ][ #  # ]:          0 :     if (Surface* ptr = dynamic_cast<Surface*>( *iter ))
                 [ #  # ]
     130         [ #  # ]:          0 :       result.append(ptr);
     131                 :            :   }
     132                 :          0 : }
     133                 :            : 
     134                 :          0 : void HiddenEntitySet::hidden_coedges( DLIList<CoEdgeSM*>& result )
     135                 :            : {
     136         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
     137 [ #  # ][ #  # ]:          0 :   for (iter=hiddenList.begin(); iter!=hiddenList.end(); iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
     138                 :            :   {
     139 [ #  # ][ #  # ]:          0 :     if (CoEdgeSM* ptr = dynamic_cast<CoEdgeSM*>( *iter ))
                 [ #  # ]
     140         [ #  # ]:          0 :       result.append(ptr);
     141                 :            :   }
     142                 :          0 : }
     143                 :            : 
     144                 :          0 : void HiddenEntitySet::hidden_curves( DLIList<Curve*>& result )
     145                 :            : {
     146         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
     147 [ #  # ][ #  # ]:          0 :   for (iter=hiddenList.begin(); iter!=hiddenList.end(); iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
     148                 :            :   {
     149 [ #  # ][ #  # ]:          0 :     if (Curve* ptr = dynamic_cast<Curve*>( *iter ))
                 [ #  # ]
     150         [ #  # ]:          0 :       result.append(ptr);
     151                 :            :   }
     152                 :          0 : }
     153                 :            : 
     154                 :          0 : void HiddenEntitySet::hidden_points( DLIList<TBPoint*>& result )
     155                 :            : {
     156         [ #  # ]:          0 :   std::vector<TopologyBridge*>::iterator iter;
     157 [ #  # ][ #  # ]:          0 :   for (iter=hiddenList.begin(); iter!=hiddenList.end(); iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
     158                 :            :   {
     159 [ #  # ][ #  # ]:          0 :     if (TBPoint* ptr = dynamic_cast<TBPoint*>( *iter ))
                 [ #  # ]
     160         [ #  # ]:          0 :       result.append(ptr);
     161                 :            :   }
     162                 :          0 : }
     163                 :            : 
     164                 :          0 : void HiddenEntitySet::print_debug_info( const char* prefix ) const
     165                 :            : {
     166         [ #  # ]:          0 :   if (!prefix)
     167                 :          0 :     prefix = "";
     168                 :            :   
     169 [ #  # ][ #  # ]:          0 :   PRINT_INFO("%sHiddenEntitySet %p owned by %s %p\n", 
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     170                 :            :     prefix, (void*)this,
     171                 :            :     myOwner ? fix_type_name(typeid(*myOwner).name()) : "(null)",
     172         [ #  # ]:          0 :     (void*)myOwner );
     173                 :            :     
     174         [ #  # ]:          0 :   char* new_prefix = new char[strlen(prefix)+3];
     175                 :          0 :   strcpy( new_prefix, prefix );
     176                 :          0 :   strcat( new_prefix, "  ");
     177                 :            : 
     178         [ #  # ]:          0 :   std::vector<TopologyBridge*>::const_iterator iter;
     179 [ #  # ][ #  # ]:          0 :   for (iter=hiddenList.begin(); iter!=hiddenList.end(); iter++)
         [ #  # ][ #  # ]
                 [ #  # ]
     180                 :            :   {
     181 [ #  # ][ #  # ]:          0 :     if( CompositePoint* cp = dynamic_cast<CompositePoint*>(*iter) )
                 [ #  # ]
     182         [ #  # ]:          0 :       cp->print_debug_info(new_prefix, true);
     183 [ #  # ][ #  # ]:          0 :     else if( CompositeCurve* cc = dynamic_cast<CompositeCurve*>(*iter) )
                 [ #  # ]
     184         [ #  # ]:          0 :       cc->print_debug_info(new_prefix, true);
     185 [ #  # ][ #  # ]:          0 :     else if( CompositeCoEdge* ce = dynamic_cast<CompositeCoEdge*>(*iter) )
                 [ #  # ]
     186         [ #  # ]:          0 :       ce->print_debug_info(new_prefix, true);
     187 [ #  # ][ #  # ]:          0 :     else if( CompositeSurface* cs = dynamic_cast<CompositeSurface*>(*iter) )
                 [ #  # ]
     188         [ #  # ]:          0 :       cs->print_debug_info(new_prefix, true);
     189                 :            :     else
     190                 :            : #ifdef TOPOLOGY_BRIDGE_IDS
     191                 :            :       PRINT_INFO("%s%s %d\n", new_prefix, fix_type_name(typeid(*(*iter)).name()), (*iter)->get_id() );
     192                 :            : #else
     193 [ #  # ][ #  # ]:          0 :       PRINT_INFO("%s%s %p\n", new_prefix, fix_type_name(typeid(*(*iter)).name()), (void*)(*iter) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     194                 :            : #endif
     195                 :            :   }
     196         [ #  # ]:          0 :   delete [] new_prefix;
     197                 :          0 : }
     198                 :            : 
     199                 :          0 : void HiddenEntitySet::notify_reversed( TopologyBridge* )
     200 [ +  - ][ +  - ]:       6364 :   {} 

Generated by: LCOV version 1.11