| 423 | |
| 424 | |
| 425 | bool ApplyCCLibAlgorithm(CC_LIB_ALGORITHM algo, ccHObject::Container& entities, QWidget* parent/*=nullptr*/, void** additionalParameters/*=nullptr*/) |
| 426 | { |
| 427 | size_t selNum = entities.size(); |
| 428 | if (selNum < 1) |
| 429 | return false; |
| 430 | |
| 431 | //generic parameters |
| 432 | QString sfName; |
| 433 | |
| 434 | //computeScalarFieldGradient parameters |
| 435 | bool euclidean = false; |
| 436 | |
| 437 | switch (algo) |
| 438 | { |
| 439 | case CCLIB_ALGO_SF_GRADIENT: |
| 440 | { |
| 441 | sfName = CC_GRADIENT_NORMS_FIELD_NAME; |
| 442 | //parameters already provided? |
| 443 | if (additionalParameters) |
| 444 | { |
| 445 | euclidean = *static_cast<bool*>(additionalParameters[0]); |
| 446 | } |
| 447 | else //ask the user! |
| 448 | { |
| 449 | euclidean = ( QMessageBox::question(parent, |
| 450 | "Gradient", |
| 451 | "Is the scalar field composed of (euclidean) distances?", |
| 452 | QMessageBox::Yes | QMessageBox::No, |
| 453 | QMessageBox::No ) == QMessageBox::Yes ); |
| 454 | } |
| 455 | } |
| 456 | break; |
| 457 | |
| 458 | default: |
| 459 | assert(false); |
| 460 | return false; |
| 461 | } |
| 462 | |
| 463 | for (size_t i = 0; i < selNum; ++i) |
| 464 | { |
| 465 | //is the ith selected data is eligible for processing? |
| 466 | ccGenericPointCloud* cloud = nullptr; |
| 467 | switch (algo) |
| 468 | { |
| 469 | case CCLIB_ALGO_SF_GRADIENT: |
| 470 | //for scalar field gradient, we can apply it directly on meshes |
| 471 | bool lockedVertices; |
| 472 | cloud = ccHObjectCaster::ToGenericPointCloud(entities[i], &lockedVertices); |
| 473 | if (lockedVertices) |
| 474 | { |
| 475 | ccUtils::DisplayLockedVerticesWarning(entities[i]->getName(), selNum == 1); |
| 476 | cloud = nullptr; |
| 477 | } |
| 478 | if (cloud) |
| 479 | { |
| 480 | //but we need an already displayed SF! |
| 481 | if (cloud->isA(CC_TYPES::POINT_CLOUD)) |
| 482 | { |
no test coverage detected