| 1 | //------------------------------------------------------------------------- |
|---|
| 2 | // Filename : CompositeCoEdge.cpp |
|---|
| 3 | // |
|---|
| 4 | // Purpose : Combined set of CoEdgeSMs |
|---|
| 5 | // |
|---|
| 6 | // Special Notes : |
|---|
| 7 | // |
|---|
| 8 | // Creator : Jason Kraftcheck |
|---|
| 9 | // |
|---|
| 10 | // Creation Date : 01/11/02 |
|---|
| 11 | //------------------------------------------------------------------------- |
|---|
| 12 | |
|---|
| 13 | #include "CompositeCoEdge.hpp" |
|---|
| 14 | #include "CompositeCurve.hpp" |
|---|
| 15 | #include "CompositeLoop.hpp" |
|---|
| 16 | #include "CompositeEngine.hpp" |
|---|
| 17 | #include "VirtualQueryEngine.hpp" |
|---|
| 18 | |
|---|
| 19 | // for printing debug info |
|---|
| 20 | #include "RefEdge.hpp" |
|---|
| 21 | |
|---|
| 22 | //------------------------------------------------------------------------- |
|---|
| 23 | // Purpose : Constructor |
|---|
| 24 | // |
|---|
| 25 | // Special Notes : |
|---|
| 26 | // |
|---|
| 27 | // Creator : Jason Kraftcheck |
|---|
| 28 | // |
|---|
| 29 | // Creation Date : 01/11/02 |
|---|
| 30 | //------------------------------------------------------------------------- |
|---|
| 31 | CompositeCoEdge::CompositeCoEdge( CoEdgeSM* coedge ) |
|---|
| 32 | : myLoop(0), |
|---|
| 33 | nextCoedge(0), |
|---|
| 34 | prevCoedge(0), |
|---|
| 35 | myCurve(0), |
|---|
| 36 | nextOnCurve(0) |
|---|
| 37 | { |
|---|
| 38 | mySense = coedge->sense(); |
|---|
| 39 | coedgeSet.push( coedge ); |
|---|
| 40 | if( coedge->owner() ) |
|---|
| 41 | coedge->owner()->swap_bridge( coedge, this, false ); |
|---|
| 42 | coedge->owner(this); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | CompositeCoEdge::CompositeCoEdge( CompositeCurve* point_curve ) |
|---|
| 46 | : mySense(CUBIT_FORWARD), |
|---|
| 47 | myLoop(0), |
|---|
| 48 | nextCoedge(0), |
|---|
| 49 | prevCoedge(0), |
|---|
| 50 | myCurve(0), |
|---|
| 51 | nextOnCurve(0) |
|---|
| 52 | { |
|---|
| 53 | assert(point_curve->num_curves() == 0); |
|---|
| 54 | CubitStatus stat = point_curve->add(this); |
|---|
| 55 | assert(stat); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | CompositeCoEdge::CompositeCoEdge() |
|---|
| 59 | : mySense(CUBIT_UNKNOWN), |
|---|
| 60 | myLoop(0), |
|---|
| 61 | nextCoedge( 0 ), |
|---|
| 62 | prevCoedge( 0 ), |
|---|
| 63 | myCurve(0), |
|---|
| 64 | nextOnCurve(0) |
|---|
| 65 | {} |
|---|
| 66 | |
|---|
| 67 | //------------------------------------------------------------------------- |
|---|
| 68 | // Purpose : Destructor |
|---|
| 69 | // |
|---|
| 70 | // Special Notes : |
|---|
| 71 | // |
|---|
| 72 | // Creator : Jason Kraftcheck |
|---|
| 73 | // |
|---|
| 74 | // Creation Date : 01/11/02 |
|---|
| 75 | //------------------------------------------------------------------------- |
|---|
| 76 | CompositeCoEdge::~CompositeCoEdge() |
|---|
| 77 | { |
|---|
| 78 | if( myLoop ) |
|---|
| 79 | myLoop->remove(this); |
|---|
| 80 | if( myCurve ) |
|---|
| 81 | myCurve->remove(this); |
|---|
| 82 | |
|---|
| 83 | assert( !prevCoedge && !nextCoedge && !nextOnCurve ); |
|---|
| 84 | |
|---|
| 85 | for( int i = 0; i < coedgeSet.size(); i++ ) |
|---|
| 86 | if( coedgeSet[i]->owner() == this ) |
|---|
| 87 | coedgeSet[i]->owner(0); |
|---|
| 88 | } |
|---|
| 89 | /* |
|---|
| 90 | //------------------------------------------------------------------------- |
|---|
| 91 | // Purpose : Add an underlying coedge |
|---|
| 92 | // |
|---|
| 93 | // Special Notes : |
|---|
| 94 | // |
|---|
| 95 | // Creator : Jason Kraftcheck |
|---|
| 96 | // |
|---|
| 97 | // Creation Date : 01/11/02 |
|---|
| 98 | //------------------------------------------------------------------------- |
|---|
| 99 | CubitStatus CompositeCoEdge::append( CoEdgeSM* coedge_ptr ) |
|---|
| 100 | { |
|---|
| 101 | if( index_of( coedge_ptr ) >= 0 || coedge_ptr->owner() ) |
|---|
| 102 | return CUBIT_FAILURE; |
|---|
| 103 | |
|---|
| 104 | coedge_ptr->owner( this ); |
|---|
| 105 | coedgeSet.push( coedge_ptr ); |
|---|
| 106 | |
|---|
| 107 | return CUBIT_SUCCESS; |
|---|
| 108 | } |
|---|
| 109 | */ |
|---|
| 110 | |
|---|
| 111 | //------------------------------------------------------------------------- |
|---|
| 112 | // Purpose : find the index of the coedge that owns the passed curve |
|---|
| 113 | // |
|---|
| 114 | // Special Notes : returns -1 if not found |
|---|
| 115 | // |
|---|
| 116 | // Creator : Jason Kraftcheck |
|---|
| 117 | // |
|---|
| 118 | // Creation Date : 01/11/02 |
|---|
| 119 | //------------------------------------------------------------------------- |
|---|
| 120 | int CompositeCoEdge::index_of( Curve* ptr ) const |
|---|
| 121 | { |
|---|
| 122 | int i; |
|---|
| 123 | DLIList<TopologyBridge*> curve_list; |
|---|
| 124 | TopologyBridge* curve = ptr; |
|---|
| 125 | for( i = coedgeSet.size() - 1; i > 0; i-- ) |
|---|
| 126 | { |
|---|
| 127 | curve_list.clean_out(); |
|---|
| 128 | coedgeSet[i]->get_children( curve_list ); |
|---|
| 129 | if( curve_list.is_in_list( curve ) ) |
|---|
| 130 | break; |
|---|
| 131 | } |
|---|
| 132 | return i; |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | //------------------------------------------------------------------------- |
|---|
| 136 | // Purpose : Split this CompositeCoEdge into two at the specified index |
|---|
| 137 | // |
|---|
| 138 | // Special Notes : new/other gets CoEdge at the passed index |
|---|
| 139 | // |
|---|
| 140 | // Creator : Jason Kraftcheck |
|---|
| 141 | // |
|---|
| 142 | // Creation Date : 01/11/02 |
|---|
| 143 | //------------------------------------------------------------------------- |
|---|
| 144 | CompositeCoEdge* CompositeCoEdge::split( int index ) |
|---|
| 145 | { |
|---|
| 146 | if( index < 0 || index >= coedgeSet.size() ) |
|---|
| 147 | return 0; |
|---|
| 148 | |
|---|
| 149 | ++index; |
|---|
| 150 | CompositeCoEdge* new_cce = new CompositeCoEdge(); |
|---|
| 151 | new_cce->mySense = mySense; |
|---|
| 152 | |
|---|
| 153 | int new_cce_count = coedgeSet.size() - index; |
|---|
| 154 | new_cce->coedgeSet.size( new_cce_count ); |
|---|
| 155 | |
|---|
| 156 | for( int i = 0; i < new_cce_count; i++ ) |
|---|
| 157 | { |
|---|
| 158 | new_cce->coedgeSet[i] = coedgeSet[i+index]; |
|---|
| 159 | new_cce->coedgeSet[i]->owner( new_cce ); |
|---|
| 160 | } |
|---|
| 161 | coedgeSet.size( index ); |
|---|
| 162 | |
|---|
| 163 | if( myLoop ) |
|---|
| 164 | { |
|---|
| 165 | CubitStatus s; |
|---|
| 166 | if( mySense == CUBIT_FORWARD ) |
|---|
| 167 | s = myLoop->insert_after( new_cce, this ); |
|---|
| 168 | else |
|---|
| 169 | s = myLoop->insert_before( new_cce, this ); |
|---|
| 170 | assert( s ); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | new_cce->mySense = mySense; |
|---|
| 174 | |
|---|
| 175 | return new_cce; |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | CubitStatus CompositeCoEdge::combine( CompositeCoEdge* dead, bool prepend ) |
|---|
| 179 | { |
|---|
| 180 | int insert; |
|---|
| 181 | if ( prepend ) |
|---|
| 182 | { |
|---|
| 183 | insert = 0; |
|---|
| 184 | coedgeSet.size_end( coedgeSet.size() + dead->coedgeSet.size() ); |
|---|
| 185 | } |
|---|
| 186 | else |
|---|
| 187 | { |
|---|
| 188 | insert = coedgeSet.size(); |
|---|
| 189 | coedgeSet.size( coedgeSet.size() + dead->coedgeSet.size() ); |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | for( int i = 0; i < dead->coedgeSet.size(); i++ ) |
|---|
| 193 | { |
|---|
| 194 | CoEdgeSM* coedge = dead->coedgeSet[i]; |
|---|
| 195 | assert( coedge->owner() == dead ); |
|---|
| 196 | coedge->owner(this); |
|---|
| 197 | coedgeSet[insert++] = coedge; |
|---|
| 198 | } |
|---|
| 199 | dead->coedgeSet.size(0); |
|---|
| 200 | return CUBIT_SUCCESS; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | /* |
|---|
| 204 | //------------------------------------------------------------------------- |
|---|
| 205 | // Purpose : dequeue underlying coedge |
|---|
| 206 | // |
|---|
| 207 | // Special Notes : |
|---|
| 208 | // |
|---|
| 209 | // Creator : Jason Kraftcheck |
|---|
| 210 | // |
|---|
| 211 | // Creation Date : 01/11/02 |
|---|
| 212 | //------------------------------------------------------------------------- |
|---|
| 213 | CoEdgeSM* CompositeCoEdge::remove_first() |
|---|
| 214 | { |
|---|
| 215 | CoEdgeSM* result = 0; |
|---|
| 216 | if( coedgeSet.size() > 0 ) |
|---|
| 217 | { |
|---|
| 218 | result = coedgeSet[0]; |
|---|
| 219 | coedgeSet.remove(0); |
|---|
| 220 | } |
|---|
| 221 | return result; |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | //------------------------------------------------------------------------- |
|---|
| 225 | // Purpose : pop underlying coedge |
|---|
| 226 | // |
|---|
| 227 | // Special Notes : |
|---|
| 228 | // |
|---|
| 229 | // Creator : Jason Kraftcheck |
|---|
| 230 | // |
|---|
| 231 | // Creation Date : 01/11/02 |
|---|
| 232 | //------------------------------------------------------------------------- |
|---|
| 233 | CoEdgeSM* CompositeCoEdge::remove_last() |
|---|
| 234 | { |
|---|
| 235 | CoEdgeSM* result = 0; |
|---|
| 236 | if( coedgeSet.size() > 0 ) |
|---|
| 237 | { |
|---|
| 238 | result = coedgeSet.pop() |
|---|
| 239 | result->owner(0); |
|---|
| 240 | } |
|---|
| 241 | return result; |
|---|
| 242 | } |
|---|
| 243 | */ |
|---|
| 244 | //------------------------------------------------------------------------- |
|---|
| 245 | // Purpose : get parents (pure virtual in TopologyBridge) |
|---|
| 246 | // |
|---|
| 247 | // Special Notes : |
|---|
| 248 | // |
|---|
| 249 | // Creator : Jason Kraftcheck |
|---|
| 250 | // |
|---|
| 251 | // Creation Date : 01/11/02 |
|---|
| 252 | //------------------------------------------------------------------------- |
|---|
| 253 | void CompositeCoEdge::get_parents_virt( DLIList<TopologyBridge*>& parents ) |
|---|
| 254 | { |
|---|
| 255 | LoopSM* result = get_parent_loop(); |
|---|
| 256 | if( result ) |
|---|
| 257 | { |
|---|
| 258 | parents.append( result ); |
|---|
| 259 | } |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | //------------------------------------------------------------------------- |
|---|
| 263 | // Purpose : get children (pure virtual in TopologyBridge) |
|---|
| 264 | // |
|---|
| 265 | // Special Notes : |
|---|
| 266 | // |
|---|
| 267 | // Creator : Jason Kraftcheck |
|---|
| 268 | // |
|---|
| 269 | // Creation Date : 01/11/02 |
|---|
| 270 | //------------------------------------------------------------------------- |
|---|
| 271 | void CompositeCoEdge::get_children_virt( DLIList<TopologyBridge*>& children ) |
|---|
| 272 | { |
|---|
| 273 | if( myCurve ) |
|---|
| 274 | { |
|---|
| 275 | children.append( myCurve->primary_stitched_curve() ); |
|---|
| 276 | } |
|---|
| 277 | /* |
|---|
| 278 | else if( num_coedges() ) |
|---|
| 279 | { |
|---|
| 280 | DLIList<TopologyBridge*> coedge_children; |
|---|
| 281 | coedge(0)->get_children( coedge_children ); |
|---|
| 282 | assert( coedge_children.size() == 1 ); |
|---|
| 283 | children.append( coedge_children.get() ); |
|---|
| 284 | } |
|---|
| 285 | */ |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | /* |
|---|
| 289 | //------------------------------------------------------------------------- |
|---|
| 290 | // Purpose : Set child curve |
|---|
| 291 | // |
|---|
| 292 | // Special Notes : If curve is composite, update curve link to this |
|---|
| 293 | // |
|---|
| 294 | // Creator : Jason Kraftcheck |
|---|
| 295 | // |
|---|
| 296 | // Creation Date : 01/11/02 |
|---|
| 297 | //------------------------------------------------------------------------- |
|---|
| 298 | void CompositeCoEdge::curve( CompositeCurve* curve_ptr ) |
|---|
| 299 | { |
|---|
| 300 | if( myCurve ) |
|---|
| 301 | { |
|---|
| 302 | myCurve->remove(this); |
|---|
| 303 | assert( !myCurve ); |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | if( curve_ptr ) |
|---|
| 307 | { |
|---|
| 308 | curve_ptr->add(this); |
|---|
| 309 | assert( myCurve == curve_ptr ); |
|---|
| 310 | } |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | //------------------------------------------------------------------------- |
|---|
| 314 | // Purpose : set loop pointer |
|---|
| 315 | // |
|---|
| 316 | // Special Notes : if loop is composite, add this to loop instead |
|---|
| 317 | // |
|---|
| 318 | // Creator : Jason Kraftcheck |
|---|
| 319 | // |
|---|
| 320 | // Creation Date : 01/11/02 |
|---|
| 321 | //------------------------------------------------------------------------- |
|---|
| 322 | void CompositeCoEdge::loop( CompositeLoop* loop_ptr ) |
|---|
| 323 | { |
|---|
| 324 | if( myLoop ) |
|---|
| 325 | myLoop->remove( this ); |
|---|
| 326 | |
|---|
| 327 | if( loop_ptr ) |
|---|
| 328 | loop_ptr->insert_before( loop_ptr->first_coedge(), this ); |
|---|
| 329 | |
|---|
| 330 | myLoop = loop_ptr; |
|---|
| 331 | } |
|---|
| 332 | */ |
|---|
| 333 | //------------------------------------------------------------------------- |
|---|
| 334 | // Purpose : Get parent loop no higher than composite level |
|---|
| 335 | // |
|---|
| 336 | // Special Notes : |
|---|
| 337 | // |
|---|
| 338 | // Creator : Jason Kraftcheck |
|---|
| 339 | // |
|---|
| 340 | // Creation Date : 03/05/02 |
|---|
| 341 | //------------------------------------------------------------------------- |
|---|
| 342 | LoopSM* CompositeCoEdge::get_parent_loop() |
|---|
| 343 | { |
|---|
| 344 | LoopSM* result = get_loop(); |
|---|
| 345 | |
|---|
| 346 | if( !result && num_coedges() ) |
|---|
| 347 | { |
|---|
| 348 | DLIList<TopologyBridge*> parents(1); |
|---|
| 349 | get_coedge(0)->get_parents_virt( parents ); |
|---|
| 350 | assert( parents.size() == 1 ); |
|---|
| 351 | result = dynamic_cast<LoopSM*>(parents.get()); |
|---|
| 352 | } |
|---|
| 353 | |
|---|
| 354 | return result; |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | //------------------------------------------------------------------------- |
|---|
| 358 | // Purpose : remove an underlying bridge |
|---|
| 359 | // |
|---|
| 360 | // Special Notes : pure virtual in TBOwner |
|---|
| 361 | // |
|---|
| 362 | // Creator : Jason Kraftcheck |
|---|
| 363 | // |
|---|
| 364 | // Creation Date : 01/11/02 |
|---|
| 365 | //------------------------------------------------------------------------- |
|---|
| 366 | CubitStatus CompositeCoEdge::remove_bridge( TopologyBridge* bridge ) |
|---|
| 367 | { |
|---|
| 368 | int index; |
|---|
| 369 | for( index = coedgeSet.size() - 1; index >= 0; index-- ) |
|---|
| 370 | if( coedgeSet[index] == bridge ) |
|---|
| 371 | break; |
|---|
| 372 | if( index < 0 ) |
|---|
| 373 | return CUBIT_FAILURE; |
|---|
| 374 | |
|---|
| 375 | coedgeSet.remove( index ); |
|---|
| 376 | bridge->owner(0); |
|---|
| 377 | /* |
|---|
| 378 | if ( coedgeSet.size() > 0 ) |
|---|
| 379 | return CUBIT_SUCCESS; |
|---|
| 380 | |
|---|
| 381 | if ( get_curve() ) |
|---|
| 382 | get_curve()->remove(this); |
|---|
| 383 | |
|---|
| 384 | if ( get_loop() ) |
|---|
| 385 | { |
|---|
| 386 | CompositeLoop* loop = get_loop(); |
|---|
| 387 | loop->remove(this); |
|---|
| 388 | if ( loop->first_coedge() == 0 ) |
|---|
| 389 | delete loop; |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | delete this; |
|---|
| 393 | */ |
|---|
| 394 | return CUBIT_SUCCESS; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | //------------------------------------------------------------------------- |
|---|
| 398 | // Purpose : exchange one underlying coedge for another |
|---|
| 399 | // |
|---|
| 400 | // Special Notes : pure virtual in TBOwner |
|---|
| 401 | // |
|---|
| 402 | // Creator : Jason Kraftcheck |
|---|
| 403 | // |
|---|
| 404 | // Creation Date : 01/11/02 |
|---|
| 405 | //------------------------------------------------------------------------- |
|---|
| 406 | CubitStatus CompositeCoEdge::swap_bridge( TopologyBridge* old_tb, |
|---|
| 407 | TopologyBridge* new_tb, |
|---|
| 408 | bool ) |
|---|
| 409 | { |
|---|
| 410 | CoEdgeSM* old_coedge = dynamic_cast<CoEdgeSM*>(old_tb); |
|---|
| 411 | CoEdgeSM* new_coedge = dynamic_cast<CoEdgeSM*>(new_tb); |
|---|
| 412 | |
|---|
| 413 | int index = index_of( old_coedge ); |
|---|
| 414 | if( index < 0 || !new_coedge || index_of(new_coedge) >= 0 ) |
|---|
| 415 | return CUBIT_FAILURE; |
|---|
| 416 | |
|---|
| 417 | coedgeSet[index] = new_coedge; |
|---|
| 418 | |
|---|
| 419 | old_tb->owner(0); |
|---|
| 420 | if( new_tb->owner() ) |
|---|
| 421 | new_tb->owner()->remove_bridge( new_tb ); |
|---|
| 422 | new_tb->owner(this); |
|---|
| 423 | |
|---|
| 424 | return CUBIT_SUCCESS; |
|---|
| 425 | } |
|---|
| 426 | |
|---|
| 427 | //------------------------------------------------------------------------- |
|---|
| 428 | // Purpose : see if we are the owner of the passed TB |
|---|
| 429 | // |
|---|
| 430 | // Special Notes : pure virtual in TBOwner |
|---|
| 431 | // |
|---|
| 432 | // Creator : Jason Kraftcheck |
|---|
| 433 | // |
|---|
| 434 | // Creation Date : 01/11/02 |
|---|
| 435 | //------------------------------------------------------------------------- |
|---|
| 436 | CubitBoolean CompositeCoEdge::contains_bridge( TopologyBridge* bridge ) const |
|---|
| 437 | { |
|---|
| 438 | CompositeCoEdge* coedge = dynamic_cast<CompositeCoEdge*>(bridge); |
|---|
| 439 | return (index_of(coedge) < 0) ? CUBIT_FALSE : CUBIT_TRUE; |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | void CompositeCoEdge::notify_reversed( TopologyBridge* ) |
|---|
| 443 | {} |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 446 | //------------------------------------------------------------------------- |
|---|
| 447 | // Purpose : Get CompositeEngine |
|---|
| 448 | // |
|---|
| 449 | // Special Notes : |
|---|
| 450 | // |
|---|
| 451 | // Creator : Jason Kraftcheck |
|---|
| 452 | // |
|---|
| 453 | // Creation Date : 01/11/02 |
|---|
| 454 | //------------------------------------------------------------------------- |
|---|
| 455 | GeometryQueryEngine* CompositeCoEdge::get_geometry_query_engine() const |
|---|
| 456 | { return VirtualQueryEngine::instance(); } |
|---|
| 457 | |
|---|
| 458 | //------------------------------------------------------------------------- |
|---|
| 459 | // Purpose : Attribute functions |
|---|
| 460 | // |
|---|
| 461 | // Special Notes : |
|---|
| 462 | // |
|---|
| 463 | // Creator : Jason Kraftcheck |
|---|
| 464 | // |
|---|
| 465 | // Creation Date : 01/11/02 |
|---|
| 466 | //------------------------------------------------------------------------- |
|---|
| 467 | void CompositeCoEdge::append_simple_attribute_virt( CubitSimpleAttrib* ) |
|---|
| 468 | { } |
|---|
| 469 | void CompositeCoEdge::remove_simple_attribute_virt( CubitSimpleAttrib* ) |
|---|
| 470 | { } |
|---|
| 471 | void CompositeCoEdge::remove_all_simple_attribute_virt() |
|---|
| 472 | { } |
|---|
| 473 | CubitStatus CompositeCoEdge::get_simple_attribute( DLIList<CubitSimpleAttrib*>& ) |
|---|
| 474 | { return CUBIT_FAILURE; } |
|---|
| 475 | CubitStatus CompositeCoEdge::get_simple_attribute( const CubitString& , |
|---|
| 476 | DLIList<CubitSimpleAttrib*>& ) |
|---|
| 477 | { return CUBIT_FAILURE; } |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | void CompositeCoEdge::reverse() |
|---|
| 483 | { |
|---|
| 484 | switch( mySense ) { |
|---|
| 485 | case CUBIT_FORWARD: |
|---|
| 486 | mySense = CUBIT_REVERSED; |
|---|
| 487 | break; |
|---|
| 488 | case CUBIT_REVERSED: |
|---|
| 489 | mySense = CUBIT_FORWARD; |
|---|
| 490 | break; |
|---|
| 491 | default: |
|---|
| 492 | mySense = CUBIT_UNKNOWN; |
|---|
| 493 | } |
|---|
| 494 | |
|---|
| 495 | int half = coedgeSet.size() / 2; |
|---|
| 496 | for( int i = 0; i < half; i++ ) |
|---|
| 497 | { |
|---|
| 498 | int j = coedgeSet.size() - i - 1; |
|---|
| 499 | CoEdgeSM* tmp = coedgeSet[i]; |
|---|
| 500 | coedgeSet[i] = coedgeSet[j]; |
|---|
| 501 | coedgeSet[j] = tmp; |
|---|
| 502 | } |
|---|
| 503 | |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | //------------------------------------------------------------------------- |
|---|
| 507 | // Purpose : Get start and end points reversed if sense is reversed |
|---|
| 508 | // |
|---|
| 509 | // Special Notes : |
|---|
| 510 | // |
|---|
| 511 | // Creator : Jason Kraftcheck |
|---|
| 512 | // |
|---|
| 513 | // Creation Date : 03/17/02 |
|---|
| 514 | //------------------------------------------------------------------------- |
|---|
| 515 | CompositePoint* CompositeCoEdge::start_point() |
|---|
| 516 | { |
|---|
| 517 | return mySense == CUBIT_FORWARD |
|---|
| 518 | ? myCurve->start_point() |
|---|
| 519 | : myCurve->end_point(); |
|---|
| 520 | } |
|---|
| 521 | CompositePoint* CompositeCoEdge::end_point() |
|---|
| 522 | { |
|---|
| 523 | return mySense == CUBIT_FORWARD |
|---|
| 524 | ? myCurve->end_point() |
|---|
| 525 | : myCurve->start_point(); |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | CubitStatus CompositeCoEdge::remove_coedge( int index ) |
|---|
| 530 | { |
|---|
| 531 | if( index < 0 || index >= coedgeSet.size() ) |
|---|
| 532 | return CUBIT_FAILURE; |
|---|
| 533 | |
|---|
| 534 | coedgeSet[index]->owner(0); |
|---|
| 535 | coedgeSet.remove( index ); |
|---|
| 536 | |
|---|
| 537 | return CUBIT_SUCCESS; |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | |
|---|
| 541 | CubitStatus CompositeCoEdge::insert_coedge( int index, CoEdgeSM* coedge ) |
|---|
| 542 | { |
|---|
| 543 | if( index < 0 || index > coedgeSet.size() ) |
|---|
| 544 | return CUBIT_FAILURE; |
|---|
| 545 | |
|---|
| 546 | coedgeSet.insert(coedge, index); |
|---|
| 547 | coedge->owner(this); |
|---|
| 548 | return CUBIT_SUCCESS; |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | void CompositeCoEdge::print_debug_info( const char* prefix, bool brief ) |
|---|
| 552 | { |
|---|
| 553 | if( prefix == 0 ) prefix = ""; |
|---|
| 554 | |
|---|
| 555 | const char* sense = mySense == CUBIT_FORWARD ? "Forward" : |
|---|
| 556 | mySense == CUBIT_REVERSED ? "Reverse" : "UNKNOWN"; |
|---|
| 557 | |
|---|
| 558 | PRINT_INFO("%sCompCoEdge %p %s ", prefix, this, sense ); |
|---|
| 559 | if ( num_coedges() == 1 ) |
|---|
| 560 | PRINT_INFO("%s %p ", fix_type_name(typeid(*get_coedge(0)).name()), |
|---|
| 561 | get_coedge(0)); |
|---|
| 562 | else |
|---|
| 563 | PRINT_INFO("%d coedges ", num_coedges() ); |
|---|
| 564 | |
|---|
| 565 | if( !myCurve ) |
|---|
| 566 | PRINT_INFO("NULL CURVE\n"); |
|---|
| 567 | else if( brief ) |
|---|
| 568 | #ifdef TOPOLOGY_BRIDGE_IDS |
|---|
| 569 | PRINT_INFO("curve %d\n", myCurve->get_id() ); |
|---|
| 570 | #else |
|---|
| 571 | PRINT_INFO("curve %p\n", myCurve ); |
|---|
| 572 | #endif |
|---|
| 573 | else |
|---|
| 574 | { PRINT_INFO("\n "); myCurve->print_debug_info(prefix, true); } |
|---|
| 575 | |
|---|
| 576 | /* |
|---|
| 577 | if( coedgeSet.size() == 0 ) |
|---|
| 578 | PRINT_INFO(" No CoEdgeSMs!\n"); |
|---|
| 579 | else if( coedgeSet.size() == 1 ) |
|---|
| 580 | PRINT_INFO(" CoEdgeSM=%p\n", coedgeSet[0] ); |
|---|
| 581 | else |
|---|
| 582 | { |
|---|
| 583 | PRINT_INFO("\n"); |
|---|
| 584 | for( int i = 0; i < coedgeSet.size(); i++ ) |
|---|
| 585 | PRINT_INFO("%s CoEdgeSM[%d] = %p\n", prefix, i, coedgeSet[i] ); |
|---|
| 586 | } |
|---|
| 587 | */ |
|---|
| 588 | } |
|---|