| 387 | } |
| 388 | |
| 389 | bool ccGraphicalSegmentationTool::addEntity(ccHObject *entity, bool silent/*=false*/) |
| 390 | { |
| 391 | if (!entity) |
| 392 | { |
| 393 | assert(false); |
| 394 | return false; |
| 395 | } |
| 396 | |
| 397 | if (!entity->isDisplayedIn(m_associatedWin) && !silent) |
| 398 | { |
| 399 | ccLog::Warning(QString("[Graphical Segmentation Tool] Entity [%1] is not visible in the active 3D view!").arg(entity->getName())); |
| 400 | } |
| 401 | |
| 402 | if (entity->isKindOf(CC_TYPES::POINT_CLOUD)) |
| 403 | { |
| 404 | ccGenericPointCloud *cloud = ccHObjectCaster::ToGenericPointCloud(entity); |
| 405 | |
| 406 | ccGenericMesh *associatedMesh = nullptr; |
| 407 | if (ccGenericMesh::IsCloudVerticesOfMesh(cloud, &associatedMesh)) |
| 408 | { |
| 409 | assert(nullptr != associatedMesh); |
| 410 | if (m_toSegment.contains(associatedMesh)) |
| 411 | { |
| 412 | if (!silent) |
| 413 | { |
| 414 | ccLog::Warning(QString("[Graphical Segmentation Tool] The mesh associated to cloud %1 is already selected").arg(cloud->getName())); |
| 415 | } |
| 416 | return false; |
| 417 | } |
| 418 | |
| 419 | // hide the associated mesh, as it will also be (graphically) segmented |
| 420 | associatedMesh->pushDisplayState(); |
| 421 | associatedMesh->setVisible(false); |
| 422 | } |
| 423 | |
| 424 | ccPolyline *associatedPolyline = nullptr; |
| 425 | if (ccPolyline::IsCloudVerticesOfPolyline(cloud, &associatedPolyline)) |
| 426 | { |
| 427 | assert(nullptr != associatedPolyline); |
| 428 | if (m_toSegment.contains(associatedPolyline)) |
| 429 | { |
| 430 | if (!silent) |
| 431 | { |
| 432 | ccLog::Warning(QString("[Graphical Segmentation Tool] The polyline associated to cloud %1 is already selected").arg(cloud->getName())); |
| 433 | } |
| 434 | return false; |
| 435 | } |
| 436 | |
| 437 | // hide the associated polyline, as it will also be (graphically) segmented |
| 438 | associatedPolyline->pushDisplayState(); |
| 439 | associatedPolyline->setVisible(false); |
| 440 | } |
| 441 | |
| 442 | m_toSegment.insert(cloud); |
| 443 | cloud->pushDisplayState(); |
| 444 | cloud->setVisible(true); |
| 445 | cloud->setEnabled(true); |
| 446 |
no test coverage detected