From 3134ba7e17608747e003ffe79944a79ea85753a5 Mon Sep 17 00:00:00 2001 From: epernod Date: Fri, 4 Jun 2021 10:36:29 +0200 Subject: [PATCH] [Constraints] Remove TopologyDataHandler in constraints as they were only redefining a Data resize operation. This is already done directly inside the TopologyData. The destroyFunction should be only overriden if a complex behavior is needed. --- .../src/LMConstraint/DOFBlockerLMConstraint.h | 21 +--------- .../LMConstraint/DOFBlockerLMConstraint.inl | 16 +------- .../src/LMConstraint/FixedLMConstraint.h | 22 +---------- .../src/LMConstraint/FixedLMConstraint.inl | 18 +-------- .../AffineMovementConstraint.h | 18 --------- .../AffineMovementConstraint.inl | 20 ++-------- .../SofaBoundaryCondition/FixedConstraint.h | 18 --------- .../SofaBoundaryCondition/FixedConstraint.inl | 19 +-------- .../FixedPlaneConstraint.h | 6 --- .../FixedPlaneConstraint.inl | 39 ++----------------- .../FixedTranslationConstraint.h | 19 --------- .../FixedTranslationConstraint.inl | 19 ++------- .../LinearMovementConstraint.h | 17 -------- .../LinearMovementConstraint.inl | 19 ++------- .../LinearVelocityConstraint.h | 19 --------- .../LinearVelocityConstraint.inl | 19 ++------- .../PartialLinearMovementConstraint.h | 16 -------- .../PartialLinearMovementConstraint.inl | 20 ++-------- .../PatchTestMovementConstraint.h | 17 -------- .../PatchTestMovementConstraint.inl | 20 ++-------- .../ProjectDirectionConstraint.h | 19 --------- .../ProjectDirectionConstraint.inl | 18 +-------- .../ProjectToLineConstraint.h | 19 --------- .../ProjectToLineConstraint.inl | 18 +-------- .../ProjectToPlaneConstraint.h | 19 --------- .../ProjectToPlaneConstraint.inl | 18 +-------- .../ProjectToPointConstraint.h | 18 --------- .../ProjectToPointConstraint.inl | 18 +-------- 28 files changed, 37 insertions(+), 492 deletions(-) diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h index 24c7d89f6e3..7e495d672b2 100644 --- a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h +++ b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h @@ -77,15 +77,13 @@ class DOFBlockerLMConstraint : public core::behavior::LMConstraint, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; - class FCTPointHandler : public sofa::component::topology::TopologyDataHandler > - { - public: - FCTPointHandler(DOFBlockerLMConstraint* _fc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler >(_data), fc(_fc) {} - - - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - - protected: - DOFBlockerLMConstraint *fc; - }; - protected : sofa::type::vector idxEquations; - - FCTPointHandler* m_pointHandler; }; #if !defined(SOFA_COMPONENT_CONSTRAINTSET_DOFBLOCKERLMCONSTRAINT_CPP) diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl index 5d0609de656..86bdc3fbd3f 100644 --- a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl +++ b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl @@ -29,17 +29,6 @@ namespace sofa::component::constraintset { -// Define RemovalFunction -template< class DataTypes> -void DOFBlockerLMConstraint::FCTPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } - return; -} - template void DOFBlockerLMConstraint::clearConstraints() { @@ -80,9 +69,8 @@ void DOFBlockerLMConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCTPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological change handling + f_indices.createTopologyHandler(_topology); } else { diff --git a/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.h b/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.h index 1dc3f6adba1..f87facefa0a 100644 --- a/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.h +++ b/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.h @@ -70,8 +70,7 @@ class FixedLMConstraint : public core::behavior::LMConstraint, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; - class FCPointHandler : public sofa::component::topology::TopologyDataHandler - { - public: - typedef typename FixedLMConstraint::SetIndexArray SetIndexArray; - FCPointHandler(FixedLMConstraint* _fc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - protected: - FixedLMConstraint *fc; - }; - protected : Deriv X,Y,Z; SetIndexArray idxX, idxY, idxZ; std::map< Index, Coord> restPosition; - - - FCPointHandler* m_pointHandler; - }; diff --git a/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.inl b/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.inl index 95d62f18aa7..671922f0793 100644 --- a/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.inl +++ b/applications/plugins/LMConstraint/src/LMConstraint/FixedLMConstraint.inl @@ -28,25 +28,12 @@ namespace sofa::component::constraintset { - -// Define RemovalFunction -template< class DataTypes> -void FixedLMConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } - return; -} - template FixedLMConstraint::FixedLMConstraint(MechanicalState *dof) : core::behavior::LMConstraint(dof,dof) , f_indices(core::objectmodel::Base::initData(&f_indices, "indices", "List of the index of particles to be fixed")) , _drawSize(core::objectmodel::Base::initData(&_drawSize,0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { } @@ -103,9 +90,8 @@ void FixedLMConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological change handling + f_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.h index fc00dba904a..a24ddd9a3f3 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.h @@ -140,21 +140,6 @@ public : /// Draw the constrained points (= border mesh points) void draw(const core::visual::VisualParams* vparams) override; - class FCPointHandler : public component::topology::TopologyDataHandler - { - public: - typedef typename AffineMovementConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(AffineMovementConstraint* _fc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - using component::topology::TopologyDataHandler::applyDestroyFunction; - void applyDestroyFunction(Index /*index*/, core::objectmodel::Data& /*T*/); - - protected: - AffineMovementConstraint *fc; - }; - protected: template @@ -162,9 +147,6 @@ public : private: - /// Handler for subset Data - FCPointHandler* m_pointHandler; - /// Initialize initial positions void initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0); diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.inl index 26b9605015c..967ec623fde 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/AffineMovementConstraint.inl @@ -33,17 +33,6 @@ namespace sofa::component::projectiveconstraintset { -// Define RemovalFunction -template< class DataTypes> -void AffineMovementConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, core::objectmodel::Data&) -{ - if (fc) - { - fc->removeConstraint(pointIndex); - } -} - - template AffineMovementConstraint::AffineMovementConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -57,7 +46,6 @@ AffineMovementConstraint::AffineMovementConstraint() , m_translation( initData(&m_translation,"translation","translation applied to border points") ) , m_drawConstrainedPoints( initData(&m_drawConstrainedPoints,"drawConstrainedPoints","draw constrained points") ) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { if(!m_beginConstraintTime.isSet()) m_beginConstraintTime = 0; @@ -70,8 +58,7 @@ AffineMovementConstraint::AffineMovementConstraint() template AffineMovementConstraint::~AffineMovementConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } template @@ -115,9 +102,8 @@ void AffineMovementConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &m_indices); - m_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + m_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.h index 8ad571ad5c1..c111d5fd8d3 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.h @@ -118,27 +118,9 @@ class FixedConstraint : public core::behavior::ProjectiveConstraintSet - { - public: - typedef typename FixedConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(FixedConstraint* _fc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - protected: - FixedConstraint *fc; - }; - protected : /// Function check values of given indices void checkIndices(); - - /// Handler for subset Data - FCPointHandler* m_pointHandler; }; diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.inl index 96ae132b0fb..437734cd365 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedConstraint.inl @@ -37,16 +37,6 @@ using sofa::core::objectmodel::ComponentState; namespace sofa::component::projectiveconstraintset { -// Define RemovalFunction -template< class DataTypes> -void FixedConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - template FixedConstraint::FixedConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -57,7 +47,6 @@ FixedConstraint::FixedConstraint() , d_projectVelocity( initData(&d_projectVelocity,false,"activate_projectVelocity","activate project velocity to set velocity") ) , l_topology(initLink("topology", "link to the topology container")) , data(new FixedConstraintInternalData()) - , m_pointHandler(nullptr) { // default to indice 0 d_indices.beginEdit()->push_back(0); @@ -75,9 +64,6 @@ FixedConstraint::FixedConstraint() template FixedConstraint::~FixedConstraint() { - if (m_pointHandler) - delete m_pointHandler; - delete data; } @@ -129,9 +115,8 @@ void FixedConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize topological functions - m_pointHandler = new FCPointHandler(this, &d_indices); - d_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.h index 8c4482d39c2..70466f6c95a 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.h @@ -110,12 +110,6 @@ class FixedPlaneConstraint : public ProjectiveConstraintSet FixedPlaneConstraintInternalData data; friend class FixedPlaneConstraintInternalData; - /// Forward class declaration, definition is in the .inl - class FCPointHandler; - - /// Handler for subset Data - FCPointHandler* m_pointHandler {nullptr}; - /// whether vertices should be selected from 2 parallel planes bool m_selectVerticesFromPlanes {false}; diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.inl index 097275fa5c4..b3b6dd5c62f 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedPlaneConstraint.inl @@ -35,36 +35,6 @@ namespace sofa::component::projectiveconstraintset using sofa::helper::WriteAccessor; using sofa::type::Vec; -using sofa::component::topology::TopologyDataHandler; - - -/////////////////////////// DEFINITION OF FCPointHandler (INNER CLASS) ///////////////////////////// -template -class FixedPlaneConstraint::FCPointHandler : - public TopologyDataHandler -{ -public: - typedef typename FixedPlaneConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(FixedPlaneConstraint* _fc, SetIndex* _data) - : TopologyDataHandler(_data), fc(_fc) {} - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - -protected: - FixedPlaneConstraint *fc; -}; - -/// Define RemovalFunction -template< class DataTypes> -void FixedPlaneConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - /////////////////////////// DEFINITION OF FixedPlaneConstraint ///////////////////////////////////// template @@ -74,7 +44,6 @@ FixedPlaneConstraint::FixedPlaneConstraint() , d_dmax( initData(&d_dmax,(Real)0,"dmax","Maximum plane distance from the origin") ) , d_indices( initData(&d_indices,"indices","Indices of the fixed points")) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { m_selectVerticesFromPlanes=false; } @@ -82,8 +51,7 @@ FixedPlaneConstraint::FixedPlaneConstraint() template FixedPlaneConstraint::~FixedPlaneConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } /// Matrix Integration interface @@ -236,9 +204,8 @@ void FixedPlaneConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - /// Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &d_indices); - d_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.h index 6cc11ff17ca..eb5ac063f1e 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.h @@ -89,29 +89,10 @@ class FixedTranslationConstraint : public core::behavior::ProjectiveConstraintSe void draw(const core::visual::VisualParams* vparams) override; - class FCPointHandler : public sofa::component::topology::TopologyDataHandler - { - public: - typedef typename FixedTranslationConstraint::SetIndexArray SetIndexArray; - typedef sofa::core::topology::Point Point; - FCPointHandler(FixedTranslationConstraint* _fc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - protected: - FixedTranslationConstraint *fc; - }; - protected: template void projectResponseT(const core::MechanicalParams* mparams, DataDeriv& dx); - /// Handler for subset Data - FCPointHandler* m_pointHandler; - }; #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDTRANSLATIONCONSTRAINT_CPP) diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.inl index 1de4274835a..4064444ecdf 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/FixedTranslationConstraint.inl @@ -30,16 +30,6 @@ namespace sofa::component::projectiveconstraintset { -// Define RemovalFunction -template< class DataTypes> -void FixedTranslationConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (fc) - { - fc->removeIndex((Index) pointIndex); - } -} - template< class DataTypes> FixedTranslationConstraint::FixedTranslationConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -48,7 +38,6 @@ FixedTranslationConstraint::FixedTranslationConstraint() , _drawSize( initData(&_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , f_coordinates( initData(&f_coordinates,"coordinates","Coordinates of the fixed points") ) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { // default to indice 0 f_indices.beginEdit()->push_back(0); @@ -59,8 +48,7 @@ FixedTranslationConstraint::FixedTranslationConstraint() template FixedTranslationConstraint::~FixedTranslationConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } template @@ -102,9 +90,8 @@ void FixedTranslationConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); f_coordinates.createTopologyHandler(_topology); } else diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.h index 40d6b81dfb9..8dfe85e2be9 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.h @@ -135,20 +135,6 @@ public : void draw(const core::visual::VisualParams* vparams) override; - class FCPointHandler : public sofa::component::topology::TopologyDataHandler - { - public: - typedef typename LinearMovementConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(LinearMovementConstraint* _lc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), lc(_lc) {} - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - protected: - LinearMovementConstraint *lc; - }; - protected: template void projectResponseT(const core::MechanicalParams* mparams, DataDeriv& dx); @@ -167,9 +153,6 @@ public : /// find previous and next time keys void findKeyTimes(); - - /// Handler for subset Data - FCPointHandler* m_pointHandler; }; diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.inl index 3048e5a2c43..9cbe0e78337 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearMovementConstraint.inl @@ -33,16 +33,6 @@ namespace sofa::component::projectiveconstraintset { -// Define RemovalFunction -template< class DataTypes> -void LinearMovementConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (lc) - { - lc->removeIndex(pointIndex); - } -} - template LinearMovementConstraint::LinearMovementConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -53,7 +43,6 @@ LinearMovementConstraint::LinearMovementConstraint() , d_relativeMovements( initData(&d_relativeMovements, bool(true), "relativeMovements", "If true, movements are relative to first position, absolute otherwise") ) , showMovement( initData(&showMovement, bool(false), "showMovement", "Visualization of the movement to be applied to constrained dofs.")) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { // default to indice 0 m_indices.beginEdit()->push_back(0); @@ -71,8 +60,7 @@ LinearMovementConstraint::LinearMovementConstraint() template LinearMovementConstraint::~LinearMovementConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } template @@ -132,9 +120,8 @@ void LinearMovementConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &m_indices); - m_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + m_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.h index c3d7e0cec8d..94140b772fe 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.h @@ -111,22 +111,6 @@ public : void draw(const core::visual::VisualParams* vparams) override; - class FCPointHandler : public sofa::component::topology::TopologyDataHandler - { - public: - typedef typename LinearVelocityConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(LinearVelocityConstraint* _lc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), lc(_lc) {} - - - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - protected: - LinearVelocityConstraint *lc; - }; - private: /// to keep the time corresponding to the key times @@ -137,9 +121,6 @@ public : /// find previous and next time keys void findKeyTimes(); - - /// Handler for subset Data - FCPointHandler* m_pointHandler; }; #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARVELOCITYCONSTRAINT_CPP) diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.inl index 6837e1721ce..adb7643a4ef 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/LinearVelocityConstraint.inl @@ -33,16 +33,6 @@ namespace sofa::component::projectiveconstraintset { -// Define RemovalFunction -template< class TDataTypes> -void LinearVelocityConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (lc) - { - lc->removeIndex((Index) pointIndex); - } -} - template LinearVelocityConstraint::LinearVelocityConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -51,7 +41,6 @@ LinearVelocityConstraint::LinearVelocityConstraint() , d_keyVelocities( initData(&d_keyVelocities,"velocities","velocities corresponding to the key times") ) , d_coordinates( initData(&d_coordinates, "coordinates", "coordinates on which to apply velocities") ) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { d_indices.beginEdit()->push_back(0); d_indices.endEdit(); @@ -66,8 +55,7 @@ LinearVelocityConstraint::LinearVelocityConstraint() template LinearVelocityConstraint::~LinearVelocityConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } template @@ -129,9 +117,8 @@ void LinearVelocityConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &d_indices); - d_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); d_coordinates.createTopologyHandler(_topology); } else diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.h index 3bc2b5053ef..befb163ece2 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.h @@ -142,19 +142,6 @@ public : void draw(const core::visual::VisualParams*) override; - class FCPointHandler : public sofa::component::topology::TopologyDataHandler - { - public: - typedef typename PartialLinearMovementConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(PartialLinearMovementConstraint* _lc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), lc(_lc) {} - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - protected: - PartialLinearMovementConstraint *lc; - }; - protected: template void projectResponseT(const core::MechanicalParams* mparams, DataDeriv& dx); @@ -174,9 +161,6 @@ public : /// find previous and next time keys void findKeyTimes(); - - /// Handler for subset Data - FCPointHandler* m_pointHandler; }; diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.inl index 6e22881e314..6f23d34a21f 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PartialLinearMovementConstraint.inl @@ -35,17 +35,6 @@ namespace sofa::component::projectiveconstraintset { - -// Define RemovalFunction -template< class DataTypes> -void PartialLinearMovementConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (lc) - { - lc->removeIndex((Index) pointIndex); - } -} - template PartialLinearMovementConstraint::PartialLinearMovementConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -64,7 +53,6 @@ PartialLinearMovementConstraint::PartialLinearMovementConstraint() , Z0 ( initData ( &Z0, Real(0.0),"Z0","Size of specimen in Z-direction" ) ) , movedDirections( initData(&movedDirections,"movedDirections","for each direction, 1 if moved, 0 if free") ) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { // default to indice 0 m_indices.beginEdit()->push_back(0); @@ -85,8 +73,7 @@ PartialLinearMovementConstraint::PartialLinearMovementConstraint() template PartialLinearMovementConstraint::~PartialLinearMovementConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } template @@ -148,9 +135,8 @@ void PartialLinearMovementConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &m_indices); - m_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + m_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.h index 7367a347ef8..57e155cd70e 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.h @@ -136,20 +136,6 @@ public : /// Draw the constrained points (= border mesh points) void draw(const core::visual::VisualParams* vparams) override; - class FCPointHandler : public sofa::component::topology::TopologyDataHandler - { - public: - typedef typename PatchTestMovementConstraint::SetIndexArray SetIndexArray; - - FCPointHandler(PatchTestMovementConstraint* _fc, SetIndex* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - void applyDestroyFunction(Index /*index*/, value_type& /*T*/); - - protected: - PatchTestMovementConstraint *fc; - }; - protected: template @@ -157,9 +143,6 @@ public : private: - /// Handler for subset Data - FCPointHandler* m_pointHandler; - /// Find the corners of the grid mesh void findCornerPoints(); diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.inl index 8b8fccd5f96..8a051d2f318 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/PatchTestMovementConstraint.inl @@ -33,17 +33,6 @@ namespace sofa::component::projectiveconstraintset { -// Define RemovalFunction -template< class DataTypes> -void PatchTestMovementConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, value_type &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - - template PatchTestMovementConstraint::PatchTestMovementConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -57,7 +46,6 @@ PatchTestMovementConstraint::PatchTestMovementConstraint() , d_cornerPoints( initData(&d_cornerPoints,"cornerPoints","corner points for computing constraint") ) , d_drawConstrainedPoints( initData(&d_drawConstrainedPoints,"drawConstrainedPoints","draw constrained points") ) , l_topology(initLink("topology", "link to the topology container")) - , m_pointHandler(nullptr) { if(!d_beginConstraintTime.isSet()) d_beginConstraintTime = 0; @@ -70,8 +58,7 @@ PatchTestMovementConstraint::PatchTestMovementConstraint() template PatchTestMovementConstraint::~PatchTestMovementConstraint() { - if (m_pointHandler) - delete m_pointHandler; + } template @@ -115,9 +102,8 @@ void PatchTestMovementConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &d_indices); - d_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.h index af16a8e43b2..78af934a4bc 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.h @@ -119,26 +119,7 @@ class ProjectDirectionConstraint : public core::behavior::ProjectiveConstraintSe void draw(const core::visual::VisualParams* vparams) override; - - class FCPointHandler : public component::topology::TopologyDataHandler - { - public: - typedef typename ProjectDirectionConstraint::Indices Indices; - typedef sofa::core::topology::Point Point; - FCPointHandler(ProjectDirectionConstraint* _fc, IndexSubsetData* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - using component::topology::TopologyDataHandler::applyDestroyFunction; - void applyDestroyFunction(Index /*index*/, core::objectmodel::Data& /*T*/); - - protected: - ProjectDirectionConstraint *fc; - }; - protected : - /// Handler for subset Data - FCPointHandler* m_pointHandler; SparseMatrix jacobian; ///< projection matrix in local state SparseMatrix J; ///< auxiliary variable diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.inl index a26c73eeee9..bc02788ea53 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectDirectionConstraint.inl @@ -33,15 +33,6 @@ namespace sofa::component::projectiveconstraintset { -template< class DataTypes> -void ProjectDirectionConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, core::objectmodel::Data &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - template ProjectDirectionConstraint::ProjectDirectionConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -50,7 +41,6 @@ ProjectDirectionConstraint::ProjectDirectionConstraint() , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) , l_topology(initLink("topology", "link to the topology container")) , data(new ProjectDirectionConstraintInternalData()) - , m_pointHandler(nullptr) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -60,9 +50,6 @@ ProjectDirectionConstraint::ProjectDirectionConstraint() template ProjectDirectionConstraint::~ProjectDirectionConstraint() { - if (m_pointHandler) - delete m_pointHandler; - delete data; } @@ -108,9 +95,8 @@ void ProjectDirectionConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.h index a399c2eae1f..8fa17f7da40 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.h @@ -119,26 +119,7 @@ class ProjectToLineConstraint : public core::behavior::ProjectiveConstraintSet - { - public: - typedef typename ProjectToLineConstraint::Indices Indices; - typedef sofa::core::topology::Point Point; - FCPointHandler(ProjectToLineConstraint* _fc, IndexSubsetData* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - using component::topology::TopologyDataHandler::applyDestroyFunction; - void applyDestroyFunction(Index /*index*/, core::objectmodel::Data& /*T*/); - - protected: - ProjectToLineConstraint *fc; - }; - protected : - /// Handler for subset Data - FCPointHandler* m_pointHandler; SparseMatrix jacobian; ///< projection matrix in local state SparseMatrix J; ///< auxiliary variable diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.inl index 854fc741217..fbcc7bcb8ba 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToLineConstraint.inl @@ -32,15 +32,6 @@ namespace sofa::component::projectiveconstraintset { -template< class DataTypes> -void ProjectToLineConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, core::objectmodel::Data &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - template ProjectToLineConstraint::ProjectToLineConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -50,7 +41,6 @@ ProjectToLineConstraint::ProjectToLineConstraint() , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) , l_topology(initLink("topology", "link to the topology container")) , data(new ProjectToLineConstraintInternalData()) - , m_pointHandler(nullptr) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -60,9 +50,6 @@ ProjectToLineConstraint::ProjectToLineConstraint() template ProjectToLineConstraint::~ProjectToLineConstraint() { - if (m_pointHandler) - delete m_pointHandler; - delete data; } @@ -107,9 +94,8 @@ void ProjectToLineConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.h index c509803a817..a5ee0c9b49d 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.h @@ -120,26 +120,7 @@ class ProjectToPlaneConstraint : public core::behavior::ProjectiveConstraintSet< void draw(const core::visual::VisualParams* vparams) override; - - class FCPointHandler : public component::topology::TopologyDataHandler - { - public: - typedef typename ProjectToPlaneConstraint::Indices Indices; - typedef typename sofa::core::topology::Point Point; - FCPointHandler(ProjectToPlaneConstraint* _fc, IndexSubsetData* _data) - : sofa::component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - using component::topology::TopologyDataHandler::applyDestroyFunction; - void applyDestroyFunction(Index /*index*/, core::objectmodel::Data& /*T*/); - - protected: - ProjectToPlaneConstraint *fc; - }; - protected : - /// Handler for subset Data - FCPointHandler* m_pointHandler; SparseMatrix jacobian; ///< projection matrix in local state SparseMatrix J; ///< auxiliary variable diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.inl index bebde811a68..075ebdb6614 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPlaneConstraint.inl @@ -32,15 +32,6 @@ namespace sofa::component::projectiveconstraintset { -template< class DataTypes> -void ProjectToPlaneConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, core::objectmodel::Data &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - template ProjectToPlaneConstraint::ProjectToPlaneConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -50,7 +41,6 @@ ProjectToPlaneConstraint::ProjectToPlaneConstraint() , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , l_topology(initLink("topology", "link to the topology container")) , data(new ProjectToPlaneConstraintInternalData()) - , m_pointHandler(nullptr) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -60,9 +50,6 @@ ProjectToPlaneConstraint::ProjectToPlaneConstraint() template ProjectToPlaneConstraint::~ProjectToPlaneConstraint() { - if (m_pointHandler) - delete m_pointHandler; - delete data; } @@ -107,9 +94,8 @@ void ProjectToPlaneConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); } else { diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.h b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.h index 11cc6e0da94..b1714491cef 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.h +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.h @@ -116,25 +116,7 @@ class ProjectToPointConstraint : public core::behavior::ProjectiveConstraintSet< bool fixAllDOFs() const { return f_fixAll.getValue(); } - class FCPointHandler : public component::topology::TopologyDataHandler - { - public: - typedef typename ProjectToPointConstraint::SetIndexArray SetIndexArray; - typedef sofa::core::topology::Point Point; - FCPointHandler(ProjectToPointConstraint* _fc, SetIndex* _data) - : component::topology::TopologyDataHandler(_data), fc(_fc) {} - - - using component::topology::TopologyDataHandler::applyDestroyFunction; - void applyDestroyFunction(Index /*index*/, core::objectmodel::Data& /*T*/); - - protected: - ProjectToPointConstraint *fc; - }; - protected : - /// Handler for subset Data - FCPointHandler* m_pointHandler; /// Matrix used in getJ // linearsolver::EigenBaseSparseMatrix jacobian; diff --git a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.inl b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.inl index d21236de3d8..98e5fca5e39 100644 --- a/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.inl +++ b/modules/SofaBoundaryCondition/src/SofaBoundaryCondition/ProjectToPointConstraint.inl @@ -33,15 +33,6 @@ namespace sofa::component::projectiveconstraintset { -template< class DataTypes> -void ProjectToPointConstraint::FCPointHandler::applyDestroyFunction(Index pointIndex, core::objectmodel::Data &) -{ - if (fc) - { - fc->removeConstraint((Index) pointIndex); - } -} - template ProjectToPointConstraint::ProjectToPointConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) @@ -51,7 +42,6 @@ ProjectToPointConstraint::ProjectToPointConstraint() , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , l_topology(initLink("topology", "link to the topology container")) , data(new ProjectToPointConstraintInternalData()) - , m_pointHandler(nullptr) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -61,9 +51,6 @@ ProjectToPointConstraint::ProjectToPointConstraint() template ProjectToPointConstraint::~ProjectToPointConstraint() { - if (m_pointHandler) - delete m_pointHandler; - delete data; } @@ -108,9 +95,8 @@ void ProjectToPointConstraint::init() { msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - // Initialize functions and parameters - m_pointHandler = new FCPointHandler(this, &f_indices); - f_indices.createTopologyHandler(_topology, m_pointHandler); + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); } else {