cgma
CompositeShell.cpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : CompositeShell.cpp
00003 //
00004 // Purpose       : ShellSM used in composite TopologyBridge graph
00005 //
00006 // Special Notes : 
00007 //
00008 // Creator       : Jason Kraftcheck
00009 //
00010 // Creation Date : 01/11/02
00011 //-------------------------------------------------------------------------
00012 
00013 #include "CompositeShell.hpp"
00014 #include "CompositeCoSurf.hpp"
00015 #include "CompositeSurface.hpp"
00016 #include "VirtualQueryEngine.hpp"
00017 #include "CompositeLump.hpp"
00018 
00019 CompositeShell::CompositeShell()
00020   : myLump(0), lumpNext(0), firstCoSurf(0)
00021 {
00022 }
00023 
00024 CompositeShell::~CompositeShell()
00025 {
00026 //  if( myLump ) 
00027 //    myLump->remove( this );
00028   
00029   while( firstCoSurf )
00030   {
00031     CompositeCoSurf* cosurf = firstCoSurf;
00032     remove( cosurf );
00033     if( cosurf->get_surface() )
00034       cosurf->get_surface()->remove( cosurf );
00035     delete cosurf;
00036   }
00037   
00038   assert( !myLump );
00039 }
00040 
00041 CompositeCoSurf* CompositeShell::next_co_surf( CompositeCoSurf* prev ) const
00042 { 
00043   if (0 == prev)
00044     return firstCoSurf;
00045   else if (this == prev->myShell)
00046     return prev->shellNext;
00047   else
00048     return 0;
00049 }
00050 
00051 CubitStatus CompositeShell::add( CompositeCoSurf* cosurf )
00052 {
00053   if( cosurf->myShell )
00054     return CUBIT_FAILURE;
00055   
00056   cosurf->shellNext = firstCoSurf;
00057   firstCoSurf = cosurf;
00058   cosurf->myShell = this;
00059 
00060   return CUBIT_SUCCESS;
00061 }
00062 
00063 CubitStatus CompositeShell::remove( CompositeCoSurf* cosurf )
00064 {
00065   if( cosurf->myShell != this )
00066     return CUBIT_FAILURE;
00067   
00068   if( firstCoSurf == cosurf )
00069     firstCoSurf = cosurf->shellNext;
00070   else 
00071   {
00072     CompositeCoSurf* prev = firstCoSurf;
00073     while( prev && prev->shellNext != cosurf )
00074       prev = prev->shellNext;
00075     assert( prev != 0 );
00076     prev->shellNext = cosurf->shellNext;
00077   }
00078   
00079   cosurf->myShell = 0;
00080   cosurf->shellNext = 0;
00081   return CUBIT_SUCCESS;
00082 }
00083 
00084 
00085 CompositeCoSurf* CompositeShell::add( CompositeSurface* surface,
00086                                       CubitSense sense )
00087 {
00088   CompositeCoSurf* cosurf = new CompositeCoSurf( sense );
00089   if( !surface->add( cosurf ) || !add( cosurf ) )
00090   {
00091     delete cosurf;
00092     cosurf = 0;
00093   }
00094   return cosurf;
00095 }
00096 
00097 CompositeCoSurf* CompositeShell::find_first( const CompositeSurface* surf ) const
00098 {
00099   CompositeCoSurf* cosurf = firstCoSurf;
00100   while( cosurf && cosurf->get_surface() != surf )
00101     cosurf = cosurf->shellNext;
00102   return cosurf;
00103 }
00104 
00105 CompositeCoSurf* CompositeShell::find_next( const CompositeCoSurf* prev ) const
00106 {
00107   CompositeCoSurf* cosurf = prev->shellNext;
00108   while( cosurf && cosurf->get_surface() != prev->get_surface() )
00109     cosurf = cosurf->shellNext;
00110   return cosurf;
00111 }
00112 
00113 CubitSense CompositeShell::find_sense( const CompositeSurface* surf ) const
00114 {
00115   CompositeCoSurf* first = find_first( surf );
00116   if( !first )
00117     return CUBIT_UNKNOWN;
00118   
00119   CompositeCoSurf* next = first;
00120   while( (next = find_next( next )) )
00121     if( next->sense() != first->sense() )
00122       return CUBIT_UNKNOWN;
00123   
00124   return first->sense();
00125 }
00126 
00127 
00128   
00129   
00130 
00131 
00132 void CompositeShell::get_parents_virt( DLIList<TopologyBridge*>& parents )
00133   { if( myLump ) parents.append( static_cast<TopologyBridge*>(myLump) ); }
00134 
00135 void CompositeShell::get_children_virt( DLIList<TopologyBridge*>& children )
00136 { 
00137   for( CompositeCoSurf* c = firstCoSurf; c; c = c->next_in_shell() )
00138     children.append( c->get_surface() );
00139 }
00140 
00141 
00142 
00143 //-------------------------------------------------------------------------
00144 // Purpose       : Get CompositeEngine
00145 //
00146 // Special Notes : 
00147 //
00148 // Creator       : Jason Kraftcheck
00149 //
00150 // Creation Date : 01/11/02
00151 //-------------------------------------------------------------------------
00152 GeometryQueryEngine* CompositeShell::get_geometry_query_engine() const
00153   { return VirtualQueryEngine::instance(); }
00154 
00155 
00156 //-------------------------------------------------------------------------
00157 // Purpose       : Attribute functions
00158 //
00159 // Special Notes : 
00160 //
00161 // Creator       : Jason Kraftcheck
00162 //
00163 // Creation Date : 01/11/02
00164 //-------------------------------------------------------------------------
00165 void CompositeShell::append_simple_attribute_virt( const CubitSimpleAttrib& )
00166 { }
00167 void CompositeShell::remove_simple_attribute_virt( const CubitSimpleAttrib& )
00168 { }
00169 void CompositeShell::remove_all_simple_attribute_virt()
00170 { }
00171 CubitStatus CompositeShell::get_simple_attribute( DLIList<CubitSimpleAttrib>& )
00172 { return CUBIT_FAILURE; }
00173 CubitStatus CompositeShell::get_simple_attribute(
00174           const CubitString& , DLIList<CubitSimpleAttrib>&  )
00175 { return CUBIT_FAILURE; }
00176 
00177 
00178 //-------------------------------------------------------------------------
00179 // Purpose       : Debug output
00180 //
00181 // Special Notes : 
00182 //
00183 // Creator       : Jason Kraftcheck
00184 //
00185 // Creation Date : 09/16/04
00186 //-------------------------------------------------------------------------
00187 void CompositeShell::print_debug_info( const char* prefix )
00188 {
00189   if( prefix == 0 ) prefix = "";
00190   PRINT_INFO("%sCompositeShell @ %p : \n", prefix, (void*)this );
00191     
00192   char* new_prefix = new char[strlen(prefix)+3];
00193   strcpy( new_prefix, prefix );
00194   strcat( new_prefix, "  " );
00195   
00196   CompositeCoSurf* cosurf = first_co_surf();
00197   if( !cosurf )
00198     PRINT_INFO("%sNo Surfaces!!\n", prefix);
00199   else for (; cosurf; cosurf = next_co_surf( cosurf ))
00200     cosurf->print_debug_info( new_prefix );
00201   
00202   delete [] new_prefix;
00203 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines