diff --git a/applications/collections/deprecated/modules/SofaGraphComponent/CMakeLists.txt b/applications/collections/deprecated/modules/SofaGraphComponent/CMakeLists.txt deleted file mode 100644 index 2bc029b92793..000000000000 --- a/applications/collections/deprecated/modules/SofaGraphComponent/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -cmake_minimum_required(VERSION 3.22) -project(SofaGraphComponent LANGUAGES CXX) - -sofa_find_package(SofaBase REQUIRED) - -set(SOFAGRAPHCOMPONENT_SRC "src/${PROJECT_NAME}") - -set(HEADER_FILES - ${SOFAGRAPHCOMPONENT_SRC}/config.h.in - ${SOFAGRAPHCOMPONENT_SRC}/initSofaGraphComponent.h - ) - -set(SOURCE_FILES - ${SOFAGRAPHCOMPONENT_SRC}/initSofaGraphComponent.cpp - ) - -list(APPEND HEADER_FILES - ${SOFAGRAPHCOMPONENT_SRC}/Gravity.h - ${SOFAGRAPHCOMPONENT_SRC}/InteractingBehaviorModel.h - ) -list(APPEND SOURCE_FILES - ${SOFAGRAPHCOMPONENT_SRC}/Gravity.cpp - ) - - -add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Helper Sofa.Simulation.Core SofaBaseUtils SofaBaseCollision) - -#message(WARNING "${PROJECT_NAME} module is deprecated. It will be removed at v23.06. Use Sofa.Component.SceneUtility, Sofa.Component.Setting, -#Sofa.GUI.Component and the plugin SceneChecking instead.") - -# forward to the new sofang module -sofa_find_package(Sofa.Component.SceneUtility REQUIRED) -sofa_find_package(Sofa.Component.Setting REQUIRED) -sofa_find_package(Sofa.GUI.Component REQUIRED) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.SceneUtility) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Setting) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.GUI.Component) - -sofa_create_package_with_targets( - PACKAGE_NAME ${PROJECT_NAME} - PACKAGE_VERSION ${Sofa_VERSION} - TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES - INCLUDE_SOURCE_DIR "src" - INCLUDE_INSTALL_DIR "${PROJECT_NAME}" - RELOCATABLE "collections" -) diff --git a/applications/collections/deprecated/modules/SofaGraphComponent/README.md b/applications/collections/deprecated/modules/SofaGraphComponent/README.md deleted file mode 100644 index aadb1e573da2..000000000000 --- a/applications/collections/deprecated/modules/SofaGraphComponent/README.md +++ /dev/null @@ -1 +0,0 @@ -# SofaGraphComponent \ No newline at end of file diff --git a/applications/collections/deprecated/modules/SofaGraphComponent/SofaGraphComponentConfig.cmake.in b/applications/collections/deprecated/modules/SofaGraphComponent/SofaGraphComponentConfig.cmake.in deleted file mode 100644 index 318ba4b526f0..000000000000 --- a/applications/collections/deprecated/modules/SofaGraphComponent/SofaGraphComponentConfig.cmake.in +++ /dev/null @@ -1,23 +0,0 @@ -# CMake package configuration file for @PROJECT_NAME@ - -if(NOT "${CMAKE_PROJECT_NAME}" STREQUAL "Sofa" OR NOT "${PROJECT_SOURCE_DIR}" MATCHES "${CMAKE_SOURCE_DIR}/.*") - # The project doing find_package is not a subproject of SOFA or is not located inside SOFA - get_property(@PROJECT_NAME@_SENT_DEPRECATION_MESSAGE GLOBAL PROPERTY PROPERTY_@PROJECT_NAME@_SENT_DEPRECATION_MESSAGE SET) - if(NOT @PROJECT_NAME@_SENT_DEPRECATION_MESSAGE) - message(WARNING "@PROJECT_NAME@ module is deprecated. It will be removed at v23.06. Use Sofa.Component.SceneUtility, Sofa.Component.Setting and Sofa.GUI.Component instead.") - endif() - set_property(GLOBAL PROPERTY PROPERTY_@PROJECT_NAME@_SENT_DEPRECATION_MESSAGE TRUE) -endif() - -@PACKAGE_GUARD@ -@PACKAGE_INIT@ - -find_package(SofaBase QUIET REQUIRED) -find_package(Sofa.Component.SceneUtility QUIET REQUIRED) -find_package(Sofa.Component.Setting QUIET REQUIRED) -find_package(Sofa.GUI.Component QUIET REQUIRED) - -if(NOT TARGET @PROJECT_NAME@) - include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") -endif() -check_required_components(@PROJECT_NAME@) diff --git a/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/config.h.in b/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/config.h.in deleted file mode 100644 index c1a5096dc718..000000000000 --- a/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/config.h.in +++ /dev/null @@ -1,34 +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 - -#define SOFAGRAPHCOMPONENT_VERSION @PROJECT_VERSION@ - -#ifdef SOFA_BUILD_SOFAGRAPHCOMPONENT -# define SOFA_TARGET @PROJECT_NAME@ -# define SOFA_SOFAGRAPHCOMPONENT_API SOFA_EXPORT_DYNAMIC_LIBRARY -#else -# define SOFA_SOFAGRAPHCOMPONENT_API SOFA_IMPORT_DYNAMIC_LIBRARY -#endif \ No newline at end of file diff --git a/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/initSofaGraphComponent.cpp b/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/initSofaGraphComponent.cpp deleted file mode 100644 index 5f5903672bbe..000000000000 --- a/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/initSofaGraphComponent.cpp +++ /dev/null @@ -1,88 +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 -using sofa::core::ObjectFactory; - -namespace sofa::component -{ - -void initSofaGraphComponent() -{ - static bool first = true; - if (first) - { - msg_deprecated("SofaGraphComponent") << "SofaGraphComponent is deprecated. It will be removed at v23.06. Use Sofa.Component.SceneUtility, Sofa.Component.Setting and Sofa.GUI.Component instead."; - - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.SceneUtility"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Setting"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.GUI.Component"); - - first = false; - } -} - -extern "C" { - SOFA_SOFAGRAPHCOMPONENT_API void initExternalModule(); - SOFA_SOFAGRAPHCOMPONENT_API const char* getModuleName(); - SOFA_SOFAGRAPHCOMPONENT_API const char* getModuleVersion(); - SOFA_SOFAGRAPHCOMPONENT_API const char* getModuleLicense(); - SOFA_SOFAGRAPHCOMPONENT_API const char* getModuleDescription(); - SOFA_SOFAGRAPHCOMPONENT_API const char* getModuleComponentList(); -} - -void initExternalModule() -{ - initSofaGraphComponent(); -} - -const char* getModuleName() -{ - return sofa_tostring(SOFA_TARGET); -} - -const char* getModuleVersion() -{ - return sofa_tostring(SOFAGRAPHCOMPONENT_VERSION); -} - -const char* getModuleLicense() -{ - return "LGPL"; -} - -const char* getModuleDescription() -{ - return "This plugin contains contains features about General Visual."; -} - -const char* getModuleComponentList() -{ - /// string containing the names of the classes provided by the plugin - static std::string classes = ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET)); - return classes.c_str(); -} - -} // namespace sofa::component diff --git a/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/initSofaGraphComponent.h b/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/initSofaGraphComponent.h deleted file mode 100644 index 5d6e90612937..000000000000 --- a/applications/collections/deprecated/modules/SofaGraphComponent/src/SofaGraphComponent/initSofaGraphComponent.h +++ /dev/null @@ -1,31 +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 - -namespace sofa::component -{ - -void SOFA_SOFAGRAPHCOMPONENT_API initSofaGraphComponent(); - -} // namespace sofa::component diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/CMakeLists.txt b/applications/collections/deprecated/modules/SofaMiscCollision/CMakeLists.txt deleted file mode 100644 index 1582a7214dc1..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -cmake_minimum_required(VERSION 3.22) -project(SofaMiscCollision VERSION 1.0) - -sofa_find_package(SofaBaseCollision REQUIRED) -sofa_find_package(SofaBaseMechanics REQUIRED) -sofa_find_package(SofaBaseTopology REQUIRED) -sofa_find_package(SofaGeneralMeshCollision REQUIRED) -sofa_find_package(SofaGeneralDeformable REQUIRED) -sofa_find_package(SofaConstraint REQUIRED) -sofa_find_package(SofaExplicitOdeSolver REQUIRED) -sofa_find_package(SofaGeneralExplicitOdeSolver REQUIRED) -sofa_find_package(SofaImplicitOdeSolver REQUIRED) - -set(SOFAMISCCOLLISION_SRC src/SofaMiscCollision) - -set(HEADER_FILES - ${SOFAMISCCOLLISION_SRC}/config.h.in - ${SOFAMISCCOLLISION_SRC}/initSofaMiscCollision.h - ) - -set(SOURCE_FILES - ${SOFAMISCCOLLISION_SRC}/initSofaMiscCollision.cpp - ) - -set(EXTRA_FILES - ${SOFAMISCCOLLISION_SRC}/README.md - ) - -list(APPEND HEADER_FILES - ${SOFAMISCCOLLISION_SRC}/DefaultCollisionGroupManager.h - ${SOFAMISCCOLLISION_SRC}/RayTriangleVisitor.h - ${SOFAMISCCOLLISION_SRC}/SolverMerger.h -) - -list(APPEND SOURCE_FILES - - ${SOFAMISCCOLLISION_SRC}/DefaultCollisionGroupManager.cpp - ${SOFAMISCCOLLISION_SRC}/RayTriangleVisitor.cpp - ${SOFAMISCCOLLISION_SRC}/SolverMerger.cpp - -) - -add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${EXTRA_FILES}) -target_link_libraries(${PROJECT_NAME} PUBLIC SofaBaseTopology SofaGeneralMeshCollision SofaGeneralDeformable SofaConstraint SofaExplicitOdeSolver SofaGeneralExplicitOdeSolver SofaImplicitOdeSolver SofaBaseCollision SofaBaseMechanics) - -#message(WARNING "${PROJECT_NAME} module is deprecated. It will be removed at v23.06. Use Sofa.Component.Collision.Geometry, Sofa.Component.Collision.Detection.Intersection and Sofa.Component.Collision.Response.Contact instead. -# Moreover, OBB and Capsule-related components have been moved into the external plugin CollisionOBBCapsule.") - -# forward to the new sofang module -sofa_find_package(Sofa.Component.Collision.Geometry REQUIRED) -sofa_find_package(Sofa.Component.Collision.Detection.Intersection REQUIRED) -sofa_find_package(Sofa.Component.Collision.Response.Contact REQUIRED) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Collision.Geometry) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Collision.Detection.Intersection) -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Collision.Response.Contact) - -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 "collections" - ) - -# Tests -# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled -cmake_dependent_option(SOFAMISCCOLLISION_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF) -if(SOFAMISCCOLLISION_BUILD_TESTS) - enable_testing() - add_subdirectory(SofaMiscCollision_test) -endif() diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollisionConfig.cmake.in b/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollisionConfig.cmake.in deleted file mode 100644 index 32e01b6511ee..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollisionConfig.cmake.in +++ /dev/null @@ -1,34 +0,0 @@ -# CMake package configuration file for @PROJECT_NAME@ - -if(NOT "${CMAKE_PROJECT_NAME}" STREQUAL "Sofa" OR NOT "${PROJECT_SOURCE_DIR}" MATCHES "${CMAKE_SOURCE_DIR}/.*") - # The project doing find_package is not a subproject of SOFA or is not located inside SOFA - get_property(@PROJECT_NAME@_SENT_DEPRECATION_MESSAGE GLOBAL PROPERTY PROPERTY_@PROJECT_NAME@_SENT_DEPRECATION_MESSAGE SET) - if(NOT @PROJECT_NAME@_SENT_DEPRECATION_MESSAGE) - message(WARNING "@PROJECT_NAME@ module is deprecated. It will be removed at v23.06. Use Sofa.Component.Collision.Geometry, Sofa.Component.Collision.Detection.Intersection and Sofa.Component.Collision.Response.Contact instead. Moreover, OBB and Capsule-related components have been moved into the external plugin CollisionOBBCapsule.") - endif() - set_property(GLOBAL PROPERTY PROPERTY_@PROJECT_NAME@_SENT_DEPRECATION_MESSAGE TRUE) -endif() - -@PACKAGE_GUARD@ -@PACKAGE_INIT@ - -find_package(SofaBaseCollision QUIET REQUIRED) -find_package(SofaBaseTopology QUIET REQUIRED) -find_package(SofaGeneralMeshCollision QUIET REQUIRED) -find_package(SofaGeneralDeformable QUIET REQUIRED) -find_package(SofaConstraint QUIET REQUIRED) -find_package(SofaExplicitOdeSolver QUIET REQUIRED) -find_package(SofaGeneralExplicitOdeSolver QUIET REQUIRED) -find_package(SofaImplicitOdeSolver QUIET REQUIRED) - -find_package(Sofa.Component.Collision.Geometry QUIET REQUIRED) -find_package(Sofa.Component.Collision.Detection.Intersection QUIET REQUIRED) -find_package(Sofa.Component.Collision.Response.Contact QUIET REQUIRED) - -if(NOT TARGET SofaMiscCollision) - include("${CMAKE_CURRENT_LIST_DIR}/SofaMiscCollisionTargets.cmake") -endif() - -check_required_components(SofaMiscCollision) -set(SofaMiscCollision_LIBRARIES SOFAMISCCOLLISION) -set(SofaMiscCollision_INCLUDE_DIRS @PACKAGE_SOFAMISCCOLLISION_INCLUDE_DIR@ ${SOFAMISCCOLLISION_INCLUDE_DIR}) diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/CMakeLists.txt b/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/CMakeLists.txt deleted file mode 100644 index bf64bbe493b2..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.22) -project(SofaMiscCollision_test) - -set(HEADER_FILES -) - -set(SOURCE_FILES - DefaultCollisionGroupManager_test.cpp -) - -add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES}) -add_definitions("-DSOFAMISCCOLLISION_TEST_SCENES_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/scenes\"") -target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Testing Sofa.Component.Collision.Testing SofaMiscCollision - SofaBase SofaGeneralDeformable SofaImplicitOdeSolver SofaTopologyMapping SofaLoader) - -add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/DefaultCollisionGroupManager_test.cpp b/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/DefaultCollisionGroupManager_test.cpp deleted file mode 100644 index 8df65f4ce69a..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/DefaultCollisionGroupManager_test.cpp +++ /dev/null @@ -1,109 +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 sofa::testing::BaseTest; - -#include -using sofa::component::collision::DefaultCollisionGroupManager; - -#include - -#include -#include - -namespace sofa -{ - -struct DefaultCollisionGroupManager_test : public BaseTest -{ - void onSetUp() override; - void onTearDown() override; - - bool combineSingleObject(); - -private: - /// Root of the scene graph - simulation::Node::SPtr root { nullptr }; - /// Simulation - simulation::Simulation* simulation { nullptr }; -}; - -void DefaultCollisionGroupManager_test::onSetUp() -{ - sofa::component::initSofaBase(); - - static const std::string sceneFilename = std::string(SOFAMISCCOLLISION_TEST_SCENES_DIR) - + "/DefaultCollisionGroupManager_singleObject_test.scn"; - - // Init simulation - simulation = sofa::simulation::getSimulation(); - root = sofa::simulation::node::load(sceneFilename.c_str()); -} - -void DefaultCollisionGroupManager_test::onTearDown() -{ - if (root != nullptr) - { - sofa::simulation::node::unload(root); - } -} - -bool DefaultCollisionGroupManager_test::combineSingleObject() -{ - EXPECT_TRUE(root != nullptr); - EXPECT_TRUE(sofa::simulation::getSimulation() != nullptr); - - sofa::simulation::node::initRoot(root.get()); - - // run 200 time steps - // objectives: - // 1) The simulation does not crash - // 2) Collision prevents the cube to fall through the floor - for (unsigned int i = 0; i < 200; ++i) - { - sofa::simulation::node::animate(root.get(), 0.01); - } - - auto* baseObject = root->getTreeNode("Cube1")->getObject("mechanicalObject"); - EXPECT_NE(baseObject, nullptr); - - auto* mechanicalObject = dynamic_cast*>(baseObject); - EXPECT_NE(mechanicalObject, nullptr); - - const auto position = mechanicalObject->readPositions(); - EXPECT_FALSE(position.empty()); - - // Check that the position of the first DOF is not below the floor - EXPECT_GT(position->front().y(), -15.); - - return true; -} - -TEST_F(DefaultCollisionGroupManager_test, combine) -{ - ASSERT_TRUE(combineSingleObject()); -} - -} diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/scenes/DefaultCollisionGroupManager_singleObject_test.scn b/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/scenes/DefaultCollisionGroupManager_singleObject_test.scn deleted file mode 100644 index 93e9a1069b0c..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/SofaMiscCollision_test/scenes/DefaultCollisionGroupManager_singleObject_test.scn +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.html b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.html deleted file mode 100644 index 63218b984171..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -
-

