diff --git a/applications/plugins/CMakeLists.txt b/applications/plugins/CMakeLists.txt
index e8c320fcc8b..95b05e67d8a 100644
--- a/applications/plugins/CMakeLists.txt
+++ b/applications/plugins/CMakeLists.txt
@@ -36,7 +36,6 @@ sofa_add_subdirectory_external(SofaPython3 SofaPython3)
sofa_add_plugin_external(CGALPlugin CGALPlugin) # Depends on image
sofa_add_plugin_external(Flexible Flexible) # Depends on image, CImgPlugin, SofaHighOrderTopology (soft)
sofa_add_plugin(Registration Registration) # Depends on image, SofaPython, SofaSimpleGUI and #SOFADISTANCEGRID
-sofa_add_plugin(LMConstraint LMConstraint ON)
sofa_add_plugin(BulletCollisionDetection BulletCollisionDetection) # Depends on Compliant and LMConstraint
sofa_add_plugin(PreassembledMass PreassembledMass) # Depends on Flexible and Compliant
sofa_add_plugin(ExternalBehaviorModel ExternalBehaviorModel)
diff --git a/applications/plugins/LMConstraint/CMakeLists.txt b/applications/plugins/LMConstraint/CMakeLists.txt
deleted file mode 100644
index 0417b377d91..00000000000
--- a/applications/plugins/LMConstraint/CMakeLists.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-cmake_minimum_required(VERSION 3.12)
-project(LMConstraint VERSION 1.0 LANGUAGES CXX)
-
-sofa_find_package(SofaFramework REQUIRED)
-sofa_find_package(SofaBase REQUIRED)
-sofa_find_package(SofaImplicitOdeSolver REQUIRED)
-sofa_find_package(SofaConstraint REQUIRED)
-sofa_find_package(SofaMiscCollision REQUIRED)
-sofa_find_package(SofaDistanceGrid QUIET)
-
-# List all files
-set(LMCONSTRAINT_SRC_DIR src/LMConstraint)
-set(HEADER_FILES
- ${LMCONSTRAINT_SRC_DIR}/config.h.in
- ${LMCONSTRAINT_SRC_DIR}/BaseLMConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/BarycentricDistanceLMConstraintContact.h
- ${LMCONSTRAINT_SRC_DIR}/BarycentricDistanceLMConstraintContact.inl
- ${LMCONSTRAINT_SRC_DIR}/LMConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/LMConstraint.inl
- ${LMCONSTRAINT_SRC_DIR}/ContactDescription.h
- ${LMCONSTRAINT_SRC_DIR}/DOFBlockerLMConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/DOFBlockerLMConstraint.inl
- ${LMCONSTRAINT_SRC_DIR}/FixedLMConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/FixedLMConstraint.inl
- ${LMCONSTRAINT_SRC_DIR}/DistanceLMContactConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/DistanceLMContactConstraint.inl
- ${LMCONSTRAINT_SRC_DIR}/DistanceLMConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/DistanceLMConstraint.inl
- ${LMCONSTRAINT_SRC_DIR}/LMConstraintSolver.h
- ${LMCONSTRAINT_SRC_DIR}/LMConstraintDirectSolver.h
- ${LMCONSTRAINT_SRC_DIR}/MechanicalWriteLMConstraint.h
- ${LMCONSTRAINT_SRC_DIR}/PrecomputedLMConstraintCorrection.h
- ${LMCONSTRAINT_SRC_DIR}/PrecomputedLMConstraintCorrection.inl
-
- )
-
-set(SOURCE_FILES
- ${LMCONSTRAINT_SRC_DIR}/initLMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/BaseLMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/BarycentricDistanceLMConstraintContact.cpp
- ${LMCONSTRAINT_SRC_DIR}/LMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/DOFBlockerLMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/FixedLMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/DistanceLMContactConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/DistanceLMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/LMConstraintSolver.cpp
- ${LMCONSTRAINT_SRC_DIR}/LMConstraintDirectSolver.cpp
- ${LMCONSTRAINT_SRC_DIR}/MechanicalWriteLMConstraint.cpp
- ${LMCONSTRAINT_SRC_DIR}/PrecomputedLMConstraintCorrection.cpp
- ${LMCONSTRAINT_SRC_DIR}/TetrahedronBarycentricDistanceLMConstraintContact.cpp
- )
-
-if(SofaDistanceGrid_FOUND)
- list(APPEND SOURCE_FILES
- ${LMCONSTRAINT_SRC_DIR}/BarycentricDistanceLMConstraintContact_DistanceGrid.cpp
- )
-else()
- message(STATUS "SofaDistanceGrid not found: DistanceLM codes will not be compiled")
-endif()
-
-
-# Create the plugin library
-add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} )
-target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore SofaBaseLinearSolver SofaImplicitOdeSolver SofaHelper SofaDefaultType SofaConstraint SofaMiscCollision)
-
-if(SofaDistanceGrid_FOUND)
- target_link_libraries(${PROJECT_NAME} PUBLIC SofaDistanceGrid)
-endif()
-
-# Create package Config, Version & Target files.
-sofa_create_package_with_targets(
- PACKAGE_NAME ${PROJECT_NAME}
- PACKAGE_VERSION ${PROJECT_VERSION}
- TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
- INCLUDE_SOURCE_DIR "src"
- INCLUDE_INSTALL_DIR ${PROJECT_NAME}
- RELOCATABLE "plugins"
- )
diff --git a/applications/plugins/LMConstraint/LMConstraintConfig.cmake.in b/applications/plugins/LMConstraint/LMConstraintConfig.cmake.in
deleted file mode 100644
index 3d69ad9464c..00000000000
--- a/applications/plugins/LMConstraint/LMConstraintConfig.cmake.in
+++ /dev/null
@@ -1,23 +0,0 @@
-# CMake package configuration file for the plugin @PROJECT_NAME@
-
-@PACKAGE_GUARD@
-@PACKAGE_INIT@
-
-set(LMCONSTRAINT_HAVE_SOFADISTANCEGRID @LMCONSTRAINT_HAVE_SOFADISTANCEGRID@)
-
-find_package(SofaFramework REQUIRED)
-find_package(SofaBase REQUIRED)
-find_package(SofaImplicitOdeSolver REQUIRED)
-find_package(SofaConstraint REQUIRED)
-
-
-if(LMCONSTRAINT_HAVE_SOFADISTANCEGRID)
- find_package(SofaDistanceGrid REQUIRED)
-endif()
-
-
-if(NOT TARGET @PROJECT_NAME@)
- include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
-endif()
-
-check_required_components(@PROJECT_NAME@)
diff --git a/applications/plugins/LMConstraint/examples/DOFBlockerLMConstraint.scn b/applications/plugins/LMConstraint/examples/DOFBlockerLMConstraint.scn
deleted file mode 100644
index 8eeae97011a..00000000000
--- a/applications/plugins/LMConstraint/examples/DOFBlockerLMConstraint.scn
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/applications/plugins/LMConstraint/examples/DistanceLMConstraint.scn b/applications/plugins/LMConstraint/examples/DistanceLMConstraint.scn
deleted file mode 100644
index 2cf5cf7502a..00000000000
--- a/applications/plugins/LMConstraint/examples/DistanceLMConstraint.scn
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/applications/plugins/LMConstraint/examples/DistanceLMContactConstraint.scn b/applications/plugins/LMConstraint/examples/DistanceLMContactConstraint.scn
deleted file mode 100644
index 14ee1b28e4a..00000000000
--- a/applications/plugins/LMConstraint/examples/DistanceLMContactConstraint.scn
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/applications/plugins/LMConstraint/examples/DistanceLMContactConstraint_DirectSolver.scn b/applications/plugins/LMConstraint/examples/DistanceLMContactConstraint_DirectSolver.scn
deleted file mode 100644
index cbf1a1588b1..00000000000
--- a/applications/plugins/LMConstraint/examples/DistanceLMContactConstraint_DirectSolver.scn
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/applications/plugins/LMConstraint/examples/FixedLMConstraint.scn b/applications/plugins/LMConstraint/examples/FixedLMConstraint.scn
deleted file mode 100644
index 76037cba503..00000000000
--- a/applications/plugins/LMConstraint/examples/FixedLMConstraint.scn
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/applications/plugins/LMConstraint/examples/LMConstraintCollisionResponse.scn b/applications/plugins/LMConstraint/examples/LMConstraintCollisionResponse.scn
deleted file mode 100644
index e0839adc793..00000000000
--- a/applications/plugins/LMConstraint/examples/LMConstraintCollisionResponse.scn
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.cpp b/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.cpp
deleted file mode 100644
index 402ac012f2b..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace sofa::defaulttype;
-using namespace sofa::core::collision;
-
-namespace sofa::component::collision
-{
-
-using simulation::Node;
-
-Creator, SphereCollisionModel> > SphereSphereDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, PointCollisionModel> > SpherePointDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, PointCollisionModel> > PointPointDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, PointCollisionModel> > LinePointDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, LineCollisionModel> > LineLineDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, SphereCollisionModel> > LineSphereDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, SphereCollisionModel> > TriangleSphereDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, PointCollisionModel> > TrianglePointDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, LineCollisionModel> > TriangleLineDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator, TriangleCollisionModel> > TriangleTriangleDistanceLMConstraintContactClass("distanceLMConstraint",true);
-
-Creator, RigidSphereModel> > TriangleRigidSphereLMConstraintContactClass("distanceLMConstraint",true);
-Creator, PointCollisionModel> > TrianglePointLMConstraintContactClass("distanceLMConstraint",true);
-Creator, LineCollisionModel> > TriangleLineLMConstraintContactClass("distanceLMConstraint",true);
-Creator, TriangleCollisionModel> > TriangleTriangleLMConstraintContactClass("distanceLMConstraint",true);
-Creator, TriangleCollisionModel> > CapsuleTriangleLMConstraintContactClass("distanceLMConstraint",true);
-Creator, LineCollisionModel> > CapsuleLineLMConstraintContactClass("distanceLMConstraint",true);
-Creator, CapsuleCollisionModel> > CapsuleCapsuleLMConstraintContactClass("distanceLMConstraint",true);
-Creator, SphereCollisionModel> > CapsuleSphereLMConstraintContactClass("distanceLMConstraint",true);
-Creator, RigidSphereModel> > CapsuleRigidSphereLMConstraintContactClass("distanceLMConstraint",true);
-Creator, OBBCollisionModel> > OBBOBBLMConstraintContactClass("distanceLMConstraint",true);
-Creator, OBBCollisionModel> > CapsuleOBBLMConstraintContactClass("distanceLMConstraint",true);
-Creator, OBBCollisionModel> > SphereOBBLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > RigidSphereOBBLMConstraintContactClass("distanceLMConstraint",true);
-Creator, OBBCollisionModel> > TriangleOBBLMConstraintContactClass("distanceLMConstraint",true);
-
-
-Creator, TriangleCollisionModel> > RigidCapsuleTriangleLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, CapsuleCollisionModel> > RigidCapsuleRigidCapsuleLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, CapsuleCollisionModel> > CapsuleRigidCapsuleLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, SphereCollisionModel> > RigidCapsuleSphereLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, RigidSphereModel> > RigidCapsuleRigidSphereLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, OBBCollisionModel> > RigidCapsuleOBBLMConstraintContactClassClass("distanceLMConstraint",true);
-
-
-Creator, CylinderCollisionModel> > CylinderCylinderLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, TriangleCollisionModel> > CylinderTriangleLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, CapsuleCollisionModel> > CylinderRigidCapsuleLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, CylinderCollisionModel> > CapsuleCylinderLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, SphereCollisionModel> > CylinderSphereLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, RigidSphereModel> > CylinderRigidSphereLMConstraintContactClassClass("distanceLMConstraint",true);
-Creator, OBBCollisionModel> > CylinderOBBLMConstraintContactClassClass("distanceLMConstraint",true);
-
-} // namespace sofa::component::collision
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.h b/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.h
deleted file mode 100644
index 756199b65fc..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#ifdef __APPLE__
-// a strange behaviour of the mac's linker requires to compile a few stuffs again
-#include
-#include
-#endif
-
-
-namespace sofa::component::collision
-{
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes = sofa::defaulttype::Vec3Types >
-class BarycentricDistanceLMConstraintContact : public core::collision::Contact
-{
-public:
- SOFA_CLASS(SOFA_TEMPLATE3(BarycentricDistanceLMConstraintContact, TCollisionModel1, TCollisionModel2, ResponseDataTypes), core::collision::Contact);
- typedef TCollisionModel1 CollisionModel1;
- typedef TCollisionModel2 CollisionModel2;
- typedef core::collision::Intersection Intersection;
- typedef core::collision::DetectionOutputVector OutputVector;
- typedef core::collision::TDetectionOutputVector TOutputVector;
- typedef ResponseDataTypes DataTypes1;
- typedef ResponseDataTypes DataTypes2;
- typedef core::behavior::MechanicalState MechanicalState1;
- typedef core::behavior::MechanicalState MechanicalState2;
- typedef typename CollisionModel1::Element CollisionElement1;
- typedef typename CollisionModel2::Element CollisionElement2;
-
- // response type
- typedef constraintset::DistanceLMContactConstraint ResponseType;
-
-protected:
- CollisionModel1* model1;
- CollisionModel2* model2;
- Intersection* intersectionMethod;
-
- ContactMapper mapper1;
- ContactMapper mapper2;
-
- typename ResponseType::SPtr ff;
- core::objectmodel::BaseContext* parent;
-
- typedef std::map ContactIndexMap;
- /// Mapping of contactids to force element (+1, so that 0 means not active).
- /// This allows to ignore duplicate contacts, and preserve information associated with each contact point over time
- ContactIndexMap contactIndex;
-
- BarycentricDistanceLMConstraintContact(CollisionModel1* model1, CollisionModel2* model2, Intersection* intersectionMethod);
- ~BarycentricDistanceLMConstraintContact() override;
-
- void setInteractionTags(MechanicalState1* mstate1, MechanicalState2* mstate2);
-
-public:
-
-
-
- void cleanup() override;
-
- std::pair getCollisionModels() override { return std::make_pair(model1,model2); }
-
- void setDetectionOutputs(OutputVector* outputs) override;
-
- void createResponse(core::objectmodel::BaseContext* group) override;
-
- void removeResponse() override;
-
- void draw(const core::visual::VisualParams* vparams) override;
-};
-
-} // namespace sofa::component::collision
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.inl b/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.inl
deleted file mode 100644
index ab8a850f6b1..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact.inl
+++ /dev/null
@@ -1,232 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-#include
-
-namespace sofa::component::collision
-{
-
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-BarycentricDistanceLMConstraintContact::BarycentricDistanceLMConstraintContact(CollisionModel1* model1, CollisionModel2* model2, Intersection* intersectionMethod)
- : model1(model1), model2(model2), intersectionMethod(intersectionMethod), ff(nullptr), parent(nullptr)
-{
- mapper1.setCollisionModel(model1);
- mapper2.setCollisionModel(model2);
-}
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-BarycentricDistanceLMConstraintContact::~BarycentricDistanceLMConstraintContact()
-{
-}
-
-
-
-
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-void BarycentricDistanceLMConstraintContact::cleanup()
-{
- if (ff!=nullptr)
- {
- ff->cleanup();
- if (parent!=nullptr) parent->removeObject(ff);
- parent = nullptr;
- ff.reset();
- mapper1.cleanup();
- mapper2.cleanup();
- }
-}
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-void BarycentricDistanceLMConstraintContact::setDetectionOutputs(OutputVector* o)
-{
- TOutputVector& outputs = *static_cast(o);
- if (ff==nullptr)
- {
-
- MechanicalState1* mstate1 = mapper1.createMapping(GenerateStringID::generate().c_str());
- MechanicalState2* mstate2 = mapper2.createMapping(GenerateStringID::generate().c_str());
- ff = sofa::core::objectmodel::New(mstate1,mstate2);
- ff->setName( getName() );
- setInteractionTags(mstate1, mstate2);
- ff->init();
- }
-
- int insize = outputs.size();
-
- // old index for each contact
- // >0 indicate preexisting contact
- // 0 indicate new contact
- // -1 indicate ignored duplicate contact
- std::vector oldIndex(insize);
-
- int nbnew = 0;
-
- for (int i=0; iid];
- if (index < 0) // duplicate contact
- {
- int i2 = -1-index;
- core::collision::DetectionOutput* o2 = &outputs[i2];
- if (o2->value <= o->value)
- {
- // current contact is ignored
- oldIndex[i] = -1;
- continue;
- }
- else
- {
- // previous contact is replaced
- oldIndex[i] = oldIndex[i2];
- oldIndex[i2] = -1;
- }
- }
- else
- {
- oldIndex[i] = index;
- if (!index)
- {
- ++nbnew;
- msg_info() << " new contact "<id ;
- }
- }
- index = -1-i; // save this index as a negative value in contactIndex map.
- }
-
- // compute new index of each contact
- std::vector newIndex(insize);
- // number of final contacts used in the response
- int size = 0;
- for (int i=0; i= 0)
- {
- ++size;
- newIndex[i] = size;
- }
- }
-
- // update contactMap
- for (ContactIndexMap::iterator it = contactIndex.begin(), itend = contactIndex.end(); it != itend; )
- {
- int& index = it->second;
- if (index >= 0)
- {
- msg_info() << " removed contact "<first;
- ContactIndexMap::iterator oldit = it;
- ++it;
- contactIndex.erase(oldit);
- }
- else
- {
- index = newIndex[-1-index]; // write the final contact index
- ++it;
- }
- }
- msg_info() << " "<clear();
- mapper1.resize(size);
- mapper2.resize(size);
- for (int i=0; ielem.first);
- CollisionElement2 elem2(o->elem.second);
- int index1 = elem1.getIndex();
- int index2 = elem2.getIndex();
- typename DataTypes1::Real r1 = 0.0;
- typename DataTypes2::Real r2 = 0.0;
- // Create mapping for first point
- index1 = mapper1.addPointB(o->point[0], index1, r1);
- // Create mapping for second point
- index2 = mapper2.addPointB(o->point[1], index2, r2);
-
- ff->addContact(index1,index2);
- ff->contactFriction.setValue( elem1.getCollisionModel()->getContactFriction(0) * elem2.getCollisionModel()->getContactFriction(0) );
- // if all the elements belong to the same CollisionModels then ff->contactFriction should be done only once...
- }
- // Update mappings
- mapper1.update();
- mapper2.update();
-}
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-void BarycentricDistanceLMConstraintContact::createResponse(core::objectmodel::BaseContext* group)
-{
- if (ff!=nullptr)
- {
- if (parent!=nullptr)
- {
- parent->removeObject(this);
- parent->removeObject(ff);
- }
- parent = group;
- if (parent!=nullptr)
- {
- //msg_error() << "Attaching contact response to "<getName() ;
- parent->addObject(this);
- parent->addObject(ff);
- }
- }
-}
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-void BarycentricDistanceLMConstraintContact::removeResponse()
-{
- if (ff!=nullptr)
- {
- if (parent!=nullptr)
- {
- parent->removeObject(this);
- parent->removeObject(ff);
- }
- parent = nullptr;
- }
-}
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-void BarycentricDistanceLMConstraintContact::draw(const core::visual::VisualParams* )
-{
-}
-
-template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
-void BarycentricDistanceLMConstraintContact::setInteractionTags(MechanicalState1* mstate1, MechanicalState2* mstate2)
-{
- sofa::core::objectmodel::TagSet tagsm1 = mstate1->getTags();
- sofa::core::objectmodel::TagSet tagsm2 = mstate2->getTags();
- sofa::core::objectmodel::TagSet::iterator it;
- for(it=tagsm1.begin(); it != tagsm1.end(); ++it)
- ff->addTag(*it);
- for(it=tagsm2.begin(); it!=tagsm2.end(); ++it)
- ff->addTag(*it);
-}
-
-
-} // namespace sofa::component::collision
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact_DistanceGrid.cpp b/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact_DistanceGrid.cpp
deleted file mode 100644
index 2a3ed0311ea..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/BarycentricDistanceLMConstraintContact_DistanceGrid.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#include
-
-#include
-
-
-using namespace sofa::defaulttype;
-using namespace sofa::core::collision;
-
-namespace sofa
-{
-
-namespace component
-{
-
-namespace collision
-{
-
-Creator > DistanceGridDistanceGridDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > DistanceGridPointDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > DistanceGridSphereDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > DistanceGridTriangleDistanceLMConstraintContactClass("distanceLMConstraint",true);
-
-
-Creator > FFDDistanceGridDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator > FFDDistanceGridRigidDistanceGridDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > FFDDistanceGridPointDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > FFDDistanceGridSphereDistanceLMConstraintContactClass("distanceLMConstraint",true);
-Creator> > FFDDistanceGridTriangleDistanceLMConstraintContactClass("distanceLMConstraint",true);
-
-} // namespace collision
-
-} // namespace component
-
-} // namespace sofa
-
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/BaseLMConstraint.cpp b/applications/plugins/LMConstraint/src/LMConstraint/BaseLMConstraint.cpp
deleted file mode 100644
index a3b060ca843..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/BaseLMConstraint.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#include
-namespace sofa
-{
-
-namespace core
-{
-
-namespace behavior
-{
-//------------------------------------------------------------------------
-//ConstraintGroup
-
-ConstraintGroup::ConstraintGroup(ConstraintParams::ConstOrder idConstraint)
- : Order(idConstraint)
- , active(true)
-{
-}
-
-void ConstraintGroup::addConstraint( unsigned int &constraintId, unsigned int idx, SReal c)
-{
- equations.resize(equations.size()+1);
- ConstraintEquation &eq=equations.back();
-
- eq.idx = idx;
- eq.correction=c;
-
- eq.constraintId = constraintId;
- constraintId++;
-}
-//------------------------------------------------------------------------
-BaseLMConstraint::BaseLMConstraint()
- : pathObject1( initData(&pathObject1, "object1","First Object to constrain") ),
- pathObject2( initData(&pathObject2, "object2","Second Object to constrain") )
-{
-}
-
-unsigned int BaseLMConstraint::getNumConstraint(ConstraintParams::ConstOrder Order)
-{
- size_t result=0;
- const type::vector< ConstraintGroup* > &vec = constraintOrder[Order];
- for (size_t i=0; igetNumConstraint();
- return static_cast(result);
-}
-
-ConstraintGroup* BaseLMConstraint::addGroupConstraint(ConstraintParams::ConstOrder id)
-{
- ConstraintGroup *c = new ConstraintGroup(id);
- constraintOrder[id].push_back(c);
- return c;
-}
-
-void BaseLMConstraint::getConstraintViolation(const core::ConstraintParams* cparams, defaulttype::BaseVector *v)
-{
- getConstraintViolation(v,cparams->constOrder());
-}
-
-void BaseLMConstraint::getConstraintViolation(defaulttype::BaseVector * v, const sofa::core::ConstraintParams::ConstOrder Order)
-{
- const type::vector< ConstraintGroup* > &constraints = constraintOrder[Order];
- for (size_t idxGroupConstraint=0; idxGroupConstraint range=group->data();
-
- for (ConstraintGroup::EquationIterator equation = range.first; equation != range.second; ++equation)
- {
- v->set(equation->constraintId, equation->correction);
- }
- }
-
-}
-
-void BaseLMConstraint::resetConstraint()
-{
- std::map< ConstraintParams::ConstOrder, type::vector< ConstraintGroup*> >::iterator it;
- for (it=constraintOrder.begin(); it!=constraintOrder.end(); ++it)
- {
- type::vector< ConstraintGroup* > &v=it->second;
- for (size_t i=0; i. *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#ifndef SOFA_COMPONENT_CONSTRAINT_BASELMCONSTRAINT_H
-#define SOFA_COMPONENT_CONSTRAINT_BASELMCONSTRAINT_H
-
-#include
-#include
-#include
-
-namespace sofa
-{
-
-namespace core
-{
-
-namespace behavior
-{
-
-
-
-
-/**
- * \brief Expression of a line of the system created to solve the constraint
-*
-* @param idx index of the equation in the constraint equation system stored within the mechanical states
-* @param correction right hand term of the equation: corresponds to a correction we have to apply to the system
-* @param constraintId actual index of the line corresponding to the constraint equation in the whole system: can be different from idx
-**/
-struct LMCONSTRAINT_API ConstraintEquation
-{
- int idx;
- SReal correction;
- unsigned int constraintId;
-};
-
-
-
-
-
-/**
- * \brief Intern storage of the constraints.
- * a ConstraintGroup is a list of equations that will be solved together.
- * They are defined by a ConstOrder(position, velocity or acceleration)
- * @see ConstraintEquation
- * @see ConstOrder
- **/
-class LMCONSTRAINT_API ConstraintGroup
-{
- typedef sofa::type::vector< ConstraintEquation > VecEquations;
-public:
- typedef VecEquations::const_iterator EquationConstIterator;
- typedef VecEquations::iterator EquationIterator;
-
- ConstraintGroup(ConstraintParams::ConstOrder idConstraint);
- /**
- * Method to add an interaction constraint to the group
- *
- * @param idx index of the equation
- * @param c correction we need to apply in order to solve the constraint
- **/
- void addConstraint( unsigned int &constraintId, unsigned int idx, SReal c);
-
-
-
- /// Random Access to an equation
- const ConstraintEquation &getConstraint(const unsigned int i) const
- {
- EquationConstIterator it=equations.begin();
- std::advance(it,i);
- return *it;
- }
-
- ConstraintEquation &getConstraint(const unsigned int i)
- {
- EquationIterator it=equations.begin();
- std::advance(it,i);
- return *it;
- }
-
-
- /// Retrieve all the equations
- std::pair< EquationConstIterator,EquationConstIterator> data() const
- {
- return std::make_pair( equations.begin(), equations.end());
- }
-
- std::pair< EquationIterator,EquationIterator > data()
- {
- return std::make_pair( equations.begin(), equations.end());
- }
-
-
- /// Return the number of constraint contained in this group
- std::size_t getNumConstraint() const { return equations.size();}
-
- /// Return the order of the constraint
- /// @see ConstOrder
- ConstraintParams::ConstOrder getOrder() const { return Order;}
-
- bool isActive()const {return active;}
- void setActive(bool b) {active=b;}
-protected:
- /// Order of the constraint
- /// @see ConstOrder
- ConstraintParams::ConstOrder Order;
- VecEquations equations;
- bool active;
-};
-
-
-/**
- * \brief Object storing constraints base on Lagrangrian Multipliers.
- *
- * They can be constraint on acceleration, velocity, or position.
- * They can be grouped or individual. The resolution is then done in the OdeSolver.
- **/
-class LMCONSTRAINT_API BaseLMConstraint: public BaseConstraintSet
-{
-public:
- SOFA_ABSTRACT_CLASS(BaseLMConstraint, BaseConstraintSet);
-
-protected:
- BaseLMConstraint();
- ~BaseLMConstraint() override {}
-
-public:
-
- /// Called by MechanicalWriteLMConstaint: The Object will compute the constraints present in the current state, and create the ConstraintGroup related.
- virtual void writeConstraintEquations(unsigned int& lineNumber, MultiVecId id, ConstraintParams::ConstOrder order)=0;
-
- /// Compute the new Lagrange Multiplier given a block of the compliance matrix W, and the current correction (left hand term) and previous Lagrange Multiplier
- virtual void LagrangeMultiplierEvaluation(const SReal* /*W*/,
- const SReal* /*c*/, SReal* /*Lambda*/,
- ConstraintGroup * /*group*/) {}
-
-
- /// Get Right Hand Term
- void getConstraintViolation(const sofa::core::ConstraintParams*, defaulttype::BaseVector * /*v*/ ) override;
-
- using BaseConstraintSet::getConstraintViolation;
- // Override used in LMConstraintSolver::buildSystem method
- void getConstraintViolation(defaulttype::BaseVector *v, const core::ConstraintParams::ConstOrder );
-
-
- /// Get the internal structure: return all the constraint stored by their nature in a map
- virtual void getConstraints( std::map< ConstraintParams::ConstOrder, type::vector< ConstraintGroup* > > &i) { i=constraintOrder;}
- /// Get all the constraints stored of a given nature
- virtual const type::vector< ConstraintGroup* > &getConstraintsOrder(ConstraintParams::ConstOrder Order) const
- {
- constraintOrder_t::const_iterator c = constraintOrder.find( Order );
- if( c == constraintOrder.end())
- {
- static type::vector emptyVector;
- return emptyVector;
- }
- return c->second;
- }
-
-
- /// Get Left Hand Term for a given constraint group
- template
- void getEquationsUsed(const ConstraintGroup* group, DataStorage &used0) const
- {
- typedef ConstraintGroup::EquationConstIterator iterator_t;
- std::pair< iterator_t, iterator_t > range=group->data();
- for (iterator_t equation=range.first; equation!=range.second; ++equation) used0.push_back(equation->idx);
- }
-
- /// Get Left Hand Term for each ConstraintGroup of a given order
- template
- void getEquationsUsed(ConstraintParams::ConstOrder Order, DataStorage &used0) const
- {
- constraintOrder_t::const_iterator g = constraintOrder.find(Order);
- if (g == constraintOrder.end()) return;
-
- const type::vector< ConstraintGroup* > &constraints = g->second;
- for (unsigned int idxGroupConstraint=0; idxGroupConstraint > constraintOrder_t;
- constraintOrder_t constraintOrder;
-
- Data pathObject1; ///< First Object to constrain
- Data pathObject2; ///< Second Object to constrain
-};
-
-} // namespace behavior
-
-} // namespace core
-
-} // namespace sofa
-
-
-#endif
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/ContactDescription.h b/applications/plugins/LMConstraint/src/LMConstraint/ContactDescription.h
deleted file mode 100644
index ab964d4c668..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/ContactDescription.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-
-#include
-#include
-
-namespace sofa::component::constraintset
-{
-
-enum ContactState {VANISHING, STICKING, SLIDING};
-
-/// ContactDescription is a class providing precise information about the state of a contact
-/// A contact can be in 3 different states: vanishing, sticking, sliding
-/// with this states, we can solve precisely a contact, knowning its state, and the direction of the response
-struct ContactDescription
-{
- /// State of the contact
- /// @see ContactState
- ContactState state;
- /// When the contact is sliding, we have to know the direction of the reponse force.
- /// coeff is the linear combination of the normal, and two tangent constraint directions.
- SReal coeff[3];
-};
-
-
-/// Class handler to make the kink between constraint groups (a set of equations related to contact) and a description of the state of the contact
-class ContactDescriptionHandler
-{
- typedef std::map< const core::behavior::ConstraintGroup*, ContactDescription> InternalData;
-public:
- const ContactDescription& getContactDescription( const core::behavior::ConstraintGroup* contact) const
- {
- InternalData::const_iterator it = infos.find(contact);
- assert (it != infos.end());
- return it->second;
- }
- ContactDescription& getContactDescription(const core::behavior::ConstraintGroup* contact)
- {
- return infos[contact];
- }
-protected:
- InternalData infos;
-};
-
-} //namespace sofa::component::constraintset
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.cpp b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.cpp
deleted file mode 100644
index becc99f5e05..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#define SOFA_COMPONENT_CONSTRAINTSET_DOFBLOCKERLMCONSTRAINT_CPP
-#include
-#include
-#include
-#include
-
-namespace sofa::component::constraintset
-{
-
-using namespace sofa::defaulttype;
-using namespace sofa::helper;
-
-int DOFBlockerLMConstraintClass = core::RegisterObject("Constrain the rotation of a given set of Rigid Bodies")
- .add< DOFBlockerLMConstraint >()
- .add< DOFBlockerLMConstraint >()
-
- ;
-
-template class DOFBlockerLMConstraint;
-template class DOFBlockerLMConstraint;
-
-
-
-
-} //namespace sofa::component::constraintset
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h
deleted file mode 100644
index 7e495d672b2..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-
-#include
-#include
-#include
-#include
-
-
-namespace sofa::component::constraintset
-{
-
-
-/// This class can be overridden if needed for additionnal storage within template specializations.
-template
-class DOFBlockerLMConstraintInternalData
-{
-};
-
-
-
-
-/** Keep two particules at an initial distance
-*/
-template
-class DOFBlockerLMConstraint : public core::behavior::LMConstraint
-{
-public:
- SOFA_CLASS(SOFA_TEMPLATE(DOFBlockerLMConstraint,DataTypes),SOFA_TEMPLATE2(sofa::core::behavior::LMConstraint, DataTypes, DataTypes));
-
- using Index = sofa::Index;
- typedef typename DataTypes::VecCoord VecCoord;
- typedef typename DataTypes::Coord Coord;
- typedef typename DataTypes::VecDeriv VecDeriv;
- typedef typename DataTypes::Deriv Deriv;
- typedef typename DataTypes::MatrixDeriv MatrixDeriv;
- typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator;
- typedef typename core::behavior::MechanicalState MechanicalState;
-
-
- typedef sofa::component::topology::TopologySubsetIndices SetIndex;
- typedef type::vector SetIndexArray;
-
- typedef core::ConstraintParams::ConstOrder ConstOrder;
-
-
-protected:
- DOFBlockerLMConstraintInternalData data;
- friend class DOFBlockerLMConstraintInternalData;
-
-
- DOFBlockerLMConstraint(MechanicalState *dof = nullptr)
- : core::behavior::LMConstraint(dof, dof)
- , BlockedAxis(core::objectmodel::Base::initData(&BlockedAxis, "rotationAxis", "List of rotation axis to constrain"))
- , factorAxis(core::objectmodel::Base::initData(&factorAxis, "factorAxis", "Factor to apply in order to block only a certain amount of rotation along the axis"))
- , f_indices(core::objectmodel::Base::initData(&f_indices, "indices", "List of the index of particles to be fixed"))
- , showSizeAxis(core::objectmodel::Base::initData(&showSizeAxis, 1.0f, "showSizeAxis", "size of the vector used to display the constrained axis"))
- , l_topology(initLink("topology", "link to the topology container"))
- {
-
- }
-
- ~DOFBlockerLMConstraint()
- {
-
- }
-
-public:
- void clearConstraints();
- void addConstraint(Index index);
- void removeConstraint(Index index);
-
-
- void init() override;
- void draw(const core::visual::VisualParams* vparams) override;
- void resetConstraint() override;
-
- // -- LMConstraint interface
- void buildConstraintMatrix(const core::ConstraintParams* cParams, core::MultiMatrixDerivId cId, unsigned int &cIndex) override;
- void writeConstraintEquations(unsigned int& lineNumber, core::MultiVecId id, ConstOrder order) override;
-
- bool isCorrectionComputedWithSimulatedDOF(ConstOrder /*order*/) const override
- {
- simulation::Node* node=(simulation::Node*) this->constrainedObject1->getContext();
- if (node->mechanicalMapping.empty()) return true;
- else return false;
- }
-
- Data > BlockedAxis; ///< List of rotation axis to constrain
- Data > factorAxis; ///< Factor to apply in order to block only a certain amount of rotation along the axis
- SetIndex f_indices; ///< List of the index of particles to be fixed
- Data showSizeAxis; ///< size of the vector used to display the constrained axis
-
- /// Link to be set to the topology container in the component graph.
- SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
-
-protected :
- sofa::type::vector idxEquations;
-};
-
-#if !defined(SOFA_COMPONENT_CONSTRAINTSET_DOFBLOCKERLMCONSTRAINT_CPP)
-extern template class DOFBlockerLMConstraint;
-extern template class DOFBlockerLMConstraint;
-
-#endif
-
-} //namespace sofa::component::constraintset
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl b/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl
deleted file mode 100644
index 59976e2a24c..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/DOFBlockerLMConstraint.inl
+++ /dev/null
@@ -1,186 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-#include
-#include
-#include
-
-
-namespace sofa::component::constraintset
-{
-
-template
-void DOFBlockerLMConstraint::clearConstraints()
-{
- SetIndexArray& _indices = *f_indices.beginEdit();
- _indices.clear();
- f_indices.endEdit();
-}
-
-template
-void DOFBlockerLMConstraint::addConstraint(Index index)
-{
- f_indices.beginEdit()->push_back(index);
- f_indices.endEdit();
-}
-
-template
-void DOFBlockerLMConstraint::removeConstraint(Index index)
-{
- sofa::type::removeValue(*f_indices.beginEdit(),index);
- f_indices.endEdit();
-}
-
-
-template
-void DOFBlockerLMConstraint::init()
-{
- core::behavior::LMConstraint::init();
-
- if (l_topology.empty())
- {
- msg_info() << "link to Topology container should be set to ensure right behavior. First Topology found in current context will be used.";
- l_topology.set(this->getContext()->getMeshTopologyLink());
- }
-
- sofa::core::topology::BaseMeshTopology* _topology = l_topology.get();
-
- if (_topology)
- {
- msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'";
-
- // Initialize topological change handling
- f_indices.createTopologyHandler(_topology);
- }
- else
- {
- msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name;
- }
-}
-
-
-template
-void DOFBlockerLMConstraint::resetConstraint()
-{
- core::behavior::LMConstraint::resetConstraint();
- idxEquations.clear();
-}
-
-template
-void DOFBlockerLMConstraint::buildConstraintMatrix(const core::ConstraintParams* /*cParams*/, core::MultiMatrixDerivId cId, unsigned int &cIndex)
-{
- if(!idxEquations.empty() ) return;
-
- using namespace core::objectmodel;
- Data* dC = cId[this->constrainedObject1].write();
- helper::WriteAccessor > c = *dC;
-
- const SetIndexArray &indices = f_indices.getValue();
- const type::vector &axis=BlockedAxis.getValue();
- idxEquations.resize(indices.size());
- unsigned int numParticle=0;
-
- for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it, ++numParticle)
- {
- const Index index=*it;
- for (unsigned int i=0; iwriteLine(cIndex).addCol(index,axis[i]);
- idxEquations[numParticle].push_back(cIndex++);
- }
- }
-
-
-}
-
-template
-void DOFBlockerLMConstraint::writeConstraintEquations(unsigned int& lineNumber, core::MultiVecId id, ConstOrder Order)
-{
- using namespace core;
- using namespace core::objectmodel;
- //We don't constrain the Position, only the velocities and accelerations
- if (idxEquations.empty() ||
- Order==core::ConstraintParams::POS) return;
-
- const SetIndexArray & indices = f_indices.getValue();
- const type::vector &factor=factorAxis.getValue();
-
- for (unsigned int numParticle=0; numParticleaddGroupConstraint(Order);
- SReal correction=0;
- switch(Order)
- {
- case core::ConstraintParams::ACC :
- case core::ConstraintParams::VEL :
- {
- ConstVecId v1 = id.getId(this->constrainedObject1);
- correction = this->constrainedObject1->getConstraintJacobianTimesVecDeriv(idxEquations[numParticle][i],v1);
- break;
- }
- default: break;
- };
- if (!factor.empty())
- {
- if (i < factor.size()) correction*=factor[i];
- else correction*=factor.back();
- }
- constraint->addConstraint( lineNumber, idxEquations[numParticle][i], -correction);
- }
- }
-}
-
-template
-void DOFBlockerLMConstraint::draw(const core::visual::VisualParams* vparams)
-{
- if (!vparams->displayFlags().getShowForceFields()) return;
- const VecCoord& x =this->constrainedObject1->read(core::ConstVecCoordId::position())->getValue();
-
- vparams->drawTool()->saveLastState();
-
- const SetIndexArray & indices = f_indices.getValue();
- sofa::type::RGBAColor color = sofa::type::RGBAColor::yellow();
-
- for (SetIndexArray::const_iterator it = indices.begin();
- it != indices.end();
- ++it)
- {
- Index index=(*it);
- Coord pos=x[index];
- type::Vector3 position;
- DataTypes::get(position[0], position[1], position[2], pos);
- const type::vector& axis=BlockedAxis.getValue();
- for (unsigned int i=0; idrawTool()->drawArrow(position, position+direction*showSizeAxis.getValue(),
- showSizeAxis.getValue()*0.03,color);
- }
- }
- vparams->drawTool()->restoreLastState();
-}
-
-} //namespace sofa::component::constraintset
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.cpp b/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.cpp
deleted file mode 100644
index 2c007661bfc..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#define SOFA_COMPONENT_CONSTRAINTSET_DISTANCELMCONSTRAINT_CPP
-#include
-
-#include
-#include
-#include
-#include
-
-namespace sofa::component::constraintset
-{
-
-using namespace sofa::type;
-using namespace sofa::defaulttype;
-using namespace sofa::helper;
-
-///TODO: handle combinaison of Rigid and Deformable bodies.
-
-int DistanceLMConstraintClass = core::RegisterObject("Maintain constant the length of some edges of a pair of objects")
- .add< DistanceLMConstraint >()
- .add< DistanceLMConstraint >()
-
- ;
-
-template class LMCONSTRAINT_API DistanceLMConstraint;
-template class LMCONSTRAINT_API DistanceLMConstraint;
-
-
-
-//TODO(dmarchal) Yet again this ugly code duplication between float and double.
-// To fix this you can use the same design of UniformMass.
-template<>
-Rigid3Types::Deriv DistanceLMConstraint::getDirection(const Edge &e, const VecCoord &x1, const VecCoord &x2) const
-{
- Vector3 V12=(x2[e[1]].getCenter() - x1[e[0]].getCenter()); V12.normalize();
- return Deriv(V12, Vector3());
-}
-template<>
-void DistanceLMConstraint::draw(const core::visual::VisualParams* vparams)
-{
- if (this->l0.size() != vecConstraint.getValue().size()) updateRestLength();
-
- if (vparams->displayFlags().getShowBehaviorModels())
- {
- const VecCoord &x1= this->constrainedObject1->read(core::ConstVecCoordId::position())->getValue();
- const VecCoord &x2= this->constrainedObject2->read(core::ConstVecCoordId::position())->getValue();
-
- std::vector< Vector3 > points;
- const SeqEdges &edges = vecConstraint.getValue();
- for (unsigned int i=0; idrawTool()->drawLines(points, 1, sofa::type::RGBAColor::green());
- }
-}
-
-
-} //namespace sofa::component::constraintset
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.h b/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.h
deleted file mode 100644
index ce300c28204..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-
-#include
-
-#include
-#include
-#include
-
-namespace sofa::component::constraintset
-{
-
-/// This class can be overridden if needed for additionnal storage within template specializations.
-template
-class DistanceLMConstraintInternalData
-{
-};
-
-
-
-
-/** Keep two particules at an initial distance
-*/
-template
-class DistanceLMConstraint : public core::behavior::LMConstraint
-{
-public:
- SOFA_CLASS(SOFA_TEMPLATE(DistanceLMConstraint,DataTypes),SOFA_TEMPLATE2(sofa::core::behavior::LMConstraint, DataTypes, DataTypes));
-
- typedef typename DataTypes::VecCoord VecCoord;
- typedef typename DataTypes::VecDeriv VecDeriv;
- typedef typename DataTypes::Deriv Deriv;
- typedef typename DataTypes::MatrixDeriv MatrixDeriv;
- typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator;
- typedef typename core::behavior::MechanicalState MechanicalState;
-
- typedef typename sofa::core::topology::BaseMeshTopology::SeqEdges SeqEdges;
- typedef typename sofa::core::topology::BaseMeshTopology::Edge Edge;
-
- typedef core::ConstraintParams::ConstOrder ConstOrder;
-
-protected:
- DistanceLMConstraintInternalData data;
- friend class DistanceLMConstraintInternalData;
-
- DistanceLMConstraint();
- DistanceLMConstraint( MechanicalState *dof);
- DistanceLMConstraint( MechanicalState *dof1, MechanicalState * dof2);
-
- ~DistanceLMConstraint() {}
-public:
- void init() override;
- void reinit() override;
-
- // -- LMConstraint interface
-
- void buildConstraintMatrix(const core::ConstraintParams* cParams, core::MultiMatrixDerivId cId, unsigned int &cIndex) override;
- void writeConstraintEquations(unsigned int& lineNumber, core::MultiVecId id, ConstOrder order) override;
-
- void draw(const core::visual::VisualParams* vparams) override;
-
- bool isCorrectionComputedWithSimulatedDOF(core::ConstraintParams::ConstOrder /*order*/) const override;
-
- //Edges involving a distance constraint
- Data< SeqEdges > vecConstraint; ///< List of the edges to constrain
-
- /// Link to be set to the topology container in the component graph.
- SingleLink , sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
-protected :
-
- ///Compute the length of an edge given the vector of coordinates corresponding
- double lengthEdge(const Edge &e, const VecCoord &x1,const VecCoord &x2) const;
- ///Compute the direction of the constraint
- Deriv getDirection(const Edge &e, const VecCoord &x1, const VecCoord &x2) const;
- void updateRestLength();
-
- type::vector< unsigned int > registeredConstraints;
-
- // rest length pre-computated
- sofa::type::vector< double > l0;
-};
-
-template<>
-defaulttype::Rigid3Types::Deriv DistanceLMConstraint::getDirection(const Edge &e, const VecCoord &x1, const VecCoord &x2) const;
-
-
-#if !defined(SOFA_COMPONENT_CONSTRAINTSET_DISTANCELMCONSTRAINT_CPP)
-extern template class LMCONSTRAINT_API DistanceLMConstraint;
-extern template class LMCONSTRAINT_API DistanceLMConstraint;
-
-#endif
-
-} //namespace sofa::component::constraintset
diff --git a/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.inl b/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.inl
deleted file mode 100644
index 0e559f5e3e4..00000000000
--- a/applications/plugins/LMConstraint/src/LMConstraint/DistanceLMConstraint.inl
+++ /dev/null
@@ -1,234 +0,0 @@
-/******************************************************************************
-* SOFA, Simulation Open-Framework Architecture *
-* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU Lesser General Public License as published by *
-* the Free Software Foundation; either version 2.1 of the License, or (at *
-* your option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but WITHOUT *
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
-* for more details. *
-* *
-* You should have received a copy of the GNU Lesser General Public License *
-* along with this program. If not, see . *
-*******************************************************************************
-* Authors: The SOFA Team and external contributors (see Authors.txt) *
-* *
-* Contact information: contact@sofa-framework.org *
-******************************************************************************/
-#pragma once
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-namespace sofa::component::constraintset
-{
-
-template
-DistanceLMConstraint::DistanceLMConstraint( MechanicalState *dof1, MechanicalState * dof2)
- : core::behavior::LMConstraint(dof1,dof2)
- , vecConstraint(sofa::core::objectmodel::Base::initData(&vecConstraint, "vecConstraint", "List of the edges to constrain"))
- , l_topology(initLink("topology", "link to the topology container"))
-{
-}
-
-template
-DistanceLMConstraint::DistanceLMConstraint( MechanicalState *dof)
- : DistanceLMConstraint(dof,dof)
-{
-}
-
-template
-DistanceLMConstraint::DistanceLMConstraint()
- : DistanceLMConstraint(nullptr, nullptr)
-{
-}
-
-template
-void DistanceLMConstraint::init()
-{
- sofa::core::behavior::LMConstraint::init();
-
- // TODO epenod 2019-12-05: Adapt code to not look for topology if constraint is manually set. Need to dig more in the code to understand how topology is used.
- if (vecConstraint.getValue().size() != 0)
- {
- // nothing to do in this case
- return;
- }
-
- if (l_topology.empty())
- {
- msg_info() << "link to Topology container should be set to ensure right behavior. First Topology found in current context will be used.";
- l_topology.set(this->getContext()->getMeshTopologyLink());
- }
-
- core::topology::BaseMeshTopology *_topology = l_topology.get();
- msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'";
-
- if (!_topology)
- {
- msg_error() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name;
- sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
- return;
- }
-
- if (vecConstraint.getValue().size() == 0 && (this->constrainedObject1==this->constrainedObject2) )
- vecConstraint.setValue(_topology->getEdges());
-}
-
-template
-void DistanceLMConstraint::reinit()
-{
- updateRestLength();
-}
-
-template
-double DistanceLMConstraint::lengthEdge(const Edge &e, const VecCoord &x1, const VecCoord &x2) const
-{
- return (x2[e[1]] - x1[e[0]]).norm();
-}
-
-template
-void DistanceLMConstraint::updateRestLength()
-{
- const VecCoord &x0_1= this->constrainedObject1->read(core::ConstVecCoordId::position())->getValue();
- const VecCoord &x0_2= this->constrainedObject2->read(core::ConstVecCoordId::position())->getValue();
- const SeqEdges &edges = vecConstraint.getValue();
- this->l0.resize(edges.size());
- for (unsigned int i=0; i