| 1 | ///------------------------------------------------------------------------- |
|---|
| 2 | // Filename : BasicTopologyEntity.cpp |
|---|
| 3 | // |
|---|
| 4 | // Purpose : This file contains the implementation of the class |
|---|
| 5 | // BasicTopologyEntity. |
|---|
| 6 | // |
|---|
| 7 | // Special Notes : |
|---|
| 8 | // |
|---|
| 9 | // Creator : Malcolm J. Panthaki |
|---|
| 10 | // |
|---|
| 11 | // Creation Date : 10/15/96 |
|---|
| 12 | // |
|---|
| 13 | // Owner : Malcolm J. Panthaki |
|---|
| 14 | //------------------------------------------------------------------------- |
|---|
| 15 | |
|---|
| 16 | // ********** BEGIN STANDARD INCLUDES ********** |
|---|
| 17 | // ********** END STANDARD INCLUDES ********** |
|---|
| 18 | |
|---|
| 19 | // ********** BEGIN CUBIT INCLUDES ********** |
|---|
| 20 | #include "CubitDefines.h" |
|---|
| 21 | #include "SenseEntity.hpp" |
|---|
| 22 | #include "BasicTopologyEntity.hpp" |
|---|
| 23 | #include "GroupingEntity.hpp" |
|---|
| 24 | #include "GeometryEntity.hpp" |
|---|
| 25 | #include "DLIList.hpp" |
|---|
| 26 | #include "ModelQueryEngine.hpp" |
|---|
| 27 | // ********** END CUBIT INCLUDES ********** |
|---|
| 28 | |
|---|
| 29 | // ********** BEGIN STATIC DECLARATIONS ********** |
|---|
| 30 | // ********** END STATIC DECLARATIONS ********** |
|---|
| 31 | |
|---|
| 32 | // ********** BEGIN PUBLIC FUNCTIONS ********** |
|---|
| 33 | |
|---|
| 34 | //------------------------------------------------------------------------- |
|---|
| 35 | // Purpose : destructor |
|---|
| 36 | // |
|---|
| 37 | // Special Notes : |
|---|
| 38 | // |
|---|
| 39 | // Creator : Jason Kraftcheck |
|---|
| 40 | // |
|---|
| 41 | // Creation Date : 07/22/03 |
|---|
| 42 | //------------------------------------------------------------------------- |
|---|
| 43 | BasicTopologyEntity::~BasicTopologyEntity() |
|---|
| 44 | { |
|---|
| 45 | while (firstSenseEntity && remove_sense_entity(firstSenseEntity)); |
|---|
| 46 | while (firstGroupingEntity && remove_grouping_entity(firstGroupingEntity)); |
|---|
| 47 | assert(!firstSenseEntity && !firstGroupingEntity); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | //------------------------------------------------------------------------- |
|---|
| 52 | // Purpose : This function gets the list of GroupingEntities of this |
|---|
| 53 | // BasicTopologyEntity. |
|---|
| 54 | // |
|---|
| 55 | // Special Notes : In the DAG, the GroupingEntities associated with the |
|---|
| 56 | // current BasicTopologyEntity are linked from one GroupingEntity |
|---|
| 57 | // to the next in order to maintain the order in |
|---|
| 58 | // which the GroupingEntities were added to the BTE. |
|---|
| 59 | // |
|---|
| 60 | // Complete reimplementation - jk, July 2003 |
|---|
| 61 | // |
|---|
| 62 | // Creator : Malcolm J. Panthaki |
|---|
| 63 | // |
|---|
| 64 | // Creation Date : 07/31/96 |
|---|
| 65 | //------------------------------------------------------------------------- |
|---|
| 66 | CubitStatus BasicTopologyEntity::get_grouping_entity_list( |
|---|
| 67 | DLIList<GroupingEntity*>& list) const |
|---|
| 68 | { |
|---|
| 69 | for (GroupingEntity* ptr = firstGroupingEntity; ptr; ptr = ptr->next()) |
|---|
| 70 | { |
|---|
| 71 | assert(ptr->get_basic_topology_entity_ptr() == this); |
|---|
| 72 | list.append(ptr); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | return CUBIT_SUCCESS; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | //------------------------------------------------------------------------- |
|---|
| 79 | // Purpose : Get the parent SenseEntities |
|---|
| 80 | // |
|---|
| 81 | // Special Notes : |
|---|
| 82 | // |
|---|
| 83 | // Creator : Jason Kraftcheck |
|---|
| 84 | // |
|---|
| 85 | // Creation Date : 06/08/99 |
|---|
| 86 | //------------------------------------------------------------------------- |
|---|
| 87 | CubitStatus BasicTopologyEntity::get_sense_entity_list( |
|---|
| 88 | DLIList<SenseEntity*>& list) const |
|---|
| 89 | { |
|---|
| 90 | for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 91 | { |
|---|
| 92 | assert(ptr->get_basic_topology_entity_ptr() == this); |
|---|
| 93 | list.append(ptr); |
|---|
| 94 | } |
|---|
| 95 | return CUBIT_SUCCESS; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | //------------------------------------------------------------------------- |
|---|
| 99 | // Purpose : Attach a child grouping entity |
|---|
| 100 | // |
|---|
| 101 | // Special Notes : |
|---|
| 102 | // |
|---|
| 103 | // Creator : Jason Kraftcheck |
|---|
| 104 | // |
|---|
| 105 | // Creation Date : 07/22/03 |
|---|
| 106 | //------------------------------------------------------------------------- |
|---|
| 107 | CubitStatus BasicTopologyEntity::add_grouping_entity( GroupingEntity* gpe_ptr) |
|---|
| 108 | { |
|---|
| 109 | if (gpe_ptr->dag_type().parent() != dag_type()) |
|---|
| 110 | return CUBIT_FAILURE; |
|---|
| 111 | |
|---|
| 112 | if (gpe_ptr->get_basic_topology_entity_ptr()) |
|---|
| 113 | return CUBIT_FAILURE; |
|---|
| 114 | |
|---|
| 115 | assert(!gpe_ptr->next()); |
|---|
| 116 | |
|---|
| 117 | if (firstGroupingEntity) |
|---|
| 118 | { |
|---|
| 119 | if (!gpe_ptr->insert_after(lastGroupingEntity)) |
|---|
| 120 | return CUBIT_FAILURE; |
|---|
| 121 | } |
|---|
| 122 | else |
|---|
| 123 | { |
|---|
| 124 | firstGroupingEntity = gpe_ptr; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | lastGroupingEntity = gpe_ptr; |
|---|
| 128 | gpe_ptr->set_basic_topology_entity_ptr(this); |
|---|
| 129 | return CUBIT_SUCCESS; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | //------------------------------------------------------------------------- |
|---|
| 133 | // Purpose : Disconnect child grouping entity |
|---|
| 134 | // |
|---|
| 135 | // Special Notes : |
|---|
| 136 | // |
|---|
| 137 | // Creator : Jason Kraftcheck |
|---|
| 138 | // |
|---|
| 139 | // Creation Date : 07/22/03 |
|---|
| 140 | //------------------------------------------------------------------------- |
|---|
| 141 | CubitStatus BasicTopologyEntity::remove_grouping_entity( GroupingEntity* gpe_ptr) |
|---|
| 142 | { |
|---|
| 143 | if (gpe_ptr->get_basic_topology_entity_ptr() != this) |
|---|
| 144 | return CUBIT_FAILURE; |
|---|
| 145 | |
|---|
| 146 | GroupingEntity* next_gpe_ptr = gpe_ptr->next(); |
|---|
| 147 | GroupingEntity* prev_gpe_ptr = gpe_ptr->previous(); |
|---|
| 148 | |
|---|
| 149 | if (!gpe_ptr->remove_from_list()) |
|---|
| 150 | return CUBIT_FAILURE; |
|---|
| 151 | |
|---|
| 152 | if (firstGroupingEntity == gpe_ptr) |
|---|
| 153 | firstGroupingEntity = next_gpe_ptr; |
|---|
| 154 | if (lastGroupingEntity == gpe_ptr) |
|---|
| 155 | lastGroupingEntity = prev_gpe_ptr; |
|---|
| 156 | |
|---|
| 157 | gpe_ptr->set_basic_topology_entity_ptr(0); |
|---|
| 158 | return CUBIT_SUCCESS; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | //------------------------------------------------------------------------- |
|---|
| 162 | // Purpose : Update list of child grouping entities |
|---|
| 163 | // |
|---|
| 164 | // Special Notes : |
|---|
| 165 | // |
|---|
| 166 | // Creator : Jason Kraftcheck |
|---|
| 167 | // |
|---|
| 168 | // Creation Date : 12/12/03 |
|---|
| 169 | //------------------------------------------------------------------------- |
|---|
| 170 | CubitStatus BasicTopologyEntity::set_grouping_entity_list( |
|---|
| 171 | DLIList<GroupingEntity*>& list, |
|---|
| 172 | DLIList<GroupingEntity*>& removed ) |
|---|
| 173 | { |
|---|
| 174 | int i; |
|---|
| 175 | |
|---|
| 176 | // Remove all? |
|---|
| 177 | if (list.size() == 0) |
|---|
| 178 | { |
|---|
| 179 | get_grouping_entity_list( removed ); |
|---|
| 180 | return disconnect_all_children(); |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | // Check for error conditions before modifying anything |
|---|
| 184 | list.reset(); |
|---|
| 185 | for (i = list.size(); i--; ) |
|---|
| 186 | { |
|---|
| 187 | GroupingEntity* grouping_entity = list.get_and_step(); |
|---|
| 188 | |
|---|
| 189 | // Check to make sure that we are getting the correct type of |
|---|
| 190 | // GroupingEntity. |
|---|
| 191 | if ( dag_type() != grouping_entity->dag_type().parent() ) |
|---|
| 192 | return CUBIT_FAILURE ; |
|---|
| 193 | |
|---|
| 194 | // Check that the grouping entity is not already in some other |
|---|
| 195 | // basic topology entity |
|---|
| 196 | if ( grouping_entity->get_basic_topology_entity_ptr() && |
|---|
| 197 | grouping_entity->get_basic_topology_entity_ptr() != this ) |
|---|
| 198 | return CUBIT_FAILURE; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | // Special case for first entity in list. |
|---|
| 202 | list.reset(); |
|---|
| 203 | GroupingEntity* new_first = list.get_and_step(); |
|---|
| 204 | // No sense entities currently attached... |
|---|
| 205 | if (!firstGroupingEntity) |
|---|
| 206 | { |
|---|
| 207 | firstGroupingEntity = lastGroupingEntity = new_first; |
|---|
| 208 | new_first->set_basic_topology_entity_ptr(this); |
|---|
| 209 | } |
|---|
| 210 | // Already attached, but not first in list... |
|---|
| 211 | else if( firstGroupingEntity != new_first ) |
|---|
| 212 | { |
|---|
| 213 | if (!new_first->get_basic_topology_entity_ptr()) |
|---|
| 214 | new_first->set_basic_topology_entity_ptr(this); |
|---|
| 215 | else |
|---|
| 216 | { |
|---|
| 217 | if (lastGroupingEntity == new_first) |
|---|
| 218 | lastGroupingEntity = new_first->previous(); |
|---|
| 219 | new_first->remove_from_list(); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | new_first->insert_before(firstGroupingEntity); |
|---|
| 223 | firstGroupingEntity = new_first; |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | // Now loop through remaining sense entities. |
|---|
| 227 | GroupingEntity* prev = new_first; |
|---|
| 228 | for (i = list.size() - 1; i--; ) |
|---|
| 229 | { |
|---|
| 230 | GroupingEntity* curr = list.get_and_step(); |
|---|
| 231 | |
|---|
| 232 | // If next grouping entity in input list is not |
|---|
| 233 | // next grouping entity in this BTE... |
|---|
| 234 | if (prev->next() != curr) |
|---|
| 235 | { |
|---|
| 236 | if (!curr->get_basic_topology_entity_ptr()) |
|---|
| 237 | curr->set_basic_topology_entity_ptr(this); |
|---|
| 238 | else |
|---|
| 239 | { |
|---|
| 240 | if (lastGroupingEntity == curr) |
|---|
| 241 | lastGroupingEntity = curr->previous(); |
|---|
| 242 | curr->remove_from_list(); |
|---|
| 243 | } |
|---|
| 244 | curr->insert_after(prev); |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 247 | // update lastSenseEntity if necessary... |
|---|
| 248 | if (lastGroupingEntity == prev) |
|---|
| 249 | lastGroupingEntity = curr; |
|---|
| 250 | |
|---|
| 251 | // iterate |
|---|
| 252 | prev = curr; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | // Disconnect any grouping entities in this BTE |
|---|
| 256 | // that were not in in the input list (they should now |
|---|
| 257 | // be at the end of the list of grouping entities in this) |
|---|
| 258 | // and pass them back in the 'removed' list. |
|---|
| 259 | CubitStatus result = CUBIT_SUCCESS; |
|---|
| 260 | while (prev != lastGroupingEntity) |
|---|
| 261 | { |
|---|
| 262 | removed.append(prev->next()); |
|---|
| 263 | if (!remove_grouping_entity(prev->next())) |
|---|
| 264 | { |
|---|
| 265 | assert(0); |
|---|
| 266 | result = CUBIT_FAILURE; |
|---|
| 267 | prev = prev->next(); |
|---|
| 268 | } |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | return result; |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | |
|---|
| 276 | |
|---|
| 277 | //------------------------------------------------------------------------- |
|---|
| 278 | // Purpose : Attach a parent sense entity |
|---|
| 279 | // |
|---|
| 280 | // Special Notes : |
|---|
| 281 | // |
|---|
| 282 | // Creator : Jason Kraftcheck |
|---|
| 283 | // |
|---|
| 284 | // Creation Date : 07/22/03 |
|---|
| 285 | //------------------------------------------------------------------------- |
|---|
| 286 | CubitStatus BasicTopologyEntity::add_sense_entity( SenseEntity* se_ptr ) |
|---|
| 287 | { |
|---|
| 288 | if (se_ptr->dag_type() != dag_type().parent()) |
|---|
| 289 | return CUBIT_FAILURE; |
|---|
| 290 | |
|---|
| 291 | if (se_ptr->get_basic_topology_entity_ptr()) |
|---|
| 292 | return CUBIT_FAILURE; |
|---|
| 293 | |
|---|
| 294 | assert(!se_ptr->next_on_bte()); |
|---|
| 295 | if (firstSenseEntity) |
|---|
| 296 | { |
|---|
| 297 | assert(!lastSenseEntity->next_on_bte()); |
|---|
| 298 | lastSenseEntity->set_bte_next(se_ptr); |
|---|
| 299 | } |
|---|
| 300 | else |
|---|
| 301 | { |
|---|
| 302 | firstSenseEntity = se_ptr; |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | lastSenseEntity = se_ptr; |
|---|
| 306 | se_ptr->set_basic_topology_entity_ptr(this); |
|---|
| 307 | return CUBIT_SUCCESS; |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | //------------------------------------------------------------------------- |
|---|
| 311 | // Purpose : Disconnect parent sense entity |
|---|
| 312 | // |
|---|
| 313 | // Special Notes : |
|---|
| 314 | // |
|---|
| 315 | // Creator : Jason Kraftcheck |
|---|
| 316 | // |
|---|
| 317 | // Creation Date : 07/22/03 |
|---|
| 318 | //------------------------------------------------------------------------- |
|---|
| 319 | CubitStatus BasicTopologyEntity::remove_sense_entity( SenseEntity* se_ptr) |
|---|
| 320 | { |
|---|
| 321 | if (se_ptr->get_basic_topology_entity_ptr() != this) |
|---|
| 322 | { assert(0); return CUBIT_FAILURE; } |
|---|
| 323 | |
|---|
| 324 | if (!firstSenseEntity) |
|---|
| 325 | return CUBIT_FAILURE; |
|---|
| 326 | |
|---|
| 327 | if (firstSenseEntity == se_ptr) |
|---|
| 328 | { |
|---|
| 329 | if (lastSenseEntity == se_ptr) |
|---|
| 330 | { |
|---|
| 331 | firstSenseEntity = lastSenseEntity = 0; |
|---|
| 332 | } |
|---|
| 333 | else |
|---|
| 334 | { |
|---|
| 335 | firstSenseEntity = se_ptr->next_on_bte(); |
|---|
| 336 | } |
|---|
| 337 | } |
|---|
| 338 | else |
|---|
| 339 | { |
|---|
| 340 | SenseEntity* prev = firstSenseEntity; |
|---|
| 341 | while (prev->next_on_bte() != se_ptr) |
|---|
| 342 | { |
|---|
| 343 | prev = prev->next_on_bte(); |
|---|
| 344 | if (!prev) |
|---|
| 345 | return CUBIT_FAILURE; |
|---|
| 346 | } |
|---|
| 347 | |
|---|
| 348 | prev->set_bte_next( se_ptr->next_on_bte() ); |
|---|
| 349 | if (lastSenseEntity == se_ptr) |
|---|
| 350 | lastSenseEntity = prev; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | se_ptr->set_bte_next(0); |
|---|
| 354 | se_ptr->set_basic_topology_entity_ptr(0); |
|---|
| 355 | return CUBIT_SUCCESS; |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | //------------------------------------------------------------------------- |
|---|
| 359 | // Purpose : Find connecting sense entity |
|---|
| 360 | // |
|---|
| 361 | // Special Notes : |
|---|
| 362 | // |
|---|
| 363 | // Creator : Jason Kraftcheck |
|---|
| 364 | // |
|---|
| 365 | // Creation Date : 07/22/03 |
|---|
| 366 | //------------------------------------------------------------------------- |
|---|
| 367 | SenseEntity* BasicTopologyEntity::find_sense_entity(GroupingEntity* gpe) const |
|---|
| 368 | { |
|---|
| 369 | SenseEntity *ptr, *result = 0; |
|---|
| 370 | for (ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 371 | { |
|---|
| 372 | if (ptr->get_grouping_entity_ptr() == gpe) |
|---|
| 373 | { |
|---|
| 374 | if (result) |
|---|
| 375 | return 0; |
|---|
| 376 | result = ptr; |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | return result; |
|---|
| 381 | } |
|---|
| 382 | SenseEntity* BasicTopologyEntity::find_sense_entity(BasicTopologyEntity* bte) const |
|---|
| 383 | { |
|---|
| 384 | SenseEntity *ptr, *result = 0; |
|---|
| 385 | for (ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 386 | { |
|---|
| 387 | GroupingEntity* gpe = ptr->get_grouping_entity_ptr(); |
|---|
| 388 | BasicTopologyEntity* tmp_bte = gpe ? gpe->get_basic_topology_entity_ptr() : 0; |
|---|
| 389 | if (tmp_bte == bte) |
|---|
| 390 | { |
|---|
| 391 | if (result) |
|---|
| 392 | return 0; |
|---|
| 393 | result = ptr; |
|---|
| 394 | } |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | return result; |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | CubitStatus BasicTopologyEntity::get_sense_entities( |
|---|
| 401 | DLIList<SenseEntity*>& result, |
|---|
| 402 | GroupingEntity* in_this ) |
|---|
| 403 | { |
|---|
| 404 | int input_size = result.size(); |
|---|
| 405 | |
|---|
| 406 | for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 407 | if (!in_this || ptr->get_grouping_entity_ptr() == in_this) |
|---|
| 408 | result.append(ptr); |
|---|
| 409 | |
|---|
| 410 | return result.size() > input_size ? CUBIT_SUCCESS : CUBIT_FAILURE; |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | CubitStatus BasicTopologyEntity::get_sense_entities( |
|---|
| 414 | DLIList<SenseEntity*>& result, |
|---|
| 415 | BasicTopologyEntity* in_this ) |
|---|
| 416 | { |
|---|
| 417 | int input_size = result.size(); |
|---|
| 418 | |
|---|
| 419 | for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 420 | if (!in_this || ptr->get_parent_basic_topology_entity_ptr() == in_this) |
|---|
| 421 | result.append(ptr); |
|---|
| 422 | |
|---|
| 423 | return result.size() > input_size ? CUBIT_SUCCESS : CUBIT_FAILURE; |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | //------------------------------------------------------------------------- |
|---|
| 427 | // Purpose : Check if this entity is nonmanifold in the parent |
|---|
| 428 | // sense entity. |
|---|
| 429 | // |
|---|
| 430 | // Special Notes : |
|---|
| 431 | // |
|---|
| 432 | // Creator : Jason Kraftcheck |
|---|
| 433 | // |
|---|
| 434 | // Creation Date : 07/22/03 |
|---|
| 435 | //------------------------------------------------------------------------- |
|---|
| 436 | CubitBoolean BasicTopologyEntity::is_nonmanifold(GroupingEntity* gpe) |
|---|
| 437 | { |
|---|
| 438 | int count = 0; |
|---|
| 439 | for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 440 | if (ptr->get_grouping_entity_ptr() == gpe) |
|---|
| 441 | count++; |
|---|
| 442 | |
|---|
| 443 | assert(count); |
|---|
| 444 | return count == 1 ? CUBIT_FALSE : CUBIT_TRUE; |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | GeometryType BasicTopologyEntity::geometry_type() const |
|---|
| 448 | { |
|---|
| 449 | //- returns type of underlying geometry representation |
|---|
| 450 | //- (see GeometryEntity.hpp for list of types) |
|---|
| 451 | return get_geometry_entity_ptr()->geometry_type(); |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | //------------------------------------------------------------------------- |
|---|
| 455 | // Purpose : These functions return the GeometryEntity of this |
|---|
| 456 | // BasicTopologyEntity. |
|---|
| 457 | // |
|---|
| 458 | // Special Notes : |
|---|
| 459 | // |
|---|
| 460 | // Creator : Malcolm J. Panthaki |
|---|
| 461 | // |
|---|
| 462 | // Creation Date : 07/31/96 |
|---|
| 463 | //------------------------------------------------------------------------- |
|---|
| 464 | GeometryEntity* BasicTopologyEntity::get_geometry_entity_ptr() const |
|---|
| 465 | { |
|---|
| 466 | TopologyBridge* bridge = bridge_manager()->topology_bridge(); |
|---|
| 467 | return dynamic_cast<GeometryEntity*>(bridge); |
|---|
| 468 | } |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | CubitBox BasicTopologyEntity::bounding_box() |
|---|
| 472 | { |
|---|
| 473 | return get_geometry_entity_ptr()->bounding_box() ; |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | //------------------------------------------------------------------------- |
|---|
| 477 | // Purpose : Set the GeometryEntity pointer of this BTE |
|---|
| 478 | // |
|---|
| 479 | // Special Notes : |
|---|
| 480 | // |
|---|
| 481 | // Creator : Raikanta Sahu |
|---|
| 482 | // |
|---|
| 483 | // Creation Date : 10/24/96 |
|---|
| 484 | //------------------------------------------------------------------------- |
|---|
| 485 | CubitStatus BasicTopologyEntity::set_geometry_entity_ptr( |
|---|
| 486 | GeometryEntity* GE_ptr) |
|---|
| 487 | { |
|---|
| 488 | // if (dag_type().dimension() != GE_ptr.dimension()) |
|---|
| 489 | // { |
|---|
| 490 | // PRINT_ERROR("Internal Error: %s:%d: Mismatched BTE/GeometryEntity.\n", |
|---|
| 491 | // __FILE__,__LINE__); |
|---|
| 492 | // return CUBIT_FAILURE; |
|---|
| 493 | // } |
|---|
| 494 | return TopologyEntity::set_topology_bridge(GE_ptr); |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | double BasicTopologyEntity::measure() |
|---|
| 498 | { return get_geometry_entity_ptr()->measure(); } |
|---|
| 499 | |
|---|
| 500 | //------------------------------------------------------------------------- |
|---|
| 501 | // Purpose : get parent sense entities |
|---|
| 502 | // |
|---|
| 503 | // Special Notes : |
|---|
| 504 | // |
|---|
| 505 | // Creator : Jason Kraftcheck |
|---|
| 506 | // |
|---|
| 507 | // Creation Date : 07/22/03 |
|---|
| 508 | //------------------------------------------------------------------------- |
|---|
| 509 | int BasicTopologyEntity::get_parents( DLIList<ModelEntity*>* list ) const |
|---|
| 510 | { |
|---|
| 511 | if (!firstSenseEntity) |
|---|
| 512 | return 0; |
|---|
| 513 | |
|---|
| 514 | int count = 0; |
|---|
| 515 | SenseEntity* ptr; |
|---|
| 516 | |
|---|
| 517 | for (ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 518 | { |
|---|
| 519 | count++; |
|---|
| 520 | if (list) |
|---|
| 521 | list->append(ptr); |
|---|
| 522 | } |
|---|
| 523 | |
|---|
| 524 | return count; |
|---|
| 525 | } |
|---|
| 526 | |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | //------------------------------------------------------------------------- |
|---|
| 530 | // Purpose : get child grouping entities |
|---|
| 531 | // |
|---|
| 532 | // Special Notes : |
|---|
| 533 | // |
|---|
| 534 | // Creator : Jason Kraftcheck |
|---|
| 535 | // |
|---|
| 536 | // Creation Date : 07/22/03 |
|---|
| 537 | //------------------------------------------------------------------------- |
|---|
| 538 | int BasicTopologyEntity::get_children( DLIList<ModelEntity*>* list ) const |
|---|
| 539 | { |
|---|
| 540 | if (!firstGroupingEntity) |
|---|
| 541 | return 0; |
|---|
| 542 | |
|---|
| 543 | int count = 0; |
|---|
| 544 | GroupingEntity* ptr; |
|---|
| 545 | |
|---|
| 546 | for (ptr = firstGroupingEntity; ptr; ptr = ptr->next()) |
|---|
| 547 | { |
|---|
| 548 | count++; |
|---|
| 549 | if (list) |
|---|
| 550 | list->append(ptr); |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | return count; |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | //------------------------------------------------------------------------- |
|---|
| 557 | // Purpose : Functions to support ModelQueryEngine |
|---|
| 558 | // |
|---|
| 559 | // Special Notes : |
|---|
| 560 | // |
|---|
| 561 | // Creator : Jason Kraftcheck |
|---|
| 562 | // |
|---|
| 563 | // Creation Date : 07/24/03 |
|---|
| 564 | //------------------------------------------------------------------------- |
|---|
| 565 | CubitBoolean BasicTopologyEntity::query_append_parents( DLIList<ModelEntity*>& list ) |
|---|
| 566 | { |
|---|
| 567 | if (!firstSenseEntity) |
|---|
| 568 | return CUBIT_FALSE; |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | CubitBoolean found_some = CUBIT_FALSE; |
|---|
| 572 | ModelQueryEngine *const mqe = ModelQueryEngine::instance(); |
|---|
| 573 | for (SenseEntity* ptr = firstSenseEntity; ptr; ptr = ptr->next_on_bte()) |
|---|
| 574 | if (!mqe->encountered(ptr)) |
|---|
| 575 | { |
|---|
| 576 | list.append(ptr); |
|---|
| 577 | found_some = CUBIT_TRUE; |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | return found_some; |
|---|
| 581 | } |
|---|
| 582 | CubitBoolean BasicTopologyEntity::query_append_children( DLIList<ModelEntity*>& list ) |
|---|
| 583 | { |
|---|
| 584 | if (!firstGroupingEntity) |
|---|
| 585 | return 0; |
|---|
| 586 | |
|---|
| 587 | CubitBoolean found_some = CUBIT_FALSE; |
|---|
| 588 | ModelQueryEngine *const mqe = ModelQueryEngine::instance(); |
|---|
| 589 | GroupingEntity* ptr; |
|---|
| 590 | |
|---|
| 591 | for (ptr = firstGroupingEntity; ptr; ptr = ptr->next()) |
|---|
| 592 | { |
|---|
| 593 | if (!mqe->encountered(ptr)) |
|---|
| 594 | { |
|---|
| 595 | found_some = CUBIT_TRUE; |
|---|
| 596 | list.append(ptr); |
|---|
| 597 | } |
|---|
| 598 | } |
|---|
| 599 | |
|---|
| 600 | return found_some; |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | //------------------------------------------------------------------------- |
|---|
| 604 | // Purpose : Generic function to remove child grouping entity |
|---|
| 605 | // |
|---|
| 606 | // Special Notes : |
|---|
| 607 | // |
|---|
| 608 | // Creator : Jason Kraftcheck |
|---|
| 609 | // |
|---|
| 610 | // Creation Date : 07/22/03 |
|---|
| 611 | //------------------------------------------------------------------------- |
|---|
| 612 | CubitStatus BasicTopologyEntity::remove_child_link(ModelEntity* entity_ptr) |
|---|
| 613 | { |
|---|
| 614 | GroupingEntity* gpe_ptr = dynamic_cast<GroupingEntity*>(entity_ptr); |
|---|
| 615 | if (!gpe_ptr) |
|---|
| 616 | return CUBIT_FAILURE; |
|---|
| 617 | |
|---|
| 618 | return remove_grouping_entity(gpe_ptr); |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | //------------------------------------------------------------------------- |
|---|
| 622 | // Purpose : Remove from parent SenseEntitys |
|---|
| 623 | // |
|---|
| 624 | // Special Notes : |
|---|
| 625 | // |
|---|
| 626 | // Creator : Jason Kraftcheck |
|---|
| 627 | // |
|---|
| 628 | // Creation Date : 07/22/03 |
|---|
| 629 | //------------------------------------------------------------------------- |
|---|
| 630 | CubitStatus BasicTopologyEntity::disconnect_all_parents( DLIList<ModelEntity*>* list ) |
|---|
| 631 | { |
|---|
| 632 | while (firstSenseEntity) |
|---|
| 633 | { |
|---|
| 634 | SenseEntity* se_ptr = firstSenseEntity; |
|---|
| 635 | |
|---|
| 636 | if (!remove_sense_entity(se_ptr)) |
|---|
| 637 | return CUBIT_FAILURE; |
|---|
| 638 | |
|---|
| 639 | if (list) |
|---|
| 640 | list->append(se_ptr); |
|---|
| 641 | } |
|---|
| 642 | return CUBIT_SUCCESS; |
|---|
| 643 | } |
|---|
| 644 | |
|---|
| 645 | //------------------------------------------------------------------------- |
|---|
| 646 | // Purpose : Disconnect child GroupingEntities |
|---|
| 647 | // |
|---|
| 648 | // Special Notes : |
|---|
| 649 | // |
|---|
| 650 | // Creator : Jason Kraftcheck |
|---|
| 651 | // |
|---|
| 652 | // Creation Date : 07/22/03 |
|---|
| 653 | //------------------------------------------------------------------------- |
|---|
| 654 | CubitStatus BasicTopologyEntity::disconnect_all_children( DLIList<ModelEntity*>* list ) |
|---|
| 655 | { |
|---|
| 656 | while (firstGroupingEntity) |
|---|
| 657 | { |
|---|
| 658 | GroupingEntity* gpe_ptr = firstGroupingEntity; |
|---|
| 659 | |
|---|
| 660 | if (!remove_grouping_entity(gpe_ptr)) |
|---|
| 661 | return CUBIT_FAILURE; |
|---|
| 662 | |
|---|
| 663 | if (list) |
|---|
| 664 | list->append(gpe_ptr); |
|---|
| 665 | } |
|---|
| 666 | return CUBIT_SUCCESS; |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | |
|---|
| 670 | |
|---|
| 671 | // ********** END PUBLIC FUNCTIONS ********** |
|---|
| 672 | |
|---|
| 673 | // ********** BEGIN PROTECTED FUNCTIONS ********** |
|---|
| 674 | |
|---|
| 675 | // ********** END PROTECTED FUNCTIONS ********** |
|---|
| 676 | |
|---|
| 677 | // ********** BEGIN PRIVATE FUNCTIONS ********** |
|---|
| 678 | |
|---|
| 679 | // ********** END PRIVATE FUNCTIONS ********** |
|---|
| 680 | |
|---|
| 681 | // ********** BEGIN HELPER CLASSES ********** |
|---|
| 682 | // ********** END HELPER CLASSES ********** |
|---|
| 683 | |
|---|
| 684 | // ********** BEGIN EXTERN FUNCTIONS ********** |
|---|
| 685 | // ********** END EXTERN FUNCTIONS ********** |
|---|
| 686 | |
|---|
| 687 | // ********** BEGIN STATIC FUNCTIONS ********** |
|---|
| 688 | // ********** END STATIC FUNCTIONS ********** |
|---|