Dynamic Collision Groups

-
- -
Description

- -
Key points

- -
Results

-
-
- - diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.png b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.png deleted file mode 100644 index 25c6b6bc214c..000000000000 Binary files a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.png and /dev/null differ diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.scn b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.scn deleted file mode 100644 index d4593212f30e..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups.scn +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups_init.png b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups_init.png deleted file mode 100644 index 6b4a944237cf..000000000000 Binary files a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsDynamicCollisionGroups_init.png and /dev/null differ diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.html b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.html deleted file mode 100644 index 76a329f727b9..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -
-

Static Collision Groups

-
- -
Description

- -
Key points

- -
Results

-
-
- - diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.png b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.png deleted file mode 100644 index 3b71316b9a1d..000000000000 Binary files a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.png and /dev/null differ diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.scn b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.scn deleted file mode 100644 index 4ca7f6dc08b7..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups.scn +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups_init.png b/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups_init.png deleted file mode 100644 index 3f69deafc307..000000000000 Binary files a/applications/collections/deprecated/modules/SofaMiscCollision/examples/MultipleObjectsStaticCollisionGroups_init.png and /dev/null differ diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/DefaultCollisionGroupManager.cpp b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/DefaultCollisionGroupManager.cpp deleted file mode 100644 index 0e393f0821f2..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/DefaultCollisionGroupManager.cpp +++ /dev/null @@ -1,438 +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 - -namespace sofa::component::collision -{ - -using core::collision::Contact; -using core::objectmodel::BaseNode; - - -int DefaultCollisionGroupManagerClass = core::RegisterObject("Responsible for gathering colliding objects in the same group, for consistent time integration") - .add< DefaultCollisionGroupManager >() - .addAlias( "CollisionGroupManager" ) - .addAlias( "CollisionGroup" ) - .addAlias( "TreeCollisionGroupManager" ) // for backward compatibility with old scene files but could be removed - ; - -DefaultCollisionGroupManager::DefaultCollisionGroupManager() = default; -DefaultCollisionGroupManager::~DefaultCollisionGroupManager() = default; - -void DefaultCollisionGroupManager::clearCollisionGroup(simulation::Node::SPtr group) -{ - const simulation::Node::Parents &parents = group->getParents(); - core::objectmodel::BaseNode::SPtr parent = *parents.begin(); - while (!group->child.empty()) - parent->moveChild(core::objectmodel::BaseNode::SPtr(group->child.begin()->get()->toBaseNode())); - - simulation::CleanupVisitor cleanupvis(sofa::core::execparams::defaultInstance()); - cleanupvis.execute(group.get()); - simulation::DeleteVisitor vis(sofa::core::execparams::defaultInstance()); - vis.execute(group.get()); - group->detachFromGraph(); - group.reset(); -} - - -void DefaultCollisionGroupManager::changeInstance(Instance inst) -{ - core::collision::CollisionGroupManager::changeInstance(inst); - storedGroupSet[instance].swap(groupMap); - groupMap.swap(storedGroupSet[inst]); -} - -void DefaultCollisionGroupManager::createGroups(core::objectmodel::BaseContext* scene, const sofa::type::vector& contacts) -{ - SCOPED_TIMER("CreateGroups"); - - int groupIndex = 1; - - // Map storing group merging history - // key: node which has been moved into the node in value - // value: node which received the content of the node in key - MergeGroupsMap mergedGroups; - - // list of nodes that must be removed due to a move from a node to another - sofa::type::vector< simulation::Node::SPtr > removedGroup; - - sofa::type::vector< std::pair > contactGroup; - - //list of contacts considered stationary: one of the collision model has no associated ODE solver (= stationary) - //for stationary contacts, no need to combine nodes into a single ODE solver - sofa::type::vector< Contact* > stationaryContacts; - - for (const auto& contact : contacts) - { - createGroup(contact.get(), groupIndex, mergedGroups, contactGroup, removedGroup, stationaryContacts); - } - - // create contact response for stationary contacts - for (auto* contact : stationaryContacts) - { - contact->createResponse(scene); - } - - // now that the groups are final, attach contacts' response - // note: contact responses must be created in the same order than the contact list - // This is to ensure the reproducibility of the simulation - for (const auto& [contact, group] : contactGroup) - { - simulation::Node* g = getNodeFromMergedGroups(group.get(), mergedGroups); - if (g != nullptr) - { - contact->createResponse(g); - } - else - { - contact->createResponse(scene); - } - } - - // delete removed groups - for (auto& node : removedGroup) - { - node->detachFromGraph(); - node->execute(sofa::core::execparams::defaultInstance()); - node.reset(); - } - removedGroup.clear(); - - // finally recreate group vector - groups.clear(); - for (auto& g : contactGroup) - { - if (g.second) - { - groups.push_back(g.second); - } - } -} - -void DefaultCollisionGroupManager::createGroup(core::collision::Contact* contact, - int& groupIndex, - MergeGroupsMap& mergedGroups, - sofa::type::vector< std::pair >& contactGroup, - sofa::type::vector< simulation::Node::SPtr >& removedGroup, - sofa::type::vector< core::collision::Contact* >& stationaryContacts) -{ - const auto contactCollisionModels = contact->getCollisionModels(); - core::CollisionModel* cm_1 = contactCollisionModels.first; - core::CollisionModel* cm_2 = contactCollisionModels.second; - - simulation::Node* group1 = getIntegrationNode(cm_1); //Node containing the ODE solver associated to cm_1 - simulation::Node* group2 = getIntegrationNode(cm_2); //Node containing the ODE solver associated to cm_1 - - if (group1 == nullptr || group2 == nullptr) - { - // one of the object does not have an associated ODE solver - // this can happen for stationary objects - stationaryContacts.push_back(contact); - return; - } - - simulation::Node::SPtr collGroup = nullptr; - if (group1 == group2) - { - // both collision models share the same group: no new group necessary - collGroup = group1; - } - else if (simulation::Node* commonParent = group1->findCommonParent(group2)) - { - const bool isSolverEmpty1 = group1->solver.empty(); - const bool isSolverEmpty2 = group2->solver.empty(); - - // we can merge the groups - // if solvers are compatible... - const bool mergeSolvers = !isSolverEmpty1 && !isSolverEmpty2; - SolverSet solver; - if (mergeSolvers) - { - solver = SolverMerger::merge(*group1->solver.begin(), *group2->solver.begin()); - } - - if (!mergeSolvers || solver.odeSolver != nullptr) - { - auto group1Iter = groupMap.find(group1); - auto group2Iter = groupMap.find(group2); - - const bool group1IsColl = group1Iter != groupMap.end(); - const bool group2IsColl = group2Iter != groupMap.end(); - - if (!group1IsColl && !group2IsColl) - { - //none of the ODE solver nodes has been visited in the time step: create a new node - const std::string childName { "collision" + std::to_string(groupIndex++) }; - - collGroup = commonParent->createChild(childName); - - //move the first ODE solver node into the new node - collGroup->moveChild(BaseNode::SPtr(group1)); - - //move the second ODE solver node into the new node - collGroup->moveChild(BaseNode::SPtr(group2)); - - groupMap[group1] = collGroup.get(); - groupMap[group2] = collGroup.get(); - groupMap[collGroup.get()] = collGroup.get(); - } - else if (group1IsColl) //the first ODE solver node has been visited during this time step - { - collGroup = getNodeFromMergedGroups(group1Iter->second, mergedGroups); - - // merge group2 in group1 - if (!group2IsColl) //the second ODE solver node has NOT been visited during this time step - { - //second ODE solver node is moved into the first ODE solver node - collGroup->moveChild(BaseNode::SPtr(group2)); - groupMap[group2] = collGroup.get(); - } - else //the second ODE solver node has been visited during this time step - { - simulation::Node::SPtr collGroup2 = getNodeFromMergedGroups(group2Iter->second, mergedGroups); - if (collGroup == collGroup2) - { - // both ODE solver nodes are already in the same collision group - groupMap[group1Iter->first] = collGroup.get(); - groupMap[group2Iter->first] = collGroup.get(); - contactGroup.emplace_back(contact, collGroup); - return; - } - else - { - //both ODE solver nodes have been visited, but they are not in the same node - //move the second node into the first - //solvers of the second node are deleted - - groupMap[group2] = collGroup.get(); - // merge groups and remove collGroup2 - - // store solvers of the second group and destroy them later - SolverSet tmpSolverSet; - if (mergeSolvers) - { - getSolverSet(collGroup2, tmpSolverSet); - - //remove solvers from group2, so it is not moved later with the rest of the objects - removeSolverSetFromNode(collGroup2, tmpSolverSet); - } - //move all objects from group 2 to group 1 - moveAllObjects(collGroup2, collGroup); - moveAllChildren(collGroup2, collGroup); - - //group2 is empty: remove the node - commonParent->removeChild(collGroup2); - - //group is added to a list of groups that will be destroyed later - removedGroup.push_back(collGroup2); - groupMap.erase(collGroup2.get()); - - //stores that group2 has been merged into group1 - mergedGroups[collGroup2.get()] = collGroup.get(); - - //solvers object can be safely destroyed - destroySolvers(tmpSolverSet); - } - } - } - else //only the second ODE solver node has been visited during this time step - { - collGroup = getNodeFromMergedGroups(group2Iter->second, mergedGroups); - // group1 is not a collision group while group2 is - collGroup->moveChild(BaseNode::SPtr(group1)); - groupMap[group1] = collGroup.get(); - } - - SolverSet tmpSolverSet; - getSolverSet(collGroup, tmpSolverSet); - removeSolverSetFromNode(collGroup, tmpSolverSet); - - addSolversToNode(collGroup, solver); - } - } - contactGroup.emplace_back(contact, collGroup); -} - - -void DefaultCollisionGroupManager::clearGroups(core::objectmodel::BaseContext* /*scene*/) -{ - for (const auto& nodePair : groupMap) - { - if (nodePair.second != nullptr && !nodePair.second->getParents().empty()) - { - clearCollisionGroup(nodePair.second); - } - } - - groupMap.clear(); - groups.clear(); -} - - -simulation::Node* DefaultCollisionGroupManager::getIntegrationNode(core::CollisionModel* model) -{ - simulation::Node* node = static_cast(model->getContext()); - type::vector< core::behavior::OdeSolver *> listSolver; - node->get< core::behavior::OdeSolver >(&listSolver); - - if (listSolver.empty()) - return nullptr; - - simulation::Node* solvernode = static_cast(listSolver.back()->getContext()); - return solvernode; -} - -void DefaultCollisionGroupManager::moveAllObjects(simulation::Node::SPtr sourceNode, simulation::Node::SPtr destinationNode) -{ - while(!sourceNode->object.empty()) - { - destinationNode->moveObject(*sourceNode->object.begin()); - } -} - -void DefaultCollisionGroupManager::moveAllChildren(simulation::Node::SPtr sourceNode, simulation::Node::SPtr destinationNode) -{ - while(!sourceNode->child.empty()) - { - destinationNode->moveChild(*sourceNode->child.begin()); - } -} - -void DefaultCollisionGroupManager::getSolverSet(simulation::Node::SPtr node, SolverSet& solverSet) -{ - if (!node->linearSolver.empty()) - { - solverSet.odeSolver = *node->solver.begin(); - } - - if (!node->linearSolver.empty()) - { - solverSet.linearSolver = *node->linearSolver.begin(); - } - - if (!node->constraintSolver.empty()) - { - solverSet.constraintSolver = *node->constraintSolver.begin(); - } -} - -void DefaultCollisionGroupManager::removeSolverSetFromNode(simulation::Node::SPtr node, sofa::component::collision::SolverSet& solverSet) -{ - if (solverSet.odeSolver) - { - node->removeObject(solverSet.odeSolver); - } - if (solverSet.linearSolver) - { - node->removeObject(solverSet.linearSolver); - } - if (solverSet.constraintSolver) - { - node->removeObject(solverSet.constraintSolver); - } -} - -void DefaultCollisionGroupManager::destroySolvers(sofa::component::collision::SolverSet& solverSet) -{ - if (solverSet.odeSolver != nullptr) - { - solverSet.odeSolver.reset(); - } - if (solverSet.linearSolver != nullptr) - { - solverSet.linearSolver.reset(); - } - if (solverSet.constraintSolver != nullptr) - { - solverSet.constraintSolver.reset(); - } -} - -void DefaultCollisionGroupManager::addSolversToNode(simulation::Node::SPtr node, sofa::component::collision::SolverSet& solverSet) -{ - if (solverSet.odeSolver) - { - node->addObject(solverSet.odeSolver); - } - if (solverSet.linearSolver) - { - node->addObject(solverSet.linearSolver); - } - if (solverSet.constraintSolver) - { - node->addObject(solverSet.constraintSolver); - } - // perform init only once everyone has been added (in case of explicit dependencies) - if (solverSet.odeSolver) - { - solverSet.odeSolver->init(); - } - if (solverSet.linearSolver) - { - solverSet.linearSolver->init(); - } - if (solverSet.constraintSolver) - { - solverSet.constraintSolver->init(); - } -} - -simulation::Node* DefaultCollisionGroupManager::getNodeFromMergedGroups(simulation::Node* node, const MergeGroupsMap& mergedGroups) -{ - if (node != nullptr) - { - simulation::Node* nodeBegin = node; - auto it = mergedGroups.find(node); - - //the group associated to a contact may have been moved to another group - while (it != mergedGroups.cend() && it->second != nullptr) - { - node = it->second; - checkEndlessLoop(mergedGroups, nodeBegin, node); - it = mergedGroups.find(node); - } - } - return node; -} - -void DefaultCollisionGroupManager::checkEndlessLoop(const MergeGroupsMap& mergedGroups, simulation::Node* firstGroup, simulation::Node* currentGroup) -{ - if (currentGroup == firstGroup) - { - std::stringstream msg; - msg << "A logic problem (endless loop) has been detected. Please report a bug on https://github.com/sofa-framework/sofa/issues. Details:\n"; - for (const auto& [a, b] : mergedGroups) - { - msg << a << "(" << (a ? a->getPathName() : "invalid") << ") " << b << "(" << (b ? b->getPathName() : "invalid") << "), "; - } - - msg_fatal() << msg.str(); - throw std::logic_error(msg.str()); - } -} - -} // namespace sofa::component::collision diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/README.md b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/README.md deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/RayTriangleVisitor.cpp b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/RayTriangleVisitor.cpp deleted file mode 100644 index 189cfa77af67..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/RayTriangleVisitor.cpp +++ /dev/null @@ -1,198 +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 "RayTriangleVisitor.h" -#include -#include -#include -#include - -namespace sofa -{ - -using core::objectmodel::BaseObject; - -namespace component{ -namespace collision { - - -RayTriangleVisitor::RayTriangleVisitor(const core::ExecParams* params):simulation::Visitor(params) -{} - -struct distanceHitSort{ - bool operator() (const RayTriangleVisitor::Hit& h1, const RayTriangleVisitor::Hit& h2){ - return h1.distance < h2.distance; - } -}; - -core::objectmodel::BaseObject* RayTriangleVisitor::embeddingModel() -{ - std::sort(hits.begin(),hits.end(),distanceHitSort()); - //================================================================ - // Version 2: we assume that objects are not nested, there can be intersections - // We look for the first exit from an object not previously entered in - std::set entered; - for( std::size_t i= 0; i* tm) -{ - typedef geometry::TriangleCollisionModel::DataTypes DataTypes; - - const DataTypes::VecCoord& x = tm->getMechanicalState()->read(sofa::core::ConstVecCoordId::position())->getValue(); - for( core::topology::BaseMeshTopology::SeqTriangles::const_iterator it=tm->getTriangles().begin(), iend=tm->getTriangles().end() ; it!=iend; it++) - { - const Vec3& v0 = x[(*it)[0]]; - const Vec3& v1 = x[(*it)[1]]; - const Vec3& v2 = x[(*it)[2]]; - - // ray-triangle intersection adapted from http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-9-ray-triangle-intersection/ray-triangle-intersection-geometric-solution/ - Vec3 e01 = v1-v0; - Vec3 e02 = v2-v0; - Vec3 N = e01.cross(e02); - - // find intersection point - SReal NdotRayDir = N*direction; - SReal eps = std::numeric_limits::epsilon() * 100; - if( fabs(NdotRayDir)0 ) continue; // point on the left side of the edge - - Hit hit; - hit.hitObject = tm; - hit.distance = (P-origin).norm(); - hit.internal = (N*direction)<0; - hits.push_back( hit ); - } -} - -void RayTriangleVisitor::processVisualModel(simulation::Node* /*node*/, component::visual::VisualModelImpl* om) -{ - typedef component::visual::VisualModelImpl::DataTypes DataTypes; - - const DataTypes::VecCoord& x = om->getVertices(); - for( std::size_t i=0; igetTriangles().size(); i++ ) - { - const Vec3& v0 = x[om->getTriangles()[i][0]]; - const Vec3& v1 = x[om->getTriangles()[i][1]]; - const Vec3& v2 = x[om->getTriangles()[i][2]]; - - // ray-triangle intersection adapted from http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-9-ray-triangle-intersection/ray-triangle-intersection-geometric-solution/ - Vec3 e01 = v1-v0; - Vec3 e02 = v2-v0; - Vec3 N = e01.cross(e02); - - // find intersection point - SReal NdotRayDir = N*direction; - SReal eps = std::numeric_limits::epsilon() * 100; - if( fabs(NdotRayDir)0 ) continue; // point on the left side of the edge - - Hit hit; - hit.hitObject = om; - hit.distance = (P-origin).norm(); - hit.internal = (N*direction)<0; - hits.push_back( hit ); - - } -} - -simulation::Visitor::Result RayTriangleVisitor::processNodeTopDown(simulation::Node* node) -{ - using core::visual::VisualModel; - using component::visual::VisualModelImpl; - typedef simulation::Node::Sequence CollisionModels; - typedef simulation::Node::Sequence VisualModels; - typedef component::collision::geometry::TriangleCollisionModel TriangleModel; - - for( CollisionModels::const_iterator it=node->collisionModel.begin(), iend=node->collisionModel.end(); it!=iend; it++ ) - { - if( TriangleModel* tmodel = dynamic_cast(*it) ) { - processTriangleModel(node,tmodel); - } - } - for( VisualModels::const_iterator it=node->visualModel.begin(), iend=node->visualModel.end(); it!=iend; it++ ) - { - if( VisualModelImpl* tmodel = dynamic_cast(*it) ) { - processVisualModel(node,tmodel); - } - } - - return Visitor::RESULT_CONTINUE; -} - - -} -} -} // namespace sofa - diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/SolverMerger.cpp b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/SolverMerger.cpp deleted file mode 100644 index ca8c5f801100..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/SolverMerger.cpp +++ /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 * -******************************************************************************/ -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace sofa::component::collision -{ -using sofa::core::behavior::OdeSolver; -using sofa::core::behavior::BaseLinearSolver; -using sofa::core::behavior::ConstraintSolver; - -SolverSet::SolverSet(core::behavior::OdeSolver::SPtr o, - core::behavior::BaseLinearSolver::SPtr l, - core::behavior::ConstraintSolver::SPtr c) : - odeSolver(o),linearSolver(l),constraintSolver(c) -{} - -namespace solvermergers -{ - -/// Create a new object which type is the template parameter, and -/// copy all its data fields values. -/// This function is meant to be used for ODE solvers and constraint solvers -template -typename SolverType::SPtr copySolver(const SolverType& s) -{ - const SolverType* src = &s; - typename SolverType::SPtr res = sofa::core::objectmodel::New(); - for (auto* dataField : src->getDataFields()) - { - msg_error_when(dataField == nullptr, "SolverMerger::copySolver") << "Found nullptr data field from " << src->getName(); - if (auto* d = res->findData(dataField->getName())) - d->copyValueFrom(dataField); - } - return res; -} - -ConstraintSolver::SPtr createConstraintSolver(OdeSolver* solver1, OdeSolver* solver2) -{ - ConstraintSolver* csolver1 = nullptr; - if (solver1!=nullptr) - { - solver1->getContext()->get(csolver1, core::objectmodel::BaseContext::SearchDown); - } - - ConstraintSolver* csolver2 = nullptr; - if (solver2!=nullptr) - { - solver2->getContext()->get(csolver2, core::objectmodel::BaseContext::SearchDown); - } - - if (!csolver1 && !csolver2) - { - //no constraint solver associated to any ODE solver - return nullptr; - } - if (!csolver1) - { - //first ODE solver does not have any constraint solver. The second is copied to be shared with the first - if (auto* cs=dynamic_cast(csolver2)) - return copySolver(*cs); - } - else if (!csolver2) - { - //second ODE solver does not have any constraint solver. The first is copied to be shared with the second - if (auto* cs=dynamic_cast(csolver1)) - return copySolver(*cs); - } - else - { - //both ODE solvers have an associated constraint solver - if (auto* lcp1 = dynamic_cast(csolver1)) - if (auto* lcp2 = dynamic_cast(csolver2)) - { - constraint::lagrangian::solver::LCPConstraintSolver::SPtr newSolver = sofa::core::objectmodel::New(); - newSolver->d_initial_guess.setValue(lcp1->d_initial_guess.getValue() | lcp2->d_initial_guess.getValue()); - newSolver->d_build_lcp.setValue(lcp1->d_build_lcp.getValue() | lcp2->d_build_lcp.getValue()); - newSolver->d_tol.setValue(lcp1->d_tol.getValue() < lcp2->d_tol.getValue() ? lcp1->d_tol.getValue() : lcp2->d_tol.getValue() ); - newSolver->d_maxIt.setValue(lcp1->d_maxIt.getValue() > lcp2->d_maxIt.getValue() ? lcp1->d_maxIt.getValue() : lcp2->d_maxIt.getValue() ); - newSolver->d_mu.setValue((lcp1->d_mu.getValue() + lcp2->d_mu.getValue()) * 0.5); - return newSolver; - } - } - - return nullptr; -} - - -// First the easy cases... - -SolverSet createSolverEulerExplicitEulerExplicit(odesolver::forward::EulerExplicitSolver& solver1, odesolver::forward::EulerExplicitSolver& solver2) -{ - return SolverSet(copySolver(solver1), nullptr,createConstraintSolver(&solver1, &solver2)); -} - -SolverSet createSolverRungeKutta4RungeKutta4(odesolver::forward::RungeKutta4Solver& solver1, odesolver::forward::RungeKutta4Solver& solver2) -{ - return SolverSet(copySolver(solver1), nullptr,createConstraintSolver(&solver1, &solver2)); -} - -typedef linearsolver::iterative::CGLinearSolver DefaultCGLinearSolver; - -BaseLinearSolver::SPtr createLinearSolver(OdeSolver* solver1, OdeSolver* solver2) -{ - DefaultCGLinearSolver::SPtr lsolver = sofa::core::objectmodel::New(); - - DefaultCGLinearSolver* lsolver1 = nullptr; - if (solver1!=nullptr) - { - solver1->getContext()->get(lsolver1, core::objectmodel::BaseContext::SearchDown); - } - - DefaultCGLinearSolver* lsolver2 = nullptr; - if (solver2!=nullptr) - { - solver2->getContext()->get(lsolver2, core::objectmodel::BaseContext::SearchDown); - } - - unsigned int maxIter = 0; - double tolerance = 1.0e10; - double smallDenominatorThreshold = 1.0e10; - if (lsolver1) - { - if (lsolver1->d_maxIter.getValue() > maxIter) maxIter = lsolver1->d_maxIter.getValue(); - if (lsolver1->d_tolerance.getValue() < tolerance) tolerance = lsolver1->d_tolerance.getValue(); - if (lsolver1->d_smallDenominatorThreshold.getValue() < smallDenominatorThreshold) smallDenominatorThreshold = lsolver1->d_smallDenominatorThreshold.getValue(); - } - if (lsolver2) - { - if (lsolver2->d_maxIter.getValue() > maxIter) maxIter = lsolver2->d_maxIter.getValue(); - if (lsolver2->d_tolerance.getValue() < tolerance) tolerance = lsolver2->d_tolerance.getValue(); - if (lsolver2->d_smallDenominatorThreshold.getValue() < smallDenominatorThreshold) smallDenominatorThreshold = lsolver2->d_smallDenominatorThreshold.getValue(); - } - lsolver->d_maxIter.setValue( maxIter ); - lsolver->d_tolerance.setValue( tolerance ); - lsolver->d_smallDenominatorThreshold.setValue( smallDenominatorThreshold ); - return lsolver; -} - -SolverSet createSolverEulerImplicitEulerImplicit(odesolver::backward::EulerImplicitSolver& solver1, odesolver::backward::EulerImplicitSolver& solver2) -{ - odesolver::backward::EulerImplicitSolver::SPtr solver = sofa::core::objectmodel::New(); - solver->d_rayleighStiffness.setValue(solver1.d_rayleighStiffness.getValue() < solver2.d_rayleighStiffness.getValue() ? solver1.d_rayleighStiffness.getValue() : solver2.d_rayleighStiffness.getValue() ); - solver->d_rayleighMass.setValue(solver1.d_rayleighMass.getValue() < solver2.d_rayleighMass.getValue() ? solver1.d_rayleighMass.getValue() : solver2.d_rayleighMass.getValue() ); - solver->d_velocityDamping.setValue(solver1.d_velocityDamping.getValue() > solver2.d_velocityDamping.getValue() ? solver1.d_velocityDamping.getValue() : solver2.d_velocityDamping.getValue()); - return SolverSet(solver, - createLinearSolver(&solver1, &solver2), - createConstraintSolver(&solver1, &solver2)); -} - -SolverSet createSolverStaticSolver(odesolver::backward::StaticSolver& solver1, odesolver::backward::StaticSolver& solver2) -{ - return SolverSet(copySolver(solver1), - createLinearSolver(&solver1, &solver2), - createConstraintSolver(&solver1, &solver2)); -} - -// Then the other, with the policy of taking the more precise solver - -SolverSet createSolverRungeKutta4Euler(odesolver::forward::RungeKutta4Solver& solver1, odesolver::forward::EulerExplicitSolver& solver2) -{ - return SolverSet(copySolver(solver1), nullptr,createConstraintSolver(&solver1, &solver2)); -} - -SolverSet createSolverEulerImplicitEuler(odesolver::backward::EulerImplicitSolver& solver1, odesolver::forward::EulerExplicitSolver& solver2) -{ - return SolverSet(copySolver(solver1), - createLinearSolver(&solver1, nullptr), - createConstraintSolver(&solver1, &solver2)); -} - -SolverSet createSolverEulerImplicitRungeKutta4(odesolver::backward::EulerImplicitSolver& solver1, odesolver::forward::RungeKutta4Solver& solver2) -{ - return SolverSet(copySolver(solver1), - createLinearSolver(&solver1, nullptr), - createConstraintSolver(&solver1, &solver2)); -} - -}// namespace SolverMergers - -using namespace solvermergers; - - -SolverMerger* SolverMerger::getInstance() -{ - static SolverMerger instance; - return &instance; -} - -SolverSet SolverMerger::merge(core::behavior::OdeSolver* solver1, core::behavior::OdeSolver* solver2) -{ - return getInstance()->solverDispatcher.go(*solver1, *solver2); -} - -SolverMerger::SolverMerger() -{ - solverDispatcher.add(); - solverDispatcher.add(); - solverDispatcher.add(); - solverDispatcher.add(); - solverDispatcher.add(); - solverDispatcher.add(); - solverDispatcher.add(); -} - -} // namespace sofa::component::collision diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/config.h.in b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/config.h.in deleted file mode 100644 index a72e67e66125..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/config.h.in +++ /dev/null @@ -1,37 +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 * -******************************************************************************/ -#ifndef SOFAMISCCOLLISION_CONFIG_H -#define SOFAMISCCOLLISION_CONFIG_H - -#include - -#cmakedefine01 SOFAMISCCOLLISION_HAVE_SOFASPHFLUID -#cmakedefine01 SOFAMISCCOLLISION_HAVE_SOFADISTANCEGRID - -#ifdef SOFA_BUILD_MISC_COLLISION -# define SOFA_TARGET SofaMiscCollision -# define SOFA_MISC_COLLISION_API SOFA_EXPORT_DYNAMIC_LIBRARY -#else -# define SOFA_MISC_COLLISION_API SOFA_IMPORT_DYNAMIC_LIBRARY -#endif - -#endif diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/initSofaMiscCollision.cpp b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/initSofaMiscCollision.cpp deleted file mode 100644 index 7a7636d55ba5..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/initSofaMiscCollision.cpp +++ /dev/null @@ -1,91 +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 - -namespace sofa -{ - -namespace component -{ - -void initSofaMiscCollision() -{ - static bool first = true; - if (first) - { - msg_deprecated("SofaMiscCollision") << "SofaMiscCollision is deprecated. It will be removed at v23.06. Use Sofa.Component.Collision.Geometry, Sofa.Component.Collision.Detection.Intersection and Sofa.Component.Collision.Response.Contact instead."; - msg_deprecated("SofaMiscCollision") << "If you are looking for OBB and Capsule-related components, please use the external plugin CollisionOBBCapsule."; - - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Geometry"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Detection.Intersection"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Response.Contact"); - - first = false; - } -} - -extern "C" { -SOFA_MISC_COLLISION_API void initExternalModule(); -SOFA_MISC_COLLISION_API const char* getModuleName(); -SOFA_MISC_COLLISION_API const char* getModuleVersion(); -SOFA_MISC_COLLISION_API const char* getModuleLicense(); -SOFA_MISC_COLLISION_API const char* getModuleDescription(); -SOFA_MISC_COLLISION_API const char* getModuleComponentList(); -} - -void initExternalModule() -{ - initSofaMiscCollision(); -} - -const char* getModuleName() -{ - return "SofaMiscCollision"; -} - -const char* getModuleVersion() -{ - return "1.0"; -} - -const char* getModuleLicense() -{ - return "LGPL"; -} - -const char* getModuleDescription() -{ - return "This plugin contains collision components."; -} - -const char* getModuleComponentList() -{ - return "DistanceGridCollisionModel FFDDistanceGridDiscreteIntersection RayDistanceGridContact " - "RigidDistanceGridDiscreteIntersection DistanceGridForceField"; -} - -} // component - -} // sofa diff --git a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/initSofaMiscCollision.h b/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/initSofaMiscCollision.h deleted file mode 100644 index c96d41f9b15e..000000000000 --- a/applications/collections/deprecated/modules/SofaMiscCollision/src/SofaMiscCollision/initSofaMiscCollision.h +++ /dev/null @@ -1,39 +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 * -******************************************************************************/ -#ifndef SOFA_COMPONENT_MISC_COLLISION_INIT_H -#define SOFA_COMPONENT_MISC_COLLISION_INIT_H -#include - -namespace sofa -{ - -namespace component -{ - -SOFA_MISC_COLLISION_API void initSofaMiscCollision(); - -} // namespace component - -} // namespace sofa - -#endif - diff --git a/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/config.h.in b/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/config.h.in deleted file mode 100644 index 312c0e7ad037..000000000000 --- a/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/config.h.in +++ /dev/null @@ -1,34 +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 - -#define SOFAUSERINTERACTION_VERSION @PROJECT_VERSION@ - -#ifdef SOFA_BUILD_SOFAUSERINTERACTION -# define SOFA_TARGET @PROJECT_NAME@ -# define SOFA_SOFAUSERINTERACTION_API SOFA_EXPORT_DYNAMIC_LIBRARY -#else -# define SOFA_SOFAUSERINTERACTION_API SOFA_IMPORT_DYNAMIC_LIBRARY -#endif diff --git a/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/initSofaUserInteraction.cpp b/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/initSofaUserInteraction.cpp deleted file mode 100644 index df6817442c88..000000000000 --- a/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/initSofaUserInteraction.cpp +++ /dev/null @@ -1,91 +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 -using sofa::core::ObjectFactory; - -namespace sofa::component -{ - -void initSofaUserInteraction() -{ - static bool first = true; - if (first) - { - msg_deprecated("SofaUserInteraction") << "SofaUserInteraction is being deprecated;. It will be removed at v23.06. You may use Sofa.Component.Collision.Geometry, Sofa.Component.Collision.Detection.Algorithm, Sofa.Component.Collision.Detection.Intersection. Sofa.Component.Collision.Response.Contact, Sofa.Component.Controller and Sofa.GUI.Component instead."; - - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Geometry"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Detection.Algorithm"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Detection.Intersection"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Collision.Response.Contact"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.Component.Controller"); - sofa::helper::system::PluginManager::getInstance().loadPlugin("Sofa.GUI.Component"); - - first = false; - } -} - -extern "C" { - SOFA_SOFAUSERINTERACTION_API void initExternalModule(); - SOFA_SOFAUSERINTERACTION_API const char* getModuleName(); - SOFA_SOFAUSERINTERACTION_API const char* getModuleVersion(); - SOFA_SOFAUSERINTERACTION_API const char* getModuleLicense(); - SOFA_SOFAUSERINTERACTION_API const char* getModuleDescription(); - SOFA_SOFAUSERINTERACTION_API const char* getModuleComponentList(); -} - -void initExternalModule() -{ - initSofaUserInteraction(); -} - -const char* getModuleName() -{ - return sofa_tostring(SOFA_TARGET); -} - -const char* getModuleVersion() -{ - return sofa_tostring(SOFAUSERINTERACTION_VERSION); -} - -const char* getModuleLicense() -{ - return "LGPL"; -} - -const char* getModuleDescription() -{ - return "This plugin contains contains features about User Interaction."; -} - -const char* getModuleComponentList() -{ - /// string containing the names of the classes provided by the plugin - static std::string classes = ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET)); - return classes.c_str(); -} - -} // namespace sofa::component diff --git a/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/initSofaUserInteraction.h b/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/initSofaUserInteraction.h deleted file mode 100644 index ad9bed4a373e..000000000000 --- a/applications/collections/deprecated/modules/SofaUserInteraction/src/SofaUserInteraction/initSofaUserInteraction.h +++ /dev/null @@ -1,30 +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 - -namespace sofa::component -{ - -SOFA_SOFAUSERINTERACTION_API void initSofaUserInteraction(); - -} //namespace sofa::component