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