From 6f8e8af056485ee2f20f6c9cf33f8ceb85558e3b Mon Sep 17 00:00:00 2001 From: epernod Date: Thu, 30 Mar 2023 00:54:45 +0200 Subject: [PATCH] Add Data bool to run the manager process if it is active --- .../CarvingTools/AdvancedCarvingManager.cpp | 27 ++++++++++--------- .../CarvingTools/AdvancedCarvingManager.h | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.cpp b/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.cpp index 9a516b2..0232f6d 100644 --- a/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.cpp +++ b/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.cpp @@ -64,6 +64,7 @@ AdvancedCarvingManager::AdvancedCarvingManager() : d_toolModelPath( initData(&d_toolModelPath, "toolModelPath", "Tool model path")) , d_surfaceModelPath( initData(&d_surfaceModelPath, "surfaceModelPath", "TriangleSetModel or SphereModel path")) , d_active( initData(&d_active, false, "active", "Activate this object.\nNote that this can be dynamically controlled by using a key") ) + , d_process(initData(&d_process, false, "process", "Will perform the carving according to filter done in active mode")) , d_carvingWithBurning(initData(&d_carvingWithBurning, true, "carvingWithBurning", "Activate this object.\nNote that this can be dynamically controlled by using a key")) , d_carvingWithRefinement(initData(&d_carvingWithRefinement, false, "carvingWithRefinement", "Activate this object.\nNote that this can be dynamically controlled by using a key")) , d_cuttingMode(initData(&d_cuttingMode, false, "cuttingMode", "Activate the option tetrahedral cutting.")) @@ -347,13 +348,7 @@ void AdvancedCarvingManager::filterCollision() for (auto carvingPerformer : m_carvingPerformer) { carvingPerformer->filterContacts(); - } - - //// process the collision - //for (auto carvingPerformer : m_carvingPerformer) - //{ - // carvingPerformer->runPerformer(); - //} + } } @@ -377,14 +372,20 @@ void AdvancedCarvingManager::handleEvent(sofa::core::objectmodel::Event* event) { if (ev->getKey() == 'C') { - msg_warning() << "Burn, baby burn!"; - //d_active.setValue(true); - for (auto carvingPerformer : m_carvingPerformer) - { - carvingPerformer->runPerformer(); - } + d_process.setValue(true); + } + } + + if (d_process.getValue()) + { + for (auto carvingPerformer : m_carvingPerformer) + { + carvingPerformer->runPerformer(); } + + d_process.setValue(false); } + } void AdvancedCarvingManager::draw(const core::visual::VisualParams* vparams) diff --git a/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.h b/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.h index 6a4014e..ded119e 100644 --- a/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.h +++ b/src/InfinyToolkit/CarvingTools/AdvancedCarvingManager.h @@ -94,6 +94,7 @@ class SOFA_INFINYTOOLKIT_API AdvancedCarvingManager : public core::behavior::Bas Data < std::string > d_surfaceModelPath; Data < bool > d_active; + Data < bool > d_process; Data < bool > d_carvingWithBurning; Data < bool > d_carvingWithRefinement; Data < bool > d_cuttingMode;