cgma
CompositeLoop.cpp
Go to the documentation of this file.
00001 #include "CompositeLoop.hpp"
00002 #include "DLIList.hpp"
00003 
00004 #include "CompositeSurface.hpp"
00005 #include "CompositeCoEdge.hpp"
00006 #include "VirtualQueryEngine.hpp"
00007 
00008 //-------------------------------------------------------------------------
00009 // Purpose       : Constructor
00010 //
00011 // Special Notes : 
00012 //
00013 // Creator       : Jason Kraftcheck
00014 //
00015 // Creation Date : 01/11/02
00016 //-------------------------------------------------------------------------
00017 CompositeLoop::CompositeLoop()
00018   : mySurface(0), myCoedge(0), loopNext(0), numCoedges(0)
00019 {
00020 }
00021 
00022 //-------------------------------------------------------------------------
00023 // Purpose       : Destructor
00024 //
00025 // Special Notes : 
00026 //
00027 // Creator       : Jason Kraftcheck
00028 //
00029 // Creation Date : 01/11/02
00030 //-------------------------------------------------------------------------
00031 CompositeLoop::~CompositeLoop()
00032 {
00033   if( mySurface )
00034   {
00035     mySurface->remove( this );
00036     mySurface = 0;
00037   }
00038     
00039   CubitStatus s = remove_all_coedges();
00040   assert( s );
00041   if (CUBIT_SUCCESS != s) {
00042     PRINT_ERROR("Failed to remove all coedges.\n");
00043   }
00044 }
00045 
00046 //-------------------------------------------------------------------------
00047 // Purpose       : insert a child coedge
00048 //
00049 // Special Notes : 
00050 //
00051 // Creator       : Jason Kraftcheck
00052 //
00053 // Creation Date : 03/23/02
00054 //-------------------------------------------------------------------------
00055 CubitStatus CompositeLoop::insert_after( CompositeCoEdge* insert,
00056                                          CompositeCoEdge* after )
00057 {
00058   if( insert->myLoop != 0 )
00059     return CUBIT_FAILURE;
00060   
00061   if( numCoedges == 0 )
00062   {
00063     if( after )
00064       return CUBIT_FAILURE;
00065     
00066     insert->nextCoedge = insert;
00067     insert->prevCoedge = insert;
00068     myCoedge = insert;
00069   }
00070   else
00071   {
00072     if( !after || after->myLoop != this )
00073       return CUBIT_FAILURE;
00074     
00075     insert->prevCoedge = after;
00076     insert->nextCoedge = after->nextCoedge;
00077     insert->nextCoedge->prevCoedge = insert;
00078     insert->prevCoedge->nextCoedge = insert;
00079   }
00080   
00081   insert->myLoop = this;
00082   numCoedges++;
00083   return CUBIT_SUCCESS;
00084 }
00085 CubitStatus CompositeLoop::insert_before( CompositeCoEdge* insert,
00086                                           CompositeCoEdge* before )
00087 {
00088   if( insert->myLoop != 0 )
00089     return CUBIT_FAILURE;
00090   
00091   if( numCoedges == 0 )
00092   {
00093     if( before ) 
00094       return CUBIT_FAILURE;
00095     
00096     insert->nextCoedge = insert;
00097     insert->prevCoedge = insert;
00098     myCoedge = insert;
00099   }
00100   else
00101   {
00102     if( !before || before->myLoop != this )
00103       return CUBIT_FAILURE;
00104     
00105     insert->nextCoedge = before;
00106     insert->prevCoedge = before->prevCoedge;
00107     insert->nextCoedge->prevCoedge = insert;
00108     insert->prevCoedge->nextCoedge = insert;
00109   }
00110   
00111   insert->myLoop = this;
00112   numCoedges++;
00113   return CUBIT_SUCCESS;
00114 }
00115 
00116 //-------------------------------------------------------------------------
00117 // Purpose       : remove a child coedge
00118 //
00119 // Special Notes : 
00120 //
00121 // Creator       : Jason Kraftcheck
00122 //
00123 // Creation Date : 03/23/02
00124 //-------------------------------------------------------------------------
00125 CubitStatus CompositeLoop::remove( CompositeCoEdge* coedge )
00126 {
00127   if( coedge->myLoop != this )
00128     return CUBIT_FAILURE;
00129   
00130   if( numCoedges == 1 )
00131   {
00132     assert( coedge->nextCoedge == coedge &&
00133             coedge->prevCoedge == coedge );
00134     myCoedge = 0;
00135   }
00136   else
00137   {
00138     coedge->nextCoedge->prevCoedge = coedge->prevCoedge;
00139     coedge->prevCoedge->nextCoedge = coedge->nextCoedge;
00140     if( myCoedge == coedge )
00141       myCoedge = coedge->nextCoedge;
00142   }
00143   
00144   numCoedges--;
00145   coedge->myLoop = 0;
00146   coedge->nextCoedge = 0;
00147   coedge->prevCoedge = 0;
00148   
00149   return CUBIT_SUCCESS;
00150 }
00151 
00152 
00153 
00154 
00155 //-------------------------------------------------------------------------
00156 // Purpose       : remove (and return) all coedges
00157 //
00158 // Special Notes : 
00159 //
00160 // Creator       : Jason Kraftcheck
00161 //
00162 // Creation Date : 03/24/02
00163 //-------------------------------------------------------------------------
00164 CubitStatus CompositeLoop::remove_all_coedges( DLIList<CompositeCoEdge*>* list )
00165 {
00166   while( myCoedge )
00167   {
00168     if( list )
00169       list->append( myCoedge );
00170     remove( myCoedge );
00171   }
00172   
00173   return CUBIT_SUCCESS;
00174 }
00175 
00176 //-------------------------------------------------------------------------
00177 // Purpose       : The purpose of this function is to see if a loop is an external
00178 //                  or internal loop of a surface.
00179 //
00180 // Special Notes : 
00181 //
00182 // Creator       : Jonathan Bugman
00183 //
00184 // Creation Date : 9/9/2008
00185 //-------------------------------------------------------------------------
00186 CubitBoolean CompositeLoop::is_external()
00187 {
00188           PRINT_ERROR( "This command is not supported with this engine.\n");
00189           return CUBIT_FAILURE;
00190 }
00191 
00192 LoopType CompositeLoop::loop_type()
00193 {
00194   return LOOP_TYPE_UNKNOWN;
00195 }
00196 
00197 //-------------------------------------------------------------------------
00198 // Purpose       : get parent bridges
00199 //
00200 // Special Notes : pure virtual in TopologyBridge
00201 //
00202 // Creator       : Jason Kraftcheck
00203 //
00204 // Creation Date : 01/11/02
00205 //-------------------------------------------------------------------------
00206 void CompositeLoop::get_parents_virt( DLIList<TopologyBridge*>& parents )
00207   { if( mySurface ) parents.append( mySurface ); }
00208 
00209 
00210 //-------------------------------------------------------------------------
00211 // Purpose       : get child bridges
00212 //
00213 // Special Notes : pure virtual in TopologyBridge
00214 //
00215 // Creator       : Jason Kraftcheck
00216 //
00217 // Creation Date : 01/11/02
00218 //-------------------------------------------------------------------------
00219 void CompositeLoop::get_children_virt( DLIList<TopologyBridge*>& children )
00220 {
00221   CompositeCoEdge* coedge = myCoedge;
00222   
00223   if( coedge ) do
00224   {
00225     children.append( coedge );
00226     coedge = next_coedge( coedge );
00227   } while( coedge != myCoedge );
00228 }
00229 
00230 
00231 //-------------------------------------------------------------------------
00232 // Purpose       : Get CompositeEngine
00233 //
00234 // Special Notes : 
00235 //
00236 // Creator       : Jason Kraftcheck
00237 //
00238 // Creation Date : 01/11/02
00239 //-------------------------------------------------------------------------
00240 GeometryQueryEngine* CompositeLoop::get_geometry_query_engine() const
00241   { return VirtualQueryEngine::instance(); }
00242 
00243 //-------------------------------------------------------------------------
00244 // Purpose       : Attribute functions
00245 //
00246 // Special Notes : 
00247 //
00248 // Creator       : Jason Kraftcheck
00249 //
00250 // Creation Date : 01/11/02
00251 //-------------------------------------------------------------------------
00252 void CompositeLoop::append_simple_attribute_virt( const CubitSimpleAttrib& )
00253 { }
00254 void CompositeLoop::remove_simple_attribute_virt( const CubitSimpleAttrib& )
00255 { }
00256 void CompositeLoop::remove_all_simple_attribute_virt()
00257 { }
00258 CubitStatus CompositeLoop::get_simple_attribute( DLIList<CubitSimpleAttrib>& )
00259 { return CUBIT_FAILURE; }
00260 CubitStatus CompositeLoop::get_simple_attribute(
00261           const CubitString& , DLIList<CubitSimpleAttrib>& )
00262 { return CUBIT_FAILURE; }
00263 
00264   
00265   
00266 //-------------------------------------------------------------------------
00267 // Purpose       : Reverse order and sense of coedges
00268 //
00269 // Special Notes : 
00270 //
00271 // Creator       : Jason Kraftcheck
00272 //
00273 // Creation Date : 03/17/02
00274 //-------------------------------------------------------------------------
00275 void CompositeLoop::reverse(bool b_reverse_coedges)
00276 {
00277   CompositeCoEdge* coedge = myCoedge;
00278   if( coedge ) do
00279   {
00280     CompositeCoEdge* temp = coedge->nextCoedge;
00281     coedge->nextCoedge = coedge->prevCoedge;
00282     coedge->prevCoedge = temp;
00283     if (b_reverse_coedges) coedge->reverse();
00284     coedge = temp;
00285   } while( coedge != myCoedge );
00286 }
00287 
00288 
00289 void CompositeLoop::print_debug_info( const char* line_prefix )
00290 {
00291   if( line_prefix == 0 )
00292     line_prefix = "";
00293     
00294   char* new_prefix = new char[strlen(line_prefix)+3];
00295   strcpy( new_prefix, line_prefix );
00296   strcat( new_prefix, "  " );
00297   
00298   PRINT_INFO("%sCompositeLoop @ %p : \n", line_prefix, (void*)this );
00299   CompositeCoEdge* coedge = first_coedge();
00300   if( !coedge )
00301     PRINT_INFO("%s  No CoEdges!!\n", line_prefix);
00302   else do
00303   {
00304     coedge->print_debug_info( new_prefix );
00305     coedge = next_coedge( coedge );
00306   } while( coedge != first_coedge() );
00307   
00308   delete [] new_prefix;
00309 }
00310 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines