From a50701b9653b930ad939e6c8da63879125feef42 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Fri, 17 Nov 2023 11:35:19 +0100 Subject: [PATCH 01/28] Added projective and lagrangian suffix --- .../Lagrangian/Model/CMakeLists.txt | 23 +- .../model/BilateralInteractionConstraint.h | 173 +---- .../model/BilateralInteractionConstraint.inl | 411 +---------- ...ateralInteractionLagrangianConstraint.cpp} | 156 ++--- ...BilateralInteractionLagrangianConstraint.h | 198 ++++++ ...lateralInteractionLagrangianConstraint.inl | 433 ++++++++++++ .../lagrangian/model/SlidingConstraint.h | 91 +-- .../lagrangian/model/SlidingConstraint.inl | 204 +----- ...nt.cpp => SlidingLagrangianConstraint.cpp} | 10 +- .../model/SlidingLagrangianConstraint.h | 117 ++++ .../model/SlidingLagrangianConstraint.inl | 226 ++++++ .../lagrangian/model/StopperConstraint.h | 105 +-- .../lagrangian/model/StopperConstraint.inl | 59 +- ...nt.cpp => StopperLagrangianConstraint.cpp} | 10 +- .../model/StopperLagrangianConstraint.h | 131 ++++ .../model/StopperLagrangianConstraint.inl | 81 +++ .../lagrangian/model/UniformConstraint.h | 55 +- .../lagrangian/model/UniformConstraint.inl | 115 +--- ...nt.cpp => UniformLagrangianConstraint.cpp} | 10 +- .../model/UniformLagrangianConstraint.h | 81 +++ .../model/UniformLagrangianConstraint.inl | 137 ++++ .../model/UnilateralConstraintResolution.h | 100 +++ .../model/UnilateralInteractionConstraint.h | 207 +----- .../model/UnilateralInteractionConstraint.inl | 399 +---------- ...ateralInteractionLagrangianConstraint.cpp} | 10 +- ...nilateralInteractionLagrangianConstraint.h | 162 +++++ ...lateralInteractionLagrangianConstraint.inl | 421 ++++++++++++ ...lInteractionLagrangianConstraint_test.cpp} | 32 +- .../Constraint/Projective/CMakeLists.txt | 82 ++- .../projective/AffineMovementConstraint.h | 143 +--- .../projective/AffineMovementConstraint.inl | 288 +------- ...=> AffineMovementProjectiveConstraint.cpp} | 14 +- .../AffineMovementProjectiveConstraint.h | 169 +++++ .../AffineMovementProjectiveConstraint.inl | 310 +++++++++ .../constraint/projective/AttachConstraint.h | 102 +-- .../projective/AttachConstraint.inl | 621 +---------------- ...int.cpp => AttachProjectiveConstraint.cpp} | 28 +- .../projective/AttachProjectiveConstraint.h | 128 ++++ .../projective/AttachProjectiveConstraint.inl | 643 ++++++++++++++++++ .../constraint/projective/FixedConstraint.h | 116 +--- .../constraint/projective/FixedConstraint.inl | 404 +---------- .../projective/FixedPlaneConstraint.h | 114 +--- .../projective/FixedPlaneConstraint.inl | 295 +------- ...cpp => FixedPlaneProjectiveConstraint.cpp} | 18 +- .../FixedPlaneProjectiveConstraint.h | 140 ++++ .../FixedPlaneProjectiveConstraint.inl | 317 +++++++++ ...aint.cpp => FixedProjectiveConstraint.cpp} | 38 +- .../projective/FixedProjectiveConstraint.h | 142 ++++ .../projective/FixedProjectiveConstraint.inl | 426 ++++++++++++ .../projective/FixedRotationConstraint.h | 58 +- .../projective/FixedRotationConstraint.inl | 120 +--- ... => FixedRotationProjectiveConstraint.cpp} | 10 +- .../FixedRotationProjectiveConstraint.h | 84 +++ .../FixedRotationProjectiveConstraint.inl | 142 ++++ .../projective/FixedTranslationConstraint.h | 84 +-- .../projective/FixedTranslationConstraint.inl | 186 +---- ... FixedTranslationProjectiveConstraint.cpp} | 18 +- .../FixedTranslationProjectiveConstraint.h | 110 +++ .../FixedTranslationProjectiveConstraint.inl | 208 ++++++ .../projective/HermiteSplineConstraint.h | 112 +-- .../projective/HermiteSplineConstraint.inl | 245 +------ ... => HermiteSplineProjectiveConstraint.cpp} | 16 +- .../HermiteSplineProjectiveConstraint.h | 137 ++++ .../HermiteSplineProjectiveConstraint.inl | 267 ++++++++ .../projective/LinearMovementConstraint.h | 146 +--- .../projective/LinearMovementConstraint.inl | 453 +----------- ...=> LinearMovementProjectiveConstraint.cpp} | 32 +- .../LinearMovementProjectiveConstraint.h | 171 +++++ .../LinearMovementProjectiveConstraint.inl | 475 +++++++++++++ .../projective/LinearVelocityConstraint.h | 113 +-- .../projective/LinearVelocityConstraint.inl | 326 +-------- ...=> LinearVelocityProjectiveConstraint.cpp} | 26 +- .../LinearVelocityProjectiveConstraint.h | 138 ++++ .../LinearVelocityProjectiveConstraint.inl | 348 ++++++++++ .../projective/OscillatorConstraint.h | 90 +-- .../projective/OscillatorConstraint.inl | 105 +-- ...cpp => OscillatorProjectiveConstraint.cpp} | 14 +- .../OscillatorProjectiveConstraint.h | 115 ++++ .../OscillatorProjectiveConstraint.inl | 127 ++++ .../projective/ParabolicConstraint.h | 105 +-- .../projective/ParabolicConstraint.inl | 241 +------ ....cpp => ParabolicProjectiveConstraint.cpp} | 14 +- .../ParabolicProjectiveConstraint.h | 130 ++++ .../ParabolicProjectiveConstraint.inl | 263 +++++++ .../projective/PartialFixedConstraint.h | 84 +-- .../projective/PartialFixedConstraint.inl | 321 +-------- ...p => PartialFixedProjectiveConstraint.cpp} | 30 +- .../PartialFixedProjectiveConstraint.h | 109 +++ .../PartialFixedProjectiveConstraint.inl | 343 ++++++++++ .../PartialLinearMovementConstraint.h | 154 +---- .../PartialLinearMovementConstraint.inl | 485 +------------ ...ialLinearMovementProjectiveConstraint.cpp} | 26 +- ...artialLinearMovementProjectiveConstraint.h | 179 +++++ ...tialLinearMovementProjectiveConstraint.inl | 507 ++++++++++++++ .../projective/PatchTestMovementConstraint.h | 143 +--- .../PatchTestMovementConstraint.inl | 427 +----------- ...PatchTestMovementProjectiveConstraint.cpp} | 14 +- .../PatchTestMovementProjectiveConstraint.h | 168 +++++ .../PatchTestMovementProjectiveConstraint.inl | 449 ++++++++++++ .../PositionBasedDynamicsConstraint.h | 92 +-- .../PositionBasedDynamicsConstraint.inl | 116 +--- ...tionBasedDynamicsProjectiveConstraint.cpp} | 32 +- ...ositionBasedDynamicsProjectiveConstraint.h | 117 ++++ ...itionBasedDynamicsProjectiveConstraint.inl | 138 ++++ .../projective/ProjectDirectionConstraint.h | 112 +-- .../projective/ProjectDirectionConstraint.inl | 255 +------ ... ProjectDirectionProjectiveConstraint.cpp} | 14 +- .../ProjectDirectionProjectiveConstraint.h | 137 ++++ .../ProjectDirectionProjectiveConstraint.inl | 277 ++++++++ .../projective/ProjectToLineConstraint.h | 116 +--- .../projective/ProjectToLineConstraint.inl | 264 +------ ... => ProjectToLineProjectiveConstraint.cpp} | 15 +- .../ProjectToLineProjectiveConstraint.h | 141 ++++ .../ProjectToLineProjectiveConstraint.inl | 286 ++++++++ .../projective/ProjectToPlaneConstraint.h | 115 +--- .../projective/ProjectToPlaneConstraint.inl | 254 +------ ...=> ProjectToPlaneProjectiveConstraint.cpp} | 15 +- .../ProjectToPlaneProjectiveConstraint.h | 140 ++++ .../ProjectToPlaneProjectiveConstraint.inl | 276 ++++++++ .../projective/ProjectToPointConstraint.h | 109 +-- .../projective/ProjectToPointConstraint.inl | 302 +------- ...=> ProjectToPointProjectiveConstraint.cpp} | 22 +- .../ProjectToPointProjectiveConstraint.h | 133 ++++ .../ProjectToPointProjectiveConstraint.inl | 324 +++++++++ .../projective/SkeletalMotionConstraint.h | 226 +----- .../projective/SkeletalMotionConstraint.inl | 400 +---------- ...=> SkeletalMotionProjectiveConstraint.cpp} | 10 +- .../SkeletalMotionProjectiveConstraint.h | 250 +++++++ .../SkeletalMotionProjectiveConstraint.inl | 422 ++++++++++++ ...fineMovementProjectiveConstraint_test.cpp} | 8 +- .../Projective/tests/CMakeLists.txt | 16 +- ...> FixedPlaneProjectiveConstraint_test.cpp} | 16 +- ...cpp => FixedProjectiveConstraint_test.cpp} | 20 +- ...PartialFixedProjectiveConstraint_test.cpp} | 16 +- ...ectDirectionProjectiveConstraint_test.cpp} | 20 +- ...rojectToLineProjectiveConstraint_test.cpp} | 20 +- ...ojectToPlaneProjectiveConstraint_test.cpp} | 20 +- ...ojectToPointProjectiveConstraint_test.cpp} | 20 +- .../tests/SkeletalMotionConstraint_test.cpp | 14 +- .../simutests/AffinePatch_test.cpp | 4 +- .../simutests/LinearElasticity_test.cpp | 24 +- .../testing/RegularGridNodeCreation.h | 6 +- .../performer/FixParticlePerformer.inl | 2 +- .../performer/SuturePointPerformer.h | 2 +- 144 files changed, 12074 insertions(+), 10607 deletions(-) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{BilateralInteractionConstraint.cpp => BilateralInteractionLagrangianConstraint.cpp} (59%) create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{SlidingConstraint.cpp => SlidingLagrangianConstraint.cpp} (85%) create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{StopperConstraint.cpp => StopperLagrangianConstraint.cpp} (85%) create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{UniformConstraint.cpp => UniformLagrangianConstraint.cpp} (82%) create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralConstraintResolution.h rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{UnilateralInteractionConstraint.cpp => UnilateralInteractionLagrangianConstraint.cpp} (91%) create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h create mode 100644 Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl rename Sofa/Component/Constraint/Lagrangian/Model/tests/{BilateralInteractionConstraint_test.cpp => BilateralInteractionLagrangianConstraint_test.cpp} (85%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{AffineMovementConstraint.cpp => AffineMovementProjectiveConstraint.cpp} (79%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{AttachConstraint.cpp => AttachProjectiveConstraint.cpp} (71%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{FixedPlaneConstraint.cpp => FixedPlaneProjectiveConstraint.cpp} (78%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{FixedConstraint.cpp => FixedProjectiveConstraint.cpp} (73%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{FixedRotationConstraint.cpp => FixedRotationProjectiveConstraint.cpp} (82%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{FixedTranslationConstraint.cpp => FixedTranslationProjectiveConstraint.cpp} (76%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{HermiteSplineConstraint.cpp => HermiteSplineProjectiveConstraint.cpp} (77%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{LinearMovementConstraint.cpp => LinearMovementProjectiveConstraint.cpp} (71%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{LinearVelocityConstraint.cpp => LinearVelocityProjectiveConstraint.cpp} (74%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{OscillatorConstraint.cpp => OscillatorProjectiveConstraint.cpp} (79%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ParabolicConstraint.cpp => ParabolicProjectiveConstraint.cpp} (77%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{PartialFixedConstraint.cpp => PartialFixedProjectiveConstraint.cpp} (72%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{PartialLinearMovementConstraint.cpp => PartialLinearMovementProjectiveConstraint.cpp} (73%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{PatchTestMovementConstraint.cpp => PatchTestMovementProjectiveConstraint.cpp} (84%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{PositionBasedDynamicsConstraint.cpp => PositionBasedDynamicsProjectiveConstraint.cpp} (79%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectDirectionConstraint.cpp => ProjectDirectionProjectiveConstraint.cpp} (80%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPlaneConstraint.cpp => ProjectToLineProjectiveConstraint.cpp} (80%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToLineConstraint.cpp => ProjectToPlaneProjectiveConstraint.cpp} (80%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPointConstraint.cpp => ProjectToPointProjectiveConstraint.cpp} (76%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{SkeletalMotionConstraint.cpp => SkeletalMotionProjectiveConstraint.cpp} (83%) create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h create mode 100644 Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl rename Sofa/Component/Constraint/Projective/tests/{AffineMovementConstraint_test.cpp => AffineMovementProjectiveConstraint_test.cpp} (95%) rename Sofa/Component/Constraint/Projective/tests/{FixedPlaneConstraint_test.cpp => FixedPlaneProjectiveConstraint_test.cpp} (89%) rename Sofa/Component/Constraint/Projective/tests/{FixedConstraint_test.cpp => FixedProjectiveConstraint_test.cpp} (92%) rename Sofa/Component/Constraint/Projective/tests/{PartialFixedConstraint_test.cpp => PartialFixedProjectiveConstraint_test.cpp} (88%) rename Sofa/Component/Constraint/Projective/tests/{ProjectDirectionConstraint_test.cpp => ProjectDirectionProjectiveConstraint_test.cpp} (91%) rename Sofa/Component/Constraint/Projective/tests/{ProjectToLineConstraint_test.cpp => ProjectToLineProjectiveConstraint_test.cpp} (91%) rename Sofa/Component/Constraint/Projective/tests/{ProjectToPlaneConstraint_test.cpp => ProjectToPlaneProjectiveConstraint_test.cpp} (91%) rename Sofa/Component/Constraint/Projective/tests/{ProjectToPointConstraint_test.cpp => ProjectToPointProjectiveConstraint_test.cpp} (91%) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt b/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt index 147e6931b3e..168cf437499 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt +++ b/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt @@ -15,17 +15,30 @@ set(HEADER_FILES ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperConstraint.inl ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformConstraint.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralConstraintResolution.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.inl + + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionLagrangianConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionLagrangianConstraint.inl ) set(SOURCE_FILES ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/init.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionConstraint.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingConstraint.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperConstraint.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformConstraint.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionLagrangianConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionLagrangianConstraint.cpp + ) sofa_find_package(Sofa.Simulation.Core REQUIRED) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h index af6f155bde2..d7be47bbc7b 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h @@ -20,176 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include +#include -#include -#include -#include -#include - -#include - -#include - -namespace sofa::component::constraint::lagrangian::model -{ - -/// These 'using' are in a per-file namespace so they will not leak -/// and polluate the standard namespace. -using sofa::core::behavior::BaseConstraint ; -using sofa::core::behavior::ConstraintResolution ; -using sofa::core::behavior::PairInteractionConstraint ; -using sofa::core::objectmodel::Data ; -using sofa::core::ConstraintParams ; -using sofa::core::ConstVecCoordId; - -using sofa::linearalgebra::BaseVector ; -using sofa::type::Vec3d; -using sofa::type::Quat ; - -using sofa::defaulttype::Rigid3Types ; -using sofa::defaulttype::Vec3Types ; - - -template -class BilateralInteractionConstraintSpecialization {}; - - -template -class BilateralInteractionConstraint : public PairInteractionConstraint -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(BilateralInteractionConstraint,DataTypes), - SOFA_TEMPLATE(PairInteractionConstraint,DataTypes)); - - /// That any templates variation of BilateralInteractionConstraintSpecialization are friend. - template - friend class BilateralInteractionConstraintSpecialization ; - - typedef PairInteractionConstraint Inherit; - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename Coord::value_type Real; - typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; - - typedef core::behavior::MechanicalState MechanicalState; - typedef BaseConstraint::PersistentID PersistentID; - - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - - using SubsetIndices = type::vector; - using DataSubsetIndices = sofa::core::topology::TopologySubsetIndices; - -protected: - std::vector dfree; - Quat q; - - std::vector cid; - - DataSubsetIndices m1; ///< index of the constraint on the first model - DataSubsetIndices m2; ///< index of the constraint on the second model - Data restVector; ///< Relative position to maintain between attached points (optional) - VecCoord initialDifference; - - Data d_numericalTolerance; ///< a real value specifying the tolerance during the constraint solving. (default=0.0001 - Data d_activate; ///< bool to control constraint activation - Data keepOrientDiff; ///< keep the initial difference in orientation (only for rigids) - - - SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology1; ///< Link to be set to the first topology container in order to support topological changes - SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology2; ///< Link to be set to the second topology container in order to support topological changes - - std::vector prevForces; - - SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'activateAtIteration' has been removed, please use the Data d_activate instead and an engine or a script to change the behavior at the right step (see PR #3327).") - sofa::core::objectmodel::lifecycle::RemovedData activateAtIteration{this, "v22.12", "v23.06", "activateAtIteration", "use the boolean data 'activate' instead and an engine or a script to change the behavior at the right step (see PR #3327)."}; - - SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'merge' has been removed. Its behavior was unused, undocumented, untested, and unclear (see PR #3328).") - sofa::core::objectmodel::lifecycle::RemovedData merge{this, "v22.12", "v23.06", "merge", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."}; - - SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'derivative' has been removed. Its behavior was unused, undocumented, untested, and unclear (see PR #3328).") - sofa::core::objectmodel::lifecycle::RemovedData derivative{this, "v22.12", "v23.06", "derivative", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."}; - - - BilateralInteractionConstraint(MechanicalState* object1, MechanicalState* object2) ; - BilateralInteractionConstraint(MechanicalState* object) ; - BilateralInteractionConstraint(); - - virtual ~BilateralInteractionConstraint(){} -public: - void init() override; - - void bwdInit() override {} - - void reinit() override; - - void buildConstraintMatrix(const ConstraintParams* cParams, - DataMatrixDeriv &c1, DataMatrixDeriv &c2, - unsigned int &cIndex, - const DataVecCoord &x1, const DataVecCoord &x2) override; - - void getConstraintViolation(const ConstraintParams* cParams, - BaseVector *v, - const DataVecCoord &x1, const DataVecCoord &x2, - const DataVecDeriv &v1, const DataVecDeriv &v2) override; - - void getVelocityViolation(BaseVector *v, - const DataVecCoord &x1, const DataVecCoord &x2, - const DataVecDeriv &v1, const DataVecDeriv &v2); - - void getConstraintResolution(const ConstraintParams* cParams, - std::vector& resTab, - unsigned int& offset) override; - - void handleEvent(sofa::core::objectmodel::Event *event) override; - - void draw(const core::visual::VisualParams* vparams) override; - - void clear(int reserve = 0) ; - - virtual void addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, - int m1, int m2, Coord Pfree, Coord Qfree, - long id=0, PersistentID localid=0); - - void addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, - int m1, int m2, long id=0, PersistentID localid=0) ; - - void addContact(Deriv norm, Real contactDistance, int m1, int m2, - long id=0, PersistentID localid=0) ; - - /// Method to remove a contact using point @param indices and id of buffer: @sa m1 (resp. @sa 2m) if @param objectId is equal to 0 (resp. to 1) - void removeContact(int objectId, SubsetIndices indices); - - virtual type::vector getBilateralInteractionIdentifiers() {return {};} - - virtual type::vector getPairInteractionIdentifiers() override final - { - type::vector ids = getBilateralInteractionIdentifiers(); - ids.push_back("Bilateral"); - return ids; - } - -private: - void unspecializedInit() ; - - /// Method to get the index position of a @param point Id inside @sa m1 or @sa m2) depending of the value passed in @param cIndices. Return InvalidID if not found. - Index indexOfElemConstraint(const SubsetIndices& cIndices, Index Id); -}; - - -#if !defined(SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionConstraint< Vec3Types >; -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionConstraint< Rigid3Types >; -#endif - -} // namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl index 0aeec985ed2..2b2c2abcc34 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl @@ -20,414 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include // for std::min +#include -namespace sofa::component::constraint::lagrangian::model -{ - -using sofa::core::objectmodel::KeypressedEvent ; -using sofa::core::objectmodel::Event ; -using sofa::helper::WriteAccessor ; -using sofa::type::Vec; - -template -BilateralInteractionConstraint::BilateralInteractionConstraint(MechanicalState* object1, MechanicalState* object2) - : Inherit(object1, object2) - , m1(initData(&m1, "first_point","index of the constraint on the first model")) - , m2(initData(&m2, "second_point","index of the constraint on the second model")) - , restVector(initData(&restVector, "rest_vector","Relative position to maintain between attached points (optional)")) - , d_numericalTolerance(initData(&d_numericalTolerance, 0.0001, "numericalTolerance", - "a real value specifying the tolerance during the constraint solving. (optional, default=0.0001)") ) - , d_activate( initData(&d_activate, true, "activate", "control constraint activation (true by default)")) - , keepOrientDiff(initData(&keepOrientDiff,false, "keepOrientationDifference", "keep the initial difference in orientation (only for rigids)")) - , l_topology1(initLink("topology1", "link to the first topology container")) - , l_topology2(initLink("topology2", "link to the second topology container")) -{ - this->f_listening.setValue(true); -} - -template -BilateralInteractionConstraint::BilateralInteractionConstraint(MechanicalState* object) - : BilateralInteractionConstraint(object, object) -{ -} - -template -BilateralInteractionConstraint::BilateralInteractionConstraint() - : BilateralInteractionConstraint(nullptr, nullptr) -{ -} - -template -void BilateralInteractionConstraint::unspecializedInit() -{ - /// Do general check of validity for inputs - Inherit1::init(); - - /// Using assert means that the previous lines have check that there is two valid mechanical state. - assert(this->mstate1); - assert(this->mstate2); - - prevForces.clear(); -} - -template -void BilateralInteractionConstraint::init() -{ - unspecializedInit(); - - if (sofa::core::topology::BaseMeshTopology* _topology1 = l_topology1.get()) - { - m1.createTopologyHandler(_topology1); - m1.addTopologyEventCallBack(core::topology::TopologyChangeType::POINTSREMOVED, - [this](const core::topology::TopologyChange* change) - { - const auto* pointsRemoved = static_cast(change); - removeContact(0, pointsRemoved->getArray()); - }); - } - - if (sofa::core::topology::BaseMeshTopology* _topology2 = l_topology2.get()) - { - m2.createTopologyHandler(_topology2); - m2.addTopologyEventCallBack(core::topology::TopologyChangeType::POINTSREMOVED, - [this](const core::topology::TopologyChange* change) - { - const auto* pointsRemoved = static_cast(change); - removeContact(1, pointsRemoved->getArray()); - }); - } -} - -template -void BilateralInteractionConstraint::reinit() -{ - prevForces.clear(); -} - - -template -void BilateralInteractionConstraint::buildConstraintMatrix(const ConstraintParams*, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &constraintId - , const DataVecCoord &/*x1*/, const DataVecCoord &/*x2*/) -{ - if (!d_activate.getValue()) - return; - - const unsigned minp = std::min(m1.getValue().size(), m2.getValue().size()); - if (minp == 0) - return; - - const SubsetIndices& m1Indices = m1.getValue(); - const SubsetIndices& m2Indices = m2.getValue(); - - MatrixDeriv &c1 = *c1_d.beginEdit(); - MatrixDeriv &c2 = *c2_d.beginEdit(); - - cid.resize(minp); - - for (unsigned pid=0; pid cx(1,0,0), cy(0,1,0), cz(0,0,1); - - cid[pid] = constraintId; - constraintId += 3; - - MatrixDerivRowIterator c1_it = c1.writeLine(cid[pid]); - c1_it.addCol(tm1, -cx); - - MatrixDerivRowIterator c2_it = c2.writeLine(cid[pid]); - c2_it.addCol(tm2, cx); - - c1_it = c1.writeLine(cid[pid] + 1); - c1_it.setCol(tm1, -cy); - - c2_it = c2.writeLine(cid[pid] + 1); - c2_it.setCol(tm2, cy); - - c1_it = c1.writeLine(cid[pid] + 2); - c1_it.setCol(tm1, -cz); - - c2_it = c2.writeLine(cid[pid] + 2); - c2_it.setCol(tm2, cz); - } - - c1_d.endEdit(); - c2_d.endEdit(); -} - - -template -void BilateralInteractionConstraint::getConstraintViolation(const ConstraintParams* cParams, - BaseVector *v, - const DataVecCoord &d_x1, const DataVecCoord &d_x2 - , const DataVecDeriv & d_v1, const DataVecDeriv & d_v2) -{ - if (!d_activate.getValue()) return; - - const SubsetIndices& m1Indices = m1.getValue(); - const SubsetIndices& m2Indices = m2.getValue(); - - unsigned minp = std::min(m1Indices.size(), m2Indices.size()); - - const VecDeriv& restVector = this->restVector.getValue(); - - if (cParams->constOrder() == sofa::core::ConstraintOrder::VEL) - { - getVelocityViolation(v, d_x1, d_x2, d_v1, d_v2); - return; - } - - const VecCoord &x1 = d_x1.getValue(); - const VecCoord &x2 = d_x2.getValue(); - - dfree.resize(minp); - - for (unsigned pid=0; pidset(cid[pid] , dfree[pid][0]); - v->set(cid[pid]+1, dfree[pid][1]); - v->set(cid[pid]+2, dfree[pid][2]); - } -} - - -template -void BilateralInteractionConstraint::getVelocityViolation(BaseVector *v, - const DataVecCoord &d_x1, - const DataVecCoord &d_x2, - const DataVecDeriv &d_v1, - const DataVecDeriv &d_v2) -{ - const SubsetIndices& m1Indices = m1.getValue(); - const SubsetIndices& m2Indices = m2.getValue(); - - SOFA_UNUSED(d_x1); - SOFA_UNUSED(d_x2); - - const VecCoord &v1 = d_v1.getValue(); - const VecCoord &v2 = d_v2.getValue(); - - const unsigned minp = std::min(m1Indices.size(), m2Indices.size()); - const VecDeriv& restVector = this->restVector.getValue(); - - auto pos1 = this->getMState1()->readPositions(); - auto pos2 = this->getMState2()->readPositions(); - - const SReal dt = this->getContext()->getDt(); - const SReal invDt = SReal(1.0) / dt; - - for (unsigned pid=0; pidset(cid[pid] , dVfree[0] + dPos[0] ); - v->set(cid[pid]+1, dVfree[1] + dPos[1] ); - v->set(cid[pid]+2, dVfree[2] + dPos[2] ); - } -} - - -template -void BilateralInteractionConstraint::getConstraintResolution(const ConstraintParams* cParams, - std::vector& resTab, - unsigned int& offset) -{ - SOFA_UNUSED(cParams); - const unsigned minp=std::min(m1.getValue().size(),m2.getValue().size()); - - prevForces.resize(minp); - for (unsigned pid=0; pid -void BilateralInteractionConstraint::addContact(Deriv /*norm*/, Coord P, Coord Q, - Real /*contactDistance*/, int m1, int m2, - Coord /*Pfree*/, Coord /*Qfree*/, - long /*id*/, PersistentID /*localid*/) -{ - WriteAccessor > wm1 = this->m1; - WriteAccessor > wm2 = this->m2; - WriteAccessor > wrest = this->restVector; - wm1.push_back(m1); - wm2.push_back(m2); - wrest.push_back(Q-P); -} - - -template -void BilateralInteractionConstraint::addContact(Deriv norm, Coord P, Coord Q, Real - contactDistance, int m1, int m2, - long id, PersistentID localid) -{ - addContact(norm, P, Q, contactDistance, m1, m2, - this->getMState2()->read(ConstVecCoordId::freePosition())->getValue()[m2], - this->getMState1()->read(ConstVecCoordId::freePosition())->getValue()[m1], - id, localid); -} - -template -void BilateralInteractionConstraint::addContact(Deriv norm, Real contactDistance, - int m1, int m2, long id, PersistentID localid) -{ - addContact(norm, - this->getMState2()->read(ConstVecCoordId::position())->getValue()[m2], - this->getMState1()->read(ConstVecCoordId::position())->getValue()[m1], - contactDistance, m1, m2, - this->getMState2()->read(ConstVecCoordId::freePosition())->getValue()[m2], - this->getMState1()->read(ConstVecCoordId::freePosition())->getValue()[m1], - id, localid); -} - - -template -void BilateralInteractionConstraint::removeContact(int objectId, SubsetIndices indices) -{ - WriteAccessor > m1Indices = this->m1; - WriteAccessor > m2Indices = this->m2; - WriteAccessor > wrest = this->restVector; - - const SubsetIndices& cIndices1 = m1.getValue(); - const SubsetIndices& cIndices2 = m2.getValue(); - - for (sofa::Size i = 0; i < indices.size(); ++i) - { - const Index elemId = indices[i]; - Index posId = sofa::InvalidID; - - if (objectId == 0) - posId = indexOfElemConstraint(cIndices1, elemId); - else if (objectId == 1) - posId = indexOfElemConstraint(cIndices2, elemId); - - if (posId != sofa::InvalidID) - { - if (wrest.size() == m1Indices.size()) - wrest.erase(wrest.begin() + posId); - - m1Indices.erase(m1Indices.begin() + posId); - m2Indices.erase(m2Indices.begin() + posId); - } - } - -} - - -template -void BilateralInteractionConstraint::clear(int reserve) -{ - WriteAccessor > wm1 = this->m1; - WriteAccessor > wm2 = this->m2; - WriteAccessor > wrest = this->restVector; - wm1.clear(); - wm2.clear(); - wrest.clear(); - if (reserve) - { - wm1.reserve(reserve); - wm2.reserve(reserve); - wrest.reserve(reserve); - } -} - - -template -Index BilateralInteractionConstraint::indexOfElemConstraint(const SubsetIndices& cIndices, Index Id) -{ - const auto it = std::find(cIndices.begin(), cIndices.end(), Id); - - if (it != cIndices.end()) - return Index(std::distance(cIndices.begin(), it)); - else - return sofa::InvalidID; -} - - -template -void BilateralInteractionConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowInteractionForceFields()) return; - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - vparams->drawTool()->disableLighting(); - - constexpr sofa::type::RGBAColor colorActive = sofa::type::RGBAColor::magenta(); - constexpr sofa::type::RGBAColor colorNotActive = sofa::type::RGBAColor::green(); - std::vector< sofa::type::Vec3 > vertices; - - const unsigned minp = std::min(m1.getValue().size(),m2.getValue().size()); - auto positionsM1 = sofa::helper::getReadAccessor(*this->mstate1->read(ConstVecCoordId::position())); - auto positionsM2 = sofa::helper::getReadAccessor(*this->mstate2->read(ConstVecCoordId::position())); - const auto indicesM1 = sofa::helper::getReadAccessor(m1); - const auto indicesM2 = sofa::helper::getReadAccessor(m2); - - for (unsigned i=0; idrawTool()->drawPoints(vertices, 10, (d_activate.getValue()) ? colorActive : colorNotActive); - - -} - -//TODO(dmarchal): implementing keyboard interaction behavior directly in a component is not a valid -//design for a component. Interaction should be defered to an independent Component implemented in the SofaInteraction -//a second possibility is to implement this behavir using script. -template -void BilateralInteractionConstraint::handleEvent(Event *event) -{ - if (KeypressedEvent::checkEventType(event)) - { - const KeypressedEvent *ev = static_cast(event); - switch(ev->getKey()) - { - - case 'A': - case 'a': - if (d_activate.getValue()) - { - msg_info() << "Unactivating constraint"; - d_activate.setValue(false); - } - else - { - msg_info() << "Activating constraint"; - d_activate.setValue(true); - } - - break; - } - } - -} - - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.cpp similarity index 59% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.cpp index 64743d5addb..94f1bfad358 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.cpp @@ -19,9 +19,9 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONCONSTRAINT_CPP +#define SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP -#include +#include #include #include @@ -33,37 +33,37 @@ class RigidImpl {}; template<> -class BilateralInteractionConstraintSpecialization +class BilateralInteractionLagrangianConstraintSpecialization { public: template - static void bwdInit(BilateralInteractionConstraint& self) { + static void bwdInit(BilateralInteractionLagrangianConstraint& self) { if (!self.keepOrientDiff.getValue()) return; - helper::WriteAccessor::VecDeriv > > wrest = self.restVector; + helper::WriteAccessor::VecDeriv > > wrest = self.restVector; if (wrest.size() > 0) { - msg_warning("BilateralInteractionConstraintSpecialization") << "keepOrientationDifference is activated, rest_vector will be ignored! " ; + msg_warning("BilateralInteractionLagrangianConstraintSpecialization") << "keepOrientationDifference is activated, rest_vector will be ignored! " ; wrest.resize(0); } - const typename BilateralInteractionConstraint::SubsetIndices& m1Indices = self.m1.getValue(); - const typename BilateralInteractionConstraint::SubsetIndices& m2Indices = self.m2.getValue(); + const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); + const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); const unsigned minp = std::min(m1Indices.size(),m2Indices.size()); - const typename BilateralInteractionConstraint::DataVecCoord &d_x1 = *self.mstate1->read(core::ConstVecCoordId::position()); - const typename BilateralInteractionConstraint::DataVecCoord &d_x2 = *self.mstate2->read(core::ConstVecCoordId::position()); + const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x1 = *self.mstate1->read(core::ConstVecCoordId::position()); + const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x2 = *self.mstate2->read(core::ConstVecCoordId::position()); - const typename BilateralInteractionConstraint::VecCoord &x1 = d_x1.getValue(); - const typename BilateralInteractionConstraint::VecCoord &x2 = d_x2.getValue(); + const typename BilateralInteractionLagrangianConstraint::VecCoord &x1 = d_x1.getValue(); + const typename BilateralInteractionLagrangianConstraint::VecCoord &x2 = d_x2.getValue(); for (unsigned pid=0; pid::Coord P = x1[m1Indices[pid]]; - const typename BilateralInteractionConstraint::Coord Q = x2[m2Indices[pid]]; + const typename BilateralInteractionLagrangianConstraint::Coord P = x1[m1Indices[pid]]; + const typename BilateralInteractionLagrangianConstraint::Coord Q = x2[m2Indices[pid]]; type::Quat qP, qQ, dQP; qP = P.getOrientation(); @@ -73,7 +73,7 @@ class BilateralInteractionConstraintSpecialization dQP = qP.quatDiff(qQ, qP); dQP.normalize(); - typename BilateralInteractionConstraint::Coord df; + typename BilateralInteractionLagrangianConstraint::Coord df; df.getCenter() = Q.getCenter() - P.getCenter(); df.getOrientation() = dQP; self.initialDifference.push_back(df); @@ -83,7 +83,7 @@ class BilateralInteractionConstraintSpecialization template - static void getConstraintResolution(BilateralInteractionConstraint& self, + static void getConstraintResolution(BilateralInteractionLagrangianConstraint& self, const ConstraintParams* cParams, std::vector& resTab, unsigned int& offset, double tolerance) @@ -104,26 +104,26 @@ class BilateralInteractionConstraintSpecialization template - static void buildConstraintMatrix(BilateralInteractionConstraint& self, + static void buildConstraintMatrix(BilateralInteractionLagrangianConstraint& self, const ConstraintParams* cParams, - typename BilateralInteractionConstraint::DataMatrixDeriv &c1_d, - typename BilateralInteractionConstraint::DataMatrixDeriv &c2_d, + typename BilateralInteractionLagrangianConstraint::DataMatrixDeriv &c1_d, + typename BilateralInteractionLagrangianConstraint::DataMatrixDeriv &c2_d, unsigned int &constraintId, - const typename BilateralInteractionConstraint::DataVecCoord &/*x1*/, - const typename BilateralInteractionConstraint::DataVecCoord &/*x2*/) + const typename BilateralInteractionLagrangianConstraint::DataVecCoord &/*x1*/, + const typename BilateralInteractionLagrangianConstraint::DataVecCoord &/*x2*/) { SOFA_UNUSED(cParams) ; - const typename BilateralInteractionConstraint::SubsetIndices& m1Indices = self.m1.getValue(); - const typename BilateralInteractionConstraint::SubsetIndices& m2Indices = self.m2.getValue(); + const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); + const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); unsigned minp = std::min(m1Indices.size(),m2Indices.size()); self.cid.resize(minp); - typename BilateralInteractionConstraint::MatrixDeriv &c1 = *c1_d.beginEdit(); - typename BilateralInteractionConstraint::MatrixDeriv &c2 = *c2_d.beginEdit(); + typename BilateralInteractionLagrangianConstraint::MatrixDeriv &c1 = *c1_d.beginEdit(); + typename BilateralInteractionLagrangianConstraint::MatrixDeriv &c2 = *c2_d.beginEdit(); - const Vec<3, typename BilateralInteractionConstraint::Real> cx(1,0,0), cy(0,1,0), cz(0,0,1); - const Vec<3, typename BilateralInteractionConstraint::Real> vZero(0,0,0); + const Vec<3, typename BilateralInteractionLagrangianConstraint::Real> cx(1,0,0), cy(0,1,0), cz(0,0,1); + const Vec<3, typename BilateralInteractionLagrangianConstraint::Real> vZero(0,0,0); for (unsigned pid=0; pid constraintId += 6; //Apply constraint for position - typename BilateralInteractionConstraint::MatrixDerivRowIterator c1_it = c1.writeLine(self.cid[pid]); - c1_it.addCol(tm1, typename BilateralInteractionConstraint::Deriv(-cx, vZero)); + typename BilateralInteractionLagrangianConstraint::MatrixDerivRowIterator c1_it = c1.writeLine(self.cid[pid]); + c1_it.addCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(-cx, vZero)); - typename BilateralInteractionConstraint::MatrixDerivRowIterator c2_it = c2.writeLine(self.cid[pid]); - c2_it.addCol(tm2, typename BilateralInteractionConstraint::Deriv(cx, vZero)); + typename BilateralInteractionLagrangianConstraint::MatrixDerivRowIterator c2_it = c2.writeLine(self.cid[pid]); + c2_it.addCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(cx, vZero)); c1_it = c1.writeLine(self.cid[pid] + 1); - c1_it.setCol(tm1, typename BilateralInteractionConstraint::Deriv(-cy, vZero)); + c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(-cy, vZero)); c2_it = c2.writeLine(self.cid[pid] + 1); - c2_it.setCol(tm2, typename BilateralInteractionConstraint::Deriv(cy, vZero)); + c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(cy, vZero)); c1_it = c1.writeLine(self.cid[pid] + 2); - c1_it.setCol(tm1, typename BilateralInteractionConstraint::Deriv(-cz, vZero)); + c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(-cz, vZero)); c2_it = c2.writeLine(self.cid[pid] + 2); - c2_it.setCol(tm2, typename BilateralInteractionConstraint::Deriv(cz, vZero)); + c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(cz, vZero)); //Apply constraint for orientation c1_it = c1.writeLine(self.cid[pid] + 3); - c1_it.setCol(tm1, typename BilateralInteractionConstraint::Deriv(vZero, -cx)); + c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, -cx)); c2_it = c2.writeLine(self.cid[pid] + 3); - c2_it.setCol(tm2, typename BilateralInteractionConstraint::Deriv(vZero, cx)); + c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, cx)); c1_it = c1.writeLine(self.cid[pid] + 4); - c1_it.setCol(tm1, typename BilateralInteractionConstraint::Deriv(vZero, -cy)); + c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, -cy)); c2_it = c2.writeLine(self.cid[pid] + 4); - c2_it.setCol(tm2, typename BilateralInteractionConstraint::Deriv(vZero, cy)); + c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, cy)); c1_it = c1.writeLine(self.cid[pid] + 5); - c1_it.setCol(tm1, typename BilateralInteractionConstraint::Deriv(vZero, -cz)); + c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, -cz)); c2_it = c2.writeLine(self.cid[pid] + 5); - c2_it.setCol(tm2, typename BilateralInteractionConstraint::Deriv(vZero, cz)); + c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, cz)); } c1_d.endEdit(); @@ -178,34 +178,34 @@ class BilateralInteractionConstraintSpecialization template - static void getConstraintViolation(BilateralInteractionConstraint& self, + static void getConstraintViolation(BilateralInteractionLagrangianConstraint& self, const ConstraintParams* /*cParams*/, BaseVector *v, - const typename BilateralInteractionConstraint::DataVecCoord &d_x1, - const typename BilateralInteractionConstraint::DataVecCoord &d_x2, - const typename BilateralInteractionConstraint::DataVecDeriv &/*v1*/, - const typename BilateralInteractionConstraint::DataVecDeriv &/*v2*/) + const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x1, + const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x2, + const typename BilateralInteractionLagrangianConstraint::DataVecDeriv &/*v1*/, + const typename BilateralInteractionLagrangianConstraint::DataVecDeriv &/*v2*/) { - const typename BilateralInteractionConstraint::SubsetIndices& m1Indices = self.m1.getValue(); - const typename BilateralInteractionConstraint::SubsetIndices& m2Indices = self.m2.getValue(); + const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); + const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); unsigned min = std::min(m1Indices.size(), m2Indices.size()); - const typename BilateralInteractionConstraint::VecDeriv& restVector = self.restVector.getValue(); + const typename BilateralInteractionLagrangianConstraint::VecDeriv& restVector = self.restVector.getValue(); self.dfree.resize(min); - const typename BilateralInteractionConstraint::VecCoord &x1 = d_x1.getValue(); - const typename BilateralInteractionConstraint::VecCoord &x2 = d_x2.getValue(); + const typename BilateralInteractionLagrangianConstraint::VecCoord &x1 = d_x1.getValue(); + const typename BilateralInteractionLagrangianConstraint::VecCoord &x2 = d_x2.getValue(); for (unsigned pid=0; pid::Coord dof1 = x1[m1Indices[pid]]; - //typename BilateralInteractionConstraint::Coord dof2 = x2[m2Indices[pid]]; - typename BilateralInteractionConstraint::Coord dof1; + //typename BilateralInteractionLagrangianConstraint::Coord dof1 = x1[m1Indices[pid]]; + //typename BilateralInteractionLagrangianConstraint::Coord dof2 = x2[m2Indices[pid]]; + typename BilateralInteractionLagrangianConstraint::Coord dof1; if (self.keepOrientDiff.getValue()) { - const typename BilateralInteractionConstraint::Coord dof1c = x1[m1Indices[pid]]; + const typename BilateralInteractionLagrangianConstraint::Coord dof1c = x1[m1Indices[pid]]; - typename BilateralInteractionConstraint::Coord corr=self.initialDifference[pid]; + typename BilateralInteractionLagrangianConstraint::Coord corr=self.initialDifference[pid]; type::Quat df = corr.getOrientation(); type::Quat o1 = dof1c.getOrientation(); type::Quat ro1 = o1 * df; @@ -215,7 +215,7 @@ class BilateralInteractionConstraintSpecialization } else dof1 = x1[m1Indices[pid]]; - const typename BilateralInteractionConstraint::Coord dof2 = x2[m2Indices[pid]]; + const typename BilateralInteractionLagrangianConstraint::Coord dof2 = x2[m2Indices[pid]]; getVCenter(self.dfree[pid]) = dof2.getCenter() - dof1.getCenter(); getVOrientation(self.dfree[pid]) = dof1.rotate(self.q.angularDisplacement(dof2.getOrientation() , @@ -229,14 +229,14 @@ class BilateralInteractionConstraintSpecialization } - template > - static void addContact(BilateralInteractionConstraint& self, typename MyClass::Deriv /*norm*/, + template > + static void addContact(BilateralInteractionLagrangianConstraint& self, typename MyClass::Deriv /*norm*/, typename MyClass::Coord P, typename MyClass::Coord Q, typename MyClass::Real /*contactDistance*/, int m1, int m2, typename MyClass::Coord /*Pfree*/, typename MyClass::Coord /*Qfree*/, long /*id*/, typename MyClass::PersistentID /*localid*/) { - helper::WriteAccessor::SubsetIndices > > wm1 = self.m1; - helper::WriteAccessor::SubsetIndices > > wm2 = self.m2; + helper::WriteAccessor::SubsetIndices > > wm1 = self.m1; + helper::WriteAccessor::SubsetIndices > > wm2 = self.m2; helper::WriteAccessor > wrest = self.restVector; wm1.push_back(m1); wm2.push_back(m2); @@ -251,52 +251,52 @@ class BilateralInteractionConstraintSpecialization template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::init(){ +void BilateralInteractionLagrangianConstraint::init(){ unspecializedInit() ; } template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::bwdInit() { - BilateralInteractionConstraintSpecialization::bwdInit(*this); +void BilateralInteractionLagrangianConstraint::bwdInit() { + BilateralInteractionLagrangianConstraintSpecialization::bwdInit(*this); } template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::getConstraintResolution(const ConstraintParams* cParams, +void BilateralInteractionLagrangianConstraint::getConstraintResolution(const ConstraintParams* cParams, std::vector& resTab, unsigned int& offset) { - BilateralInteractionConstraintSpecialization::getConstraintResolution(*this, + BilateralInteractionLagrangianConstraintSpecialization::getConstraintResolution(*this, cParams, resTab, offset, d_numericalTolerance.getValue()) ; } template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::buildConstraintMatrix(const ConstraintParams* cParams, +void BilateralInteractionLagrangianConstraint::buildConstraintMatrix(const ConstraintParams* cParams, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &constraintId, const DataVecCoord &x1, const DataVecCoord &x2) { - BilateralInteractionConstraintSpecialization::buildConstraintMatrix(*this, + BilateralInteractionLagrangianConstraintSpecialization::buildConstraintMatrix(*this, cParams, c1_d, c2_d, constraintId, x1, x2) ; } template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::getConstraintViolation(const ConstraintParams* cParams, +void BilateralInteractionLagrangianConstraint::getConstraintViolation(const ConstraintParams* cParams, BaseVector *v, const DataVecCoord &d_x1, const DataVecCoord &d_x2, const DataVecDeriv &v1, const DataVecDeriv &v2) { - BilateralInteractionConstraintSpecialization::getConstraintViolation(*this, + BilateralInteractionLagrangianConstraintSpecialization::getConstraintViolation(*this, cParams, v, d_x1, d_x2, v1, v2) ; } template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::getVelocityViolation(BaseVector * /*v*/, +void BilateralInteractionLagrangianConstraint::getVelocityViolation(BaseVector * /*v*/, const DataVecCoord &/*x1*/, const DataVecCoord &/*x2*/, const DataVecDeriv &/*v1*/, @@ -306,25 +306,25 @@ void BilateralInteractionConstraint::getVelocityViolation(BaseVecto } template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionConstraint::addContact(Deriv norm, +void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord Pfree, Coord Qfree, long id, PersistentID localid) { - BilateralInteractionConstraintSpecialization::addContact(*this, + BilateralInteractionLagrangianConstraintSpecialization::addContact(*this, norm, P, Q, contactDistance, m1, m2, Pfree, Qfree, id, localid) ; } -int BilateralInteractionConstraintClass = core::RegisterObject("BilateralInteractionConstraint defining an holonomic equality constraint (attachment)") - .add< BilateralInteractionConstraint >() - .add< BilateralInteractionConstraint >() +int BilateralInteractionLagrangianConstraintClass = core::RegisterObject("BilateralInteractionLagrangianConstraint defining an holonomic equality constraint (attachment)") + .add< BilateralInteractionLagrangianConstraint >() + .add< BilateralInteractionLagrangianConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionConstraint; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint; } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h new file mode 100644 index 00000000000..4288af3456a --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h @@ -0,0 +1,198 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +/// These 'using' are in a per-file namespace so they will not leak +/// and polluate the standard namespace. +using sofa::core::behavior::BaseConstraint ; +using sofa::core::behavior::ConstraintResolution ; +using sofa::core::behavior::PairInteractionConstraint ; +using sofa::core::objectmodel::Data ; +using sofa::core::ConstraintParams ; +using sofa::core::ConstVecCoordId; + +using sofa::linearalgebra::BaseVector ; +using sofa::type::Vec3d; +using sofa::type::Quat ; + +using sofa::defaulttype::Rigid3Types ; +using sofa::defaulttype::Vec3Types ; + + +template +class BilateralInteractionLagrangianConstraintSpecialization {}; + + +template +class BilateralInteractionLagrangianConstraint : public PairInteractionConstraint +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(BilateralInteractionLagrangianConstraint,DataTypes), + SOFA_TEMPLATE(PairInteractionConstraint,DataTypes)); + + /// That any templates variation of BilateralInteractionLagrangianConstraintSpecialization are friend. + template + friend class BilateralInteractionLagrangianConstraintSpecialization ; + + typedef PairInteractionConstraint Inherit; + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename Coord::value_type Real; + typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; + + typedef core::behavior::MechanicalState MechanicalState; + typedef BaseConstraint::PersistentID PersistentID; + + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + + using SubsetIndices = type::vector; + using DataSubsetIndices = sofa::core::topology::TopologySubsetIndices; + +protected: + std::vector dfree; + Quat q; + + std::vector cid; + + DataSubsetIndices m1; ///< index of the constraint on the first model + DataSubsetIndices m2; ///< index of the constraint on the second model + Data restVector; ///< Relative position to maintain between attached points (optional) + VecCoord initialDifference; + + Data d_numericalTolerance; ///< a real value specifying the tolerance during the constraint solving. (default=0.0001 + Data d_activate; ///< bool to control constraint activation + Data keepOrientDiff; ///< keep the initial difference in orientation (only for rigids) + + + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology1; ///< Link to be set to the first topology container in order to support topological changes + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology2; ///< Link to be set to the second topology container in order to support topological changes + + std::vector prevForces; + + SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'activateAtIteration' has been removed, please use the Data d_activate instead and an engine or a script to change the behavior at the right step (see PR #3327).") + sofa::core::objectmodel::lifecycle::RemovedData activateAtIteration{this, "v22.12", "v23.06", "activateAtIteration", "use the boolean data 'activate' instead and an engine or a script to change the behavior at the right step (see PR #3327)."}; + + SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'merge' has been removed. Its behavior was unused, undocumented, untested, and unclear (see PR #3328).") + sofa::core::objectmodel::lifecycle::RemovedData merge{this, "v22.12", "v23.06", "merge", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."}; + + SOFA_ATTRIBUTE_DISABLED__BILATERALINTERACTIONCONSTRAINTDATA("Data 'derivative' has been removed. Its behavior was unused, undocumented, untested, and unclear (see PR #3328).") + sofa::core::objectmodel::lifecycle::RemovedData derivative{this, "v22.12", "v23.06", "derivative", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."}; + + + BilateralInteractionLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) ; + BilateralInteractionLagrangianConstraint(MechanicalState* object) ; + BilateralInteractionLagrangianConstraint(); + + virtual ~BilateralInteractionLagrangianConstraint(){} +public: + void init() override; + + void bwdInit() override {} + + void reinit() override; + + void buildConstraintMatrix(const ConstraintParams* cParams, + DataMatrixDeriv &c1, DataMatrixDeriv &c2, + unsigned int &cIndex, + const DataVecCoord &x1, const DataVecCoord &x2) override; + + void getConstraintViolation(const ConstraintParams* cParams, + BaseVector *v, + const DataVecCoord &x1, const DataVecCoord &x2, + const DataVecDeriv &v1, const DataVecDeriv &v2) override; + + void getVelocityViolation(BaseVector *v, + const DataVecCoord &x1, const DataVecCoord &x2, + const DataVecDeriv &v1, const DataVecDeriv &v2); + + void getConstraintResolution(const ConstraintParams* cParams, + std::vector& resTab, + unsigned int& offset) override; + + void handleEvent(sofa::core::objectmodel::Event *event) override; + + void draw(const core::visual::VisualParams* vparams) override; + + void clear(int reserve = 0) ; + + virtual void addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, + int m1, int m2, Coord Pfree, Coord Qfree, + long id=0, PersistentID localid=0); + + void addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, + int m1, int m2, long id=0, PersistentID localid=0) ; + + void addContact(Deriv norm, Real contactDistance, int m1, int m2, + long id=0, PersistentID localid=0) ; + + /// Method to remove a contact using point @param indices and id of buffer: @sa m1 (resp. @sa 2m) if @param objectId is equal to 0 (resp. to 1) + void removeContact(int objectId, SubsetIndices indices); + + virtual type::vector getBilateralInteractionIdentifiers() {return {};} + + virtual type::vector getPairInteractionIdentifiers() override final + { + type::vector ids = getBilateralInteractionIdentifiers(); + ids.push_back("Bilateral"); + return ids; + } + +private: + void unspecializedInit() ; + + /// Method to get the index position of a @param point Id inside @sa m1 or @sa m2) depending of the value passed in @param cIndices. Return InvalidID if not found. + Index indexOfElemConstraint(const SubsetIndices& cIndices, Index Id); +}; + + +#if !defined(SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint< Vec3Types >; +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint< Rigid3Types >; +#endif + +template +using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "BilateralInteractionConstraint has been renamed to BilateralInteractionLagrangianConstraint") = BilateralInteractionLagrangianConstraint; + +} // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl new file mode 100644 index 00000000000..3d0f88b221b --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl @@ -0,0 +1,433 @@ +/****************************************************************************** +* 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 // for std::min + +namespace sofa::component::constraint::lagrangian::model +{ + +using sofa::core::objectmodel::KeypressedEvent ; +using sofa::core::objectmodel::Event ; +using sofa::helper::WriteAccessor ; +using sofa::type::Vec; + +template +BilateralInteractionLagrangianConstraint::BilateralInteractionLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) + : Inherit(object1, object2) + , m1(initData(&m1, "first_point","index of the constraint on the first model")) + , m2(initData(&m2, "second_point","index of the constraint on the second model")) + , restVector(initData(&restVector, "rest_vector","Relative position to maintain between attached points (optional)")) + , d_numericalTolerance(initData(&d_numericalTolerance, 0.0001, "numericalTolerance", + "a real value specifying the tolerance during the constraint solving. (optional, default=0.0001)") ) + , d_activate( initData(&d_activate, true, "activate", "control constraint activation (true by default)")) + , keepOrientDiff(initData(&keepOrientDiff,false, "keepOrientationDifference", "keep the initial difference in orientation (only for rigids)")) + , l_topology1(initLink("topology1", "link to the first topology container")) + , l_topology2(initLink("topology2", "link to the second topology container")) +{ + this->f_listening.setValue(true); +} + +template +BilateralInteractionLagrangianConstraint::BilateralInteractionLagrangianConstraint(MechanicalState* object) + : BilateralInteractionLagrangianConstraint(object, object) +{ +} + +template +BilateralInteractionLagrangianConstraint::BilateralInteractionLagrangianConstraint() + : BilateralInteractionLagrangianConstraint(nullptr, nullptr) +{ +} + +template +void BilateralInteractionLagrangianConstraint::unspecializedInit() +{ + /// Do general check of validity for inputs + Inherit1::init(); + + /// Using assert means that the previous lines have check that there is two valid mechanical state. + assert(this->mstate1); + assert(this->mstate2); + + prevForces.clear(); +} + +template +void BilateralInteractionLagrangianConstraint::init() +{ + unspecializedInit(); + + if (sofa::core::topology::BaseMeshTopology* _topology1 = l_topology1.get()) + { + m1.createTopologyHandler(_topology1); + m1.addTopologyEventCallBack(core::topology::TopologyChangeType::POINTSREMOVED, + [this](const core::topology::TopologyChange* change) + { + const auto* pointsRemoved = static_cast(change); + removeContact(0, pointsRemoved->getArray()); + }); + } + + if (sofa::core::topology::BaseMeshTopology* _topology2 = l_topology2.get()) + { + m2.createTopologyHandler(_topology2); + m2.addTopologyEventCallBack(core::topology::TopologyChangeType::POINTSREMOVED, + [this](const core::topology::TopologyChange* change) + { + const auto* pointsRemoved = static_cast(change); + removeContact(1, pointsRemoved->getArray()); + }); + } +} + +template +void BilateralInteractionLagrangianConstraint::reinit() +{ + prevForces.clear(); +} + + +template +void BilateralInteractionLagrangianConstraint::buildConstraintMatrix(const ConstraintParams*, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &constraintId + , const DataVecCoord &/*x1*/, const DataVecCoord &/*x2*/) +{ + if (!d_activate.getValue()) + return; + + const unsigned minp = std::min(m1.getValue().size(), m2.getValue().size()); + if (minp == 0) + return; + + const SubsetIndices& m1Indices = m1.getValue(); + const SubsetIndices& m2Indices = m2.getValue(); + + MatrixDeriv &c1 = *c1_d.beginEdit(); + MatrixDeriv &c2 = *c2_d.beginEdit(); + + cid.resize(minp); + + for (unsigned pid=0; pid cx(1,0,0), cy(0,1,0), cz(0,0,1); + + cid[pid] = constraintId; + constraintId += 3; + + MatrixDerivRowIterator c1_it = c1.writeLine(cid[pid]); + c1_it.addCol(tm1, -cx); + + MatrixDerivRowIterator c2_it = c2.writeLine(cid[pid]); + c2_it.addCol(tm2, cx); + + c1_it = c1.writeLine(cid[pid] + 1); + c1_it.setCol(tm1, -cy); + + c2_it = c2.writeLine(cid[pid] + 1); + c2_it.setCol(tm2, cy); + + c1_it = c1.writeLine(cid[pid] + 2); + c1_it.setCol(tm1, -cz); + + c2_it = c2.writeLine(cid[pid] + 2); + c2_it.setCol(tm2, cz); + } + + c1_d.endEdit(); + c2_d.endEdit(); +} + + +template +void BilateralInteractionLagrangianConstraint::getConstraintViolation(const ConstraintParams* cParams, + BaseVector *v, + const DataVecCoord &d_x1, const DataVecCoord &d_x2 + , const DataVecDeriv & d_v1, const DataVecDeriv & d_v2) +{ + if (!d_activate.getValue()) return; + + const SubsetIndices& m1Indices = m1.getValue(); + const SubsetIndices& m2Indices = m2.getValue(); + + unsigned minp = std::min(m1Indices.size(), m2Indices.size()); + + const VecDeriv& restVector = this->restVector.getValue(); + + if (cParams->constOrder() == sofa::core::ConstraintOrder::VEL) + { + getVelocityViolation(v, d_x1, d_x2, d_v1, d_v2); + return; + } + + const VecCoord &x1 = d_x1.getValue(); + const VecCoord &x2 = d_x2.getValue(); + + dfree.resize(minp); + + for (unsigned pid=0; pidset(cid[pid] , dfree[pid][0]); + v->set(cid[pid]+1, dfree[pid][1]); + v->set(cid[pid]+2, dfree[pid][2]); + } +} + + +template +void BilateralInteractionLagrangianConstraint::getVelocityViolation(BaseVector *v, + const DataVecCoord &d_x1, + const DataVecCoord &d_x2, + const DataVecDeriv &d_v1, + const DataVecDeriv &d_v2) +{ + const SubsetIndices& m1Indices = m1.getValue(); + const SubsetIndices& m2Indices = m2.getValue(); + + SOFA_UNUSED(d_x1); + SOFA_UNUSED(d_x2); + + const VecCoord &v1 = d_v1.getValue(); + const VecCoord &v2 = d_v2.getValue(); + + const unsigned minp = std::min(m1Indices.size(), m2Indices.size()); + const VecDeriv& restVector = this->restVector.getValue(); + + auto pos1 = this->getMState1()->readPositions(); + auto pos2 = this->getMState2()->readPositions(); + + const SReal dt = this->getContext()->getDt(); + const SReal invDt = SReal(1.0) / dt; + + for (unsigned pid=0; pidset(cid[pid] , dVfree[0] + dPos[0] ); + v->set(cid[pid]+1, dVfree[1] + dPos[1] ); + v->set(cid[pid]+2, dVfree[2] + dPos[2] ); + } +} + + +template +void BilateralInteractionLagrangianConstraint::getConstraintResolution(const ConstraintParams* cParams, + std::vector& resTab, + unsigned int& offset) +{ + SOFA_UNUSED(cParams); + const unsigned minp=std::min(m1.getValue().size(),m2.getValue().size()); + + prevForces.resize(minp); + for (unsigned pid=0; pid +void BilateralInteractionLagrangianConstraint::addContact(Deriv /*norm*/, Coord P, Coord Q, + Real /*contactDistance*/, int m1, int m2, + Coord /*Pfree*/, Coord /*Qfree*/, + long /*id*/, PersistentID /*localid*/) +{ + WriteAccessor > wm1 = this->m1; + WriteAccessor > wm2 = this->m2; + WriteAccessor > wrest = this->restVector; + wm1.push_back(m1); + wm2.push_back(m2); + wrest.push_back(Q-P); +} + + +template +void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, Coord P, Coord Q, Real + contactDistance, int m1, int m2, + long id, PersistentID localid) +{ + addContact(norm, P, Q, contactDistance, m1, m2, + this->getMState2()->read(ConstVecCoordId::freePosition())->getValue()[m2], + this->getMState1()->read(ConstVecCoordId::freePosition())->getValue()[m1], + id, localid); +} + +template +void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, Real contactDistance, + int m1, int m2, long id, PersistentID localid) +{ + addContact(norm, + this->getMState2()->read(ConstVecCoordId::position())->getValue()[m2], + this->getMState1()->read(ConstVecCoordId::position())->getValue()[m1], + contactDistance, m1, m2, + this->getMState2()->read(ConstVecCoordId::freePosition())->getValue()[m2], + this->getMState1()->read(ConstVecCoordId::freePosition())->getValue()[m1], + id, localid); +} + + +template +void BilateralInteractionLagrangianConstraint::removeContact(int objectId, SubsetIndices indices) +{ + WriteAccessor > m1Indices = this->m1; + WriteAccessor > m2Indices = this->m2; + WriteAccessor > wrest = this->restVector; + + const SubsetIndices& cIndices1 = m1.getValue(); + const SubsetIndices& cIndices2 = m2.getValue(); + + for (sofa::Size i = 0; i < indices.size(); ++i) + { + const Index elemId = indices[i]; + Index posId = sofa::InvalidID; + + if (objectId == 0) + posId = indexOfElemConstraint(cIndices1, elemId); + else if (objectId == 1) + posId = indexOfElemConstraint(cIndices2, elemId); + + if (posId != sofa::InvalidID) + { + if (wrest.size() == m1Indices.size()) + wrest.erase(wrest.begin() + posId); + + m1Indices.erase(m1Indices.begin() + posId); + m2Indices.erase(m2Indices.begin() + posId); + } + } + +} + + +template +void BilateralInteractionLagrangianConstraint::clear(int reserve) +{ + WriteAccessor > wm1 = this->m1; + WriteAccessor > wm2 = this->m2; + WriteAccessor > wrest = this->restVector; + wm1.clear(); + wm2.clear(); + wrest.clear(); + if (reserve) + { + wm1.reserve(reserve); + wm2.reserve(reserve); + wrest.reserve(reserve); + } +} + + +template +Index BilateralInteractionLagrangianConstraint::indexOfElemConstraint(const SubsetIndices& cIndices, Index Id) +{ + const auto it = std::find(cIndices.begin(), cIndices.end(), Id); + + if (it != cIndices.end()) + return Index(std::distance(cIndices.begin(), it)); + else + return sofa::InvalidID; +} + + +template +void BilateralInteractionLagrangianConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowInteractionForceFields()) return; + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + vparams->drawTool()->disableLighting(); + + constexpr sofa::type::RGBAColor colorActive = sofa::type::RGBAColor::magenta(); + constexpr sofa::type::RGBAColor colorNotActive = sofa::type::RGBAColor::green(); + std::vector< sofa::type::Vec3 > vertices; + + const unsigned minp = std::min(m1.getValue().size(),m2.getValue().size()); + auto positionsM1 = sofa::helper::getReadAccessor(*this->mstate1->read(ConstVecCoordId::position())); + auto positionsM2 = sofa::helper::getReadAccessor(*this->mstate2->read(ConstVecCoordId::position())); + const auto indicesM1 = sofa::helper::getReadAccessor(m1); + const auto indicesM2 = sofa::helper::getReadAccessor(m2); + + for (unsigned i=0; idrawTool()->drawPoints(vertices, 10, (d_activate.getValue()) ? colorActive : colorNotActive); + + +} + +//TODO(dmarchal): implementing keyboard interaction behavior directly in a component is not a valid +//design for a component. Interaction should be defered to an independent Component implemented in the SofaInteraction +//a second possibility is to implement this behavir using script. +template +void BilateralInteractionLagrangianConstraint::handleEvent(Event *event) +{ + if (KeypressedEvent::checkEventType(event)) + { + const KeypressedEvent *ev = static_cast(event); + switch(ev->getKey()) + { + + case 'A': + case 'a': + if (d_activate.getValue()) + { + msg_info() << "Unactivating constraint"; + d_activate.setValue(false); + } + else + { + msg_info() << "Activating constraint"; + d_activate.setValue(true); + } + + break; + } + } + +} + + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h index 19e2a124a90..ae6e1f0482e 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h @@ -20,94 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include +#include -namespace sofa::component::constraint::lagrangian::model -{ - -using sofa::core::ConstraintParams; - -template -class SlidingConstraint : public core::behavior::PairInteractionConstraint -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(SlidingConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::PairInteractionConstraint,DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename Coord::value_type Real; - typedef typename core::behavior::MechanicalState MechanicalState; - typedef typename core::behavior::PairInteractionConstraint Inherit; - - typedef core::objectmodel::Data DataVecCoord; - typedef core::objectmodel::Data DataVecDeriv; - typedef core::objectmodel::Data DataMatrixDeriv; - -protected: - - Data d_m1; ///< index of the spliding point on the first model - Data d_m2a; ///< index of one end of the sliding axis - Data d_m2b; ///< index of the other end of the sliding axis - Data d_force; ///< interaction force - - Real m_dist; // constraint violation - Real m_thirdConstraint; // 0 if A getSlidingIdentifiers() { return {}; } - - virtual type::vector getPairInteractionIdentifiers() override final - { - type::vector ids = getSlidingIdentifiers(); - ids.push_back("Sliding"); - return ids; - } - - -public: - void init() override; - - void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c1, DataMatrixDeriv &c2, unsigned int &cIndex - , const DataVecCoord &x1, const DataVecCoord &x2) override; - - void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *v, const DataVecCoord &x1, const DataVecCoord &x2 - , const DataVecDeriv &v1, const DataVecDeriv &v2) override; - - void getConstraintResolution(const core::ConstraintParams*, - std::vector& resTab, - unsigned int& offset) override; - void storeLambda(const ConstraintParams* cParams, sofa::core::MultiVecDerivId res, const sofa::linearalgebra::BaseVector* lambda) override; - - void draw(const core::visual::VisualParams* vparams) override; - -private: - // storage of force - Deriv m_dirAxe, m_dirProj, m_dirOrtho; - - - -}; - -#if !defined(SOFA_COMPONENT_CONSTRAINTSET_SLIDINGCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API SlidingConstraint< defaulttype::Vec3Types >; - -#endif - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl index e656c12cc7c..c328ba4d984 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl @@ -20,207 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -namespace sofa::component::constraint::lagrangian::model -{ -template -SlidingConstraint::SlidingConstraint() - : SlidingConstraint(nullptr, nullptr) -{ -} +#include -template -SlidingConstraint::SlidingConstraint(MechanicalState* object) - : SlidingConstraint(object, object) -{ -} - -template -SlidingConstraint::SlidingConstraint(MechanicalState* object1, MechanicalState* object2) - : Inherit(object1, object2) - , d_m1(initData(&d_m1, 0, "sliding_point","index of the spliding point on the first model")) - , d_m2a(initData(&d_m2a, 0, "axis_1","index of one end of the sliding axis")) - , d_m2b(initData(&d_m2b, 0, "axis_2","index of the other end of the sliding axis")) - , d_force(initData(&d_force,"force","force (impulse) used to solve the constraint")) -{ -} - -template -void SlidingConstraint::init() -{ - assert(this->mstate1); - assert(this->mstate2); - - m_thirdConstraint = 0; -} - - -template -void SlidingConstraint::buildConstraintMatrix(const core::ConstraintParams*, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &cIndex - , const DataVecCoord &x1, const DataVecCoord &x2) -{ - int tm1 = d_m1.getValue(); - int tm2a = d_m2a.getValue(); - int tm2b = d_m2b.getValue(); - - MatrixDeriv &c1 = *c1_d.beginEdit(); - MatrixDeriv &c2 = *c2_d.beginEdit(); - - const Coord P = x1.getValue()[tm1]; - const Coord A = x2.getValue()[tm2a]; - const Coord B = x2.getValue()[tm2b]; - - // the axis - m_dirAxe = B - A; - const Real ab = m_dirAxe.norm(); - m_dirAxe.normalize(); - - // projection of the point on the axis - Real r = (P-A) * m_dirAxe; - Real r2 = r / ab; - const Deriv proj = A + m_dirAxe * r; - - // We move the constraint point onto the projection - m_dirProj = P - proj; - m_dist = m_dirProj.norm(); // constraint violation - m_dirProj.normalize(); // direction of the constraint - - m_dirOrtho = cross(m_dirProj, m_dirAxe); - m_dirOrtho.normalize(); - - m_cid = cIndex; - cIndex += 2; - - MatrixDerivRowIterator c1_it = c1.writeLine(m_cid); - c1_it.addCol(tm1, m_dirProj); - - MatrixDerivRowIterator c2_it = c2.writeLine(m_cid); - c2_it.addCol(tm2a, -m_dirProj * (1-r2)); - c2_it.addCol(tm2b, -m_dirProj * r2); - - c1_it = c1.writeLine(m_cid + 1); - c1_it.setCol(tm1, m_dirOrtho); - - c2_it = c2.writeLine(m_cid + 1); - c2_it.addCol(tm2a, -m_dirOrtho * (1-r2)); - c2_it.addCol(tm2b, -m_dirOrtho * r2); - - m_thirdConstraint = 0; - - if (r < 0) - { - m_thirdConstraint = r; - cIndex++; - - c1_it = c1.writeLine(m_cid + 2); - c1_it.setCol(tm1, m_dirAxe); - - c2_it = c2.writeLine(m_cid + 2); - c2_it.addCol(tm2a, -m_dirAxe); - } - else if (r > ab) - { - m_thirdConstraint = r - ab; - cIndex++; - - c1_it = c1.writeLine(m_cid + 2); - c1_it.setCol(tm1, -m_dirAxe); - - c2_it = c2.writeLine(m_cid + 2); - c2_it.addCol(tm2b, m_dirAxe); - } - - c1_d.endEdit(); - c2_d.endEdit(); -} - - -template -void SlidingConstraint::getConstraintViolation(const core::ConstraintParams *, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & - , const DataVecDeriv &, const DataVecDeriv &) -{ - v->set(m_cid, m_dist); - v->set(m_cid+1, 0.0); - - if(m_thirdConstraint) - { - if(m_thirdConstraint>0) - v->set(m_cid+2, -m_thirdConstraint); - else - v->set(m_cid+2, m_thirdConstraint); - } -} - - -template -void SlidingConstraint::getConstraintResolution(const ConstraintParams*, - std::vector& resTab, - unsigned int& offset) -{ - resTab[offset++] = new BilateralConstraintResolution(); - resTab[offset++] = new BilateralConstraintResolution(); - - if(m_thirdConstraint) - resTab[offset++] = new UnilateralConstraintResolution(); -} - - -template -void SlidingConstraint::storeLambda(const ConstraintParams* /*cParams*/, sofa::core::MultiVecDerivId /*res*/, const sofa::linearalgebra::BaseVector* lambda) -{ - Real lamb1,lamb2, lamb3; - - lamb1 = lambda->element(m_cid); - lamb2 = lambda->element(m_cid+1); - - if(m_thirdConstraint) - { - lamb3 = lambda->element(m_cid+2); - d_force.setValue( m_dirProj* lamb1 + m_dirOrtho * lamb2 + m_dirAxe * lamb3); - } - else - { - d_force.setValue( m_dirProj* lamb1 + m_dirOrtho * lamb2 ); - } -} - -template -void SlidingConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowInteractionForceFields()) - return; - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - vparams->drawTool()->disableLighting(); - - sofa::type::RGBAColor color; - - if(m_thirdConstraint<0) - color = sofa::type::RGBAColor::yellow(); - else if(m_thirdConstraint>0) - color = sofa::type::RGBAColor::green(); - else - color = sofa::type::RGBAColor::magenta(); - - std::vector vertices; - vertices.push_back(DataTypes::getCPos((this->mstate1->read(core::ConstVecCoordId::position())->getValue())[d_m1.getValue()])); - - vparams->drawTool()->drawPoints(vertices, 10, color); - vertices.clear(); - - color = sofa::type::RGBAColor::blue(); - vertices.push_back(DataTypes::getCPos((this->mstate2->read(core::ConstVecCoordId::position())->getValue())[d_m2a.getValue()])); - vertices.push_back(DataTypes::getCPos((this->mstate2->read(core::ConstVecCoordId::position())->getValue())[d_m2b.getValue()])); - vparams->drawTool()->drawLines(vertices, 1, color); - - -} - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.cpp similarity index 85% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.cpp index a3e1d474ae9..86f42c1935b 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.cpp @@ -19,9 +19,9 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINTSET_SLIDINGCONSTRAINT_CPP +#define SOFA_COMPONENT_CONSTRAINTSET_SLIDINGLAGRANGIANCONSTRAINT_CPP -#include +#include #include #include @@ -32,10 +32,10 @@ namespace sofa::component::constraint::lagrangian::model using namespace sofa::defaulttype; using namespace sofa::helper; -int SlidingConstraintClass = core::RegisterObject("TODO-SlidingConstraint") - .add< SlidingConstraint >(true); +int SlidingLagrangianConstraintClass = core::RegisterObject("TODO-SlidingLagrangianConstraint") + .add< SlidingLagrangianConstraint >(true); -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API SlidingConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API SlidingLagrangianConstraint; } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h new file mode 100644 index 00000000000..a450eea0ce1 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h @@ -0,0 +1,117 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +using sofa::core::ConstraintParams; + +template +class SlidingLagrangianConstraint : public core::behavior::PairInteractionConstraint +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(SlidingLagrangianConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::PairInteractionConstraint,DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename Coord::value_type Real; + typedef typename core::behavior::MechanicalState MechanicalState; + typedef typename core::behavior::PairInteractionConstraint Inherit; + + typedef core::objectmodel::Data DataVecCoord; + typedef core::objectmodel::Data DataVecDeriv; + typedef core::objectmodel::Data DataMatrixDeriv; + +protected: + + Data d_m1; ///< index of the spliding point on the first model + Data d_m2a; ///< index of one end of the sliding axis + Data d_m2b; ///< index of the other end of the sliding axis + Data d_force; ///< interaction force + + Real m_dist; // constraint violation + Real m_thirdConstraint; // 0 if A getSlidingIdentifiers() { return {}; } + + virtual type::vector getPairInteractionIdentifiers() override final + { + type::vector ids = getSlidingIdentifiers(); + ids.push_back("Sliding"); + return ids; + } + + +public: + void init() override; + + void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c1, DataMatrixDeriv &c2, unsigned int &cIndex + , const DataVecCoord &x1, const DataVecCoord &x2) override; + + void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *v, const DataVecCoord &x1, const DataVecCoord &x2 + , const DataVecDeriv &v1, const DataVecDeriv &v2) override; + + void getConstraintResolution(const core::ConstraintParams*, + std::vector& resTab, + unsigned int& offset) override; + void storeLambda(const ConstraintParams* cParams, sofa::core::MultiVecDerivId res, const sofa::linearalgebra::BaseVector* lambda) override; + + void draw(const core::visual::VisualParams* vparams) override; + +private: + // storage of force + Deriv m_dirAxe, m_dirProj, m_dirOrtho; + + + +}; + +#if !defined(SOFA_COMPONENT_CONSTRAINTSET_SLIDINGLAGRANGIANCONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API SlidingLagrangianConstraint< defaulttype::Vec3Types >; + +#endif + +template +using SlidingConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SlidingConstraint has been renamed to SlidingLagrangianConstraint") = SlidingLagrangianConstraint; + + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl new file mode 100644 index 00000000000..3581c3dc7a6 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl @@ -0,0 +1,226 @@ +/****************************************************************************** +* 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 +namespace sofa::component::constraint::lagrangian::model +{ + +template +SlidingLagrangianConstraint::SlidingLagrangianConstraint() + : SlidingLagrangianConstraint(nullptr, nullptr) +{ +} + +template +SlidingLagrangianConstraint::SlidingLagrangianConstraint(MechanicalState* object) + : SlidingLagrangianConstraint(object, object) +{ +} + +template +SlidingLagrangianConstraint::SlidingLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) + : Inherit(object1, object2) + , d_m1(initData(&d_m1, 0, "sliding_point","index of the spliding point on the first model")) + , d_m2a(initData(&d_m2a, 0, "axis_1","index of one end of the sliding axis")) + , d_m2b(initData(&d_m2b, 0, "axis_2","index of the other end of the sliding axis")) + , d_force(initData(&d_force,"force","force (impulse) used to solve the constraint")) +{ +} + +template +void SlidingLagrangianConstraint::init() +{ + assert(this->mstate1); + assert(this->mstate2); + + m_thirdConstraint = 0; +} + + +template +void SlidingLagrangianConstraint::buildConstraintMatrix(const core::ConstraintParams*, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &cIndex + , const DataVecCoord &x1, const DataVecCoord &x2) +{ + int tm1 = d_m1.getValue(); + int tm2a = d_m2a.getValue(); + int tm2b = d_m2b.getValue(); + + MatrixDeriv &c1 = *c1_d.beginEdit(); + MatrixDeriv &c2 = *c2_d.beginEdit(); + + const Coord P = x1.getValue()[tm1]; + const Coord A = x2.getValue()[tm2a]; + const Coord B = x2.getValue()[tm2b]; + + // the axis + m_dirAxe = B - A; + const Real ab = m_dirAxe.norm(); + m_dirAxe.normalize(); + + // projection of the point on the axis + Real r = (P-A) * m_dirAxe; + Real r2 = r / ab; + const Deriv proj = A + m_dirAxe * r; + + // We move the constraint point onto the projection + m_dirProj = P - proj; + m_dist = m_dirProj.norm(); // constraint violation + m_dirProj.normalize(); // direction of the constraint + + m_dirOrtho = cross(m_dirProj, m_dirAxe); + m_dirOrtho.normalize(); + + m_cid = cIndex; + cIndex += 2; + + MatrixDerivRowIterator c1_it = c1.writeLine(m_cid); + c1_it.addCol(tm1, m_dirProj); + + MatrixDerivRowIterator c2_it = c2.writeLine(m_cid); + c2_it.addCol(tm2a, -m_dirProj * (1-r2)); + c2_it.addCol(tm2b, -m_dirProj * r2); + + c1_it = c1.writeLine(m_cid + 1); + c1_it.setCol(tm1, m_dirOrtho); + + c2_it = c2.writeLine(m_cid + 1); + c2_it.addCol(tm2a, -m_dirOrtho * (1-r2)); + c2_it.addCol(tm2b, -m_dirOrtho * r2); + + m_thirdConstraint = 0; + + if (r < 0) + { + m_thirdConstraint = r; + cIndex++; + + c1_it = c1.writeLine(m_cid + 2); + c1_it.setCol(tm1, m_dirAxe); + + c2_it = c2.writeLine(m_cid + 2); + c2_it.addCol(tm2a, -m_dirAxe); + } + else if (r > ab) + { + m_thirdConstraint = r - ab; + cIndex++; + + c1_it = c1.writeLine(m_cid + 2); + c1_it.setCol(tm1, -m_dirAxe); + + c2_it = c2.writeLine(m_cid + 2); + c2_it.addCol(tm2b, m_dirAxe); + } + + c1_d.endEdit(); + c2_d.endEdit(); +} + + +template +void SlidingLagrangianConstraint::getConstraintViolation(const core::ConstraintParams *, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & + , const DataVecDeriv &, const DataVecDeriv &) +{ + v->set(m_cid, m_dist); + v->set(m_cid+1, 0.0); + + if(m_thirdConstraint) + { + if(m_thirdConstraint>0) + v->set(m_cid+2, -m_thirdConstraint); + else + v->set(m_cid+2, m_thirdConstraint); + } +} + + +template +void SlidingLagrangianConstraint::getConstraintResolution(const ConstraintParams*, + std::vector& resTab, + unsigned int& offset) +{ + resTab[offset++] = new BilateralConstraintResolution(); + resTab[offset++] = new BilateralConstraintResolution(); + + if(m_thirdConstraint) + resTab[offset++] = new UnilateralConstraintResolution(); +} + + +template +void SlidingLagrangianConstraint::storeLambda(const ConstraintParams* /*cParams*/, sofa::core::MultiVecDerivId /*res*/, const sofa::linearalgebra::BaseVector* lambda) +{ + Real lamb1,lamb2, lamb3; + + lamb1 = lambda->element(m_cid); + lamb2 = lambda->element(m_cid+1); + + if(m_thirdConstraint) + { + lamb3 = lambda->element(m_cid+2); + d_force.setValue( m_dirProj* lamb1 + m_dirOrtho * lamb2 + m_dirAxe * lamb3); + } + else + { + d_force.setValue( m_dirProj* lamb1 + m_dirOrtho * lamb2 ); + } +} + +template +void SlidingLagrangianConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowInteractionForceFields()) + return; + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + vparams->drawTool()->disableLighting(); + + sofa::type::RGBAColor color; + + if(m_thirdConstraint<0) + color = sofa::type::RGBAColor::yellow(); + else if(m_thirdConstraint>0) + color = sofa::type::RGBAColor::green(); + else + color = sofa::type::RGBAColor::magenta(); + + std::vector vertices; + vertices.push_back(DataTypes::getCPos((this->mstate1->read(core::ConstVecCoordId::position())->getValue())[d_m1.getValue()])); + + vparams->drawTool()->drawPoints(vertices, 10, color); + vertices.clear(); + + color = sofa::type::RGBAColor::blue(); + vertices.push_back(DataTypes::getCPos((this->mstate2->read(core::ConstVecCoordId::position())->getValue())[d_m2a.getValue()])); + vertices.push_back(DataTypes::getCPos((this->mstate2->read(core::ConstVecCoordId::position())->getValue())[d_m2b.getValue()])); + vparams->drawTool()->drawLines(vertices, 1, color); + + +} + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h index 42cdea0cfcf..3f685373bd3 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h @@ -20,108 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::lagrangian::model -{ - -class StopperConstraintResolution1Dof : public core::behavior::ConstraintResolution -{ -protected: - double _invW, _w, _min, _max ; - -public: - - StopperConstraintResolution1Dof(const double &min, const double &max) - : core::behavior::ConstraintResolution(1) - , _min(min) - , _max(max) - { - } - - void init(int line, SReal** w, SReal*force) override - { - _w = w[line][line]; - _invW = 1.0/_w; - force[line ] = 0.0; - } - - void resolution(int line, SReal** /*w*/, SReal* d, SReal* force, SReal*) override - { - const double dfree = d[line] - _w * force[line]; - - if (dfree > _max) - force[line] = (_max - dfree) * _invW; - else if (dfree < _min) - force[line] = (_min - dfree) * _invW; - else - force[line] = 0; - } -}; - -template< class DataTypes > -class StopperConstraint : public core::behavior::Constraint -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(StopperConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::Constraint,DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename Coord::value_type Real; - typedef typename core::behavior::MechanicalState MechanicalState; - typedef typename core::behavior::Constraint Inherit; - - typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef core::objectmodel::Data DataVecCoord; - typedef core::objectmodel::Data DataVecDeriv; - typedef core::objectmodel::Data DataMatrixDeriv; - -protected: - - unsigned int cid; - - Data index; ///< index of the stop constraint - Data min; ///< minimum value accepted - Data max; ///< maximum value accepted - - - - StopperConstraint(MechanicalState* object = nullptr); - - virtual ~StopperConstraint() {} - - - virtual type::vector getConstraintIdentifiers() override final - { - type::vector ids = getStopperIdentifiers(); - ids.push_back("Stopper"); - ids.push_back("Unilateral"); - return ids; - } - - virtual type::vector getStopperIdentifiers(){ return {}; } - - - -public: - void init() override; - void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c_d, unsigned int &cIndex, const DataVecCoord &x) override; - void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &v) override; - - void getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) override; -}; - -#if !defined(SOFA_COMPONENT_CONSTRAINTSET_STOPPERCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API StopperConstraint; - -#endif - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl index 6f1e04be10f..574e86c8db3 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl @@ -20,62 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include +#include -namespace sofa::component::constraint::lagrangian::model -{ - -template -StopperConstraint::StopperConstraint(MechanicalState* object) - : Inherit(object) - , index(initData(&index, 0, "index", "index of the stop constraint")) - , min(initData(&min, -100.0_sreal, "min", "minimum value accepted")) - , max(initData(&max, 100.0_sreal, "max", "maximum value accepted")) -{ -} - -template -void StopperConstraint::init() -{ - this->mstate = dynamic_cast(this->getContext()->getMechanicalState()); - assert(this->mstate); - - helper::WriteAccessor > xData = *this->mstate->write(core::VecCoordId::position()); - VecCoord& x = xData.wref(); - if (x[index.getValue()].x() < min.getValue()) - x[index.getValue()].x() = (Real) min.getValue(); - if (x[index.getValue()].x() > max.getValue()) - x[index.getValue()].x() = (Real) max.getValue(); -} - -template -void StopperConstraint::buildConstraintMatrix(const core::ConstraintParams* /*cParams*/, DataMatrixDeriv &c_d, unsigned int &cIndex, const DataVecCoord &/*x*/) -{ - cid = cIndex; - - MatrixDeriv& c = *c_d.beginEdit(); - - MatrixDerivRowIterator c_it = c.writeLine(cid); - c_it.setCol(index.getValue(), Coord(1)); - - cIndex++; - c_d.endEdit(); -} - -template -void StopperConstraint::getConstraintViolation(const core::ConstraintParams* /*cParams*/, linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &/*v*/) -{ - resV->set(cid, x.getValue()[index.getValue()][0]); -} - -template -void StopperConstraint::getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) -{ - for(int i=0; i<1; i++) - resTab[offset++] = new StopperConstraintResolution1Dof(min.getValue(), max.getValue()); -} - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.cpp similarity index 85% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.cpp index a56e09d0713..431a80e8428 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINTSET_STOPPERCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_CONSTRAINTSET_STOPPERLAGRANGIANCONSTRAINT_CPP +#include #include #include @@ -31,12 +31,12 @@ namespace sofa::component::constraint::lagrangian::model using namespace sofa::defaulttype; using namespace sofa::helper; -int StopperConstraintClass = core::RegisterObject("TODO-StopperConstraint") - .add< StopperConstraint >() +int StopperLagrangianConstraintClass = core::RegisterObject("TODO-StopperLagrangianConstraint") + .add< StopperLagrangianConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API StopperConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API StopperLagrangianConstraint; } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h new file mode 100644 index 00000000000..d285a11b53d --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h @@ -0,0 +1,131 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +class StopperLagrangianConstraintResolution1Dof : public core::behavior::ConstraintResolution +{ +protected: + double _invW, _w, _min, _max ; + +public: + + StopperLagrangianConstraintResolution1Dof(const double &min, const double &max) + : core::behavior::ConstraintResolution(1) + , _min(min) + , _max(max) + { + } + + void init(int line, SReal** w, SReal*force) override + { + _w = w[line][line]; + _invW = 1.0/_w; + force[line ] = 0.0; + } + + void resolution(int line, SReal** /*w*/, SReal* d, SReal* force, SReal*) override + { + const double dfree = d[line] - _w * force[line]; + + if (dfree > _max) + force[line] = (_max - dfree) * _invW; + else if (dfree < _min) + force[line] = (_min - dfree) * _invW; + else + force[line] = 0; + } +}; + +template< class DataTypes > +class StopperLagrangianConstraint : public core::behavior::Constraint +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(StopperLagrangianConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::Constraint,DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename Coord::value_type Real; + typedef typename core::behavior::MechanicalState MechanicalState; + typedef typename core::behavior::Constraint Inherit; + + typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef core::objectmodel::Data DataVecCoord; + typedef core::objectmodel::Data DataVecDeriv; + typedef core::objectmodel::Data DataMatrixDeriv; + +protected: + + unsigned int cid; + + Data index; ///< index of the stop constraint + Data min; ///< minimum value accepted + Data max; ///< maximum value accepted + + + + StopperLagrangianConstraint(MechanicalState* object = nullptr); + + virtual ~StopperLagrangianConstraint() {} + + + virtual type::vector getConstraintIdentifiers() override final + { + type::vector ids = getStopperIdentifiers(); + ids.push_back("Stopper"); + ids.push_back("Unilateral"); + return ids; + } + + virtual type::vector getStopperIdentifiers(){ return {}; } + + + +public: + void init() override; + void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c_d, unsigned int &cIndex, const DataVecCoord &x) override; + void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &v) override; + + void getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) override; +}; + +#if !defined(SOFA_COMPONENT_CONSTRAINTSET_STOPPERLAGRANGIANCONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API StopperLagrangianConstraint; + +#endif + +template +using StopperConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "StopperConstraint has been renamed to StopperLagrangianConstraint") = StopperLagrangianConstraint; + + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl new file mode 100644 index 00000000000..7265ab54804 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl @@ -0,0 +1,81 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +template +StopperLagrangianConstraint::StopperLagrangianConstraint(MechanicalState* object) + : Inherit(object) + , index(initData(&index, 0, "index", "index of the stop constraint")) + , min(initData(&min, -100.0_sreal, "min", "minimum value accepted")) + , max(initData(&max, 100.0_sreal, "max", "maximum value accepted")) +{ +} + +template +void StopperLagrangianConstraint::init() +{ + this->mstate = dynamic_cast(this->getContext()->getMechanicalState()); + assert(this->mstate); + + helper::WriteAccessor > xData = *this->mstate->write(core::VecCoordId::position()); + VecCoord& x = xData.wref(); + if (x[index.getValue()].x() < min.getValue()) + x[index.getValue()].x() = (Real) min.getValue(); + if (x[index.getValue()].x() > max.getValue()) + x[index.getValue()].x() = (Real) max.getValue(); +} + +template +void StopperLagrangianConstraint::buildConstraintMatrix(const core::ConstraintParams* /*cParams*/, DataMatrixDeriv &c_d, unsigned int &cIndex, const DataVecCoord &/*x*/) +{ + cid = cIndex; + + MatrixDeriv& c = *c_d.beginEdit(); + + MatrixDerivRowIterator c_it = c.writeLine(cid); + c_it.setCol(index.getValue(), Coord(1)); + + cIndex++; + c_d.endEdit(); +} + +template +void StopperLagrangianConstraint::getConstraintViolation(const core::ConstraintParams* /*cParams*/, linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &/*v*/) +{ + resV->set(cid, x.getValue()[index.getValue()][0]); +} + +template +void StopperLagrangianConstraint::getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) +{ + for(int i=0; i<1; i++) + resTab[offset++] = new StopperLagrangianConstraintResolution1Dof(min.getValue(), max.getValue()); +} + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h index e53399c5b9a..f7c7b8858f9 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h @@ -20,58 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include +#include -namespace sofa::component::constraint::lagrangian::model -{ - -template < class DataTypes > -class UniformConstraint : public sofa::core::behavior::Constraint< DataTypes > -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(UniformConstraint, DataTypes), SOFA_TEMPLATE(sofa::core::behavior::Constraint, DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - - typedef sofa::Data DataVecCoord; - typedef sofa::Data DataVecDeriv; - typedef sofa::Data DataMatrixDeriv; - - void buildConstraintMatrix(const sofa::core::ConstraintParams* cParams, DataMatrixDeriv & c, unsigned int &cIndex, const DataVecCoord &x) override; - - void getConstraintViolation(const sofa::core::ConstraintParams* cParams, sofa::linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &v) override; - - void getConstraintResolution(const sofa::core::ConstraintParams* cParams, std::vector& crVector, unsigned int& offset) override; - - sofa::Data d_iterative; ///< Iterate over the bilateral constraints, otherwise a block factorisation is computed. - sofa::Data d_constraintRestPos; ///< if false, constrains the pos to be zero / if true constraint the current position to stay at rest position -protected: - - unsigned int m_constraintIndex; - - UniformConstraint(); - - virtual type::vector getConstraintIdentifiers() override final - { - type::vector ids = getStopperIdentifiers(); - ids.push_back("Uniform"); - ids.push_back("Bilateral"); - return ids; - } - - virtual type::vector getStopperIdentifiers(){ return {}; } - -}; - -#if !defined(SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_UNIFORMCONSTRAINT_CPP) - extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UniformConstraint; -#endif - -} // namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl index b34a9377b97..1fc4488730b 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl @@ -19,119 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ - #pragma once -#include - -#include -#include -#include - -namespace sofa::component::constraint::lagrangian::model -{ - -template< class DataTypes > -UniformConstraint::UniformConstraint() - :d_iterative(initData(&d_iterative, true, "iterative", "Iterate over the bilateral constraints, otherwise a block factorisation is computed.")) - ,d_constraintRestPos(initData(&d_constraintRestPos, false, "constrainToRestPos", "if false, constrains the pos to be zero / if true constraint the current position to stay at rest position")) - ,m_constraintIndex(0) -{ - -} - -template< class DataTypes > -void UniformConstraint::buildConstraintMatrix(const sofa::core::ConstraintParams* cParams, DataMatrixDeriv & c, unsigned int &cIndex, const DataVecCoord &x) -{ - SOFA_UNUSED(cParams); - - const auto N = Deriv::size(); // MatrixDeriv is a container of Deriv types. - - auto& jacobian = sofa::helper::getWriteAccessor(c).wref(); - auto xVec = sofa::helper::getReadAccessor(x); - - m_constraintIndex = cIndex; // we should not have to remember this, it should be available through the API directly. - - for (std::size_t i = 0; i < xVec.size(); ++i) - { - for (std::size_t j = 0; j < N; ++j) - { - auto row = jacobian.writeLine(N*i + j + m_constraintIndex); - Deriv d; - d[j] = Real(1); - row.setCol(i, d); - ++cIndex; - } - } -} - -template -void computeViolation(DstV& resV, unsigned int constraintIndex, const - Free& free, size_t N, std::function f) -{ - for (std::size_t i = 0; i < free.size(); ++i) - { - for (std::size_t j = 0; j < N; ++j) - { - resV->set(constraintIndex + i*N + j, f(i, j) ); - } - } -} - -template< class DataTypes > -void UniformConstraint::getConstraintViolation(const sofa::core::ConstraintParams* cParams, sofa::linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &v) -{ - auto xfree = sofa::helper::getReadAccessor(x); - auto vfree = sofa::helper::getReadAccessor(v); - const SReal dt = this->getContext()->getDt(); - const SReal invDt = 1.0 / dt; - - auto pos = this->getMState()->readPositions(); - auto restPos = this->getMState()->readRestPositions(); - - if (cParams->constOrder() == sofa::core::ConstraintOrder::VEL) - { - if (d_constraintRestPos.getValue()){ - computeViolation(resV, m_constraintIndex, vfree, Deriv::size(),[&invDt,&pos,&vfree,&restPos](int i, int j) - { return vfree[i][j] + invDt *(pos[i][j]-restPos[i][j]); }); - } - else { - computeViolation(resV, m_constraintIndex, vfree, Deriv::size(),[&invDt,&pos,&vfree](int i, int j) - { return vfree[i][j] + invDt *pos[i][j]; }); - } - } - else - { - if( d_constraintRestPos.getValue() ) - computeViolation(resV, m_constraintIndex, xfree, Coord::size(), - [&xfree,&restPos](int i, int j){ return xfree[i][j] - restPos[i][j]; }); - else - computeViolation(resV, m_constraintIndex, xfree, Coord::size(),[&xfree](int i, int j){ return xfree[i][j]; }); - } -} - -template< class DataTypes > -void UniformConstraint::getConstraintResolution(const sofa::core::ConstraintParams* cParams, std::vector& crVector, unsigned int& offset) -{ - SOFA_UNUSED(cParams); - if (d_iterative.getValue()) - { - for (std::size_t i = 0; i < this->getMState()->getSize(); ++i) - { - for (std::size_t j = 0; j < Deriv::size(); ++j) - { - auto* cr = new sofa::component::constraint::lagrangian::model::BilateralConstraintResolution(); - crVector[offset++] = cr; - } - } - } - else - { - const std::size_t nbLines = this->getMState()->getSize() * Deriv::size(); - auto* cr = new sofa::component::constraint::lagrangian::model::BilateralConstraintResolutionNDof(nbLines); - crVector[offset] = cr; - offset += nbLines; - } -} +#include -} // namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.cpp similarity index 82% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.cpp index 60f11dac072..eb993968042 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_UNIFORMCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_UNIFORMLAGRANGIANCONSTRAINT_CPP +#include #include #include @@ -28,11 +28,11 @@ namespace sofa::component::constraint::lagrangian::model { -int UniformConstraintClass = sofa::core::RegisterObject("A constraint equation applied on all dofs.") -.add< UniformConstraint >() +int UniformLagrangianConstraintClass = sofa::core::RegisterObject("A constraint equation applied on all dofs.") +.add< UniformLagrangianConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UniformConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UniformLagrangianConstraint; } // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h new file mode 100644 index 00000000000..647ac2754cf --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h @@ -0,0 +1,81 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +template < class DataTypes > +class UniformLagrangianConstraint : public sofa::core::behavior::Constraint< DataTypes > +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(UniformLagrangianConstraint, DataTypes), SOFA_TEMPLATE(sofa::core::behavior::Constraint, DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + + typedef sofa::Data DataVecCoord; + typedef sofa::Data DataVecDeriv; + typedef sofa::Data DataMatrixDeriv; + + void buildConstraintMatrix(const sofa::core::ConstraintParams* cParams, DataMatrixDeriv & c, unsigned int &cIndex, const DataVecCoord &x) override; + + void getConstraintViolation(const sofa::core::ConstraintParams* cParams, sofa::linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &v) override; + + void getConstraintResolution(const sofa::core::ConstraintParams* cParams, std::vector& crVector, unsigned int& offset) override; + + sofa::Data d_iterative; ///< Iterate over the bilateral constraints, otherwise a block factorisation is computed. + sofa::Data d_constraintRestPos; ///< if false, constrains the pos to be zero / if true constraint the current position to stay at rest position +protected: + + unsigned int m_constraintIndex; + + UniformLagrangianConstraint(); + + virtual type::vector getConstraintIdentifiers() override final + { + type::vector ids = getStopperIdentifiers(); + ids.push_back("Uniform"); + ids.push_back("Bilateral"); + return ids; + } + + virtual type::vector getStopperIdentifiers(){ return {}; } + +}; + +#if !defined(SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_UNIFORMLAGRANGIANCONSTRAINT_CPP) + extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UniformLagrangianConstraint; +#endif + +template +using UniformConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UniformConstraint has been renamed to UniformLagrangianConstraint") = UniformLagrangianConstraint; + + +} // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl new file mode 100644 index 00000000000..707797df0c4 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl @@ -0,0 +1,137 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +template< class DataTypes > +UniformLagrangianConstraint::UniformLagrangianConstraint() + :d_iterative(initData(&d_iterative, true, "iterative", "Iterate over the bilateral constraints, otherwise a block factorisation is computed.")) + ,d_constraintRestPos(initData(&d_constraintRestPos, false, "constrainToRestPos", "if false, constrains the pos to be zero / if true constraint the current position to stay at rest position")) + ,m_constraintIndex(0) +{ + +} + +template< class DataTypes > +void UniformLagrangianConstraint::buildConstraintMatrix(const sofa::core::ConstraintParams* cParams, DataMatrixDeriv & c, unsigned int &cIndex, const DataVecCoord &x) +{ + SOFA_UNUSED(cParams); + + const auto N = Deriv::size(); // MatrixDeriv is a container of Deriv types. + + auto& jacobian = sofa::helper::getWriteAccessor(c).wref(); + auto xVec = sofa::helper::getReadAccessor(x); + + m_constraintIndex = cIndex; // we should not have to remember this, it should be available through the API directly. + + for (std::size_t i = 0; i < xVec.size(); ++i) + { + for (std::size_t j = 0; j < N; ++j) + { + auto row = jacobian.writeLine(N*i + j + m_constraintIndex); + Deriv d; + d[j] = Real(1); + row.setCol(i, d); + ++cIndex; + } + } +} + +template +void computeViolation(DstV& resV, unsigned int constraintIndex, const + Free& free, size_t N, std::function f) +{ + for (std::size_t i = 0; i < free.size(); ++i) + { + for (std::size_t j = 0; j < N; ++j) + { + resV->set(constraintIndex + i*N + j, f(i, j) ); + } + } +} + +template< class DataTypes > +void UniformLagrangianConstraint::getConstraintViolation(const sofa::core::ConstraintParams* cParams, sofa::linearalgebra::BaseVector *resV, const DataVecCoord &x, const DataVecDeriv &v) +{ + auto xfree = sofa::helper::getReadAccessor(x); + auto vfree = sofa::helper::getReadAccessor(v); + const SReal dt = this->getContext()->getDt(); + const SReal invDt = 1.0 / dt; + + auto pos = this->getMState()->readPositions(); + auto restPos = this->getMState()->readRestPositions(); + + if (cParams->constOrder() == sofa::core::ConstraintOrder::VEL) + { + if (d_constraintRestPos.getValue()){ + computeViolation(resV, m_constraintIndex, vfree, Deriv::size(),[&invDt,&pos,&vfree,&restPos](int i, int j) + { return vfree[i][j] + invDt *(pos[i][j]-restPos[i][j]); }); + } + else { + computeViolation(resV, m_constraintIndex, vfree, Deriv::size(),[&invDt,&pos,&vfree](int i, int j) + { return vfree[i][j] + invDt *pos[i][j]; }); + } + } + else + { + if( d_constraintRestPos.getValue() ) + computeViolation(resV, m_constraintIndex, xfree, Coord::size(), + [&xfree,&restPos](int i, int j){ return xfree[i][j] - restPos[i][j]; }); + else + computeViolation(resV, m_constraintIndex, xfree, Coord::size(),[&xfree](int i, int j){ return xfree[i][j]; }); + } +} + +template< class DataTypes > +void UniformLagrangianConstraint::getConstraintResolution(const sofa::core::ConstraintParams* cParams, std::vector& crVector, unsigned int& offset) +{ + SOFA_UNUSED(cParams); + + if (d_iterative.getValue()) + { + for (std::size_t i = 0; i < this->getMState()->getSize(); ++i) + { + for (std::size_t j = 0; j < Deriv::size(); ++j) + { + auto* cr = new sofa::component::constraint::lagrangian::model::BilateralConstraintResolution(); + crVector[offset++] = cr; + } + } + } + else + { + const std::size_t nbLines = this->getMState()->getSize() * Deriv::size(); + auto* cr = new sofa::component::constraint::lagrangian::model::BilateralConstraintResolutionNDof(nbLines); + crVector[offset] = cr; + offset += nbLines; + } +} + +} // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralConstraintResolution.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralConstraintResolution.h new file mode 100644 index 00000000000..3cf9f7847e5 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralConstraintResolution.h @@ -0,0 +1,100 @@ +/****************************************************************************** +* 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 + + +namespace sofa::component::constraint::lagrangian::model +{ + +class UnilateralConstraintResolution : public core::behavior::ConstraintResolution +{ + public: + UnilateralConstraintResolution() : core::behavior::ConstraintResolution(1) {} + + void resolution(int line, SReal** w, SReal* d, SReal* force, SReal* dfree) override + { + SOFA_UNUSED(dfree); + force[line] -= d[line] / w[line][line]; + if (force[line] < 0) force[line] = 0.0; + } +}; + +// A little experiment on how to best save the forces for the hot start. +// TODO : save as a map (index of the contact <-> force) +class PreviousForcesContainer +{ + public: + PreviousForcesContainer() : resetFlag(true) {} + SReal popForce() + { + resetFlag = true; + if (forces.empty()) return 0; + const SReal f = forces.front(); + forces.pop_front(); + return f; + } + + void pushForce(SReal f) + { + if (resetFlag) + { + forces.clear(); + resetFlag = false; + } + + forces.push_back(f); + } + + protected: + std::deque forces; + bool resetFlag; // We delete all forces that were not read +}; + +class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralConstraintResolutionWithFriction + : public core::behavior::ConstraintResolution +{ + public: + UnilateralConstraintResolutionWithFriction(SReal mu, PreviousForcesContainer* prev = nullptr, + bool* active = nullptr) + : core::behavior::ConstraintResolution(3), _mu(mu), _prev(prev), _active(active) + { + } + + void init(int line, SReal** w, SReal* force) override; + void resolution(int line, SReal** w, SReal* d, SReal* force, SReal* dFree) override; + void store(int line, SReal* force, bool /*convergence*/) override; + + protected: + SReal _mu; + SReal _W[6]; + PreviousForcesContainer* _prev; + bool* _active; // Will set this after the resolution +}; + +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h index 254103f59fe..cf12d105c2b 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h @@ -20,210 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::lagrangian::model -{ -class UnilateralConstraintResolution : public core::behavior::ConstraintResolution -{ -public: - - UnilateralConstraintResolution() : core::behavior::ConstraintResolution(1) - { - - } - - void resolution(int line, SReal** w, SReal* d, SReal* force, SReal *dfree) override - { - SOFA_UNUSED(dfree); - force[line] -= d[line] / w[line][line]; - if(force[line] < 0) - force[line] = 0.0; - } -}; - -// A little experiment on how to best save the forces for the hot start. -// TODO : save as a map (index of the contact <-> force) -class PreviousForcesContainer -{ -public: - PreviousForcesContainer() : resetFlag(true) {} - SReal popForce() - { - resetFlag = true; - if(forces.empty()) return 0; - const SReal f = forces.front(); - forces.pop_front(); - return f; - } - - void pushForce(SReal f) - { - if(resetFlag) - { - forces.clear(); - resetFlag = false; - } - - forces.push_back(f); - } - -protected: - std::deque forces; - bool resetFlag; // We delete all forces that were not read -}; - -class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralConstraintResolutionWithFriction : public core::behavior::ConstraintResolution -{ -public: - UnilateralConstraintResolutionWithFriction(SReal mu, PreviousForcesContainer* prev = nullptr, bool* active = nullptr) - :core::behavior::ConstraintResolution(3) - , _mu(mu) - , _prev(prev) - , _active(active) - { - } - - void init(int line, SReal** w, SReal* force) override; - void resolution(int line, SReal** w, SReal* d, SReal* force, SReal *dFree) override; - void store(int line, SReal* force, bool /*convergence*/) override; - -protected: - SReal _mu; - SReal _W[6]; - PreviousForcesContainer* _prev; - bool* _active; // Will set this after the resolution -}; - - -template -class UnilateralInteractionConstraint : public core::behavior::PairInteractionConstraint -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(UnilateralInteractionConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::PairInteractionConstraint,DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::MatrixDeriv::RowConstIterator MatrixDerivRowConstIterator; - typedef typename DataTypes::MatrixDeriv::ColConstIterator MatrixDerivColConstIterator; - typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename DataTypes::MatrixDeriv::ColIterator MatrixDerivColIterator; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename Coord::value_type Real; - typedef typename core::behavior::MechanicalState MechanicalState; - - typedef core::behavior::BaseConstraint::ConstraintBlockInfo ConstraintBlockInfo; - typedef core::behavior::BaseConstraint::PersistentID PersistentID; - typedef core::behavior::BaseConstraint::ConstCoord ConstCoord; - - typedef core::behavior::BaseConstraint::VecConstraintBlockInfo VecConstraintBlockInfo; - typedef core::behavior::BaseConstraint::VecPersistentID VecPersistentID; - typedef core::behavior::BaseConstraint::VecConstCoord VecConstCoord; - typedef core::behavior::BaseConstraint::VecConstDeriv VecConstDeriv; - typedef core::behavior::BaseConstraint::VecConstArea VecConstArea; - - typedef core::objectmodel::Data DataVecCoord; - typedef core::objectmodel::Data DataVecDeriv; - typedef core::objectmodel::Data DataMatrixDeriv; - - typedef typename core::behavior::PairInteractionConstraint Inherit; - -protected: - - struct Contact - { - int m1, m2; ///< the two extremities of the spring: masses m1 and m2 - Deriv norm; ///< contact normal, from m1 to m2 - Deriv t; ///< added for friction - Deriv s; ///< added for friction - Real contactDistance; - - unsigned int id; - long contactId; - PersistentID localId; - SReal mu; ///< angle for friction - - Coord P, Q; - - mutable Real dfree; - }; - - sofa::type::vector contacts; - Real epsilon; - bool yetIntegrated; - SReal customTolerance; - - PreviousForcesContainer prevForces; - bool* contactsStatus; - - /// Computes constraint violation in position and stores it into resolution global vector - /// - /// @param v Global resolution vector - virtual void getPositionViolation(linearalgebra::BaseVector *v); - - ///Computes constraint violation in velocity and stores it into resolution global vector - /// - /// @param v Global resolution vector - virtual void getVelocityViolation(linearalgebra::BaseVector *v); - -public: - - unsigned int constraintId; -protected: - - virtual type::vector getUnilateralInteractionIdentifiers() {return {};} - - virtual type::vector getPairInteractionIdentifiers() override final - { - type::vector ids = getUnilateralInteractionIdentifiers(); - ids.push_back("Unilateral"); - return ids; - } - - - UnilateralInteractionConstraint(MechanicalState* object1=nullptr, MechanicalState* object2=nullptr); - virtual ~UnilateralInteractionConstraint(); - -public: - void setCustomTolerance(SReal tol) { customTolerance = tol; } - - void clear(int reserve = 0); - - virtual void addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord Pfree, Coord Qfree, long id=0, PersistentID localid=0); - - void addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id=0, PersistentID localid=0); - void addContact(SReal mu, Deriv norm, Real contactDistance, int m1, int m2, long id=0, PersistentID localid=0); - - void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c1, DataMatrixDeriv &c2, unsigned int &cIndex - , const DataVecCoord &x1, const DataVecCoord &x2) override; - - void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *v, const DataVecCoord &x1, const DataVecCoord &x2 - , const DataVecDeriv &v1, const DataVecDeriv &v2) override; - - - void getConstraintInfo(const core::ConstraintParams* cParams, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& positions, VecConstDeriv& directions, VecConstArea& areas) override; - - void getConstraintResolution(const core::ConstraintParams *,std::vector& resTab, unsigned int& offset) override; - bool isActive() const override; - - void draw(const core::visual::VisualParams* vparams) override; -}; - - -#if !defined(SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionConstraint; - -#endif - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl index 7cd50ba7b9b..0da78f67d34 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl @@ -20,402 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -namespace sofa::component::constraint::lagrangian::model -{ +#include -template -UnilateralInteractionConstraint::UnilateralInteractionConstraint(MechanicalState* object1, MechanicalState* object2) - : Inherit(object1, object2) - , epsilon(Real(0.001)) - , yetIntegrated(false) - , customTolerance(0.0) - , contactsStatus(nullptr) -{ -} - -template -UnilateralInteractionConstraint::~UnilateralInteractionConstraint() -{ - if(contactsStatus) - delete[] contactsStatus; -} - -template -void UnilateralInteractionConstraint::clear(int reserve) -{ - contacts.clear(); - if (reserve) - contacts.reserve(reserve); -} - -template -void UnilateralInteractionConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id, PersistentID localid) -{ - addContact(mu, norm, P, Q, contactDistance, m1, m2, - this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue()[m2], - this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue()[m1], - id, localid); -} - -template -void UnilateralInteractionConstraint::addContact(SReal mu, Deriv norm, Real contactDistance, int m1, int m2, long id, PersistentID localid) -{ - addContact(mu, norm, - this->getMState2()->read(core::ConstVecCoordId::position())->getValue()[m2], - this->getMState1()->read(core::ConstVecCoordId::position())->getValue()[m1], - contactDistance, m1, m2, - this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue()[m2], - this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue()[m1], - id, localid); -} - -template -void UnilateralInteractionConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord /*Pfree*/, Coord /*Qfree*/, long id, PersistentID localid) -{ - contacts.resize(contacts.size() + 1); - Contact &c = contacts.back(); - - c.P = P; - c.Q = Q; - c.m1 = m1; - c.m2 = m2; - c.norm = norm; - c.t = Deriv(norm.z(), norm.x(), norm.y()); - c.s = cross(norm, c.t); - c.s = c.s / c.s.norm(); - c.t = cross((-norm), c.s); - c.mu = mu; - c.contactId = id; - c.localId = localid; - c.contactDistance = contactDistance; -} - - -template -void UnilateralInteractionConstraint::buildConstraintMatrix(const core::ConstraintParams *, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &contactId - , const DataVecCoord &, const DataVecCoord &) -{ - assert(this->mstate1); - assert(this->mstate2); - - if (this->mstate1 == this->mstate2) - { - MatrixDeriv& c1 = *c1_d.beginEdit(); - - for (unsigned int i = 0; i < contacts.size(); i++) - { - Contact& c = contacts[i]; - - c.id = contactId++; - - MatrixDerivRowIterator c1_it = c1.writeLine(c.id); - - c1_it.addCol(c.m1, -c.norm); - c1_it.addCol(c.m2, c.norm); - - if (c.mu > 0.0) - { - c1_it = c1.writeLine(c.id + 1); - c1_it.setCol(c.m1, -c.t); - c1_it.setCol(c.m2, c.t); - - c1_it = c1.writeLine(c.id + 2); - c1_it.setCol(c.m1, -c.s); - c1_it.setCol(c.m2, c.s); - - contactId += 2; - } - } - - c1_d.endEdit(); - } - else - { - MatrixDeriv& c1 = *c1_d.beginEdit(); - MatrixDeriv& c2 = *c2_d.beginEdit(); - - for (unsigned int i = 0; i < contacts.size(); i++) - { - Contact& c = contacts[i]; - - c.id = contactId++; - - MatrixDerivRowIterator c1_it = c1.writeLine(c.id); - c1_it.addCol(c.m1, -c.norm); - - MatrixDerivRowIterator c2_it = c2.writeLine(c.id); - c2_it.addCol(c.m2, c.norm); - - if (c.mu > 0.0) - { - c1_it = c1.writeLine(c.id + 1); - c1_it.setCol(c.m1, -c.t); - - c1_it = c1.writeLine(c.id + 2); - c1_it.setCol(c.m1, -c.s); - - c2_it = c2.writeLine(c.id + 1); - c2_it.setCol(c.m2, c.t); - - c2_it = c2.writeLine(c.id + 2); - c2_it.setCol(c.m2, c.s); - - contactId += 2; - } - } - - c1_d.endEdit(); - c2_d.endEdit(); - } -} - - -template -void UnilateralInteractionConstraint::getPositionViolation(linearalgebra::BaseVector *v) -{ - const VecCoord &PfreeVec = this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue(); - const VecCoord &QfreeVec = this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue(); - - Real dfree = (Real)0.0; - Real dfree_t = (Real)0.0; - Real dfree_s = (Real)0.0; - - const unsigned int cSize = contacts.size(); - - for (unsigned int i = 0; i < cSize; i++) - { - const Contact& c = contacts[i]; - - // Compute dfree, dfree_t and d_free_s - - const Coord &Pfree = PfreeVec[c.m2]; - const Coord &Qfree = QfreeVec[c.m1]; - - const Coord PPfree = Pfree - c.P; - const Coord QQfree = Qfree - c.Q; - - const Real ref_dist = PPfree.norm() + QQfree.norm(); - - dfree = dot(Pfree - Qfree, c.norm) - c.contactDistance; - const Real delta = dot(c.P - c.Q, c.norm) - c.contactDistance; - - if ((helper::rabs(delta) < 0.00001 * ref_dist) && (helper::rabs(dfree) < 0.00001 * ref_dist)) - { - dfree_t = dot(PPfree, c.t) - dot(QQfree, c.t); - dfree_s = dot(PPfree, c.s) - dot(QQfree, c.s); - } - else if (helper::rabs(delta - dfree) > 0.001 * delta) - { - const Real dt = delta / (delta - dfree); - - if (dt > 0.0 && dt < 1.0) - { - const Coord Pt = c.P * (1 - dt) + Pfree * dt; - const Coord Qt = c.Q * (1 - dt) + Qfree * dt; - const Coord PtPfree = Pfree - Pt; - const Coord QtQfree = Qfree - Qt; - - dfree_t = dot(PtPfree, c.t) - dot(QtQfree, c.t); - dfree_s = dot(PtPfree, c.s) - dot(QtQfree, c.s); - } - else if (dfree < 0.0) - { - dfree_t = dot(PPfree, c.t) - dot(QQfree, c.t); - dfree_s = dot(PPfree, c.s) - dot(QQfree, c.s); - } - else - { - dfree_t = 0; - dfree_s = 0; - } - } - else - { - dfree_t = dot(PPfree, c.t) - dot(QQfree, c.t); - dfree_s = dot(PPfree, c.s) - dot(QQfree, c.s); - } - - // Sets dfree in global violation vector - - v->set(c.id, dfree); - - c.dfree = dfree; // PJ : For isActive() method. Don't know if it's still usefull. - - if (c.mu > 0.0) - { - v->set(c.id + 1, dfree_t); - v->set(c.id + 2, dfree_s); - } - } -} - - -template -void UnilateralInteractionConstraint::getVelocityViolation(linearalgebra::BaseVector *v) -{ - auto P = this->getMState2()->readPositions(); - auto Q = this->getMState1()->readPositions(); - - const SReal dt = this->getContext()->getDt(); - const SReal invDt = SReal(1.0) / dt; - - const VecDeriv &PvfreeVec = this->getMState2()->read(core::ConstVecDerivId::freeVelocity())->getValue(); - const VecDeriv &QvfreeVec = this->getMState1()->read(core::ConstVecDerivId::freeVelocity())->getValue(); - - const unsigned int cSize = contacts.size(); - - for (unsigned int i = 0; i < cSize; i++) - { - const Contact& c = contacts[i]; - - const Deriv QP_invDt = (P[c.m2] - Q[c.m1])*invDt; - const Deriv QP_vfree = PvfreeVec[c.m2] - QvfreeVec[c.m1]; - const Deriv dFreeVec = QP_vfree + QP_invDt; - - v->set(c.id, dot(dFreeVec, c.norm) - c.contactDistance*invDt ); // dvfree = 1/dt * [ dot ( P - Q, n) - contactDist ] + dot(v_P - v_Q , n ) ] - - if (c.mu > 0.0) - { - v->set(c.id + 1, dot(QP_vfree, c.t)); // dfree_t - v->set(c.id + 2, dot(QP_vfree, c.s)); // dfree_s - } - } -} - - -template -void UnilateralInteractionConstraint::getConstraintViolation(const core::ConstraintParams *cparams, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & - , const DataVecDeriv &, const DataVecDeriv &) -{ - switch (cparams->constOrder()) - { - case core::ConstraintOrder::POS_AND_VEL : - case core::ConstraintOrder::POS : - getPositionViolation(v); - break; - - case core::ConstraintOrder::ACC : - case core::ConstraintOrder::VEL : - getVelocityViolation(v); - break; - - default : - msg_error() << "UnilateralInteractionConstraint doesn't implement " << cparams->getName() << " constraint violation\n"; - break; - } -} - - -template -void UnilateralInteractionConstraint::getConstraintInfo(const core::ConstraintParams*, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& /*positions*/, VecConstDeriv& directions, VecConstArea& /*areas*/) -{ - if (contacts.empty()) return; - const bool friction = (contacts[0].mu > 0.0); /// @todo: can there be both friction-less and friction contacts in the same UnilateralInteractionConstraint ??? - ConstraintBlockInfo info; - info.parent = this; - info.const0 = contacts[0].id; - info.nbLines = friction ? 3 : 1; - info.hasId = true; - info.offsetId = ids.size(); - info.hasDirection = true; - info.offsetDirection = directions.size(); - info.nbGroups = contacts.size(); - - for (unsigned int i=0; i -void UnilateralInteractionConstraint::getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) -{ - if(contactsStatus) - { - delete[] contactsStatus; - contactsStatus = nullptr; - } - - if (contacts.size() > 0) - { - contactsStatus = new bool[contacts.size()]; - memset(contactsStatus, 0, sizeof(bool)*contacts.size()); - } - - for(unsigned int i=0; i 0.0) - { - UnilateralConstraintResolutionWithFriction* ucrwf = new UnilateralConstraintResolutionWithFriction(c.mu, nullptr, &contactsStatus[i]); - ucrwf->setTolerance(customTolerance); - resTab[offset] = ucrwf; - - // TODO : cette méthode de stockage des forces peu mal fonctionner avec 2 threads quand on utilise l'haptique - offset += 3; - } - else - resTab[offset++] = new UnilateralConstraintResolution(); - } -} - -template -bool UnilateralInteractionConstraint::isActive() const -{ - for(unsigned int i = 0; i < contacts.size(); i++) - if(contacts[i].dfree < 0) - return true; - - return false; -} - -template -void UnilateralInteractionConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowInteractionForceFields()) return; - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - vparams->drawTool()->disableLighting(); - - std::vector redVertices; - std::vector otherVertices; - std::vector otherColors; - - for (unsigned int i=0; idrawTool()->drawLines(otherVertices, 3, otherColors); - - - - -} - -} //namespace sofa::component::constraint::lagrangian::model +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.cpp similarity index 91% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.cpp index 731d7ff2372..6e44411758f 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP +#include #include #include @@ -31,13 +31,13 @@ using namespace sofa::defaulttype; using namespace sofa::helper; //TODO(dmarchal) What does this TODO mean ? -int UnilateralInteractionConstraintClass = core::RegisterObject("TODO-UnilateralInteractionConstraint") - .add< UnilateralInteractionConstraint >() +int UnilateralInteractionLagrangianConstraintClass = core::RegisterObject("TODO-UnilateralInteractionLagrangianConstraint") + .add< UnilateralInteractionLagrangianConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionLagrangianConstraint; diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h new file mode 100644 index 00000000000..2669be18f93 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h @@ -0,0 +1,162 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::lagrangian::model +{ + +template +class UnilateralInteractionLagrangianConstraint : public core::behavior::PairInteractionConstraint +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(UnilateralInteractionLagrangianConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::PairInteractionConstraint,DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::MatrixDeriv::RowConstIterator MatrixDerivRowConstIterator; + typedef typename DataTypes::MatrixDeriv::ColConstIterator MatrixDerivColConstIterator; + typedef typename DataTypes::MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename DataTypes::MatrixDeriv::ColIterator MatrixDerivColIterator; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename Coord::value_type Real; + typedef typename core::behavior::MechanicalState MechanicalState; + + typedef core::behavior::BaseConstraint::ConstraintBlockInfo ConstraintBlockInfo; + typedef core::behavior::BaseConstraint::PersistentID PersistentID; + typedef core::behavior::BaseConstraint::ConstCoord ConstCoord; + + typedef core::behavior::BaseConstraint::VecConstraintBlockInfo VecConstraintBlockInfo; + typedef core::behavior::BaseConstraint::VecPersistentID VecPersistentID; + typedef core::behavior::BaseConstraint::VecConstCoord VecConstCoord; + typedef core::behavior::BaseConstraint::VecConstDeriv VecConstDeriv; + typedef core::behavior::BaseConstraint::VecConstArea VecConstArea; + + typedef core::objectmodel::Data DataVecCoord; + typedef core::objectmodel::Data DataVecDeriv; + typedef core::objectmodel::Data DataMatrixDeriv; + + typedef typename core::behavior::PairInteractionConstraint Inherit; + +protected: + + struct Contact + { + int m1, m2; ///< the two extremities of the spring: masses m1 and m2 + Deriv norm; ///< contact normal, from m1 to m2 + Deriv t; ///< added for friction + Deriv s; ///< added for friction + Real contactDistance; + + unsigned int id; + long contactId; + PersistentID localId; + SReal mu; ///< angle for friction + + Coord P, Q; + + mutable Real dfree; + }; + + sofa::type::vector contacts; + Real epsilon; + bool yetIntegrated; + SReal customTolerance; + + PreviousForcesContainer prevForces; + bool* contactsStatus; + + /// Computes constraint violation in position and stores it into resolution global vector + /// + /// @param v Global resolution vector + virtual void getPositionViolation(linearalgebra::BaseVector *v); + + ///Computes constraint violation in velocity and stores it into resolution global vector + /// + /// @param v Global resolution vector + virtual void getVelocityViolation(linearalgebra::BaseVector *v); + +public: + + unsigned int constraintId; +protected: + + virtual type::vector getUnilateralInteractionIdentifiers() {return {};} + + virtual type::vector getPairInteractionIdentifiers() override final + { + type::vector ids = getUnilateralInteractionIdentifiers(); + ids.push_back("Unilateral"); + return ids; + } + + + UnilateralInteractionLagrangianConstraint(MechanicalState* object1=nullptr, MechanicalState* object2=nullptr); + virtual ~UnilateralInteractionLagrangianConstraint(); + +public: + void setCustomTolerance(SReal tol) { customTolerance = tol; } + + void clear(int reserve = 0); + + virtual void addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord Pfree, Coord Qfree, long id=0, PersistentID localid=0); + + void addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id=0, PersistentID localid=0); + void addContact(SReal mu, Deriv norm, Real contactDistance, int m1, int m2, long id=0, PersistentID localid=0); + + void buildConstraintMatrix(const core::ConstraintParams* cParams, DataMatrixDeriv &c1, DataMatrixDeriv &c2, unsigned int &cIndex + , const DataVecCoord &x1, const DataVecCoord &x2) override; + + void getConstraintViolation(const core::ConstraintParams* cParams, linearalgebra::BaseVector *v, const DataVecCoord &x1, const DataVecCoord &x2 + , const DataVecDeriv &v1, const DataVecDeriv &v2) override; + + + void getConstraintInfo(const core::ConstraintParams* cParams, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& positions, VecConstDeriv& directions, VecConstArea& areas) override; + + void getConstraintResolution(const core::ConstraintParams *,std::vector& resTab, unsigned int& offset) override; + bool isActive() const override; + + void draw(const core::visual::VisualParams* vparams) override; +}; + + +#if !defined(SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionLagrangianConstraint; + +#endif + +template +using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UnilateralInteractionConstraint has been renamed to UnilateralInteractionLagrangianConstraint") = UnilateralInteractionLagrangianConstraint; + + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl new file mode 100644 index 00000000000..4b65ac27673 --- /dev/null +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl @@ -0,0 +1,421 @@ +/****************************************************************************** +* 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::constraint::lagrangian::model +{ + +template +UnilateralInteractionLagrangianConstraint::UnilateralInteractionLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) + : Inherit(object1, object2) + , epsilon(Real(0.001)) + , yetIntegrated(false) + , customTolerance(0.0) + , contactsStatus(nullptr) +{ +} + +template +UnilateralInteractionLagrangianConstraint::~UnilateralInteractionLagrangianConstraint() +{ + if(contactsStatus) + delete[] contactsStatus; +} + +template +void UnilateralInteractionLagrangianConstraint::clear(int reserve) +{ + contacts.clear(); + if (reserve) + contacts.reserve(reserve); +} + +template +void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id, PersistentID localid) +{ + addContact(mu, norm, P, Q, contactDistance, m1, m2, + this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue()[m2], + this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue()[m1], + id, localid); +} + +template +void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, Deriv norm, Real contactDistance, int m1, int m2, long id, PersistentID localid) +{ + addContact(mu, norm, + this->getMState2()->read(core::ConstVecCoordId::position())->getValue()[m2], + this->getMState1()->read(core::ConstVecCoordId::position())->getValue()[m1], + contactDistance, m1, m2, + this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue()[m2], + this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue()[m1], + id, localid); +} + +template +void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord /*Pfree*/, Coord /*Qfree*/, long id, PersistentID localid) +{ + contacts.resize(contacts.size() + 1); + Contact &c = contacts.back(); + + c.P = P; + c.Q = Q; + c.m1 = m1; + c.m2 = m2; + c.norm = norm; + c.t = Deriv(norm.z(), norm.x(), norm.y()); + c.s = cross(norm, c.t); + c.s = c.s / c.s.norm(); + c.t = cross((-norm), c.s); + c.mu = mu; + c.contactId = id; + c.localId = localid; + c.contactDistance = contactDistance; +} + + +template +void UnilateralInteractionLagrangianConstraint::buildConstraintMatrix(const core::ConstraintParams *, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &contactId + , const DataVecCoord &, const DataVecCoord &) +{ + assert(this->mstate1); + assert(this->mstate2); + + if (this->mstate1 == this->mstate2) + { + MatrixDeriv& c1 = *c1_d.beginEdit(); + + for (unsigned int i = 0; i < contacts.size(); i++) + { + Contact& c = contacts[i]; + + c.id = contactId++; + + MatrixDerivRowIterator c1_it = c1.writeLine(c.id); + + c1_it.addCol(c.m1, -c.norm); + c1_it.addCol(c.m2, c.norm); + + if (c.mu > 0.0) + { + c1_it = c1.writeLine(c.id + 1); + c1_it.setCol(c.m1, -c.t); + c1_it.setCol(c.m2, c.t); + + c1_it = c1.writeLine(c.id + 2); + c1_it.setCol(c.m1, -c.s); + c1_it.setCol(c.m2, c.s); + + contactId += 2; + } + } + + c1_d.endEdit(); + } + else + { + MatrixDeriv& c1 = *c1_d.beginEdit(); + MatrixDeriv& c2 = *c2_d.beginEdit(); + + for (unsigned int i = 0; i < contacts.size(); i++) + { + Contact& c = contacts[i]; + + c.id = contactId++; + + MatrixDerivRowIterator c1_it = c1.writeLine(c.id); + c1_it.addCol(c.m1, -c.norm); + + MatrixDerivRowIterator c2_it = c2.writeLine(c.id); + c2_it.addCol(c.m2, c.norm); + + if (c.mu > 0.0) + { + c1_it = c1.writeLine(c.id + 1); + c1_it.setCol(c.m1, -c.t); + + c1_it = c1.writeLine(c.id + 2); + c1_it.setCol(c.m1, -c.s); + + c2_it = c2.writeLine(c.id + 1); + c2_it.setCol(c.m2, c.t); + + c2_it = c2.writeLine(c.id + 2); + c2_it.setCol(c.m2, c.s); + + contactId += 2; + } + } + + c1_d.endEdit(); + c2_d.endEdit(); + } +} + + +template +void UnilateralInteractionLagrangianConstraint::getPositionViolation(linearalgebra::BaseVector *v) +{ + const VecCoord &PfreeVec = this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue(); + const VecCoord &QfreeVec = this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue(); + + Real dfree = (Real)0.0; + Real dfree_t = (Real)0.0; + Real dfree_s = (Real)0.0; + + const unsigned int cSize = contacts.size(); + + for (unsigned int i = 0; i < cSize; i++) + { + const Contact& c = contacts[i]; + + // Compute dfree, dfree_t and d_free_s + + const Coord &Pfree = PfreeVec[c.m2]; + const Coord &Qfree = QfreeVec[c.m1]; + + const Coord PPfree = Pfree - c.P; + const Coord QQfree = Qfree - c.Q; + + const Real ref_dist = PPfree.norm() + QQfree.norm(); + + dfree = dot(Pfree - Qfree, c.norm) - c.contactDistance; + const Real delta = dot(c.P - c.Q, c.norm) - c.contactDistance; + + if ((helper::rabs(delta) < 0.00001 * ref_dist) && (helper::rabs(dfree) < 0.00001 * ref_dist)) + { + dfree_t = dot(PPfree, c.t) - dot(QQfree, c.t); + dfree_s = dot(PPfree, c.s) - dot(QQfree, c.s); + } + else if (helper::rabs(delta - dfree) > 0.001 * delta) + { + const Real dt = delta / (delta - dfree); + + if (dt > 0.0 && dt < 1.0) + { + const Coord Pt = c.P * (1 - dt) + Pfree * dt; + const Coord Qt = c.Q * (1 - dt) + Qfree * dt; + const Coord PtPfree = Pfree - Pt; + const Coord QtQfree = Qfree - Qt; + + dfree_t = dot(PtPfree, c.t) - dot(QtQfree, c.t); + dfree_s = dot(PtPfree, c.s) - dot(QtQfree, c.s); + } + else if (dfree < 0.0) + { + dfree_t = dot(PPfree, c.t) - dot(QQfree, c.t); + dfree_s = dot(PPfree, c.s) - dot(QQfree, c.s); + } + else + { + dfree_t = 0; + dfree_s = 0; + } + } + else + { + dfree_t = dot(PPfree, c.t) - dot(QQfree, c.t); + dfree_s = dot(PPfree, c.s) - dot(QQfree, c.s); + } + + // Sets dfree in global violation vector + + v->set(c.id, dfree); + + c.dfree = dfree; // PJ : For isActive() method. Don't know if it's still usefull. + + if (c.mu > 0.0) + { + v->set(c.id + 1, dfree_t); + v->set(c.id + 2, dfree_s); + } + } +} + + +template +void UnilateralInteractionLagrangianConstraint::getVelocityViolation(linearalgebra::BaseVector *v) +{ + auto P = this->getMState2()->readPositions(); + auto Q = this->getMState1()->readPositions(); + + const SReal dt = this->getContext()->getDt(); + const SReal invDt = SReal(1.0) / dt; + + const VecDeriv &PvfreeVec = this->getMState2()->read(core::ConstVecDerivId::freeVelocity())->getValue(); + const VecDeriv &QvfreeVec = this->getMState1()->read(core::ConstVecDerivId::freeVelocity())->getValue(); + + const unsigned int cSize = contacts.size(); + + for (unsigned int i = 0; i < cSize; i++) + { + const Contact& c = contacts[i]; + + const Deriv QP_invDt = (P[c.m2] - Q[c.m1])*invDt; + const Deriv QP_vfree = PvfreeVec[c.m2] - QvfreeVec[c.m1]; + const Deriv dFreeVec = QP_vfree + QP_invDt; + + v->set(c.id, dot(dFreeVec, c.norm) - c.contactDistance*invDt ); // dvfree = 1/dt * [ dot ( P - Q, n) - contactDist ] + dot(v_P - v_Q , n ) ] + + if (c.mu > 0.0) + { + v->set(c.id + 1, dot(QP_vfree, c.t)); // dfree_t + v->set(c.id + 2, dot(QP_vfree, c.s)); // dfree_s + } + } +} + + +template +void UnilateralInteractionLagrangianConstraint::getConstraintViolation(const core::ConstraintParams *cparams, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & + , const DataVecDeriv &, const DataVecDeriv &) +{ + switch (cparams->constOrder()) + { + case core::ConstraintOrder::POS_AND_VEL : + case core::ConstraintOrder::POS : + getPositionViolation(v); + break; + + case core::ConstraintOrder::ACC : + case core::ConstraintOrder::VEL : + getVelocityViolation(v); + break; + + default : + msg_error() << "UnilateralInteractionLagrangianConstraint doesn't implement " << cparams->getName() << " constraint violation\n"; + break; + } +} + + +template +void UnilateralInteractionLagrangianConstraint::getConstraintInfo(const core::ConstraintParams*, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& /*positions*/, VecConstDeriv& directions, VecConstArea& /*areas*/) +{ + if (contacts.empty()) return; + const bool friction = (contacts[0].mu > 0.0); /// @todo: can there be both friction-less and friction contacts in the same UnilateralInteractionLagrangianConstraint ??? + ConstraintBlockInfo info; + info.parent = this; + info.const0 = contacts[0].id; + info.nbLines = friction ? 3 : 1; + info.hasId = true; + info.offsetId = ids.size(); + info.hasDirection = true; + info.offsetDirection = directions.size(); + info.nbGroups = contacts.size(); + + for (unsigned int i=0; i +void UnilateralInteractionLagrangianConstraint::getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) +{ + if(contactsStatus) + { + delete[] contactsStatus; + contactsStatus = nullptr; + } + + if (contacts.size() > 0) + { + contactsStatus = new bool[contacts.size()]; + memset(contactsStatus, 0, sizeof(bool)*contacts.size()); + } + + for(unsigned int i=0; i 0.0) + { + UnilateralConstraintResolutionWithFriction* ucrwf = new UnilateralConstraintResolutionWithFriction(c.mu, nullptr, &contactsStatus[i]); + ucrwf->setTolerance(customTolerance); + resTab[offset] = ucrwf; + + // TODO : cette méthode de stockage des forces peu mal fonctionner avec 2 threads quand on utilise l'haptique + offset += 3; + } + else + resTab[offset++] = new UnilateralConstraintResolution(); + } +} + +template +bool UnilateralInteractionLagrangianConstraint::isActive() const +{ + for(unsigned int i = 0; i < contacts.size(); i++) + if(contacts[i].dfree < 0) + return true; + + return false; +} + +template +void UnilateralInteractionLagrangianConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowInteractionForceFields()) return; + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + vparams->drawTool()->disableLighting(); + + std::vector redVertices; + std::vector otherVertices; + std::vector otherColors; + + for (unsigned int i=0; idrawTool()->drawLines(otherVertices, 3, otherColors); + + + + +} + +} //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/tests/BilateralInteractionConstraint_test.cpp b/Sofa/Component/Constraint/Lagrangian/Model/tests/BilateralInteractionLagrangianConstraint_test.cpp similarity index 85% rename from Sofa/Component/Constraint/Lagrangian/Model/tests/BilateralInteractionConstraint_test.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/tests/BilateralInteractionLagrangianConstraint_test.cpp index 49925d5a621..a00f9d760d1 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/tests/BilateralInteractionConstraint_test.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/tests/BilateralInteractionLagrangianConstraint_test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include using sofa::core::execparams::defaultInstance; @@ -50,7 +50,7 @@ using namespace component; using namespace defaulttype; template -struct BilateralInteractionConstraint_test : public NumericTest<> +struct BilateralInteractionLangrangianConstraint_test : public NumericTest<> { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -59,7 +59,7 @@ struct BilateralInteractionConstraint_test : public NumericTest<> typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::CPos CPos; typedef typename Coord::value_type Real; - typedef constraintset::BilateralInteractionConstraint BilateralInteractionConstraint; + typedef constraintset::BilateralInteractionLangrangianConstraint BilateralInteractionLangrangianConstraint; typedef component::topology::PointSetTopologyContainer PointSetTopologyContainer; typedef container::MechanicalObject MechanicalObject; @@ -103,7 +103,7 @@ struct BilateralInteractionConstraint_test : public NumericTest<> " \n" " \n" " \n" - " \n" + " \n" " \n" ; Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene", @@ -111,7 +111,7 @@ struct BilateralInteractionConstraint_test : public NumericTest<> scene.str().size()) ; root->init(sofa::core::execparams::defaultInstance()) ; - BilateralInteractionConstraint* constraint = root->getTreeObject() ; + BilateralInteractionLangrangianConstraint* constraint = root->getTreeObject() ; EXPECT_TRUE( constraint != nullptr ) ; EXPECT_TRUE( constraint->findData("first_point") != nullptr ) ; @@ -135,7 +135,7 @@ struct BilateralInteractionConstraint_test : public NumericTest<> std::stringstream scene; scene << " \n" " \n" - " \n" + " \n" " \n" ; Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene", @@ -150,7 +150,7 @@ struct BilateralInteractionConstraint_test : public NumericTest<> }; template<> -void BilateralInteractionConstraint_test::checkRigid3fFixForBackwardCompatibility(){ +void BilateralInteractionLangrangianConstraint_test::checkRigid3fFixForBackwardCompatibility(){ EXPECT_MSG_EMIT(Warning) ; /// I'm using '\n' so that the XML parser correctly report the line number @@ -160,7 +160,7 @@ void BilateralInteractionConstraint_test::checkRigid3fFixForBackwa " \n" " \n" " \n" - " \n" + " \n" " \n" ; Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene", @@ -172,12 +172,12 @@ void BilateralInteractionConstraint_test::checkRigid3fFixForBackwa template<> -void BilateralInteractionConstraint_test::init_Vec3Setup() +void BilateralInteractionLangrangianConstraint_test::init_Vec3Setup() { /// Load the scene //TODO(dmarchal): This general load should be updated... there is no reason to load // a scene independently of the data template to use. - std::string sceneName = "BilateralInteractionConstraint.scn"; + std::string sceneName = "BilateralInteractionLangrangianConstraint.scn"; std::string fileName = std::string(SOFATEST_SCENES_DIR) + "/" + sceneName; root = sofa::simulation::getSimulation()->load(fileName.c_str()).get(); @@ -199,7 +199,7 @@ void BilateralInteractionConstraint_test::init_Vec3Setup() } template<> -bool BilateralInteractionConstraint_test::test_Vec3ConstrainedPositions() +bool BilateralInteractionLangrangianConstraint_test::test_Vec3ConstrainedPositions() { std::vector meca; root->get(&meca,std::string("mecaConstraint"),root->SearchDown); @@ -240,27 +240,27 @@ typedef Types DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(BilateralInteractionConstraint_test, DataTypes); +TYPED_TEST_SUITE(BilateralInteractionLangrangianConstraint_test, DataTypes); //TODO(dmarchal): Needs a serious refactor !!! -TYPED_TEST( BilateralInteractionConstraint_test , checkVec3ConstrainedPositions ) +TYPED_TEST( BilateralInteractionLangrangianConstraint_test , checkVec3ConstrainedPositions ) { this->init_Vec3Setup(); ASSERT_TRUE( this->test_Vec3ConstrainedPositions() ); } -TYPED_TEST( BilateralInteractionConstraint_test , attributesTests ) +TYPED_TEST( BilateralInteractionLangrangianConstraint_test , attributesTests ) { ASSERT_NO_THROW( this->attributesTests() ); } -TYPED_TEST( BilateralInteractionConstraint_test , checkMstateRequiredAssumption ) +TYPED_TEST( BilateralInteractionLangrangianConstraint_test , checkMstateRequiredAssumption ) { ASSERT_NO_THROW( this->checkMstateRequiredAssumption() ); } -TYPED_TEST( BilateralInteractionConstraint_test , checkRigid3fFixForBackwardCompatibility) +TYPED_TEST( BilateralInteractionLangrangianConstraint_test , checkRigid3fFixForBackwardCompatibility) { ASSERT_NO_THROW( this->checkRigid3fFixForBackwardCompatibility() ); } diff --git a/Sofa/Component/Constraint/Projective/CMakeLists.txt b/Sofa/Component/Constraint/Projective/CMakeLists.txt index fcb8797553f..bce59cfa94d 100644 --- a/Sofa/Component/Constraint/Projective/CMakeLists.txt +++ b/Sofa/Component/Constraint/Projective/CMakeLists.txt @@ -45,30 +45,72 @@ set(HEADER_FILES ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointConstraint.inl ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionConstraint.h ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionConstraint.inl + + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AffineMovementProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AffineMovementProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AttachProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AttachProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedPlaneProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedPlaneProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedRotationProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedRotationProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedTranslationProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedTranslationProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/HermiteSplineProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/HermiteSplineProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearMovementProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearMovementProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearVelocityProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearVelocityProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/OscillatorProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/OscillatorProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ParabolicProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ParabolicProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialFixedProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialFixedProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialLinearMovementProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialLinearMovementProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PatchTestMovementProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PatchTestMovementProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PositionBasedDynamicsProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PositionBasedDynamicsProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionProjectiveConstraint.inl + ) set(SOURCE_FILES ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/init.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AffineMovementConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AttachConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedPlaneConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedRotationConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedTranslationConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/HermiteSplineConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearMovementConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearVelocityConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/OscillatorConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ParabolicConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialFixedConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialLinearMovementConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PatchTestMovementConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PositionBasedDynamicsConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AffineMovementProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/AttachProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedPlaneProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedRotationProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/FixedTranslationProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/HermiteSplineProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearMovementProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LinearVelocityProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/OscillatorProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ParabolicProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialFixedProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PartialLinearMovementProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PatchTestMovementProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PositionBasedDynamicsProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionProjectiveConstraint.cpp ) sofa_find_package(Sofa.Simulation.Core REQUIRED) diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h index 74f2cae555c..43eadcfe07a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h @@ -20,146 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -class AffineMovementConstraintInternalData -{ -}; - -/** - Impose a motion to all the boundary points of a mesh. The motion of the 4 corners are given in the data m_cornerMovements and the movements of the edge points are computed by linear interpolation. -*/ -template -class AffineMovementConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(AffineMovementConstraint,TDataTypes), - SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); - - using Index = sofa::Index; - typedef TDataTypes DataTypes; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::CPos CPos; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - typedef type::Quat Quat; - typedef type::Vec3 Vec3; - - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef core::objectmodel::Data DataMatrixDeriv; - - static const auto CoordSize = Coord::total_size; - typedef type::Mat<3,3,Real> RotationMatrix; - -protected: - AffineMovementConstraintInternalData *data; - friend class AffineMovementConstraintInternalData; - -public : - /// indices of the DOFs of the mesh - SetIndex m_meshIndices; - /// indices of the DOFs the constraint is applied to - SetIndex m_indices; - /// data begin time when the constraint is applied - Data m_beginConstraintTime; - /// data end time when the constraint is applied - Data m_endConstraintTime; - /// Rotation Matrix of affine transformation - Data m_rotation; - /// Quaternion of affine transformation (for rigid) - Data m_quaternion; - /// Translation Matrix of affine transformation - Data m_translation; - /// Draw constrained points - Data m_drawConstrainedPoints; - /// initial constrained DOFs position - VecCoord x0; - /// final constrained DOFs position - VecCoord xf; - /// initial mesh DOFs position - VecCoord meshPointsX0; - /// final mesh DOFs position - VecCoord meshPointsXf; - - /// 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: - AffineMovementConstraint(); - - virtual ~AffineMovementConstraint(); - -public: - //Add or clear constraints - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - /// -- Constraint interface - void init() override; - - /// Cancel the possible forces - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - /// Cancel the possible velocities - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - /// Apply the computed movements to the border mesh points between beginConstraintTime and endConstraintTime - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - - void projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /* cData */) override - { - msg_error() << "projectJacobianMatrix not implemented"; - } - - /// Compute the theoretical final positions - void getFinalPositions (VecCoord& finalPos, DataVecCoord& xData); - - // Implement projectMatrix for assembled solver of compliant - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - /// Draw the constrained points (= border mesh points) - void draw(const core::visual::VisualParams* vparams) override; - -protected: - - void projectResponseImpl(VecDeriv& dx); - -private: - - /// Initialize initial positions - void initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0); - - /// Initialize final positions - void initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0 , VecCoord& xf); - - /// Apply affine transform - void transform(const SetIndexArray & indices, VecCoord& x0 , VecCoord& xf); -}; - -#if !defined(SOFABOUNDARYCONDITION_AFFINEMOVEMENTCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementConstraint; -#endif //SOFABOUNDARYCONDITION_AFFINEMOVEMENTCONSTRAINT_CPP - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AffineMovementConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl index b6434701c86..20e6e0d8886 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl @@ -21,290 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include +#include -#include - -namespace sofa::component::constraint::projective -{ - -template -AffineMovementConstraint::AffineMovementConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , data(new AffineMovementConstraintInternalData) - , m_meshIndices( initData(&m_meshIndices,"meshIndices","Indices of the mesh") ) - , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) - , m_beginConstraintTime( initData(&m_beginConstraintTime,"beginConstraintTime","Begin time of the bilinear constraint") ) - , m_endConstraintTime( initData(&m_endConstraintTime,"endConstraintTime","End time of the bilinear constraint") ) - , m_rotation( initData(&m_rotation,"rotation","rotation applied to border points") ) - , m_quaternion( initData(&m_quaternion,"quaternion","quaternion applied to border points") ) - , m_translation( initData(&m_translation,"translation","translation applied to border points") ) - , m_drawConstrainedPoints( initData(&m_drawConstrainedPoints,"drawConstrainedPoints","draw constrained points") ) - , l_topology(initLink("topology", "link to the topology container")) -{ - if(!m_beginConstraintTime.isSet()) - m_beginConstraintTime = 0; - if(!m_endConstraintTime.isSet()) - m_endConstraintTime = 20; -} - - - -template -AffineMovementConstraint::~AffineMovementConstraint() -{ - -} - -template -void AffineMovementConstraint::clearConstraints() -{ - m_indices.beginEdit()->clear(); - m_indices.endEdit(); -} - -template -void AffineMovementConstraint::addConstraint(Index index) -{ - m_indices.beginEdit()->push_back(index); - m_indices.endEdit(); -} - -template -void AffineMovementConstraint::removeConstraint(Index index) -{ - removeValue(*m_indices.beginEdit(),index); - m_indices.endEdit(); -} - -// -- Constraint interface - - -template -void AffineMovementConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - m_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - const SetIndexArray & indices = m_indices.getValue(); - - auto maxIndex=this->mstate->getSize(); - for (Size i=0; i= maxIndex) - { - msg_error() << "Index " << index << " not valid!"; - removeConstraint(index); - } - } - -} - -template -void AffineMovementConstraint::projectResponseImpl(VecDeriv& dx) -{ - const SetIndexArray & indices = m_indices.getValue(); - for (size_t i = 0; i< indices.size(); ++i) - { - dx[indices[i]]=Deriv(); - } -} - -template -void AffineMovementConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseImpl(res.wref()); -} - - - -template -void AffineMovementConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = vData; - projectResponseImpl(res.wref()); -} - -template -void AffineMovementConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - const SetIndexArray & indices = m_indices.getValue(); - - // Time - SReal beginTime = m_beginConstraintTime.getValue(); - SReal endTime = m_endConstraintTime.getValue(); - SReal totalTime = endTime - beginTime; - - //initialize initial mesh Dofs positions, if it's not done - if(meshPointsX0.size()==0) - this->initializeInitialPositions(m_meshIndices.getValue(),xData,meshPointsX0); - - //initialize final mesh Dofs positions, if it's not done - if(meshPointsXf.size()==0) - this->initializeFinalPositions(m_meshIndices.getValue(),xData, meshPointsX0, meshPointsXf); - - //initialize initial constrained Dofs positions, if it's not done - if(x0.size() == 0) - this->initializeInitialPositions(indices,xData,x0); - - //initialize final constrained Dofs positions, if it's not done - if (xf.size() == 0) - this->initializeFinalPositions(indices,xData,x0,xf); - // Update the intermediate Dofs positions computed by linear interpolation - SReal time = sofa::core::objectmodel::basecontext::getTime(this->getContext()->getRootContext()); - if( time > beginTime && time <= endTime && totalTime > 0) - { - for (auto index : indices) - { - DataTypes::setCPos( x[index], - ((DataTypes::getCPos(xf[index])-DataTypes::getCPos(x0[index]))*time + - (DataTypes::getCPos(x0[index])*endTime - DataTypes::getCPos(xf[index])*beginTime))/totalTime); - } - } - else if (time > endTime) - { - for (auto index : indices) - { - x[index] = xf[index]; - } - } -} - -template -void AffineMovementConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned /*offset*/ ) -{ - // clears the rows and columns associated with constrained particles - const unsigned blockSize = DataTypes::deriv_total_size; - - for (const auto id : m_indices.getValue()) - { - M->clearRowsCols( id * blockSize, (id+1) * blockSize ); - } -} - -template -void AffineMovementConstraint::getFinalPositions( VecCoord& finalPos,DataVecCoord& xData) -{ - // Indices of mesh points - const SetIndexArray & meshIndices = m_meshIndices.getValue(); - - // Initialize final positions - if(meshPointsXf.size()==0) - {this->initializeFinalPositions(meshIndices,xData,meshPointsX0,meshPointsXf);} - - // Set final positions - finalPos.resize(meshIndices.size()); - for (size_t i=0; i < meshIndices.size() ; ++i) - { - finalPos[meshIndices[i]] = meshPointsXf[meshIndices[i]]; - } -} - -template -void AffineMovementConstraint::initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0) -{ - helper::WriteAccessor x = xData; - - x0.resize(x.size()); - for (size_t i=0; i < indices.size() ; ++i) - { - x0[indices[i]] = x[indices[i]]; - } -} - - -template <> -void AffineMovementConstraint::transform(const SetIndexArray & indices, - defaulttype::Rigid3Types::VecCoord& x0, - defaulttype::Rigid3Types::VecCoord& xf) -{ - // Get quaternion and translation values - RotationMatrix rotationMat(0); - const Quat quat = m_quaternion.getValue(); - quat.toMatrix(rotationMat); - const Vec3 translation = m_translation.getValue(); - - // Apply transformation - for (size_t i=0; i < indices.size() ; ++i) - { - // Translation - xf[indices[i]].getCenter() = rotationMat*(x0[indices[i]].getCenter()) + translation; - // Rotation - xf[indices[i]].getOrientation() = (quat)+x0[indices[i]].getOrientation(); - } -} - -template -void AffineMovementConstraint::transform(const SetIndexArray & indices, VecCoord& x0, VecCoord& xf) -{ - Vec3 translation = m_translation.getValue(); - - for (size_t i=0; i < indices.size() ; ++i) - { - DataTypes::setCPos(xf[indices[i]], (m_rotation.getValue())*DataTypes::getCPos(x0[indices[i]]) + translation); - } -} - - -template -void AffineMovementConstraint::initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0, VecCoord& xf) -{ - helper::WriteAccessor x = xData; - - xf.resize(x.size()); - - // if the positions were not initialized - if(x0.size() == 0) - this->initializeInitialPositions(indices,xData,x0); - - transform(indices,x0,xf); -} - -template -void AffineMovementConstraint::draw(const core::visual::VisualParams* vparams) -{ - const SetIndexArray & indices = m_indices.getValue(); - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - Vec3 point; - - if(m_drawConstrainedPoints.getValue()) - { - std::vector< Vec3 > points; - for( auto& index : indices ) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - constexpr sofa::type::RGBAColor color(1,0.5,0.5,1); - vparams->drawTool()->drawPoints(points, 10, color); - } -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AffineMovementConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp similarity index 79% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp index 433bad30dff..a34416970dc 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp @@ -19,24 +19,24 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFABOUNDARYCONDITION_AFFINEMOVEMENTCONSTRAINT_CPP +#define SOFABOUNDARYCONDITION_AFFINEMOVEMENTPROJECTIVECONSTRAINT_CPP #include #include #include #include -#include +#include namespace sofa::component::constraint::projective { -int AffineMovementConstraintRegister = core::RegisterObject("Constraint the movement by a rigid transform.") - .add< AffineMovementConstraint >() - .add< AffineMovementConstraint >() +int AffineMovementProjectiveConstraintRegister = core::RegisterObject("Constraint the movement by a rigid transform.") + .add< AffineMovementProjectiveConstraint >() + .add< AffineMovementProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h new file mode 100644 index 00000000000..f769a867a6b --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h @@ -0,0 +1,169 @@ +/****************************************************************************** +* 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 +#include +#include + +namespace sofa::component::constraint::projective +{ + +template +class AffineMovementProjectiveConstraintInternalData +{ +}; + +/** + Impose a motion to all the boundary points of a mesh. The motion of the 4 corners are given in the data m_cornerMovements and the movements of the edge points are computed by linear interpolation. +*/ +template +class AffineMovementProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(AffineMovementProjectiveConstraint,TDataTypes), + SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); + + using Index = sofa::Index; + typedef TDataTypes DataTypes; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::CPos CPos; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + typedef type::Quat Quat; + typedef type::Vec3 Vec3; + + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef core::objectmodel::Data DataMatrixDeriv; + + static const auto CoordSize = Coord::total_size; + typedef type::Mat<3,3,Real> RotationMatrix; + +protected: + AffineMovementProjectiveConstraintInternalData *data; + friend class AffineMovementProjectiveConstraintInternalData; + +public : + /// indices of the DOFs of the mesh + SetIndex m_meshIndices; + /// indices of the DOFs the constraint is applied to + SetIndex m_indices; + /// data begin time when the constraint is applied + Data m_beginConstraintTime; + /// data end time when the constraint is applied + Data m_endConstraintTime; + /// Rotation Matrix of affine transformation + Data m_rotation; + /// Quaternion of affine transformation (for rigid) + Data m_quaternion; + /// Translation Matrix of affine transformation + Data m_translation; + /// Draw constrained points + Data m_drawConstrainedPoints; + /// initial constrained DOFs position + VecCoord x0; + /// final constrained DOFs position + VecCoord xf; + /// initial mesh DOFs position + VecCoord meshPointsX0; + /// final mesh DOFs position + VecCoord meshPointsXf; + + /// 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: + AffineMovementProjectiveConstraint(); + + virtual ~AffineMovementProjectiveConstraint(); + +public: + //Add or clear constraints + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + /// -- Constraint interface + void init() override; + + /// Cancel the possible forces + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + /// Cancel the possible velocities + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + /// Apply the computed movements to the border mesh points between beginConstraintTime and endConstraintTime + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + + void projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /* cData */) override + { + msg_error() << "projectJacobianMatrix not implemented"; + } + + /// Compute the theoretical final positions + void getFinalPositions (VecCoord& finalPos, DataVecCoord& xData); + + // Implement projectMatrix for assembled solver of compliant + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + /// Draw the constrained points (= border mesh points) + void draw(const core::visual::VisualParams* vparams) override; + +protected: + + void projectResponseImpl(VecDeriv& dx); + +private: + + /// Initialize initial positions + void initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0); + + /// Initialize final positions + void initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0 , VecCoord& xf); + + /// Apply affine transform + void transform(const SetIndexArray & indices, VecCoord& x0 , VecCoord& xf); +}; + +#if !defined(SOFABOUNDARYCONDITION_AFFINEMOVEMENTPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; +#endif //SOFABOUNDARYCONDITION_AFFINEMOVEMENTPROJECTIVECONSTRAINT_CPP + +template +using AffineMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AffineMovementConstraint has been renamed to AffineMovementProjectiveConstraint") = AffineMovementProjectiveConstraint; + + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.inl new file mode 100644 index 00000000000..ee7a56d83ac --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.inl @@ -0,0 +1,310 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +template +AffineMovementProjectiveConstraint::AffineMovementProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , data(new AffineMovementProjectiveConstraintInternalData) + , m_meshIndices( initData(&m_meshIndices,"meshIndices","Indices of the mesh") ) + , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) + , m_beginConstraintTime( initData(&m_beginConstraintTime,"beginConstraintTime","Begin time of the bilinear constraint") ) + , m_endConstraintTime( initData(&m_endConstraintTime,"endConstraintTime","End time of the bilinear constraint") ) + , m_rotation( initData(&m_rotation,"rotation","rotation applied to border points") ) + , m_quaternion( initData(&m_quaternion,"quaternion","quaternion applied to border points") ) + , m_translation( initData(&m_translation,"translation","translation applied to border points") ) + , m_drawConstrainedPoints( initData(&m_drawConstrainedPoints,"drawConstrainedPoints","draw constrained points") ) + , l_topology(initLink("topology", "link to the topology container")) +{ + if(!m_beginConstraintTime.isSet()) + m_beginConstraintTime = 0; + if(!m_endConstraintTime.isSet()) + m_endConstraintTime = 20; +} + + + +template +AffineMovementProjectiveConstraint::~AffineMovementProjectiveConstraint() +{ + +} + +template +void AffineMovementProjectiveConstraint::clearConstraints() +{ + m_indices.beginEdit()->clear(); + m_indices.endEdit(); +} + +template +void AffineMovementProjectiveConstraint::addConstraint(Index index) +{ + m_indices.beginEdit()->push_back(index); + m_indices.endEdit(); +} + +template +void AffineMovementProjectiveConstraint::removeConstraint(Index index) +{ + removeValue(*m_indices.beginEdit(),index); + m_indices.endEdit(); +} + +// -- Constraint interface + + +template +void AffineMovementProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + m_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + const SetIndexArray & indices = m_indices.getValue(); + + auto maxIndex=this->mstate->getSize(); + for (Size i=0; i= maxIndex) + { + msg_error() << "Index " << index << " not valid!"; + removeConstraint(index); + } + } + +} + +template +void AffineMovementProjectiveConstraint::projectResponseImpl(VecDeriv& dx) +{ + const SetIndexArray & indices = m_indices.getValue(); + for (size_t i = 0; i< indices.size(); ++i) + { + dx[indices[i]]=Deriv(); + } +} + +template +void AffineMovementProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseImpl(res.wref()); +} + + + +template +void AffineMovementProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = vData; + projectResponseImpl(res.wref()); +} + +template +void AffineMovementProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + const SetIndexArray & indices = m_indices.getValue(); + + // Time + SReal beginTime = m_beginConstraintTime.getValue(); + SReal endTime = m_endConstraintTime.getValue(); + SReal totalTime = endTime - beginTime; + + //initialize initial mesh Dofs positions, if it's not done + if(meshPointsX0.size()==0) + this->initializeInitialPositions(m_meshIndices.getValue(),xData,meshPointsX0); + + //initialize final mesh Dofs positions, if it's not done + if(meshPointsXf.size()==0) + this->initializeFinalPositions(m_meshIndices.getValue(),xData, meshPointsX0, meshPointsXf); + + //initialize initial constrained Dofs positions, if it's not done + if(x0.size() == 0) + this->initializeInitialPositions(indices,xData,x0); + + //initialize final constrained Dofs positions, if it's not done + if (xf.size() == 0) + this->initializeFinalPositions(indices,xData,x0,xf); + // Update the intermediate Dofs positions computed by linear interpolation + SReal time = sofa::core::objectmodel::basecontext::getTime(this->getContext()->getRootContext()); + if( time > beginTime && time <= endTime && totalTime > 0) + { + for (auto index : indices) + { + DataTypes::setCPos( x[index], + ((DataTypes::getCPos(xf[index])-DataTypes::getCPos(x0[index]))*time + + (DataTypes::getCPos(x0[index])*endTime - DataTypes::getCPos(xf[index])*beginTime))/totalTime); + } + } + else if (time > endTime) + { + for (auto index : indices) + { + x[index] = xf[index]; + } + } +} + +template +void AffineMovementProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned /*offset*/ ) +{ + // clears the rows and columns associated with constrained particles + const unsigned blockSize = DataTypes::deriv_total_size; + + for (const auto id : m_indices.getValue()) + { + M->clearRowsCols( id * blockSize, (id+1) * blockSize ); + } +} + +template +void AffineMovementProjectiveConstraint::getFinalPositions( VecCoord& finalPos,DataVecCoord& xData) +{ + // Indices of mesh points + const SetIndexArray & meshIndices = m_meshIndices.getValue(); + + // Initialize final positions + if(meshPointsXf.size()==0) + {this->initializeFinalPositions(meshIndices,xData,meshPointsX0,meshPointsXf);} + + // Set final positions + finalPos.resize(meshIndices.size()); + for (size_t i=0; i < meshIndices.size() ; ++i) + { + finalPos[meshIndices[i]] = meshPointsXf[meshIndices[i]]; + } +} + +template +void AffineMovementProjectiveConstraint::initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0) +{ + helper::WriteAccessor x = xData; + + x0.resize(x.size()); + for (size_t i=0; i < indices.size() ; ++i) + { + x0[indices[i]] = x[indices[i]]; + } +} + + +template <> +void AffineMovementProjectiveConstraint::transform(const SetIndexArray & indices, + defaulttype::Rigid3Types::VecCoord& x0, + defaulttype::Rigid3Types::VecCoord& xf) +{ + // Get quaternion and translation values + RotationMatrix rotationMat(0); + const Quat quat = m_quaternion.getValue(); + quat.toMatrix(rotationMat); + const Vec3 translation = m_translation.getValue(); + + // Apply transformation + for (size_t i=0; i < indices.size() ; ++i) + { + // Translation + xf[indices[i]].getCenter() = rotationMat*(x0[indices[i]].getCenter()) + translation; + // Rotation + xf[indices[i]].getOrientation() = (quat)+x0[indices[i]].getOrientation(); + } +} + +template +void AffineMovementProjectiveConstraint::transform(const SetIndexArray & indices, VecCoord& x0, VecCoord& xf) +{ + Vec3 translation = m_translation.getValue(); + + for (size_t i=0; i < indices.size() ; ++i) + { + DataTypes::setCPos(xf[indices[i]], (m_rotation.getValue())*DataTypes::getCPos(x0[indices[i]]) + translation); + } +} + + +template +void AffineMovementProjectiveConstraint::initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0, VecCoord& xf) +{ + helper::WriteAccessor x = xData; + + xf.resize(x.size()); + + // if the positions were not initialized + if(x0.size() == 0) + this->initializeInitialPositions(indices,xData,x0); + + transform(indices,x0,xf); +} + +template +void AffineMovementProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + const SetIndexArray & indices = m_indices.getValue(); + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + Vec3 point; + + if(m_drawConstrainedPoints.getValue()) + { + std::vector< Vec3 > points; + for( auto& index : indices ) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + constexpr sofa::type::RGBAColor color(1,0.5,0.5,1); + vparams->drawTool()->drawPoints(points, 10, color); + } +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h index 14eff971abb..d93f7476b6f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h @@ -20,105 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/** Attach given pair of particles, projecting the positions of the second particles to the first ones. -*/ -template -class AttachConstraint : public core::behavior::PairInteractionProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(AttachConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::PairInteractionProjectiveConstraintSet,DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - - typedef core::objectmodel::Data DataVecCoord; - typedef core::objectmodel::Data DataVecDeriv; - - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - -public: - SetIndex f_indices1; ///< Indices of the source points on the first model - SetIndex f_indices2; ///< Indices of the fixed points on the second model - Data f_twoWay; ///< true if forces should be projected back from model2 to model1 - Data f_freeRotations; ///< true to keep rotations free (only used for Rigid DOFs) - Data f_lastFreeRotation; ///< true to keep rotation of the last attached point free (only used for Rigid DOFs) - Data f_restRotations; ///< true to use rest rotations local offsets (only used for Rigid DOFs) - Data f_lastPos; ///< position at which the attach constraint should become inactive - Data f_lastDir; ///< direction from lastPos at which the attach coustraint should become inactive - Data f_clamp; ///< true to clamp particles at lastPos instead of freeing them. - Data f_minDistance; ///< the constraint become inactive if the distance between the points attached is bigger than minDistance. - Data< Real > d_positionFactor; ///< IN: Factor applied to projection of position - Data< Real > d_velocityFactor; ///< IN: Factor applied to projection of velocity - Data< Real > d_responseFactor; ///< IN: Factor applied to projection of force/acceleration - Data< type::vector > d_constraintFactor; ///< Constraint factor per pair of points constrained. 0 -> the constraint is released. 1 -> the constraint is fully constrained - - type::vector activeFlags; - type::vector constraintReleased; - type::vector lastDist; - type::vector> restRotations; - -protected: - AttachConstraint(); - AttachConstraint(core::behavior::MechanicalState *mm1, core::behavior::MechanicalState *mm2); - ~AttachConstraint() override; - -public: - - /// Inherited from Base - void init() override; - void reinit() override; - void draw(const core::visual::VisualParams* vparams) override; - - /// Inherited from Constraint - void projectJacobianMatrix(const core::MechanicalParams* mparams, core::MultiMatrixDerivId cId) override; - void projectResponse(const core::MechanicalParams *mparams, DataVecDeriv& dx1, DataVecDeriv& dx2) override; - void projectVelocity(const core::MechanicalParams *mparams, DataVecDeriv& v1, DataVecDeriv& v2) override; - void projectPosition(const core::MechanicalParams *mparams, DataVecCoord& x1, DataVecCoord& x2) override; - - /// Project the global Mechanical Matrix to constrained space using offset parameter - void applyConstraint(const core::MechanicalParams *mparams, - const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - /// Project the global Mechanical Vector to constrained space using offset parameter - void applyConstraint(const core::MechanicalParams *mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - virtual void reinitIfChanged(); - - template - static std::string templateName(const T* ptr= nullptr) { - return core::behavior::PairInteractionProjectiveConstraintSet::templateName(ptr); - } - -protected : - const Real getConstraintFactor(const int index); - void doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor); - void doProjectVelocity(Deriv& x1, Deriv& x2, bool freeRotations, unsigned index, Real velocityFactor); - void doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor); - - void calcRestRotations(); - static unsigned int DerivConstrainedSize(bool freeRotations); - -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ATTACHCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AttachProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl index a77b223d41d..83e8ee50264 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl @@ -20,624 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -namespace sofa::component::constraint::projective -{ +#include -using sofa::simulation::Node ; - -template<> -inline void AttachConstraint::doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor) -{ - SOFA_UNUSED(positionFactor); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (f_minDistance.getValue() != -1.0 && - (x2.getCenter() - x1.getCenter()).norm() > f_minDistance.getValue()) - { - constraintReleased[index] = true; - return; - } - constraintReleased[index] = false; - - x2.getCenter() = x1.getCenter(); - if (!freeRotations) - { - if (!restRotations.empty()) - { - if (index+1 >= lastDist.size() || activeFlags[index+1]) - x2.getOrientation() = x1.getOrientation()*restRotations[index]; - else - { - // gradually set the velocity along the direction axis - const Real fact = -lastDist[index] / (lastDist[index+1]-lastDist[index]); - const sofa::type::Vec3 axis(restRotations[index][0], restRotations[index][1], restRotations[index][2]); - const Real angle = acos(restRotations[index][3])*2; - x2.getOrientation() = x1.getOrientation()*sofa::type::Quat(axis,angle*fact); - } - } - else - x2.getOrientation() = x1.getOrientation(); - } -} - - -template<> -inline void AttachConstraint::doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor) -{ - SOFA_UNUSED(positionFactor); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (f_minDistance.getValue() != -1 && - (x2.getCenter() - x1.getCenter()).norm() > f_minDistance.getValue()) - { - constraintReleased[index] = true; - return; - } - constraintReleased[index] = false; - - x2.getCenter() = x1.getCenter(); - if (!freeRotations) - x2.getOrientation() = x1.getOrientation(); -} - - -template<> -inline void AttachConstraint::doProjectVelocity(Deriv& x1, Deriv& x2, bool freeRotations, unsigned index, Real velocityFactor) -{ - SOFA_UNUSED(velocityFactor); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (constraintReleased[index]) - return; - - getVCenter( x2) = getVCenter(x1); - if (!freeRotations) - getVOrientation(x2) = getVOrientation(x1); -} - - -template<> -inline void AttachConstraint::doProjectVelocity(Deriv& x1, Deriv& x2, bool freeRotations, unsigned index, Real velocityFactor) -{ - SOFA_UNUSED(velocityFactor); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (constraintReleased[index]) return; - - getVCenter(x2) = getVCenter(x1); - if (!freeRotations) - getVOrientation(x2) = getVOrientation(x1); -} - -template<> -inline void AttachConstraint::doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor) -{ - SOFA_UNUSED(responseFactor); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (constraintReleased[index]) return; - - if (!twoway) - { - if (!freeRotations) - dx2 = Deriv(); - else - getVCenter(dx2).clear(); - } - else - { - if (!freeRotations) - { - dx1 += dx2; - dx2 = dx1; - } - else - { - getVCenter(dx1) += getVCenter(dx2); - getVCenter(dx2) = getVCenter(dx1); - } - } -} - - -template<> -inline void AttachConstraint::doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor) -{ - SOFA_UNUSED(responseFactor); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (constraintReleased[index]) return; - - if (!twoway) - { - if (!freeRotations) - dx2 = Deriv(); - else - getVCenter(dx2).clear(); - } - else - { - if (!freeRotations) - { - dx1 += dx2; - dx2 = dx1; - } - else - { - getVCenter(dx1) += getVCenter(dx2); - getVCenter(dx2) = getVCenter(dx1); - } - } -} - -template -inline unsigned int AttachConstraint::DerivConstrainedSize(bool freeRotations) -{ - if (std::is_same::value || std::is_same::value) { - if (freeRotations) - return Deriv::spatial_dimensions; - else - return Deriv::total_size; - } - else { - SOFA_UNUSED(freeRotations); - return Deriv::size(); - } -} - -// Could be simplified with default values for mm1 and mm2, but that way we are assured that either both or neither of mm1/mm2 are set. -template -AttachConstraint::AttachConstraint() - : AttachConstraint::AttachConstraint(nullptr, nullptr) -{ -} - -template -AttachConstraint::AttachConstraint(core::behavior::MechanicalState *mm1, core::behavior::MechanicalState *mm2) - : core::behavior::PairInteractionProjectiveConstraintSet(mm1,mm2) - , f_indices1( initData(&f_indices1,"indices1","Indices of the source points on the first model") ) - , f_indices2( initData(&f_indices2,"indices2","Indices of the fixed points on the second model") ) - , f_twoWay( initData(&f_twoWay,false,"twoWay", "true if forces should be projected back from model2 to model1") ) - , f_freeRotations( initData(&f_freeRotations,false,"freeRotations", "true to keep rotations free (only used for Rigid DOFs)") ) - , f_lastFreeRotation( initData(&f_lastFreeRotation,false,"lastFreeRotation", "true to keep rotation of the last attached point free (only used for Rigid DOFs)") ) - , f_restRotations( initData(&f_restRotations,false,"restRotations", "true to use rest rotations local offsets (only used for Rigid DOFs)") ) - , f_lastPos( initData(&f_lastPos,"lastPos", "position at which the attach constraint should become inactive") ) - , f_lastDir( initData(&f_lastDir,"lastDir", "direction from lastPos at which the attach coustraint should become inactive") ) - , f_clamp( initData(&f_clamp, false,"clamp", "true to clamp particles at lastPos instead of freeing them.") ) - , f_minDistance( initData(&f_minDistance, static_cast(-1),"minDistance", "the constraint become inactive if the distance between the points attached is bigger than minDistance.") ) - , d_positionFactor(initData(&d_positionFactor, static_cast(1.0), "positionFactor", "IN: Factor applied to projection of position")) - , d_velocityFactor(initData(&d_velocityFactor, static_cast(1.0), "velocityFactor", "IN: Factor applied to projection of velocity")) - , d_responseFactor(initData(&d_responseFactor, static_cast(1.0), "responseFactor", "IN: Factor applied to projection of force/acceleration")) - , d_constraintFactor( initData(&d_constraintFactor,"constraintFactor","Constraint factor per pair of points constrained. 0 -> the constraint is released. 1 -> the constraint is fully constrained") ) -{ - -} - -template -AttachConstraint::~AttachConstraint() -{ -} - -template -void AttachConstraint::init() -{ - this->core::behavior::PairInteractionProjectiveConstraintSet::init(); - reinit(); -} - -template -void AttachConstraint::reinit() -{ - // Check coherency of size between indices vectors 1 and 2 - if(f_indices1.getValue().size() != f_indices2.getValue().size()) - { - msg_warning() << "Size mismatch between indices1 and indices2 (" - << f_indices1.getValue().size() << " != " << f_indices2.getValue().size() << ")."; - } - - // Set to the correct length if dynamic, else check coherency. - if(d_constraintFactor.getValue().size()) - { - helper::ReadAccessor>> constraintFactor = d_constraintFactor; - if(constraintFactor.size() != f_indices2.getValue().size()) - { - msg_warning() << "Size of vector constraintFactor, do not fit number of indices attached (" << constraintFactor.size() << " != " << f_indices2.getValue().size() << ")."; - } - else - { - for (unsigned int j=0; j 1.0) || (constraintFactor[j] < 0.0)) - { - msg_warning() << "Value of vector constraintFactor at indice "< 1.0e-10) { - lastDist.resize(f_indices2.getValue().size()); - } - - if (f_restRotations.getValue()) - calcRestRotations(); - this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid); -} - -template -void AttachConstraint::reinitIfChanged() { - if((f_indices1.getParent() || f_indices2.getParent()) && constraintReleased.size() != f_indices2.getValue().size()) - { - reinit(); - } -} - -template -void AttachConstraint::calcRestRotations() -{ -} - -template <> -void AttachConstraint::calcRestRotations(); - -template -void AttachConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, core::MultiMatrixDerivId cId) -{ - SOFA_UNUSED(mparams); - SOFA_UNUSED(cId); -} - -template -void AttachConstraint::projectPosition(const core::MechanicalParams * mparams, DataVecCoord& res1_d, DataVecCoord& res2_d) -{ - SOFA_UNUSED(mparams); - const SetIndexArray & indices1 = f_indices1.getValue(); - const SetIndexArray & indices2 = f_indices2.getValue(); - const bool freeRotations = f_freeRotations.getValue(); - const bool lastFreeRotation = f_lastFreeRotation.getValue(); - const bool last = (f_lastDir.isSet() && f_lastDir.getValue().norm() > 1.0e-10); - const bool clamp = f_clamp.getValue(); - - VecCoord &res1 = *res1_d.beginEdit(); - VecCoord &res2 = *res2_d.beginEdit(); - - // update active flags - reinitIfChanged(); - - for (unsigned int i=0; i p3d; - DataTypes::get(p3d[0],p3d[1],p3d[2],p); - lastDist[i] = (Real)( (p3d-f_lastPos.getValue())*f_lastDir.getValue()); - if (lastDist[i] > 0.0) - { - if (clamp) - { - msg_info_when(activeFlags[i]) << "AttachConstraint: point " - <> positionFactor = d_positionFactor; - for (unsigned int i=0; i=activeFlags.size() || !activeFlags[i+1])), i, positionFactor); - } - else if (clamp) - { - DataTypes::set(p,f_lastPos.getValue()[0],f_lastPos.getValue()[1],f_lastPos.getValue()[2]); - - msg_info() << "AttachConstraint: x2["< -void AttachConstraint::projectVelocity(const core::MechanicalParams * mparams, DataVecDeriv& res1_d, DataVecDeriv& res2_d) -{ - SOFA_UNUSED(mparams); - VecDeriv &res1 = *res1_d.beginEdit(); - VecDeriv &res2 = *res2_d.beginEdit(); - - const SetIndexArray & indices1 = f_indices1.getValue(); - const SetIndexArray & indices2 = f_indices2.getValue(); - const bool freeRotations = f_freeRotations.getValue(); - const bool lastFreeRotation = f_lastFreeRotation.getValue(); - const bool clamp = f_clamp.getValue(); - - reinitIfChanged(); - helper::ReadAccessor> velocityFactor = d_velocityFactor; - for (unsigned int i=0; i=activeFlags.size() || !activeFlags[i+1])), i, velocityFactor); - } - else if (clamp) - { - msg_info() << "AttachConstraint: v2["< -void AttachConstraint::projectResponse(const core::MechanicalParams * mparams, DataVecDeriv& res1_d, DataVecDeriv& res2_d) -{ - SOFA_UNUSED(mparams); - VecDeriv &res1 = *res1_d.beginEdit(); - VecDeriv &res2 = *res2_d.beginEdit(); - - const SetIndexArray & indices1 = f_indices1.getValue(); - const SetIndexArray & indices2 = f_indices2.getValue(); - const bool twoway = f_twoWay.getValue(); - const bool freeRotations = f_freeRotations.getValue(); - const bool lastFreeRotation = f_lastFreeRotation.getValue(); - const bool clamp = f_clamp.getValue(); - - reinitIfChanged(); - helper::ReadAccessor> responseFactor = d_responseFactor; - for (unsigned int i=0; i=activeFlags.size() || !activeFlags[i+1])), twoway, i, responseFactor); - - msg_info() << " final r2["< -void AttachConstraint::applyConstraint(const core::MechanicalParams * mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if (f_twoWay.getValue()) - return; - - const sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate2); - if (!r) - return; - - sofa::linearalgebra::BaseMatrix *mat = r.matrix; - const unsigned int offset = r.offset; - - const SetIndexArray & indices = f_indices2.getValue(); - const unsigned int N = Deriv::size(); - const unsigned int NC = DerivConstrainedSize(f_freeRotations.getValue()); - const unsigned int NCLast = DerivConstrainedSize(f_lastFreeRotation.getValue()); - unsigned int i=0; - const bool clamp = f_clamp.getValue(); - - reinitIfChanged(); - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it, ++i) - { - if (!clamp && i < activeFlags.size() && !activeFlags[i]) - continue; - - msg_info() << "AttachConstraint: apply in matrix column/row "<<(*it); - - if (NCLast != NC && (i>=activeFlags.size() || !activeFlags[i+1])) - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(offset + N * (*it) + c); - // Set Fixed Vertex - for (unsigned int c=0; cset(offset + N * (*it) + c, offset + N * (*it) + c, 1.0); - } - else - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(offset + N * (*it) + c); - // Set Fixed Vertex - for (unsigned int c=0; cset(offset + N * (*it) + c, offset + N * (*it) + c, 1.0); - } - } -} - - -template -void AttachConstraint::applyConstraint(const core::MechanicalParams * mparams, linearalgebra::BaseVector* vect, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if (f_twoWay.getValue()) - return; - - const int o = matrix->getGlobalOffset(this->mstate2); - if (o < 0) - return; - - unsigned int offset = (unsigned int)o; - - msg_info() << "applyConstraint in Vector with offset = " << offset ; - - const SetIndexArray & indices = f_indices2.getValue(); - const unsigned int N = Deriv::size(); - const unsigned int NC = DerivConstrainedSize(f_freeRotations.getValue()); - const unsigned int NCLast = DerivConstrainedSize(f_lastFreeRotation.getValue()); - unsigned int i = 0; - const bool clamp = f_clamp.getValue(); - - reinitIfChanged(); - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it, ++i) - { - if (!clamp && i < activeFlags.size() && !activeFlags[i]) - continue; - - if (NCLast != NC && (i>=activeFlags.size() || !activeFlags[i+1])) - { - for (unsigned int c=0; cclear(offset + N * (*it) + c); - } - else - { - for (unsigned int c=0; cclear(offset + N * (*it) + c); - } - } -} - -template -const typename DataTypes::Real AttachConstraint::getConstraintFactor(const int index) { - return d_constraintFactor.getValue().size() ? d_constraintFactor.getValue()[index] : 1; -} - -template -void AttachConstraint::doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor) -{ - SOFA_UNUSED(freeRotations); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (f_minDistance.getValue() != -1 && - (x2 - x1).norm() > f_minDistance.getValue()) - { - constraintReleased[index] = true; - return; - } - constraintReleased[index] = false; - - Deriv corr = (x2-x1)*(0.5*positionFactor*getConstraintFactor(index)); - - x1 += corr; - x2 -= corr; -} - -template -void AttachConstraint::doProjectVelocity(Deriv &x1, Deriv &x2, bool freeRotations, unsigned index, Real velocityFactor) -{ - SOFA_UNUSED(freeRotations); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (constraintReleased[index]) return; - - Deriv corr = (x2-x1)*(0.5*velocityFactor*getConstraintFactor(index)); - - x1 += corr; - x2 -= corr; -} - -template -void AttachConstraint::doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor) -{ - SOFA_UNUSED(freeRotations); - // do nothing if distance between x2 & x1 is bigger than f_minDistance - if (constraintReleased[index]) return; - - if (!twoway) - { - dx2 = Deriv(); - } - else - { - Deriv corr = (dx2-dx1)*0.5*responseFactor*getConstraintFactor(index); - dx1 += corr; - dx2 -= corr; - } -} - - -template -void AttachConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) - return; - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - vparams->drawTool()->disableLighting(); - - const SetIndexArray & indices1 = f_indices1.getValue(); - const SetIndexArray & indices2 = f_indices2.getValue(); - const VecCoord& x1 = this->mstate1->read(core::ConstVecCoordId::position())->getValue(); - const VecCoord& x2 = this->mstate2->read(core::ConstVecCoordId::position())->getValue(); - - constexpr sofa::type::RGBAColor color1(1,0.5,0.5,1); - std::vector vertices; - - for (unsigned int i=0; i i && !activeFlags[i]) - continue; - vertices.push_back(sofa::type::Vec3(x2[indices2[i]][0],x2[indices2[i]][1],x2[indices2[i]][2])); - } - vparams->drawTool()->drawPoints(vertices,10,color1); - vertices.clear(); - - constexpr sofa::type::RGBAColor color2(1,0.5,0.5,1); - for (unsigned int i=0; i i && !activeFlags[i]) - continue; - vertices.push_back(sofa::type::Vec3(x1[indices1[i]][0],x1[indices1[i]][1],x1[indices1[i]][2])); - vertices.push_back(sofa::type::Vec3(x2[indices2[i]][0],x2[indices2[i]][1],x2[indices2[i]][2])); - } - vparams->drawTool()->drawLines(vertices,1,color2); - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AttachProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp similarity index 71% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp index 8642434e285..2c2683c9d1c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ATTACHCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ATTACHPROJECTIVECONSTRAINT_CPP +#include #include namespace sofa::component::constraint::projective @@ -30,16 +30,16 @@ using namespace sofa::type; using namespace sofa::defaulttype; using namespace sofa::helper; -int AttachConstraintClass = core::RegisterObject("Attach given pair of particles, projecting the positions of the second particles to the first ones") - .add< AttachConstraint >() - .add< AttachConstraint >() - .add< AttachConstraint >() - .add< AttachConstraint >() - .add< AttachConstraint >() +int AttachProjectiveConstraintClass = core::RegisterObject("Attach given pair of particles, projecting the positions of the second particles to the first ones") + .add< AttachProjectiveConstraint >() + .add< AttachProjectiveConstraint >() + .add< AttachProjectiveConstraint >() + .add< AttachProjectiveConstraint >() + .add< AttachProjectiveConstraint >() ; template <> SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API -void AttachConstraint::calcRestRotations() +void AttachProjectiveConstraint::calcRestRotations() { const SetIndexArray & indices2 = f_indices2.getValue(); const VecCoord& x0 = this->mstate2->read(core::ConstVecCoordId::restPosition())->getValue(); @@ -61,11 +61,11 @@ void AttachConstraint::calcRestRotations() } } -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h new file mode 100644 index 00000000000..a463114ff85 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h @@ -0,0 +1,128 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +/** Attach given pair of particles, projecting the positions of the second particles to the first ones. +*/ +template +class AttachProjectiveConstraint : public core::behavior::PairInteractionProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(AttachProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::PairInteractionProjectiveConstraintSet,DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + + typedef core::objectmodel::Data DataVecCoord; + typedef core::objectmodel::Data DataVecDeriv; + + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + +public: + SetIndex f_indices1; ///< Indices of the source points on the first model + SetIndex f_indices2; ///< Indices of the fixed points on the second model + Data f_twoWay; ///< true if forces should be projected back from model2 to model1 + Data f_freeRotations; ///< true to keep rotations free (only used for Rigid DOFs) + Data f_lastFreeRotation; ///< true to keep rotation of the last attached point free (only used for Rigid DOFs) + Data f_restRotations; ///< true to use rest rotations local offsets (only used for Rigid DOFs) + Data f_lastPos; ///< position at which the attach constraint should become inactive + Data f_lastDir; ///< direction from lastPos at which the attach coustraint should become inactive + Data f_clamp; ///< true to clamp particles at lastPos instead of freeing them. + Data f_minDistance; ///< the constraint become inactive if the distance between the points attached is bigger than minDistance. + Data< Real > d_positionFactor; ///< IN: Factor applied to projection of position + Data< Real > d_velocityFactor; ///< IN: Factor applied to projection of velocity + Data< Real > d_responseFactor; ///< IN: Factor applied to projection of force/acceleration + Data< type::vector > d_constraintFactor; ///< Constraint factor per pair of points constrained. 0 -> the constraint is released. 1 -> the constraint is fully constrained + + type::vector activeFlags; + type::vector constraintReleased; + type::vector lastDist; + type::vector> restRotations; + +protected: + AttachProjectiveConstraint(); + AttachProjectiveConstraint(core::behavior::MechanicalState *mm1, core::behavior::MechanicalState *mm2); + ~AttachProjectiveConstraint() override; + +public: + + /// Inherited from Base + void init() override; + void reinit() override; + void draw(const core::visual::VisualParams* vparams) override; + + /// Inherited from Constraint + void projectJacobianMatrix(const core::MechanicalParams* mparams, core::MultiMatrixDerivId cId) override; + void projectResponse(const core::MechanicalParams *mparams, DataVecDeriv& dx1, DataVecDeriv& dx2) override; + void projectVelocity(const core::MechanicalParams *mparams, DataVecDeriv& v1, DataVecDeriv& v2) override; + void projectPosition(const core::MechanicalParams *mparams, DataVecCoord& x1, DataVecCoord& x2) override; + + /// Project the global Mechanical Matrix to constrained space using offset parameter + void applyConstraint(const core::MechanicalParams *mparams, + const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + /// Project the global Mechanical Vector to constrained space using offset parameter + void applyConstraint(const core::MechanicalParams *mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + virtual void reinitIfChanged(); + + template + static std::string templateName(const T* ptr= nullptr) { + return core::behavior::PairInteractionProjectiveConstraintSet::templateName(ptr); + } + +protected : + const Real getConstraintFactor(const int index); + void doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor); + void doProjectVelocity(Deriv& x1, Deriv& x2, bool freeRotations, unsigned index, Real velocityFactor); + void doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor); + + void calcRestRotations(); + static unsigned int DerivConstrainedSize(bool freeRotations); + +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ATTACHPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; +#endif + +template +using AttachConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AttachConstraint has been renamed to AttachProjectiveConstraint") = AttachProjectiveConstraint; + + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.inl new file mode 100644 index 00000000000..e7bd429434f --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.inl @@ -0,0 +1,643 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +using sofa::simulation::Node ; + +template<> +inline void AttachProjectiveConstraint::doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor) +{ + SOFA_UNUSED(positionFactor); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (f_minDistance.getValue() != -1.0 && + (x2.getCenter() - x1.getCenter()).norm() > f_minDistance.getValue()) + { + constraintReleased[index] = true; + return; + } + constraintReleased[index] = false; + + x2.getCenter() = x1.getCenter(); + if (!freeRotations) + { + if (!restRotations.empty()) + { + if (index+1 >= lastDist.size() || activeFlags[index+1]) + x2.getOrientation() = x1.getOrientation()*restRotations[index]; + else + { + // gradually set the velocity along the direction axis + const Real fact = -lastDist[index] / (lastDist[index+1]-lastDist[index]); + const sofa::type::Vec3 axis(restRotations[index][0], restRotations[index][1], restRotations[index][2]); + const Real angle = acos(restRotations[index][3])*2; + x2.getOrientation() = x1.getOrientation()*sofa::type::Quat(axis,angle*fact); + } + } + else + x2.getOrientation() = x1.getOrientation(); + } +} + + +template<> +inline void AttachProjectiveConstraint::doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor) +{ + SOFA_UNUSED(positionFactor); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (f_minDistance.getValue() != -1 && + (x2.getCenter() - x1.getCenter()).norm() > f_minDistance.getValue()) + { + constraintReleased[index] = true; + return; + } + constraintReleased[index] = false; + + x2.getCenter() = x1.getCenter(); + if (!freeRotations) + x2.getOrientation() = x1.getOrientation(); +} + + +template<> +inline void AttachProjectiveConstraint::doProjectVelocity(Deriv& x1, Deriv& x2, bool freeRotations, unsigned index, Real velocityFactor) +{ + SOFA_UNUSED(velocityFactor); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (constraintReleased[index]) + return; + + getVCenter( x2) = getVCenter(x1); + if (!freeRotations) + getVOrientation(x2) = getVOrientation(x1); +} + + +template<> +inline void AttachProjectiveConstraint::doProjectVelocity(Deriv& x1, Deriv& x2, bool freeRotations, unsigned index, Real velocityFactor) +{ + SOFA_UNUSED(velocityFactor); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (constraintReleased[index]) return; + + getVCenter(x2) = getVCenter(x1); + if (!freeRotations) + getVOrientation(x2) = getVOrientation(x1); +} + +template<> +inline void AttachProjectiveConstraint::doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor) +{ + SOFA_UNUSED(responseFactor); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (constraintReleased[index]) return; + + if (!twoway) + { + if (!freeRotations) + dx2 = Deriv(); + else + getVCenter(dx2).clear(); + } + else + { + if (!freeRotations) + { + dx1 += dx2; + dx2 = dx1; + } + else + { + getVCenter(dx1) += getVCenter(dx2); + getVCenter(dx2) = getVCenter(dx1); + } + } +} + + +template<> +inline void AttachProjectiveConstraint::doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor) +{ + SOFA_UNUSED(responseFactor); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (constraintReleased[index]) return; + + if (!twoway) + { + if (!freeRotations) + dx2 = Deriv(); + else + getVCenter(dx2).clear(); + } + else + { + if (!freeRotations) + { + dx1 += dx2; + dx2 = dx1; + } + else + { + getVCenter(dx1) += getVCenter(dx2); + getVCenter(dx2) = getVCenter(dx1); + } + } +} + +template +inline unsigned int AttachProjectiveConstraint::DerivConstrainedSize(bool freeRotations) +{ + if (std::is_same::value || std::is_same::value) { + if (freeRotations) + return Deriv::spatial_dimensions; + else + return Deriv::total_size; + } + else { + SOFA_UNUSED(freeRotations); + return Deriv::size(); + } +} + +// Could be simplified with default values for mm1 and mm2, but that way we are assured that either both or neither of mm1/mm2 are set. +template +AttachProjectiveConstraint::AttachProjectiveConstraint() + : AttachProjectiveConstraint::AttachProjectiveConstraint(nullptr, nullptr) +{ +} + +template +AttachProjectiveConstraint::AttachProjectiveConstraint(core::behavior::MechanicalState *mm1, core::behavior::MechanicalState *mm2) + : core::behavior::PairInteractionProjectiveConstraintSet(mm1,mm2) + , f_indices1( initData(&f_indices1,"indices1","Indices of the source points on the first model") ) + , f_indices2( initData(&f_indices2,"indices2","Indices of the fixed points on the second model") ) + , f_twoWay( initData(&f_twoWay,false,"twoWay", "true if forces should be projected back from model2 to model1") ) + , f_freeRotations( initData(&f_freeRotations,false,"freeRotations", "true to keep rotations free (only used for Rigid DOFs)") ) + , f_lastFreeRotation( initData(&f_lastFreeRotation,false,"lastFreeRotation", "true to keep rotation of the last attached point free (only used for Rigid DOFs)") ) + , f_restRotations( initData(&f_restRotations,false,"restRotations", "true to use rest rotations local offsets (only used for Rigid DOFs)") ) + , f_lastPos( initData(&f_lastPos,"lastPos", "position at which the attach constraint should become inactive") ) + , f_lastDir( initData(&f_lastDir,"lastDir", "direction from lastPos at which the attach coustraint should become inactive") ) + , f_clamp( initData(&f_clamp, false,"clamp", "true to clamp particles at lastPos instead of freeing them.") ) + , f_minDistance( initData(&f_minDistance, static_cast(-1),"minDistance", "the constraint become inactive if the distance between the points attached is bigger than minDistance.") ) + , d_positionFactor(initData(&d_positionFactor, static_cast(1.0), "positionFactor", "IN: Factor applied to projection of position")) + , d_velocityFactor(initData(&d_velocityFactor, static_cast(1.0), "velocityFactor", "IN: Factor applied to projection of velocity")) + , d_responseFactor(initData(&d_responseFactor, static_cast(1.0), "responseFactor", "IN: Factor applied to projection of force/acceleration")) + , d_constraintFactor( initData(&d_constraintFactor,"constraintFactor","Constraint factor per pair of points constrained. 0 -> the constraint is released. 1 -> the constraint is fully constrained") ) +{ + +} + +template +AttachProjectiveConstraint::~AttachProjectiveConstraint() +{ +} + +template +void AttachProjectiveConstraint::init() +{ + this->core::behavior::PairInteractionProjectiveConstraintSet::init(); + reinit(); +} + +template +void AttachProjectiveConstraint::reinit() +{ + // Check coherency of size between indices vectors 1 and 2 + if(f_indices1.getValue().size() != f_indices2.getValue().size()) + { + msg_warning() << "Size mismatch between indices1 and indices2 (" + << f_indices1.getValue().size() << " != " << f_indices2.getValue().size() << ")."; + } + + // Set to the correct length if dynamic, else check coherency. + if(d_constraintFactor.getValue().size()) + { + helper::ReadAccessor>> constraintFactor = d_constraintFactor; + if(constraintFactor.size() != f_indices2.getValue().size()) + { + msg_warning() << "Size of vector constraintFactor, do not fit number of indices attached (" << constraintFactor.size() << " != " << f_indices2.getValue().size() << ")."; + } + else + { + for (unsigned int j=0; j 1.0) || (constraintFactor[j] < 0.0)) + { + msg_warning() << "Value of vector constraintFactor at indice "< 1.0e-10) { + lastDist.resize(f_indices2.getValue().size()); + } + + if (f_restRotations.getValue()) + calcRestRotations(); + this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid); +} + +template +void AttachProjectiveConstraint::reinitIfChanged() { + if((f_indices1.getParent() || f_indices2.getParent()) && constraintReleased.size() != f_indices2.getValue().size()) + { + reinit(); + } +} + +template +void AttachProjectiveConstraint::calcRestRotations() +{ +} + +template <> +void AttachProjectiveConstraint::calcRestRotations(); + +template +void AttachProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, core::MultiMatrixDerivId cId) +{ + SOFA_UNUSED(mparams); + SOFA_UNUSED(cId); +} + +template +void AttachProjectiveConstraint::projectPosition(const core::MechanicalParams * mparams, DataVecCoord& res1_d, DataVecCoord& res2_d) +{ + SOFA_UNUSED(mparams); + const SetIndexArray & indices1 = f_indices1.getValue(); + const SetIndexArray & indices2 = f_indices2.getValue(); + const bool freeRotations = f_freeRotations.getValue(); + const bool lastFreeRotation = f_lastFreeRotation.getValue(); + const bool last = (f_lastDir.isSet() && f_lastDir.getValue().norm() > 1.0e-10); + const bool clamp = f_clamp.getValue(); + + VecCoord &res1 = *res1_d.beginEdit(); + VecCoord &res2 = *res2_d.beginEdit(); + + // update active flags + reinitIfChanged(); + + for (unsigned int i=0; i p3d; + DataTypes::get(p3d[0],p3d[1],p3d[2],p); + lastDist[i] = (Real)( (p3d-f_lastPos.getValue())*f_lastDir.getValue()); + if (lastDist[i] > 0.0) + { + if (clamp) + { + msg_info_when(activeFlags[i]) << "AttachProjectiveConstraint: point " + <> positionFactor = d_positionFactor; + for (unsigned int i=0; i=activeFlags.size() || !activeFlags[i+1])), i, positionFactor); + } + else if (clamp) + { + DataTypes::set(p,f_lastPos.getValue()[0],f_lastPos.getValue()[1],f_lastPos.getValue()[2]); + + msg_info() << "AttachProjectiveConstraint: x2["< +void AttachProjectiveConstraint::projectVelocity(const core::MechanicalParams * mparams, DataVecDeriv& res1_d, DataVecDeriv& res2_d) +{ + SOFA_UNUSED(mparams); + VecDeriv &res1 = *res1_d.beginEdit(); + VecDeriv &res2 = *res2_d.beginEdit(); + + const SetIndexArray & indices1 = f_indices1.getValue(); + const SetIndexArray & indices2 = f_indices2.getValue(); + const bool freeRotations = f_freeRotations.getValue(); + const bool lastFreeRotation = f_lastFreeRotation.getValue(); + const bool clamp = f_clamp.getValue(); + + reinitIfChanged(); + helper::ReadAccessor> velocityFactor = d_velocityFactor; + for (unsigned int i=0; i=activeFlags.size() || !activeFlags[i+1])), i, velocityFactor); + } + else if (clamp) + { + msg_info() << "AttachProjectiveConstraint: v2["< +void AttachProjectiveConstraint::projectResponse(const core::MechanicalParams * mparams, DataVecDeriv& res1_d, DataVecDeriv& res2_d) +{ + SOFA_UNUSED(mparams); + VecDeriv &res1 = *res1_d.beginEdit(); + VecDeriv &res2 = *res2_d.beginEdit(); + + const SetIndexArray & indices1 = f_indices1.getValue(); + const SetIndexArray & indices2 = f_indices2.getValue(); + const bool twoway = f_twoWay.getValue(); + const bool freeRotations = f_freeRotations.getValue(); + const bool lastFreeRotation = f_lastFreeRotation.getValue(); + const bool clamp = f_clamp.getValue(); + + reinitIfChanged(); + helper::ReadAccessor> responseFactor = d_responseFactor; + for (unsigned int i=0; i=activeFlags.size() || !activeFlags[i+1])), twoway, i, responseFactor); + + msg_info() << " final r2["< +void AttachProjectiveConstraint::applyConstraint(const core::MechanicalParams * mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if (f_twoWay.getValue()) + return; + + const sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate2); + if (!r) + return; + + sofa::linearalgebra::BaseMatrix *mat = r.matrix; + const unsigned int offset = r.offset; + + const SetIndexArray & indices = f_indices2.getValue(); + const unsigned int N = Deriv::size(); + const unsigned int NC = DerivConstrainedSize(f_freeRotations.getValue()); + const unsigned int NCLast = DerivConstrainedSize(f_lastFreeRotation.getValue()); + unsigned int i=0; + const bool clamp = f_clamp.getValue(); + + reinitIfChanged(); + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it, ++i) + { + if (!clamp && i < activeFlags.size() && !activeFlags[i]) + continue; + + msg_info() << "AttachProjectiveConstraint: apply in matrix column/row "<<(*it); + + if (NCLast != NC && (i>=activeFlags.size() || !activeFlags[i+1])) + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(offset + N * (*it) + c); + // Set Fixed Vertex + for (unsigned int c=0; cset(offset + N * (*it) + c, offset + N * (*it) + c, 1.0); + } + else + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(offset + N * (*it) + c); + // Set Fixed Vertex + for (unsigned int c=0; cset(offset + N * (*it) + c, offset + N * (*it) + c, 1.0); + } + } +} + + +template +void AttachProjectiveConstraint::applyConstraint(const core::MechanicalParams * mparams, linearalgebra::BaseVector* vect, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if (f_twoWay.getValue()) + return; + + const int o = matrix->getGlobalOffset(this->mstate2); + if (o < 0) + return; + + unsigned int offset = (unsigned int)o; + + msg_info() << "applyConstraint in Vector with offset = " << offset ; + + const SetIndexArray & indices = f_indices2.getValue(); + const unsigned int N = Deriv::size(); + const unsigned int NC = DerivConstrainedSize(f_freeRotations.getValue()); + const unsigned int NCLast = DerivConstrainedSize(f_lastFreeRotation.getValue()); + unsigned int i = 0; + const bool clamp = f_clamp.getValue(); + + reinitIfChanged(); + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it, ++i) + { + if (!clamp && i < activeFlags.size() && !activeFlags[i]) + continue; + + if (NCLast != NC && (i>=activeFlags.size() || !activeFlags[i+1])) + { + for (unsigned int c=0; cclear(offset + N * (*it) + c); + } + else + { + for (unsigned int c=0; cclear(offset + N * (*it) + c); + } + } +} + +template +const typename DataTypes::Real AttachProjectiveConstraint::getConstraintFactor(const int index) { + return d_constraintFactor.getValue().size() ? d_constraintFactor.getValue()[index] : 1; +} + +template +void AttachProjectiveConstraint::doProjectPosition(Coord& x1, Coord& x2, bool freeRotations, unsigned index, Real positionFactor) +{ + SOFA_UNUSED(freeRotations); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (f_minDistance.getValue() != -1 && + (x2 - x1).norm() > f_minDistance.getValue()) + { + constraintReleased[index] = true; + return; + } + constraintReleased[index] = false; + + Deriv corr = (x2-x1)*(0.5*positionFactor*getConstraintFactor(index)); + + x1 += corr; + x2 -= corr; +} + +template +void AttachProjectiveConstraint::doProjectVelocity(Deriv &x1, Deriv &x2, bool freeRotations, unsigned index, Real velocityFactor) +{ + SOFA_UNUSED(freeRotations); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (constraintReleased[index]) return; + + Deriv corr = (x2-x1)*(0.5*velocityFactor*getConstraintFactor(index)); + + x1 += corr; + x2 -= corr; +} + +template +void AttachProjectiveConstraint::doProjectResponse(Deriv& dx1, Deriv& dx2, bool freeRotations, bool twoway, unsigned index, Real responseFactor) +{ + SOFA_UNUSED(freeRotations); + // do nothing if distance between x2 & x1 is bigger than f_minDistance + if (constraintReleased[index]) return; + + if (!twoway) + { + dx2 = Deriv(); + } + else + { + Deriv corr = (dx2-dx1)*0.5*responseFactor*getConstraintFactor(index); + dx1 += corr; + dx2 -= corr; + } +} + + +template +void AttachProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) + return; + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + vparams->drawTool()->disableLighting(); + + const SetIndexArray & indices1 = f_indices1.getValue(); + const SetIndexArray & indices2 = f_indices2.getValue(); + const VecCoord& x1 = this->mstate1->read(core::ConstVecCoordId::position())->getValue(); + const VecCoord& x2 = this->mstate2->read(core::ConstVecCoordId::position())->getValue(); + + constexpr sofa::type::RGBAColor color1(1,0.5,0.5,1); + std::vector vertices; + + for (unsigned int i=0; i i && !activeFlags[i]) + continue; + vertices.push_back(sofa::type::Vec3(x2[indices2[i]][0],x2[indices2[i]][1],x2[indices2[i]][2])); + } + vparams->drawTool()->drawPoints(vertices,10,color1); + vertices.clear(); + + constexpr sofa::type::RGBAColor color2(1,0.5,0.5,1); + for (unsigned int i=0; i i && !activeFlags[i]) + continue; + vertices.push_back(sofa::type::Vec3(x1[indices1[i]][0],x1[indices1[i]][1],x1[indices1[i]][2])); + vertices.push_back(sofa::type::Vec3(x2[indices2[i]][0],x2[indices2[i]][1],x2[indices2[i]][2])); + } + vparams->drawTool()->drawLines(vertices,1,color2); + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h index 7c83fb40cb8..a12a7207113 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h @@ -20,119 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class FixedConstraintInternalData -{ - -}; - - -/** Maintain a constant velocity. - * If the particle is initially fixed then it is attached to its initial position. - * Otherwise it keeps on drifting. - * For maintaining particles fixed in any case, @sa ProjectToPointConstraint -*/ -template -class FixedConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(FixedConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - typedef sofa::core::topology::Point Point; - - SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vec3, sofa::type::Vec3); -protected: - FixedConstraint(); - - virtual ~FixedConstraint(); - -public: - SetIndex d_indices; - Data d_fixAll; ///< filter all the DOF to implement a fixed object - Data d_showObject; ///< draw or not the fixed constraints - Data d_drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres - Data d_projectVelocity; ///< activate project velocity to set velocity to zero - - /// 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: - FixedConstraintInternalData* data; - friend class FixedConstraintInternalData; - - -public: - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - // -- Constraint interface - void init() override; - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vect, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - /** Project the given matrix (Experimental API). - See doc in base parent class - */ - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; - - void draw(const core::visual::VisualParams* vparams) override; - - bool fixAllDOFs() const { return d_fixAll.getValue(); } - -protected : - /// Function check values of given indices - void checkIndices(); - -}; - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl index 23fcc61269d..5b537294c99 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl @@ -21,406 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include +#include -using sofa::core::objectmodel::ComponentState; - - -namespace sofa::component::constraint::projective -{ - -template -FixedConstraint::FixedConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , d_indices( initData(&d_indices,"indices","Indices of the fixed points") ) - , d_fixAll( initData(&d_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) - , d_showObject(initData(&d_showObject,true,"showObject","draw or not the fixed constraints")) - , d_drawSize( initData(&d_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) - , d_projectVelocity( initData(&d_projectVelocity,false,"activate_projectVelocity","activate project velocity to set velocity") ) - , l_topology(initLink("topology", "link to the topology container")) - , data(new FixedConstraintInternalData()) -{ - // default to indice 0 - d_indices.beginEdit()->push_back(0); - d_indices.endEdit(); - - this->addUpdateCallback("updateIndices", { &d_indices}, [this](const core::DataTracker& t) - { - SOFA_UNUSED(t); - checkIndices(); - return sofa::core::objectmodel::ComponentState::Valid; - }, {}); -} - - -template -FixedConstraint::~FixedConstraint() -{ - delete data; -} - -template -void FixedConstraint::clearConstraints() -{ - d_indices.beginEdit()->clear(); - d_indices.endEdit(); -} - -template -void FixedConstraint::addConstraint(Index index) -{ - d_indices.beginEdit()->push_back(index); - d_indices.endEdit(); -} - -template -void FixedConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*d_indices.beginEdit(),index); - d_indices.endEdit(); -} - -// -- Constraint interface - - -template -void FixedConstraint::init() -{ - this->d_componentState.setValue(ComponentState::Invalid); - this->core::behavior::ProjectiveConstraintSet::init(); - - if (!this->mstate.get()) - { - msg_warning() << "Missing mstate, cannot initialize the component."; - 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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - d_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "Can not find the topology, won't be able to handle topological changes"; - } - - this->checkIndices(); - this->d_componentState.setValue(ComponentState::Valid); -} - -template -void FixedConstraint::reinit() -{ - this->checkIndices(); -} - -template -void FixedConstraint::checkIndices() -{ - // Check value of given indices - Index maxIndex=this->mstate->getSize(); - - const SetIndexArray & indices = d_indices.getValue(); - SetIndexArray invalidIndices; - for (unsigned int i=0; i= maxIndex) - { - msg_warning() << "Index " << index << " not valid, should be [0,"<< maxIndex <<"]. Constraint will be removed."; - invalidIndices.push_back(index); - } - } - - // if invalid indices, sort them and remove in decreasing order as removeConstraint perform a swap and pop_back. - if (!invalidIndices.empty()) - { - std::sort( invalidIndices.begin(), invalidIndices.end(), std::greater() ); - const int max = invalidIndices.size()-1; - for (int i=max; i>= 0; i--) - { - removeConstraint(invalidIndices[i]); - } - } -} - -template -void FixedConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - static const unsigned blockSize = DataTypes::deriv_total_size; - - if( d_fixAll.getValue() ) - { - const unsigned size = this->mstate->getSize(); - for( unsigned i=0; iclearRowsCols( offset + i * blockSize, offset + (i+1) * (blockSize) ); - } - } - else - { - // clears the rows and columns associated with fixed particles - for (const auto id : d_indices.getValue()) - { - M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); - } - } -} - - -template -void FixedConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res (resData ); - const SetIndexArray & indices = d_indices.getValue(); - - if( d_fixAll.getValue() ) - { - // fix everything - typename VecDeriv::iterator it; - for( it = res.begin(); it != res.end(); ++it ) - { - *it = Deriv(); - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - res[*it] = Deriv(); - } - } -} - -template -void FixedConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor c (cData ); - - if( d_fixAll.getValue() ) - { - // fix everything - c->clear(); - } - else - { - const SetIndexArray& indices = d_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - c->clearColBlock(*it); - } - } -} - -// projectVelocity applies the same changes on velocity vector as projectResponse on position vector : -// Each fixed point received a null velocity vector. -// When a new fixed point is added while its velocity vector is already null, projectVelocity is not usefull. -// But when a new fixed point is added while its velocity vector is not null, it's necessary to fix it to null or -// to set the projectVelocity option to True. If not, the fixed point is going to drift. -template -void FixedConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - SOFA_UNUSED(mparams); - - if(!d_projectVelocity.getValue()) return; - - helper::WriteAccessor res (vData ); - - if ( d_fixAll.getValue() ) // fix everyting - { - for(Size i=0; id_indices.getValue(); - for(Index ind : indices) - { - res[ind] = Deriv(); - } - } -} - - -template -void FixedConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& /*xData*/) -{ - -} - -// Matrix Integration interface -template -void FixedConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) - { - const unsigned int N = Deriv::size(); - - if( d_fixAll.getValue() ) - { - const unsigned size = this->mstate->getSize(); - for(unsigned int i=0; iclearRowCol(r.offset + N * i + c); - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * i + c, r.offset + N * i + c, 1.0); - } - } - else - { - const SetIndexArray & indices = d_indices.getValue(); - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); - } - } - } -} - -template -void FixedConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vect, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const int o = matrix->getGlobalOffset(this->mstate.get()); - if (o >= 0) - { - const unsigned int offset = (unsigned int)o; - const unsigned int N = Deriv::size(); - - if( d_fixAll.getValue() ) - { - for(sofa::Size i=0; i < (sofa::Size) vect->size(); i++ ) - { - for (unsigned int c=0; cclear(offset + N * i + c); - } - } - else - { - const SetIndexArray & indices = d_indices.getValue(); - for (const auto & index : indices) - { - for (unsigned int c=0; cclear(offset + N * index + c); - } - } - } -} - -template -void FixedConstraint::applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) -{ - static constexpr unsigned int N = Deriv::size(); - - if( d_fixAll.getValue() ) - { - const sofa::Size size = this->mstate->getMatrixSize(); - for(sofa::Index i = 0; i < size; ++i) - { - matrix->discardRowCol(i, i); - } - } - else - { - const SetIndexArray & indices = d_indices.getValue(); - - for (const auto index : indices) - { - for (unsigned int c = 0; c < N; ++c) - { - matrix->discardRowCol(N * index + c, N * index + c); - } - } - } -} - -template -void FixedConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (this->d_componentState.getValue() != ComponentState::Valid) return; - if (!vparams->displayFlags().getShowBehaviorModels()) return; - if (!d_showObject.getValue()) return; - if (!this->isActive()) return; - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - const SetIndexArray & indices = d_indices.getValue(); - - if( d_drawSize.getValue() == 0) // old classical drawing by points - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - - if (d_fixAll.getValue()) - { - for (unsigned i = 0; i < x.size(); i++) - { - point = DataTypes::getCPos(x[i]); - points.push_back(point); - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - point = DataTypes::getCPos(x[*it]); - points.push_back(point); - } - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); - } - else // new drawing by spheres - { - vparams->drawTool()->setLightingEnabled(true); - - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - if( d_fixAll.getValue()==true ) - for (unsigned i=0; idrawTool()->drawSpheres(points, (float)d_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); - } - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h index d6b7e177dd0..45b6a9c8d49 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h @@ -20,117 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include +#include -#include -#include -#include -#include - -namespace sofa::component::constraint::projective -{ - -using sofa::linearalgebra::BaseVector; -using sofa::core::MechanicalParams; -using sofa::core::visual::VisualParams; -using sofa::core::topology::BaseMeshTopology; -using sofa::core::behavior::MultiMatrixAccessor; -using sofa::core::behavior::ProjectiveConstraintSet; - -/// This class can be overriden if needed for additionnal storage within template specilizations. -template -class FixedPlaneConstraintInternalData -{ -}; - -template -class FixedPlaneConstraint : public ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(FixedPlaneConstraint,DataTypes), - SOFA_TEMPLATE(ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename Coord::value_type Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef core::topology::TopologySubsetIndices SetIndex; -public: - Data d_direction; ///< direction on which the constraint applied - Data d_dmin; ///< coordinates min of the plane for the vertex selection - Data d_dmax; ///< coordinates max of the plane for the vertex selection - SetIndex d_indices; ///< the set of vertex indices - - /// 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; - - - /// inherited from the BaseObject interface - void init() override; - void draw(const VisualParams* vparams) override; - - /// -- Constraint interface - void projectResponse(const MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const MechanicalParams* mparams, DataVecCoord& xData) override; - - /// Implement projectMatrix for assembled solver of compliant - void projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset) override; - void projectJacobianMatrix(const MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - /// Implement applyConstraint for direct solvers - void applyConstraint(const MechanicalParams* mparams, - const MultiMatrixAccessor* matrix) override; - - void applyConstraint(const MechanicalParams* mparams, BaseVector* vect, - const MultiMatrixAccessor* matrix) override; - - void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; - - void setDirection (Coord dir); - void selectVerticesAlongPlane(); - void setDminAndDmax(const Real _dmin,const Real _dmax); - - void addConstraint(Index index); - void removeConstraint(Index index); - -protected: - FixedPlaneConstraint(); - ~FixedPlaneConstraint(); - - FixedPlaneConstraintInternalData data; - friend class FixedPlaneConstraintInternalData; - - /// whether vertices should be selected from 2 parallel planes - bool m_selectVerticesFromPlanes {false}; - - ////////////////////////// Inherited attributes //////////////////////////// - /// https://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html - /// Bring inherited attributes and function in the current lookup context. - /// otherwise any access to the base::attribute would require - /// the "this->" approach. - using ProjectiveConstraintSet::mstate; - using ProjectiveConstraintSet::getContext; - - bool isPointInPlane(const Coord& p) const ; -}; - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDPLANECONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl index 9c8dad30165..aee6c46621b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl @@ -21,297 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -using sofa::helper::WriteAccessor; -using sofa::type::Vec; - -/////////////////////////// DEFINITION OF FixedPlaneConstraint ///////////////////////////////////// -template -FixedPlaneConstraint::FixedPlaneConstraint() - : d_direction( initData(&d_direction,"direction","normal direction of the plane")) - , d_dmin( initData(&d_dmin,(Real)0,"dmin","Minimum plane distance from the origin")) - , d_dmax( initData(&d_dmax,(Real)0,"dmax","Maximum plane distance from the origin") ) - , d_indices( initData(&d_indices,"indices","Indices of the fixed points")) - , l_topology(initLink("topology", "link to the topology container")) -{ - m_selectVerticesFromPlanes=false; -} - -template -FixedPlaneConstraint::~FixedPlaneConstraint() -{ - -} - -/// Matrix Integration interface -template -void FixedPlaneConstraint::applyConstraint(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if(const MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(mstate.get())) - { - /// Implement plane constraint only when the direction is along the coordinates directions - // TODO : generalize projection to any direction - - const unsigned int N = Deriv::size(); - Coord dir=d_direction.getValue(); - for (auto& index : d_indices.getValue()) - { - /// Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(r.offset + N * index + c); - /// Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * index + c, r.offset + N * index + c, 1.0); - } - } -} - -template -void FixedPlaneConstraint::applyConstraint(const MechanicalParams* mparams, - BaseVector* vect, - const MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const int o = matrix->getGlobalOffset(mstate.get()); - if (o >= 0) - { - const unsigned int offset = (unsigned int)o; - /// Implement plane constraint only when the direction is along the coordinates directions - // TODO : generalize projection to any direction - Coord dir=d_direction.getValue(); - - const unsigned int N = Deriv::size(); - - for (auto& index : d_indices.getValue()) - { - for (unsigned int c=0; cclear(offset + N * index + c); - } - } -} - -template -void FixedPlaneConstraint::applyConstraint( - sofa::core::behavior::ZeroDirichletCondition* matrix) -{ - static constexpr unsigned int N = Deriv::size(); - const Coord dir = d_direction.getValue(); - for (auto& index : d_indices.getValue()) - { - for (unsigned int c=0; cdiscardRowCol(N * index + c, N * index + c); - } - } - } -} - -template -void FixedPlaneConstraint::addConstraint(Index index) -{ - d_indices.beginEdit()->push_back(index); - d_indices.endEdit(); -} - -template -void FixedPlaneConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*d_indices.beginEdit(),(unsigned int)index); - d_indices.endEdit(); -} - - -/// This function are there to provide kind of type translation to the vector one so we can -/// implement the algorithm as is the different objects where of similar type. -/// this solution is not really satisfactory but for the moment it does the job. -/// A better solution would that all the used types are following the same interface which -/// requires to touch core sofa classes. -sofa::type::Vec3d& getVec(sofa::defaulttype::Rigid3dTypes::Deriv& i) { return i.getVCenter(); } -sofa::type::Vec3d& getVec(sofa::defaulttype::Rigid3dTypes::Coord& i) { return i.getCenter(); } -const sofa::type::Vec3d& getVec(const sofa::defaulttype::Rigid3dTypes::Deriv& i) { return i.getVCenter(); } -const sofa::type::Vec3d& getVec(const sofa::defaulttype::Rigid3dTypes::Coord& i) { return i.getCenter(); } -sofa::type::Vec3d& getVec(sofa::defaulttype::Vec3dTypes::Deriv& i) { return i; } -const sofa::type::Vec3d& getVec(const sofa::defaulttype::Vec3dTypes::Deriv& i) { return i; } -sofa::type::Vec6d& getVec(sofa::defaulttype::Vec6dTypes::Deriv& i) { return i; } -const sofa::type::Vec6d& getVec(const sofa::defaulttype::Vec6dTypes::Deriv& i) { return i; } - -sofa::type::Vec3f& getVec(sofa::defaulttype::Rigid3fTypes::Deriv& i) { return i.getVCenter(); } -sofa::type::Vec3f& getVec(sofa::defaulttype::Rigid3fTypes::Coord& i) { return i.getCenter(); } -const sofa::type::Vec3f& getVec(const sofa::defaulttype::Rigid3fTypes::Deriv& i) { return i.getVCenter(); } -const sofa::type::Vec3f& getVec(const sofa::defaulttype::Rigid3fTypes::Coord& i) { return i.getCenter(); } -sofa::type::Vec3f& getVec(sofa::defaulttype::Vec3fTypes::Deriv& i) { return i; } -const sofa::type::Vec3f& getVec(const sofa::defaulttype::Vec3fTypes::Deriv& i) { return i; } -sofa::type::Vec6f& getVec(sofa::defaulttype::Vec6fTypes::Deriv& i) { return i; } -const sofa::type::Vec6f& getVec(const sofa::defaulttype::Vec6fTypes::Deriv& i) { return i; } - -template -void FixedPlaneConstraint::projectResponse(const MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - WriteAccessor res = resData; - - const auto& indices = d_indices.getValue(); - const auto& dir = getVec(d_direction.getValue()); - auto& dx = res.wref(); - for (const auto& i : indices) - { - /// only constraint one projection of the displacement to be zero - auto val = getVec(dx[i]); - val = val - (dir * dot(val, dir)); - DataTypes::setDPos(dx[i], val); - } -} - -/// project dx to constrained space (dx models a velocity) -template -void FixedPlaneConstraint::projectVelocity(const MechanicalParams* /*mparams*/, DataVecDeriv& /*vData*/) -{ - -} - -/// project x to constrained space (x models a position) -template -void FixedPlaneConstraint::projectPosition(const MechanicalParams* /*mparams*/, DataVecCoord& /*xData*/) -{ - -} - -template -void FixedPlaneConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned /*offset*/ ) -{ - /// clears the rows and columns associated with constrained particles - const unsigned blockSize = DataTypes::deriv_total_size; - - for(auto& index : d_indices.getValue()) - { - M->clearRowsCols((index) * blockSize,(index+1) * (blockSize) ); - } -} - -template -void FixedPlaneConstraint::projectJacobianMatrix(const MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - WriteAccessor c = cData; - - const auto& indices = d_indices.getValue(); - const auto& dir = getVec(d_direction.getValue()); - auto& dx = c.wref(); - - auto itRow = dx.begin(); - auto itRowEnd = dx.end(); - while (itRow != itRowEnd) - { - for (auto colIt = itRow.begin(); colIt != itRow.end(); colIt++) - { - if (std::find(indices.begin(), indices.end(), colIt.index()) != indices.end()) - { - auto val = getVec(colIt.val()); - Deriv r(type::NOINIT); - DataTypes::setDPos(r, -(dir * dot(val, dir))); - dx.writeLine(itRow.index()).addCol(colIt.index(), r); - } - } - } -} - -template -void FixedPlaneConstraint::setDirection(Coord dir) -{ - if (dir.norm2()>0) - { - d_direction.setValue(dir); - } -} - -template -void FixedPlaneConstraint::selectVerticesAlongPlane() -{ - const VecCoord& x = mstate->read(core::ConstVecCoordId::position())->getValue(); - for(unsigned int i=0; i -void FixedPlaneConstraint::init() -{ - ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - d_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - /// test that dmin or dmax are different from zero - if (d_dmin.getValue()!=d_dmax.getValue()) - m_selectVerticesFromPlanes=true; - - if (m_selectVerticesFromPlanes) - selectVerticesAlongPlane(); -} - -template -void FixedPlaneConstraint::setDminAndDmax(const Real _dmin,const Real _dmax) -{ - d_dmin=_dmin; - d_dmax=_dmax; - m_selectVerticesFromPlanes=true; -} - -template -void FixedPlaneConstraint::draw(const VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) return; - const VecCoord& x = mstate->read(core::ConstVecCoordId::position())->getValue(); - vparams->drawTool()->disableLighting(); - - type::vector points; - for(auto& index : d_indices.getValue()) - { - points.push_back({x[index][0], x[index][1], x[index][2]}); - } - - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor{1,1.0,0.5,1}); -} - -template -bool FixedPlaneConstraint::isPointInPlane(const Coord& p) const -{ - const Real d = getVec(p) * getVec(d_direction.getValue()); - return d > d_dmin.getValue() && d < d_dmax.getValue(); -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp similarity index 78% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp index 725d791f612..ab9c9e49cc6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDPLANECONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDPLANEPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -32,15 +32,15 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int FixedPlaneConstraintClass = core::RegisterObject("Project particles on a given plane") - .add< FixedPlaneConstraint >() - .add< FixedPlaneConstraint >() - .add< FixedPlaneConstraint >() +int FixedPlaneProjectiveConstraintClass = core::RegisterObject("Project particles on a given plane") + .add< FixedPlaneProjectiveConstraint >() + .add< FixedPlaneProjectiveConstraint >() + .add< FixedPlaneProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h new file mode 100644 index 00000000000..f86187d7549 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h @@ -0,0 +1,140 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +using sofa::linearalgebra::BaseVector; +using sofa::core::MechanicalParams; +using sofa::core::visual::VisualParams; +using sofa::core::topology::BaseMeshTopology; +using sofa::core::behavior::MultiMatrixAccessor; +using sofa::core::behavior::ProjectiveConstraintSet; + +/// This class can be overriden if needed for additionnal storage within template specilizations. +template +class FixedPlaneProjectiveConstraintInternalData +{ +}; + +template +class FixedPlaneProjectiveConstraint : public ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(FixedPlaneProjectiveConstraint,DataTypes), + SOFA_TEMPLATE(ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename Coord::value_type Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef core::topology::TopologySubsetIndices SetIndex; +public: + Data d_direction; ///< direction on which the constraint applied + Data d_dmin; ///< coordinates min of the plane for the vertex selection + Data d_dmax; ///< coordinates max of the plane for the vertex selection + SetIndex d_indices; ///< the set of vertex indices + + /// 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; + + + /// inherited from the BaseObject interface + void init() override; + void draw(const VisualParams* vparams) override; + + /// -- Constraint interface + void projectResponse(const MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const MechanicalParams* mparams, DataVecCoord& xData) override; + + /// Implement projectMatrix for assembled solver of compliant + void projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset) override; + void projectJacobianMatrix(const MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + /// Implement applyConstraint for direct solvers + void applyConstraint(const MechanicalParams* mparams, + const MultiMatrixAccessor* matrix) override; + + void applyConstraint(const MechanicalParams* mparams, BaseVector* vect, + const MultiMatrixAccessor* matrix) override; + + void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; + + void setDirection (Coord dir); + void selectVerticesAlongPlane(); + void setDminAndDmax(const Real _dmin,const Real _dmax); + + void addConstraint(Index index); + void removeConstraint(Index index); + +protected: + FixedPlaneProjectiveConstraint(); + ~FixedPlaneProjectiveConstraint(); + + FixedPlaneProjectiveConstraintInternalData data; + friend class FixedPlaneProjectiveConstraintInternalData; + + /// whether vertices should be selected from 2 parallel planes + bool m_selectVerticesFromPlanes {false}; + + ////////////////////////// Inherited attributes //////////////////////////// + /// https://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html + /// Bring inherited attributes and function in the current lookup context. + /// otherwise any access to the base::attribute would require + /// the "this->" approach. + using ProjectiveConstraintSet::mstate; + using ProjectiveConstraintSet::getContext; + + bool isPointInPlane(const Coord& p) const ; +}; + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDPLANEPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; + +#endif + +template +using FixedPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedPlaneConstraint has been renamed to FixedPlaneProjectiveConstraint") = FixedPlaneProjectiveConstraint; + + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl new file mode 100644 index 00000000000..49b29b03583 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl @@ -0,0 +1,317 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +using sofa::helper::WriteAccessor; +using sofa::type::Vec; + +/////////////////////////// DEFINITION OF FixedPlaneProjectiveConstraint ///////////////////////////////////// +template +FixedPlaneProjectiveConstraint::FixedPlaneProjectiveConstraint() + : d_direction( initData(&d_direction,"direction","normal direction of the plane")) + , d_dmin( initData(&d_dmin,(Real)0,"dmin","Minimum plane distance from the origin")) + , d_dmax( initData(&d_dmax,(Real)0,"dmax","Maximum plane distance from the origin") ) + , d_indices( initData(&d_indices,"indices","Indices of the fixed points")) + , l_topology(initLink("topology", "link to the topology container")) +{ + m_selectVerticesFromPlanes=false; +} + +template +FixedPlaneProjectiveConstraint::~FixedPlaneProjectiveConstraint() +{ + +} + +/// Matrix Integration interface +template +void FixedPlaneProjectiveConstraint::applyConstraint(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if(const MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(mstate.get())) + { + /// Implement plane constraint only when the direction is along the coordinates directions + // TODO : generalize projection to any direction + + const unsigned int N = Deriv::size(); + Coord dir=d_direction.getValue(); + for (auto& index : d_indices.getValue()) + { + /// Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(r.offset + N * index + c); + /// Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * index + c, r.offset + N * index + c, 1.0); + } + } +} + +template +void FixedPlaneProjectiveConstraint::applyConstraint(const MechanicalParams* mparams, + BaseVector* vect, + const MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const int o = matrix->getGlobalOffset(mstate.get()); + if (o >= 0) + { + const unsigned int offset = (unsigned int)o; + /// Implement plane constraint only when the direction is along the coordinates directions + // TODO : generalize projection to any direction + Coord dir=d_direction.getValue(); + + const unsigned int N = Deriv::size(); + + for (auto& index : d_indices.getValue()) + { + for (unsigned int c=0; cclear(offset + N * index + c); + } + } +} + +template +void FixedPlaneProjectiveConstraint::applyConstraint( + sofa::core::behavior::ZeroDirichletCondition* matrix) +{ + static constexpr unsigned int N = Deriv::size(); + const Coord dir = d_direction.getValue(); + for (auto& index : d_indices.getValue()) + { + for (unsigned int c=0; cdiscardRowCol(N * index + c, N * index + c); + } + } + } +} + +template +void FixedPlaneProjectiveConstraint::addConstraint(Index index) +{ + d_indices.beginEdit()->push_back(index); + d_indices.endEdit(); +} + +template +void FixedPlaneProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*d_indices.beginEdit(),(unsigned int)index); + d_indices.endEdit(); +} + + +/// This function are there to provide kind of type translation to the vector one so we can +/// implement the algorithm as is the different objects where of similar type. +/// this solution is not really satisfactory but for the moment it does the job. +/// A better solution would that all the used types are following the same interface which +/// requires to touch core sofa classes. +sofa::type::Vec3d& getVec(sofa::defaulttype::Rigid3dTypes::Deriv& i) { return i.getVCenter(); } +sofa::type::Vec3d& getVec(sofa::defaulttype::Rigid3dTypes::Coord& i) { return i.getCenter(); } +const sofa::type::Vec3d& getVec(const sofa::defaulttype::Rigid3dTypes::Deriv& i) { return i.getVCenter(); } +const sofa::type::Vec3d& getVec(const sofa::defaulttype::Rigid3dTypes::Coord& i) { return i.getCenter(); } +sofa::type::Vec3d& getVec(sofa::defaulttype::Vec3dTypes::Deriv& i) { return i; } +const sofa::type::Vec3d& getVec(const sofa::defaulttype::Vec3dTypes::Deriv& i) { return i; } +sofa::type::Vec6d& getVec(sofa::defaulttype::Vec6dTypes::Deriv& i) { return i; } +const sofa::type::Vec6d& getVec(const sofa::defaulttype::Vec6dTypes::Deriv& i) { return i; } + +sofa::type::Vec3f& getVec(sofa::defaulttype::Rigid3fTypes::Deriv& i) { return i.getVCenter(); } +sofa::type::Vec3f& getVec(sofa::defaulttype::Rigid3fTypes::Coord& i) { return i.getCenter(); } +const sofa::type::Vec3f& getVec(const sofa::defaulttype::Rigid3fTypes::Deriv& i) { return i.getVCenter(); } +const sofa::type::Vec3f& getVec(const sofa::defaulttype::Rigid3fTypes::Coord& i) { return i.getCenter(); } +sofa::type::Vec3f& getVec(sofa::defaulttype::Vec3fTypes::Deriv& i) { return i; } +const sofa::type::Vec3f& getVec(const sofa::defaulttype::Vec3fTypes::Deriv& i) { return i; } +sofa::type::Vec6f& getVec(sofa::defaulttype::Vec6fTypes::Deriv& i) { return i; } +const sofa::type::Vec6f& getVec(const sofa::defaulttype::Vec6fTypes::Deriv& i) { return i; } + +template +void FixedPlaneProjectiveConstraint::projectResponse(const MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + WriteAccessor res = resData; + + const auto& indices = d_indices.getValue(); + const auto& dir = getVec(d_direction.getValue()); + auto& dx = res.wref(); + for (const auto& i : indices) + { + /// only constraint one projection of the displacement to be zero + auto val = getVec(dx[i]); + val = val - (dir * dot(val, dir)); + DataTypes::setDPos(dx[i], val); + } +} + +/// project dx to constrained space (dx models a velocity) +template +void FixedPlaneProjectiveConstraint::projectVelocity(const MechanicalParams* /*mparams*/, DataVecDeriv& /*vData*/) +{ + +} + +/// project x to constrained space (x models a position) +template +void FixedPlaneProjectiveConstraint::projectPosition(const MechanicalParams* /*mparams*/, DataVecCoord& /*xData*/) +{ + +} + +template +void FixedPlaneProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned /*offset*/ ) +{ + /// clears the rows and columns associated with constrained particles + const unsigned blockSize = DataTypes::deriv_total_size; + + for(auto& index : d_indices.getValue()) + { + M->clearRowsCols((index) * blockSize,(index+1) * (blockSize) ); + } +} + +template +void FixedPlaneProjectiveConstraint::projectJacobianMatrix(const MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + WriteAccessor c = cData; + + const auto& indices = d_indices.getValue(); + const auto& dir = getVec(d_direction.getValue()); + auto& dx = c.wref(); + + auto itRow = dx.begin(); + auto itRowEnd = dx.end(); + while (itRow != itRowEnd) + { + for (auto colIt = itRow.begin(); colIt != itRow.end(); colIt++) + { + if (std::find(indices.begin(), indices.end(), colIt.index()) != indices.end()) + { + auto val = getVec(colIt.val()); + Deriv r(type::NOINIT); + DataTypes::setDPos(r, -(dir * dot(val, dir))); + dx.writeLine(itRow.index()).addCol(colIt.index(), r); + } + } + } +} + +template +void FixedPlaneProjectiveConstraint::setDirection(Coord dir) +{ + if (dir.norm2()>0) + { + d_direction.setValue(dir); + } +} + +template +void FixedPlaneProjectiveConstraint::selectVerticesAlongPlane() +{ + const VecCoord& x = mstate->read(core::ConstVecCoordId::position())->getValue(); + for(unsigned int i=0; i +void FixedPlaneProjectiveConstraint::init() +{ + ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + /// test that dmin or dmax are different from zero + if (d_dmin.getValue()!=d_dmax.getValue()) + m_selectVerticesFromPlanes=true; + + if (m_selectVerticesFromPlanes) + selectVerticesAlongPlane(); +} + +template +void FixedPlaneProjectiveConstraint::setDminAndDmax(const Real _dmin,const Real _dmax) +{ + d_dmin=_dmin; + d_dmax=_dmax; + m_selectVerticesFromPlanes=true; +} + +template +void FixedPlaneProjectiveConstraint::draw(const VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) return; + const VecCoord& x = mstate->read(core::ConstVecCoordId::position())->getValue(); + vparams->drawTool()->disableLighting(); + + type::vector points; + for(auto& index : d_indices.getValue()) + { + points.push_back({x[index][0], x[index][1], x[index][2]}); + } + + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor{1,1.0,0.5,1}); +} + +template +bool FixedPlaneProjectiveConstraint::isPointInPlane(const Coord& p) const +{ + const Real d = getVec(p) * getVec(d_direction.getValue()); + return d > d_dmin.getValue() && d < d_dmax.getValue(); +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp similarity index 73% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp index 42021e2cdbc..97cbfce8ba6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDPROJECTIVECONSTRAINT_CPP +#include #include #include @@ -32,37 +32,37 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int FixedConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< FixedConstraint >() - .add< FixedConstraint >() - .add< FixedConstraint >() - .add< FixedConstraint >() - .add< FixedConstraint >() - .add< FixedConstraint >() +int FixedProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< FixedProjectiveConstraint >() + .add< FixedProjectiveConstraint >() + .add< FixedProjectiveConstraint >() + .add< FixedProjectiveConstraint >() + .add< FixedProjectiveConstraint >() + .add< FixedProjectiveConstraint >() ; // methods specilizations declaration template <> SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API -void FixedConstraint::draw(const core::visual::VisualParams* vparams); +void FixedProjectiveConstraint::draw(const core::visual::VisualParams* vparams); template <> SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API -void FixedConstraint::draw(const core::visual::VisualParams* vparams); +void FixedProjectiveConstraint::draw(const core::visual::VisualParams* vparams); -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; // methods specilizations definition template <> -void FixedConstraint::draw(const core::visual::VisualParams* vparams) +void FixedProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { if (this->d_componentState.getValue() != ComponentState::Valid) return; if (!d_showObject.getValue()) return; @@ -104,7 +104,7 @@ void FixedConstraint::draw(const core::visual::VisualParams* vparam } template <> -void FixedConstraint::draw(const core::visual::VisualParams* vparams) +void FixedProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { if (this->d_componentState.getValue() != ComponentState::Valid) return; if (!d_showObject.getValue()) return; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h new file mode 100644 index 00000000000..81bd14265a7 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h @@ -0,0 +1,142 @@ +/****************************************************************************** +* 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 +#include + +namespace sofa::component::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class FixedProjectiveConstraintInternalData +{ + +}; + + +/** Maintain a constant velocity. + * If the particle is initially fixed then it is attached to its initial position. + * Otherwise it keeps on drifting. + * For maintaining particles fixed in any case, @sa ProjectToPointConstraint +*/ +template +class FixedProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(FixedProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + typedef sofa::core::topology::Point Point; + + SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vec3, sofa::type::Vec3); +protected: + FixedProjectiveConstraint(); + + virtual ~FixedProjectiveConstraint(); + +public: + SetIndex d_indices; + Data d_fixAll; ///< filter all the DOF to implement a fixed object + Data d_showObject; ///< draw or not the fixed constraints + Data d_drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres + Data d_projectVelocity; ///< activate project velocity to set velocity to zero + + /// 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: + FixedProjectiveConstraintInternalData* data; + friend class FixedProjectiveConstraintInternalData; + + +public: + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + // -- Constraint interface + void init() override; + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vect, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + /** Project the given matrix (Experimental API). + See doc in base parent class + */ + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; + + void draw(const core::visual::VisualParams* vparams) override; + + bool fixAllDOFs() const { return d_fixAll.getValue(); } + +protected : + /// Function check values of given indices + void checkIndices(); + +}; + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; + +#endif + +template +using FixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedConstraint has been renamed to FixedProjectiveConstraint") = FixedProjectiveConstraint; + + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl new file mode 100644 index 00000000000..78bd3636d2e --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.inl @@ -0,0 +1,426 @@ +/****************************************************************************** +* 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 + +using sofa::core::objectmodel::ComponentState; + + +namespace sofa::component::constraint::projective +{ + +template +FixedProjectiveConstraint::FixedProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , d_indices( initData(&d_indices,"indices","Indices of the fixed points") ) + , d_fixAll( initData(&d_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) + , d_showObject(initData(&d_showObject,true,"showObject","draw or not the fixed constraints")) + , d_drawSize( initData(&d_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) + , d_projectVelocity( initData(&d_projectVelocity,false,"activate_projectVelocity","activate project velocity to set velocity") ) + , l_topology(initLink("topology", "link to the topology container")) + , data(new FixedProjectiveConstraintInternalData()) +{ + // default to indice 0 + d_indices.beginEdit()->push_back(0); + d_indices.endEdit(); + + this->addUpdateCallback("updateIndices", { &d_indices}, [this](const core::DataTracker& t) + { + SOFA_UNUSED(t); + checkIndices(); + return sofa::core::objectmodel::ComponentState::Valid; + }, {}); +} + + +template +FixedProjectiveConstraint::~FixedProjectiveConstraint() +{ + delete data; +} + +template +void FixedProjectiveConstraint::clearConstraints() +{ + d_indices.beginEdit()->clear(); + d_indices.endEdit(); +} + +template +void FixedProjectiveConstraint::addConstraint(Index index) +{ + d_indices.beginEdit()->push_back(index); + d_indices.endEdit(); +} + +template +void FixedProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*d_indices.beginEdit(),index); + d_indices.endEdit(); +} + +// -- Constraint interface + + +template +void FixedProjectiveConstraint::init() +{ + this->d_componentState.setValue(ComponentState::Invalid); + this->core::behavior::ProjectiveConstraintSet::init(); + + if (!this->mstate.get()) + { + msg_warning() << "Missing mstate, cannot initialize the component."; + 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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "Can not find the topology, won't be able to handle topological changes"; + } + + this->checkIndices(); + this->d_componentState.setValue(ComponentState::Valid); +} + +template +void FixedProjectiveConstraint::reinit() +{ + this->checkIndices(); +} + +template +void FixedProjectiveConstraint::checkIndices() +{ + // Check value of given indices + Index maxIndex=this->mstate->getSize(); + + const SetIndexArray & indices = d_indices.getValue(); + SetIndexArray invalidIndices; + for (unsigned int i=0; i= maxIndex) + { + msg_warning() << "Index " << index << " not valid, should be [0,"<< maxIndex <<"]. Constraint will be removed."; + invalidIndices.push_back(index); + } + } + + // if invalid indices, sort them and remove in decreasing order as removeConstraint perform a swap and pop_back. + if (!invalidIndices.empty()) + { + std::sort( invalidIndices.begin(), invalidIndices.end(), std::greater() ); + const int max = invalidIndices.size()-1; + for (int i=max; i>= 0; i--) + { + removeConstraint(invalidIndices[i]); + } + } +} + +template +void FixedProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + static const unsigned blockSize = DataTypes::deriv_total_size; + + if( d_fixAll.getValue() ) + { + const unsigned size = this->mstate->getSize(); + for( unsigned i=0; iclearRowsCols( offset + i * blockSize, offset + (i+1) * (blockSize) ); + } + } + else + { + // clears the rows and columns associated with fixed particles + for (const auto id : d_indices.getValue()) + { + M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); + } + } +} + + +template +void FixedProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res (resData ); + const SetIndexArray & indices = d_indices.getValue(); + + if( d_fixAll.getValue() ) + { + // fix everything + typename VecDeriv::iterator it; + for( it = res.begin(); it != res.end(); ++it ) + { + *it = Deriv(); + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + res[*it] = Deriv(); + } + } +} + +template +void FixedProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor c (cData ); + + if( d_fixAll.getValue() ) + { + // fix everything + c->clear(); + } + else + { + const SetIndexArray& indices = d_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + c->clearColBlock(*it); + } + } +} + +// projectVelocity applies the same changes on velocity vector as projectResponse on position vector : +// Each fixed point received a null velocity vector. +// When a new fixed point is added while its velocity vector is already null, projectVelocity is not usefull. +// But when a new fixed point is added while its velocity vector is not null, it's necessary to fix it to null or +// to set the projectVelocity option to True. If not, the fixed point is going to drift. +template +void FixedProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + SOFA_UNUSED(mparams); + + if(!d_projectVelocity.getValue()) return; + + helper::WriteAccessor res (vData ); + + if ( d_fixAll.getValue() ) // fix everyting + { + for(Size i=0; id_indices.getValue(); + for(Index ind : indices) + { + res[ind] = Deriv(); + } + } +} + + +template +void FixedProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& /*xData*/) +{ + +} + +// Matrix Integration interface +template +void FixedProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) + { + const unsigned int N = Deriv::size(); + + if( d_fixAll.getValue() ) + { + const unsigned size = this->mstate->getSize(); + for(unsigned int i=0; iclearRowCol(r.offset + N * i + c); + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * i + c, r.offset + N * i + c, 1.0); + } + } + else + { + const SetIndexArray & indices = d_indices.getValue(); + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); + } + } + } +} + +template +void FixedProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vect, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const int o = matrix->getGlobalOffset(this->mstate.get()); + if (o >= 0) + { + const unsigned int offset = (unsigned int)o; + const unsigned int N = Deriv::size(); + + if( d_fixAll.getValue() ) + { + for(sofa::Size i=0; i < (sofa::Size) vect->size(); i++ ) + { + for (unsigned int c=0; cclear(offset + N * i + c); + } + } + else + { + const SetIndexArray & indices = d_indices.getValue(); + for (const auto & index : indices) + { + for (unsigned int c=0; cclear(offset + N * index + c); + } + } + } +} + +template +void FixedProjectiveConstraint::applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) +{ + static constexpr unsigned int N = Deriv::size(); + + if( d_fixAll.getValue() ) + { + const sofa::Size size = this->mstate->getMatrixSize(); + for(sofa::Index i = 0; i < size; ++i) + { + matrix->discardRowCol(i, i); + } + } + else + { + const SetIndexArray & indices = d_indices.getValue(); + + for (const auto index : indices) + { + for (unsigned int c = 0; c < N; ++c) + { + matrix->discardRowCol(N * index + c, N * index + c); + } + } + } +} + +template +void FixedProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (this->d_componentState.getValue() != ComponentState::Valid) return; + if (!vparams->displayFlags().getShowBehaviorModels()) return; + if (!d_showObject.getValue()) return; + if (!this->isActive()) return; + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + const SetIndexArray & indices = d_indices.getValue(); + + if( d_drawSize.getValue() == 0) // old classical drawing by points + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + + if (d_fixAll.getValue()) + { + for (unsigned i = 0; i < x.size(); i++) + { + point = DataTypes::getCPos(x[i]); + points.push_back(point); + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + point = DataTypes::getCPos(x[*it]); + points.push_back(point); + } + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); + } + else // new drawing by spheres + { + vparams->drawTool()->setLightingEnabled(true); + + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + if( d_fixAll.getValue()==true ) + for (unsigned i=0; idrawTool()->drawSpheres(points, (float)d_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); + } + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h index cd66b14734a..77ae733eeb3 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h @@ -20,61 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/** - * Prevents rotation around X or Y or Z axis - */ -template -class FixedRotationConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(FixedRotationConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::MatrixDeriv::RowType MatrixDerivRowType; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::Vec<3,Real> Vec3; - - -protected: - FixedRotationConstraint(); - ~FixedRotationConstraint() override; -public: - void init() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& c) override; - - void draw(const core::visual::VisualParams* vparams) override; - - -protected : - Data< bool > FixedXRotation; ///< Prevent Rotation around X axis - Data< bool > FixedYRotation; ///< Prevent Rotation around Y axis - Data< bool > FixedZRotation; ///< Prevent Rotation around Z axis - type::vector> previousOrientation; -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDROTATIONCONSTRAINT_CPP) -extern template class FixedRotationConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl index 0f1a6731a8d..aec31d964c6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl @@ -21,122 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - - -template -FixedRotationConstraint::FixedRotationConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr), - FixedXRotation( initData( &FixedXRotation, false, "FixedXRotation", "Prevent Rotation around X axis")), - FixedYRotation( initData( &FixedYRotation, false, "FixedYRotation", "Prevent Rotation around Y axis")), - FixedZRotation( initData( &FixedZRotation, false, "FixedZRotation", "Prevent Rotation around Z axis")) -{ -} - - -template -FixedRotationConstraint::~FixedRotationConstraint() -{ -} - - -template -void FixedRotationConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::init(); - - // Retrieves mechanical state - VecCoord x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - // Stores initial orientation for each vertex - previousOrientation.resize(x.size()); - for (unsigned int i=0; i -void FixedRotationConstraint::projectResponse(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*res*/) -{ - -} - -template -void FixedRotationConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /*res*/) -{ - -} - -template -void FixedRotationConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*dx*/) -{ - -} - -template -void FixedRotationConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - for (unsigned int i = 0; i < x.size(); ++i) - { - // Current orientations - const sofa::type::Quat& Q = x[i].getOrientation(); - // Previous orientations - const sofa::type::Quat& Q_prev = previousOrientation[i]; - - auto project = [](const Vec3 a, const Vec3 b) -> Vec3 { - return (a * b) * b; - }; - auto decompose_ts = [&](const sofa::type::Quat q, const Vec3 twistAxis) { - Vec3 vec3_part(q[0], q[1], q[2]); - Vec3 projected = project(vec3_part, twistAxis); - sofa::type::Quat twist(projected[0], projected[1], projected[2], q[3]); - // Singularity : A perpendicular angle would give you quaternion (0, 0, 0, 0) - if (std::none_of(twist.ptr(), twist.ptr() + 4, [](SReal x) {return x != 0.; })) { - twist = sofa::type::Quat::identity(); - } - twist.normalize(); - sofa::type::Quat swing = q * twist.inverse(); - swing.normalize(); - return std::make_pair(twist, swing); - }; - const Vec3 vx(1, 0, 0), vy(0, 1, 0), vz(0, 0, 1); - - sofa::type::Quat Q_remaining = Q; - sofa::type::Quat Qp_remaining = Q_prev; - sofa::type::Quat to_keep = sofa::type::Quat::identity(); - - auto remove_rotation = [&](const Vec3 axis) { - Q_remaining = decompose_ts(Q_remaining, axis).second; - sofa::type::Quat twist; - std::tie(twist, Qp_remaining) = decompose_ts(Qp_remaining, axis); - to_keep = twist * to_keep; - }; - - if (FixedXRotation.getValue() == true){ - remove_rotation(vx); - } - if (FixedYRotation.getValue() == true){ - remove_rotation(vy); - } - if (FixedZRotation.getValue() == true){ - remove_rotation(vz); - } - x[i].getOrientation() = Q_remaining * to_keep; - } -} - - -template -void FixedRotationConstraint::draw(const core::visual::VisualParams* ) -{ -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp similarity index 82% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp index 3a47b6bbd69..0ce596ae483 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDROTATIONCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDROTATIONPROJECTIVECONSTRAINT_CPP +#include #include #include @@ -31,10 +31,10 @@ namespace sofa::component::constraint::projective using namespace sofa::defaulttype; -int FixedRotationConstraintClass = core::RegisterObject("Prevents rotation around x or/and y or/and z axis") - .add< FixedRotationConstraint >() +int FixedRotationProjectiveConstraintClass = core::RegisterObject("Prevents rotation around x or/and y or/and z axis") + .add< FixedRotationProjectiveConstraint >() ; -template class FixedRotationConstraint; +template class FixedRotationProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h new file mode 100644 index 00000000000..d8cc61cb115 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h @@ -0,0 +1,84 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +/** + * Prevents rotation around X or Y or Z axis + */ +template +class FixedRotationProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(FixedRotationProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::MatrixDeriv::RowType MatrixDerivRowType; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::Vec<3,Real> Vec3; + + +protected: + FixedRotationProjectiveConstraint(); + ~FixedRotationProjectiveConstraint() override; +public: + void init() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& c) override; + + void draw(const core::visual::VisualParams* vparams) override; + + +protected : + Data< bool > FixedXRotation; ///< Prevent Rotation around X axis + Data< bool > FixedYRotation; ///< Prevent Rotation around Y axis + Data< bool > FixedZRotation; ///< Prevent Rotation around Z axis + type::vector> previousOrientation; +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDROTATIONPROJECTIVECONSTRAINT_CPP) +extern template class FixedRotationProjectiveConstraint; + +#endif + +template +using FixedRotationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedRotationConstraint has been renamed to FixedRotationProjectiveConstraint") = FixedRotationProjectiveConstraint; + + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl new file mode 100644 index 00000000000..d900e468c9c --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl @@ -0,0 +1,142 @@ +/****************************************************************************** +* 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::constraint::projective +{ + + +template +FixedRotationProjectiveConstraint::FixedRotationProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr), + FixedXRotation( initData( &FixedXRotation, false, "FixedXRotation", "Prevent Rotation around X axis")), + FixedYRotation( initData( &FixedYRotation, false, "FixedYRotation", "Prevent Rotation around Y axis")), + FixedZRotation( initData( &FixedZRotation, false, "FixedZRotation", "Prevent Rotation around Z axis")) +{ +} + + +template +FixedRotationProjectiveConstraint::~FixedRotationProjectiveConstraint() +{ +} + + +template +void FixedRotationProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::init(); + + // Retrieves mechanical state + VecCoord x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + // Stores initial orientation for each vertex + previousOrientation.resize(x.size()); + for (unsigned int i=0; i +void FixedRotationProjectiveConstraint::projectResponse(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*res*/) +{ + +} + +template +void FixedRotationProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /*res*/) +{ + +} + +template +void FixedRotationProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*dx*/) +{ + +} + +template +void FixedRotationProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + for (unsigned int i = 0; i < x.size(); ++i) + { + // Current orientations + const sofa::type::Quat& Q = x[i].getOrientation(); + // Previous orientations + const sofa::type::Quat& Q_prev = previousOrientation[i]; + + auto project = [](const Vec3 a, const Vec3 b) -> Vec3 { + return (a * b) * b; + }; + auto decompose_ts = [&](const sofa::type::Quat q, const Vec3 twistAxis) { + Vec3 vec3_part(q[0], q[1], q[2]); + Vec3 projected = project(vec3_part, twistAxis); + sofa::type::Quat twist(projected[0], projected[1], projected[2], q[3]); + // Singularity : A perpendicular angle would give you quaternion (0, 0, 0, 0) + if (std::none_of(twist.ptr(), twist.ptr() + 4, [](SReal x) {return x != 0.; })) { + twist = sofa::type::Quat::identity(); + } + twist.normalize(); + sofa::type::Quat swing = q * twist.inverse(); + swing.normalize(); + return std::make_pair(twist, swing); + }; + const Vec3 vx(1, 0, 0), vy(0, 1, 0), vz(0, 0, 1); + + sofa::type::Quat Q_remaining = Q; + sofa::type::Quat Qp_remaining = Q_prev; + sofa::type::Quat to_keep = sofa::type::Quat::identity(); + + auto remove_rotation = [&](const Vec3 axis) { + Q_remaining = decompose_ts(Q_remaining, axis).second; + sofa::type::Quat twist; + std::tie(twist, Qp_remaining) = decompose_ts(Qp_remaining, axis); + to_keep = twist * to_keep; + }; + + if (FixedXRotation.getValue() == true){ + remove_rotation(vx); + } + if (FixedYRotation.getValue() == true){ + remove_rotation(vy); + } + if (FixedZRotation.getValue() == true){ + remove_rotation(vz); + } + x[i].getOrientation() = Q_remaining * to_keep; + } +} + + +template +void FixedRotationProjectiveConstraint::draw(const core::visual::VisualParams* ) +{ +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h index 29360c58629..34d2f8d097d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h @@ -20,87 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class FixedTranslationConstraintInternalData -{ -}; - -/** Attach given particles to their initial positions. -*/ -template -class FixedTranslationConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(FixedTranslationConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; -protected: - FixedTranslationConstraintInternalData data; - friend class FixedTranslationConstraintInternalData; - -public: - SetIndex f_indices; ///< Indices of the fixed points - Data f_fixAll; ///< filter all the DOF to implement a fixed object - Data _drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres - SetIndex f_coordinates; ///< Coordinates of the fixed points - - /// 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: - FixedTranslationConstraint(); - - virtual ~FixedTranslationConstraint(); -public: - // methods to add/remove some indices - void clearIndices(); - void addIndex(Index index); - void removeIndex(Index index); - - // -- Constraint interface - void init() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - - void draw(const core::visual::VisualParams* vparams) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); - -}; - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDTRANSLATIONCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl index 9c734a4b1c4..525c736847f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl @@ -21,188 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template< class DataTypes> -FixedTranslationConstraint::FixedTranslationConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) - , f_fixAll( initData(&f_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) - , _drawSize( initData(&_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) - , f_coordinates( initData(&f_coordinates,"coordinates","Coordinates of the fixed points") ) - , l_topology(initLink("topology", "link to the topology container")) -{ - // default to indice 0 - f_indices.beginEdit()->push_back(0); - f_indices.endEdit(); -} - - -template -FixedTranslationConstraint::~FixedTranslationConstraint() -{ - -} - -template -void FixedTranslationConstraint::clearIndices() -{ - f_indices.beginEdit()->clear(); - f_indices.endEdit(); -} - -template -void FixedTranslationConstraint::addIndex(Index index) -{ - f_indices.beginEdit()->push_back(index); - f_indices.endEdit(); -} - -template -void FixedTranslationConstraint::removeIndex(Index index) -{ - sofa::type::removeValue(*f_indices.beginEdit(),index); - f_indices.endEdit(); -} - -// -- Constraint interface -template -void FixedTranslationConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - f_indices.createTopologyHandler(_topology); - f_coordinates.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } -} - - -template -static inline void clearPos(defaulttype::RigidDeriv& v) -{ - getVCenter(v).clear(); -} - -template -static inline void clearPos(type::Vec<6,T>& v) -{ - for (unsigned int i=0; i<3; ++i) - v[i] = 0; -} - -template template -void FixedTranslationConstraint::projectResponseT(DataDeriv& dx, - const std::function& clear) -{ - if (f_fixAll.getValue()) - { - for (std::size_t i = 0; i < dx.size(); i++) - { - clear(dx, i); - } - } - else - { - const SetIndexArray & indices = f_indices.getValue(); - for (const auto index : indices) - { - clear(dx, index); - } - } -} - -template -void FixedTranslationConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(), [](auto& dx, const unsigned int index) {dx[index].clear(); }); -} - -template -void FixedTranslationConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*vData*/) -{ - -} - -template -void FixedTranslationConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& /*xData*/) -{ - -} - -template -void FixedTranslationConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); -} - - -template -void FixedTranslationConstraint::draw(const core::visual::VisualParams* vparams) -{ - const SetIndexArray & indices = f_indices.getValue(); - if (!vparams->displayFlags().getShowBehaviorModels()) - return; - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - vparams->drawTool()->disableLighting(); - - std::vector vertices; - constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); - - if (f_fixAll.getValue() == true) - { - for (unsigned i = 0; i < x.size(); i++) - { - sofa::type::Vec3 v; - const typename DataTypes::CPos& cpos = DataTypes::getCPos(x[i]); - for(Size j=0 ; jdrawTool()->drawPoints(vertices, 10, color); - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp similarity index 76% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp index c4acd3e16f1..2d25df55ec8 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDTRANSLATIONCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDTRANSLATIONPROJECTIVECONSTRAINT_CPP +#include #include #include @@ -31,16 +31,16 @@ namespace sofa::component::constraint::projective using namespace sofa::defaulttype; using namespace sofa::helper; -int FixedTranslationConstraintClass = core::RegisterObject("Attach given rigids to their initial positions but they still can have rotations") - .add< FixedTranslationConstraint >() - .add< FixedTranslationConstraint >() - .add< FixedTranslationConstraint >() +int FixedTranslationProjectiveConstraintClass = core::RegisterObject("Attach given rigids to their initial positions but they still can have rotations") + .add< FixedTranslationProjectiveConstraint >() + .add< FixedTranslationProjectiveConstraint >() + .add< FixedTranslationProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h new file mode 100644 index 00000000000..101762a6567 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h @@ -0,0 +1,110 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class FixedTranslationProjectiveConstraintInternalData +{ +}; + +/** Attach given particles to their initial positions. +*/ +template +class FixedTranslationProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(FixedTranslationProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; +protected: + FixedTranslationProjectiveConstraintInternalData data; + friend class FixedTranslationProjectiveConstraintInternalData; + +public: + SetIndex f_indices; ///< Indices of the fixed points + Data f_fixAll; ///< filter all the DOF to implement a fixed object + Data _drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres + SetIndex f_coordinates; ///< Coordinates of the fixed points + + /// 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: + FixedTranslationProjectiveConstraint(); + + virtual ~FixedTranslationProjectiveConstraint(); +public: + // methods to add/remove some indices + void clearIndices(); + void addIndex(Index index); + void removeIndex(Index index); + + // -- Constraint interface + void init() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + + void draw(const core::visual::VisualParams* vparams) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); + +}; + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDTRANSLATIONPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; + +#endif + +template +using FixedTranslationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedTranslationConstraint has been renamed to FixedTranslationProjectiveConstraint") = FixedTranslationProjectiveConstraint; + + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl new file mode 100644 index 00000000000..d1f7408b8c8 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl @@ -0,0 +1,208 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +template< class DataTypes> +FixedTranslationProjectiveConstraint::FixedTranslationProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) + , f_fixAll( initData(&f_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) + , _drawSize( initData(&_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) + , f_coordinates( initData(&f_coordinates,"coordinates","Coordinates of the fixed points") ) + , l_topology(initLink("topology", "link to the topology container")) +{ + // default to indice 0 + f_indices.beginEdit()->push_back(0); + f_indices.endEdit(); +} + + +template +FixedTranslationProjectiveConstraint::~FixedTranslationProjectiveConstraint() +{ + +} + +template +void FixedTranslationProjectiveConstraint::clearIndices() +{ + f_indices.beginEdit()->clear(); + f_indices.endEdit(); +} + +template +void FixedTranslationProjectiveConstraint::addIndex(Index index) +{ + f_indices.beginEdit()->push_back(index); + f_indices.endEdit(); +} + +template +void FixedTranslationProjectiveConstraint::removeIndex(Index index) +{ + sofa::type::removeValue(*f_indices.beginEdit(),index); + f_indices.endEdit(); +} + +// -- Constraint interface +template +void FixedTranslationProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); + f_coordinates.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } +} + + +template +static inline void clearPos(defaulttype::RigidDeriv& v) +{ + getVCenter(v).clear(); +} + +template +static inline void clearPos(type::Vec<6,T>& v) +{ + for (unsigned int i=0; i<3; ++i) + v[i] = 0; +} + +template template +void FixedTranslationProjectiveConstraint::projectResponseT(DataDeriv& dx, + const std::function& clear) +{ + if (f_fixAll.getValue()) + { + for (std::size_t i = 0; i < dx.size(); i++) + { + clear(dx, i); + } + } + else + { + const SetIndexArray & indices = f_indices.getValue(); + for (const auto index : indices) + { + clear(dx, index); + } + } +} + +template +void FixedTranslationProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(), [](auto& dx, const unsigned int index) {dx[index].clear(); }); +} + +template +void FixedTranslationProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& /*vData*/) +{ + +} + +template +void FixedTranslationProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& /*xData*/) +{ + +} + +template +void FixedTranslationProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); +} + + +template +void FixedTranslationProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + const SetIndexArray & indices = f_indices.getValue(); + if (!vparams->displayFlags().getShowBehaviorModels()) + return; + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + vparams->drawTool()->disableLighting(); + + std::vector vertices; + constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); + + if (f_fixAll.getValue() == true) + { + for (unsigned i = 0; i < x.size(); i++) + { + sofa::type::Vec3 v; + const typename DataTypes::CPos& cpos = DataTypes::getCPos(x[i]); + for(Size j=0 ; jdrawTool()->drawPoints(vertices, 10, color); + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h index 858a5ab5a6c..f059eb884ee 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h @@ -20,115 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/** - Impose a trajectory to given Dofs following a Hermite cubic spline constraint. - Control parameters are : - - begin and end points - - derivates at this points - - acceleration curve on the trajectory - */ -template -class HermiteSplineConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(HermiteSplineConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename Coord::value_type Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - typedef typename type::Vec<3, Real> Vec3R; - typedef typename type::Vec<2, Real> Vec2R; - typedef typename type::Quat QuatR; - -public: - ///indices of the DOFs constraints - SetIndex m_indices; - - /// the time steps defining the duration of the constraint - Data m_tBegin; - Data m_tEnd; ///< End Time of the motion - - /// control parameters : - /// first control point - Data m_x0; - /// first derivated control point - Data m_dx0; - /// second control point - Data m_x1; - /// second derivated control point - Data m_dx1; - /// acceleration parameters : the accaleration curve is itself a hermite spline, with first point at (0,0) and second at (1,1) - /// and derivated on this points are : - Data m_sx0; - Data m_sx1; ///< second interpolation vector - - /// 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: - explicit HermiteSplineConstraint(core::behavior::MechanicalState* mstate = nullptr); - - ~HermiteSplineConstraint(); -public: - void clearConstraints(); - void addConstraint(unsigned index ); - - void setBeginTime(const Real &t) {m_tBegin.setValue(t);} - void setEndTime(const Real &t) {m_tEnd.setValue(t);} - - Real getBeginTime() {return m_tBegin.getValue();} - Real getEndTime() {return m_tEnd.getValue();} - - void computeHermiteCoefs( const Real u, Real &H00, Real &H10, Real &H01, Real &H11); - void computeDerivateHermiteCoefs( const Real u, Real &dH00, Real &dH10, Real &dH01, Real &dH11); - - /// -- Constraint interface - void init() override; - void reinit() override; - - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void draw(const core::visual::VisualParams* vparams) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); - -}; - -template <> -void SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineConstraint::init(); - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_HERMITESPLINECONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl index 6fc823bf0c1..d11f87acb31 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl @@ -21,247 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -HermiteSplineConstraint::HermiteSplineConstraint(core::behavior::MechanicalState* mstate) - : core::behavior::ProjectiveConstraintSet(mstate) - , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) - , m_tBegin(initData(&m_tBegin,"BeginTime","Begin Time of the motion") ) - , m_tEnd(initData(&m_tEnd,"EndTime","End Time of the motion") ) - , m_x0(initData(&m_x0,"X0","first control point") ) - , m_dx0(initData(&m_dx0,"dX0","first control tangente") ) - , m_x1(initData(&m_x1,"X1","second control point") ) - , m_dx1(initData(&m_dx1,"dX1","sceond control tangente") ) - , m_sx0(initData(&m_sx0,"SX0","first interpolation vector") ) - , m_sx1(initData(&m_sx1,"SX1","second interpolation vector") ) - , l_topology(initLink("topology", "link to the topology container")) -{ -} - -template -HermiteSplineConstraint::~HermiteSplineConstraint() -{ -} - -template -void HermiteSplineConstraint::clearConstraints() -{ - m_indices.beginEdit()->clear(); - m_indices.endEdit(); -} - -template -void HermiteSplineConstraint::addConstraint(unsigned index) -{ - m_indices.beginEdit()->push_back(index); - m_indices.endEdit(); -} - - -template -void HermiteSplineConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize functions and parameters for topology data and handler - m_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } -} - -template -void HermiteSplineConstraint::reinit() -{ - init(); -} - - -template -void HermiteSplineConstraint::computeHermiteCoefs( const Real u, Real &H00, Real &H10, Real &H01, Real &H11) -{ - //-- time interpolation --> acceleration is itself computed from hemite - Real u2 = u*u; - Real u3 = u*u*u; - //Real uH00 = 2*u3 -3*u2 +1 ; //hermite coefs - Real uH10 = u3 -2*u2 +u; - Real uH01 = -2*u3 + 3*u2; - Real uH11 = u3 -u2; - Vec2R pu = m_sx0.getValue()*uH10 + Vec2R(1,1)*uH01 + m_sx1.getValue()*uH11; - Real su = pu.y(); - - Real su2 = su*su; - Real su3 = su*su*su; - H00 = 2*su3 -3*su2 +1 ; - H10 = su3 -2*su2 +su; - H01 = -2*su3 + 3*su2; - H11 = su3 -su2; -} - -template -void HermiteSplineConstraint::computeDerivateHermiteCoefs( const Real u, Real &dH00, Real &dH10, Real &dH01, Real &dH11) -{ - //-- time interpolation --> acceleration is itself computed from hemite - Real u2 = u*u; - Real u3 = u*u*u; - Real uH10 = u3 -2*u2 +u; - Real uH01 = -2*u3 + 3*u2; - Real uH11 = u3 -u2; - Vec2R pu = m_sx0.getValue()*uH10 + Vec2R(1,1)*uH01 + m_sx1.getValue()*uH11; - Real su = pu.y(); - - Real su2 = su*su; - dH00 = 6*su2 -6*su ; - dH10 = 3*su2 -4*su +1; - dH01 = -6*su2 + 6*su; - dH11 = 3*su2 -2*su; -} - - -template template -void HermiteSplineConstraint::projectResponseT(DataDeriv& dx, - const std::function& clear) -{ - Real t = (Real) this->getContext()->getTime(); - if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue()) - { - const SetIndexArray & indices = m_indices.getValue(); - for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - clear(dx, *it); - } -} - -template -void HermiteSplineConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(), [](auto& dx, const unsigned int index) {dx[index].clear();}); -} - -template -void HermiteSplineConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - helper::WriteAccessor dx = vData; - Real t = (Real) this->getContext()->getTime(); - - if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) - { - Real DT = m_tEnd.getValue() - m_tBegin.getValue(); - const SetIndexArray & indices = m_indices.getValue(); - - t -= m_tBegin.getValue(); - Real u = t/DT; - - Real dH00, dH10, dH01, dH11; - computeDerivateHermiteCoefs( u, dH00, dH10, dH01, dH11); - - for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - dx[*it] = m_x0.getValue()*dH00 + m_dx0.getValue()*dH10 + m_x1.getValue()*dH01 + m_dx1.getValue()*dH11; - } - } -} - -template -void HermiteSplineConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - Real t = (Real) this->getContext()->getTime(); - - if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) - { - Real DT = m_tEnd.getValue() - m_tBegin.getValue(); - const SetIndexArray & indices = m_indices.getValue(); - - t -= m_tBegin.getValue(); - Real u = t/DT; - - Real H00, H10, H01, H11; - computeHermiteCoefs( u, H00, H10, H01, H11); - - for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it] = m_x0.getValue()*H00 + m_dx0.getValue()*H10 + m_x1.getValue()*H01 + m_dx1.getValue()*H11; - } - } -} - -template -void HermiteSplineConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - - projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); -} - -template -void HermiteSplineConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) return; - - Real dt = (Real) this->getContext()->getDt(); - Real DT = m_tEnd.getValue() - m_tBegin.getValue(); - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - vparams->drawTool()->disableLighting(); - - std::vector vertices; - constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); - - const Vec3R& mx0 = m_x0.getValue(); - const Vec3R& mx1 = m_x0.getValue(); - const Vec3R& mdx0 = m_dx0.getValue(); - const Vec3R& mdx1 = m_dx1.getValue(); - - for (Real t=0.0 ; t< DT ; t+= dt) - { - Real u = t/DT; - - Real H00, H10, H01, H11; - computeHermiteCoefs( u, H00, H10, H01, H11); - - Vec3R p = mx0*H00 + mdx0*H10 + mx1*H01 + mdx1*H11; - - sofa::type::Vec3 v(p[0], p[1],p[2]); - vertices.push_back(v); - } - vparams->drawTool()->drawLineStrip(vertices, 2, color); - - vertices.clear(); - vertices.push_back(sofa::type::Vec3(mx0[0], mx0[1], mx0[2])); - vertices.push_back(sofa::type::Vec3(mx1[0], mx1[1], mx1[2])); - - vparams->drawTool()->drawPoints(vertices, 5.0, sofa::type::RGBAColor::red()); - - //display control tangents - vertices.clear(); - vertices.push_back(mx0); - vertices.push_back(mx0 + mdx0*0.1); - vertices.push_back(mx1); - vertices.push_back(mx1 + mdx1*0.1); - - vparams->drawTool()->drawLines(vertices, 1.0, sofa::type::RGBAColor::red()); - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp similarity index 77% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp index 1d6ec21d8bb..aa10b586bf7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_HERMITESPLINECONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_HERMITESPLINEPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -28,18 +28,18 @@ namespace sofa::component::constraint::projective { -int HermiteSplineConstraintClass = core::RegisterObject("Apply a hermite cubic spline trajectory to given points") - .add< HermiteSplineConstraint >() - .add< HermiteSplineConstraint >() +int HermiteSplineProjectiveConstraintClass = core::RegisterObject("Apply a hermite cubic spline trajectory to given points") + .add< HermiteSplineProjectiveConstraint >() + .add< HermiteSplineProjectiveConstraint >() ; template <> -void HermiteSplineConstraint::init() +void HermiteSplineProjectiveConstraint::init() { this->core::behavior::ProjectiveConstraintSet::init(); } -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h new file mode 100644 index 00000000000..7a284739e2c --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h @@ -0,0 +1,137 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +/** + Impose a trajectory to given Dofs following a Hermite cubic spline constraint. + Control parameters are : + - begin and end points + - derivates at this points + - acceleration curve on the trajectory + */ +template +class HermiteSplineProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(HermiteSplineProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename Coord::value_type Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + typedef typename type::Vec<3, Real> Vec3R; + typedef typename type::Vec<2, Real> Vec2R; + typedef typename type::Quat QuatR; + +public: + ///indices of the DOFs constraints + SetIndex m_indices; + + /// the time steps defining the duration of the constraint + Data m_tBegin; + Data m_tEnd; ///< End Time of the motion + + /// control parameters : + /// first control point + Data m_x0; + /// first derivated control point + Data m_dx0; + /// second control point + Data m_x1; + /// second derivated control point + Data m_dx1; + /// acceleration parameters : the accaleration curve is itself a hermite spline, with first point at (0,0) and second at (1,1) + /// and derivated on this points are : + Data m_sx0; + Data m_sx1; ///< second interpolation vector + + /// 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: + explicit HermiteSplineProjectiveConstraint(core::behavior::MechanicalState* mstate = nullptr); + + ~HermiteSplineProjectiveConstraint(); +public: + void clearConstraints(); + void addConstraint(unsigned index ); + + void setBeginTime(const Real &t) {m_tBegin.setValue(t);} + void setEndTime(const Real &t) {m_tEnd.setValue(t);} + + Real getBeginTime() {return m_tBegin.getValue();} + Real getEndTime() {return m_tEnd.getValue();} + + void computeHermiteCoefs( const Real u, Real &H00, Real &H10, Real &H01, Real &H11); + void computeDerivateHermiteCoefs( const Real u, Real &dH00, Real &dH10, Real &dH01, Real &dH11); + + /// -- Constraint interface + void init() override; + void reinit() override; + + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void draw(const core::visual::VisualParams* vparams) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); + +}; + +template <> +void SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineProjectiveConstraint::init(); + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_HERMITESPLINEPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineProjectiveConstraint; + +#endif + +template +using HermiteSplineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "HermiteSplineConstraint has been renamed to HermiteSplineProjectiveConstraint") = HermiteSplineProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl new file mode 100644 index 00000000000..eeef7815197 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl @@ -0,0 +1,267 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +template +HermiteSplineProjectiveConstraint::HermiteSplineProjectiveConstraint(core::behavior::MechanicalState* mstate) + : core::behavior::ProjectiveConstraintSet(mstate) + , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) + , m_tBegin(initData(&m_tBegin,"BeginTime","Begin Time of the motion") ) + , m_tEnd(initData(&m_tEnd,"EndTime","End Time of the motion") ) + , m_x0(initData(&m_x0,"X0","first control point") ) + , m_dx0(initData(&m_dx0,"dX0","first control tangente") ) + , m_x1(initData(&m_x1,"X1","second control point") ) + , m_dx1(initData(&m_dx1,"dX1","sceond control tangente") ) + , m_sx0(initData(&m_sx0,"SX0","first interpolation vector") ) + , m_sx1(initData(&m_sx1,"SX1","second interpolation vector") ) + , l_topology(initLink("topology", "link to the topology container")) +{ +} + +template +HermiteSplineProjectiveConstraint::~HermiteSplineProjectiveConstraint() +{ +} + +template +void HermiteSplineProjectiveConstraint::clearConstraints() +{ + m_indices.beginEdit()->clear(); + m_indices.endEdit(); +} + +template +void HermiteSplineProjectiveConstraint::addConstraint(unsigned index) +{ + m_indices.beginEdit()->push_back(index); + m_indices.endEdit(); +} + + +template +void HermiteSplineProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize functions and parameters for topology data and handler + m_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } +} + +template +void HermiteSplineProjectiveConstraint::reinit() +{ + init(); +} + + +template +void HermiteSplineProjectiveConstraint::computeHermiteCoefs( const Real u, Real &H00, Real &H10, Real &H01, Real &H11) +{ + //-- time interpolation --> acceleration is itself computed from hemite + Real u2 = u*u; + Real u3 = u*u*u; + //Real uH00 = 2*u3 -3*u2 +1 ; //hermite coefs + Real uH10 = u3 -2*u2 +u; + Real uH01 = -2*u3 + 3*u2; + Real uH11 = u3 -u2; + Vec2R pu = m_sx0.getValue()*uH10 + Vec2R(1,1)*uH01 + m_sx1.getValue()*uH11; + Real su = pu.y(); + + Real su2 = su*su; + Real su3 = su*su*su; + H00 = 2*su3 -3*su2 +1 ; + H10 = su3 -2*su2 +su; + H01 = -2*su3 + 3*su2; + H11 = su3 -su2; +} + +template +void HermiteSplineProjectiveConstraint::computeDerivateHermiteCoefs( const Real u, Real &dH00, Real &dH10, Real &dH01, Real &dH11) +{ + //-- time interpolation --> acceleration is itself computed from hemite + Real u2 = u*u; + Real u3 = u*u*u; + Real uH10 = u3 -2*u2 +u; + Real uH01 = -2*u3 + 3*u2; + Real uH11 = u3 -u2; + Vec2R pu = m_sx0.getValue()*uH10 + Vec2R(1,1)*uH01 + m_sx1.getValue()*uH11; + Real su = pu.y(); + + Real su2 = su*su; + dH00 = 6*su2 -6*su ; + dH10 = 3*su2 -4*su +1; + dH01 = -6*su2 + 6*su; + dH11 = 3*su2 -2*su; +} + + +template template +void HermiteSplineProjectiveConstraint::projectResponseT(DataDeriv& dx, + const std::function& clear) +{ + Real t = (Real) this->getContext()->getTime(); + if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue()) + { + const SetIndexArray & indices = m_indices.getValue(); + for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + clear(dx, *it); + } +} + +template +void HermiteSplineProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(), [](auto& dx, const unsigned int index) {dx[index].clear();}); +} + +template +void HermiteSplineProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + helper::WriteAccessor dx = vData; + Real t = (Real) this->getContext()->getTime(); + + if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) + { + Real DT = m_tEnd.getValue() - m_tBegin.getValue(); + const SetIndexArray & indices = m_indices.getValue(); + + t -= m_tBegin.getValue(); + Real u = t/DT; + + Real dH00, dH10, dH01, dH11; + computeDerivateHermiteCoefs( u, dH00, dH10, dH01, dH11); + + for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + dx[*it] = m_x0.getValue()*dH00 + m_dx0.getValue()*dH10 + m_x1.getValue()*dH01 + m_dx1.getValue()*dH11; + } + } +} + +template +void HermiteSplineProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + Real t = (Real) this->getContext()->getTime(); + + if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) + { + Real DT = m_tEnd.getValue() - m_tBegin.getValue(); + const SetIndexArray & indices = m_indices.getValue(); + + t -= m_tBegin.getValue(); + Real u = t/DT; + + Real H00, H10, H01, H11; + computeHermiteCoefs( u, H00, H10, H01, H11); + + for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it] = m_x0.getValue()*H00 + m_dx0.getValue()*H10 + m_x1.getValue()*H01 + m_dx1.getValue()*H11; + } + } +} + +template +void HermiteSplineProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + + projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); +} + +template +void HermiteSplineProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) return; + + Real dt = (Real) this->getContext()->getDt(); + Real DT = m_tEnd.getValue() - m_tBegin.getValue(); + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + vparams->drawTool()->disableLighting(); + + std::vector vertices; + constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); + + const Vec3R& mx0 = m_x0.getValue(); + const Vec3R& mx1 = m_x0.getValue(); + const Vec3R& mdx0 = m_dx0.getValue(); + const Vec3R& mdx1 = m_dx1.getValue(); + + for (Real t=0.0 ; t< DT ; t+= dt) + { + Real u = t/DT; + + Real H00, H10, H01, H11; + computeHermiteCoefs( u, H00, H10, H01, H11); + + Vec3R p = mx0*H00 + mdx0*H10 + mx1*H01 + mdx1*H11; + + sofa::type::Vec3 v(p[0], p[1],p[2]); + vertices.push_back(v); + } + vparams->drawTool()->drawLineStrip(vertices, 2, color); + + vertices.clear(); + vertices.push_back(sofa::type::Vec3(mx0[0], mx0[1], mx0[2])); + vertices.push_back(sofa::type::Vec3(mx1[0], mx1[1], mx1[2])); + + vparams->drawTool()->drawPoints(vertices, 5.0, sofa::type::RGBAColor::red()); + + //display control tangents + vertices.clear(); + vertices.push_back(mx0); + vertices.push_back(mx0 + mdx0*0.1); + vertices.push_back(mx1); + vertices.push_back(mx1 + mdx1*0.1); + + vparams->drawTool()->drawLines(vertices, 1.0, sofa::type::RGBAColor::red()); + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h index 4df6f686718..a6087d6acb0 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h @@ -20,149 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -class LinearMovementConstraintInternalData -{ -}; - -/** impose a motion to given DOFs (translation and rotation) - The motion between 2 key times is linearly interpolated - Rigid version doesn't handle Topology change. -*/ -template -class LinearMovementConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(LinearMovementConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); - - using Index = sofa::Index; - typedef TDataTypes DataTypes; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - -protected: - LinearMovementConstraintInternalData *data; - friend class LinearMovementConstraintInternalData; - -public : - /// indices of the DOFs the constraint is applied to - SetIndex m_indices; - /// the key frames when the motion is defined by the user - Data > m_keyTimes; - /// the motions corresponding to the key frames - Data m_keyMovements; - - /// indicates whether movements are relative to the dof or absolute - Data< bool > d_relativeMovements; - - /// attributes to precise display - /// if showMovement is true we display the expected movement - /// otherwise we show which are the fixed dofs - Data< bool > showMovement; - - - /// the key times surrounding the current simulation time (for interpolation) - Real prevT, nextT; - ///the motions corresponding to the surrouding key times - Deriv prevM, nextM; - ///initial constrained DOFs position - VecCoord x0; - - /// 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: - LinearMovementConstraint(); - ~LinearMovementConstraint() override; - -public: - ///methods to add/remove some indices, keyTimes, keyMovement - void clearIndices(); - void addIndex(Index index); - void removeIndex(Index index); - void clearKeyMovements(); - - ///@brief Add a new key movement - /// @param time : the simulation time you want to set a movement (in sec) - /// @param movement : the corresponding motion - /// for instance, addKeyMovement(1.0, Deriv(5,0,0) ) will set a translation of 5 in x direction a time 1.0s - /// - void addKeyMovement(Real time, Deriv movement); - - /// -- Constraint interface - void init() override; - void reset() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; - - void draw(const core::visual::VisualParams* vparams) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); - - template - void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); - template - void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); - -private: - /// to keep the time corresponding to the key times - Real currentTime; - - /// to know if we found the key times - bool finished; - - /// find previous and next time keys - void findKeyTimes(); -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARMOVEMENTCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl index d1700e27943..b652d73c8d9 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl @@ -21,455 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -LinearMovementConstraint::LinearMovementConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , data(new LinearMovementConstraintInternalData) - , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) - , m_keyTimes( initData(&m_keyTimes,"keyTimes","key times for the movements") ) - , m_keyMovements( initData(&m_keyMovements,"movements","movements corresponding to the key times") ) - , d_relativeMovements( initData(&d_relativeMovements, bool(true), "relativeMovements", "If true, movements are relative to first position, absolute otherwise") ) - , showMovement( initData(&showMovement, bool(false), "showMovement", "Visualization of the movement to be applied to constrained dofs.")) - , l_topology(initLink("topology", "link to the topology container")) - , finished(false) -{ - // default to indice 0 - m_indices.beginEdit()->push_back(0); - m_indices.endEdit(); - - //default valueEvent to 0 - m_keyTimes.beginEdit()->push_back( 0.0 ); - m_keyTimes.endEdit(); - m_keyMovements.beginEdit()->push_back( Deriv() ); - m_keyMovements.endEdit(); -} - - - -template -LinearMovementConstraint::~LinearMovementConstraint() -{ - -} - -template -void LinearMovementConstraint::clearIndices() -{ - m_indices.beginEdit()->clear(); - m_indices.endEdit(); -} - -template -void LinearMovementConstraint::addIndex(Index index) -{ - m_indices.beginEdit()->push_back(index); - m_indices.endEdit(); -} - -template -void LinearMovementConstraint::removeIndex(Index index) -{ - sofa::type::removeValue(*m_indices.beginEdit(),index); - m_indices.endEdit(); -} - -template -void LinearMovementConstraint::clearKeyMovements() -{ - m_keyTimes.beginEdit()->clear(); - m_keyTimes.endEdit(); - m_keyMovements.beginEdit()->clear(); - m_keyMovements.endEdit(); -} - -template -void LinearMovementConstraint::addKeyMovement(Real time, Deriv movement) -{ - m_keyTimes.beginEdit()->push_back( time ); - m_keyTimes.endEdit(); - m_keyMovements.beginEdit()->push_back( movement ); - m_keyMovements.endEdit(); -} - -// -- Constraint interface -template -void LinearMovementConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - m_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - x0.resize(0); - nextM = prevM = Deriv(); - - currentTime = -1.0; - finished = false; -} - - -template -void LinearMovementConstraint::reset() -{ - nextT = prevT = 0.0; - nextM = prevM = Deriv(); - - currentTime = -1.0; - finished = false; -} - - -template -template -void LinearMovementConstraint::projectResponseT(DataDeriv& dx, - const std::function& clear) -{ - Real cT = static_cast(this->getContext()->getTime()); - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - if (finished && nextT != prevT) - { - const SetIndexArray & indices = m_indices.getValue(); - - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - clear(dx, *it); - } - } -} - -template -void LinearMovementConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(), [](auto& dx, const unsigned int index) {dx[index].clear(); }); -} - -template -void LinearMovementConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - helper::WriteAccessor dx = vData; - Real cT = static_cast(this->getContext()->getTime()); - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - if (finished && nextT != prevT) - { - const SetIndexArray & indices = m_indices.getValue(); - - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - dx[*it] = (nextM - prevM)*(1.0 / (nextT - prevT)); - } - } -} - - -template -void LinearMovementConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - Real cT = static_cast(this->getContext()->getTime()); - - //initialize initial Dofs positions, if it's not done - if (x0.size() == 0) - { - const SetIndexArray & indices = m_indices.getValue(); - x0.resize(x.size()); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x0[*it] = x[*it]; - } - } - - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - //if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) - if(finished && nextT != prevT) - { - interpolatePosition(cT, x.wref()); - } -} - -template -template -void LinearMovementConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) -{ - const SetIndexArray & indices = m_indices.getValue(); - - Real dt = (cT - prevT) / (nextT - prevT); - Deriv m = prevM + (nextM-prevM)*dt; - - //set the motion to the Dofs - if (d_relativeMovements.getValue()) - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it] = x0[*it] + m ; - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it] = m ; - } - } -} - -template -template -void LinearMovementConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) -{ - const SetIndexArray & indices = m_indices.getValue(); - - Real dt = (cT - prevT) / (nextT - prevT); - Deriv m = prevM + (nextM-prevM)*dt; - type::Quat prevOrientation = type::Quat::createQuaterFromEuler(getVOrientation(prevM)); - type::Quat nextOrientation = type::Quat::createQuaterFromEuler(getVOrientation(nextM)); - - //set the motion to the Dofs - if (d_relativeMovements.getValue()) - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it].getCenter() = x0[*it].getCenter() + getVCenter(m) ; - x[*it].getOrientation() = x0[*it].getOrientation() * prevOrientation.slerp2(nextOrientation, dt); - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it].getCenter() = getVCenter(m) ; - x[*it].getOrientation() = prevOrientation.slerp2(nextOrientation, dt); - } - } -} - -template -void LinearMovementConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - - projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); -} - -template -void LinearMovementConstraint::findKeyTimes() -{ - Real cT = static_cast(this->getContext()->getTime()); - finished = false; - - if(m_keyTimes.getValue().size() != 0 && cT >= *m_keyTimes.getValue().begin() && cT <= *m_keyTimes.getValue().rbegin()) - { - nextT = *m_keyTimes.getValue().begin(); - prevT = nextT; - - typename type::vector::const_iterator it_t = m_keyTimes.getValue().begin(); - typename VecDeriv::const_iterator it_m = m_keyMovements.getValue().begin(); - - //WARNING : we consider that the key-events are in chronological order - //here we search between which keyTimes we are, to know which are the motion to interpolate - while( it_t != m_keyTimes.getValue().end() && !finished) - { - if( *it_t <= cT) - { - prevT = *it_t; - prevM = *it_m; - } - else - { - nextT = *it_t; - nextM = *it_m; - finished = true; - } - ++it_t; - ++it_m; - } - } -} - - -template -void LinearMovementConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - static const unsigned blockSize = DataTypes::deriv_total_size; - - // clears the rows and columns associated with fixed particles - for (const auto id : m_indices.getValue()) - { - M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); - } - -} - - -// Matrix Integration interface -template -void LinearMovementConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) - { - const unsigned int N = Deriv::size(); - const SetIndexArray & indices = m_indices.getValue(); - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); - } - } -} - -template -void LinearMovementConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const int o = matrix->getGlobalOffset(this->mstate.get()); - if (o >= 0) - { - const unsigned int offset = (unsigned int)o; - const unsigned int N = Deriv::size(); - - const SetIndexArray & indices = m_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for (unsigned int c=0; cclear(offset + N * (*it) + c); - } - } -} - -template -void LinearMovementConstraint::applyConstraint( - sofa::core::behavior::ZeroDirichletCondition* matrix) -{ - constexpr unsigned int N = Deriv::size(); - - for (const auto index : m_indices.getValue()) - { - for (unsigned int c = 0; c < N; ++c) - { - matrix->discardRowCol(N * index + c, N * index + c); - } - } -} - -//display the path the constrained dofs will go through -template -void LinearMovementConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels() || m_keyTimes.getValue().size() == 0) - return; - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); - - if (showMovement.getValue()) - { - vparams->drawTool()->disableLighting(); - - std::vector vertices; - - constexpr auto minDimensions = std::min(DataTypes::spatial_dimensions, 3u); - - const SetIndexArray & indices = m_indices.getValue(); - const VecDeriv& keyMovements = m_keyMovements.getValue(); - if (d_relativeMovements.getValue()) - { - for (unsigned int i = 0; i < m_keyMovements.getValue().size() - 1; i++) - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - const auto& tmp0 = DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i]); - const auto& tmp1 = DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i + 1]); - sofa::type::Vec3 v0, v1; - std::copy_n(tmp0.begin(), minDimensions, v0.begin()); - std::copy_n(tmp1.begin(), minDimensions, v1.begin()); - vertices.push_back(v0); - vertices.push_back(v1); - } - } - } - else - { - for (unsigned int i = 0; i < keyMovements.size() - 1; i++) - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - const auto& tmp0 = DataTypes::getDPos(keyMovements[i]); - const auto& tmp1 = DataTypes::getDPos(keyMovements[i + 1]); - sofa::type::Vec3 v0, v1; - std::copy_n(tmp0.begin(), minDimensions, v0.begin()); - std::copy_n(tmp1.begin(), minDimensions, v1.begin()); - vertices.push_back(v0); - vertices.push_back(v1); - } - } - } - vparams->drawTool()->drawLines(vertices, 10, color); - } - else - { - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - sofa::type::vector points; - type::Vec3 point; - const SetIndexArray & indices = m_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - point = DataTypes::getCPos(x[*it]); - points.push_back(point); - } - vparams->drawTool()->drawPoints(points, 10, color); - } - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp similarity index 71% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp index 3c47dc2dbce..0b528b78105 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARMOVEMENTCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARMOVEMENTPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -29,7 +29,7 @@ namespace sofa::component::constraint::projective { template <> SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API -void LinearMovementConstraint::init() +void LinearMovementProjectiveConstraint::init() { this->core::behavior::ProjectiveConstraintSet::init(); @@ -42,18 +42,18 @@ void LinearMovementConstraint::init() //declaration of the class, for the factory -int LinearMovementConstraintClass = core::RegisterObject("translate given particles") - .add< LinearMovementConstraint >() - .add< LinearMovementConstraint >() - .add< LinearMovementConstraint >() - .add< LinearMovementConstraint >() - .add< LinearMovementConstraint >(); - - -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementConstraint; +int LinearMovementProjectiveConstraintClass = core::RegisterObject("translate given particles") + .add< LinearMovementProjectiveConstraint >() + .add< LinearMovementProjectiveConstraint >() + .add< LinearMovementProjectiveConstraint >() + .add< LinearMovementProjectiveConstraint >() + .add< LinearMovementProjectiveConstraint >(); + + +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h new file mode 100644 index 00000000000..af424d6d1ef --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h @@ -0,0 +1,171 @@ +/****************************************************************************** +* 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 +#include +#include +#include + +namespace sofa::component::constraint::projective +{ + +template +class LinearMovementProjectiveConstraintInternalData +{ +}; + +/** impose a motion to given DOFs (translation and rotation) + The motion between 2 key times is linearly interpolated + Rigid version doesn't handle Topology change. +*/ +template +class LinearMovementProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(LinearMovementProjectiveConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); + + using Index = sofa::Index; + typedef TDataTypes DataTypes; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + +protected: + LinearMovementProjectiveConstraintInternalData *data; + friend class LinearMovementProjectiveConstraintInternalData; + +public : + /// indices of the DOFs the constraint is applied to + SetIndex m_indices; + /// the key frames when the motion is defined by the user + Data > m_keyTimes; + /// the motions corresponding to the key frames + Data m_keyMovements; + + /// indicates whether movements are relative to the dof or absolute + Data< bool > d_relativeMovements; + + /// attributes to precise display + /// if showMovement is true we display the expected movement + /// otherwise we show which are the fixed dofs + Data< bool > showMovement; + + + /// the key times surrounding the current simulation time (for interpolation) + Real prevT, nextT; + ///the motions corresponding to the surrouding key times + Deriv prevM, nextM; + ///initial constrained DOFs position + VecCoord x0; + + /// 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: + LinearMovementProjectiveConstraint(); + ~LinearMovementProjectiveConstraint() override; + +public: + ///methods to add/remove some indices, keyTimes, keyMovement + void clearIndices(); + void addIndex(Index index); + void removeIndex(Index index); + void clearKeyMovements(); + + ///@brief Add a new key movement + /// @param time : the simulation time you want to set a movement (in sec) + /// @param movement : the corresponding motion + /// for instance, addKeyMovement(1.0, Deriv(5,0,0) ) will set a translation of 5 in x direction a time 1.0s + /// + void addKeyMovement(Real time, Deriv movement); + + /// -- Constraint interface + void init() override; + void reset() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; + + void draw(const core::visual::VisualParams* vparams) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); + + template + void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); + template + void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); + +private: + /// to keep the time corresponding to the key times + Real currentTime; + + /// to know if we found the key times + bool finished; + + /// find previous and next time keys + void findKeyTimes(); +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARMOVEMENTPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; +#endif + +template +using LinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearMovementConstraint has been renamed to LinearMovementProjectiveConstraint") = LinearMovementProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl new file mode 100644 index 00000000000..a5b6f81616b --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl @@ -0,0 +1,475 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +template +LinearMovementProjectiveConstraint::LinearMovementProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , data(new LinearMovementProjectiveConstraintInternalData) + , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) + , m_keyTimes( initData(&m_keyTimes,"keyTimes","key times for the movements") ) + , m_keyMovements( initData(&m_keyMovements,"movements","movements corresponding to the key times") ) + , d_relativeMovements( initData(&d_relativeMovements, bool(true), "relativeMovements", "If true, movements are relative to first position, absolute otherwise") ) + , showMovement( initData(&showMovement, bool(false), "showMovement", "Visualization of the movement to be applied to constrained dofs.")) + , l_topology(initLink("topology", "link to the topology container")) + , finished(false) +{ + // default to indice 0 + m_indices.beginEdit()->push_back(0); + m_indices.endEdit(); + + //default valueEvent to 0 + m_keyTimes.beginEdit()->push_back( 0.0 ); + m_keyTimes.endEdit(); + m_keyMovements.beginEdit()->push_back( Deriv() ); + m_keyMovements.endEdit(); +} + + + +template +LinearMovementProjectiveConstraint::~LinearMovementProjectiveConstraint() +{ + +} + +template +void LinearMovementProjectiveConstraint::clearIndices() +{ + m_indices.beginEdit()->clear(); + m_indices.endEdit(); +} + +template +void LinearMovementProjectiveConstraint::addIndex(Index index) +{ + m_indices.beginEdit()->push_back(index); + m_indices.endEdit(); +} + +template +void LinearMovementProjectiveConstraint::removeIndex(Index index) +{ + sofa::type::removeValue(*m_indices.beginEdit(),index); + m_indices.endEdit(); +} + +template +void LinearMovementProjectiveConstraint::clearKeyMovements() +{ + m_keyTimes.beginEdit()->clear(); + m_keyTimes.endEdit(); + m_keyMovements.beginEdit()->clear(); + m_keyMovements.endEdit(); +} + +template +void LinearMovementProjectiveConstraint::addKeyMovement(Real time, Deriv movement) +{ + m_keyTimes.beginEdit()->push_back( time ); + m_keyTimes.endEdit(); + m_keyMovements.beginEdit()->push_back( movement ); + m_keyMovements.endEdit(); +} + +// -- Constraint interface +template +void LinearMovementProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + m_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + x0.resize(0); + nextM = prevM = Deriv(); + + currentTime = -1.0; + finished = false; +} + + +template +void LinearMovementProjectiveConstraint::reset() +{ + nextT = prevT = 0.0; + nextM = prevM = Deriv(); + + currentTime = -1.0; + finished = false; +} + + +template +template +void LinearMovementProjectiveConstraint::projectResponseT(DataDeriv& dx, + const std::function& clear) +{ + Real cT = static_cast(this->getContext()->getTime()); + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + if (finished && nextT != prevT) + { + const SetIndexArray & indices = m_indices.getValue(); + + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + clear(dx, *it); + } + } +} + +template +void LinearMovementProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(), [](auto& dx, const unsigned int index) {dx[index].clear(); }); +} + +template +void LinearMovementProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + helper::WriteAccessor dx = vData; + Real cT = static_cast(this->getContext()->getTime()); + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + if (finished && nextT != prevT) + { + const SetIndexArray & indices = m_indices.getValue(); + + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + dx[*it] = (nextM - prevM)*(1.0 / (nextT - prevT)); + } + } +} + + +template +void LinearMovementProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + Real cT = static_cast(this->getContext()->getTime()); + + //initialize initial Dofs positions, if it's not done + if (x0.size() == 0) + { + const SetIndexArray & indices = m_indices.getValue(); + x0.resize(x.size()); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x0[*it] = x[*it]; + } + } + + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + //if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) + if(finished && nextT != prevT) + { + interpolatePosition(cT, x.wref()); + } +} + +template +template +void LinearMovementProjectiveConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) +{ + const SetIndexArray & indices = m_indices.getValue(); + + Real dt = (cT - prevT) / (nextT - prevT); + Deriv m = prevM + (nextM-prevM)*dt; + + //set the motion to the Dofs + if (d_relativeMovements.getValue()) + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it] = x0[*it] + m ; + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it] = m ; + } + } +} + +template +template +void LinearMovementProjectiveConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) +{ + const SetIndexArray & indices = m_indices.getValue(); + + Real dt = (cT - prevT) / (nextT - prevT); + Deriv m = prevM + (nextM-prevM)*dt; + type::Quat prevOrientation = type::Quat::createQuaterFromEuler(getVOrientation(prevM)); + type::Quat nextOrientation = type::Quat::createQuaterFromEuler(getVOrientation(nextM)); + + //set the motion to the Dofs + if (d_relativeMovements.getValue()) + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it].getCenter() = x0[*it].getCenter() + getVCenter(m) ; + x[*it].getOrientation() = x0[*it].getOrientation() * prevOrientation.slerp2(nextOrientation, dt); + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it].getCenter() = getVCenter(m) ; + x[*it].getOrientation() = prevOrientation.slerp2(nextOrientation, dt); + } + } +} + +template +void LinearMovementProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + + projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); +} + +template +void LinearMovementProjectiveConstraint::findKeyTimes() +{ + Real cT = static_cast(this->getContext()->getTime()); + finished = false; + + if(m_keyTimes.getValue().size() != 0 && cT >= *m_keyTimes.getValue().begin() && cT <= *m_keyTimes.getValue().rbegin()) + { + nextT = *m_keyTimes.getValue().begin(); + prevT = nextT; + + typename type::vector::const_iterator it_t = m_keyTimes.getValue().begin(); + typename VecDeriv::const_iterator it_m = m_keyMovements.getValue().begin(); + + //WARNING : we consider that the key-events are in chronological order + //here we search between which keyTimes we are, to know which are the motion to interpolate + while( it_t != m_keyTimes.getValue().end() && !finished) + { + if( *it_t <= cT) + { + prevT = *it_t; + prevM = *it_m; + } + else + { + nextT = *it_t; + nextM = *it_m; + finished = true; + } + ++it_t; + ++it_m; + } + } +} + + +template +void LinearMovementProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + static const unsigned blockSize = DataTypes::deriv_total_size; + + // clears the rows and columns associated with fixed particles + for (const auto id : m_indices.getValue()) + { + M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); + } + +} + + +// Matrix Integration interface +template +void LinearMovementProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) + { + const unsigned int N = Deriv::size(); + const SetIndexArray & indices = m_indices.getValue(); + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); + } + } +} + +template +void LinearMovementProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const int o = matrix->getGlobalOffset(this->mstate.get()); + if (o >= 0) + { + const unsigned int offset = (unsigned int)o; + const unsigned int N = Deriv::size(); + + const SetIndexArray & indices = m_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for (unsigned int c=0; cclear(offset + N * (*it) + c); + } + } +} + +template +void LinearMovementProjectiveConstraint::applyConstraint( + sofa::core::behavior::ZeroDirichletCondition* matrix) +{ + constexpr unsigned int N = Deriv::size(); + + for (const auto index : m_indices.getValue()) + { + for (unsigned int c = 0; c < N; ++c) + { + matrix->discardRowCol(N * index + c, N * index + c); + } + } +} + +//display the path the constrained dofs will go through +template +void LinearMovementProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels() || m_keyTimes.getValue().size() == 0) + return; + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); + + if (showMovement.getValue()) + { + vparams->drawTool()->disableLighting(); + + std::vector vertices; + + constexpr auto minDimensions = std::min(DataTypes::spatial_dimensions, 3u); + + const SetIndexArray & indices = m_indices.getValue(); + const VecDeriv& keyMovements = m_keyMovements.getValue(); + if (d_relativeMovements.getValue()) + { + for (unsigned int i = 0; i < m_keyMovements.getValue().size() - 1; i++) + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + const auto& tmp0 = DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i]); + const auto& tmp1 = DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i + 1]); + sofa::type::Vec3 v0, v1; + std::copy_n(tmp0.begin(), minDimensions, v0.begin()); + std::copy_n(tmp1.begin(), minDimensions, v1.begin()); + vertices.push_back(v0); + vertices.push_back(v1); + } + } + } + else + { + for (unsigned int i = 0; i < keyMovements.size() - 1; i++) + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + const auto& tmp0 = DataTypes::getDPos(keyMovements[i]); + const auto& tmp1 = DataTypes::getDPos(keyMovements[i + 1]); + sofa::type::Vec3 v0, v1; + std::copy_n(tmp0.begin(), minDimensions, v0.begin()); + std::copy_n(tmp1.begin(), minDimensions, v1.begin()); + vertices.push_back(v0); + vertices.push_back(v1); + } + } + } + vparams->drawTool()->drawLines(vertices, 10, color); + } + else + { + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + sofa::type::vector points; + type::Vec3 point; + const SetIndexArray & indices = m_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + point = DataTypes::getCPos(x[*it]); + points.push_back(point); + } + vparams->drawTool()->drawPoints(points, 10, color); + } + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h index e347423b33b..ea7a6b514e2 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h @@ -20,116 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - - -/** impose a motion to given DOFs (translation and rotation) - The motion between 2 key times is linearly interpolated -*/ -template -class LinearVelocityConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(LinearVelocityConstraint,TDataTypes),SOFA_TEMPLATE(core::behavior::ProjectiveConstraintSet,TDataTypes)); - - using Index = sofa::Index; - typedef TDataTypes DataTypes; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - -public : - /// indices of the DOFs the constraint is applied to - SetIndex d_indices; - /// the key frames when the motion is defined by the user - Data > d_keyTimes; - /// the motions corresponding to the key frames - Data d_keyVelocities; - /// the coordinates on which to applay velocities - SetIndex d_coordinates; - - /// the key times surrounding the current simulation time (for interpolation) - Real prevT, nextT; - ///the velocities corresponding to the surrouding key times - Deriv prevV, nextV; - ///position at the initial step for constrained DOFs position - VecCoord x0; - ///position at the previous step for constrained DOFs position - VecCoord xP; - - /// 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: - LinearVelocityConstraint(); - - virtual ~LinearVelocityConstraint(); -public: - ///methods to add/remove some indices, keyTimes, keyVelocity - void clearIndices(); - void addIndex(Index index); - void removeIndex(Index index); - void clearKeyVelocities(); - /**add a new key movement - @param time : the simulation time you want to set a movement (in sec) - @param movement : the corresponding motion - for instance, addKeyMovement(1.0, Deriv(5,0,0) ) will set a translation of 5 in x direction a time 1.0s - **/ - void addKeyVelocity(Real time, Deriv movement); - - - /// -- Constraint interface - void init() override; - void reset() override; - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void draw(const core::visual::VisualParams* vparams) override; - -private: - - /// to keep the time corresponding to the key times - Real currentTime; - - /// to know if we found the key times - bool finished; - - /// find previous and next time keys - void findKeyTimes(); -}; - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARVELOCITYCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl index 9457ccfcb94..bf7a13d8187 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl @@ -21,328 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - -template -LinearVelocityConstraint::LinearVelocityConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , d_indices( initData(&d_indices,"indices","Indices of the constrained points") ) - , d_keyTimes( initData(&d_keyTimes,"keyTimes","key times for the movements") ) - , d_keyVelocities( initData(&d_keyVelocities,"velocities","velocities corresponding to the key times") ) - , d_coordinates( initData(&d_coordinates, "coordinates", "coordinates on which to apply velocities") ) - , l_topology(initLink("topology", "link to the topology container")) - , finished(false) -{ - d_indices.beginEdit()->push_back(0); - d_indices.endEdit(); - - d_keyTimes.beginEdit()->push_back( 0.0 ); - d_keyTimes.endEdit(); - d_keyVelocities.beginEdit()->push_back( Deriv() ); - d_keyVelocities.endEdit(); -} - - -template -LinearVelocityConstraint::~LinearVelocityConstraint() -{ - -} - -template -void LinearVelocityConstraint::clearIndices() -{ - d_indices.beginEdit()->clear(); - d_indices.endEdit(); -} - -template -void LinearVelocityConstraint::addIndex(Index index) -{ - d_indices.beginEdit()->push_back(index); - d_indices.endEdit(); -} - -template -void LinearVelocityConstraint::removeIndex(Index index) -{ - sofa::type::removeValue(*d_indices.beginEdit(),index); - d_indices.endEdit(); -} - -template -void LinearVelocityConstraint::clearKeyVelocities() -{ - d_keyTimes.beginEdit()->clear(); - d_keyTimes.endEdit(); - d_keyVelocities.beginEdit()->clear(); - d_keyVelocities.endEdit(); -} - -template -void LinearVelocityConstraint::addKeyVelocity(Real time, Deriv movement) -{ - d_keyTimes.beginEdit()->push_back( time ); - d_keyTimes.endEdit(); - d_keyVelocities.beginEdit()->push_back( movement ); - d_keyVelocities.endEdit(); -} - -// -- Constraint interface - - -template -void LinearVelocityConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - d_indices.createTopologyHandler(_topology); - d_coordinates.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - x0.resize(0); - xP.resize(0); - nextV = prevV = Deriv(); - - currentTime = -1.0; - finished = false; -} - -template -void LinearVelocityConstraint::reset() -{ - nextT = prevT = 0.0; - nextV = prevV = Deriv(); - - currentTime = -1.0; - finished = false; -} - - -template -void LinearVelocityConstraint::projectResponse(const core::MechanicalParams* /*mparams*/, DataVecDeriv& resData) -{ - helper::WriteAccessor res = resData; - VecDeriv& dx = res.wref(); - - Real cT = (Real) this->getContext()->getTime(); - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - if (finished && nextT != prevT) - { - const SetIndexArray & indices = d_indices.getValue(); - - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - dx[*it] = Deriv(); - } - } - -} - -template -void LinearVelocityConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - helper::WriteAccessor dx = vData; - Real cT = (Real) this->getContext()->getTime(); - - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - if (finished && nextT != prevT) - { - //if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) - Deriv v = ((nextV - prevV)*((cT - prevT)/(nextT - prevT))) + prevV; - - const SetIndexArray & indices = d_indices.getValue(); - const SetIndexArray & coordinates = d_coordinates.getValue(); - - if (coordinates.size() == 0) - { - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - dx[*it] = v; - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for(SetIndexArray::const_iterator itInd = coordinates.begin(); itInd != coordinates.end(); ++itInd) - { - dx[*it][*itInd] = v[*itInd]; - } - } - } - } -} - - -template -void LinearVelocityConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - - //initialize initial Dofs positions, if it's not done - if (x0.size() == 0) - { - const SetIndexArray & indices = d_indices.getValue(); - x0.resize( x.size() ); - xP.resize( x.size() ); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x0[*it] = x[*it]; - xP[*it] = x0[*it]; - } - } - - Real cT = (Real) this->getContext()->getTime(); - - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - - Real dTsimu = (Real) this->getContext()->getDt(); - - - if(finished) - { - Real dt = (cT - prevT) / (nextT - prevT); - Deriv m = (nextV-prevV)*dt + prevV; - - const SetIndexArray & indices = d_indices.getValue(); - const SetIndexArray & coordinates = d_coordinates.getValue(); - - if (coordinates.size() == 0) - { - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it] = xP[*it] + m*dTsimu; - xP[*it] = x[*it]; - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for(SetIndexArray::const_iterator itInd = coordinates.begin(); itInd != coordinates.end(); ++itInd) - { - x[*it][*itInd] = xP[*it][*itInd] + m[*itInd]*dTsimu; - xP[*it] = x[*it]; - } - } - } - } -} - -template -void LinearVelocityConstraint::findKeyTimes() -{ - Real cT = (Real) this->getContext()->getTime(); - finished = false; - - if(d_keyTimes.getValue().size() != 0 && cT >= *d_keyTimes.getValue().begin() && cT <= *d_keyTimes.getValue().rbegin()) - { - nextT = *d_keyTimes.getValue().begin(); - prevT = nextT; - - typename type::vector::const_iterator it_t = d_keyTimes.getValue().begin(); - typename VecDeriv::const_iterator it_v = d_keyVelocities.getValue().begin(); - - //WARNING : we consider that the key-events are in chronological order - //here we search between which keyTimes we are, to know which are the motion to interpolate - while( it_t != d_keyTimes.getValue().end() && !finished) - { - if( *it_t <= cT) - { - prevT = *it_t; - prevV = *it_v; - } - else - { - nextT = *it_t; - nextV = *it_v; - finished = true; - } - ++it_t; - ++it_v; - } - } -}// LinearVelocityConstraint::findKeyTimes - -template -void LinearVelocityConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /*cData*/) -{ - -} - -//display the path the constrained dofs will go through -template -void LinearVelocityConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels() || d_keyTimes.getValue().size() == 0 ) return; - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - vparams->drawTool()->disableLighting(); - - std::vector vertices; - constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); - const VecDeriv& keyVelocities = d_keyVelocities.getValue(); - const SetIndexArray & indices = d_indices.getValue(); - for (unsigned int i=0 ; idrawTool()->drawLines(vertices, 1.0, color); - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp similarity index 74% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp index 163a066f18c..a8baf97606b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARVELOCITYCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARVELOCITYPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -32,19 +32,19 @@ using namespace sofa::defaulttype; using namespace sofa::helper; //declaration of the class, for the factory -int LinearVelocityConstraintClass = core::RegisterObject("apply velocity to given particles") - .add< LinearVelocityConstraint >() - .add< LinearVelocityConstraint >() - .add< LinearVelocityConstraint >() - .add< LinearVelocityConstraint >() - .add< LinearVelocityConstraint >() +int LinearVelocityProjectiveConstraintClass = core::RegisterObject("apply velocity to given particles") + .add< LinearVelocityProjectiveConstraint >() + .add< LinearVelocityProjectiveConstraint >() + .add< LinearVelocityProjectiveConstraint >() + .add< LinearVelocityProjectiveConstraint >() + .add< LinearVelocityProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h new file mode 100644 index 00000000000..7b3ab049b69 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h @@ -0,0 +1,138 @@ +/****************************************************************************** +* 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 +#include + +namespace sofa::component::constraint::projective +{ + + +/** impose a motion to given DOFs (translation and rotation) + The motion between 2 key times is linearly interpolated +*/ +template +class LinearVelocityProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(LinearVelocityProjectiveConstraint,TDataTypes),SOFA_TEMPLATE(core::behavior::ProjectiveConstraintSet,TDataTypes)); + + using Index = sofa::Index; + typedef TDataTypes DataTypes; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + +public : + /// indices of the DOFs the constraint is applied to + SetIndex d_indices; + /// the key frames when the motion is defined by the user + Data > d_keyTimes; + /// the motions corresponding to the key frames + Data d_keyVelocities; + /// the coordinates on which to applay velocities + SetIndex d_coordinates; + + /// the key times surrounding the current simulation time (for interpolation) + Real prevT, nextT; + ///the velocities corresponding to the surrouding key times + Deriv prevV, nextV; + ///position at the initial step for constrained DOFs position + VecCoord x0; + ///position at the previous step for constrained DOFs position + VecCoord xP; + + /// 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: + LinearVelocityProjectiveConstraint(); + + virtual ~LinearVelocityProjectiveConstraint(); +public: + ///methods to add/remove some indices, keyTimes, keyVelocity + void clearIndices(); + void addIndex(Index index); + void removeIndex(Index index); + void clearKeyVelocities(); + /**add a new key movement + @param time : the simulation time you want to set a movement (in sec) + @param movement : the corresponding motion + for instance, addKeyMovement(1.0, Deriv(5,0,0) ) will set a translation of 5 in x direction a time 1.0s + **/ + void addKeyVelocity(Real time, Deriv movement); + + + /// -- Constraint interface + void init() override; + void reset() override; + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void draw(const core::visual::VisualParams* vparams) override; + +private: + + /// to keep the time corresponding to the key times + Real currentTime; + + /// to know if we found the key times + bool finished; + + /// find previous and next time keys + void findKeyTimes(); +}; + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LINEARVELOCITYPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; + +#endif + +template +using LinearVelocityConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearVelocityConstraint has been renamed to LinearVelocityProjectiveConstraint") = LinearVelocityProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl new file mode 100644 index 00000000000..80ff4e51937 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl @@ -0,0 +1,348 @@ +/****************************************************************************** +* 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 + + +namespace sofa::component::constraint::projective +{ + +template +LinearVelocityProjectiveConstraint::LinearVelocityProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , d_indices( initData(&d_indices,"indices","Indices of the constrained points") ) + , d_keyTimes( initData(&d_keyTimes,"keyTimes","key times for the movements") ) + , d_keyVelocities( initData(&d_keyVelocities,"velocities","velocities corresponding to the key times") ) + , d_coordinates( initData(&d_coordinates, "coordinates", "coordinates on which to apply velocities") ) + , l_topology(initLink("topology", "link to the topology container")) + , finished(false) +{ + d_indices.beginEdit()->push_back(0); + d_indices.endEdit(); + + d_keyTimes.beginEdit()->push_back( 0.0 ); + d_keyTimes.endEdit(); + d_keyVelocities.beginEdit()->push_back( Deriv() ); + d_keyVelocities.endEdit(); +} + + +template +LinearVelocityProjectiveConstraint::~LinearVelocityProjectiveConstraint() +{ + +} + +template +void LinearVelocityProjectiveConstraint::clearIndices() +{ + d_indices.beginEdit()->clear(); + d_indices.endEdit(); +} + +template +void LinearVelocityProjectiveConstraint::addIndex(Index index) +{ + d_indices.beginEdit()->push_back(index); + d_indices.endEdit(); +} + +template +void LinearVelocityProjectiveConstraint::removeIndex(Index index) +{ + sofa::type::removeValue(*d_indices.beginEdit(),index); + d_indices.endEdit(); +} + +template +void LinearVelocityProjectiveConstraint::clearKeyVelocities() +{ + d_keyTimes.beginEdit()->clear(); + d_keyTimes.endEdit(); + d_keyVelocities.beginEdit()->clear(); + d_keyVelocities.endEdit(); +} + +template +void LinearVelocityProjectiveConstraint::addKeyVelocity(Real time, Deriv movement) +{ + d_keyTimes.beginEdit()->push_back( time ); + d_keyTimes.endEdit(); + d_keyVelocities.beginEdit()->push_back( movement ); + d_keyVelocities.endEdit(); +} + +// -- Constraint interface + + +template +void LinearVelocityProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); + d_coordinates.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + x0.resize(0); + xP.resize(0); + nextV = prevV = Deriv(); + + currentTime = -1.0; + finished = false; +} + +template +void LinearVelocityProjectiveConstraint::reset() +{ + nextT = prevT = 0.0; + nextV = prevV = Deriv(); + + currentTime = -1.0; + finished = false; +} + + +template +void LinearVelocityProjectiveConstraint::projectResponse(const core::MechanicalParams* /*mparams*/, DataVecDeriv& resData) +{ + helper::WriteAccessor res = resData; + VecDeriv& dx = res.wref(); + + Real cT = (Real) this->getContext()->getTime(); + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + if (finished && nextT != prevT) + { + const SetIndexArray & indices = d_indices.getValue(); + + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + dx[*it] = Deriv(); + } + } + +} + +template +void LinearVelocityProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + helper::WriteAccessor dx = vData; + Real cT = (Real) this->getContext()->getTime(); + + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + if (finished && nextT != prevT) + { + //if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) + Deriv v = ((nextV - prevV)*((cT - prevT)/(nextT - prevT))) + prevV; + + const SetIndexArray & indices = d_indices.getValue(); + const SetIndexArray & coordinates = d_coordinates.getValue(); + + if (coordinates.size() == 0) + { + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + dx[*it] = v; + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for(SetIndexArray::const_iterator itInd = coordinates.begin(); itInd != coordinates.end(); ++itInd) + { + dx[*it][*itInd] = v[*itInd]; + } + } + } + } +} + + +template +void LinearVelocityProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + + //initialize initial Dofs positions, if it's not done + if (x0.size() == 0) + { + const SetIndexArray & indices = d_indices.getValue(); + x0.resize( x.size() ); + xP.resize( x.size() ); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x0[*it] = x[*it]; + xP[*it] = x0[*it]; + } + } + + Real cT = (Real) this->getContext()->getTime(); + + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + + Real dTsimu = (Real) this->getContext()->getDt(); + + + if(finished) + { + Real dt = (cT - prevT) / (nextT - prevT); + Deriv m = (nextV-prevV)*dt + prevV; + + const SetIndexArray & indices = d_indices.getValue(); + const SetIndexArray & coordinates = d_coordinates.getValue(); + + if (coordinates.size() == 0) + { + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it] = xP[*it] + m*dTsimu; + xP[*it] = x[*it]; + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for(SetIndexArray::const_iterator itInd = coordinates.begin(); itInd != coordinates.end(); ++itInd) + { + x[*it][*itInd] = xP[*it][*itInd] + m[*itInd]*dTsimu; + xP[*it] = x[*it]; + } + } + } + } +} + +template +void LinearVelocityProjectiveConstraint::findKeyTimes() +{ + Real cT = (Real) this->getContext()->getTime(); + finished = false; + + if(d_keyTimes.getValue().size() != 0 && cT >= *d_keyTimes.getValue().begin() && cT <= *d_keyTimes.getValue().rbegin()) + { + nextT = *d_keyTimes.getValue().begin(); + prevT = nextT; + + typename type::vector::const_iterator it_t = d_keyTimes.getValue().begin(); + typename VecDeriv::const_iterator it_v = d_keyVelocities.getValue().begin(); + + //WARNING : we consider that the key-events are in chronological order + //here we search between which keyTimes we are, to know which are the motion to interpolate + while( it_t != d_keyTimes.getValue().end() && !finished) + { + if( *it_t <= cT) + { + prevT = *it_t; + prevV = *it_v; + } + else + { + nextT = *it_t; + nextV = *it_v; + finished = true; + } + ++it_t; + ++it_v; + } + } +}// LinearVelocityProjectiveConstraint::findKeyTimes + +template +void LinearVelocityProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /*cData*/) +{ + +} + +//display the path the constrained dofs will go through +template +void LinearVelocityProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels() || d_keyTimes.getValue().size() == 0 ) return; + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + vparams->drawTool()->disableLighting(); + + std::vector vertices; + constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); + const VecDeriv& keyVelocities = d_keyVelocities.getValue(); + const SetIndexArray & indices = d_indices.getValue(); + for (unsigned int i=0 ; idrawTool()->drawLines(vertices, 1.0, color); + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h index ab2389a61da..b014a222ce4 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h @@ -20,93 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - -/** - * Apply sinusoidal trajectories to particles. - * Defined as \f$ x = x_m A \sin ( \omega t + \phi )\f$ - * where \f$ x_m, A , \omega t , \phi \f$ are the mean value, the amplitude, the pulsation and the phase, respectively. - */ -template -class OscillatorConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(OscillatorConstraint,TDataTypes),SOFA_TEMPLATE(core::behavior::ProjectiveConstraintSet,TDataTypes)); - - typedef TDataTypes DataTypes; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - -protected: - struct Oscillator - { - unsigned int index; - Coord mean; - Deriv amplitude; - Real pulsation; - Real phase; - - Oscillator(); - Oscillator(unsigned int i, const Coord& m, const Deriv& a, - const Real& w, const Real& p); - - inline friend std::istream& operator >>(std::istream& in, Oscillator& o) - { - in >> o.index >> o.mean >> o.amplitude >> o.pulsation >> o.phase; - return in; - } - - inline friend std::ostream& operator <<(std::ostream& out, const Oscillator& o) - { - out << o.index << " " << o.mean << " " << o.amplitude << " " - << o.pulsation << " " << o.phase << "\n"; - return out; - } - }; - - Data< type::vector< Oscillator > > constraints; ///< constrained particles - - -public: - explicit OscillatorConstraint(core::behavior::MechanicalState* mstate=nullptr); - ~OscillatorConstraint() override ; - - OscillatorConstraint* addConstraint(unsigned index, - const Coord& mean, const Deriv& amplitude, - Real pulsation, Real phase); - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_OSCILLATORCONSTRAINT_CPP) -extern template class OscillatorConstraint; -extern template class OscillatorConstraint; -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl index 831e3468cfb..d9805d4210c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl @@ -21,107 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -OscillatorConstraint::OscillatorConstraint(core::behavior::MechanicalState* mstate) - : core::behavior::ProjectiveConstraintSet(mstate) - , constraints(initData(&constraints,"oscillators","Define a sequence of oscillating particules: \n[index, Mean(x,y,z), amplitude(x,y,z), pulsation, phase]")) -{ -} - -template -OscillatorConstraint::~OscillatorConstraint() -{ -} - -template -OscillatorConstraint* OscillatorConstraint::addConstraint(unsigned index, const Coord& mean, const Deriv& amplitude, Real pulsation, Real phase) -{ - this->constraints.beginEdit()->push_back( Oscillator(index,mean,amplitude,pulsation,phase) ); - return this; -} - - -template template -void OscillatorConstraint::projectResponseT(DataDeriv& res, - const std::function& clear) -{ - const auto& oscillators = constraints.getValue(); - - for (unsigned i = 0; i < oscillators.size(); ++i) - { - const unsigned& index = oscillators[i].index; - clear(res, index); - } -} - -template -void OscillatorConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(),[](VecDeriv& res, const unsigned int index) { res[index].clear(); }); -} - -template -void OscillatorConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - helper::WriteAccessor v = vData; - const type::vector& oscillators = constraints.getValue(); - Real t = (Real) this->getContext()->getTime(); - for (unsigned i = 0; i < oscillators.size(); ++i) - { - const unsigned& index = oscillators[i].index; - const Deriv& a = oscillators[i].amplitude; - const Real& w = oscillators[i].pulsation; - const Real& p = oscillators[i].phase; - - v[index] = a * w * cos(w * t + p); - } -} - -template -void OscillatorConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - const type::vector &oscillators = constraints.getValue(); - Real t = (Real) this->getContext()->getTime(); - for (unsigned i = 0; i < oscillators.size(); ++i) - { - const unsigned& index = oscillators[i].index; - const Coord& m = oscillators[i].mean; - const Deriv& a = oscillators[i].amplitude; - const Real& w = oscillators[i].pulsation; - const Real& p = oscillators[i].phase; - - x[index] = m + a * sin(w * t + p); - } -} - -template -void OscillatorConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); -} - -template -OscillatorConstraint::Oscillator::Oscillator(): index(0) -{ -} - -template -OscillatorConstraint::Oscillator::Oscillator(unsigned int i, const Coord& m, const Deriv& a, - const Real& w, const Real& p) : - index(i), mean(m), amplitude(a), pulsation(w), phase(p) -{ -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp similarity index 79% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp index 8edb65b5447..dc805487a32 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_OSCILLATORCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_OSCILLATORPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -31,11 +31,11 @@ namespace sofa::component::constraint::projective using namespace sofa::defaulttype; using namespace sofa::helper; -int OscillatorConstraintClass = core::RegisterObject("Apply a sinusoidal trajectory to given points") - .add< OscillatorConstraint >() - .add< OscillatorConstraint >(); +int OscillatorProjectiveConstraintClass = core::RegisterObject("Apply a sinusoidal trajectory to given points") + .add< OscillatorProjectiveConstraint >() + .add< OscillatorProjectiveConstraint >(); -template class OscillatorConstraint; -template class OscillatorConstraint; +template class OscillatorProjectiveConstraint; +template class OscillatorProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h new file mode 100644 index 00000000000..cedbc55efd2 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h @@ -0,0 +1,115 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +/** + * Apply sinusoidal trajectories to particles. + * Defined as \f$ x = x_m A \sin ( \omega t + \phi )\f$ + * where \f$ x_m, A , \omega t , \phi \f$ are the mean value, the amplitude, the pulsation and the phase, respectively. + */ +template +class OscillatorProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(OscillatorProjectiveConstraint,TDataTypes),SOFA_TEMPLATE(core::behavior::ProjectiveConstraintSet,TDataTypes)); + + typedef TDataTypes DataTypes; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + +protected: + struct Oscillator + { + unsigned int index; + Coord mean; + Deriv amplitude; + Real pulsation; + Real phase; + + Oscillator(); + Oscillator(unsigned int i, const Coord& m, const Deriv& a, + const Real& w, const Real& p); + + inline friend std::istream& operator >>(std::istream& in, Oscillator& o) + { + in >> o.index >> o.mean >> o.amplitude >> o.pulsation >> o.phase; + return in; + } + + inline friend std::ostream& operator <<(std::ostream& out, const Oscillator& o) + { + out << o.index << " " << o.mean << " " << o.amplitude << " " + << o.pulsation << " " << o.phase << "\n"; + return out; + } + }; + + Data< type::vector< Oscillator > > constraints; ///< constrained particles + + +public: + explicit OscillatorProjectiveConstraint(core::behavior::MechanicalState* mstate=nullptr); + ~OscillatorProjectiveConstraint() override ; + + OscillatorProjectiveConstraint* addConstraint(unsigned index, + const Coord& mean, const Deriv& amplitude, + Real pulsation, Real phase); + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_OSCILLATORPROJECTIVECONSTRAINT_CPP) +extern template class OscillatorProjectiveConstraint; +extern template class OscillatorProjectiveConstraint; +#endif + +template +using OscillatorConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "OscillatorConstraint has been renamed to OscillatorProjectiveConstraint") = OscillatorProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl new file mode 100644 index 00000000000..0f089b2eea1 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl @@ -0,0 +1,127 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +template +OscillatorProjectiveConstraint::OscillatorProjectiveConstraint(core::behavior::MechanicalState* mstate) + : core::behavior::ProjectiveConstraintSet(mstate) + , constraints(initData(&constraints,"oscillators","Define a sequence of oscillating particules: \n[index, Mean(x,y,z), amplitude(x,y,z), pulsation, phase]")) +{ +} + +template +OscillatorProjectiveConstraint::~OscillatorProjectiveConstraint() +{ +} + +template +OscillatorProjectiveConstraint* OscillatorProjectiveConstraint::addConstraint(unsigned index, const Coord& mean, const Deriv& amplitude, Real pulsation, Real phase) +{ + this->constraints.beginEdit()->push_back( Oscillator(index,mean,amplitude,pulsation,phase) ); + return this; +} + + +template template +void OscillatorProjectiveConstraint::projectResponseT(DataDeriv& res, + const std::function& clear) +{ + const auto& oscillators = constraints.getValue(); + + for (unsigned i = 0; i < oscillators.size(); ++i) + { + const unsigned& index = oscillators[i].index; + clear(res, index); + } +} + +template +void OscillatorProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(),[](VecDeriv& res, const unsigned int index) { res[index].clear(); }); +} + +template +void OscillatorProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + helper::WriteAccessor v = vData; + const type::vector& oscillators = constraints.getValue(); + Real t = (Real) this->getContext()->getTime(); + for (unsigned i = 0; i < oscillators.size(); ++i) + { + const unsigned& index = oscillators[i].index; + const Deriv& a = oscillators[i].amplitude; + const Real& w = oscillators[i].pulsation; + const Real& p = oscillators[i].phase; + + v[index] = a * w * cos(w * t + p); + } +} + +template +void OscillatorProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + const type::vector &oscillators = constraints.getValue(); + Real t = (Real) this->getContext()->getTime(); + for (unsigned i = 0; i < oscillators.size(); ++i) + { + const unsigned& index = oscillators[i].index; + const Coord& m = oscillators[i].mean; + const Deriv& a = oscillators[i].amplitude; + const Real& w = oscillators[i].pulsation; + const Real& p = oscillators[i].phase; + + x[index] = m + a * sin(w * t + p); + } +} + +template +void OscillatorProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); +} + +template +OscillatorProjectiveConstraint::Oscillator::Oscillator(): index(0) +{ +} + +template +OscillatorProjectiveConstraint::Oscillator::Oscillator(unsigned int i, const Coord& m, const Deriv& a, + const Real& w, const Real& p) : + index(i), mean(m), amplitude(a), pulsation(w), phase(p) +{ +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h index 4b6b1bc7c75..ac6a825815f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h @@ -20,108 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - -/** Apply a parabolic trajectory to particles going through 3 points specified by the user. - The DOFs set in the "indices" list follow the computed parabol from "tBegin" to "tEnd". - */ -template -class ParabolicConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(ParabolicConstraint,DataTypes),SOFA_TEMPLATE(core::behavior::ProjectiveConstraintSet,DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - typedef type::Vec<3, Real> Vec3R; - typedef type::Quat QuatR; - -protected: - ///indices of the DOFs constraints - SetIndex m_indices; - - /// the three points defining the parabol - Data m_P1; - Data m_P2; ///< second point of the parabol - Data m_P3; ///< third point of the parabol - - /// the time steps defining the velocity of the movement - Data m_tBegin; - Data m_tEnd; ///< End Time of the motion - - /// 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; - - /// the 3 points projected in the parabol plan - Vec3R m_locP1; - Vec3R m_locP2; - Vec3R m_locP3; - - /// the quaternion doing the projection - QuatR m_projection; - - explicit ParabolicConstraint(core::behavior::MechanicalState* mstate = nullptr); - - ~ParabolicConstraint(); -public: - void addConstraint(unsigned index ); - - void setP1(const Vec3R &p) {m_P1.setValue(p);} - void setP2(const Vec3R &p) {m_P2.setValue(p);} - void setP3(const Vec3R &p) {m_P3.setValue(p);} - - void setBeginTime(const Real &t) {m_tBegin.setValue(t);} - void setEndTime(const Real &t) {m_tEnd.setValue(t);} - - Vec3R getP1() {return m_P1.getValue();} - Vec3R getP2() {return m_P2.getValue();} - Vec3R getP3() {return m_P3.getValue();} - - Real getBeginTime() {return m_tBegin.getValue();} - Real getEndTime() {return m_tEnd.getValue();} - - /// -- Constraint interface - void init() override; - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void draw(const core::visual::VisualParams* vparams) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARABOLICCONSTRAINT_CPP) -extern template class ParabolicConstraint; -extern template class ParabolicConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl index e8b6489cc9c..711d390fcc7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl @@ -21,243 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -ParabolicConstraint::ParabolicConstraint(core::behavior::MechanicalState* mstate) - : core::behavior::ProjectiveConstraintSet(mstate) - , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) - , m_P1(initData(&m_P1,"P1","first point of the parabol") ) - , m_P2(initData(&m_P2,"P2","second point of the parabol") ) - , m_P3(initData(&m_P3,"P3","third point of the parabol") ) - , m_tBegin(initData(&m_tBegin,"BeginTime","Begin Time of the motion") ) - , m_tEnd(initData(&m_tEnd,"EndTime","End Time of the motion") ) - , l_topology(initLink("topology", "link to the topology container")) -{ -} - -template -ParabolicConstraint::~ParabolicConstraint() -{ -} - -template -void ParabolicConstraint::addConstraint(unsigned index) -{ - m_indices.beginEdit()->push_back(index); - m_indices.endEdit(); -} - - -template -void ParabolicConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize functions and parameters for topology data and handler - m_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - Vec3R P1 = m_P1.getValue(); - Vec3R P2 = m_P2.getValue(); - Vec3R P3 = m_P3.getValue(); - - //compute the projection to go in the parabol plan, - //such as P1 is the origin, P1P3 vector is the x axis, and P1P2 is in the xy plan - //by the way the computation of the parabol equation is much easier - if(P1 != P2 && P1 != P3 && P2 != P3) - { - - Vec3R P1P2 = P2 - P1; - Vec3R P1P3 = P3 - P1; - - Vec3R ax = P1P3; - Vec3R az = cross(P1P3, P1P2); - Vec3R ay = cross(az, ax); - ax.normalize(); - ay.normalize(); - az.normalize(); - - - type::Mat<3,3,Real> Mrot(ax, ay, az); - type::Mat<3,3,Real> Mrot2; - Mrot2.transpose(Mrot); - m_projection.fromMatrix(Mrot2); - m_projection.normalize(); - - m_locP1 = Vec3R(); - m_locP2 = m_projection.inverseRotate(P1P2); - m_locP3 = m_projection.inverseRotate(P1P3); - } -} - -template -void ParabolicConstraint::reinit() -{ - init(); -} - - -template -template -void ParabolicConstraint::projectResponseT(DataDeriv& dx, - const std::function& clear) -{ - Real t = (Real) this->getContext()->getTime(); - if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue()) - { - const SetIndexArray & indices = m_indices.getValue(); - for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - clear(dx, *it); - } -} - -template -void ParabolicConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(),[](VecDeriv& dx, const unsigned int index) { dx[index].clear(); }); -} - -template -void ParabolicConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - helper::WriteAccessor dx = vData; - Real t = (Real) this->getContext()->getTime(); - Real dt = (Real) this->getContext()->getDt(); - - if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) - { - Real relativeTime = (t - m_tBegin.getValue() ) / (m_tEnd.getValue() - m_tBegin.getValue()); - const SetIndexArray & indices = m_indices.getValue(); - - for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - //compute velocity by doing v = dx/dt - Real pxP = m_locP3.x()*relativeTime; - Real pyP = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (pxP *pxP) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * pxP; - relativeTime = (t+dt - m_tBegin.getValue() ) / (m_tEnd.getValue() - m_tBegin.getValue()); - Real pxN = m_locP3.x()*relativeTime; - Real pyN = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (pxN *pxN) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * pxN; - - Vec3R locVel = Vec3R( (pxN-pxP)/dt, (pyN-pyP)/dt, 0.0); - - Vec3R worldVel = m_projection.rotate(locVel); - - dx[*it] = worldVel; - } - } -} - -template -void ParabolicConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - Real t = (Real) this->getContext()->getTime(); - - if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) - { - Real relativeTime = (t - m_tBegin.getValue() ) / (m_tEnd.getValue() - m_tBegin.getValue()); - const SetIndexArray & indices = m_indices.getValue(); - - for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - //compute position from the equation of the parabol : Y = -y2/(x3*x2-x2�) * X� + (x3*y2)/(x3*x2-x2�) * X - //with P1:(0,0,0), P2:(x2,y2,z2), P3:(x3,y3,z3) , projected in parabol plan - Real px = m_locP3.x()*relativeTime; - Real py = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (px *px) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * px; - Vec3R locPos( px , py, 0.0); - - //projection to world coordinates - Vec3R worldPos = m_P1.getValue() + m_projection.rotate(locPos); - - x[*it] = worldPos; - } - } -} - -template -void ParabolicConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - - projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); -} - - -template -void ParabolicConstraint::draw(const core::visual::VisualParams* vparams) -{ - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - if (!vparams->displayFlags().getShowBehaviorModels()) return; - - Real dt = (Real) this->getContext()->getDt(); - Real t = m_tEnd.getValue() - m_tBegin.getValue(); - Real nbStep = t/dt; - - vparams->drawTool()->disableLighting(); - constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); - std::vector vertices; - - for (unsigned int i=0 ; i< nbStep ; i++) - { - //draw lines between each step of the parabolic trajectory - //so, the smaller is dt, the finer is the parabol - Real relativeTime = i/nbStep; - Real px = m_locP3.x()*relativeTime; - Real py = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (px *px) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * px; - Vec3R locPos( px , py, 0.0); - Vec3R worldPos = m_P1.getValue() + m_projection.rotate(locPos); - - vertices.push_back(sofa::type::Vec3(worldPos[0],worldPos[1],worldPos[2])); - - relativeTime = (i+1)/nbStep; - px = m_locP3.x()*relativeTime; - py = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (px *px) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * px; - locPos = Vec3R( px , py, 0.0); - worldPos = m_P1.getValue() + m_projection.rotate(locPos); - - - vertices.push_back(sofa::type::Vec3(worldPos[0],worldPos[1],worldPos[2])); - - } - vparams->drawTool()->drawLines(vertices, 1.0, color); - vertices.clear(); - - //draw points for the 3 control points - const Vec3R& mp1 = m_P1.getValue(); - const Vec3R& mp2 = m_P2.getValue(); - const Vec3R& mp3 = m_P3.getValue(); - vertices.push_back(sofa::type::Vec3(mp1[0],mp1[1],mp1[2])); - vertices.push_back(sofa::type::Vec3(mp2[0],mp2[1],mp2[2])); - vertices.push_back(sofa::type::Vec3(mp3[0],mp3[1],mp3[2])); - - vparams->drawTool()->drawPoints(vertices, 5.0, color); - - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp similarity index 77% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp index 15239ed4f36..a25f89e4a0a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARABOLICCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARABOLICPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -28,11 +28,11 @@ namespace sofa::component::constraint::projective { -int ParabolicConstraintClass = core::RegisterObject("Apply a parabolic trajectory to given points") - .add< ParabolicConstraint >() - .add< ParabolicConstraint >(); +int ParabolicProjectiveConstraintClass = core::RegisterObject("Apply a parabolic trajectory to given points") + .add< ParabolicProjectiveConstraint >() + .add< ParabolicProjectiveConstraint >(); -template class ParabolicConstraint; -template class ParabolicConstraint; +template class ParabolicProjectiveConstraint; +template class ParabolicProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h new file mode 100644 index 00000000000..28f60603a96 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h @@ -0,0 +1,130 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +/** Apply a parabolic trajectory to particles going through 3 points specified by the user. + The DOFs set in the "indices" list follow the computed parabol from "tBegin" to "tEnd". + */ +template +class ParabolicProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(ParabolicProjectiveConstraint,DataTypes),SOFA_TEMPLATE(core::behavior::ProjectiveConstraintSet,DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + typedef type::Vec<3, Real> Vec3R; + typedef type::Quat QuatR; + +protected: + ///indices of the DOFs constraints + SetIndex m_indices; + + /// the three points defining the parabol + Data m_P1; + Data m_P2; ///< second point of the parabol + Data m_P3; ///< third point of the parabol + + /// the time steps defining the velocity of the movement + Data m_tBegin; + Data m_tEnd; ///< End Time of the motion + + /// 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; + + /// the 3 points projected in the parabol plan + Vec3R m_locP1; + Vec3R m_locP2; + Vec3R m_locP3; + + /// the quaternion doing the projection + QuatR m_projection; + + explicit ParabolicProjectiveConstraint(core::behavior::MechanicalState* mstate = nullptr); + + ~ParabolicProjectiveConstraint(); +public: + void addConstraint(unsigned index ); + + void setP1(const Vec3R &p) {m_P1.setValue(p);} + void setP2(const Vec3R &p) {m_P2.setValue(p);} + void setP3(const Vec3R &p) {m_P3.setValue(p);} + + void setBeginTime(const Real &t) {m_tBegin.setValue(t);} + void setEndTime(const Real &t) {m_tEnd.setValue(t);} + + Vec3R getP1() {return m_P1.getValue();} + Vec3R getP2() {return m_P2.getValue();} + Vec3R getP3() {return m_P3.getValue();} + + Real getBeginTime() {return m_tBegin.getValue();} + Real getEndTime() {return m_tEnd.getValue();} + + /// -- Constraint interface + void init() override; + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void draw(const core::visual::VisualParams* vparams) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARABOLICPROJECTIVECONSTRAINT_CPP) +extern template class ParabolicProjectiveConstraint; +extern template class ParabolicProjectiveConstraint; + +#endif + +template +using ParabolicConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ParabolicConstraint has been renamed to ParabolicProjectiveConstraint") = ParabolicProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl new file mode 100644 index 00000000000..09a34cc7b9b --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl @@ -0,0 +1,263 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +template +ParabolicProjectiveConstraint::ParabolicProjectiveConstraint(core::behavior::MechanicalState* mstate) + : core::behavior::ProjectiveConstraintSet(mstate) + , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) + , m_P1(initData(&m_P1,"P1","first point of the parabol") ) + , m_P2(initData(&m_P2,"P2","second point of the parabol") ) + , m_P3(initData(&m_P3,"P3","third point of the parabol") ) + , m_tBegin(initData(&m_tBegin,"BeginTime","Begin Time of the motion") ) + , m_tEnd(initData(&m_tEnd,"EndTime","End Time of the motion") ) + , l_topology(initLink("topology", "link to the topology container")) +{ +} + +template +ParabolicProjectiveConstraint::~ParabolicProjectiveConstraint() +{ +} + +template +void ParabolicProjectiveConstraint::addConstraint(unsigned index) +{ + m_indices.beginEdit()->push_back(index); + m_indices.endEdit(); +} + + +template +void ParabolicProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize functions and parameters for topology data and handler + m_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + Vec3R P1 = m_P1.getValue(); + Vec3R P2 = m_P2.getValue(); + Vec3R P3 = m_P3.getValue(); + + //compute the projection to go in the parabol plan, + //such as P1 is the origin, P1P3 vector is the x axis, and P1P2 is in the xy plan + //by the way the computation of the parabol equation is much easier + if(P1 != P2 && P1 != P3 && P2 != P3) + { + + Vec3R P1P2 = P2 - P1; + Vec3R P1P3 = P3 - P1; + + Vec3R ax = P1P3; + Vec3R az = cross(P1P3, P1P2); + Vec3R ay = cross(az, ax); + ax.normalize(); + ay.normalize(); + az.normalize(); + + + type::Mat<3,3,Real> Mrot(ax, ay, az); + type::Mat<3,3,Real> Mrot2; + Mrot2.transpose(Mrot); + m_projection.fromMatrix(Mrot2); + m_projection.normalize(); + + m_locP1 = Vec3R(); + m_locP2 = m_projection.inverseRotate(P1P2); + m_locP3 = m_projection.inverseRotate(P1P3); + } +} + +template +void ParabolicProjectiveConstraint::reinit() +{ + init(); +} + + +template +template +void ParabolicProjectiveConstraint::projectResponseT(DataDeriv& dx, + const std::function& clear) +{ + Real t = (Real) this->getContext()->getTime(); + if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue()) + { + const SetIndexArray & indices = m_indices.getValue(); + for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + clear(dx, *it); + } +} + +template +void ParabolicProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(),[](VecDeriv& dx, const unsigned int index) { dx[index].clear(); }); +} + +template +void ParabolicProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + helper::WriteAccessor dx = vData; + Real t = (Real) this->getContext()->getTime(); + Real dt = (Real) this->getContext()->getDt(); + + if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) + { + Real relativeTime = (t - m_tBegin.getValue() ) / (m_tEnd.getValue() - m_tBegin.getValue()); + const SetIndexArray & indices = m_indices.getValue(); + + for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + //compute velocity by doing v = dx/dt + Real pxP = m_locP3.x()*relativeTime; + Real pyP = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (pxP *pxP) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * pxP; + relativeTime = (t+dt - m_tBegin.getValue() ) / (m_tEnd.getValue() - m_tBegin.getValue()); + Real pxN = m_locP3.x()*relativeTime; + Real pyN = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (pxN *pxN) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * pxN; + + Vec3R locVel = Vec3R( (pxN-pxP)/dt, (pyN-pyP)/dt, 0.0); + + Vec3R worldVel = m_projection.rotate(locVel); + + dx[*it] = worldVel; + } + } +} + +template +void ParabolicProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + Real t = (Real) this->getContext()->getTime(); + + if ( t >= m_tBegin.getValue() && t <= m_tEnd.getValue() ) + { + Real relativeTime = (t - m_tBegin.getValue() ) / (m_tEnd.getValue() - m_tBegin.getValue()); + const SetIndexArray & indices = m_indices.getValue(); + + for(SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + //compute position from the equation of the parabol : Y = -y2/(x3*x2-x2�) * X� + (x3*y2)/(x3*x2-x2�) * X + //with P1:(0,0,0), P2:(x2,y2,z2), P3:(x3,y3,z3) , projected in parabol plan + Real px = m_locP3.x()*relativeTime; + Real py = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (px *px) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * px; + Vec3R locPos( px , py, 0.0); + + //projection to world coordinates + Vec3R worldPos = m_P1.getValue() + m_projection.rotate(locPos); + + x[*it] = worldPos; + } + } +} + +template +void ParabolicProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + + projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); +} + + +template +void ParabolicProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + if (!vparams->displayFlags().getShowBehaviorModels()) return; + + Real dt = (Real) this->getContext()->getDt(); + Real t = m_tEnd.getValue() - m_tBegin.getValue(); + Real nbStep = t/dt; + + vparams->drawTool()->disableLighting(); + constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); + std::vector vertices; + + for (unsigned int i=0 ; i< nbStep ; i++) + { + //draw lines between each step of the parabolic trajectory + //so, the smaller is dt, the finer is the parabol + Real relativeTime = i/nbStep; + Real px = m_locP3.x()*relativeTime; + Real py = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (px *px) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * px; + Vec3R locPos( px , py, 0.0); + Vec3R worldPos = m_P1.getValue() + m_projection.rotate(locPos); + + vertices.push_back(sofa::type::Vec3(worldPos[0],worldPos[1],worldPos[2])); + + relativeTime = (i+1)/nbStep; + px = m_locP3.x()*relativeTime; + py = (- m_locP2.y() / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * (px *px) + ( (m_locP3.x()*m_locP2.y()) / (m_locP3.x()*m_locP2.x() - m_locP2.x()*m_locP2.x())) * px; + locPos = Vec3R( px , py, 0.0); + worldPos = m_P1.getValue() + m_projection.rotate(locPos); + + + vertices.push_back(sofa::type::Vec3(worldPos[0],worldPos[1],worldPos[2])); + + } + vparams->drawTool()->drawLines(vertices, 1.0, color); + vertices.clear(); + + //draw points for the 3 control points + const Vec3R& mp1 = m_P1.getValue(); + const Vec3R& mp2 = m_P2.getValue(); + const Vec3R& mp3 = m_P3.getValue(); + vertices.push_back(sofa::type::Vec3(mp1[0],mp1[1],mp1[2])); + vertices.push_back(sofa::type::Vec3(mp2[0],mp2[1],mp2[2])); + vertices.push_back(sofa::type::Vec3(mp3[0],mp3[1],mp3[2])); + + vparams->drawTool()->drawPoints(vertices, 5.0, color); + + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h index b54bdc2b611..0154ef31dc4 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h @@ -20,87 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/** - * Attach given particles to their initial positions, in some directions only. - * The fixed and free directioons are the same for all the particles, defined in the fixedDirections attribute. - **/ -template -class PartialFixedConstraint : public FixedConstraint -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(PartialFixedConstraint,DataTypes),SOFA_TEMPLATE(FixedConstraint, DataTypes)); - - typedef FixedConstraint Inherited; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - -public: - enum { NumDimensions = Deriv::total_size }; - typedef sofa::type::fixed_array VecBool; - Data d_fixedDirections; ///< Defines the directions in which the particles are fixed: true (or 1) for fixed, false (or 0) for free. - Data d_projectVelocity; ///< activate project velocity to set velocity to zero - -protected: - PartialFixedConstraint(); - virtual ~PartialFixedConstraint(); - -public: - - // -- Constraint interface - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); -}; - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALFIXEDCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl index 1e0a8bb8b9f..55ffbb891af 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl @@ -21,323 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - -template -PartialFixedConstraint::PartialFixedConstraint() - : d_fixedDirections( initData(&d_fixedDirections,"fixedDirections","for each direction, 1 if fixed, 0 if free") ) - , d_projectVelocity(initData(&d_projectVelocity, false, "projectVelocity", "project velocity to ensure no drift of the fixed point")) -{ - VecBool blockedDirection; - for( unsigned i=0; i -PartialFixedConstraint::~PartialFixedConstraint() -{ - //Parent class FixedConstraint already destruct : pointHandler and data -} - -template -void PartialFixedConstraint::reinit() -{ - this->Inherited::reinit(); -} - - -template -template -void PartialFixedConstraint::projectResponseT(DataDeriv& res, - const std::function& clear) -{ - const VecBool& blockedDirection = d_fixedDirections.getValue(); - - if (this->d_fixAll.getValue() == true) - { - // fix everything - for( std::size_t i=0; id_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - clear(res, *it, blockedDirection); - } - } -} - -template -void PartialFixedConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(), - [](VecDeriv& dx, const unsigned int index, const VecBool& b) - { - for (std::size_t j = 0; j < b.size(); j++) if (b[j]) dx[index][j] = 0.0; - } - ); -} - -// projectVelocity applies the same changes on velocity vector as projectResponse on position vector : -// Each fixed point received a null velocity vector. -// When a new fixed point is added while its velocity vector is already null, projectVelocity is not usefull. -// But when a new fixed point is added while its velocity vector is not null, it's necessary to fix it to null or -// to set the projectVelocity option to True. If not, the fixed point is going to drift. -template -void PartialFixedConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - SOFA_UNUSED(mparams); - - if(!d_projectVelocity.getValue()) return; - - const VecBool& blockedDirection = d_fixedDirections.getValue(); - helper::WriteAccessor res = vData; - - if ( this->d_fixAll.getValue() ) - { - // fix everyting - for (Size i = 0; i < res.size(); i++) - { - for (unsigned int c = 0; c < NumDimensions; ++c) - { - if (blockedDirection[c]) res[i][c] = 0; - } - } - } - else - { - const SetIndexArray & indices = this->d_indices.getValue(); - for(Index ind : indices) - { - for (unsigned int c = 0; c < NumDimensions; ++c) - { - if (blockedDirection[c]) - res[ind][c] = 0; - } - } - } -} - - -template -void PartialFixedConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - - projectResponseT(c.wref(), - [](MatrixDeriv& res, const unsigned int index, const VecBool& btype) - { - auto itRow = res.begin(); - auto itRowEnd = res.end(); - - while (itRow != itRowEnd) - { - for (auto colIt = itRow.begin(); colIt != itRow.end(); colIt++) - { - if (index == (unsigned int)colIt.index()) - { - Deriv b = colIt.val(); - for (unsigned int j = 0; j < btype.size(); j++) - if (btype[j]) b[j] = 0.0; - res.writeLine(itRow.index()).setCol(colIt.index(), b); - } - } - ++itRow; - } - }); -} - -template -void PartialFixedConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const int o = matrix->getGlobalOffset(this->mstate.get()); - if (o >= 0) - { - const unsigned int offset = (unsigned int)o; - const unsigned int N = Deriv::size(); - - const VecBool& blockedDirection = d_fixedDirections.getValue(); - - if( this->d_fixAll.getValue() ) - { - for(sofa::Index i=0; i<(sofa::Size) vector->size(); i++ ) - { - for (unsigned int c = 0; c < N; ++c) - { - if (blockedDirection[c]) - { - vector->clear(offset + N * i + c); - } - } - } - } - else - { - const SetIndexArray & indices = this->d_indices.getValue(); - for (const unsigned int index : indices) - { - for (unsigned int c = 0; c < N; ++c) - { - if (blockedDirection[c]) - { - vector->clear(offset + N * index + c); - } - } - } - } - } -} - -template -void PartialFixedConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) - { - const unsigned int N = Deriv::size(); - const VecBool& blockedDirection = d_fixedDirections.getValue(); - const SetIndexArray & indices = this->d_indices.getValue(); - - if( this->d_fixAll.getValue() ) - { - const unsigned size = this->mstate->getSize(); - for(unsigned int i=0; iclearRowCol(r.offset + N * i + c); - } - } - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * i + c, r.offset + N * i + c, 1.0); - } - } - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); - } - } - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); - } - } - } - } - } -} - -template -void PartialFixedConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - static const unsigned blockSize = DataTypes::deriv_total_size; - - const VecBool& blockedDirection = d_fixedDirections.getValue(); - - if( this->d_fixAll.getValue() ) - { - const unsigned size = this->mstate->getSize(); - for( unsigned i=0; iclearRowCol( offset + i * blockSize + c ); - } - } - } - } - else - { - const SetIndexArray & indices = this->d_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for (unsigned int c = 0; c < blockSize; ++c) - { - if (blockedDirection[c]) - { - M->clearRowCol( offset + (*it) * blockSize + c); - } - } - } - } -} - -template -void PartialFixedConstraint::applyConstraint( - sofa::core::behavior::ZeroDirichletCondition* matrix) -{ - static constexpr unsigned int N = Deriv::size(); - const VecBool& blockedDirection = d_fixedDirections.getValue(); - - if( this->d_fixAll.getValue() ) - { - const sofa::Size size = this->mstate->getSize(); - - for(sofa::Index i = 0; i < size; ++i) - { - for (unsigned int c=0; cdiscardRowCol(N * i + c, N * i + c); - } - } - } - } - else - { - const SetIndexArray & indices = this->d_indices.getValue(); - - for (const auto index : indices) - { - for (unsigned int c = 0; c < N; ++c) - { - if (blockedDirection[c]) - { - matrix->discardRowCol(N * index + c, N * index + c); - } - } - } - } -} -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp similarity index 72% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp index d28aae72e24..3a070fbc4d3 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALFIXEDCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALFIXEDPROJECTIVECONSTRAINT_CPP +#include #include #include @@ -31,21 +31,21 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int PartialFixedConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< PartialFixedConstraint >() - .add< PartialFixedConstraint >() - .add< PartialFixedConstraint >() - .add< PartialFixedConstraint >() - .add< PartialFixedConstraint >() - .add< PartialFixedConstraint >() +int PartialFixedProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< PartialFixedProjectiveConstraint >() + .add< PartialFixedProjectiveConstraint >() + .add< PartialFixedProjectiveConstraint >() + .add< PartialFixedProjectiveConstraint >() + .add< PartialFixedProjectiveConstraint >() + .add< PartialFixedProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h new file mode 100644 index 00000000000..71c31a7e1ff --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h @@ -0,0 +1,109 @@ +/****************************************************************************** +* 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 +#include + +namespace sofa::component::constraint::projective +{ + +/** + * Attach given particles to their initial positions, in some directions only. + * The fixed and free directioons are the same for all the particles, defined in the fixedDirections attribute. + **/ +template +class PartialFixedProjectiveConstraint : public FixedProjectiveConstraint +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(PartialFixedProjectiveConstraint,DataTypes),SOFA_TEMPLATE(FixedProjectiveConstraint, DataTypes)); + + typedef FixedProjectiveConstraint Inherited; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + +public: + enum { NumDimensions = Deriv::total_size }; + typedef sofa::type::fixed_array VecBool; + Data d_fixedDirections; ///< Defines the directions in which the particles are fixed: true (or 1) for fixed, false (or 0) for free. + Data d_projectVelocity; ///< activate project velocity to set velocity to zero + +protected: + PartialFixedProjectiveConstraint(); + virtual ~PartialFixedProjectiveConstraint(); + +public: + + // -- Constraint interface + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + void applyConstraint(sofa::core::behavior::ZeroDirichletCondition* matrix) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); +}; + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALFIXEDPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; + +#endif + +template +using PartialFixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialFixedConstraint has been renamed to PartialFixedProjectiveConstraint") = PartialFixedProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl new file mode 100644 index 00000000000..3c9b090d771 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl @@ -0,0 +1,343 @@ +/****************************************************************************** +* 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 + + +namespace sofa::component::constraint::projective +{ + +template +PartialFixedProjectiveConstraint::PartialFixedProjectiveConstraint() + : d_fixedDirections( initData(&d_fixedDirections,"fixedDirections","for each direction, 1 if fixed, 0 if free") ) + , d_projectVelocity(initData(&d_projectVelocity, false, "projectVelocity", "project velocity to ensure no drift of the fixed point")) +{ + VecBool blockedDirection; + for( unsigned i=0; i +PartialFixedProjectiveConstraint::~PartialFixedProjectiveConstraint() +{ + //Parent class FixedConstraint already destruct : pointHandler and data +} + +template +void PartialFixedProjectiveConstraint::reinit() +{ + this->Inherited::reinit(); +} + + +template +template +void PartialFixedProjectiveConstraint::projectResponseT(DataDeriv& res, + const std::function& clear) +{ + const VecBool& blockedDirection = d_fixedDirections.getValue(); + + if (this->d_fixAll.getValue() == true) + { + // fix everything + for( std::size_t i=0; id_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + clear(res, *it, blockedDirection); + } + } +} + +template +void PartialFixedProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(), + [](VecDeriv& dx, const unsigned int index, const VecBool& b) + { + for (std::size_t j = 0; j < b.size(); j++) if (b[j]) dx[index][j] = 0.0; + } + ); +} + +// projectVelocity applies the same changes on velocity vector as projectResponse on position vector : +// Each fixed point received a null velocity vector. +// When a new fixed point is added while its velocity vector is already null, projectVelocity is not usefull. +// But when a new fixed point is added while its velocity vector is not null, it's necessary to fix it to null or +// to set the projectVelocity option to True. If not, the fixed point is going to drift. +template +void PartialFixedProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + SOFA_UNUSED(mparams); + + if(!d_projectVelocity.getValue()) return; + + const VecBool& blockedDirection = d_fixedDirections.getValue(); + helper::WriteAccessor res = vData; + + if ( this->d_fixAll.getValue() ) + { + // fix everyting + for (Size i = 0; i < res.size(); i++) + { + for (unsigned int c = 0; c < NumDimensions; ++c) + { + if (blockedDirection[c]) res[i][c] = 0; + } + } + } + else + { + const SetIndexArray & indices = this->d_indices.getValue(); + for(Index ind : indices) + { + for (unsigned int c = 0; c < NumDimensions; ++c) + { + if (blockedDirection[c]) + res[ind][c] = 0; + } + } + } +} + + +template +void PartialFixedProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + + projectResponseT(c.wref(), + [](MatrixDeriv& res, const unsigned int index, const VecBool& btype) + { + auto itRow = res.begin(); + auto itRowEnd = res.end(); + + while (itRow != itRowEnd) + { + for (auto colIt = itRow.begin(); colIt != itRow.end(); colIt++) + { + if (index == (unsigned int)colIt.index()) + { + Deriv b = colIt.val(); + for (unsigned int j = 0; j < btype.size(); j++) + if (btype[j]) b[j] = 0.0; + res.writeLine(itRow.index()).setCol(colIt.index(), b); + } + } + ++itRow; + } + }); +} + +template +void PartialFixedProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const int o = matrix->getGlobalOffset(this->mstate.get()); + if (o >= 0) + { + const unsigned int offset = (unsigned int)o; + const unsigned int N = Deriv::size(); + + const VecBool& blockedDirection = d_fixedDirections.getValue(); + + if( this->d_fixAll.getValue() ) + { + for(sofa::Index i=0; i<(sofa::Size) vector->size(); i++ ) + { + for (unsigned int c = 0; c < N; ++c) + { + if (blockedDirection[c]) + { + vector->clear(offset + N * i + c); + } + } + } + } + else + { + const SetIndexArray & indices = this->d_indices.getValue(); + for (const unsigned int index : indices) + { + for (unsigned int c = 0; c < N; ++c) + { + if (blockedDirection[c]) + { + vector->clear(offset + N * index + c); + } + } + } + } + } +} + +template +void PartialFixedProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) + { + const unsigned int N = Deriv::size(); + const VecBool& blockedDirection = d_fixedDirections.getValue(); + const SetIndexArray & indices = this->d_indices.getValue(); + + if( this->d_fixAll.getValue() ) + { + const unsigned size = this->mstate->getSize(); + for(unsigned int i=0; iclearRowCol(r.offset + N * i + c); + } + } + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * i + c, r.offset + N * i + c, 1.0); + } + } + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); + } + } + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); + } + } + } + } + } +} + +template +void PartialFixedProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + static const unsigned blockSize = DataTypes::deriv_total_size; + + const VecBool& blockedDirection = d_fixedDirections.getValue(); + + if( this->d_fixAll.getValue() ) + { + const unsigned size = this->mstate->getSize(); + for( unsigned i=0; iclearRowCol( offset + i * blockSize + c ); + } + } + } + } + else + { + const SetIndexArray & indices = this->d_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for (unsigned int c = 0; c < blockSize; ++c) + { + if (blockedDirection[c]) + { + M->clearRowCol( offset + (*it) * blockSize + c); + } + } + } + } +} + +template +void PartialFixedProjectiveConstraint::applyConstraint( + sofa::core::behavior::ZeroDirichletCondition* matrix) +{ + static constexpr unsigned int N = Deriv::size(); + const VecBool& blockedDirection = d_fixedDirections.getValue(); + + if( this->d_fixAll.getValue() ) + { + const sofa::Size size = this->mstate->getSize(); + + for(sofa::Index i = 0; i < size; ++i) + { + for (unsigned int c=0; cdiscardRowCol(N * i + c, N * i + c); + } + } + } + } + else + { + const SetIndexArray & indices = this->d_indices.getValue(); + + for (const auto index : indices) + { + for (unsigned int c = 0; c < N; ++c) + { + if (blockedDirection[c]) + { + matrix->discardRowCol(N * index + c, N * index + c); + } + } + } + } +} +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h index 072548a5030..4a69e586d60 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h @@ -20,157 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -class PartialLinearMovementConstraintInternalData -{ -}; - -/** impose a motion to given DOFs (translation and rotation) in some directions only. - The moved and free directioons are the same for all the particles, defined in the movedDirections attribute. - The motion between 2 key times is linearly interpolated -*/ -template -class PartialLinearMovementConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(PartialLinearMovementConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); - - using Index = sofa::Index; - typedef TDataTypes DataTypes; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - -protected: - PartialLinearMovementConstraintInternalData *data; - friend class PartialLinearMovementConstraintInternalData; - -public : - /// indices of the DOFs the constraint is applied to - SetIndex m_indices; - /// the key frames when the motion is defined by the user - core::objectmodel::Data > m_keyTimes; - /// the motions corresponding to the key frames - core::objectmodel::Data m_keyMovements; - - /// attributes to precise display - /// if showMovement is true we display the expected movement - /// otherwise we show which are the fixed dofs - core::objectmodel::Data< bool > showMovement; - - /// the key times surrounding the current simulation time (for interpolation) - Real prevT, nextT; - ///the motions corresponding to the surrouding key times - Deriv prevM, nextM; - ///initial constrained DOFs position - VecCoord x0; - - core::objectmodel::Data linearMovementBetweenNodesInIndices; ///< Take into account the linear movement between the constrained points - core::objectmodel::Data mainIndice; ///< The main indice node in the list of constrained nodes, it defines how to apply the linear movement between this constrained nodes - core::objectmodel::Data minDepIndice; ///< The indice node in the list of constrained nodes, which is imposed the minimum displacment - core::objectmodel::Data maxDepIndice; ///< The indice node in the list of constrained nodes, which is imposed the maximum displacment - core::objectmodel::Data > m_imposedDisplacmentOnMacroNodes; ///< imposed displacement at u1 u2 u3 u4 for 2d case - ///< and u1 u2 u3 u4 u5 u6 u7 u8 for 3d case - Data X0; ///< Size of specimen in X-direction - Data Y0; ///< Size of specimen in Y-direction - Data Z0; ///< Size of specimen in Z-direction - - enum { NumDimensions = Deriv::total_size }; - typedef sofa::type::fixed_array VecBool; - core::objectmodel::Data movedDirections; ///< Defines the directions in which the particles are moved: true (or 1) for fixed, false (or 0) for free. - - /// 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: - PartialLinearMovementConstraint(); - ~PartialLinearMovementConstraint() override; - -public: - ///methods to add/remove some indices, keyTimes, keyMovement - void clearIndices(); - void addIndex(Index index); - void removeIndex(Index index); - void clearKeyMovements(); - - ///@brief Add a new key movement - ///@param time : the simulation time you want to set a movement (in sec) - ///@param movement : the corresponding motion - ///for instance, addKeyMovement(1.0, Deriv(5,0,0) ) will set a translation of 5 in x direction a time 1.0s - void addKeyMovement(Real time, Deriv movement); - - - /// -- Constraint interface - void init() override; - void reset() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - void draw(const core::visual::VisualParams*) override; - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); - - template - void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); - template - void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); - -private: - - /// to keep the time corresponding to the key times - Real currentTime; - - /// to know if we found the key times - bool finished; - - /// find previous and next time keys - void findKeyTimes(); -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALLINEARMOVEMENTCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl index 08bd3e7df9d..cf9428c4888 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl @@ -21,487 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - -template -PartialLinearMovementConstraint::PartialLinearMovementConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , data(new PartialLinearMovementConstraintInternalData) - , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) - , m_keyTimes( initData(&m_keyTimes,"keyTimes","key times for the movements") ) - , m_keyMovements( initData(&m_keyMovements,"movements","movements corresponding to the key times") ) - , showMovement( initData(&showMovement, (bool)false, "showMovement", "Visualization of the movement to be applied to constrained dofs.")) - , linearMovementBetweenNodesInIndices( initData(&linearMovementBetweenNodesInIndices, (bool)false, "linearMovementBetweenNodesInIndices", "Take into account the linear movement between the constrained points")) - , mainIndice( initData(&mainIndice, "mainIndice", "The main indice node in the list of constrained nodes, it defines how to apply the linear movement between this constrained nodes ")) - , minDepIndice( initData(&minDepIndice, "minDepIndice", "The indice node in the list of constrained nodes, which is imposed the minimum displacment ")) - , maxDepIndice( initData(&maxDepIndice, "maxDepIndice", "The indice node in the list of constrained nodes, which is imposed the maximum displacment ")) - , m_imposedDisplacmentOnMacroNodes( initData(&m_imposedDisplacmentOnMacroNodes,"imposedDisplacmentOnMacroNodes","The imposed displacment on macro nodes") ) - , X0 ( initData ( &X0, Real(0.0),"X0","Size of specimen in X-direction" ) ) - , Y0 ( initData ( &Y0, Real(0.0),"Y0","Size of specimen in Y-direction" ) ) - , Z0 ( initData ( &Z0, Real(0.0),"Z0","Size of specimen in Z-direction" ) ) - , movedDirections( initData(&movedDirections,"movedDirections","for each direction, 1 if moved, 0 if free") ) - , l_topology(initLink("topology", "link to the topology container")) - , finished(false) -{ - // default to indice 0 - m_indices.beginEdit()->push_back(0); - m_indices.endEdit(); - - //default valueEvent to 0 - m_keyTimes.beginEdit()->push_back( 0.0 ); - m_keyTimes.endEdit(); - m_keyMovements.beginEdit()->push_back( Deriv() ); - m_keyMovements.endEdit(); - VecBool movedDirection; - for( unsigned i=0; i -PartialLinearMovementConstraint::~PartialLinearMovementConstraint() -{ - -} - -template -void PartialLinearMovementConstraint::clearIndices() -{ - m_indices.beginEdit()->clear(); - m_indices.endEdit(); -} - -template -void PartialLinearMovementConstraint::addIndex(Index index) -{ - m_indices.beginEdit()->push_back(index); - m_indices.endEdit(); -} - -template -void PartialLinearMovementConstraint::removeIndex(Index index) -{ - sofa::type::removeValue(*m_indices.beginEdit(),index); - m_indices.endEdit(); -} - -template -void PartialLinearMovementConstraint::clearKeyMovements() -{ - m_keyTimes.beginEdit()->clear(); - m_keyTimes.endEdit(); - m_keyMovements.beginEdit()->clear(); - m_keyMovements.endEdit(); -} - -template -void PartialLinearMovementConstraint::addKeyMovement(Real time, Deriv movement) -{ - m_keyTimes.beginEdit()->push_back( time ); - m_keyTimes.endEdit(); - m_keyMovements.beginEdit()->push_back( movement ); - m_keyMovements.endEdit(); -} - -// -- Constraint interface - - -template -void PartialLinearMovementConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - m_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - x0.resize(0); - nextM = prevM = Deriv(); - - currentTime = -1.0; - finished = false; -} - - -template -void PartialLinearMovementConstraint::reset() -{ - nextT = prevT = 0.0; - nextM = prevM = Deriv(); - - currentTime = -1.0; - finished = false; -} - - -template -template -void PartialLinearMovementConstraint::projectResponseT(DataDeriv& dx, - const std::function& clear) -{ - Real cT = (Real) this->getContext()->getTime(); - VecBool movedDirection = movedDirections.getValue(); - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - if (finished && nextT != prevT) - { - const SetIndexArray & indices = m_indices.getValue(); - - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - clear(dx, *it, movedDirection); - } - } -} - -template -void PartialLinearMovementConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseT(res.wref(), [](VecDeriv& dx, const unsigned int index, const VecBool& b) - { for (unsigned j = 0; j < b.size(); j++) if (b[j]) dx[index][j] = 0.0; }); -} - -template -void PartialLinearMovementConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - helper::WriteAccessor dx = vData; - Real cT = (Real) this->getContext()->getTime(); - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - if (finished && nextT != prevT) - { - const SetIndexArray & indices = m_indices.getValue(); - - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - dx[*it] = (nextM - prevM)*(1.0 / (nextT - prevT)); - } - } -} - - -template -void PartialLinearMovementConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - helper::WriteAccessor x = xData; - Real cT = (Real) this->getContext()->getTime(); - - //initialize initial Dofs positions, if it's not done - if (x0.size() == 0) - { - const SetIndexArray & indices = m_indices.getValue(); - x0.resize(x.size()); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x0[*it] = x[*it]; - } - } - - if ((cT != currentTime) || !finished) - { - findKeyTimes(); - } - - //if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) - if(finished && nextT != prevT) - { - interpolatePosition(cT, x.wref()); - } -} - -template -template -void PartialLinearMovementConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) -{ - const SetIndexArray & indices = m_indices.getValue(); - Real dt = (cT - prevT) / (nextT - prevT); - Deriv m = prevM + (nextM-prevM)*dt; - VecBool movedDirection = movedDirections.getValue(); - //set the motion to the Dofs - if(linearMovementBetweenNodesInIndices.getValue()) - { - - const type::vector &imposedDisplacmentOnMacroNodes = this->m_imposedDisplacmentOnMacroNodes.getValue(); - Real a = X0.getValue(); - Real b = Y0.getValue(); - Real c = Z0.getValue(); - bool case2d=false; - if((a==0.0)||(b==0.0)||(c==0.0)) case2d=true; - if(a==0.0) {a=b; b=c;} - if(b==0.0) {b=c;} - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for( unsigned j=0; j< NumDimensions; j++) - { - if(movedDirection[j]) - { - if(case2d) - { - x[*it][j] = x0[*it][j] + ((Real)1.0/(a*b))*((a-x0[*it][0])*(b-x0[*it][1])*imposedDisplacmentOnMacroNodes[0]+ ///< N1 - x0[*it][0]*(b-x0[*it][1])*imposedDisplacmentOnMacroNodes[1]+ ///< N2 - x0[*it][0]*x0[*it][1]*imposedDisplacmentOnMacroNodes[2]+ ///< N3 - (a-x0[*it][0])*x0[*it][1]*imposedDisplacmentOnMacroNodes[3])*m[j]; ///< N4 - // 4|----------------|3 - // | | - // | | - // | | - // 1|----------------|2 - } - else ///< case3d - { - // |Y - // 5---------8 - // /| /| - // / | / | - // 6--|------7 | - // | |/ | | - // | 1------|--4--->X - // | / | / - // |/ |/ - // 2---------3 - // Z/ - // - - x[*it][j] = x0[*it][j] + ((Real)1.0/(a*b*c))*( - (a-x0[*it][0])*(b-x0[*it][1])*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[0]+ ///< N1 - (a-x0[*it][0])*(b-x0[*it][1])*x0[*it][2]*imposedDisplacmentOnMacroNodes[1]+ ///< N2 - x0[*it][0]*(b-x0[*it][1])*x0[*it][2]*imposedDisplacmentOnMacroNodes[2]+ ///< N3 - x0[*it][0]*(b-x0[*it][1])*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[3]+ ///< N4 - (a-x0[*it][0])*x0[*it][1]*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[4]+ ///< N5 - (a-x0[*it][0])*x0[*it][1]*x0[*it][2]*imposedDisplacmentOnMacroNodes[5]+ ///< N6 - x0[*it][0]*x0[*it][1]*x0[*it][2]*imposedDisplacmentOnMacroNodes[6]+ ///< N7 - x0[*it][0]*x0[*it][1]*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[7] ///< N8 - - )*m[j]; - - } - } - } - } - - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for( unsigned j=0; j< NumDimensions; j++) - if(movedDirection[j]) x[*it][j] = x0[*it][j] + m[j] ; - } - } - -} - -template -template -void PartialLinearMovementConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) -{ - const SetIndexArray & indices = m_indices.getValue(); - - Real dt = (cT - prevT) / (nextT - prevT); - Deriv m = prevM + (nextM-prevM)*dt; - type::Quat prevOrientation = type::Quat::createQuaterFromEuler(getVOrientation(prevM)); - type::Quat nextOrientation = type::Quat::createQuaterFromEuler(getVOrientation(nextM)); - - //set the motion to the Dofs - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - x[*it].getCenter() = x0[*it].getCenter() + getVCenter(m) ; - x[*it].getOrientation() = x0[*it].getOrientation() * prevOrientation.slerp2(nextOrientation, dt); - } -} - -template -void PartialLinearMovementConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c = cData; - projectResponseT(c.wref(), - [](MatrixDeriv& res, const unsigned int index, const VecBool& btype) - { - auto itRow = res.begin(); - auto itRowEnd = res.end(); - - while (itRow != itRowEnd) - { - for (auto colIt = itRow.begin(); colIt != itRow.end(); colIt++) - { - if (index == (unsigned int)colIt.index()) - { - Deriv b = colIt.val(); - for (unsigned int j = 0; j < btype.size(); j++) if (btype[j]) b[j] = 0.0; - res.writeLine(itRow.index()).setCol(colIt.index(), b); - } - } - } - }); -} - -template -void PartialLinearMovementConstraint::findKeyTimes() -{ - Real cT = (Real) this->getContext()->getTime(); - finished = false; - - if(m_keyTimes.getValue().size() != 0 && cT >= *m_keyTimes.getValue().begin() && cT <= *m_keyTimes.getValue().rbegin()) - { - nextT = *m_keyTimes.getValue().begin(); - prevT = nextT; - - typename type::vector::const_iterator it_t = m_keyTimes.getValue().begin(); - typename VecDeriv::const_iterator it_m = m_keyMovements.getValue().begin(); - - //WARNING : we consider that the key-events are in chronological order - //here we search between which keyTimes we are, to know which are the motion to interpolate - while( it_t != m_keyTimes.getValue().end() && !finished) - { - if( *it_t <= cT) - { - prevT = *it_t; - prevM = *it_m; - } - else - { - nextT = *it_t; - nextM = *it_m; - finished = true; - } - ++it_t; - ++it_m; - } - } -} - -// Matrix Integration interface -template -void PartialLinearMovementConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const SetIndexArray & indices = m_indices.getValue(); - - if (core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) - { - VecBool movedDirection = movedDirections.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(r.offset + NumDimensions * (*it) + c); - } - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + NumDimensions * (*it) + c, r.offset + NumDimensions * (*it) + c, 1.0); - } - } - } -} - -template -void PartialLinearMovementConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const int o = matrix->getGlobalOffset(this->mstate.get()); - if (o >= 0) { - unsigned int offset = (unsigned int)o; - VecBool movedDirection = movedDirections.getValue(); - const SetIndexArray & indices = m_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for (unsigned int c = 0; c < NumDimensions; ++c) - { - if (movedDirection[c]) - { - vector->clear(offset + NumDimensions * (*it) + c); - } - } - } - } -} - -//display the path the constrained dofs will go through -template -void PartialLinearMovementConstraint::draw(const core::visual::VisualParams* vparams) -{ - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - if (!vparams->displayFlags().getShowBehaviorModels() || m_keyTimes.getValue().size() == 0) - return; - - sofa::type::vector vertices; - constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); - - if (showMovement.getValue()) - { - vparams->drawTool()->disableLighting(); - - const SetIndexArray & indices = m_indices.getValue(); - const VecDeriv& keyMovements = m_keyMovements.getValue(); - for (unsigned int i = 0; i < keyMovements.size() - 1; i++) - { - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - const type::Vec3 v0 { DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i]) }; - const type::Vec3 v1 { DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i + 1]) }; - - vertices.push_back(v0); - vertices.push_back(v1); - } - } - vparams->drawTool()->drawLines(vertices, 1, color); - } - else - { - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - type::Vec3 point; - const SetIndexArray & indices = m_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - point = DataTypes::getCPos(x[*it]); - vertices.push_back(point); - } - vparams->drawTool()->drawPoints(vertices, 10, color); - } - - -} -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp similarity index 73% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp index 694c399bc9c..896e5bb385f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALLINEARMOVEMENTCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALLINEARMOVEMENTPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -29,19 +29,19 @@ namespace sofa::component::constraint::projective { //declaration of the class, for the factory -int PartialLinearMovementConstraintClass = core::RegisterObject("translate given particles") - .add< PartialLinearMovementConstraint >() - .add< PartialLinearMovementConstraint >() - .add< PartialLinearMovementConstraint >() - .add< PartialLinearMovementConstraint >() - .add< PartialLinearMovementConstraint >() +int PartialLinearMovementProjectiveConstraintClass = core::RegisterObject("translate given particles") + .add< PartialLinearMovementProjectiveConstraint >() + .add< PartialLinearMovementProjectiveConstraint >() + .add< PartialLinearMovementProjectiveConstraint >() + .add< PartialLinearMovementProjectiveConstraint >() + .add< PartialLinearMovementProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h new file mode 100644 index 00000000000..f8f95983474 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h @@ -0,0 +1,179 @@ +/****************************************************************************** +* 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 +#include +#include +#include + +namespace sofa::component::constraint::projective +{ + +template +class PartialLinearMovementProjectiveConstraintInternalData +{ +}; + +/** impose a motion to given DOFs (translation and rotation) in some directions only. + The moved and free directioons are the same for all the particles, defined in the movedDirections attribute. + The motion between 2 key times is linearly interpolated +*/ +template +class PartialLinearMovementProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(PartialLinearMovementProjectiveConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); + + using Index = sofa::Index; + typedef TDataTypes DataTypes; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + +protected: + PartialLinearMovementProjectiveConstraintInternalData *data; + friend class PartialLinearMovementProjectiveConstraintInternalData; + +public : + /// indices of the DOFs the constraint is applied to + SetIndex m_indices; + /// the key frames when the motion is defined by the user + core::objectmodel::Data > m_keyTimes; + /// the motions corresponding to the key frames + core::objectmodel::Data m_keyMovements; + + /// attributes to precise display + /// if showMovement is true we display the expected movement + /// otherwise we show which are the fixed dofs + core::objectmodel::Data< bool > showMovement; + + /// the key times surrounding the current simulation time (for interpolation) + Real prevT, nextT; + ///the motions corresponding to the surrouding key times + Deriv prevM, nextM; + ///initial constrained DOFs position + VecCoord x0; + + core::objectmodel::Data linearMovementBetweenNodesInIndices; ///< Take into account the linear movement between the constrained points + core::objectmodel::Data mainIndice; ///< The main indice node in the list of constrained nodes, it defines how to apply the linear movement between this constrained nodes + core::objectmodel::Data minDepIndice; ///< The indice node in the list of constrained nodes, which is imposed the minimum displacment + core::objectmodel::Data maxDepIndice; ///< The indice node in the list of constrained nodes, which is imposed the maximum displacment + core::objectmodel::Data > m_imposedDisplacmentOnMacroNodes; ///< imposed displacement at u1 u2 u3 u4 for 2d case + ///< and u1 u2 u3 u4 u5 u6 u7 u8 for 3d case + Data X0; ///< Size of specimen in X-direction + Data Y0; ///< Size of specimen in Y-direction + Data Z0; ///< Size of specimen in Z-direction + + enum { NumDimensions = Deriv::total_size }; + typedef sofa::type::fixed_array VecBool; + core::objectmodel::Data movedDirections; ///< Defines the directions in which the particles are moved: true (or 1) for fixed, false (or 0) for free. + + /// 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: + PartialLinearMovementProjectiveConstraint(); + ~PartialLinearMovementProjectiveConstraint() override; + +public: + ///methods to add/remove some indices, keyTimes, keyMovement + void clearIndices(); + void addIndex(Index index); + void removeIndex(Index index); + void clearKeyMovements(); + + ///@brief Add a new key movement + ///@param time : the simulation time you want to set a movement (in sec) + ///@param movement : the corresponding motion + ///for instance, addKeyMovement(1.0, Deriv(5,0,0) ) will set a translation of 5 in x direction a time 1.0s + void addKeyMovement(Real time, Deriv movement); + + + /// -- Constraint interface + void init() override; + void reset() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + void draw(const core::visual::VisualParams*) override; + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); + + template + void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); + template + void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); + +private: + + /// to keep the time corresponding to the key times + Real currentTime; + + /// to know if we found the key times + bool finished; + + /// find previous and next time keys + void findKeyTimes(); +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARTIALLINEARMOVEMENTPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; +#endif + +template +using PartialLinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialLinearMovementConstraint has been renamed to PartialLinearMovementProjectiveConstraint") = PartialLinearMovementProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl new file mode 100644 index 00000000000..af02bb262d2 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl @@ -0,0 +1,507 @@ +/****************************************************************************** +* 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 + + +namespace sofa::component::constraint::projective +{ + +template +PartialLinearMovementProjectiveConstraint::PartialLinearMovementProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , data(new PartialLinearMovementProjectiveConstraintInternalData) + , m_indices( initData(&m_indices,"indices","Indices of the constrained points") ) + , m_keyTimes( initData(&m_keyTimes,"keyTimes","key times for the movements") ) + , m_keyMovements( initData(&m_keyMovements,"movements","movements corresponding to the key times") ) + , showMovement( initData(&showMovement, (bool)false, "showMovement", "Visualization of the movement to be applied to constrained dofs.")) + , linearMovementBetweenNodesInIndices( initData(&linearMovementBetweenNodesInIndices, (bool)false, "linearMovementBetweenNodesInIndices", "Take into account the linear movement between the constrained points")) + , mainIndice( initData(&mainIndice, "mainIndice", "The main indice node in the list of constrained nodes, it defines how to apply the linear movement between this constrained nodes ")) + , minDepIndice( initData(&minDepIndice, "minDepIndice", "The indice node in the list of constrained nodes, which is imposed the minimum displacment ")) + , maxDepIndice( initData(&maxDepIndice, "maxDepIndice", "The indice node in the list of constrained nodes, which is imposed the maximum displacment ")) + , m_imposedDisplacmentOnMacroNodes( initData(&m_imposedDisplacmentOnMacroNodes,"imposedDisplacmentOnMacroNodes","The imposed displacment on macro nodes") ) + , X0 ( initData ( &X0, Real(0.0),"X0","Size of specimen in X-direction" ) ) + , Y0 ( initData ( &Y0, Real(0.0),"Y0","Size of specimen in Y-direction" ) ) + , Z0 ( initData ( &Z0, Real(0.0),"Z0","Size of specimen in Z-direction" ) ) + , movedDirections( initData(&movedDirections,"movedDirections","for each direction, 1 if moved, 0 if free") ) + , l_topology(initLink("topology", "link to the topology container")) + , finished(false) +{ + // default to indice 0 + m_indices.beginEdit()->push_back(0); + m_indices.endEdit(); + + //default valueEvent to 0 + m_keyTimes.beginEdit()->push_back( 0.0 ); + m_keyTimes.endEdit(); + m_keyMovements.beginEdit()->push_back( Deriv() ); + m_keyMovements.endEdit(); + VecBool movedDirection; + for( unsigned i=0; i +PartialLinearMovementProjectiveConstraint::~PartialLinearMovementProjectiveConstraint() +{ + +} + +template +void PartialLinearMovementProjectiveConstraint::clearIndices() +{ + m_indices.beginEdit()->clear(); + m_indices.endEdit(); +} + +template +void PartialLinearMovementProjectiveConstraint::addIndex(Index index) +{ + m_indices.beginEdit()->push_back(index); + m_indices.endEdit(); +} + +template +void PartialLinearMovementProjectiveConstraint::removeIndex(Index index) +{ + sofa::type::removeValue(*m_indices.beginEdit(),index); + m_indices.endEdit(); +} + +template +void PartialLinearMovementProjectiveConstraint::clearKeyMovements() +{ + m_keyTimes.beginEdit()->clear(); + m_keyTimes.endEdit(); + m_keyMovements.beginEdit()->clear(); + m_keyMovements.endEdit(); +} + +template +void PartialLinearMovementProjectiveConstraint::addKeyMovement(Real time, Deriv movement) +{ + m_keyTimes.beginEdit()->push_back( time ); + m_keyTimes.endEdit(); + m_keyMovements.beginEdit()->push_back( movement ); + m_keyMovements.endEdit(); +} + +// -- Constraint interface + + +template +void PartialLinearMovementProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + m_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + x0.resize(0); + nextM = prevM = Deriv(); + + currentTime = -1.0; + finished = false; +} + + +template +void PartialLinearMovementProjectiveConstraint::reset() +{ + nextT = prevT = 0.0; + nextM = prevM = Deriv(); + + currentTime = -1.0; + finished = false; +} + + +template +template +void PartialLinearMovementProjectiveConstraint::projectResponseT(DataDeriv& dx, + const std::function& clear) +{ + Real cT = (Real) this->getContext()->getTime(); + VecBool movedDirection = movedDirections.getValue(); + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + if (finished && nextT != prevT) + { + const SetIndexArray & indices = m_indices.getValue(); + + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + clear(dx, *it, movedDirection); + } + } +} + +template +void PartialLinearMovementProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseT(res.wref(), [](VecDeriv& dx, const unsigned int index, const VecBool& b) + { for (unsigned j = 0; j < b.size(); j++) if (b[j]) dx[index][j] = 0.0; }); +} + +template +void PartialLinearMovementProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + helper::WriteAccessor dx = vData; + Real cT = (Real) this->getContext()->getTime(); + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + if (finished && nextT != prevT) + { + const SetIndexArray & indices = m_indices.getValue(); + + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + dx[*it] = (nextM - prevM)*(1.0 / (nextT - prevT)); + } + } +} + + +template +void PartialLinearMovementProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + helper::WriteAccessor x = xData; + Real cT = (Real) this->getContext()->getTime(); + + //initialize initial Dofs positions, if it's not done + if (x0.size() == 0) + { + const SetIndexArray & indices = m_indices.getValue(); + x0.resize(x.size()); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x0[*it] = x[*it]; + } + } + + if ((cT != currentTime) || !finished) + { + findKeyTimes(); + } + + //if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) + if(finished && nextT != prevT) + { + interpolatePosition(cT, x.wref()); + } +} + +template +template +void PartialLinearMovementProjectiveConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) +{ + const SetIndexArray & indices = m_indices.getValue(); + Real dt = (cT - prevT) / (nextT - prevT); + Deriv m = prevM + (nextM-prevM)*dt; + VecBool movedDirection = movedDirections.getValue(); + //set the motion to the Dofs + if(linearMovementBetweenNodesInIndices.getValue()) + { + + const type::vector &imposedDisplacmentOnMacroNodes = this->m_imposedDisplacmentOnMacroNodes.getValue(); + Real a = X0.getValue(); + Real b = Y0.getValue(); + Real c = Z0.getValue(); + bool case2d=false; + if((a==0.0)||(b==0.0)||(c==0.0)) case2d=true; + if(a==0.0) {a=b; b=c;} + if(b==0.0) {b=c;} + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for( unsigned j=0; j< NumDimensions; j++) + { + if(movedDirection[j]) + { + if(case2d) + { + x[*it][j] = x0[*it][j] + ((Real)1.0/(a*b))*((a-x0[*it][0])*(b-x0[*it][1])*imposedDisplacmentOnMacroNodes[0]+ ///< N1 + x0[*it][0]*(b-x0[*it][1])*imposedDisplacmentOnMacroNodes[1]+ ///< N2 + x0[*it][0]*x0[*it][1]*imposedDisplacmentOnMacroNodes[2]+ ///< N3 + (a-x0[*it][0])*x0[*it][1]*imposedDisplacmentOnMacroNodes[3])*m[j]; ///< N4 + // 4|----------------|3 + // | | + // | | + // | | + // 1|----------------|2 + } + else ///< case3d + { + // |Y + // 5---------8 + // /| /| + // / | / | + // 6--|------7 | + // | |/ | | + // | 1------|--4--->X + // | / | / + // |/ |/ + // 2---------3 + // Z/ + // + + x[*it][j] = x0[*it][j] + ((Real)1.0/(a*b*c))*( + (a-x0[*it][0])*(b-x0[*it][1])*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[0]+ ///< N1 + (a-x0[*it][0])*(b-x0[*it][1])*x0[*it][2]*imposedDisplacmentOnMacroNodes[1]+ ///< N2 + x0[*it][0]*(b-x0[*it][1])*x0[*it][2]*imposedDisplacmentOnMacroNodes[2]+ ///< N3 + x0[*it][0]*(b-x0[*it][1])*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[3]+ ///< N4 + (a-x0[*it][0])*x0[*it][1]*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[4]+ ///< N5 + (a-x0[*it][0])*x0[*it][1]*x0[*it][2]*imposedDisplacmentOnMacroNodes[5]+ ///< N6 + x0[*it][0]*x0[*it][1]*x0[*it][2]*imposedDisplacmentOnMacroNodes[6]+ ///< N7 + x0[*it][0]*x0[*it][1]*(c-x0[*it][2])*imposedDisplacmentOnMacroNodes[7] ///< N8 + + )*m[j]; + + } + } + } + } + + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for( unsigned j=0; j< NumDimensions; j++) + if(movedDirection[j]) x[*it][j] = x0[*it][j] + m[j] ; + } + } + +} + +template +template +void PartialLinearMovementProjectiveConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) +{ + const SetIndexArray & indices = m_indices.getValue(); + + Real dt = (cT - prevT) / (nextT - prevT); + Deriv m = prevM + (nextM-prevM)*dt; + type::Quat prevOrientation = type::Quat::createQuaterFromEuler(getVOrientation(prevM)); + type::Quat nextOrientation = type::Quat::createQuaterFromEuler(getVOrientation(nextM)); + + //set the motion to the Dofs + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + x[*it].getCenter() = x0[*it].getCenter() + getVCenter(m) ; + x[*it].getOrientation() = x0[*it].getOrientation() * prevOrientation.slerp2(nextOrientation, dt); + } +} + +template +void PartialLinearMovementProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c = cData; + projectResponseT(c.wref(), + [](MatrixDeriv& res, const unsigned int index, const VecBool& btype) + { + auto itRow = res.begin(); + auto itRowEnd = res.end(); + + while (itRow != itRowEnd) + { + for (auto colIt = itRow.begin(); colIt != itRow.end(); colIt++) + { + if (index == (unsigned int)colIt.index()) + { + Deriv b = colIt.val(); + for (unsigned int j = 0; j < btype.size(); j++) if (btype[j]) b[j] = 0.0; + res.writeLine(itRow.index()).setCol(colIt.index(), b); + } + } + } + }); +} + +template +void PartialLinearMovementProjectiveConstraint::findKeyTimes() +{ + Real cT = (Real) this->getContext()->getTime(); + finished = false; + + if(m_keyTimes.getValue().size() != 0 && cT >= *m_keyTimes.getValue().begin() && cT <= *m_keyTimes.getValue().rbegin()) + { + nextT = *m_keyTimes.getValue().begin(); + prevT = nextT; + + typename type::vector::const_iterator it_t = m_keyTimes.getValue().begin(); + typename VecDeriv::const_iterator it_m = m_keyMovements.getValue().begin(); + + //WARNING : we consider that the key-events are in chronological order + //here we search between which keyTimes we are, to know which are the motion to interpolate + while( it_t != m_keyTimes.getValue().end() && !finished) + { + if( *it_t <= cT) + { + prevT = *it_t; + prevM = *it_m; + } + else + { + nextT = *it_t; + nextM = *it_m; + finished = true; + } + ++it_t; + ++it_m; + } + } +} + +// Matrix Integration interface +template +void PartialLinearMovementProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const SetIndexArray & indices = m_indices.getValue(); + + if (core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) + { + VecBool movedDirection = movedDirections.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(r.offset + NumDimensions * (*it) + c); + } + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + NumDimensions * (*it) + c, r.offset + NumDimensions * (*it) + c, 1.0); + } + } + } +} + +template +void PartialLinearMovementProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const int o = matrix->getGlobalOffset(this->mstate.get()); + if (o >= 0) { + unsigned int offset = (unsigned int)o; + VecBool movedDirection = movedDirections.getValue(); + const SetIndexArray & indices = m_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for (unsigned int c = 0; c < NumDimensions; ++c) + { + if (movedDirection[c]) + { + vector->clear(offset + NumDimensions * (*it) + c); + } + } + } + } +} + +//display the path the constrained dofs will go through +template +void PartialLinearMovementProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + if (!vparams->displayFlags().getShowBehaviorModels() || m_keyTimes.getValue().size() == 0) + return; + + sofa::type::vector vertices; + constexpr sofa::type::RGBAColor color(1, 0.5, 0.5, 1); + + if (showMovement.getValue()) + { + vparams->drawTool()->disableLighting(); + + const SetIndexArray & indices = m_indices.getValue(); + const VecDeriv& keyMovements = m_keyMovements.getValue(); + for (unsigned int i = 0; i < keyMovements.size() - 1; i++) + { + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + const type::Vec3 v0 { DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i]) }; + const type::Vec3 v1 { DataTypes::getCPos(x0[*it]) + DataTypes::getDPos(keyMovements[i + 1]) }; + + vertices.push_back(v0); + vertices.push_back(v1); + } + } + vparams->drawTool()->drawLines(vertices, 1, color); + } + else + { + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + type::Vec3 point; + const SetIndexArray & indices = m_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + point = DataTypes::getCPos(x[*it]); + vertices.push_back(point); + } + vparams->drawTool()->drawPoints(vertices, 10, color); + } + + +} +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h index 2a53250282d..36b07bb0bc6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h @@ -20,146 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -#include -#include - -namespace sofa::component::constraint::projective -{ - -template -class PatchTestMovementConstraintInternalData -{ -}; - -/** - Impose a motion to all the boundary points of a mesh. The motion of the 4 corners are given in the data d_cornerMovements and the movements of the edge points are computed by linear interpolation. -*/ -template -class PatchTestMovementConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(PatchTestMovementConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); - - using Index = sofa::Index; - typedef TDataTypes DataTypes; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - - static constexpr unsigned int CoordSize = Coord::total_size; - - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef core::objectmodel::Data DataMatrixDeriv; - -protected: - PatchTestMovementConstraintInternalData *data; - friend class PatchTestMovementConstraintInternalData; - -public : - /// indices of the DOFs of the mesh - SetIndex d_meshIndices; - /// indices of the DOFs the constraint is applied to - SetIndex d_indices; - /// data begin time when the constraint is applied - Data d_beginConstraintTime; - /// data end time when the constraint is applied - Data d_endConstraintTime; - /// coordinates of the DOFs the constraint is applied to - Data d_constrainedPoints; - /// the movements of the corner points (this is the difference between initial and final positions of the 4 corners) - Data d_cornerMovements; - /// the coordinates of the corner points - Data d_cornerPoints; - /// Draw constrained points - Data d_drawConstrainedPoints; - /// initial constrained DOFs position - VecCoord x0; - /// final constrained DOFs position - VecCoord xf; - /// initial mesh DOFs position - VecCoord meshPointsX0; - /// final mesh DOFs position - VecCoord meshPointsXf; - - /// 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: - PatchTestMovementConstraint(); - - virtual ~PatchTestMovementConstraint(); - -public: - //Add or clear constraints - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - /// -- Constraint interface - void init() override; - - /// Cancel the possible forces - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - /// Cancel the possible velocities - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - /// Apply the computed movements to the border mesh points between beginConstraintTime and endConstraintTime - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - // Implement projectMatrix for assembled solver of compliant - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - void projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /* cData */) override - { - msg_error() <<"projectJacobianMatrix not implemented"; - } - - /// Compute the theoretical final positions - void getFinalPositions (VecCoord& finalPos, DataVecCoord& xData); - - /// Draw the constrained points (= border mesh points) - void draw(const core::visual::VisualParams* vparams) override; - -protected: - - void projectResponseImpl(VecDeriv& dx); - -private: - - /// Find the corners of the grid mesh - void findCornerPoints(); - - /// Compute the displacement of each mesh point by linear interpolation with the displacement of corner points - void computeInterpolatedDisplacement (int pointIndice,const DataVecCoord& xData, Deriv& displacement); - - /// Initialize initial positions - void initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0); - - /// Initialize final positions - void initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0 , VecCoord& xf); -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PATCHTESTMOVEMENTCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl index be21d19e187..ff6b2f45bbe 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl @@ -21,429 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -PatchTestMovementConstraint::PatchTestMovementConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , data(new PatchTestMovementConstraintInternalData) - , d_meshIndices( initData(&d_meshIndices,"meshIndices","Indices of the mesh") ) - , d_indices( initData(&d_indices,"indices","Indices of the constrained points") ) - , d_beginConstraintTime( initData(&d_beginConstraintTime,"beginConstraintTime","Begin time of the bilinear constraint") ) - , d_endConstraintTime( initData(&d_endConstraintTime,"endConstraintTime","End time of the bilinear constraint") ) - , d_constrainedPoints( initData(&d_constrainedPoints,"constrainedPoints","Coordinates of the constrained points") ) - , d_cornerMovements( initData(&d_cornerMovements,"cornerMovements","movements of the corners of the grid") ) - , d_cornerPoints( initData(&d_cornerPoints,"cornerPoints","corner points for computing constraint") ) - , d_drawConstrainedPoints( initData(&d_drawConstrainedPoints,"drawConstrainedPoints","draw constrained points") ) - , l_topology(initLink("topology", "link to the topology container")) -{ - if(!d_beginConstraintTime.isSet()) - d_beginConstraintTime = 0; - if(!d_endConstraintTime.isSet()) - d_endConstraintTime = 20; -} - - - -template -PatchTestMovementConstraint::~PatchTestMovementConstraint() -{ - -} - -template -void PatchTestMovementConstraint::clearConstraints() -{ - d_indices.beginEdit()->clear(); - d_indices.endEdit(); -} - -template -void PatchTestMovementConstraint::addConstraint(Index index) -{ - d_indices.beginEdit()->push_back(index); - d_indices.endEdit(); -} - -template -void PatchTestMovementConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*d_indices.beginEdit(),index); - d_indices.endEdit(); -} - -// -- Constraint interface - - -template -void PatchTestMovementConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - d_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - const SetIndexArray & indices = d_indices.getValue(); - - const Index maxIndex=this->mstate->getSize(); - for (unsigned int i=0; i= maxIndex) - { - msg_error() <<"Index " << index << " not valid!"; - removeConstraint(index); - } - } - - // Find the 4 corners of the grid topology - this->findCornerPoints(); -} - -template -void PatchTestMovementConstraint::findCornerPoints() -{ - Coord corner0, corner1, corner2, corner3,corner4,corner5,corner6,corner7; - // Write accessor - helper::WriteAccessor< Data > cornerPositions = d_cornerPoints; - helper::WriteAccessor< Data > constrainedPoints = d_constrainedPoints; - bool isMeshin3D = false; - - if (!constrainedPoints.empty()) - { - const Coord& point = constrainedPoints[0]; - - // Search if the constrained points are in the same plane - for(Size i = 0; i < constrainedPoints.size() ; i++) - { - if(CoordSize > 2 && constrainedPoints[i][2]!=point[2]) - { - isMeshin3D = true; - } - } - } - - if(constrainedPoints.size() > 0) - { - corner0 = constrainedPoints[0]; - corner1 = constrainedPoints[0]; - corner2 = constrainedPoints[0]; - corner3 = constrainedPoints[0]; - corner4 = constrainedPoints[0]; - corner5 = constrainedPoints[0]; - corner6 = constrainedPoints[0]; - corner7 = constrainedPoints[0]; - - for (size_t i = 0; i < constrainedPoints.size() ; i++) - { - if(constrainedPoints[i][0] < corner0[0] || constrainedPoints[i][1] < corner0[1] || ( CoordSize>2 && constrainedPoints[i][2] < corner0[2] ) ) - { - corner0 = constrainedPoints[i]; - } - - if(constrainedPoints[i][0] > corner2[0] || constrainedPoints[i][1] > corner2[1] || ( CoordSize>2 && constrainedPoints[i][2] < corner2[2] ) ) - { - corner2 = constrainedPoints[i]; - } - - if(constrainedPoints[i][1] < corner1[1] || constrainedPoints[i][0] > corner1[0] || ( CoordSize>2 && constrainedPoints[i][2] < corner1[2] )) - { - corner1 = constrainedPoints[i]; - } - - if(constrainedPoints[i][0] < corner3[0] || constrainedPoints[i][1] > corner3[1] || ( CoordSize>2 && constrainedPoints[i][2] < corner3[2] )) - { - corner3 = constrainedPoints[i]; - } - - if(isMeshin3D && (constrainedPoints[i][0] < corner4[0] || constrainedPoints[i][1] < corner4[1] || (CoordSize>2 && constrainedPoints[i][2] > corner0[2] )) ) - { - corner4 = constrainedPoints[i]; - } - - if(isMeshin3D && (constrainedPoints[i][0] > corner6[0] || constrainedPoints[i][1] > corner6[1] || (CoordSize>2 && constrainedPoints[i][2] > corner2[2] )) ) - { - corner6 = constrainedPoints[i]; - } - - if(isMeshin3D && (constrainedPoints[i][1] < corner5[1] || constrainedPoints[i][0] > corner5[0] || (CoordSize>2 && constrainedPoints[i][2] > corner5[2] )) ) - { - corner5 = constrainedPoints[i]; - } - - else if(isMeshin3D && (constrainedPoints[i][0] < corner7[0] || constrainedPoints[i][1] > corner7[1] || (CoordSize>2 && constrainedPoints[i][2] > corner7[2] )) ) - { - corner7 = constrainedPoints[i]; - } - } - - cornerPositions.push_back(corner0); - cornerPositions.push_back(corner1); - cornerPositions.push_back(corner2); - cornerPositions.push_back(corner3); - - // 3D - if(isMeshin3D) - { - cornerPositions.push_back(corner4); - cornerPositions.push_back(corner5); - cornerPositions.push_back(corner6); - cornerPositions.push_back(corner7); - } - } -} - -template -void PatchTestMovementConstraint::projectResponseImpl(VecDeriv& dx) -{ - const SetIndexArray & indices = d_indices.getValue(); - for (size_t i = 0; i< indices.size(); ++i) - { - dx[indices[i]]=Deriv(); - } -} - -template -void PatchTestMovementConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = resData; - projectResponseImpl(res.wref()); -} - -template -void PatchTestMovementConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor res = vData; - projectResponseImpl(res.wref()); -} - -template -void PatchTestMovementConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - const sofa::simulation::Node::SPtr root = down_cast( this->getContext()->getRootContext() ); - helper::WriteAccessor x = xData; - const SetIndexArray & indices = d_indices.getValue(); - - // Time - double beginTime = d_beginConstraintTime.getValue(); - double endTime = d_endConstraintTime.getValue(); - double totalTime = endTime - beginTime; - - //initialize initial mesh Dofs positions, if it's not done - if(meshPointsX0.size()==0) - this->initializeInitialPositions(d_meshIndices.getValue(),xData,meshPointsX0); - - //initialize final mesh Dofs positions, if it's not done - if(meshPointsXf.size()==0) - this->initializeFinalPositions(d_meshIndices.getValue(),xData, meshPointsX0, meshPointsXf); - - //initialize initial constrained Dofs positions, if it's not done - if(x0.size() == 0) - this->initializeInitialPositions(indices,xData,x0); - - //initialize final constrained Dofs positions, if it's not done - if (xf.size() == 0) - this->initializeFinalPositions(indices,xData,x0,xf); - - // Update the intermediate Dofs positions computed by linear interpolation - double time = root->getTime(); - if( time > beginTime && time <= endTime && totalTime > 0) - { - for (size_t i = 0; i< indices.size(); ++i) - { - x[indices[i]] = ((xf[indices[i]]-x0[indices[i]])*time + (x0[indices[i]]*endTime - xf[indices[i]]*beginTime))/totalTime; - } - } - else if (time > endTime) - { - for (size_t i = 0; i< indices.size(); ++i) - { - x[indices[i]] = xf[indices[i]]; - } - } -} - -template -void PatchTestMovementConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - // clears the rows and columns associated with constrained particles - const unsigned blockSize = DataTypes::deriv_total_size; - - for (const auto id : d_indices.getValue()) - { - M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); - } - -} - -template -void PatchTestMovementConstraint::getFinalPositions( VecCoord& finalPos,DataVecCoord& xData) -{ - // Indices of mesh points - const SetIndexArray & meshIndices = d_meshIndices.getValue(); - - // Initialize final positions - if(meshPointsXf.size()==0) - {this->initializeFinalPositions(meshIndices,xData,meshPointsX0,meshPointsXf);} - - // Set final positions - finalPos.resize(meshIndices.size()); - for (size_t i=0; i < meshIndices.size() ; ++i) - { - finalPos[meshIndices[i]] = meshPointsXf[meshIndices[i]]; - } -} - -template -void PatchTestMovementConstraint::initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0) -{ - helper::WriteAccessor x = xData; - - x0.resize(x.size()); - for (size_t i=0; i < indices.size() ; ++i) - { - x0[indices[i]] = x[indices[i]]; - } - -} - -template -void PatchTestMovementConstraint::initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0, VecCoord& xf) -{ - Deriv displacement; - helper::WriteAccessor x = xData; - - xf.resize(x.size()); - - // if the positions were not initialized - if(x0.size() == 0) - this->initializeInitialPositions(indices,xData,x0); - - for (size_t i=0; i < indices.size() ; ++i) - { - this->computeInterpolatedDisplacement(indices[i],xData,displacement); - xf[indices[i]] = x0[indices[i]] + displacement ; - } - -} - -template -void PatchTestMovementConstraint::computeInterpolatedDisplacement(int pointIndice,const DataVecCoord& xData, Deriv& displacement) -{ - // For each mesh point compute the associated displacement - - // The 3 barycentric coefficients along x, y and z axis - Real alpha, beta, gamma; - - // Corner points - const VecCoord& cornerPoints = d_cornerPoints.getValue(); - if(cornerPoints.size()==0) - this->findCornerPoints(); - - if(cornerPoints.size() == 4) - { - Coord corner0 = cornerPoints[0]; - Coord corner1 = cornerPoints[1]; - Coord corner3 = cornerPoints[3]; - - // Coord of the point - helper::ReadAccessor x = xData; - Coord point = x[pointIndice]; - - // Compute alpha = barycentric coefficient along the x axis - alpha = fabs(point[0]-corner0[0])/fabs(corner1[0]-corner0[0]); - - // Compute beta = barycentric coefficient along the y axis - beta = fabs(point[1]-corner0[1])/fabs(corner3[1]-corner0[1]); - - // cornerMovements - const VecDeriv& cornerMovements = d_cornerMovements.getValue(); - - // Compute displacement by linear interpolation - displacement = cornerMovements[0]*(1-alpha)*(1-beta) + cornerMovements[1]*alpha*(1-beta)+ cornerMovements[2]*alpha*beta+cornerMovements[3]*(1-alpha)*beta; - } - - else if(cornerPoints.size() == 8) - { - Coord corner0 = cornerPoints[0]; - Coord corner1 = cornerPoints[1]; - Coord corner3 = cornerPoints[3]; - Coord corner4 = cornerPoints[4]; - - // Coord of the point - helper::ReadAccessor x = xData; - Coord point = x[pointIndice]; - - // Compute alpha = barycentric coefficient along the x axis - alpha = fabs(point[0]-corner0[0])/fabs(corner1[0]-corner0[0]); - - // Compute beta = barycentric coefficient along the y axis - beta = fabs(point[1]-corner0[1])/fabs(corner3[1]-corner0[1]); - - // Compute gamma = barycentric coefficient along the z axis - if( CoordSize>2 ) - gamma = fabs(point[2]-corner0[2])/fabs(corner4[2]-corner0[2]); // 3D - else - gamma = 0; // 2D - - // cornerMovements - const VecDeriv& cornerMovements = d_cornerMovements.getValue(); - - // Compute displacement by linear interpolation - displacement = (cornerMovements[0]*(1-alpha)*(1-beta) + cornerMovements[1]*alpha*(1-beta)+ cornerMovements[2]*alpha*beta+cornerMovements[3]*(1-alpha)*beta) * (1-gamma) - + (cornerMovements[4]*(1-alpha)*(1-beta) + cornerMovements[5]*alpha*(1-beta)+ cornerMovements[6]*alpha*beta+cornerMovements[7]*(1-alpha)*beta) * gamma; - } - else - { - msg_info() << "error don't find the corner points" ; - } - -} - -template -void PatchTestMovementConstraint::draw(const core::visual::VisualParams* vparams) -{ - const SetIndexArray & indices = d_indices.getValue(); - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - type::Vec3 point; - - if(d_drawConstrainedPoints.getValue()) - { - std::vector< type::Vec3 > points; - for (unsigned int index : indices) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); - } -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp similarity index 84% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp index beb420617e0..0c97c873ff1 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PATCHTESTMOVEMENTCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PATCHTESTMOVEMENTPROJECTIVECONSTRAINT_CPP +#include #include #include #include @@ -29,14 +29,14 @@ namespace sofa::component::constraint::projective { //declaration of the class, for the factory -int PatchTestMovementConstraintClass = core::RegisterObject("bilinear constraint") - .add< PatchTestMovementConstraint >() - .add< PatchTestMovementConstraint >() +int PatchTestMovementProjectiveConstraintClass = core::RegisterObject("bilinear constraint") + .add< PatchTestMovementProjectiveConstraint >() + .add< PatchTestMovementProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h new file mode 100644 index 00000000000..bd0def66848 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h @@ -0,0 +1,168 @@ +/****************************************************************************** +* 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 + +#include +#include + +namespace sofa::component::constraint::projective +{ + +template +class PatchTestMovementProjectiveConstraintInternalData +{ +}; + +/** + Impose a motion to all the boundary points of a mesh. The motion of the 4 corners are given in the data d_cornerMovements and the movements of the edge points are computed by linear interpolation. +*/ +template +class PatchTestMovementProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(PatchTestMovementProjectiveConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); + + using Index = sofa::Index; + typedef TDataTypes DataTypes; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + + static constexpr unsigned int CoordSize = Coord::total_size; + + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef core::objectmodel::Data DataMatrixDeriv; + +protected: + PatchTestMovementProjectiveConstraintInternalData *data; + friend class PatchTestMovementProjectiveConstraintInternalData; + +public : + /// indices of the DOFs of the mesh + SetIndex d_meshIndices; + /// indices of the DOFs the constraint is applied to + SetIndex d_indices; + /// data begin time when the constraint is applied + Data d_beginConstraintTime; + /// data end time when the constraint is applied + Data d_endConstraintTime; + /// coordinates of the DOFs the constraint is applied to + Data d_constrainedPoints; + /// the movements of the corner points (this is the difference between initial and final positions of the 4 corners) + Data d_cornerMovements; + /// the coordinates of the corner points + Data d_cornerPoints; + /// Draw constrained points + Data d_drawConstrainedPoints; + /// initial constrained DOFs position + VecCoord x0; + /// final constrained DOFs position + VecCoord xf; + /// initial mesh DOFs position + VecCoord meshPointsX0; + /// final mesh DOFs position + VecCoord meshPointsXf; + + /// 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: + PatchTestMovementProjectiveConstraint(); + + virtual ~PatchTestMovementProjectiveConstraint(); + +public: + //Add or clear constraints + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + /// -- Constraint interface + void init() override; + + /// Cancel the possible forces + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + /// Cancel the possible velocities + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + /// Apply the computed movements to the border mesh points between beginConstraintTime and endConstraintTime + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + // Implement projectMatrix for assembled solver of compliant + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + void projectJacobianMatrix(const core::MechanicalParams* /*mparams*/, DataMatrixDeriv& /* cData */) override + { + msg_error() <<"projectJacobianMatrix not implemented"; + } + + /// Compute the theoretical final positions + void getFinalPositions (VecCoord& finalPos, DataVecCoord& xData); + + /// Draw the constrained points (= border mesh points) + void draw(const core::visual::VisualParams* vparams) override; + +protected: + + void projectResponseImpl(VecDeriv& dx); + +private: + + /// Find the corners of the grid mesh + void findCornerPoints(); + + /// Compute the displacement of each mesh point by linear interpolation with the displacement of corner points + void computeInterpolatedDisplacement (int pointIndice,const DataVecCoord& xData, Deriv& displacement); + + /// Initialize initial positions + void initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0); + + /// Initialize final positions + void initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0 , VecCoord& xf); +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PATCHTESTMOVEMENTPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; + +#endif + +template +using PatchTestMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PatchTestMovementConstraint has been renamed to PatchTestMovementProjectiveConstraint") = PatchTestMovementProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl new file mode 100644 index 00000000000..b93be91ea5c --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl @@ -0,0 +1,449 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +template +PatchTestMovementProjectiveConstraint::PatchTestMovementProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , data(new PatchTestMovementProjectiveConstraintInternalData) + , d_meshIndices( initData(&d_meshIndices,"meshIndices","Indices of the mesh") ) + , d_indices( initData(&d_indices,"indices","Indices of the constrained points") ) + , d_beginConstraintTime( initData(&d_beginConstraintTime,"beginConstraintTime","Begin time of the bilinear constraint") ) + , d_endConstraintTime( initData(&d_endConstraintTime,"endConstraintTime","End time of the bilinear constraint") ) + , d_constrainedPoints( initData(&d_constrainedPoints,"constrainedPoints","Coordinates of the constrained points") ) + , d_cornerMovements( initData(&d_cornerMovements,"cornerMovements","movements of the corners of the grid") ) + , d_cornerPoints( initData(&d_cornerPoints,"cornerPoints","corner points for computing constraint") ) + , d_drawConstrainedPoints( initData(&d_drawConstrainedPoints,"drawConstrainedPoints","draw constrained points") ) + , l_topology(initLink("topology", "link to the topology container")) +{ + if(!d_beginConstraintTime.isSet()) + d_beginConstraintTime = 0; + if(!d_endConstraintTime.isSet()) + d_endConstraintTime = 20; +} + + + +template +PatchTestMovementProjectiveConstraint::~PatchTestMovementProjectiveConstraint() +{ + +} + +template +void PatchTestMovementProjectiveConstraint::clearConstraints() +{ + d_indices.beginEdit()->clear(); + d_indices.endEdit(); +} + +template +void PatchTestMovementProjectiveConstraint::addConstraint(Index index) +{ + d_indices.beginEdit()->push_back(index); + d_indices.endEdit(); +} + +template +void PatchTestMovementProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*d_indices.beginEdit(),index); + d_indices.endEdit(); +} + +// -- Constraint interface + + +template +void PatchTestMovementProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + d_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + const SetIndexArray & indices = d_indices.getValue(); + + const Index maxIndex=this->mstate->getSize(); + for (unsigned int i=0; i= maxIndex) + { + msg_error() <<"Index " << index << " not valid!"; + removeConstraint(index); + } + } + + // Find the 4 corners of the grid topology + this->findCornerPoints(); +} + +template +void PatchTestMovementProjectiveConstraint::findCornerPoints() +{ + Coord corner0, corner1, corner2, corner3,corner4,corner5,corner6,corner7; + // Write accessor + helper::WriteAccessor< Data > cornerPositions = d_cornerPoints; + helper::WriteAccessor< Data > constrainedPoints = d_constrainedPoints; + bool isMeshin3D = false; + + if (!constrainedPoints.empty()) + { + const Coord& point = constrainedPoints[0]; + + // Search if the constrained points are in the same plane + for(Size i = 0; i < constrainedPoints.size() ; i++) + { + if(CoordSize > 2 && constrainedPoints[i][2]!=point[2]) + { + isMeshin3D = true; + } + } + } + + if(constrainedPoints.size() > 0) + { + corner0 = constrainedPoints[0]; + corner1 = constrainedPoints[0]; + corner2 = constrainedPoints[0]; + corner3 = constrainedPoints[0]; + corner4 = constrainedPoints[0]; + corner5 = constrainedPoints[0]; + corner6 = constrainedPoints[0]; + corner7 = constrainedPoints[0]; + + for (size_t i = 0; i < constrainedPoints.size() ; i++) + { + if(constrainedPoints[i][0] < corner0[0] || constrainedPoints[i][1] < corner0[1] || ( CoordSize>2 && constrainedPoints[i][2] < corner0[2] ) ) + { + corner0 = constrainedPoints[i]; + } + + if(constrainedPoints[i][0] > corner2[0] || constrainedPoints[i][1] > corner2[1] || ( CoordSize>2 && constrainedPoints[i][2] < corner2[2] ) ) + { + corner2 = constrainedPoints[i]; + } + + if(constrainedPoints[i][1] < corner1[1] || constrainedPoints[i][0] > corner1[0] || ( CoordSize>2 && constrainedPoints[i][2] < corner1[2] )) + { + corner1 = constrainedPoints[i]; + } + + if(constrainedPoints[i][0] < corner3[0] || constrainedPoints[i][1] > corner3[1] || ( CoordSize>2 && constrainedPoints[i][2] < corner3[2] )) + { + corner3 = constrainedPoints[i]; + } + + if(isMeshin3D && (constrainedPoints[i][0] < corner4[0] || constrainedPoints[i][1] < corner4[1] || (CoordSize>2 && constrainedPoints[i][2] > corner0[2] )) ) + { + corner4 = constrainedPoints[i]; + } + + if(isMeshin3D && (constrainedPoints[i][0] > corner6[0] || constrainedPoints[i][1] > corner6[1] || (CoordSize>2 && constrainedPoints[i][2] > corner2[2] )) ) + { + corner6 = constrainedPoints[i]; + } + + if(isMeshin3D && (constrainedPoints[i][1] < corner5[1] || constrainedPoints[i][0] > corner5[0] || (CoordSize>2 && constrainedPoints[i][2] > corner5[2] )) ) + { + corner5 = constrainedPoints[i]; + } + + else if(isMeshin3D && (constrainedPoints[i][0] < corner7[0] || constrainedPoints[i][1] > corner7[1] || (CoordSize>2 && constrainedPoints[i][2] > corner7[2] )) ) + { + corner7 = constrainedPoints[i]; + } + } + + cornerPositions.push_back(corner0); + cornerPositions.push_back(corner1); + cornerPositions.push_back(corner2); + cornerPositions.push_back(corner3); + + // 3D + if(isMeshin3D) + { + cornerPositions.push_back(corner4); + cornerPositions.push_back(corner5); + cornerPositions.push_back(corner6); + cornerPositions.push_back(corner7); + } + } +} + +template +void PatchTestMovementProjectiveConstraint::projectResponseImpl(VecDeriv& dx) +{ + const SetIndexArray & indices = d_indices.getValue(); + for (size_t i = 0; i< indices.size(); ++i) + { + dx[indices[i]]=Deriv(); + } +} + +template +void PatchTestMovementProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = resData; + projectResponseImpl(res.wref()); +} + +template +void PatchTestMovementProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor res = vData; + projectResponseImpl(res.wref()); +} + +template +void PatchTestMovementProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + const sofa::simulation::Node::SPtr root = down_cast( this->getContext()->getRootContext() ); + helper::WriteAccessor x = xData; + const SetIndexArray & indices = d_indices.getValue(); + + // Time + double beginTime = d_beginConstraintTime.getValue(); + double endTime = d_endConstraintTime.getValue(); + double totalTime = endTime - beginTime; + + //initialize initial mesh Dofs positions, if it's not done + if(meshPointsX0.size()==0) + this->initializeInitialPositions(d_meshIndices.getValue(),xData,meshPointsX0); + + //initialize final mesh Dofs positions, if it's not done + if(meshPointsXf.size()==0) + this->initializeFinalPositions(d_meshIndices.getValue(),xData, meshPointsX0, meshPointsXf); + + //initialize initial constrained Dofs positions, if it's not done + if(x0.size() == 0) + this->initializeInitialPositions(indices,xData,x0); + + //initialize final constrained Dofs positions, if it's not done + if (xf.size() == 0) + this->initializeFinalPositions(indices,xData,x0,xf); + + // Update the intermediate Dofs positions computed by linear interpolation + double time = root->getTime(); + if( time > beginTime && time <= endTime && totalTime > 0) + { + for (size_t i = 0; i< indices.size(); ++i) + { + x[indices[i]] = ((xf[indices[i]]-x0[indices[i]])*time + (x0[indices[i]]*endTime - xf[indices[i]]*beginTime))/totalTime; + } + } + else if (time > endTime) + { + for (size_t i = 0; i< indices.size(); ++i) + { + x[indices[i]] = xf[indices[i]]; + } + } +} + +template +void PatchTestMovementProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + // clears the rows and columns associated with constrained particles + const unsigned blockSize = DataTypes::deriv_total_size; + + for (const auto id : d_indices.getValue()) + { + M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); + } + +} + +template +void PatchTestMovementProjectiveConstraint::getFinalPositions( VecCoord& finalPos,DataVecCoord& xData) +{ + // Indices of mesh points + const SetIndexArray & meshIndices = d_meshIndices.getValue(); + + // Initialize final positions + if(meshPointsXf.size()==0) + {this->initializeFinalPositions(meshIndices,xData,meshPointsX0,meshPointsXf);} + + // Set final positions + finalPos.resize(meshIndices.size()); + for (size_t i=0; i < meshIndices.size() ; ++i) + { + finalPos[meshIndices[i]] = meshPointsXf[meshIndices[i]]; + } +} + +template +void PatchTestMovementProjectiveConstraint::initializeInitialPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0) +{ + helper::WriteAccessor x = xData; + + x0.resize(x.size()); + for (size_t i=0; i < indices.size() ; ++i) + { + x0[indices[i]] = x[indices[i]]; + } + +} + +template +void PatchTestMovementProjectiveConstraint::initializeFinalPositions (const SetIndexArray & indices, DataVecCoord& xData, VecCoord& x0, VecCoord& xf) +{ + Deriv displacement; + helper::WriteAccessor x = xData; + + xf.resize(x.size()); + + // if the positions were not initialized + if(x0.size() == 0) + this->initializeInitialPositions(indices,xData,x0); + + for (size_t i=0; i < indices.size() ; ++i) + { + this->computeInterpolatedDisplacement(indices[i],xData,displacement); + xf[indices[i]] = x0[indices[i]] + displacement ; + } + +} + +template +void PatchTestMovementProjectiveConstraint::computeInterpolatedDisplacement(int pointIndice,const DataVecCoord& xData, Deriv& displacement) +{ + // For each mesh point compute the associated displacement + + // The 3 barycentric coefficients along x, y and z axis + Real alpha, beta, gamma; + + // Corner points + const VecCoord& cornerPoints = d_cornerPoints.getValue(); + if(cornerPoints.size()==0) + this->findCornerPoints(); + + if(cornerPoints.size() == 4) + { + Coord corner0 = cornerPoints[0]; + Coord corner1 = cornerPoints[1]; + Coord corner3 = cornerPoints[3]; + + // Coord of the point + helper::ReadAccessor x = xData; + Coord point = x[pointIndice]; + + // Compute alpha = barycentric coefficient along the x axis + alpha = fabs(point[0]-corner0[0])/fabs(corner1[0]-corner0[0]); + + // Compute beta = barycentric coefficient along the y axis + beta = fabs(point[1]-corner0[1])/fabs(corner3[1]-corner0[1]); + + // cornerMovements + const VecDeriv& cornerMovements = d_cornerMovements.getValue(); + + // Compute displacement by linear interpolation + displacement = cornerMovements[0]*(1-alpha)*(1-beta) + cornerMovements[1]*alpha*(1-beta)+ cornerMovements[2]*alpha*beta+cornerMovements[3]*(1-alpha)*beta; + } + + else if(cornerPoints.size() == 8) + { + Coord corner0 = cornerPoints[0]; + Coord corner1 = cornerPoints[1]; + Coord corner3 = cornerPoints[3]; + Coord corner4 = cornerPoints[4]; + + // Coord of the point + helper::ReadAccessor x = xData; + Coord point = x[pointIndice]; + + // Compute alpha = barycentric coefficient along the x axis + alpha = fabs(point[0]-corner0[0])/fabs(corner1[0]-corner0[0]); + + // Compute beta = barycentric coefficient along the y axis + beta = fabs(point[1]-corner0[1])/fabs(corner3[1]-corner0[1]); + + // Compute gamma = barycentric coefficient along the z axis + if( CoordSize>2 ) + gamma = fabs(point[2]-corner0[2])/fabs(corner4[2]-corner0[2]); // 3D + else + gamma = 0; // 2D + + // cornerMovements + const VecDeriv& cornerMovements = d_cornerMovements.getValue(); + + // Compute displacement by linear interpolation + displacement = (cornerMovements[0]*(1-alpha)*(1-beta) + cornerMovements[1]*alpha*(1-beta)+ cornerMovements[2]*alpha*beta+cornerMovements[3]*(1-alpha)*beta) * (1-gamma) + + (cornerMovements[4]*(1-alpha)*(1-beta) + cornerMovements[5]*alpha*(1-beta)+ cornerMovements[6]*alpha*beta+cornerMovements[7]*(1-alpha)*beta) * gamma; + } + else + { + msg_info() << "error don't find the corner points" ; + } + +} + +template +void PatchTestMovementProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + const SetIndexArray & indices = d_indices.getValue(); + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + type::Vec3 point; + + if(d_drawConstrainedPoints.getValue()) + { + std::vector< type::Vec3 > points; + for (unsigned int index : indices) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); + } +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h index d861e5a7a72..a53ebf6f5f8 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h @@ -20,95 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class PositionBasedDynamicsConstraintInternalData -{ -}; - -/** Position-based dynamics as described in [Muller06]: -input: target positions X -output : x(t) <- x(t) + stiffness.( X - x(t) ) - v(t) <- [ x(t) - x(t-1) ] / dt = v(t) + stiffness.( X - x(t) ) /dt - -*/ - -template -class PositionBasedDynamicsConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(PositionBasedDynamicsConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - -protected: - PositionBasedDynamicsConstraintInternalData data; - friend class PositionBasedDynamicsConstraintInternalData; - -public: - Data< Real > stiffness; ///< Blending between current pos and target pos. - Data< VecCoord > position; ///< Target positions. - - Data < VecDeriv > velocity; ///< Velocities. - Data < VecCoord > old_position; ///< Old positions. - - PositionBasedDynamicsConstraint(); - - virtual ~PositionBasedDynamicsConstraint(); - - // -- Constraint interface - void init() override; - void reset() override; - - void projectResponse(const core::MechanicalParams* , DataVecDeriv& ) override {} - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - // Handle topological changes - void handleTopologyChange() override; - -protected : - - - -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_POSITIONBASEDDYNAMICSCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -//extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl index 80117815e5d..87e1d67275e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl @@ -21,118 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - - -template -PositionBasedDynamicsConstraint::PositionBasedDynamicsConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , stiffness(initData(&stiffness,(Real)1.0,"stiffness","Blending between current pos and target pos.")) - , position(initData(&position,"position","Target positions.")) - , velocity(initData(&velocity,"velocity","Velocities.")) - , old_position(initData(&old_position,"old_position","Old positions.")) -{ -} - - -// Handle topological changes -template void PositionBasedDynamicsConstraint::handleTopologyChange() -{ - this->reinit(); -} - -template -PositionBasedDynamicsConstraint::~PositionBasedDynamicsConstraint() -{ -} - - -// -- Constraint interface - - -template -void PositionBasedDynamicsConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::init(); - if ((int)position.getValue().size() != (int)this->mstate->getSize()) msg_error() << "Invalid target position vector size." ; -} - - -template -void PositionBasedDynamicsConstraint::reset() -{ - this->core::behavior::ProjectiveConstraintSet::reset(); - - helper::WriteAccessor vel ( velocity ); - std::fill(vel.begin(),vel.end(),Deriv()); - - helper::WriteAccessor old_pos ( old_position ); - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - old_pos.resize(x.size()); - std::copy(x.begin(),x.end(),old_pos.begin()); -} - - - -template -void PositionBasedDynamicsConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - helper::WriteAccessor c ( cData ); -} - - - -template -void PositionBasedDynamicsConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res (vData ); - helper::ReadAccessor vel ( velocity ); - - if (vel.size() != res.size()) { msg_error() << "Invalid target position vector size." ; return; } - std::copy(vel.begin(),vel.end(),res.begin()); -} - -template -void PositionBasedDynamicsConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res ( xData ); - helper::WriteAccessor vel ( velocity ); - helper::WriteAccessor old_pos ( old_position ); - helper::ReadAccessor tpos = position ; - if (tpos.size() != res.size()) { msg_error() << "Invalid target position vector size." ; return; } - - Real dt = (Real)this->getContext()->getDt(); - if(!dt) return; - Real invdt=(Real)(1./dt); - - vel.resize(res.size()); - - if(old_pos.size() != res.size()) { - old_pos.resize(res.size()); - std::copy(res.begin(),res.end(),old_pos.begin()); - } - - for( size_t i=0; i -void PositionBasedDynamicsConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData); - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp similarity index 79% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp index 8861bb04b35..d0b0c03a4f8 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_POSITIONBASEDDYNAMICSCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_POSITIONBASEDDYNAMICSPROJECTIVECONSTRAINT_CPP +#include #include #include @@ -35,30 +35,30 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int PositionBasedDynamicsConstraintClass = core::RegisterObject("Position-based dynamics") +int PositionBasedDynamicsProjectiveConstraintClass = core::RegisterObject("Position-based dynamics") - .add< PositionBasedDynamicsConstraint >(true) - .add< PositionBasedDynamicsConstraint >() - .add< PositionBasedDynamicsConstraint >() - .add< PositionBasedDynamicsConstraint >() - .add< PositionBasedDynamicsConstraint >() -//.add< PositionBasedDynamicsConstraint >() + .add< PositionBasedDynamicsProjectiveConstraint >(true) + .add< PositionBasedDynamicsProjectiveConstraint >() + .add< PositionBasedDynamicsProjectiveConstraint >() + .add< PositionBasedDynamicsProjectiveConstraint >() + .add< PositionBasedDynamicsProjectiveConstraint >() +//.add< PositionBasedDynamicsProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; -//template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +//template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; // specialization for rigids template <> -void PositionBasedDynamicsConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) +void PositionBasedDynamicsProjectiveConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) { SOFA_UNUSED(mparams); diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h new file mode 100644 index 00000000000..9915c63d8cc --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h @@ -0,0 +1,117 @@ +/****************************************************************************** +* 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 +#include + +namespace sofa::component::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class PositionBasedDynamicsProjectiveConstraintInternalData +{ +}; + +/** Position-based dynamics as described in [Muller06]: +input: target positions X +output : x(t) <- x(t) + stiffness.( X - x(t) ) + v(t) <- [ x(t) - x(t-1) ] / dt = v(t) + stiffness.( X - x(t) ) /dt + +*/ + +template +class PositionBasedDynamicsProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(PositionBasedDynamicsProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + +protected: + PositionBasedDynamicsProjectiveConstraintInternalData data; + friend class PositionBasedDynamicsProjectiveConstraintInternalData; + +public: + Data< Real > stiffness; ///< Blending between current pos and target pos. + Data< VecCoord > position; ///< Target positions. + + Data < VecDeriv > velocity; ///< Velocities. + Data < VecCoord > old_position; ///< Old positions. + + PositionBasedDynamicsProjectiveConstraint(); + + virtual ~PositionBasedDynamicsProjectiveConstraint(); + + // -- Constraint interface + void init() override; + void reset() override; + + void projectResponse(const core::MechanicalParams* , DataVecDeriv& ) override {} + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + // Handle topological changes + void handleTopologyChange() override; + +protected : + + + +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_POSITIONBASEDDYNAMICSPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; +//extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; + +#endif + +template +using PositionBasedDynamicsConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PositionBasedDynamicsConstraint has been renamed to PositionBasedDynamicsProjectiveConstraint") = PositionBasedDynamicsProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl new file mode 100644 index 00000000000..473b6ceafa1 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl @@ -0,0 +1,138 @@ +/****************************************************************************** +* 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::constraint::projective +{ + + +template +PositionBasedDynamicsProjectiveConstraint::PositionBasedDynamicsProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , stiffness(initData(&stiffness,(Real)1.0,"stiffness","Blending between current pos and target pos.")) + , position(initData(&position,"position","Target positions.")) + , velocity(initData(&velocity,"velocity","Velocities.")) + , old_position(initData(&old_position,"old_position","Old positions.")) +{ +} + + +// Handle topological changes +template void PositionBasedDynamicsProjectiveConstraint::handleTopologyChange() +{ + this->reinit(); +} + +template +PositionBasedDynamicsProjectiveConstraint::~PositionBasedDynamicsProjectiveConstraint() +{ +} + + +// -- Constraint interface + + +template +void PositionBasedDynamicsProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::init(); + if ((int)position.getValue().size() != (int)this->mstate->getSize()) msg_error() << "Invalid target position vector size." ; +} + + +template +void PositionBasedDynamicsProjectiveConstraint::reset() +{ + this->core::behavior::ProjectiveConstraintSet::reset(); + + helper::WriteAccessor vel ( velocity ); + std::fill(vel.begin(),vel.end(),Deriv()); + + helper::WriteAccessor old_pos ( old_position ); + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + old_pos.resize(x.size()); + std::copy(x.begin(),x.end(),old_pos.begin()); +} + + + +template +void PositionBasedDynamicsProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + helper::WriteAccessor c ( cData ); +} + + + +template +void PositionBasedDynamicsProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res (vData ); + helper::ReadAccessor vel ( velocity ); + + if (vel.size() != res.size()) { msg_error() << "Invalid target position vector size." ; return; } + std::copy(vel.begin(),vel.end(),res.begin()); +} + +template +void PositionBasedDynamicsProjectiveConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res ( xData ); + helper::WriteAccessor vel ( velocity ); + helper::WriteAccessor old_pos ( old_position ); + helper::ReadAccessor tpos = position ; + if (tpos.size() != res.size()) { msg_error() << "Invalid target position vector size." ; return; } + + Real dt = (Real)this->getContext()->getDt(); + if(!dt) return; + Real invdt=(Real)(1./dt); + + vel.resize(res.size()); + + if(old_pos.size() != res.size()) { + old_pos.resize(res.size()); + std::copy(res.begin(),res.end(),old_pos.begin()); + } + + for( size_t i=0; i +void PositionBasedDynamicsProjectiveConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData); + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h index 73b8f78525c..fa767ebb33e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h @@ -20,115 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class ProjectDirectionConstraintInternalData -{ - -}; - -/** Project particles to an affine straight line going through the particle original position. -*/ -template -class ProjectDirectionConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectDirectionConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::CPos CPos; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector Indices; - SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); - typedef sofa::core::topology::TopologySubsetIndices IndexSubsetData; - typedef linearalgebra::EigenBaseSparseMatrix BaseSparseMatrix; - typedef linearalgebra::EigenSparseMatrix SparseMatrix; - typedef typename SparseMatrix::Block Block; ///< projection matrix of a particle displacement to the plane - enum {bsize=SparseMatrix::Nin}; ///< size of a block - - -protected: - ProjectDirectionConstraint(); - - virtual ~ProjectDirectionConstraint(); - -public: - IndexSubsetData f_indices; ///< the particles to project - Data f_drawSize; ///< The size of the square used to display the constrained particles - Data f_direction; ///< The direction of the line. Will be normalized by init() - - /// 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: - ProjectDirectionConstraintInternalData* data; - friend class ProjectDirectionConstraintInternalData; - - type::vector m_origin; - - -public: - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - // -- Constraint interface - void init() override; - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - /// Project the given matrix (Experimental API, see the spec in sofa::core::behavior::BaseProjectiveConstraintSet). - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - - void draw(const core::visual::VisualParams* vparams) override; - -protected : - - SparseMatrix jacobian; ///< projection matrix in local state - SparseMatrix J; ///< auxiliary variable -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectDirectionConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl index 1d63aa29002..cb073b97a2a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl @@ -21,257 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include - -namespace sofa::component::constraint::projective -{ - -template -ProjectDirectionConstraint::ProjectDirectionConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) - , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) - , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) - , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectDirectionConstraintInternalData()) -{ - f_indices.beginEdit()->push_back(0); - f_indices.endEdit(); -} - - -template -ProjectDirectionConstraint::~ProjectDirectionConstraint() -{ - delete data; -} - -template -void ProjectDirectionConstraint::clearConstraints() -{ - f_indices.beginEdit()->clear(); - f_indices.endEdit(); -} - -template -void ProjectDirectionConstraint::addConstraint(Index index) -{ - f_indices.beginEdit()->push_back(index); - f_indices.endEdit(); -} - -template -void ProjectDirectionConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*f_indices.beginEdit(),index); - f_indices.endEdit(); -} - -// -- Constraint interface - - -template -void ProjectDirectionConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - f_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - const Indices & indices = f_indices.getValue(); - - const Index maxIndex=this->mstate->getSize(); - for (unsigned int i=0; i= maxIndex) - { - msg_error() << "Index " << index << " not valid!"; - removeConstraint(index); - } - } - - reinit(); -} - -template -void ProjectDirectionConstraint::reinit() -{ - // normalize the normal vector - CPos n = f_direction.getValue(); - if( n.norm()==0 ) - n[1]=0; - else n *= 1/n.norm(); - f_direction.setValue(n); - - // create the matrix blocks corresponding to the projection to the line: nn^t or to the identity - Block bProjection; - for(unsigned i=0; imstate->getSize(); - const unsigned blockSize = DataTypes::deriv_total_size; - jacobian.resize( numBlocks*blockSize,numBlocks*blockSize ); - - // fill the jacobian in ascending order - Indices::const_iterator it = tmp.begin(); - unsigned i = 0; - while( i < numBlocks ) - { - if( it != tmp.end() && i==*it ) // constrained particle: set diagonal to projection block, and the cursor to the next constraint - { - jacobian.insertBackBlock(i,i,bProjection); - ++it; - } - else // unconstrained particle: set diagonal to identity block - { - jacobian.insertBackBlock(i,i,Block::Identity()); - } - i++; - } - jacobian.compress(); - - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - const Indices &indices = f_indices.getValue(); - for (const auto id : indices) - { - m_origin.push_back(DataTypes::getCPos(x[id])); - } - -} - -template -void ProjectDirectionConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state - BaseSparseMatrix* E = dynamic_cast(M); - assert(E); - E->compressedMatrix = J.compressedMatrix * E->compressedMatrix * J.compressedMatrix; -} - - - -template -void ProjectDirectionConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res ( resData ); - jacobian.mult(res.wref(),res.ref()); -} - -template -void ProjectDirectionConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) -{ - msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; -} - -template -void ProjectDirectionConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - projectResponse(mparams,vData); -} - -template -void ProjectDirectionConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) -{ - VecCoord& x = *xData.beginEdit(); - - const CPos& n = f_direction.getValue(); - - const Indices& indices = f_indices.getValue(); - for(unsigned i=0; i -void ProjectDirectionConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - msg_error() << "applyConstraint is not implemented"; -} - -template -void ProjectDirectionConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - dmsg_error() << "ProjectDirectionConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented"; -} - - - - -template -void ProjectDirectionConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) return; - if (!this->isActive()) return; - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - const Indices & indices = f_indices.getValue(); - - if( f_drawSize.getValue() == 0) // old classical drawing by points - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - for (unsigned int index : indices) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); - } - else // new drawing by spheres - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - for (unsigned int index : indices) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); - } - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp similarity index 80% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp index 9d956a1949d..70d1e00b0a1 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectDirectionConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectDirectionProjectiveConstraint_CPP +#include #include #include @@ -32,14 +32,14 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectDirectionConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< ProjectDirectionConstraint >() - .add< ProjectDirectionConstraint >() +int ProjectDirectionProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< ProjectDirectionProjectiveConstraint >() + .add< ProjectDirectionProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h new file mode 100644 index 00000000000..3da00ee882c --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h @@ -0,0 +1,137 @@ +/****************************************************************************** +* 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 +#include +#include +#include +#include + +namespace sofa::component::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class ProjectDirectionProjectiveConstraintInternalData +{ + +}; + +/** Project particles to an affine straight line going through the particle original position. +*/ +template +class ProjectDirectionProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(ProjectDirectionProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::CPos CPos; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector Indices; + SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); + typedef sofa::core::topology::TopologySubsetIndices IndexSubsetData; + typedef linearalgebra::EigenBaseSparseMatrix BaseSparseMatrix; + typedef linearalgebra::EigenSparseMatrix SparseMatrix; + typedef typename SparseMatrix::Block Block; ///< projection matrix of a particle displacement to the plane + enum {bsize=SparseMatrix::Nin}; ///< size of a block + + +protected: + ProjectDirectionProjectiveConstraint(); + + virtual ~ProjectDirectionProjectiveConstraint(); + +public: + IndexSubsetData f_indices; ///< the particles to project + Data f_drawSize; ///< The size of the square used to display the constrained particles + Data f_direction; ///< The direction of the line. Will be normalized by init() + + /// 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: + ProjectDirectionProjectiveConstraintInternalData* data; + friend class ProjectDirectionProjectiveConstraintInternalData; + + type::vector m_origin; + + +public: + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + // -- Constraint interface + void init() override; + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + /// Project the given matrix (Experimental API, see the spec in sofa::core::behavior::BaseProjectiveConstraintSet). + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + + void draw(const core::visual::VisualParams* vparams) override; + +protected : + + SparseMatrix jacobian; ///< projection matrix in local state + SparseMatrix J; ///< auxiliary variable +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectDirectionProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; + +#endif + +template +using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectDirectionConstraint has been renamed to ProjectDirectionProjectiveConstraint") = ProjectDirectionProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl new file mode 100644 index 00000000000..af1d8f39f3f --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl @@ -0,0 +1,277 @@ +/****************************************************************************** +* 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 + + +namespace sofa::component::constraint::projective +{ + +template +ProjectDirectionProjectiveConstraint::ProjectDirectionProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) + , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) + , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) + , l_topology(initLink("topology", "link to the topology container")) + , data(new ProjectDirectionProjectiveConstraintInternalData()) +{ + f_indices.beginEdit()->push_back(0); + f_indices.endEdit(); +} + + +template +ProjectDirectionProjectiveConstraint::~ProjectDirectionProjectiveConstraint() +{ + delete data; +} + +template +void ProjectDirectionProjectiveConstraint::clearConstraints() +{ + f_indices.beginEdit()->clear(); + f_indices.endEdit(); +} + +template +void ProjectDirectionProjectiveConstraint::addConstraint(Index index) +{ + f_indices.beginEdit()->push_back(index); + f_indices.endEdit(); +} + +template +void ProjectDirectionProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*f_indices.beginEdit(),index); + f_indices.endEdit(); +} + +// -- Constraint interface + + +template +void ProjectDirectionProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + const Indices & indices = f_indices.getValue(); + + const Index maxIndex=this->mstate->getSize(); + for (unsigned int i=0; i= maxIndex) + { + msg_error() << "Index " << index << " not valid!"; + removeConstraint(index); + } + } + + reinit(); +} + +template +void ProjectDirectionProjectiveConstraint::reinit() +{ + // normalize the normal vector + CPos n = f_direction.getValue(); + if( n.norm()==0 ) + n[1]=0; + else n *= 1/n.norm(); + f_direction.setValue(n); + + // create the matrix blocks corresponding to the projection to the line: nn^t or to the identity + Block bProjection; + for(unsigned i=0; imstate->getSize(); + const unsigned blockSize = DataTypes::deriv_total_size; + jacobian.resize( numBlocks*blockSize,numBlocks*blockSize ); + + // fill the jacobian in ascending order + Indices::const_iterator it = tmp.begin(); + unsigned i = 0; + while( i < numBlocks ) + { + if( it != tmp.end() && i==*it ) // constrained particle: set diagonal to projection block, and the cursor to the next constraint + { + jacobian.insertBackBlock(i,i,bProjection); + ++it; + } + else // unconstrained particle: set diagonal to identity block + { + jacobian.insertBackBlock(i,i,Block::Identity()); + } + i++; + } + jacobian.compress(); + + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + const Indices &indices = f_indices.getValue(); + for (const auto id : indices) + { + m_origin.push_back(DataTypes::getCPos(x[id])); + } + +} + +template +void ProjectDirectionProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state + BaseSparseMatrix* E = dynamic_cast(M); + assert(E); + E->compressedMatrix = J.compressedMatrix * E->compressedMatrix * J.compressedMatrix; +} + + + +template +void ProjectDirectionProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res ( resData ); + jacobian.mult(res.wref(),res.ref()); +} + +template +void ProjectDirectionProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) +{ + msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; +} + +template +void ProjectDirectionProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + projectResponse(mparams,vData); +} + +template +void ProjectDirectionProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) +{ + VecCoord& x = *xData.beginEdit(); + + const CPos& n = f_direction.getValue(); + + const Indices& indices = f_indices.getValue(); + for(unsigned i=0; i +void ProjectDirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + msg_error() << "applyConstraint is not implemented"; +} + +template +void ProjectDirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + dmsg_error() << "ProjectDirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented"; +} + + + + +template +void ProjectDirectionProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) return; + if (!this->isActive()) return; + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + const Indices & indices = f_indices.getValue(); + + if( f_drawSize.getValue() == 0) // old classical drawing by points + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + for (unsigned int index : indices) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); + } + else // new drawing by spheres + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + for (unsigned int index : indices) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); + } + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h index 9e30c5687d7..4517e80a549 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h @@ -20,119 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class ProjectToLineConstraintInternalData -{ - -}; - -/** Project particles to an affine straight line. - @author Francois Faure, 2012 - @todo Optimized versions for lines parallel to the main directions -*/ -template -class ProjectToLineConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectToLineConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::CPos CPos; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); - typedef type::vector Indices; - typedef sofa::core::topology::TopologySubsetIndices IndexSubsetData; - typedef linearalgebra::EigenBaseSparseMatrix BaseSparseMatrix; - typedef linearalgebra::EigenSparseMatrix SparseMatrix; - typedef typename SparseMatrix::Block Block; ///< projection matrix of a particle displacement to the plane - enum {bsize=SparseMatrix::Nin}; ///< size of a block - - -protected: - ProjectToLineConstraint(); - - virtual ~ProjectToLineConstraint(); - -public: - IndexSubsetData f_indices; ///< the particles to project - Data f_drawSize; ///< The size of the square used to display the constrained particles - Data f_origin; ///< A point on the line - Data f_direction; ///< The direction of the line. Will be normalized by init() - - /// 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: - ProjectToLineConstraintInternalData* data; - friend class ProjectToLineConstraintInternalData; - - -public: - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - // -- Constraint interface - void init() override; - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - /// Project the given matrix (Experimental API, see the spec in sofa::core::behavior::BaseProjectiveConstraintSet). - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - - void draw(const core::visual::VisualParams* vparams) override; - -protected : - - SparseMatrix jacobian; ///< projection matrix in local state - SparseMatrix J; ///< auxiliary variable - - /// Resize/update Jacobian matrix according to the linked mechanical state and the direction - void updateJacobian(); - -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToLineConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl index 7abe1ce1c5e..4517e80a549 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl @@ -21,266 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -ProjectToLineConstraint::ProjectToLineConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) - , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) - , f_origin( initData(&f_origin,CPos(),"origin","A point in the line")) - , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) - , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectToLineConstraintInternalData()) -{ - f_indices.beginEdit()->push_back(0); - f_indices.endEdit(); -} - - -template -ProjectToLineConstraint::~ProjectToLineConstraint() -{ - delete data; -} - -template -void ProjectToLineConstraint::clearConstraints() -{ - f_indices.beginEdit()->clear(); - f_indices.endEdit(); -} - -template -void ProjectToLineConstraint::addConstraint(Index index) -{ - f_indices.beginEdit()->push_back(index); - f_indices.endEdit(); -} - -template -void ProjectToLineConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*f_indices.beginEdit(),index); - f_indices.endEdit(); -} - -// -- Constraint interface - - -template -void ProjectToLineConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - f_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - const Indices & indices = f_indices.getValue(); - - const Index maxIndex=this->mstate->getSize(); - for (unsigned int i=0; i= maxIndex) - { - msg_error() << "Index " << index << " not valid!"; - removeConstraint(index); - } - } - - updateJacobian(); -} - -template -void ProjectToLineConstraint::reinit() -{ - updateJacobian(); -} - -template -void ProjectToLineConstraint::updateJacobian() -{ - // normalize the normal vector - CPos n = f_direction.getValue(); - if( n.norm()==0 ) - n[0]=1; // arbritary normal vector - else n *= 1/n.norm(); - f_direction.setValue(n); - - // create the matrix blocks corresponding to the projection to the line: nn^t or to the identity - Block bProjection; - for(unsigned i=0; imstate->getSize(); - const unsigned blockSize = DataTypes::deriv_total_size; - jacobian.resize( numBlocks*blockSize,numBlocks*blockSize ); - - // fill the jacobian in ascending order - Indices::const_iterator it = tmp.begin(); - unsigned i = 0; - while( i < numBlocks ) // (FF) do not stop after the last constrained particle, for the remainder of the diagonal would be null, while it must be identity. - { - if( it!=tmp.end() && i==*it ) // constrained particle: set diagonal to projection block, and the cursor to the next constraint - { - jacobian.insertBackBlock(i,i,bProjection); - ++it; - } - else // unconstrained particle: set diagonal to identity block - { - jacobian.insertBackBlock(i,i,Block::Identity()); - } - i++; - } - jacobian.compress(); -} - -template -void ProjectToLineConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state - BaseSparseMatrix* E = dynamic_cast(M); - assert(E); - E->compressedMatrix = J.compressedMatrix * E->compressedMatrix * J.compressedMatrix; -} - - - -template -void ProjectToLineConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res(resData); - - using Size = decltype(jacobian.colSize()); - if( (jacobian.colSize() / Size(DataTypes::deriv_total_size)) != Size(res.size())) - { - updateJacobian(); - } - - jacobian.mult(res.wref(),res.ref()); -} - -template -void ProjectToLineConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) -{ - msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; -} - -template -void ProjectToLineConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - projectResponse(mparams,vData); -} - -template -void ProjectToLineConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) -{ - VecCoord& x = *xData.beginEdit(); - - const CPos& n = f_direction.getValue(); - const CPos& o = f_origin.getValue(); - - const Indices& indices = f_indices.getValue(); - for(unsigned i=0; i -void ProjectToLineConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - msg_error() << "applyConstraint is not implemented "; -} - -template -void ProjectToLineConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - msg_error() << "ProjectToLineConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; -} - - - - -template -void ProjectToLineConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) return; - if (!this->isActive()) return; - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - const Indices & indices = f_indices.getValue(); - - if( f_drawSize.getValue() == 0) // old classical drawing by points - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - - for (Indices::const_iterator it = indices.begin(); - it != indices.end(); - ++it) - { - point = DataTypes::getCPos(x[*it]); - points.push_back(point); - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); - } - else // new drawing by spheres - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - for (unsigned int index : indices) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); - } - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp similarity index 80% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp index 8d584ac88e0..beaab2ce92d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPlaneConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToLineProjectiveConstraint_CPP +#include #include namespace sofa::component::constraint::projective @@ -30,14 +30,13 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectToPlaneConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< ProjectToPlaneConstraint >() - .add< ProjectToPlaneConstraint >() +int ProjectToLineProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< ProjectToLineProjectiveConstraint >() + .add< ProjectToLineProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; } // namespace sofa::component::constraint::projective - diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h new file mode 100644 index 00000000000..c4e2f352b52 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h @@ -0,0 +1,141 @@ +/****************************************************************************** +* 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 +#include +#include +#include + +namespace sofa::component::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class ProjectToLineProjectiveConstraintInternalData +{ + +}; + +/** Project particles to an affine straight line. + @author Francois Faure, 2012 + @todo Optimized versions for lines parallel to the main directions +*/ +template +class ProjectToLineProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(ProjectToLineProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::CPos CPos; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); + typedef type::vector Indices; + typedef sofa::core::topology::TopologySubsetIndices IndexSubsetData; + typedef linearalgebra::EigenBaseSparseMatrix BaseSparseMatrix; + typedef linearalgebra::EigenSparseMatrix SparseMatrix; + typedef typename SparseMatrix::Block Block; ///< projection matrix of a particle displacement to the plane + enum {bsize=SparseMatrix::Nin}; ///< size of a block + + +protected: + ProjectToLineProjectiveConstraint(); + + virtual ~ProjectToLineProjectiveConstraint(); + +public: + IndexSubsetData f_indices; ///< the particles to project + Data f_drawSize; ///< The size of the square used to display the constrained particles + Data f_origin; ///< A point on the line + Data f_direction; ///< The direction of the line. Will be normalized by init() + + /// 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: + ProjectToLineProjectiveConstraintInternalData* data; + friend class ProjectToLineProjectiveConstraintInternalData; + + +public: + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + // -- Constraint interface + void init() override; + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + /// Project the given matrix (Experimental API, see the spec in sofa::core::behavior::BaseProjectiveConstraintSet). + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + + void draw(const core::visual::VisualParams* vparams) override; + +protected : + + SparseMatrix jacobian; ///< projection matrix in local state + SparseMatrix J; ///< auxiliary variable + + /// Resize/update Jacobian matrix according to the linked mechanical state and the direction + void updateJacobian(); + +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToLineProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; + +#endif + +template +using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToLineConstraint has been renamed to ProjectToLineProjectiveConstraint") = ProjectToLineProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl new file mode 100644 index 00000000000..51fa74ebcc9 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl @@ -0,0 +1,286 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +template +ProjectToLineProjectiveConstraint::ProjectToLineProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) + , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) + , f_origin( initData(&f_origin,CPos(),"origin","A point in the line")) + , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) + , l_topology(initLink("topology", "link to the topology container")) + , data(new ProjectToLineProjectiveConstraintInternalData()) +{ + f_indices.beginEdit()->push_back(0); + f_indices.endEdit(); +} + + +template +ProjectToLineProjectiveConstraint::~ProjectToLineProjectiveConstraint() +{ + delete data; +} + +template +void ProjectToLineProjectiveConstraint::clearConstraints() +{ + f_indices.beginEdit()->clear(); + f_indices.endEdit(); +} + +template +void ProjectToLineProjectiveConstraint::addConstraint(Index index) +{ + f_indices.beginEdit()->push_back(index); + f_indices.endEdit(); +} + +template +void ProjectToLineProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*f_indices.beginEdit(),index); + f_indices.endEdit(); +} + +// -- Constraint interface + + +template +void ProjectToLineProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + const Indices & indices = f_indices.getValue(); + + const Index maxIndex=this->mstate->getSize(); + for (unsigned int i=0; i= maxIndex) + { + msg_error() << "Index " << index << " not valid!"; + removeConstraint(index); + } + } + + updateJacobian(); +} + +template +void ProjectToLineProjectiveConstraint::reinit() +{ + updateJacobian(); +} + +template +void ProjectToLineProjectiveConstraint::updateJacobian() +{ + // normalize the normal vector + CPos n = f_direction.getValue(); + if( n.norm()==0 ) + n[0]=1; // arbritary normal vector + else n *= 1/n.norm(); + f_direction.setValue(n); + + // create the matrix blocks corresponding to the projection to the line: nn^t or to the identity + Block bProjection; + for(unsigned i=0; imstate->getSize(); + const unsigned blockSize = DataTypes::deriv_total_size; + jacobian.resize( numBlocks*blockSize,numBlocks*blockSize ); + + // fill the jacobian in ascending order + Indices::const_iterator it = tmp.begin(); + unsigned i = 0; + while( i < numBlocks ) // (FF) do not stop after the last constrained particle, for the remainder of the diagonal would be null, while it must be identity. + { + if( it!=tmp.end() && i==*it ) // constrained particle: set diagonal to projection block, and the cursor to the next constraint + { + jacobian.insertBackBlock(i,i,bProjection); + ++it; + } + else // unconstrained particle: set diagonal to identity block + { + jacobian.insertBackBlock(i,i,Block::Identity()); + } + i++; + } + jacobian.compress(); +} + +template +void ProjectToLineProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state + BaseSparseMatrix* E = dynamic_cast(M); + assert(E); + E->compressedMatrix = J.compressedMatrix * E->compressedMatrix * J.compressedMatrix; +} + + + +template +void ProjectToLineProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res(resData); + + using Size = decltype(jacobian.colSize()); + if( (jacobian.colSize() / Size(DataTypes::deriv_total_size)) != Size(res.size())) + { + updateJacobian(); + } + + jacobian.mult(res.wref(),res.ref()); +} + +template +void ProjectToLineProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) +{ + msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; +} + +template +void ProjectToLineProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + projectResponse(mparams,vData); +} + +template +void ProjectToLineProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) +{ + VecCoord& x = *xData.beginEdit(); + + const CPos& n = f_direction.getValue(); + const CPos& o = f_origin.getValue(); + + const Indices& indices = f_indices.getValue(); + for(unsigned i=0; i +void ProjectToLineProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + msg_error() << "applyConstraint is not implemented "; +} + +template +void ProjectToLineProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + msg_error() << "ProjectToLineProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; +} + + + + +template +void ProjectToLineProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) return; + if (!this->isActive()) return; + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + const Indices & indices = f_indices.getValue(); + + if( f_drawSize.getValue() == 0) // old classical drawing by points + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + + for (Indices::const_iterator it = indices.begin(); + it != indices.end(); + ++it) + { + point = DataTypes::getCPos(x[*it]); + points.push_back(point); + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); + } + else // new drawing by spheres + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + for (unsigned int index : indices) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); + } + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h index 925bf007d65..b84d4e807d1 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h @@ -20,118 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class ProjectToPlaneConstraintInternalData -{ - -}; - -/** Project particles to an affine plane. - @author Francois Faure, 2012 - @todo Optimized versions for planes parallel to the main directions -*/ -template -class ProjectToPlaneConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectToPlaneConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::CPos CPos; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector Indices; - typedef sofa::core::topology::TopologySubsetIndices IndexSubsetData; - typedef linearalgebra::EigenBaseSparseMatrix BaseSparseMatrix; - typedef linearalgebra::EigenSparseMatrix SparseMatrix; - typedef typename SparseMatrix::Block Block; ///< projection matrix of a particle displacement to the plane - enum {bsize=SparseMatrix::Nin}; ///< size of a block - - SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); - -protected: - ProjectToPlaneConstraint(); - - virtual ~ProjectToPlaneConstraint(); - -public: - IndexSubsetData f_indices; ///< the particles to project - Data f_origin; ///< A point in the plane - Data f_normal; ///< The normal to the plane. Will be normalized by init(). - Data f_drawSize; ///< The size of the display of the constrained particles - - /// 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: - ProjectToPlaneConstraintInternalData* data; - friend class ProjectToPlaneConstraintInternalData; - - -public: - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - // -- Constraint interface - void init() override; - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - /** Project the given matrix (Experimental API). - Replace M with PMP, where P is the projection matrix corresponding to the projectResponse method, shifted by the given offset, i.e. P is the identity matrix with a block on the diagonal replaced by the projection matrix. - */ - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - - void draw(const core::visual::VisualParams* vparams) override; - -protected : - - SparseMatrix jacobian; ///< projection matrix in local state - SparseMatrix J; ///< auxiliary variable -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPlaneConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +#include +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl index 6e7fd9be4f2..7720a8b39fc 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl @@ -21,256 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -ProjectToPlaneConstraint::ProjectToPlaneConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) - , f_origin( initData(&f_origin,CPos(),"origin","A point in the plane")) - , f_normal( initData(&f_normal,CPos(),"normal","Normal vector to the plane")) - , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) - , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectToPlaneConstraintInternalData()) -{ - f_indices.beginEdit()->push_back(0); - f_indices.endEdit(); -} - - -template -ProjectToPlaneConstraint::~ProjectToPlaneConstraint() -{ - delete data; -} - -template -void ProjectToPlaneConstraint::clearConstraints() -{ - f_indices.beginEdit()->clear(); - f_indices.endEdit(); -} - -template -void ProjectToPlaneConstraint::addConstraint(Index index) -{ - f_indices.beginEdit()->push_back(index); - f_indices.endEdit(); -} - -template -void ProjectToPlaneConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*f_indices.beginEdit(),index); - f_indices.endEdit(); -} - -// -- Constraint interface - - -template -void ProjectToPlaneConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - f_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - const Indices & indices = f_indices.getValue(); - - const Index maxIndex=this->mstate->getSize(); - for (unsigned int i=0; i= maxIndex) - { - msg_error() << "Index " << index << " not valid!"; - removeConstraint(index); - } - } - - reinit(); - -} - -template -void ProjectToPlaneConstraint::reinit() -{ - - // normalize the normal vector - CPos n = f_normal.getValue(); - if( n.norm()==0 ) - n[1]=0; - else n *= 1/n.norm(); - f_normal.setValue(n); - - // create the matrix blocks corresponding to the projection to the plane: I-nn^t or to the identity - Block bProjection; - for(unsigned i=0; imstate->getSize(); - const unsigned blockSize = DataTypes::deriv_total_size; - jacobian.resize( numBlocks*blockSize,numBlocks*blockSize ); - - // fill the jacobian in ascending order - unsigned i=0; - Indices::const_iterator it = tmp.begin(); - while( i -void ProjectToPlaneConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state - BaseSparseMatrix* E = dynamic_cast(M); - assert(E); - E->compressedMatrix = J.compressedMatrix * E->compressedMatrix * J.compressedMatrix; -} - - - -template -void ProjectToPlaneConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res ( resData ); - jacobian.mult(res.wref(),res.ref()); -} - -template -void ProjectToPlaneConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) -{ - msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; -} - -template -void ProjectToPlaneConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) -{ - projectResponse(mparams,vData); -} - -template -void ProjectToPlaneConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) -{ - VecCoord& x = *xData.beginEdit(); - - const CPos& n = f_normal.getValue(); - const CPos& o = f_origin.getValue(); - - const Indices& indices = f_indices.getValue(); - for(unsigned i=0; i -void ProjectToPlaneConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - msg_error() << "applyConstraint is not implemented "; -} - -template -void ProjectToPlaneConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - msg_error() << "ProjectToPlaneConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; -} - -template -void ProjectToPlaneConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) return; - if (!this->isActive()) return; - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - const Indices & indices = f_indices.getValue(); - - if( f_drawSize.getValue() == 0) // old classical drawing by points - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - for (unsigned int index : indices) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); - } - else // new drawing by spheres - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - - for (unsigned int index : indices) - { - point = DataTypes::getCPos(x[index]); - points.push_back(point); - } - vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); - } - - -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp similarity index 80% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp index 5c701444225..0ce7f0dccee 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToLineConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPlaneProjectiveConstraint_CPP +#include #include namespace sofa::component::constraint::projective @@ -30,13 +30,14 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectToLineConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< ProjectToLineConstraint >() - .add< ProjectToLineConstraint >() +int ProjectToPlaneProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< ProjectToPlaneProjectiveConstraint >() + .add< ProjectToPlaneProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; } // namespace sofa::component::constraint::projective + diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h new file mode 100644 index 00000000000..49544d2395d --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h @@ -0,0 +1,140 @@ +/****************************************************************************** +* 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 +#include +#include +#include + +namespace sofa::component::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class ProjectToPlaneProjectiveConstraintInternalData +{ + +}; + +/** Project particles to an affine plane. + @author Francois Faure, 2012 + @todo Optimized versions for planes parallel to the main directions +*/ +template +class ProjectToPlaneProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(ProjectToPlaneProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::CPos CPos; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector Indices; + typedef sofa::core::topology::TopologySubsetIndices IndexSubsetData; + typedef linearalgebra::EigenBaseSparseMatrix BaseSparseMatrix; + typedef linearalgebra::EigenSparseMatrix SparseMatrix; + typedef typename SparseMatrix::Block Block; ///< projection matrix of a particle displacement to the plane + enum {bsize=SparseMatrix::Nin}; ///< size of a block + + SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); + +protected: + ProjectToPlaneProjectiveConstraint(); + + virtual ~ProjectToPlaneProjectiveConstraint(); + +public: + IndexSubsetData f_indices; ///< the particles to project + Data f_origin; ///< A point in the plane + Data f_normal; ///< The normal to the plane. Will be normalized by init(). + Data f_drawSize; ///< The size of the display of the constrained particles + + /// 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: + ProjectToPlaneProjectiveConstraintInternalData* data; + friend class ProjectToPlaneProjectiveConstraintInternalData; + + +public: + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + // -- Constraint interface + void init() override; + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + /** Project the given matrix (Experimental API). + Replace M with PMP, where P is the projection matrix corresponding to the projectResponse method, shifted by the given offset, i.e. P is the identity matrix with a block on the diagonal replaced by the projection matrix. + */ + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + + void draw(const core::visual::VisualParams* vparams) override; + +protected : + + SparseMatrix jacobian; ///< projection matrix in local state + SparseMatrix J; ///< auxiliary variable +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPlaneProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; + +#endif + +template +using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPlaneConstraint has been renamed to ProjectToPlaneProjectiveConstraint") = ProjectToPlaneProjectiveConstraint; + +} // namespace sofa::component::constraint::projective + diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl new file mode 100644 index 00000000000..a4a9ea7d627 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl @@ -0,0 +1,276 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +template +ProjectToPlaneProjectiveConstraint::ProjectToPlaneProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) + , f_origin( initData(&f_origin,CPos(),"origin","A point in the plane")) + , f_normal( initData(&f_normal,CPos(),"normal","Normal vector to the plane")) + , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) + , l_topology(initLink("topology", "link to the topology container")) + , data(new ProjectToPlaneProjectiveConstraintInternalData()) +{ + f_indices.beginEdit()->push_back(0); + f_indices.endEdit(); +} + + +template +ProjectToPlaneProjectiveConstraint::~ProjectToPlaneProjectiveConstraint() +{ + delete data; +} + +template +void ProjectToPlaneProjectiveConstraint::clearConstraints() +{ + f_indices.beginEdit()->clear(); + f_indices.endEdit(); +} + +template +void ProjectToPlaneProjectiveConstraint::addConstraint(Index index) +{ + f_indices.beginEdit()->push_back(index); + f_indices.endEdit(); +} + +template +void ProjectToPlaneProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*f_indices.beginEdit(),index); + f_indices.endEdit(); +} + +// -- Constraint interface + + +template +void ProjectToPlaneProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + const Indices & indices = f_indices.getValue(); + + const Index maxIndex=this->mstate->getSize(); + for (unsigned int i=0; i= maxIndex) + { + msg_error() << "Index " << index << " not valid!"; + removeConstraint(index); + } + } + + reinit(); + +} + +template +void ProjectToPlaneProjectiveConstraint::reinit() +{ + + // normalize the normal vector + CPos n = f_normal.getValue(); + if( n.norm()==0 ) + n[1]=0; + else n *= 1/n.norm(); + f_normal.setValue(n); + + // create the matrix blocks corresponding to the projection to the plane: I-nn^t or to the identity + Block bProjection; + for(unsigned i=0; imstate->getSize(); + const unsigned blockSize = DataTypes::deriv_total_size; + jacobian.resize( numBlocks*blockSize,numBlocks*blockSize ); + + // fill the jacobian in ascending order + unsigned i=0; + Indices::const_iterator it = tmp.begin(); + while( i +void ProjectToPlaneProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state + BaseSparseMatrix* E = dynamic_cast(M); + assert(E); + E->compressedMatrix = J.compressedMatrix * E->compressedMatrix * J.compressedMatrix; +} + + + +template +void ProjectToPlaneProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res ( resData ); + jacobian.mult(res.wref(),res.ref()); +} + +template +void ProjectToPlaneProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) +{ + msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; +} + +template +void ProjectToPlaneProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +{ + projectResponse(mparams,vData); +} + +template +void ProjectToPlaneProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) +{ + VecCoord& x = *xData.beginEdit(); + + const CPos& n = f_normal.getValue(); + const CPos& o = f_origin.getValue(); + + const Indices& indices = f_indices.getValue(); + for(unsigned i=0; i +void ProjectToPlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + msg_error() << "applyConstraint is not implemented "; +} + +template +void ProjectToPlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + msg_error() << "ProjectToPlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; +} + +template +void ProjectToPlaneProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) return; + if (!this->isActive()) return; + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + const Indices & indices = f_indices.getValue(); + + if( f_drawSize.getValue() == 0) // old classical drawing by points + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + for (unsigned int index : indices) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); + } + else // new drawing by spheres + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + + for (unsigned int index : indices) + { + point = DataTypes::getCPos(x[index]); + points.push_back(point); + } + vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); + } + + +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h index 91a50f2b7c0..46e68da759e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h @@ -20,112 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -/// This class can be overridden if needed for additionnal storage within template specializations. -template -class ProjectToPointConstraintInternalData -{ - -}; - -/** Attach given particles to their initial positions. - * Contrary to FixedConstraint, this one stops the particles even if they have a non-null initial velocity. - * @sa FixedConstraint -*/ -template -class ProjectToPointConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectToPointConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); - - using Index = sofa::Index; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - typedef type::vector SetIndexArray; - typedef sofa::core::topology::TopologySubsetIndices SetIndex; - - SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); - -protected: - ProjectToPointConstraint(); - - virtual ~ProjectToPointConstraint(); - -public: - SetIndex f_indices; ///< the indices of the points to project to the target - Data f_point; ///< the target of the projection - Data f_fixAll; ///< to project all the points, rather than those listed in f_indices - Data f_drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres - - /// 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: - ProjectToPointConstraintInternalData* data; - friend class ProjectToPointConstraintInternalData; - - -public: - void clearConstraints(); - void addConstraint(Index index); - void removeConstraint(Index index); - - // -- Constraint interface - void init() override; - void reinit() override; - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - /** Project the given matrix (Experimental API). - Replace M with PMP, where P is the projection matrix corresponding to the projectResponse method, shifted by the given offset, i.e. P is the identity matrix with a block on the diagonal replaced by the projection matrix. - */ - void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; - - - void draw(const core::visual::VisualParams* vparams) override; - - bool fixAllDOFs() const { return f_fixAll.getValue(); } - -protected : - -}; - - -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPointConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; - -#endif - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl index 8bfd98db63a..03afaee1b2e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl @@ -21,304 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace sofa::component::constraint::projective -{ - -template -ProjectToPointConstraint::ProjectToPointConstraint() - : core::behavior::ProjectiveConstraintSet(nullptr) - , f_indices( initData(&f_indices,"indices","Indices of the points to project") ) - , f_point( initData(&f_point,"point","Target of the projection") ) - , f_fixAll( initData(&f_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) - , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) - , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectToPointConstraintInternalData()) -{ - f_indices.beginEdit()->push_back(0); - f_indices.endEdit(); -} - - -template -ProjectToPointConstraint::~ProjectToPointConstraint() -{ - delete data; -} - -template -void ProjectToPointConstraint::clearConstraints() -{ - f_indices.beginEdit()->clear(); - f_indices.endEdit(); -} - -template -void ProjectToPointConstraint::addConstraint(Index index) -{ - f_indices.beginEdit()->push_back(index); - f_indices.endEdit(); -} - -template -void ProjectToPointConstraint::removeConstraint(Index index) -{ - sofa::type::removeValue(*f_indices.beginEdit(),index); - f_indices.endEdit(); -} - -// -- Constraint interface - - -template -void ProjectToPointConstraint::init() -{ - this->core::behavior::ProjectiveConstraintSet::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()); - } - - if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) - { - msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; - - // Initialize topological changes support - f_indices.createTopologyHandler(_topology); - } - else - { - msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; - } - - const SetIndexArray & indices = f_indices.getValue(); - - std::stringstream sstream; - const Index maxIndex=this->mstate->getSize(); - for (unsigned int i=0; i= maxIndex) - { - sstream << "Index " << index << " not valid!\n"; - removeConstraint(index); - } - } - msg_error_when(!sstream.str().empty()) << sstream.str(); - - reinit(); -} - -template -void ProjectToPointConstraint::reinit() -{ - - // get the indices sorted - SetIndexArray tmp = f_indices.getValue(); - std::sort(tmp.begin(),tmp.end()); -} - -template -void ProjectToPointConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - const unsigned blockSize = DataTypes::deriv_total_size; - - // clears the rows and columns associated with fixed particles - for (const auto id : f_indices.getValue()) - { - M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); - } -} - -template -void ProjectToPointConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res ( resData ); - const SetIndexArray & indices = f_indices.getValue(); - if( f_fixAll.getValue() ) - { - // fix everything - typename VecDeriv::iterator it; - for( it = res.begin(); it != res.end(); ++it ) - { - *it = Deriv(); - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); - it != indices.end(); - ++it) - { - res[*it] = Deriv(); - } - } -} - -template -void ProjectToPointConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor c ( cData ); - - if( f_fixAll.getValue() ) - { - // fix everything - c->clear(); - } - else - { - const SetIndexArray& indices = f_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); - it != indices.end(); - ++it) - { - c->clearColBlock(*it); - } - } -} - -template -void ProjectToPointConstraint::projectVelocity(const core::MechanicalParams* mparams , DataVecDeriv& vData) -{ - projectResponse(mparams, vData); -} - -template -void ProjectToPointConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) -{ - SOFA_UNUSED(mparams); - - helper::WriteAccessor res ( xData ); - const SetIndexArray & indices = f_indices.getValue(); - if( f_fixAll.getValue() ) - { - // fix everything - typename VecCoord::iterator it; - for( it = res.begin(); it != res.end(); ++it ) - { - *it = f_point.getValue(); - } - } - else - { - for (SetIndexArray::const_iterator it = indices.begin(); - it != indices.end(); - ++it) - { - res[*it] = f_point.getValue(); - } - } -} - -template -void ProjectToPointConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) - { - const unsigned int N = Deriv::size(); - const SetIndexArray & indices = f_indices.getValue(); - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - // Reset Fixed Row and Col - for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); - // Set Fixed Vertex - for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); - } - } -} - -template -void ProjectToPointConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) -{ - SOFA_UNUSED(mparams); - const int o = matrix->getGlobalOffset(this->mstate.get()); - if (o >= 0) - { - const unsigned int offset = (unsigned int)o; - const unsigned int N = Deriv::size(); - - const SetIndexArray & indices = f_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for (unsigned int c=0; cclear(offset + N * (*it) + c); - } - } -} - - - - -template -void ProjectToPointConstraint::draw(const core::visual::VisualParams* vparams) -{ - if (!vparams->displayFlags().getShowBehaviorModels()) return; - if (!this->isActive()) return; - const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); - const SetIndexArray & indices = f_indices.getValue(); - - const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); - - if( f_drawSize.getValue() == 0) // old classical drawing by points - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - if( f_fixAll.getValue() ) - for (unsigned i=0; idrawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); - } - else // new drawing by spheres - { - std::vector< sofa::type::Vec3 > points; - sofa::type::Vec3 point; - if(f_fixAll.getValue()) - for (unsigned i=0; idrawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); - } - - -} - -} // namespace sofa::component::constraint::projective - - +#include +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp similarity index 76% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp index e76a0ffe931..b80f6bc0c80 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPointConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPointProjectiveConstraint_CPP +#include #include #include @@ -32,17 +32,17 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectToPointConstraintClass = core::RegisterObject("Project particles to a point") - .add< ProjectToPointConstraint >() - .add< ProjectToPointConstraint >() - .add< ProjectToPointConstraint >() - .add< ProjectToPointConstraint >() +int ProjectToPointProjectiveConstraintClass = core::RegisterObject("Project particles to a point") + .add< ProjectToPointProjectiveConstraint >() + .add< ProjectToPointProjectiveConstraint >() + .add< ProjectToPointProjectiveConstraint >() + .add< ProjectToPointProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h new file mode 100644 index 00000000000..db881be9af9 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h @@ -0,0 +1,133 @@ +/****************************************************************************** +* 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 +#include + +namespace sofa::component::constraint::projective +{ + +/// This class can be overridden if needed for additionnal storage within template specializations. +template +class ProjectToPointProjectiveConstraintInternalData +{ + +}; + +/** Attach given particles to their initial positions. + * Contrary to FixedConstraint, this one stops the particles even if they have a non-null initial velocity. + * @sa FixedConstraint +*/ +template +class ProjectToPointProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(ProjectToPointProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + + using Index = sofa::Index; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + typedef type::vector SetIndexArray; + typedef sofa::core::topology::TopologySubsetIndices SetIndex; + + SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); + +protected: + ProjectToPointProjectiveConstraint(); + + virtual ~ProjectToPointProjectiveConstraint(); + +public: + SetIndex f_indices; ///< the indices of the points to project to the target + Data f_point; ///< the target of the projection + Data f_fixAll; ///< to project all the points, rather than those listed in f_indices + Data f_drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres + + /// 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: + ProjectToPointProjectiveConstraintInternalData* data; + friend class ProjectToPointProjectiveConstraintInternalData; + + +public: + void clearConstraints(); + void addConstraint(Index index); + void removeConstraint(Index index); + + // -- Constraint interface + void init() override; + void reinit() override; + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + /** Project the given matrix (Experimental API). + Replace M with PMP, where P is the projection matrix corresponding to the projectResponse method, shifted by the given offset, i.e. P is the identity matrix with a block on the diagonal replaced by the projection matrix. + */ + void projectMatrix( sofa::linearalgebra::BaseMatrix* /*M*/, unsigned /*offset*/ ) override; + + + void draw(const core::visual::VisualParams* vparams) override; + + bool fixAllDOFs() const { return f_fixAll.getValue(); } + +protected : + +}; + + +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPointProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; + +#endif +template +using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPointConstraint has been renamed to ProjectToPointProjectiveConstraint") = ProjectToPointProjectiveConstraint; + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl new file mode 100644 index 00000000000..7e567574f5d --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl @@ -0,0 +1,324 @@ +/****************************************************************************** +* 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 + + +namespace sofa::component::constraint::projective +{ + +template +ProjectToPointProjectiveConstraint::ProjectToPointProjectiveConstraint() + : core::behavior::ProjectiveConstraintSet(nullptr) + , f_indices( initData(&f_indices,"indices","Indices of the points to project") ) + , f_point( initData(&f_point,"point","Target of the projection") ) + , f_fixAll( initData(&f_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) + , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) + , l_topology(initLink("topology", "link to the topology container")) + , data(new ProjectToPointProjectiveConstraintInternalData()) +{ + f_indices.beginEdit()->push_back(0); + f_indices.endEdit(); +} + + +template +ProjectToPointProjectiveConstraint::~ProjectToPointProjectiveConstraint() +{ + delete data; +} + +template +void ProjectToPointProjectiveConstraint::clearConstraints() +{ + f_indices.beginEdit()->clear(); + f_indices.endEdit(); +} + +template +void ProjectToPointProjectiveConstraint::addConstraint(Index index) +{ + f_indices.beginEdit()->push_back(index); + f_indices.endEdit(); +} + +template +void ProjectToPointProjectiveConstraint::removeConstraint(Index index) +{ + sofa::type::removeValue(*f_indices.beginEdit(),index); + f_indices.endEdit(); +} + +// -- Constraint interface + + +template +void ProjectToPointProjectiveConstraint::init() +{ + this->core::behavior::ProjectiveConstraintSet::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()); + } + + if (sofa::core::topology::BaseMeshTopology* _topology = l_topology.get()) + { + msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'"; + + // Initialize topological changes support + f_indices.createTopologyHandler(_topology); + } + else + { + msg_info() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name; + } + + const SetIndexArray & indices = f_indices.getValue(); + + std::stringstream sstream; + const Index maxIndex=this->mstate->getSize(); + for (unsigned int i=0; i= maxIndex) + { + sstream << "Index " << index << " not valid!\n"; + removeConstraint(index); + } + } + msg_error_when(!sstream.str().empty()) << sstream.str(); + + reinit(); +} + +template +void ProjectToPointProjectiveConstraint::reinit() +{ + + // get the indices sorted + SetIndexArray tmp = f_indices.getValue(); + std::sort(tmp.begin(),tmp.end()); +} + +template +void ProjectToPointProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + const unsigned blockSize = DataTypes::deriv_total_size; + + // clears the rows and columns associated with fixed particles + for (const auto id : f_indices.getValue()) + { + M->clearRowsCols( offset + id * blockSize, offset + (id+1) * blockSize ); + } +} + +template +void ProjectToPointProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res ( resData ); + const SetIndexArray & indices = f_indices.getValue(); + if( f_fixAll.getValue() ) + { + // fix everything + typename VecDeriv::iterator it; + for( it = res.begin(); it != res.end(); ++it ) + { + *it = Deriv(); + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); + it != indices.end(); + ++it) + { + res[*it] = Deriv(); + } + } +} + +template +void ProjectToPointProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor c ( cData ); + + if( f_fixAll.getValue() ) + { + // fix everything + c->clear(); + } + else + { + const SetIndexArray& indices = f_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); + it != indices.end(); + ++it) + { + c->clearColBlock(*it); + } + } +} + +template +void ProjectToPointProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams , DataVecDeriv& vData) +{ + projectResponse(mparams, vData); +} + +template +void ProjectToPointProjectiveConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) +{ + SOFA_UNUSED(mparams); + + helper::WriteAccessor res ( xData ); + const SetIndexArray & indices = f_indices.getValue(); + if( f_fixAll.getValue() ) + { + // fix everything + typename VecCoord::iterator it; + for( it = res.begin(); it != res.end(); ++it ) + { + *it = f_point.getValue(); + } + } + else + { + for (SetIndexArray::const_iterator it = indices.begin(); + it != indices.end(); + ++it) + { + res[*it] = f_point.getValue(); + } + } +} + +template +void ProjectToPointProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) + { + const unsigned int N = Deriv::size(); + const SetIndexArray & indices = f_indices.getValue(); + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + // Reset Fixed Row and Col + for (unsigned int c=0; cclearRowCol(r.offset + N * (*it) + c); + // Set Fixed Vertex + for (unsigned int c=0; cset(r.offset + N * (*it) + c, r.offset + N * (*it) + c, 1.0); + } + } +} + +template +void ProjectToPointProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + SOFA_UNUSED(mparams); + const int o = matrix->getGlobalOffset(this->mstate.get()); + if (o >= 0) + { + const unsigned int offset = (unsigned int)o; + const unsigned int N = Deriv::size(); + + const SetIndexArray & indices = f_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for (unsigned int c=0; cclear(offset + N * (*it) + c); + } + } +} + + + + +template +void ProjectToPointProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if (!vparams->displayFlags().getShowBehaviorModels()) return; + if (!this->isActive()) return; + const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue(); + const SetIndexArray & indices = f_indices.getValue(); + + const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle(); + + if( f_drawSize.getValue() == 0) // old classical drawing by points + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + if( f_fixAll.getValue() ) + for (unsigned i=0; idrawTool()->drawPoints(points, 10, sofa::type::RGBAColor(1,0.5,0.5,1)); + } + else // new drawing by spheres + { + std::vector< sofa::type::Vec3 > points; + sofa::type::Vec3 point; + if(f_fixAll.getValue()) + for (unsigned i=0; idrawTool()->drawSpheres(points, (float)f_drawSize.getValue(), sofa::type::RGBAColor(1.0f,0.35f,0.35f,1.0f)); + } + + +} + +} // namespace sofa::component::constraint::projective + + + diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h index e383eee8dad..402c3538226 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h @@ -20,229 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include - -namespace sofa::component::constraint::projective -{ - -// a joint of the skeletal hierarchy, it participates in the skeletal animation chain and may be animated -template -struct SkeletonJoint; - -// joints index to export in the MechanicalObject (in order to use them for skinning for instance) -typedef int SkeletonBone; - -// impose a specific motion (translation and rotation) for each DOFs of a MechanicalObject -template -class SkeletalMotionConstraint : public core::behavior::ProjectiveConstraintSet -{ -public: - SOFA_CLASS(SOFA_TEMPLATE(SkeletalMotionConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); - typedef TDataTypes DataTypes; - typedef sofa::core::behavior::ProjectiveConstraintSet TProjectiveConstraintSet; - typedef sofa::core::behavior::MechanicalState MechanicalState; - typedef typename DataTypes::VecCoord VecCoord; - typedef typename DataTypes::VecDeriv VecDeriv; - typedef typename DataTypes::MatrixDeriv MatrixDeriv; - typedef typename DataTypes::Coord Coord; - typedef typename DataTypes::Deriv Deriv; - typedef typename DataTypes::Real Real; - typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; - typedef typename MatrixDeriv::RowType MatrixDerivRowType; - typedef Data DataVecCoord; - typedef Data DataVecDeriv; - typedef Data DataMatrixDeriv; - -protected: - SkeletalMotionConstraint(); - - virtual ~SkeletalMotionConstraint(); - -public: - - void init() override; - void reset() override; - - float getAnimationSpeed() const {return animationSpeed.getValue();} - void setAnimationSpeed(float speed) {animationSpeed.setValue(speed);} - - void findKeyTimes(Real ct); - - void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; - void projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) override; - void projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) override; - void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; - - using core::behavior::ProjectiveConstraintSet::applyConstraint; - void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - - void projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) override; - - void draw(const core::visual::VisualParams* vparams) override; - - template - void localToGlobal(typename std::enable_if >::value, VecCoord>::type& x); - - void setSkeletalMotion(const type::vector >& skeletonJoints, const type::vector& skeletonBones); - - void addChannel(unsigned int jointIndex , Coord channel, double time); - -protected: - template - void projectResponseT(DataDeriv& dx, - const std::function& clear); - - template - void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); - -protected: - // every nodes needed in the animation chain - Data > > skeletonJoints; ///< skeleton joints - // mesh skeleton bones which need to be updated according to the animated nodes, we use them to fill the mechanical object - Data > skeletonBones; ///< skeleton bones - - // control how fast the animation is played since animation time is not simulation time - Data animationSpeed; ///< animation speed - - /// is the projective constraint activated? - Data active; - -private: - /// the key times surrounding the current simulation time (for interpolation) - Real prevT, nextT; - - /// the global position of the bones at time t+dt used for the velocities computation - VecCoord nextPositions; - - /// to know if we found the key times - bool finished; - -}; - -template -struct SkeletonJoint -{ - friend class SkeletalMotionConstraint; - - typedef typename DataTypes::Coord Coord; - - SkeletonJoint() - : mParentIndex(-1) - , mChannels() - , mTimes() - , mPreviousMotionTime(0) - , mNextMotionTime(0) - {} - - virtual ~SkeletonJoint(){} - - void addChannel(Coord channel, double time) - { - mChannels.push_back(channel); - mTimes.push_back(time); - } - - inline friend std::ostream& operator << (std::ostream& out, const SkeletonJoint& skeletonJoint) - { - out << "Parent" << " " << skeletonJoint.mParentIndex << " "; - out << "Channels" << " " << skeletonJoint.mChannels.size() << " " << skeletonJoint.mChannels << " "; - out << "Times" << " " << skeletonJoint.mTimes.size() << " " << skeletonJoint.mTimes << " "; - out << "PreviousMotion" << " " << skeletonJoint.mPreviousMotion << " "; - out << "PreviousMotionTime" << " " << skeletonJoint.mPreviousMotionTime << " "; - out << "NextMotion" << " " << skeletonJoint.mNextMotion << " "; - out << "NextMotionTime" << " " << skeletonJoint.mNextMotionTime << " "; - out << "LocalRigid" << " " << skeletonJoint.mLocalRigid; - - return out; - } - - inline friend std::istream& operator >> (std::istream& in, SkeletonJoint& skeletonJoint) - { - std::string tmp; - - in >> tmp >> skeletonJoint.mParentIndex; - - size_t numChannel; - in >> tmp >> numChannel; - skeletonJoint.mChannels.resize(numChannel); - Coord channel; - for(Size i = 0; i < numChannel; ++i) - { - in >> channel; - skeletonJoint.mChannels[i] = channel; - } - - size_t numTime; - in >> tmp >> numTime; - skeletonJoint.mTimes.resize(numTime); - double time; - for(Size i = 0; i < numTime; ++i) - { - in >> time; - skeletonJoint.mTimes[i] = time; - } - - in >> tmp >> skeletonJoint.mPreviousMotion; - in >> tmp >> skeletonJoint.mNextMotion; - in >> tmp >> skeletonJoint.mLocalRigid; - - return in; - } - - // parent joint, set to -1 if root, you must set this value - int mParentIndex; - - // set the joint rest position, you must set this value - void setRestPosition(const Coord& restPosition) - { - mPreviousMotion = restPosition; - mNextMotion = restPosition; - mLocalRigid = restPosition; - } - - // following data are useful for animation only, you must fill those vectors if this joint is animated - - // each channel represents a local transformation at a given time in the animation - type::vector mChannels; - - // times corresponding to each animation channel, the channel mChannels[i] must be played at the time contained in mTimes[i] - type::vector mTimes; - -private: - - // following data are used internally to compute the final joint transformation at a specific time using interpolation - - // previous joint motion - Coord mPreviousMotion; - - // next joint motion - Coord mNextMotion; - - // time position for previous joint motion - double mPreviousMotionTime; - - // time position for next joint motion - double mNextMotionTime; - - // this rigid represent the animated node at a specific time relatively to its parent, it may be an interpolation between two channels - // we need to store the current rigid in order to compute the final world position of its rigid children - Coord mLocalRigid; - - // mCurrentRigid in the world coordinate - Coord mWorldRigid; -}; - -#if defined(WIN32) && !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_SKELETALMOTIONCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionConstraint; - -#endif - - -} // namespace sofa::component::constraint::projective +#include +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl index 47194a6e86f..d8a93524815 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl @@ -21,402 +21,6 @@ ******************************************************************************/ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include +#include -namespace sofa::component::constraint::projective -{ - -template -SkeletalMotionConstraint::SkeletalMotionConstraint() : - sofa::core::behavior::ProjectiveConstraintSet() - , skeletonJoints(initData(&skeletonJoints, "joints", "skeleton joints")) - , skeletonBones(initData(&skeletonBones, "bones", "skeleton bones")) - , animationSpeed(initData(&animationSpeed, 1.0f, "animationSpeed", "animation speed")) - , active(initData(&active, true, "active", "is the constraint active?")) - , finished(false) -{ -} - -template -SkeletalMotionConstraint::~SkeletalMotionConstraint() -{ -} - -template -void SkeletalMotionConstraint::init() -{ - nextPositions.resize(skeletonBones.getValue().size()); - sofa::core::behavior::ProjectiveConstraintSet::init(); -} - -template -void SkeletalMotionConstraint::reset() -{ - sofa::core::behavior::ProjectiveConstraintSet::reset(); -} - -template -void SkeletalMotionConstraint::findKeyTimes(Real ct) -{ - //Note: works only if the times are sorted - - finished = false; - - for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) - { - SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; - - - if(skeletonJoint.mChannels.empty() || skeletonJoint.mChannels.size() != skeletonJoint.mTimes.size()) - continue; - - for(unsigned int j = 0; j < skeletonJoint.mTimes.size(); ++j) - { - Real keyTime = (Real) skeletonJoint.mTimes[j]; - if(keyTime <= ct) - { - { - skeletonJoint.mPreviousMotionTime = keyTime; - const defaulttype::RigidCoord<3, Real>& motion = skeletonJoint.mChannels[j]; - skeletonJoint.mPreviousMotion = motion; - } - if(prevT < keyTime) - prevT = keyTime; - } - else - { - { - skeletonJoint.mNextMotionTime = keyTime; - const defaulttype::RigidCoord<3, Real>& motion = skeletonJoint.mChannels[j]; - skeletonJoint.mNextMotion = motion; - } - if(nextT > keyTime) - nextT = keyTime; - - finished = true; - break; - } - } - skeletonJoints.endEdit(); - } -} - -template template -void SkeletalMotionConstraint::projectResponseT(DataDeriv& res, - const std::function& clear) -{ - if( !active.getValue() ) return; - - for (unsigned int i = 0; i < res.size(); ++i) - clear(res, i); -} - -template -void SkeletalMotionConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) -{ - SOFA_UNUSED(mparams); - if( !active.getValue() ) return; - - helper::WriteAccessor res = resData; - projectResponseT(res.wref(), [](VecDeriv& res, const unsigned int index) { res[index].clear(); }); -} - -template -void SkeletalMotionConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) -{ - if( !active.getValue() ) return; - - helper::WriteAccessor dx = vData; - helper::ReadAccessor x = ((MechanicalState*)this->getContext()->getMechanicalState())->readPositions(); - Real cT = (Real) this->getContext()->getTime() * animationSpeed.getValue(); - Real dt = (Real) this->getContext()->getDt(); - - if(0.0 != cT) - { - findKeyTimes(cT+dt); - if(finished) - { - // compute the position of the bones at cT + dt - this->interpolatePosition(cT+dt, nextPositions); - // compute the velocity using finite difference - for (unsigned i=0; i -void SkeletalMotionConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) -{ - if( !active.getValue() ) return; - - helper::WriteAccessor x = xData; - Real cT = (Real) this->getContext()->getTime() * animationSpeed.getValue(); - - if(0.0 != cT) - { - findKeyTimes(cT); - - // if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) - interpolatePosition(cT, x.wref()); - } -} - -template -template -void SkeletalMotionConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) -{ - // set the motion to the SkeletonJoint corresponding rigid - - if(finished) - for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) - { - - SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; - if( skeletonJoint.mPreviousMotionTime != skeletonJoint.mNextMotionTime) - { - Real dt = (Real)((cT - skeletonJoint.mPreviousMotionTime) / (skeletonJoint.mNextMotionTime - skeletonJoint.mPreviousMotionTime)); - - const type::vector >& channels = skeletonJoint.mChannels; - - if(channels.empty()) - continue; - - skeletonJoint.mLocalRigid.getCenter() = skeletonJoint.mPreviousMotion.getCenter() + (skeletonJoint.mNextMotion.getCenter() - skeletonJoint.mPreviousMotion.getCenter()) * dt; - skeletonJoint.mLocalRigid.getOrientation().slerp(skeletonJoint.mPreviousMotion.getOrientation(), skeletonJoint.mNextMotion.getOrientation(), (float) dt, true); - - skeletonJoints.endEdit(); - } - else - { - const type::vector >& channels = skeletonJoint.mChannels; - - if(channels.empty()) - continue; - - skeletonJoint.mLocalRigid.getCenter() = skeletonJoint.mNextMotion.getCenter(); - skeletonJoint.mLocalRigid.getOrientation() = skeletonJoint.mNextMotion.getOrientation(); - - skeletonJoints.endEdit(); - } - } - else - { - for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) - { - SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; - - const type::vector >& channels = skeletonJoint.mChannels; - - if(channels.empty()) - continue; - - skeletonJoint.mLocalRigid.getCenter() = skeletonJoint.mNextMotion.getCenter(); - skeletonJoint.mLocalRigid.getOrientation() = skeletonJoint.mNextMotion.getOrientation(); - - skeletonJoints.endEdit(); - } - } - - // apply the final transformation from skeletonBones to dofs here - localToGlobal(x); -} - -template -void SkeletalMotionConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) -{ - SOFA_UNUSED(mparams); - if( !active.getValue() ) return; - - helper::WriteAccessor c = cData; - - projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); -} - -template -template -void SkeletalMotionConstraint::localToGlobal(typename std::enable_if >::value, VecCoord>::type& x) -{ - for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) - { - SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; - - defaulttype::RigidCoord< 3, Real> worldRigid = skeletonJoint.mLocalRigid; - - // break if the parent joint is the root - for(int parentIndex = skeletonJoint.mParentIndex; -1 != parentIndex; parentIndex = skeletonJoints.getValue()[parentIndex].mParentIndex) - { - defaulttype::RigidCoord< 3, Real> parentLocalRigid = skeletonJoints.getValue()[parentIndex].mLocalRigid; - worldRigid = parentLocalRigid.mult(worldRigid); - } - - skeletonJoint.mWorldRigid = worldRigid; - - skeletonJoints.endEdit(); - } - - for(unsigned int i = 0; i < skeletonBones.getValue().size(); ++i) - x[i] = skeletonJoints.getValue()[skeletonBones.getValue()[i]].mWorldRigid; -} - -template -void SkeletalMotionConstraint::setSkeletalMotion(const type::vector >& skeletonJoints, const type::vector& skeletonBones) -{ - this->skeletonJoints.setValue(skeletonJoints); - this->skeletonBones.setValue(skeletonBones); - this->init(); -} - -template -void SkeletalMotionConstraint::addChannel(unsigned int jointIndex , Coord channel, double time) -{ - (*skeletonJoints.beginEdit())[jointIndex].addChannel(channel, time); - skeletonJoints.endEdit(); -} - -// Matrix Integration interface -template -void SkeletalMotionConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - if( !active.getValue() ) return; - - /*const unsigned int N = Deriv::size(); - const SetIndexArray & indices = m_indices.getValue(); - - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - // Reset Fixed Row and Col - for (unsigned int c=0;cclearRowCol(offset + N * (*it) + c); - // Set Fixed Vertex - for (unsigned int c=0;cset(offset + N * (*it) + c, offset + N * (*it) + c, 1.0); - }*/ -} - -template -void SkeletalMotionConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ - if( !active.getValue() ) return; - - /*const unsigned int N = Deriv::size(); - - const SetIndexArray & indices = m_indices.getValue(); - for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) - { - for (unsigned int c=0;cclear(offset + N * (*it) + c); - }*/ -} - -template -void SkeletalMotionConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) -{ - const unsigned blockSize = DataTypes::deriv_total_size; - const unsigned size = this->mstate->getSize(); - for( unsigned i=0; iclearRowsCols( offset + i * blockSize, offset + (i+1) * (blockSize) ); - } -} - -// display the paths the constrained dofs will go through -template -void SkeletalMotionConstraint::draw(const core::visual::VisualParams* vparams) -{ - if( !active.getValue() ) return; - - if (!vparams->displayFlags().getShowBehaviorModels()) - return; - - sofa::type::vector points; - sofa::type::vector linesX; - sofa::type::vector linesY; - sofa::type::vector linesZ; - sofa::type::vector colorFalloff; - - type::Vec3 point; - type::Vec3 line; - - // draw joints (not bones we draw them differently later) - { - for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) - { - defaulttype::RigidCoord< 3, Real> jointWorldRigid = skeletonJoints.getValue()[i].mWorldRigid; - - unsigned int j; - for(j = 0; j < skeletonBones.getValue().size(); ++j) - if((int)i == skeletonBones.getValue()[j]) - break; - - if(skeletonBones.getValue().size() != j) - continue; - - point = DataTypes::getCPos(jointWorldRigid); - points.push_back(point); - - linesX.push_back(point); - line = point + DataTypes::getCRot(jointWorldRigid).rotate(type::Vec3f(0.1f, 0.0f, 0.0f)); - linesX.push_back(line); - - linesY.push_back(point); - line = point + DataTypes::getCRot(jointWorldRigid).rotate(type::Vec3f(0.0f, 0.1f, 0.0f)); - linesY.push_back(line); - - linesZ.push_back(point); - line = point + DataTypes::getCRot(jointWorldRigid).rotate(type::Vec3f(0.0f, 0.0f, 0.1f)); - linesZ.push_back(line); - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor (1.0f , 0.5f , 0.5f , 1.0f)); - vparams->drawTool()->drawLines (linesX, 2, sofa::type::RGBAColor (0.75f, 0.0f , 0.0f , 1.0f)); - vparams->drawTool()->drawLines (linesY, 2, sofa::type::RGBAColor (0.0f , 0.75f, 0.0f , 1.0f)); - vparams->drawTool()->drawLines (linesZ, 2, sofa::type::RGBAColor (0.0f , 0.0f , 0.75f, 1.0f)); - } - - points.clear(); - linesX.clear(); - linesY.clear(); - linesZ.clear(); - - // draw bones now - { - for(unsigned int i = 0; i < skeletonBones.getValue().size(); ++i) - { - defaulttype::RigidCoord< 3, Real> boneWorldRigid = skeletonJoints.getValue()[skeletonBones.getValue()[i]].mWorldRigid; - - point = DataTypes::getCPos(boneWorldRigid); - points.push_back(point); - - linesX.push_back(point); - line = point + DataTypes::getCRot(boneWorldRigid).rotate(type::Vec3f(0.1f, 0.0f, 0.0f)); - linesX.push_back(line); - - linesY.push_back(point); - line = point + DataTypes::getCRot(boneWorldRigid).rotate(type::Vec3f(0.0f, 0.1f, 0.0f)); - linesY.push_back(line); - - linesZ.push_back(point); - line = point + DataTypes::getCRot(boneWorldRigid).rotate(type::Vec3f(0.0f, 0.0f, 0.1f)); - linesZ.push_back(line); - } - vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor (1.0f, 0.5f, 0.5f, 1.0f)); - vparams->drawTool()->drawLines (linesX, 2 , sofa::type::RGBAColor (1.0f, 0.0f, 0.0f, 1.0f)); - vparams->drawTool()->drawLines (linesY, 2 , sofa::type::RGBAColor (0.0f, 1.0f, 0.0f, 1.0f)); - vparams->drawTool()->drawLines (linesZ, 2 , sofa::type::RGBAColor (0.0f, 0.0f, 1.0f, 1.0f)); - } -} - -} // namespace sofa::component::constraint::projective +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp similarity index 83% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp index e8010c918f6..03b01bcb1ed 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_SKELETALMOTIONCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_SKELETALMOTIONPROJECTIVECONSTRAINT_CPP +#include #include #include @@ -28,11 +28,11 @@ namespace sofa::component::constraint::projective { //declaration of the class, for the factory -int SkeletalMotionConstraintClass = core::RegisterObject("animate a skeleton") - .add< SkeletalMotionConstraint >() +int SkeletalMotionProjectiveConstraintClass = core::RegisterObject("animate a skeleton") + .add< SkeletalMotionProjectiveConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h new file mode 100644 index 00000000000..220c7dfaaad --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h @@ -0,0 +1,250 @@ +/****************************************************************************** +* 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::constraint::projective +{ + +// a joint of the skeletal hierarchy, it participates in the skeletal animation chain and may be animated +template +struct SkeletonJoint; + +// joints index to export in the MechanicalObject (in order to use them for skinning for instance) +typedef int SkeletonBone; + +// impose a specific motion (translation and rotation) for each DOFs of a MechanicalObject +template +class SkeletalMotionProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +{ +public: + SOFA_CLASS(SOFA_TEMPLATE(SkeletalMotionProjectiveConstraint,TDataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, TDataTypes)); + typedef TDataTypes DataTypes; + typedef sofa::core::behavior::ProjectiveConstraintSet TProjectiveConstraintSet; + typedef sofa::core::behavior::MechanicalState MechanicalState; + typedef typename DataTypes::VecCoord VecCoord; + typedef typename DataTypes::VecDeriv VecDeriv; + typedef typename DataTypes::MatrixDeriv MatrixDeriv; + typedef typename DataTypes::Coord Coord; + typedef typename DataTypes::Deriv Deriv; + typedef typename DataTypes::Real Real; + typedef typename MatrixDeriv::RowIterator MatrixDerivRowIterator; + typedef typename MatrixDeriv::RowType MatrixDerivRowType; + typedef Data DataVecCoord; + typedef Data DataVecDeriv; + typedef Data DataMatrixDeriv; + +protected: + SkeletalMotionProjectiveConstraint(); + + virtual ~SkeletalMotionProjectiveConstraint(); + +public: + + void init() override; + void reset() override; + + float getAnimationSpeed() const {return animationSpeed.getValue();} + void setAnimationSpeed(float speed) {animationSpeed.setValue(speed);} + + void findKeyTimes(Real ct); + + void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) override; + void projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) override; + void projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) override; + void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) override; + + using core::behavior::ProjectiveConstraintSet::applyConstraint; + void applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + void projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) override; + + void draw(const core::visual::VisualParams* vparams) override; + + template + void localToGlobal(typename std::enable_if >::value, VecCoord>::type& x); + + void setSkeletalMotion(const type::vector >& skeletonJoints, const type::vector& skeletonBones); + + void addChannel(unsigned int jointIndex , Coord channel, double time); + +protected: + template + void projectResponseT(DataDeriv& dx, + const std::function& clear); + + template + void interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x); + +protected: + // every nodes needed in the animation chain + Data > > skeletonJoints; ///< skeleton joints + // mesh skeleton bones which need to be updated according to the animated nodes, we use them to fill the mechanical object + Data > skeletonBones; ///< skeleton bones + + // control how fast the animation is played since animation time is not simulation time + Data animationSpeed; ///< animation speed + + /// is the projective constraint activated? + Data active; + +private: + /// the key times surrounding the current simulation time (for interpolation) + Real prevT, nextT; + + /// the global position of the bones at time t+dt used for the velocities computation + VecCoord nextPositions; + + /// to know if we found the key times + bool finished; + +}; + +template +struct SkeletonJoint +{ + friend class SkeletalMotionProjectiveConstraint; + + typedef typename DataTypes::Coord Coord; + + SkeletonJoint() + : mParentIndex(-1) + , mChannels() + , mTimes() + , mPreviousMotionTime(0) + , mNextMotionTime(0) + {} + + virtual ~SkeletonJoint(){} + + void addChannel(Coord channel, double time) + { + mChannels.push_back(channel); + mTimes.push_back(time); + } + + inline friend std::ostream& operator << (std::ostream& out, const SkeletonJoint& skeletonJoint) + { + out << "Parent" << " " << skeletonJoint.mParentIndex << " "; + out << "Channels" << " " << skeletonJoint.mChannels.size() << " " << skeletonJoint.mChannels << " "; + out << "Times" << " " << skeletonJoint.mTimes.size() << " " << skeletonJoint.mTimes << " "; + out << "PreviousMotion" << " " << skeletonJoint.mPreviousMotion << " "; + out << "PreviousMotionTime" << " " << skeletonJoint.mPreviousMotionTime << " "; + out << "NextMotion" << " " << skeletonJoint.mNextMotion << " "; + out << "NextMotionTime" << " " << skeletonJoint.mNextMotionTime << " "; + out << "LocalRigid" << " " << skeletonJoint.mLocalRigid; + + return out; + } + + inline friend std::istream& operator >> (std::istream& in, SkeletonJoint& skeletonJoint) + { + std::string tmp; + + in >> tmp >> skeletonJoint.mParentIndex; + + size_t numChannel; + in >> tmp >> numChannel; + skeletonJoint.mChannels.resize(numChannel); + Coord channel; + for(Size i = 0; i < numChannel; ++i) + { + in >> channel; + skeletonJoint.mChannels[i] = channel; + } + + size_t numTime; + in >> tmp >> numTime; + skeletonJoint.mTimes.resize(numTime); + double time; + for(Size i = 0; i < numTime; ++i) + { + in >> time; + skeletonJoint.mTimes[i] = time; + } + + in >> tmp >> skeletonJoint.mPreviousMotion; + in >> tmp >> skeletonJoint.mNextMotion; + in >> tmp >> skeletonJoint.mLocalRigid; + + return in; + } + + // parent joint, set to -1 if root, you must set this value + int mParentIndex; + + // set the joint rest position, you must set this value + void setRestPosition(const Coord& restPosition) + { + mPreviousMotion = restPosition; + mNextMotion = restPosition; + mLocalRigid = restPosition; + } + + // following data are useful for animation only, you must fill those vectors if this joint is animated + + // each channel represents a local transformation at a given time in the animation + type::vector mChannels; + + // times corresponding to each animation channel, the channel mChannels[i] must be played at the time contained in mTimes[i] + type::vector mTimes; + +private: + + // following data are used internally to compute the final joint transformation at a specific time using interpolation + + // previous joint motion + Coord mPreviousMotion; + + // next joint motion + Coord mNextMotion; + + // time position for previous joint motion + double mPreviousMotionTime; + + // time position for next joint motion + double mNextMotionTime; + + // this rigid represent the animated node at a specific time relatively to its parent, it may be an interpolation between two channels + // we need to store the current rigid in order to compute the final world position of its rigid children + Coord mLocalRigid; + + // mCurrentRigid in the world coordinate + Coord mWorldRigid; +}; + +#if defined(WIN32) && !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_SKELETALMOTIONPROJECTIVECONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionProjectiveConstraint; + +#endif + +template +using SkeletalMotionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SkeletalMotionConstraint has been renamed to SkeletalMotionProjectiveConstraint") = SkeletalMotionProjectiveConstraint; + +} // namespace sofa::component::constraint::projective + diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl new file mode 100644 index 00000000000..7c06a73fd18 --- /dev/null +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl @@ -0,0 +1,422 @@ +/****************************************************************************** +* 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 + +namespace sofa::component::constraint::projective +{ + +template +SkeletalMotionProjectiveConstraint::SkeletalMotionProjectiveConstraint() : + sofa::core::behavior::ProjectiveConstraintSet() + , skeletonJoints(initData(&skeletonJoints, "joints", "skeleton joints")) + , skeletonBones(initData(&skeletonBones, "bones", "skeleton bones")) + , animationSpeed(initData(&animationSpeed, 1.0f, "animationSpeed", "animation speed")) + , active(initData(&active, true, "active", "is the constraint active?")) + , finished(false) +{ +} + +template +SkeletalMotionProjectiveConstraint::~SkeletalMotionProjectiveConstraint() +{ +} + +template +void SkeletalMotionProjectiveConstraint::init() +{ + nextPositions.resize(skeletonBones.getValue().size()); + sofa::core::behavior::ProjectiveConstraintSet::init(); +} + +template +void SkeletalMotionProjectiveConstraint::reset() +{ + sofa::core::behavior::ProjectiveConstraintSet::reset(); +} + +template +void SkeletalMotionProjectiveConstraint::findKeyTimes(Real ct) +{ + //Note: works only if the times are sorted + + finished = false; + + for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) + { + SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; + + + if(skeletonJoint.mChannels.empty() || skeletonJoint.mChannels.size() != skeletonJoint.mTimes.size()) + continue; + + for(unsigned int j = 0; j < skeletonJoint.mTimes.size(); ++j) + { + Real keyTime = (Real) skeletonJoint.mTimes[j]; + if(keyTime <= ct) + { + { + skeletonJoint.mPreviousMotionTime = keyTime; + const defaulttype::RigidCoord<3, Real>& motion = skeletonJoint.mChannels[j]; + skeletonJoint.mPreviousMotion = motion; + } + if(prevT < keyTime) + prevT = keyTime; + } + else + { + { + skeletonJoint.mNextMotionTime = keyTime; + const defaulttype::RigidCoord<3, Real>& motion = skeletonJoint.mChannels[j]; + skeletonJoint.mNextMotion = motion; + } + if(nextT > keyTime) + nextT = keyTime; + + finished = true; + break; + } + } + skeletonJoints.endEdit(); + } +} + +template template +void SkeletalMotionProjectiveConstraint::projectResponseT(DataDeriv& res, + const std::function& clear) +{ + if( !active.getValue() ) return; + + for (unsigned int i = 0; i < res.size(); ++i) + clear(res, i); +} + +template +void SkeletalMotionProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +{ + SOFA_UNUSED(mparams); + if( !active.getValue() ) return; + + helper::WriteAccessor res = resData; + projectResponseT(res.wref(), [](VecDeriv& res, const unsigned int index) { res[index].clear(); }); +} + +template +void SkeletalMotionProjectiveConstraint::projectVelocity(const core::MechanicalParams* /*mparams*/, DataVecDeriv& vData) +{ + if( !active.getValue() ) return; + + helper::WriteAccessor dx = vData; + helper::ReadAccessor x = ((MechanicalState*)this->getContext()->getMechanicalState())->readPositions(); + Real cT = (Real) this->getContext()->getTime() * animationSpeed.getValue(); + Real dt = (Real) this->getContext()->getDt(); + + if(0.0 != cT) + { + findKeyTimes(cT+dt); + if(finished) + { + // compute the position of the bones at cT + dt + this->interpolatePosition(cT+dt, nextPositions); + // compute the velocity using finite difference + for (unsigned i=0; i +void SkeletalMotionProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/, DataVecCoord& xData) +{ + if( !active.getValue() ) return; + + helper::WriteAccessor x = xData; + Real cT = (Real) this->getContext()->getTime() * animationSpeed.getValue(); + + if(0.0 != cT) + { + findKeyTimes(cT); + + // if we found 2 keyTimes, we have to interpolate a velocity (linear interpolation) + interpolatePosition(cT, x.wref()); + } +} + +template +template +void SkeletalMotionProjectiveConstraint::interpolatePosition(Real cT, typename std::enable_if >::value, VecCoord>::type& x) +{ + // set the motion to the SkeletonJoint corresponding rigid + + if(finished) + for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) + { + + SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; + if( skeletonJoint.mPreviousMotionTime != skeletonJoint.mNextMotionTime) + { + Real dt = (Real)((cT - skeletonJoint.mPreviousMotionTime) / (skeletonJoint.mNextMotionTime - skeletonJoint.mPreviousMotionTime)); + + const type::vector >& channels = skeletonJoint.mChannels; + + if(channels.empty()) + continue; + + skeletonJoint.mLocalRigid.getCenter() = skeletonJoint.mPreviousMotion.getCenter() + (skeletonJoint.mNextMotion.getCenter() - skeletonJoint.mPreviousMotion.getCenter()) * dt; + skeletonJoint.mLocalRigid.getOrientation().slerp(skeletonJoint.mPreviousMotion.getOrientation(), skeletonJoint.mNextMotion.getOrientation(), (float) dt, true); + + skeletonJoints.endEdit(); + } + else + { + const type::vector >& channels = skeletonJoint.mChannels; + + if(channels.empty()) + continue; + + skeletonJoint.mLocalRigid.getCenter() = skeletonJoint.mNextMotion.getCenter(); + skeletonJoint.mLocalRigid.getOrientation() = skeletonJoint.mNextMotion.getOrientation(); + + skeletonJoints.endEdit(); + } + } + else + { + for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) + { + SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; + + const type::vector >& channels = skeletonJoint.mChannels; + + if(channels.empty()) + continue; + + skeletonJoint.mLocalRigid.getCenter() = skeletonJoint.mNextMotion.getCenter(); + skeletonJoint.mLocalRigid.getOrientation() = skeletonJoint.mNextMotion.getOrientation(); + + skeletonJoints.endEdit(); + } + } + + // apply the final transformation from skeletonBones to dofs here + localToGlobal(x); +} + +template +void SkeletalMotionProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +{ + SOFA_UNUSED(mparams); + if( !active.getValue() ) return; + + helper::WriteAccessor c = cData; + + projectResponseT(c.wref(), [](MatrixDeriv& res, const unsigned int index) { res.clearColBlock(index); }); +} + +template +template +void SkeletalMotionProjectiveConstraint::localToGlobal(typename std::enable_if >::value, VecCoord>::type& x) +{ + for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) + { + SkeletonJoint& skeletonJoint = (*skeletonJoints.beginEdit())[i]; + + defaulttype::RigidCoord< 3, Real> worldRigid = skeletonJoint.mLocalRigid; + + // break if the parent joint is the root + for(int parentIndex = skeletonJoint.mParentIndex; -1 != parentIndex; parentIndex = skeletonJoints.getValue()[parentIndex].mParentIndex) + { + defaulttype::RigidCoord< 3, Real> parentLocalRigid = skeletonJoints.getValue()[parentIndex].mLocalRigid; + worldRigid = parentLocalRigid.mult(worldRigid); + } + + skeletonJoint.mWorldRigid = worldRigid; + + skeletonJoints.endEdit(); + } + + for(unsigned int i = 0; i < skeletonBones.getValue().size(); ++i) + x[i] = skeletonJoints.getValue()[skeletonBones.getValue()[i]].mWorldRigid; +} + +template +void SkeletalMotionProjectiveConstraint::setSkeletalMotion(const type::vector >& skeletonJoints, const type::vector& skeletonBones) +{ + this->skeletonJoints.setValue(skeletonJoints); + this->skeletonBones.setValue(skeletonBones); + this->init(); +} + +template +void SkeletalMotionProjectiveConstraint::addChannel(unsigned int jointIndex , Coord channel, double time) +{ + (*skeletonJoints.beginEdit())[jointIndex].addChannel(channel, time); + skeletonJoints.endEdit(); +} + +// Matrix Integration interface +template +void SkeletalMotionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + if( !active.getValue() ) return; + + /*const unsigned int N = Deriv::size(); + const SetIndexArray & indices = m_indices.getValue(); + + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + // Reset Fixed Row and Col + for (unsigned int c=0;cclearRowCol(offset + N * (*it) + c); + // Set Fixed Vertex + for (unsigned int c=0;cset(offset + N * (*it) + c, offset + N * (*it) + c, 1.0); + }*/ +} + +template +void SkeletalMotionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +{ + if( !active.getValue() ) return; + + /*const unsigned int N = Deriv::size(); + + const SetIndexArray & indices = m_indices.getValue(); + for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it) + { + for (unsigned int c=0;cclear(offset + N * (*it) + c); + }*/ +} + +template +void SkeletalMotionProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +{ + const unsigned blockSize = DataTypes::deriv_total_size; + const unsigned size = this->mstate->getSize(); + for( unsigned i=0; iclearRowsCols( offset + i * blockSize, offset + (i+1) * (blockSize) ); + } +} + +// display the paths the constrained dofs will go through +template +void SkeletalMotionProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +{ + if( !active.getValue() ) return; + + if (!vparams->displayFlags().getShowBehaviorModels()) + return; + + sofa::type::vector points; + sofa::type::vector linesX; + sofa::type::vector linesY; + sofa::type::vector linesZ; + sofa::type::vector colorFalloff; + + type::Vec3 point; + type::Vec3 line; + + // draw joints (not bones we draw them differently later) + { + for(unsigned int i = 0; i < skeletonJoints.getValue().size(); ++i) + { + defaulttype::RigidCoord< 3, Real> jointWorldRigid = skeletonJoints.getValue()[i].mWorldRigid; + + unsigned int j; + for(j = 0; j < skeletonBones.getValue().size(); ++j) + if((int)i == skeletonBones.getValue()[j]) + break; + + if(skeletonBones.getValue().size() != j) + continue; + + point = DataTypes::getCPos(jointWorldRigid); + points.push_back(point); + + linesX.push_back(point); + line = point + DataTypes::getCRot(jointWorldRigid).rotate(type::Vec3f(0.1f, 0.0f, 0.0f)); + linesX.push_back(line); + + linesY.push_back(point); + line = point + DataTypes::getCRot(jointWorldRigid).rotate(type::Vec3f(0.0f, 0.1f, 0.0f)); + linesY.push_back(line); + + linesZ.push_back(point); + line = point + DataTypes::getCRot(jointWorldRigid).rotate(type::Vec3f(0.0f, 0.0f, 0.1f)); + linesZ.push_back(line); + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor (1.0f , 0.5f , 0.5f , 1.0f)); + vparams->drawTool()->drawLines (linesX, 2, sofa::type::RGBAColor (0.75f, 0.0f , 0.0f , 1.0f)); + vparams->drawTool()->drawLines (linesY, 2, sofa::type::RGBAColor (0.0f , 0.75f, 0.0f , 1.0f)); + vparams->drawTool()->drawLines (linesZ, 2, sofa::type::RGBAColor (0.0f , 0.0f , 0.75f, 1.0f)); + } + + points.clear(); + linesX.clear(); + linesY.clear(); + linesZ.clear(); + + // draw bones now + { + for(unsigned int i = 0; i < skeletonBones.getValue().size(); ++i) + { + defaulttype::RigidCoord< 3, Real> boneWorldRigid = skeletonJoints.getValue()[skeletonBones.getValue()[i]].mWorldRigid; + + point = DataTypes::getCPos(boneWorldRigid); + points.push_back(point); + + linesX.push_back(point); + line = point + DataTypes::getCRot(boneWorldRigid).rotate(type::Vec3f(0.1f, 0.0f, 0.0f)); + linesX.push_back(line); + + linesY.push_back(point); + line = point + DataTypes::getCRot(boneWorldRigid).rotate(type::Vec3f(0.0f, 0.1f, 0.0f)); + linesY.push_back(line); + + linesZ.push_back(point); + line = point + DataTypes::getCRot(boneWorldRigid).rotate(type::Vec3f(0.0f, 0.0f, 0.1f)); + linesZ.push_back(line); + } + vparams->drawTool()->drawPoints(points, 10, sofa::type::RGBAColor (1.0f, 0.5f, 0.5f, 1.0f)); + vparams->drawTool()->drawLines (linesX, 2 , sofa::type::RGBAColor (1.0f, 0.0f, 0.0f, 1.0f)); + vparams->drawTool()->drawLines (linesY, 2 , sofa::type::RGBAColor (0.0f, 1.0f, 0.0f, 1.0f)); + vparams->drawTool()->drawLines (linesZ, 2 , sofa::type::RGBAColor (0.0f, 0.0f, 1.0f, 1.0f)); + } +} + +} // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/tests/AffineMovementConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/AffineMovementProjectiveConstraint_test.cpp similarity index 95% rename from Sofa/Component/Constraint/Projective/tests/AffineMovementConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/AffineMovementProjectiveConstraint_test.cpp index 82379cb5145..a1d845afc32 100644 --- a/Sofa/Component/Constraint/Projective/tests/AffineMovementConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/AffineMovementProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ namespace sofa { namespace { template -struct AffineMovementConstraint_test : public BaseSimulationTest, NumericTest +struct AffineMovementProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::Coord Coord; @@ -197,9 +197,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(AffineMovementConstraint_test, DataTypes); +TYPED_TEST_SUITE(AffineMovementProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( AffineMovementConstraint_test , testValue ) +TYPED_TEST( AffineMovementProjectiveConstraint_test , testValue ) { EXPECT_MSG_NOEMIT(Error) ; ASSERT_TRUE( this->projectPosition(5e-6,5e-5)); diff --git a/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt b/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt index 042f7537a21..0456bcd1434 100644 --- a/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt +++ b/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt @@ -3,14 +3,14 @@ cmake_minimum_required(VERSION 3.12) project(Sofa.Component.Constraint.Projective_test) set(SOURCE_FILES - AffineMovementConstraint_test.cpp - FixedConstraint_test.cpp - FixedPlaneConstraint_test.cpp - PartialFixedConstraint_test.cpp - ProjectDirectionConstraint_test.cpp - ProjectToLineConstraint_test.cpp - ProjectToPlaneConstraint_test.cpp - ProjectToPointConstraint_test.cpp + AffineMovementProjectiveConstraint_test.cpp + FixedProjectiveConstraint_test.cpp + FixedPlaneProjectiveConstraint_test.cpp + PartialFixedProjectiveConstraint_test.cpp + ProjectDirectionProjectiveConstraint_test.cpp + ProjectToLineProjectiveConstraint_test.cpp + ProjectToPlaneProjectiveConstraint_test.cpp + ProjectToPointProjectiveConstraint_test.cpp ) add_executable(${PROJECT_NAME} ${SOURCE_FILES}) diff --git a/Sofa/Component/Constraint/Projective/tests/FixedPlaneConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/FixedPlaneProjectiveConstraint_test.cpp similarity index 89% rename from Sofa/Component/Constraint/Projective/tests/FixedPlaneConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/FixedPlaneProjectiveConstraint_test.cpp index 5ed1c9ca855..6537e800394 100644 --- a/Sofa/Component/Constraint/Projective/tests/FixedPlaneConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/FixedPlaneProjectiveConstraint_test.cpp @@ -23,7 +23,7 @@ #include using sofa::testing::BaseSimulationTest; -#include +#include #include #include #include @@ -46,12 +46,12 @@ void createUniformMass(simulation::Node::SPtr node, component::statecontainer::M } template -struct FixedPlaneConstraint_test : public BaseSimulationTest +struct FixedPlaneProjectiveConstraint_test : public BaseSimulationTest { typedef _DataTypes DataTypes; typedef typename DataTypes::Real Real; - typedef component::constraint::projective::FixedPlaneConstraint FixedPlaneConstraint; + typedef component::constraint::projective::FixedPlaneProjectiveConstraint FixedPlaneProjectiveConstraint; typedef component::mechanicalload::ConstantForceField ForceField; typedef component::statecontainer::MechanicalObject MechanicalObject; @@ -89,7 +89,7 @@ struct FixedPlaneConstraint_test : public BaseSimulationTest typename ForceField::SPtr forceField = addNew(node); forceField->setForce( 0, force ); - typename FixedPlaneConstraint::SPtr constraint = addNew(node); + typename FixedPlaneProjectiveConstraint::SPtr constraint = addNew(node); constraint->d_indices.setValue({0}); if(constraint->d_indices.getValue().empty()) { @@ -134,22 +134,22 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(FixedPlaneConstraint_test, DataTypes); +TYPED_TEST_SUITE(FixedPlaneProjectiveConstraint_test, DataTypes); // test cases -TYPED_TEST( FixedPlaneConstraint_test , testContraintExplicit ) +TYPED_TEST( FixedPlaneProjectiveConstraint_test , testContraintExplicit ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Explicit")) ); } -TYPED_TEST( FixedPlaneConstraint_test , testConstraintImplicitWithCG ) +TYPED_TEST( FixedPlaneProjectiveConstraint_test , testConstraintImplicitWithCG ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Implicit")) ); } -TYPED_TEST( FixedPlaneConstraint_test , testConstraintImplicitWithSparseLDL ) +TYPED_TEST( FixedPlaneProjectiveConstraint_test , testConstraintImplicitWithSparseLDL ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Implicit_SparseLDL")) ); diff --git a/Sofa/Component/Constraint/Projective/tests/FixedConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/FixedProjectiveConstraint_test.cpp similarity index 92% rename from Sofa/Component/Constraint/Projective/tests/FixedConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/FixedProjectiveConstraint_test.cpp index e755e35fdd6..e717e5d6b82 100644 --- a/Sofa/Component/Constraint/Projective/tests/FixedConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/FixedProjectiveConstraint_test.cpp @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#include +#include #include #include #include @@ -49,10 +49,10 @@ void createUniformMass(simulation::Node::SPtr node, component::statecontainer::M } template -struct FixedConstraint_test : public BaseTest +struct FixedProjectiveConstraint_test : public BaseTest { typedef _DataTypes DataTypes; - typedef component::constraint::projective::FixedConstraint FixedConstraint; + typedef component::constraint::projective::FixedProjectiveConstraint FixedProjectiveConstraint; typedef component::mechanicalload::ConstantForceField ForceField; typedef component::statecontainer::MechanicalObject MechanicalObject; @@ -106,7 +106,7 @@ struct FixedConstraint_test : public BaseTest forceField->setForce( 1, force ); /// Let's fix the particle's movement for particle number 1 (the second one). - typename FixedConstraint::SPtr cst = sofa::core::objectmodel::New(); + typename FixedProjectiveConstraint::SPtr cst = sofa::core::objectmodel::New(); cst->findData("indices")->read("1"); node->addObject(cst); @@ -197,7 +197,7 @@ struct FixedConstraint_test : public BaseTest } /// Add fixconstraint - typename FixedConstraint::SPtr cst = sofa::core::objectmodel::New(); + typename FixedProjectiveConstraint::SPtr cst = sofa::core::objectmodel::New(); type::vector indices = { 0, 1, 2 }; cst->d_indices.setValue(indices); node->addObject(cst); @@ -247,27 +247,27 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(FixedConstraint_test, DataTypes); +TYPED_TEST_SUITE(FixedProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( FixedConstraint_test , testValueImplicitWithCG ) +TYPED_TEST( FixedProjectiveConstraint_test , testValueImplicitWithCG ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8,std::string("Implicit")) ); } -TYPED_TEST( FixedConstraint_test , testValueExplicit ) +TYPED_TEST( FixedProjectiveConstraint_test , testValueExplicit ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Explicit")) ); } -TYPED_TEST( FixedConstraint_test , testValueImplicitWithSparseLDL ) +TYPED_TEST( FixedProjectiveConstraint_test , testValueImplicitWithSparseLDL ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Implicit_SparseLDL")) ); } -TYPED_TEST(FixedConstraint_test, testTopologicalChanges) +TYPED_TEST(FixedProjectiveConstraint_test, testTopologicalChanges) { EXPECT_MSG_NOEMIT(Error); EXPECT_TRUE(this->testTopologicalChanges()); diff --git a/Sofa/Component/Constraint/Projective/tests/PartialFixedConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/PartialFixedProjectiveConstraint_test.cpp similarity index 88% rename from Sofa/Component/Constraint/Projective/tests/PartialFixedConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/PartialFixedProjectiveConstraint_test.cpp index a7b462c0f5e..3ca05c51679 100644 --- a/Sofa/Component/Constraint/Projective/tests/PartialFixedConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/PartialFixedProjectiveConstraint_test.cpp @@ -22,7 +22,7 @@ #include using sofa::testing::BaseSimulationTest; -#include +#include #include #include #include @@ -45,12 +45,12 @@ void createUniformMass(simulation::Node::SPtr node, component::statecontainer::M } template -struct PartialFixedConstraint_test : public BaseSimulationTest +struct PartialFixedProjectiveConstraint_test : public BaseSimulationTest { typedef _DataTypes DataTypes; typedef typename DataTypes::Real Real; - typedef component::constraint::projective::PartialFixedConstraint PartialFixedConstraint; + typedef component::constraint::projective::PartialFixedProjectiveConstraint PartialFixedProjectiveConstraint; typedef component::mechanicalload::ConstantForceField ForceField; typedef component::statecontainer::MechanicalObject MechanicalObject; @@ -92,7 +92,7 @@ struct PartialFixedConstraint_test : public BaseSimulationTest typename ForceField::SPtr forceField = addNew(node); forceField->setForce( 0, force ); - typename PartialFixedConstraint::SPtr constraint = addNew(node); + typename PartialFixedProjectiveConstraint::SPtr constraint = addNew(node); // Init simulation sofa::simulation::node::initRoot(root.get()); @@ -134,22 +134,22 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(PartialFixedConstraint_test, DataTypes); +TYPED_TEST_SUITE(PartialFixedProjectiveConstraint_test, DataTypes); // test cases -TYPED_TEST( PartialFixedConstraint_test , testContraintExplicit ) +TYPED_TEST( PartialFixedProjectiveConstraint_test , testContraintExplicit ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Explicit")) ); } -TYPED_TEST( PartialFixedConstraint_test , testContraintImplicitWithCG ) +TYPED_TEST( PartialFixedProjectiveConstraint_test , testContraintImplicitWithCG ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Implicit")) ); } -TYPED_TEST( PartialFixedConstraint_test , testContraintImplicitWithSparseLDL ) +TYPED_TEST( PartialFixedProjectiveConstraint_test , testContraintImplicitWithSparseLDL ) { EXPECT_MSG_NOEMIT(Error) ; EXPECT_TRUE( this->test(1e-8, std::string("Implicit_SparseLDL")) ); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectDirectionConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/ProjectDirectionProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectDirectionConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/ProjectDirectionProjectiveConstraint_test.cpp index 3a60bde1807..ec858101dca 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectDirectionConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/ProjectDirectionProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -41,11 +41,11 @@ using namespace component; using namespace defaulttype; using namespace core::objectmodel; -/** Test suite for ProjectDirectionConstraint. +/** Test suite for ProjectDirectionProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectDirectionConstraint_test : public BaseSimulationTest, NumericTest +struct ProjectDirectionProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -54,8 +54,8 @@ struct ProjectDirectionConstraint_test : public BaseSimulationTest, NumericTest< typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::CPos CPos; typedef typename Coord::value_type Real; - typedef constraint::projective::ProjectDirectionConstraint ProjectDirectionConstraint; - typedef typename ProjectDirectionConstraint::Indices Indices; + typedef constraint::projective::ProjectDirectionProjectiveConstraint ProjectDirectionProjectiveConstraint; + typedef typename ProjectDirectionProjectiveConstraint::Indices Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -65,7 +65,7 @@ struct ProjectDirectionConstraint_test : public BaseSimulationTest, NumericTest< unsigned numNodes; ///< number of particles used for the test Indices indices; ///< indices of the nodes to project CPos direction; ///< direction to project to - typename ProjectDirectionConstraint::SPtr projection; + typename ProjectDirectionProjectiveConstraint::SPtr projection; typename MechanicalObject::SPtr dofs; /// Create the context for the tests. @@ -85,7 +85,7 @@ struct ProjectDirectionConstraint_test : public BaseSimulationTest, NumericTest< root->addObject(dofs); // Project direction constraint - projection = New(); + projection = New(); root->addObject(projection); /// Set the values @@ -236,10 +236,10 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectDirectionConstraint_test, DataTypes); +TYPED_TEST_SUITE(ProjectDirectionProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectDirectionConstraint_test , oneConstrainedParticle ) +TYPED_TEST( ProjectDirectionProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -247,7 +247,7 @@ TYPED_TEST( ProjectDirectionConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // second test case -TYPED_TEST( ProjectDirectionConstraint_test , allParticlesConstrained ) +TYPED_TEST( ProjectDirectionProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectToLineConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/ProjectToLineProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectToLineConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/ProjectToLineProjectiveConstraint_test.cpp index 8308103367a..ad77e7be8a9 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectToLineConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/ProjectToLineProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -39,11 +39,11 @@ using namespace defaulttype; -/** Test suite for ProjectToLineConstraint. +/** Test suite for ProjectToLineProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectToLineConstraint_test : public BaseSimulationTest, NumericTest +struct ProjectToLineProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -52,8 +52,8 @@ struct ProjectToLineConstraint_test : public BaseSimulationTest, NumericTest ProjectToLineConstraint; - typedef typename ProjectToLineConstraint::Indices Indices; + typedef constraint::projective::ProjectToLineProjectiveConstraint ProjectToLineProjectiveConstraint; + typedef typename ProjectToLineProjectiveConstraint::Indices Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -64,7 +64,7 @@ struct ProjectToLineConstraint_test : public BaseSimulationTest, NumericTest(); root->addObject(dofs); - projection = core::objectmodel::New(); + projection = core::objectmodel::New(); root->addObject(projection); /// Set the values @@ -221,9 +221,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectToLineConstraint_test, DataTypes); +TYPED_TEST_SUITE(ProjectToLineProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectToLineConstraint_test , oneConstrainedParticle ) +TYPED_TEST( ProjectToLineProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -231,7 +231,7 @@ TYPED_TEST( ProjectToLineConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // next test case -TYPED_TEST( ProjectToLineConstraint_test , allParticlesConstrained ) +TYPED_TEST( ProjectToLineProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectToPlaneConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/ProjectToPlaneProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectToPlaneConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/ProjectToPlaneProjectiveConstraint_test.cpp index 76c5e46ae25..ed622ef6ddb 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectToPlaneConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/ProjectToPlaneProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -40,11 +40,11 @@ using namespace defaulttype; -/** Test suite for ProjectToPlaneConstraint. +/** Test suite for ProjectToPlaneProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectToPlaneConstraint_test : public BaseSimulationTest, NumericTest +struct ProjectToPlaneProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -53,8 +53,8 @@ struct ProjectToPlaneConstraint_test : public BaseSimulationTest, NumericTest ProjectToPlaneConstraint; - typedef typename ProjectToPlaneConstraint::Indices Indices; + typedef constraint::projective::ProjectToPlaneProjectiveConstraint ProjectToPlaneProjectiveConstraint; + typedef typename ProjectToPlaneProjectiveConstraint::Indices Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -65,7 +65,7 @@ struct ProjectToPlaneConstraint_test : public BaseSimulationTest, NumericTest(); root->addObject(dofs); - projection = core::objectmodel::New(); + projection = core::objectmodel::New(); root->addObject(projection); /// Set the values @@ -220,9 +220,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectToPlaneConstraint_test, DataTypes); +TYPED_TEST_SUITE(ProjectToPlaneProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectToPlaneConstraint_test , oneConstrainedParticle ) +TYPED_TEST( ProjectToPlaneProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -230,7 +230,7 @@ TYPED_TEST( ProjectToPlaneConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // next test case -TYPED_TEST( ProjectToPlaneConstraint_test , allParticlesConstrained ) +TYPED_TEST( ProjectToPlaneProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectToPointConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/ProjectToPointProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectToPointConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/ProjectToPointProjectiveConstraint_test.cpp index 1b33c49fe5f..e6455a9b5f6 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectToPointConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/ProjectToPointProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -41,11 +41,11 @@ using namespace defaulttype; using sofa::core::objectmodel::New; -/** Test suite for ProjectToPointConstraint. +/** Test suite for ProjectToPointProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectToPointConstraint_test : public BaseSimulationTest, NumericTest +struct ProjectToPointProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -54,8 +54,8 @@ struct ProjectToPointConstraint_test : public BaseSimulationTest, NumericTest ProjectToPointConstraint; - typedef typename ProjectToPointConstraint::SetIndexArray Indices; + typedef constraint::projective::ProjectToPointProjectiveConstraint ProjectToPointProjectiveConstraint; + typedef typename ProjectToPointProjectiveConstraint::SetIndexArray Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -65,7 +65,7 @@ struct ProjectToPointConstraint_test : public BaseSimulationTest, NumericTestaddObject(dofs); // Project to point constraint - projection = New(); + projection = New(); root->addObject(projection); /// Set the values @@ -224,9 +224,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectToPointConstraint_test, DataTypes); +TYPED_TEST_SUITE(ProjectToPointProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectToPointConstraint_test , oneConstrainedParticle ) +TYPED_TEST( ProjectToPointProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -234,7 +234,7 @@ TYPED_TEST( ProjectToPointConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // next test case -TYPED_TEST( ProjectToPointConstraint_test , allParticlesConstrained ) +TYPED_TEST( ProjectToPointProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/MechanicalLoad/tests/SkeletalMotionConstraint_test.cpp b/Sofa/Component/MechanicalLoad/tests/SkeletalMotionConstraint_test.cpp index eb5c9790beb..f6a846d532b 100644 --- a/Sofa/Component/MechanicalLoad/tests/SkeletalMotionConstraint_test.cpp +++ b/Sofa/Component/MechanicalLoad/tests/SkeletalMotionConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ using namespace defaulttype; The test cases are defined in the #Test_Cases member group. */ template -struct SkeletalMotionConstraint_test : public BaseSimulationTest, NumericTest +struct SkeletalMotionProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -55,7 +55,7 @@ struct SkeletalMotionConstraint_test : public BaseSimulationTest, NumericTest SkeletalMotionConstraint; + typedef constraint::projective::SkeletalMotionProjectiveConstraint SkeletalMotionProjectiveConstraint; typedef constraint::projective::SkeletonJoint SkeletonJoint; typedef statecontainer::MechanicalObject MechanicalObject; @@ -63,7 +63,7 @@ struct SkeletalMotionConstraint_test : public BaseSimulationTest, NumericTest joints; ///< skeletal joint - typename SkeletalMotionConstraint::SPtr projection; + typename SkeletalMotionProjectiveConstraint::SPtr projection; typename MechanicalObject::SPtr dofs; /// Create the context for the tests. @@ -77,7 +77,7 @@ struct SkeletalMotionConstraint_test : public BaseSimulationTest, NumericTest(); root->addObject(dofs); - projection = core::objectmodel::New(); + projection = core::objectmodel::New(); root->addObject(projection); @@ -184,9 +184,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(SkeletalMotionConstraint_test, DataTypes); +TYPED_TEST_SUITE(SkeletalMotionProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( SkeletalMotionConstraint_test , twoConstrainedBones ) +TYPED_TEST( SkeletalMotionProjectiveConstraint_test , twoConstrainedBones ) { EXPECT_MSG_NOEMIT(Error) ; this->init_2bones(); diff --git a/Sofa/Component/SolidMechanics/simutests/AffinePatch_test.cpp b/Sofa/Component/SolidMechanics/simutests/AffinePatch_test.cpp index 90c87619417..b0779c4062b 100644 --- a/Sofa/Component/SolidMechanics/simutests/AffinePatch_test.cpp +++ b/Sofa/Component/SolidMechanics/simutests/AffinePatch_test.cpp @@ -30,7 +30,7 @@ #include // Including constraint, force and mass -#include +#include #include #include #include @@ -61,7 +61,7 @@ struct AffinePatch_sofa_test : public sofa::testing::BaseSimulationTest, sofa::t typedef typename DataTypes::VecDeriv VecDeriv; typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::Real Real; - typedef constraint::projective::AffineMovementConstraint AffineMovementConstraint; + typedef constraint::projective::AffineMovementProjectiveConstraint AffineMovementProjectiveConstraint; typedef statecontainer::MechanicalObject MechanicalObject; typedef typename component::solidmechanics::spring::MeshSpringForceField MeshSpringForceField; typedef typename component::solidmechanics::fem::elastic::TetrahedronFEMForceField TetraForceField; diff --git a/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp b/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp index 197433adacf..5835e5266fb 100644 --- a/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp +++ b/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp @@ -39,9 +39,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include namespace sofa { @@ -136,13 +136,13 @@ CylinderTractionStruct createCylinderTractionScene( typename BoxRoi::SPtr boxRoi1 = modeling::addNew(root,"boxRoiFix"); boxRoi1->d_alignedBoxes.setValue(vecBox); boxRoi1->d_strict.setValue(false); - // FixedConstraint - typename component::constraint::projective::FixedConstraint::SPtr fc= - modeling::addNew >(root); + // FixedProjectiveConstraint + typename component::constraint::projective::FixedProjectiveConstraint::SPtr fc= + modeling::addNew >(root); sofa::modeling::setDataLink(&boxRoi1->d_indices,&fc->d_indices); - // FixedPlaneConstraint - typename component::constraint::projective::FixedPlaneConstraint::SPtr fpc= - modeling::addNew >(root); + // FixedPlaneProjectiveConstraint + typename component::constraint::projective::FixedPlaneProjectiveConstraint::SPtr fpc= + modeling::addNew >(root); fpc->d_dmin= -0.01; fpc->d_dmax= 0.01; fpc->d_direction=Coord(0,0,1); @@ -158,9 +158,9 @@ CylinderTractionStruct createCylinderTractionScene( modeling::addNew >(root); tractionStruct.forceField=tpff; sofa::modeling::setDataLink(&boxRoi2->d_triangleIndices,&tpff->triangleList); - // ProjectToLineConstraint - typename component::constraint::projective::ProjectToLineConstraint::SPtr ptlc= - modeling::addNew >(root); + // ProjectToLineProjectiveConstraint + typename component::constraint::projective::ProjectToLineProjectiveConstraint::SPtr ptlc= + modeling::addNew >(root); ptlc->f_direction=Coord(1,0,0); ptlc->f_origin=Coord(0,0,0); sofa::type::vector vArray; diff --git a/Sofa/Component/Topology/Testing/src/sofa/component/topology/testing/RegularGridNodeCreation.h b/Sofa/Component/Topology/Testing/src/sofa/component/topology/testing/RegularGridNodeCreation.h index d4b22e9e5c6..6a6799a8d6e 100644 --- a/Sofa/Component/Topology/Testing/src/sofa/component/topology/testing/RegularGridNodeCreation.h +++ b/Sofa/Component/Topology/Testing/src/sofa/component/topology/testing/RegularGridNodeCreation.h @@ -40,7 +40,7 @@ template struct PatchTestStruct { simulation::Node::SPtr SquareNode; - typename component::constraint::projective::AffineMovementConstraint::SPtr affineConstraint; + typename component::constraint::projective::AffineMovementProjectiveConstraint::SPtr affineConstraint; typename component::statecontainer::MechanicalObject::SPtr dofs; }; @@ -66,7 +66,7 @@ PatchTestStruct createRegularGridScene( typedef component::topology::container::grid::RegularGridTopology RegularGridTopology; typedef typename component::engine::select::BoxROI BoxRoi; typedef typename sofa::component::engine::select::PairBoxROI PairBoxRoi; - typedef typename component::constraint::projective::AffineMovementConstraint AffineMovementConstraint; + typedef typename component::constraint::projective::AffineMovementProjectiveConstraint AffineMovementProjectiveConstraint; typedef component::linearsolver::iterative::CGLinearSolver CGLinearSolver; // Root node @@ -114,7 +114,7 @@ PatchTestStruct createRegularGridScene( pairBoxRoi->includedBox.setValue(includedBox); //Affine constraint - patchStruct.affineConstraint = modeling::addNew(SquareNode,"affineConstraint"); + patchStruct.affineConstraint = modeling::addNew(SquareNode,"affineConstraint"); modeling::setDataLink(&boxRoi->d_indices,&patchStruct.affineConstraint->m_meshIndices); modeling::setDataLink(&pairBoxRoi->f_indices,& patchStruct.affineConstraint->m_indices); diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl b/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl index b96e142bbbd..8cec4715378 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl @@ -62,7 +62,7 @@ void FixParticlePerformer::start() //Fix all the points - typename sofa::component::constraint::projective::FixedConstraint::SPtr fixFixation = sofa::core::objectmodel::New< sofa::component::constraint::projective::FixedConstraint >(); + typename sofa::component::constraint::projective::FixedProjectiveConstraint::SPtr fixFixation = sofa::core::objectmodel::New< sofa::component::constraint::projective::FixedProjectiveConstraint >(); fixFixation->d_fixAll.setValue(true); nodeFixation->addObject(fixFixation); diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h b/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h index b12adce22fb..4b93b261499 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h @@ -51,7 +51,7 @@ class SOFA_GUI_COMPONENT_API SuturePointPerformer: public TInteractionPerformer< typedef typename DataTypes::Real Real; typedef sofa::component::solidmechanics::spring::LinearSpring Spring; typedef sofa::component::solidmechanics::spring::StiffSpringForceField SpringObjectType; - typedef sofa::component::constraint::projective::FixedConstraint FixObjectType; + typedef sofa::component::constraint::projective::FixedProjectiveConstraint FixObjectType; SuturePointPerformer(BaseMouseInteractor *i); ~SuturePointPerformer(); From 650224376008002080ff858414884af71c65cdab Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 21 Nov 2023 16:21:58 +0100 Subject: [PATCH 02/28] Reported changes to Cuda plugin --- applications/plugins/SofaCUDA/CMakeLists.txt | 22 +- ...ateralInteractionLagrangianConstraint.cpp} | 20 +- .../projective/CudaFixedConstraint.cu | 223 ------------------ ....cpp => CudaFixedProjectiveConstraint.cpp} | 40 ++-- .../CudaFixedProjectiveConstraint.cu | 223 ++++++++++++++++++ ...aint.h => CudaFixedProjectiveConstraint.h} | 38 +-- ....inl => CudaFixedProjectiveConstraint.inl} | 158 ++++++------- ...aFixedTranslationProjectiveConstraint.cpp} | 36 +-- .../CudaLinearMovementConstraint.cu | 208 ---------------- ...udaLinearMovementProjectiveConstraint.cpp} | 20 +- .../CudaLinearMovementProjectiveConstraint.cu | 208 ++++++++++++++++ ... CudaLinearMovementProjectiveConstraint.h} | 72 +++--- ...udaLinearMovementProjectiveConstraint.inl} | 168 ++++++------- ...udaLinearVelocityProjectiveConstraint.cpp} | 20 +- 14 files changed, 728 insertions(+), 728 deletions(-) rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/{CudaBilateralInteractionConstraint.cpp => CudaBilateralInteractionLagrangianConstraint.cpp} (72%) delete mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cu rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaFixedConstraint.cpp => CudaFixedProjectiveConstraint.cpp} (54%) create mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cu rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaFixedConstraint.h => CudaFixedProjectiveConstraint.h} (70%) rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaFixedConstraint.inl => CudaFixedProjectiveConstraint.inl} (56%) rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaFixedTranslationConstraint.cpp => CudaFixedTranslationProjectiveConstraint.cpp} (70%) delete mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cu rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaLinearMovementConstraint.cpp => CudaLinearMovementProjectiveConstraint.cpp} (72%) create mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cu rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaLinearMovementConstraint.h => CudaLinearMovementProjectiveConstraint.h} (53%) rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaLinearMovementConstraint.inl => CudaLinearMovementProjectiveConstraint.inl} (55%) rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/{CudaLinearVelocityConstraint.cpp => CudaLinearVelocityProjectiveConstraint.cpp} (75%) diff --git a/applications/plugins/SofaCUDA/CMakeLists.txt b/applications/plugins/SofaCUDA/CMakeLists.txt index 18d32a9d0c5..25aded79541 100644 --- a/applications/plugins/SofaCUDA/CMakeLists.txt +++ b/applications/plugins/SofaCUDA/CMakeLists.txt @@ -88,10 +88,10 @@ set(HEADER_FILES ${SOFACUDA_SOURCE_DIR}/component/collision/geometry/CudaTriangleModel.h ### Constraints - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedConstraint.h - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedConstraint.inl - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementConstraint.h - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementConstraint.inl + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedProjectiveConstraint.h + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedProjectiveConstraint.inl + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementProjectiveConstraint.h + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementProjectiveConstraint.inl ${SOFACUDA_SOURCE_DIR}/component/collision/response/contact/CudaPenalityContactForceField.h ${SOFACUDA_SOURCE_DIR}/component/collision/response/contact/CudaPenalityContactForceField.inl @@ -155,11 +155,11 @@ set(SOURCE_FILES ${SOFACUDA_SOURCE_DIR}/component/collision/geometry/CudaTriangleModel.cpp ### Constraints - ${SOFACUDA_SOURCE_DIR}/component/constraint/lagrangian/model/CudaBilateralInteractionConstraint.cpp - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedConstraint.cpp - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedTranslationConstraint.cpp - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementConstraint.cpp - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearVelocityConstraint.cpp + ${SOFACUDA_SOURCE_DIR}/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedProjectiveConstraint.cpp + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedTranslationProjectiveConstraint.cpp + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cpp + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearVelocityProjectiveConstraint.cpp ${SOFACUDA_SOURCE_DIR}/component/mapping/linear/CudaBeamLinearMapping.cpp ${SOFACUDA_SOURCE_DIR}/component/engine/select/CudaBoxROI.cpp @@ -214,8 +214,8 @@ set(CUDA_SOURCES ### Collisions ### Constraints - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedConstraint.cu - ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementConstraint.cu + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedProjectiveConstraint.cu + ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cu ) diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionConstraint.cpp b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp similarity index 72% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionConstraint.cpp rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp index b0486fe7930..6904cb6b1f6 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionConstraint.cpp +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp @@ -21,18 +21,18 @@ ******************************************************************************/ #include #include -#include +#include #include namespace sofa::component::constraint::lagrangian::model { -template class SOFA_GPU_CUDA_API BilateralInteractionConstraint; -template class SOFA_GPU_CUDA_API BilateralInteractionConstraint; +template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; +template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; #ifdef SOFA_GPU_CUDA_DOUBLE -template class SOFA_GPU_CUDA_API BilateralInteractionConstraint; -template class SOFA_GPU_CUDA_API BilateralInteractionConstraint; +template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; +template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; #endif // SOFA_GPU_CUDA_DOUBLE } //namespace sofa::component::constraint::lagrangian::model @@ -42,12 +42,12 @@ namespace sofa::gpu::cuda using namespace sofa::component::constraint::lagrangian::model; -int BilateralInteractionConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") - .add< BilateralInteractionConstraint >() - .add< BilateralInteractionConstraint >() +int BilateralInteractionLagrangianConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") + .add< BilateralInteractionLagrangianConstraint >() + .add< BilateralInteractionLagrangianConstraint >() #ifdef SOFA_GPU_CUDA_DOUBLE - .add< BilateralInteractionConstraint >() - .add< BilateralInteractionConstraint >() + .add< BilateralInteractionLagrangianConstraint >() + .add< BilateralInteractionLagrangianConstraint >() #endif // SOFA_GPU_CUDA_DOUBLE ; } // namespace sofa::gpu::cuda diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cu b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cu deleted file mode 100644 index b193ef8ef77..00000000000 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cu +++ /dev/null @@ -1,223 +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 "cuda.h" -#include - -#if defined(__cplusplus) && CUDA_VERSION < 2000 -namespace sofa -{ -namespace gpu -{ -namespace cuda -{ -#endif - -extern "C" -{ - void FixedConstraintCuda1f_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda1f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCuda3f_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCuda3f1_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3f1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCudaRigid3f_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCudaRigid3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - -#ifdef SOFA_GPU_CUDA_DOUBLE - - void FixedConstraintCuda3d_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCuda3d1_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3d1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCudaRigid3d_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCudaRigid3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - -#endif // SOFA_GPU_CUDA_DOUBLE -} - -////////////////////// -// GPU-side methods // -////////////////////// - -template -__global__ void FixedConstraintCuda1t_projectResponseContiguous_kernel(int size, real* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[index] = 0.0f; -} - -template -__global__ void FixedConstraintCuda3t_projectResponseContiguous_kernel(int size, CudaVec3* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[index] = CudaVec3::make(0.0f,0.0f,0.0f); -} - -template -__global__ void FixedConstraintCuda3t1_projectResponseContiguous_kernel(int size, CudaVec4* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[index] = CudaVec4::make(0.0f,0.0f,0.0f,0.0f); -} - -template -__global__ void FixedConstraintCudaRigid3t_projectResponseContiguous_kernel(int size, CudaRigidDeriv3* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[index] = CudaRigidDeriv3::make(0.0f,0.0f,0.0f,0.0f,0.0f,0.0f); -} - -template -__global__ void FixedConstraintCuda1t_projectResponseIndexed_kernel(int size, const int* indices, real* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[indices[index]] = 0.0f; -} - -template -__global__ void FixedConstraintCuda3t_projectResponseIndexed_kernel(int size, const int* indices, CudaVec3* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[indices[index]] = CudaVec3::make(0.0f,0.0f,0.0f); -} - -template -__global__ void FixedConstraintCuda3t1_projectResponseIndexed_kernel(int size, const int* indices, CudaVec4* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[indices[index]] = CudaVec4::make(0.0f,0.0f,0.0f,0.0f); -} - -template -__global__ void FixedConstraintCudaRigid3t_projectResponseIndexed_kernel(int size, const int* indices, CudaRigidDeriv3* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - if (index < size) - dx[indices[index]] = CudaRigidDeriv3::make(0.0f,0.0f,0.0f,0.0f,0.0f,0.0f); -} - -////////////////////// -// CPU-side methods // -////////////////////// - -void FixedConstraintCuda1f_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*sizeof(float)); -} - -void FixedConstraintCuda3f_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*3*sizeof(float)); -} - -void FixedConstraintCuda3f1_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*4*sizeof(float)); -} - -void FixedConstraintCudaRigid3f_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*6*sizeof(float)); -} - -void FixedConstraintCuda1f_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCuda1t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (float*)dx); mycudaDebugError("FixedConstraintCuda1t_projectResponseIndexed_kernel");} -} - -void FixedConstraintCuda3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCuda3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec3*)dx); mycudaDebugError("FixedConstraintCuda3t_projectResponseIndexed_kernel");} -} - -void FixedConstraintCuda3f1_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCuda3t1_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec4*)dx); mycudaDebugError("FixedConstraintCuda3t1_projectResponseIndexed_kernel");} -} - -void FixedConstraintCudaRigid3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("FixedConstraintCudaRigid3t_projectResponseIndexed_kernel");} -} - -#ifdef SOFA_GPU_CUDA_DOUBLE - -void FixedConstraintCuda3d_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*3*sizeof(double)); -} - -void FixedConstraintCuda3d1_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*4*sizeof(double)); -} - -void FixedConstraintCudaRigid3d_projectResponseContiguous(unsigned int size, void* dx) -{ - cudaMemset(dx, 0, size*6*sizeof(double)); -} - -void FixedConstraintCuda3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCuda3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec3*)dx); mycudaDebugError("FixedConstraintCuda3t_projectResponseIndexed_kernel");} -} - -void FixedConstraintCuda3d1_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCuda3t1_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec4*)dx); mycudaDebugError("FixedConstraintCuda3t1_projectResponseIndexed_kernel");} -} - -void FixedConstraintCudaRigid3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx) -{ - dim3 threads(BSIZE,1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {FixedConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("FixedConstraintCudaRigid3t_projectResponseIndexed_kernel");} -} - -#endif // SOFA_GPU_CUDA_DOUBLE - -#if defined(__cplusplus) && CUDA_VERSION < 2000 -} // namespace cuda -} // namespace gpu -} // namespace sofa -#endif diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cpp b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cpp similarity index 54% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cpp rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cpp index eb3455d6c04..0384749ab2c 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.cpp +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cpp @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include -#include +#include #include #include #include @@ -29,17 +29,17 @@ namespace sofa::component::constraint::projective { -template class SOFA_GPU_CUDA_API FixedConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; #ifdef SOFA_GPU_CUDA_DOUBLE -template class SOFA_GPU_CUDA_API FixedConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; -template class SOFA_GPU_CUDA_API FixedConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedProjectiveConstraint; #endif // SOFA_GPU_CUDA_DOUBLE } // namespace sofa::component::constraint::projective @@ -47,17 +47,17 @@ template class SOFA_GPU_CUDA_API FixedConstraint; namespace sofa::gpu::cuda { -int FixedConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() +int FixedProjectiveConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() #ifdef SOFA_GPU_CUDA_DOUBLE - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() - .add< component::constraint::projective::FixedConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() + .add< component::constraint::projective::FixedProjectiveConstraint >() #endif // SOFA_GPU_CUDA_DOUBLE ; diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cu b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cu new file mode 100644 index 00000000000..24a7dd330c2 --- /dev/null +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.cu @@ -0,0 +1,223 @@ +/****************************************************************************** +* 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 "cuda.h" +#include + +#if defined(__cplusplus) && CUDA_VERSION < 2000 +namespace sofa +{ +namespace gpu +{ +namespace cuda +{ +#endif + +extern "C" +{ + void FixedProjectiveConstraintCuda1f_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda1f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3f_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3f1_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3f1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCudaRigid3f_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCudaRigid3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + +#ifdef SOFA_GPU_CUDA_DOUBLE + + void FixedProjectiveConstraintCuda3d_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3d1_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3d1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCudaRigid3d_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCudaRigid3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + +#endif // SOFA_GPU_CUDA_DOUBLE +} + +////////////////////// +// GPU-side methods // +////////////////////// + +template +__global__ void FixedProjectiveConstraintCuda1t_projectResponseContiguous_kernel(int size, real* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[index] = 0.0f; +} + +template +__global__ void FixedProjectiveConstraintCuda3t_projectResponseContiguous_kernel(int size, CudaVec3* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[index] = CudaVec3::make(0.0f,0.0f,0.0f); +} + +template +__global__ void FixedProjectiveConstraintCuda3t1_projectResponseContiguous_kernel(int size, CudaVec4* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[index] = CudaVec4::make(0.0f,0.0f,0.0f,0.0f); +} + +template +__global__ void FixedProjectiveConstraintCudaRigid3t_projectResponseContiguous_kernel(int size, CudaRigidDeriv3* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[index] = CudaRigidDeriv3::make(0.0f,0.0f,0.0f,0.0f,0.0f,0.0f); +} + +template +__global__ void FixedProjectiveConstraintCuda1t_projectResponseIndexed_kernel(int size, const int* indices, real* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[indices[index]] = 0.0f; +} + +template +__global__ void FixedProjectiveConstraintCuda3t_projectResponseIndexed_kernel(int size, const int* indices, CudaVec3* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[indices[index]] = CudaVec3::make(0.0f,0.0f,0.0f); +} + +template +__global__ void FixedProjectiveConstraintCuda3t1_projectResponseIndexed_kernel(int size, const int* indices, CudaVec4* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[indices[index]] = CudaVec4::make(0.0f,0.0f,0.0f,0.0f); +} + +template +__global__ void FixedProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel(int size, const int* indices, CudaRigidDeriv3* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + if (index < size) + dx[indices[index]] = CudaRigidDeriv3::make(0.0f,0.0f,0.0f,0.0f,0.0f,0.0f); +} + +////////////////////// +// CPU-side methods // +////////////////////// + +void FixedProjectiveConstraintCuda1f_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*sizeof(float)); +} + +void FixedProjectiveConstraintCuda3f_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*3*sizeof(float)); +} + +void FixedProjectiveConstraintCuda3f1_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*4*sizeof(float)); +} + +void FixedProjectiveConstraintCudaRigid3f_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*6*sizeof(float)); +} + +void FixedProjectiveConstraintCuda1f_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCuda1t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (float*)dx); mycudaDebugError("FixedProjectiveConstraintCuda1t_projectResponseIndexed_kernel");} +} + +void FixedProjectiveConstraintCuda3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCuda3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec3*)dx); mycudaDebugError("FixedProjectiveConstraintCuda3t_projectResponseIndexed_kernel");} +} + +void FixedProjectiveConstraintCuda3f1_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCuda3t1_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec4*)dx); mycudaDebugError("FixedProjectiveConstraintCuda3t1_projectResponseIndexed_kernel");} +} + +void FixedProjectiveConstraintCudaRigid3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("FixedProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel");} +} + +#ifdef SOFA_GPU_CUDA_DOUBLE + +void FixedProjectiveConstraintCuda3d_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*3*sizeof(double)); +} + +void FixedProjectiveConstraintCuda3d1_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*4*sizeof(double)); +} + +void FixedProjectiveConstraintCudaRigid3d_projectResponseContiguous(unsigned int size, void* dx) +{ + cudaMemset(dx, 0, size*6*sizeof(double)); +} + +void FixedProjectiveConstraintCuda3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCuda3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec3*)dx); mycudaDebugError("FixedProjectiveConstraintCuda3t_projectResponseIndexed_kernel");} +} + +void FixedProjectiveConstraintCuda3d1_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCuda3t1_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaVec4*)dx); mycudaDebugError("FixedProjectiveConstraintCuda3t1_projectResponseIndexed_kernel");} +} + +void FixedProjectiveConstraintCudaRigid3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx) +{ + dim3 threads(BSIZE,1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {FixedProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("FixedProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel");} +} + +#endif // SOFA_GPU_CUDA_DOUBLE + +#if defined(__cplusplus) && CUDA_VERSION < 2000 +} // namespace cuda +} // namespace gpu +} // namespace sofa +#endif diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h similarity index 70% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h index 15e27ce1a2a..aebbdb87fe4 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h @@ -22,19 +22,19 @@ #pragma once #include -#include +#include namespace sofa::component::constraint::projective { template -class FixedConstraintInternalData< gpu::cuda::CudaVectorTypes > +class FixedProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes > { public: using Index = sofa::Index; - typedef FixedConstraintInternalData< gpu::cuda::CudaVectorTypes > Data; + typedef FixedProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes > Data; typedef gpu::cuda::CudaVectorTypes DataTypes; - typedef FixedConstraint Main; + typedef FixedProjectiveConstraint Main; typedef typename DataTypes::VecDeriv VecDeriv; typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::Real Real; @@ -58,13 +58,13 @@ class FixedConstraintInternalData< gpu::cuda::CudaVectorTypes -class FixedConstraintInternalData< gpu::cuda::CudaRigidTypes > +class FixedProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes > { public: using Index = sofa::Index; - typedef FixedConstraintInternalData< gpu::cuda::CudaRigidTypes > Data; + typedef FixedProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes > Data; typedef gpu::cuda::CudaRigidTypes DataTypes; - typedef FixedConstraint Main; + typedef FixedProjectiveConstraint Main; typedef typename DataTypes::VecDeriv VecDeriv; typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::Real Real; @@ -88,24 +88,24 @@ class FixedConstraintInternalData< gpu::cuda::CudaRigidTypes > }; // I know using macros is bad design but this is the only way not to repeat the code for all CUDA types -#define CudaFixedConstraint_DeclMethods(T) \ - template<> void FixedConstraint< T >::init(); \ - template<> void FixedConstraint< T >::addConstraint(Index index); \ - template<> void FixedConstraint< T >::removeConstraint(Index index); \ - template<> void FixedConstraint< T >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData); +#define CudaFixedProjectiveConstraint_DeclMethods(T) \ + template<> void FixedProjectiveConstraint< T >::init(); \ + template<> void FixedProjectiveConstraint< T >::addConstraint(Index index); \ + template<> void FixedProjectiveConstraint< T >::removeConstraint(Index index); \ + template<> void FixedProjectiveConstraint< T >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData); -CudaFixedConstraint_DeclMethods(gpu::cuda::CudaVec3fTypes); -CudaFixedConstraint_DeclMethods(gpu::cuda::CudaVec3f1Types); -CudaFixedConstraint_DeclMethods(gpu::cuda::CudaRigid3fTypes); +CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaVec3fTypes); +CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaVec3f1Types); +CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaRigid3fTypes); #ifdef SOFA_GPU_CUDA_DOUBLE -CudaFixedConstraint_DeclMethods(gpu::cuda::CudaVec3dTypes); -CudaFixedConstraint_DeclMethods(gpu::cuda::CudaVec3d1Types); -CudaFixedConstraint_DeclMethods(gpu::cuda::CudaRigid3dTypes); +CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaVec3dTypes); +CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaVec3d1Types); +CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaRigid3dTypes); #endif // SOFA_GPU_CUDA_DOUBLE -#undef CudaFixedConstraint_DeclMethods +#undef CudaFixedProjectiveConstraint_DeclMethods } // namespace sofa::component::constraint::projective diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.inl similarity index 56% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.inl index 1054b5a3784..6d3ce62aa71 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.inl @@ -21,31 +21,31 @@ ******************************************************************************/ #pragma once -#include -#include +#include +#include namespace sofa::gpu::cuda { extern "C" { - void FixedConstraintCuda1f_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda1f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCuda3f_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCuda3f1_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3f1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCudaRigid3f_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCudaRigid3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda1f_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda1f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3f_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3f1_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3f1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCudaRigid3f_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCudaRigid3f_projectResponseIndexed(unsigned int size, const void* indices, void* dx); #ifdef SOFA_GPU_CUDA_DOUBLE - void FixedConstraintCuda3d_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCuda3d1_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCuda3d1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); - void FixedConstraintCudaRigid3d_projectResponseContiguous(unsigned int size, void* dx); - void FixedConstraintCudaRigid3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3d_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCuda3d1_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCuda3d1_projectResponseIndexed(unsigned int size, const void* indices, void* dx); + void FixedProjectiveConstraintCudaRigid3d_projectResponseContiguous(unsigned int size, void* dx); + void FixedProjectiveConstraintCudaRigid3d_projectResponseIndexed(unsigned int size, const void* indices, void* dx); #endif // SOFA_GPU_CUDA_DOUBLE } @@ -58,7 +58,7 @@ namespace sofa::component::constraint::projective using namespace gpu::cuda; template -void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes >::init(Main* m) +void FixedProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::init(Main* m) { Data& data = *m->data; data.minIndex = sofa::InvalidID; @@ -77,11 +77,11 @@ void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes::const_iterator it = sortedIndices.begin(); it!=sortedIndices.end(); ++it) data.cudaIndices.push_back(*it); @@ -92,17 +92,17 @@ void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes -void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes >::addConstraint(Main* m, Index index) +void FixedProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::addConstraint(Main* m, Index index) { Data& data = *m->data; - //std::cout << "CudaFixedConstraint::addConstraint("<d_indices.beginEdit()->push_back(index); m->d_indices.endEdit(); if (data.cudaIndices.empty()) { if (data.minIndex == sofa::InvalidID) { - //std::cout << "CudaFixedConstraint: single index "< -void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes >::removeConstraint(Main* m, Index index) +void FixedProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::removeConstraint(Main* m, Index index) { Data& data = *m->data; removeValue(*m->d_indices.beginEdit(),index); @@ -188,7 +188,7 @@ void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes -void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes >::init(Main* m) +void FixedProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::init(Main* m) { Data& data = *m->data; data.minIndex = sofa::InvalidID; @@ -207,11 +207,11 @@ void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes >::init(Mai { data.minIndex = *sortedIndices.begin(); data.maxIndex = *sortedIndices.rbegin(); - msg_info("CudaFixedConstraint") << "init: " << sortedIndices.size() << " contiguous fixed indices, " << data.minIndex << " - " << data.maxIndex; + msg_info("CudaFixedProjectiveConstraint") << "init: " << sortedIndices.size() << " contiguous fixed indices, " << data.minIndex << " - " << data.maxIndex; } else { - msg_info("CudaFixedConstraint") << "init: " << sortedIndices.size() << " non-contiguous fixed indices"; + msg_info("CudaFixedProjectiveConstraint") << "init: " << sortedIndices.size() << " non-contiguous fixed indices"; data.cudaIndices.reserve(sortedIndices.size()); for (std::set::const_iterator it = sortedIndices.begin(); it!=sortedIndices.end(); ++it) data.cudaIndices.push_back(*it); @@ -222,17 +222,17 @@ void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes >::init(Mai } template -void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes >::addConstraint(Main* m, Index index) +void FixedProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::addConstraint(Main* m, Index index) { Data& data = *m->data; - //std::cout << "CudaFixedConstraint::addConstraint("<d_indices.beginEdit()->push_back(index); m->d_indices.endEdit(); if (data.cudaIndices.empty()) { if (data.minIndex == sofa::InvalidID) { - //std::cout << "CudaFixedConstraint: single index "< >::addConst else if (data.minIndex == index+1) { data.minIndex = index; - //std::cout << "CudaFixedConstraint: new min index "< >::addConst data.cudaIndices.push_back(index); data.minIndex = sofa::InvalidID; data.maxIndex = sofa::InvalidID; - msg_info("CudaFixedConstraint") << "new indices array size "< -void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes >::removeConstraint(Main* m, Index index) +void FixedProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::removeConstraint(Main* m, Index index) { Data& data = *m->data; removeValue(*m->d_indices.beginEdit(),index); @@ -320,53 +320,53 @@ void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes >::removeCo template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { const Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCuda1f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); + FixedProjectiveConstraintCuda1f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); else if (data.minIndex >= 0) - FixedConstraintCuda1f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+data.minIndex); + FixedProjectiveConstraintCuda1f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+data.minIndex); else - FixedConstraintCuda1f_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCuda1f_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { const Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCuda3f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); + FixedProjectiveConstraintCuda3f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); else if (data.minIndex != sofa::InvalidID) - FixedConstraintCuda3f_projectResponseContiguous(data.maxIndex - data.minIndex + 1, ((float*)dx.deviceWrite()) + 3 * data.minIndex); + FixedProjectiveConstraintCuda3f_projectResponseContiguous(data.maxIndex - data.minIndex + 1, ((float*)dx.deviceWrite()) + 3 * data.minIndex); else - FixedConstraintCuda3f_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCuda3f_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { const Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCuda3f1_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); + FixedProjectiveConstraintCuda3f1_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); else if (data.minIndex != sofa::InvalidID) - FixedConstraintCuda3f1_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+4*data.minIndex); + FixedProjectiveConstraintCuda3f1_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+4*data.minIndex); else - FixedConstraintCuda3f1_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCuda3f1_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { const Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCudaRigid3f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); + FixedProjectiveConstraintCudaRigid3f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite())); else if (data.minIndex != sofa::InvalidID) - FixedConstraintCudaRigid3f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+6*data.minIndex); + FixedProjectiveConstraintCudaRigid3f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+6*data.minIndex); else - FixedConstraintCudaRigid3f_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCudaRigid3f_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } @@ -375,7 +375,7 @@ void FixedConstraintInternalData::projectResponse(M // // Handle topological changes // template <> -// void FixedConstraint::handleTopologyChange() { +// void FixedProjectiveConstraint::handleTopologyChange() { // // std::list::const_iterator itBegin=topology->firstChange(); // // std::list::const_iterator itEnd=topology->lastChange(); // // @@ -384,70 +384,70 @@ void FixedConstraintInternalData::projectResponse(M // } template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCuda3d_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite())); + FixedProjectiveConstraintCuda3d_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite())); else if (data.minIndex >= 0) - FixedConstraintCuda3d_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+3*data.minIndex); + FixedProjectiveConstraintCuda3d_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+3*data.minIndex); else - FixedConstraintCuda3d_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCuda3d_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCuda3d1_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite())); + FixedProjectiveConstraintCuda3d1_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite())); else if (data.minIndex >= 0) - FixedConstraintCuda3d1_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+4*data.minIndex); + FixedProjectiveConstraintCuda3d1_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+4*data.minIndex); else - FixedConstraintCuda3d1_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCuda3d1_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } template <> -void FixedConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) +void FixedProjectiveConstraintInternalData::projectResponse(Main* m, VecDeriv& dx) { Data& data = *m->data; if (m->d_fixAll.getValue()) - FixedConstraintCudaRigid3d_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite())); + FixedProjectiveConstraintCudaRigid3d_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite())); else if (data.minIndex >= 0) - FixedConstraintCudaRigid3d_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+6*data.minIndex); + FixedProjectiveConstraintCudaRigid3d_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+6*data.minIndex); else - FixedConstraintCudaRigid3d_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); + FixedProjectiveConstraintCudaRigid3d_projectResponseIndexed(data.cudaIndices.size(), data.cudaIndices.deviceRead(), dx.deviceWrite()); } #endif // SOFA_GPU_CUDA_DOUBLE // I know using macros is bad design but this is the only way not to repeat the code for all CUDA types -#define CudaFixedConstraint_ImplMethods(T) \ - template<> void FixedConstraint< T >::init() \ +#define CudaFixedProjectiveConstraint_ImplMethods(T) \ + template<> void FixedProjectiveConstraint< T >::init() \ { data->init(this); } \ - template<> void FixedConstraint< T >::addConstraint(Index index) \ + template<> void FixedProjectiveConstraint< T >::addConstraint(Index index) \ { data->addConstraint(this, index); } \ - template<> void FixedConstraint< T >::removeConstraint(Index index) \ + template<> void FixedProjectiveConstraint< T >::removeConstraint(Index index) \ { data->removeConstraint(this, index); } \ - template<> void FixedConstraint< T >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& d_resData) \ + template<> void FixedProjectiveConstraint< T >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& d_resData) \ { \ VecDeriv &resData = *d_resData.beginEdit(); \ data->projectResponse(this, resData); \ d_resData.endEdit(); \ } -CudaFixedConstraint_ImplMethods(gpu::cuda::CudaVec3fTypes); -CudaFixedConstraint_ImplMethods(gpu::cuda::CudaVec3f1Types); -CudaFixedConstraint_ImplMethods(gpu::cuda::CudaRigid3fTypes); +CudaFixedProjectiveConstraint_ImplMethods(gpu::cuda::CudaVec3fTypes); +CudaFixedProjectiveConstraint_ImplMethods(gpu::cuda::CudaVec3f1Types); +CudaFixedProjectiveConstraint_ImplMethods(gpu::cuda::CudaRigid3fTypes); #ifdef SOFA_GPU_CUDA_DOUBLE -CudaFixedConstraint_ImplMethods(gpu::cuda::CudaVec3dTypes); -CudaFixedConstraint_ImplMethods(gpu::cuda::CudaVec3d1Types); -CudaFixedConstraint_ImplMethods(gpu::cuda::CudaRigid3dTypes); +CudaFixedProjectiveConstraint_ImplMethods(gpu::cuda::CudaVec3dTypes); +CudaFixedProjectiveConstraint_ImplMethods(gpu::cuda::CudaVec3d1Types); +CudaFixedProjectiveConstraint_ImplMethods(gpu::cuda::CudaRigid3dTypes); #endif // SOFA_GPU_CUDA_DOUBLE -#undef CudaFixedConstraint_ImplMethods +#undef CudaFixedProjectiveConstraint_ImplMethods } // namespace sofa::component::constraint::projective diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedTranslationConstraint.cpp b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedTranslationProjectiveConstraint.cpp similarity index 70% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedTranslationConstraint.cpp rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedTranslationProjectiveConstraint.cpp index 7d9d18db439..64ebf9fecac 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedTranslationConstraint.cpp +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedTranslationProjectiveConstraint.cpp @@ -21,7 +21,7 @@ ******************************************************************************/ #include #include -#include +#include #include @@ -32,15 +32,15 @@ namespace sofa::component::constraint::projective { template<> -void FixedTranslationConstraint::draw(const core::visual::VisualParams* vparams); +void FixedTranslationProjectiveConstraint::draw(const core::visual::VisualParams* vparams); #ifdef SOFA_GPU_CUDA_DOUBLE template<> -void FixedTranslationConstraint::draw(const core::visual::VisualParams* vparams); +void FixedTranslationProjectiveConstraint::draw(const core::visual::VisualParams* vparams); #endif // SOFA_GPU_CUDA_DOUBLE template <> -void component::constraint::projective::FixedTranslationConstraint::draw(const core::visual::VisualParams* vparams) +void component::constraint::projective::FixedTranslationProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { #if SOFACUDA_HAVE_SOFA_GL == 1 const SetIndexArray & indices = f_indices.getValue(); @@ -71,7 +71,7 @@ void component::constraint::projective::FixedTranslationConstraint -void component::constraint::projective::FixedTranslationConstraint::draw(const core::visual::VisualParams* vparams) +void component::constraint::projective::FixedTranslationProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { const SetIndexArray & indices = f_indices.getValue(); if (!vparams->displayFlags().getShowBehaviorModels()) @@ -100,11 +100,11 @@ void component::constraint::projective::FixedTranslationConstraint; -template class SOFA_GPU_CUDA_API FixedTranslationConstraint; +template class SOFA_GPU_CUDA_API FixedTranslationProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedTranslationProjectiveConstraint; #ifdef SOFA_GPU_CUDA_DOUBLE -template class SOFA_GPU_CUDA_API FixedTranslationConstraint; -template class SOFA_GPU_CUDA_API FixedTranslationConstraint; +template class SOFA_GPU_CUDA_API FixedTranslationProjectiveConstraint; +template class SOFA_GPU_CUDA_API FixedTranslationProjectiveConstraint; #endif // SOFA_GPU_CUDA_DOUBLE }// namespace sofa::component::constraint::projective @@ -113,16 +113,16 @@ namespace sofa::gpu::cuda { -int FixedTranslationConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") -// .add< component::constraint::projective::FixedTranslationConstraint >() -// .add< component::constraint::projective::FixedTranslationConstraint >() - .add< component::constraint::projective::FixedTranslationConstraint >() - .add< component::constraint::projective::FixedTranslationConstraint >() +int FixedTranslationProjectiveConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") +// .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() +// .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() + .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() + .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() #ifdef SOFA_GPU_CUDA_DOUBLE -// .add< component::constraint::projective::FixedTranslationConstraint >() -// .add< component::constraint::projective::FixedTranslationConstraint >() - .add< component::constraint::projective::FixedTranslationConstraint >() - .add< component::constraint::projective::FixedTranslationConstraint >() +// .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() +// .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() + .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() + .add< component::constraint::projective::FixedTranslationProjectiveConstraint >() #endif // SOFA_GPU_CUDA_DOUBLE ; diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cu b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cu deleted file mode 100644 index 2deca0a26ad..00000000000 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cu +++ /dev/null @@ -1,208 +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 "cuda.h" -#include - -#if defined(__cplusplus) && CUDA_VERSION < 2000 -namespace sofa -{ -namespace gpu -{ -namespace cuda -{ -#endif - -extern "C" -{ - - void LinearMovementConstraintCudaVec6f_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaVec6f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaVec6f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); - void LinearMovementConstraintCudaRigid3f_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaRigid3f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaRigid3f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); - -#ifdef SOFA_GPU_CUDA_DOUBLE - void LinearMovementConstraintCudaVec6d_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaVec6d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaVec6d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); - void LinearMovementConstraintCudaRigid3d_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaRigid3d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaRigid3d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); -#endif // SOFA_GPU_CUDA_DOUBLE - -}// extern "C" - -////////////////////// -// GPU-side methods // -////////////////////// - -template -__global__ void LinearMovementConstraintCudaVec6t_projectPositionIndexed_kernel(unsigned size, const int* indices, real dirX, real dirY, real dirZ, real dirU, real dirV, real dirW, const CudaVec6* x0, CudaVec6* x) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - - CudaVec6 m = CudaVec6::make(dirX, dirY, dirZ, dirU, dirV, dirW); - if (index < size) - { - x[indices[index]] = x0[index]; - x[indices[index]] += m; - } -}// projectPositionIndexed_kernel - -template -__global__ void LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel(unsigned size, const int* indices, CudaRigidDeriv3* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - - if (index < size) - { - dx[indices[index]] = CudaRigidDeriv3::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - } -}// kernel Indexed Cuda3t1 - -template -__global__ void LinearMovementConstraintCudaRigid3t_projectPositionIndexed_kernel(unsigned size, const int* indices, real dirX, real dirY, real dirZ, real dirU, real dirV, real dirW, const CudaRigidCoord3* x0, CudaRigidCoord3* x) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - - CudaRigidCoord3 m = CudaRigidCoord3::make(dirX, dirY, dirZ, dirU, dirV, dirW, 0.0); - if (index < size) - { - x[indices[index]] = x0[index]; - x[indices[index]] += m; - } -}// projectPositionIndexed_kernel - - -template -__global__ void LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel(unsigned size, const int* indices, real velX, real velY, real velZ, real velU, real velV, real velW, CudaRigidDeriv3* dx) -{ - int index = blockIdx.x * BSIZE+threadIdx.x; - - CudaRigidDeriv3 vel = CudaRigidDeriv3::make(velX, velY, velZ, velU, velV, velW); - if (index < size) - { - dx[indices[index]] = vel; - } -}// projectVelocityIndexed_kernel - -////////////////////// -// CPU-side methods // -////////////////////// -void LinearMovementConstraintCudaVec6f_projectResponseIndexed(unsigned size, const void* indices, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel");} -} - -void LinearMovementConstraintCudaVec6f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - LinearMovementConstraintCudaVec6t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, - ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], - (const CudaVec6*) x0, (CudaVec6*)x); -} - -void LinearMovementConstraintCudaVec6f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel");} -} -void LinearMovementConstraintCudaRigid3f_projectResponseIndexed(unsigned size, const void* indices, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel");} -} - -void LinearMovementConstraintCudaRigid3f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], (const CudaRigidCoord3*) x0, (CudaRigidCoord3*)x); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectPositionIndexed_kernel");} -} - -void LinearMovementConstraintCudaRigid3f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel");} -} - -#ifdef SOFA_GPU_CUDA_DOUBLE -void LinearMovementConstraintCudaVec6d_projectResponseIndexed(unsigned size, const void* indices, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel");} -} - -void LinearMovementConstraintCudaVec6d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - LinearMovementConstraintCudaVec6t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, - ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], - (const CudaVec6*) x0, (CudaVec6*)x); -} - -void LinearMovementConstraintCudaVec6d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel");} -} - -void LinearMovementConstraintCudaRigid3d_projectResponseIndexed(unsigned size, const void* indices, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectResponseIndexed_kernel");} -} - -void LinearMovementConstraintCudaRigid3d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], (const CudaRigidCoord3*) x0, (CudaRigidCoord3*)x); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectPositionIndexed_kernel");} -} - -void LinearMovementConstraintCudaRigid3d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) -{ - dim3 threads(BSIZE, 1); - dim3 grid((size+BSIZE-1)/BSIZE,1); - {LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementConstraintCudaRigid3t_projectVelocityIndexed_kernel");} -} - -#endif // SOFA_GPU_CUDA_DOUBLE - -#if defined(__cplusplus) && CUDA_VERSION < 2000 -} // namespace cuda -} // namespace gpu -} // namespace sofa -#endif diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cpp b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cpp similarity index 72% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cpp rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cpp index 6968e2ddfed..2ef5054b202 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.cpp +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cpp @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include -#include +#include #include #include @@ -41,16 +41,16 @@ namespace sofa::gpu::cuda { -int LinearMovementConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") -// .add< component::constraint::projective::LinearMovementConstraint >() -// .add< component::constraint::projective::LinearMovementConstraint >() - .add< component::constraint::projective::LinearMovementConstraint >() - .add< component::constraint::projective::LinearMovementConstraint >() +int LinearMovementProjectiveConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") +// .add< component::constraint::projective::LinearMovementProjectiveConstraint >() +// .add< component::constraint::projective::LinearMovementProjectiveConstraint >() + .add< component::constraint::projective::LinearMovementProjectiveConstraint >() + .add< component::constraint::projective::LinearMovementProjectiveConstraint >() #ifdef SOFA_GPU_CUDA_DOUBLE -// .add< component::constraint::projective::LinearMovementConstraint >() -// .add< component::constraint::projective::LinearMovementConstraint >() - .add< component::constraint::projective::LinearMovementConstraint >() - .add< component::constraint::projective::LinearMovementConstraint >() +// .add< component::constraint::projective::LinearMovementProjectiveConstraint >() +// .add< component::constraint::projective::LinearMovementProjectiveConstraint >() + .add< component::constraint::projective::LinearMovementProjectiveConstraint >() + .add< component::constraint::projective::LinearMovementProjectiveConstraint >() #endif // SOFA_GPU_CUDA_DOUBLE ; diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cu b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cu new file mode 100644 index 00000000000..d315362b0de --- /dev/null +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cu @@ -0,0 +1,208 @@ +/****************************************************************************** +* 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 "cuda.h" +#include + +#if defined(__cplusplus) && CUDA_VERSION < 2000 +namespace sofa +{ +namespace gpu +{ +namespace cuda +{ +#endif + +extern "C" +{ + + void LinearMovementProjectiveConstraintCudaVec6f_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaVec6f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaVec6f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3f_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaRigid3f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + +#ifdef SOFA_GPU_CUDA_DOUBLE + void LinearMovementProjectiveConstraintCudaVec6d_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaVec6d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaVec6d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3d_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaRigid3d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); +#endif // SOFA_GPU_CUDA_DOUBLE + +}// extern "C" + +////////////////////// +// GPU-side methods // +////////////////////// + +template +__global__ void LinearMovementProjectiveConstraintCudaVec6t_projectPositionIndexed_kernel(unsigned size, const int* indices, real dirX, real dirY, real dirZ, real dirU, real dirV, real dirW, const CudaVec6* x0, CudaVec6* x) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + + CudaVec6 m = CudaVec6::make(dirX, dirY, dirZ, dirU, dirV, dirW); + if (index < size) + { + x[indices[index]] = x0[index]; + x[indices[index]] += m; + } +}// projectPositionIndexed_kernel + +template +__global__ void LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel(unsigned size, const int* indices, CudaRigidDeriv3* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + + if (index < size) + { + dx[indices[index]] = CudaRigidDeriv3::make(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + } +}// kernel Indexed Cuda3t1 + +template +__global__ void LinearMovementProjectiveConstraintCudaRigid3t_projectPositionIndexed_kernel(unsigned size, const int* indices, real dirX, real dirY, real dirZ, real dirU, real dirV, real dirW, const CudaRigidCoord3* x0, CudaRigidCoord3* x) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + + CudaRigidCoord3 m = CudaRigidCoord3::make(dirX, dirY, dirZ, dirU, dirV, dirW, 0.0); + if (index < size) + { + x[indices[index]] = x0[index]; + x[indices[index]] += m; + } +}// projectPositionIndexed_kernel + + +template +__global__ void LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel(unsigned size, const int* indices, real velX, real velY, real velZ, real velU, real velV, real velW, CudaRigidDeriv3* dx) +{ + int index = blockIdx.x * BSIZE+threadIdx.x; + + CudaRigidDeriv3 vel = CudaRigidDeriv3::make(velX, velY, velZ, velU, velV, velW); + if (index < size) + { + dx[indices[index]] = vel; + } +}// projectVelocityIndexed_kernel + +////////////////////// +// CPU-side methods // +////////////////////// +void LinearMovementProjectiveConstraintCudaVec6f_projectResponseIndexed(unsigned size, const void* indices, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaVec6f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + LinearMovementProjectiveConstraintCudaVec6t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, + ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], + (const CudaVec6*) x0, (CudaVec6*)x); +} + +void LinearMovementProjectiveConstraintCudaVec6f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel");} +} +void LinearMovementProjectiveConstraintCudaRigid3f_projectResponseIndexed(unsigned size, const void* indices, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaRigid3f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], (const CudaRigidCoord3*) x0, (CudaRigidCoord3*)x); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectPositionIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaRigid3f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((float*)dir)[0], ((float*)dir)[1], ((float*)dir)[2], ((float*)dir)[3], ((float*)dir)[4], ((float*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel");} +} + +#ifdef SOFA_GPU_CUDA_DOUBLE +void LinearMovementProjectiveConstraintCudaVec6d_projectResponseIndexed(unsigned size, const void* indices, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaVec6d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + LinearMovementProjectiveConstraintCudaVec6t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, + ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], + (const CudaVec6*) x0, (CudaVec6*)x); +} + +void LinearMovementProjectiveConstraintCudaVec6d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaRigid3d_projectResponseIndexed(unsigned size, const void* indices, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectResponseIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaRigid3d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectPositionIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], (const CudaRigidCoord3*) x0, (CudaRigidCoord3*)x); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectPositionIndexed_kernel");} +} + +void LinearMovementProjectiveConstraintCudaRigid3d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx) +{ + dim3 threads(BSIZE, 1); + dim3 grid((size+BSIZE-1)/BSIZE,1); + {LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel<<< grid, threads >>>(size, (const int*)indices, ((double*)dir)[0], ((double*)dir)[1], ((double*)dir)[2], ((double*)dir)[3], ((double*)dir)[4], ((double*)dir)[5], (CudaRigidDeriv3*)dx); mycudaDebugError("LinearMovementProjectiveConstraintCudaRigid3t_projectVelocityIndexed_kernel");} +} + +#endif // SOFA_GPU_CUDA_DOUBLE + +#if defined(__cplusplus) && CUDA_VERSION < 2000 +} // namespace cuda +} // namespace gpu +} // namespace sofa +#endif diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.h similarity index 53% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.h index fcfa31f5a2f..be287995b87 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.h @@ -22,13 +22,13 @@ #pragma once #include -#include +#include namespace sofa::gpu::cuda { template -class CudaKernelsLinearMovementConstraint; +class CudaKernelsLinearMovementProjectiveConstraint; }// namespace sofa::gpu::cuda @@ -36,13 +36,13 @@ namespace sofa::component::constraint::projective { template -class LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes > +class LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes > { public: using Index = sofa::Index; - typedef LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes > Data; + typedef LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes > Data; typedef gpu::cuda::CudaVectorTypes DataTypes; - typedef LinearMovementConstraint Main; + typedef LinearMovementProjectiveConstraint Main; typedef typename DataTypes::VecCoord VecCoord; typedef typename DataTypes::VecDeriv VecDeriv; typedef typename DataTypes::MatrixDeriv MatrixDeriv; @@ -56,7 +56,7 @@ class LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes DataVecDeriv; typedef sofa::core::objectmodel::Data DataMatrixDeriv; - typedef gpu::cuda::CudaKernelsLinearMovementConstraint Kernels; + typedef gpu::cuda::CudaKernelsLinearMovementProjectiveConstraint Kernels; // vector of indices for general case gpu::cuda::CudaVector indices; @@ -80,13 +80,13 @@ class LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -class LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes > +class LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes > { public: using Index = sofa::Index; - typedef LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes > Data; + typedef LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes > Data; typedef gpu::cuda::CudaRigidTypes DataTypes; - typedef LinearMovementConstraint Main; + typedef LinearMovementProjectiveConstraint Main; typedef typename DataTypes::VecCoord VecCoord; typedef typename DataTypes::VecDeriv VecDeriv; typedef typename DataTypes::MatrixDeriv MatrixDeriv; @@ -100,7 +100,7 @@ class LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes > typedef sofa::core::objectmodel::Data DataVecDeriv; typedef sofa::core::objectmodel::Data DataMatrixDeriv; - typedef gpu::cuda::CudaKernelsLinearMovementConstraint Kernels; + typedef gpu::cuda::CudaKernelsLinearMovementProjectiveConstraint Kernels; // vector of indices for general case gpu::cuda::CudaVector indices; @@ -124,84 +124,84 @@ class LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes > // template<> -// void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::init(); +// void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::init(); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::addIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::addIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::removeIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::removeIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::addIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::addIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::removeIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::removeIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); #ifdef SOFA_GPU_CUDA_DOUBLE // template<> -// void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::init(); +// void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::init(); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::addIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::addIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::removeIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::removeIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::addIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::addIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::removeIndex(Index index); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::removeIndex(Index index); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& dx); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& x); template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& dx); #endif // SOFA_GPU_CUDA_DOUBLE diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.inl similarity index 55% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.inl index a9abcd99c24..e3f00a0f5d7 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.inl @@ -21,8 +21,8 @@ ******************************************************************************/ #pragma once -#include -#include +#include +#include namespace sofa::gpu::cuda { @@ -30,97 +30,97 @@ namespace sofa::gpu::cuda extern "C" { - void LinearMovementConstraintCudaVec6f_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaVec6f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaVec6f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); - void LinearMovementConstraintCudaRigid3f_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaRigid3f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaRigid3f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + void LinearMovementProjectiveConstraintCudaVec6f_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaVec6f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaVec6f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3f_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3f_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaRigid3f_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); #ifdef SOFA_GPU_CUDA_DOUBLE - void LinearMovementConstraintCudaVec6d_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaVec6d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaVec6d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); - void LinearMovementConstraintCudaRigid3d_projectResponseIndexed(unsigned size, const void* indices, void* dx); - void LinearMovementConstraintCudaRigid3d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); - void LinearMovementConstraintCudaRigid3d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + void LinearMovementProjectiveConstraintCudaVec6d_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaVec6d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaVec6d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3d_projectResponseIndexed(unsigned size, const void* indices, void* dx); + void LinearMovementProjectiveConstraintCudaRigid3d_projectPositionIndexed(unsigned size, const void* indices, const void* dir, const void* x0, void* x); + void LinearMovementProjectiveConstraintCudaRigid3d_projectVelocityIndexed(unsigned size, const void* indices, const void* dir, void* dx); #endif // SOFA_GPU_CUDA_DOUBLE }// extern "C" template<> -class CudaKernelsLinearMovementConstraint< CudaVec6fTypes > +class CudaKernelsLinearMovementProjectiveConstraint< CudaVec6fTypes > { public: static void projectResponse(unsigned size, const void* indices, void* dx) { - LinearMovementConstraintCudaVec6f_projectResponseIndexed(size, indices, dx); + LinearMovementProjectiveConstraintCudaVec6f_projectResponseIndexed(size, indices, dx); } static void projectPosition(unsigned size, const void* indices, const void* dir, const void* x0, void* x) { - LinearMovementConstraintCudaVec6f_projectPositionIndexed(size, indices, dir, x0, x); + LinearMovementProjectiveConstraintCudaVec6f_projectPositionIndexed(size, indices, dir, x0, x); } static void projectVelocity(unsigned size, const void* indices, const void* dir, void* dx) { - LinearMovementConstraintCudaVec6f_projectVelocityIndexed(size, indices, dir, dx); + LinearMovementProjectiveConstraintCudaVec6f_projectVelocityIndexed(size, indices, dir, dx); } -};// CudaKernelsLinearMovementConstraint +};// CudaKernelsLinearMovementProjectiveConstraint template<> -class CudaKernelsLinearMovementConstraint< CudaRigid3fTypes > +class CudaKernelsLinearMovementProjectiveConstraint< CudaRigid3fTypes > { public: static void projectResponse(unsigned size, const void* indices, void* dx) { - LinearMovementConstraintCudaRigid3f_projectResponseIndexed(size, indices, dx); + LinearMovementProjectiveConstraintCudaRigid3f_projectResponseIndexed(size, indices, dx); } static void projectPosition(unsigned size, const void* indices, const void* dir, const void* x0, void* x) { - LinearMovementConstraintCudaRigid3f_projectPositionIndexed(size, indices, dir, x0, x); + LinearMovementProjectiveConstraintCudaRigid3f_projectPositionIndexed(size, indices, dir, x0, x); } static void projectVelocity(unsigned size, const void* indices, const void* dir, void* dx) { - LinearMovementConstraintCudaRigid3f_projectVelocityIndexed(size, indices, dir, dx); + LinearMovementProjectiveConstraintCudaRigid3f_projectVelocityIndexed(size, indices, dir, dx); } -};// CudaKernelsLinearMovementConstraint +};// CudaKernelsLinearMovementProjectiveConstraint #ifdef SOFA_GPU_CUDA_DOUBLE template<> -class CudaKernelsLinearMovementConstraint< CudaVec6dTypes > +class CudaKernelsLinearMovementProjectiveConstraint< CudaVec6dTypes > { public: static void projectResponse(unsigned size, const void* indices, void* dx) { - LinearMovementConstraintCudaVec6d_projectResponseIndexed(size, indices, dx); + LinearMovementProjectiveConstraintCudaVec6d_projectResponseIndexed(size, indices, dx); } static void projectPosition(unsigned size, const void* indices, const void* dir, const void* x0, void* x) { - LinearMovementConstraintCudaVec6d_projectPositionIndexed(size, indices, dir, x0, x); + LinearMovementProjectiveConstraintCudaVec6d_projectPositionIndexed(size, indices, dir, x0, x); } static void projectVelocity(unsigned size, const void* indices, const void* dir, void* dx) { - LinearMovementConstraintCudaVec6d_projectVelocityIndexed(size, indices, dir, dx); + LinearMovementProjectiveConstraintCudaVec6d_projectVelocityIndexed(size, indices, dir, dx); } -};// CudaKernelsLinearMovementConstraint +};// CudaKernelsLinearMovementProjectiveConstraint template<> -class CudaKernelsLinearMovementConstraint< CudaRigid3dTypes > +class CudaKernelsLinearMovementProjectiveConstraint< CudaRigid3dTypes > { public: static void projectResponse(unsigned size, const void* indices, void* dx) { - LinearMovementConstraintCudaRigid3d_projectResponseIndexed(size, indices, dx); + LinearMovementProjectiveConstraintCudaRigid3d_projectResponseIndexed(size, indices, dx); } static void projectPosition(unsigned size, const void* indices, const void* dir, const void* x0, void* x) { - LinearMovementConstraintCudaRigid3d_projectPositionIndexed(size, indices, dir, x0, x); + LinearMovementProjectiveConstraintCudaRigid3d_projectPositionIndexed(size, indices, dir, x0, x); } static void projectVelocity(unsigned size, const void* indices, const void* dir, void* dx) { - LinearMovementConstraintCudaRigid3d_projectVelocityIndexed(size, indices, dir, dx); + LinearMovementProjectiveConstraintCudaRigid3d_projectVelocityIndexed(size, indices, dir, dx); } -};// CudaKernelsLinearMovementConstraint +};// CudaKernelsLinearMovementProjectiveConstraint #endif // SOFA_GPU_CUDA_DOUBLE @@ -133,7 +133,7 @@ namespace sofa::component::constraint::projective // CudaVectorTypes specializations ///////////////////////////////////// template -void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes >::addIndex(Main* m, Index index) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::addIndex(Main* m, Index index) { Data& data = *m->data; @@ -144,10 +144,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes >::removeIndex(Main* m, Index index) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::removeIndex(Main* m, Index index) { // Data& data = m->data; @@ -158,10 +158,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes >::init(Main* m, VecCoord& x) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::init(Main* m, VecCoord& x) { Data& data = *m->data; const SetIndexArray & indices = m->m_indices.getValue(); @@ -186,10 +186,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes >::projectResponse(Main* m, VecDeriv& dx) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::projectResponse(Main* m, VecDeriv& dx) { Data& data = *m->data; @@ -208,10 +208,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes >::projectPosition(Main* m, VecCoord& x) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::projectPosition(Main* m, VecCoord& x) { Data& data = *m->data; @@ -241,10 +241,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes >::projectVelocity(Main* m, VecDeriv& dx) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaVectorTypes >::projectVelocity(Main* m, VecDeriv& dx) { Data& data = *m->data; @@ -264,7 +264,7 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaVectorTypes -void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >::addIndex(Main* m, Index index) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::addIndex(Main* m, Index index) { Data& data = *m->data; @@ -283,10 +283,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: // TODO : then it becomes non-consistent and also in the main version !!! // data.x0.push_back(); -}// LinearMovementConstraintInternalData::addIndex +}// LinearMovementProjectiveConstraintInternalData::addIndex template -void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >::removeIndex(Main* m, Index index) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::removeIndex(Main* m, Index index) { // Data& data = m->data; @@ -297,10 +297,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: // TODO : then it becomes non-consistent and also in the main version !!! // data.x0.push_back(); -}// LinearMovementConstraintInternalData::removeIndex +}// LinearMovementProjectiveConstraintInternalData::removeIndex template -void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >::init(Main* m, VecCoord& x) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::init(Main* m, VecCoord& x) { Data& data = *m->data; const SetIndexArray & indices = m->m_indices.getValue(); @@ -325,10 +325,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: data.x0[index] = x[*it]; index++; } -}// LinearMovementConstraintInternalData::init +}// LinearMovementProjectiveConstraintInternalData::init template -void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >::projectResponse(Main* m, VecDeriv& dx) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::projectResponse(Main* m, VecDeriv& dx) { Data& data = *m->data; @@ -347,10 +347,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: dx.deviceWrite() ); } -}// LinearMovementConstraintInternalData::projectResponse +}// LinearMovementProjectiveConstraintInternalData::projectResponse template -void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >::projectPosition(Main* m, VecCoord& x) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::projectPosition(Main* m, VecCoord& x) { Data& data = *m->data; @@ -380,10 +380,10 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: x.deviceWrite() ); } -}// LinearMovementConstraintInternalData::projectPosition +}// LinearMovementProjectiveConstraintInternalData::projectPosition template -void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >::projectVelocity(Main* m, VecDeriv& dx) +void LinearMovementProjectiveConstraintInternalData< gpu::cuda::CudaRigidTypes >::projectVelocity(Main* m, VecDeriv& dx) { Data& data = *m->data; @@ -403,7 +403,7 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: dx.deviceWrite() ); } -}// LinearMovementConstraintInternalData::projectVelocity +}// LinearMovementProjectiveConstraintInternalData::projectVelocity ////////////////////////////// @@ -411,25 +411,25 @@ void LinearMovementConstraintInternalData< gpu::cuda::CudaRigidTypes >: ///////////////////////////// // template<> -// void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::init() +// void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::init() // { // data.init(this); // } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::addIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::addIndex(Index index) { data->addIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::removeIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::removeIndex(Index index) { data->removeIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectResponse(this, _dx); @@ -437,13 +437,13 @@ void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectResponse(cons } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) { /* data.projectResponseT(this, index); */ } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) { VecCoord& _x = *x.beginEdit(); data->projectPosition(this, _x); @@ -451,7 +451,7 @@ void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectPosition(cons } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6fTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectVelocity(this, _dx); @@ -459,19 +459,19 @@ void LinearMovementConstraint< gpu::cuda::CudaVec6fTypes >::projectVelocity(cons } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::addIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::addIndex(Index index) { data->addIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::removeIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::removeIndex(Index index) { data->removeIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectResponse(this, _dx); @@ -479,13 +479,13 @@ void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectResponse(co } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) { /* data.projectResponseT(this, index); */ } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) { VecCoord& _x = *x.beginEdit(); data->projectPosition(this, _x); @@ -493,7 +493,7 @@ void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectPosition(co } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3fTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectVelocity(this, _dx); @@ -502,25 +502,25 @@ void LinearMovementConstraint< gpu::cuda::CudaRigid3fTypes >::projectVelocity(co #ifdef SOFA_GPU_CUDA_DOUBLE // template<> -// void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::init() +// void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::init() // { // data->init(this); // } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::addIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::addIndex(Index index) { data->addIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::removeIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::removeIndex(Index index) { data->removeIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectResponse(this, _dx); @@ -528,13 +528,13 @@ void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectResponse(cons } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) { /* data.projectResponseT(this, index); */ } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) { VecCoord& _x = *x.beginEdit(); data->projectPosition(this, _x); @@ -542,7 +542,7 @@ void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectPosition(cons } template<> -void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaVec6dTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectVelocity(this, _dx); @@ -550,19 +550,19 @@ void LinearMovementConstraint< gpu::cuda::CudaVec6dTypes >::projectVelocity(cons } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::addIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::addIndex(Index index) { data->addIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::removeIndex(Index index) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::removeIndex(Index index) { data->removeIndex(this, index); } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectResponse(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectResponse(this, _dx); @@ -570,13 +570,13 @@ void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectResponse(co } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectJacobianMatrix(const core::MechanicalParams* /* mparams */, DataMatrixDeriv& /*dx*/) { /* data.projectResponseT(this, index); */ } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectPosition(const core::MechanicalParams* /* mparams */, DataVecCoord& x) { VecCoord& _x = *x.beginEdit(); data->projectPosition(this, _x); @@ -584,7 +584,7 @@ void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectPosition(co } template<> -void LinearMovementConstraint< gpu::cuda::CudaRigid3dTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) +void LinearMovementProjectiveConstraint< gpu::cuda::CudaRigid3dTypes >::projectVelocity(const core::MechanicalParams* /* mparams */, DataVecDeriv& dx) { VecDeriv& _dx = *dx.beginEdit(); data->projectVelocity(this, _dx); diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearVelocityConstraint.cpp b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearVelocityProjectiveConstraint.cpp similarity index 75% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearVelocityConstraint.cpp rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearVelocityProjectiveConstraint.cpp index 57c4996f06d..c720af9db74 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearVelocityConstraint.cpp +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearVelocityProjectiveConstraint.cpp @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include -#include +#include #include @@ -28,11 +28,11 @@ namespace sofa::component::constraint::projective { -template class SOFA_GPU_CUDA_API LinearVelocityConstraint; -template class SOFA_GPU_CUDA_API LinearVelocityConstraint; +template class SOFA_GPU_CUDA_API LinearVelocityProjectiveConstraint; +template class SOFA_GPU_CUDA_API LinearVelocityProjectiveConstraint; #ifdef SOFA_GPU_CUDA_DOUBLE -template class SOFA_GPU_CUDA_API LinearVelocityConstraint; -template class SOFA_GPU_CUDA_API LinearVelocityConstraint; +template class SOFA_GPU_CUDA_API LinearVelocityProjectiveConstraint; +template class SOFA_GPU_CUDA_API LinearVelocityProjectiveConstraint; #endif // SOFA_GPU_CUDA_DOUBLE }// namespace sofa::component::constraint::projective @@ -40,12 +40,12 @@ template class SOFA_GPU_CUDA_API LinearVelocityConstraint >() - .add< sofa::component::constraint::projective::LinearVelocityConstraint >() +int LinearVelocityProjectiveConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") + .add< sofa::component::constraint::projective::LinearVelocityProjectiveConstraint >() + .add< sofa::component::constraint::projective::LinearVelocityProjectiveConstraint >() #ifdef SOFA_GPU_CUDA_DOUBLE - .add< sofa::component::constraint::projective::LinearVelocityConstraint >() - .add< sofa::component::constraint::projective::LinearVelocityConstraint >() + .add< sofa::component::constraint::projective::LinearVelocityProjectiveConstraint >() + .add< sofa::component::constraint::projective::LinearVelocityProjectiveConstraint >() #endif // SOFA_GPU_CUDA_DOUBLE ; From 5252432c530c892a0390ca844010b053c6d1c7f7 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 21 Nov 2023 17:00:29 +0100 Subject: [PATCH 03/28] Modify rest of the code to avoid warning from compatibility layer --- .../response/contact/FrictionContact.h | 4 ++-- .../response/contact/FrictionContact.inl | 2 +- .../response/contact/StickContactConstraint.h | 4 ++-- .../contact/StickContactConstraint.inl | 2 +- .../BilateralInteractionConstraint.h | 4 ++-- .../model/SlidingLagrangianConstraint.inl | 4 ++-- .../projective/FixedProjectiveConstraint.h | 2 +- .../tests/SquareDistanceMapping_test.cpp | 2 +- .../odesolver/backward/StaticSolver.cpp | 4 ++-- .../tests/EulerImplicitSolverStatic_test.cpp | 2 +- .../Backward/tests/StaticSolver_test.cpp | 2 +- .../odesolver/forward/EulerSolver.cpp | 4 ++-- .../component/odesolver/forward/EulerSolver.h | 2 +- .../testing/MassSpringSystemCreation.h | 2 +- .../Elastic/tests/BeamFEMForceField_test.cpp | 2 +- .../tests/TetrahedronFEMForceField_test.cpp | 2 +- .../tests/TriangleFEMForceField_test.cpp | 2 +- .../performer/ConstraintAttachBodyPerformer.h | 6 ++--- .../ConstraintAttachBodyPerformer.inl | 6 ++--- .../performer/FixParticlePerformer.inl | 2 +- .../plugins/SofaAssimp/SceneColladaLoader.cpp | 16 +++++++------- .../plugins/SofaAssimp/SceneColladaLoader.h | 4 ++-- .../plugins/SofaTest/Elasticity_test.h | 4 ++-- .../plugins/SofaTest/Elasticity_test.inl | 22 +++++++++---------- .../plugins/SofaTest/InitPlugin_test.h | 2 +- 25 files changed, 54 insertions(+), 54 deletions(-) diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h index abfe6878d00..3e71d5e0a69 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -60,7 +60,7 @@ class FrictionContact : public core::collision::Contact, public ContactIdentifie mapper::ContactMapper mapper1; mapper::ContactMapper mapper2; - constraint::lagrangian::model::UnilateralInteractionConstraint::SPtr m_constraint; + constraint::lagrangian::model::UnilateralInteractionLagrangianConstraint::SPtr m_constraint; core::objectmodel::BaseContext* parent; Data mu; ///< friction coefficient (0 for frictionless contacts) diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl index d753e9ed690..6da62dd345b 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl @@ -144,7 +144,7 @@ void FrictionContact::activ { mmodel2 = mapper2.createMapping(getName().c_str()); } - m_constraint = sofa::core::objectmodel::New >(mmodel1, mmodel2); + m_constraint = sofa::core::objectmodel::New >(mmodel1, mmodel2); m_constraint->setName( getName() ); setInteractionTags(mmodel1, mmodel2); m_constraint->setCustomTolerance( tol.getValue() ); diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h index f612ad49d70..381a414bdcc 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ class StickContactConstraint : public core::collision::Contact, public ContactId mapper::ContactMapper mapper1; mapper::ContactMapper mapper2; - constraint::lagrangian::model::BilateralInteractionConstraint::SPtr m_constraint; + constraint::lagrangian::model::BilateralInteractionLagrangianConstraint::SPtr m_constraint; core::objectmodel::BaseContext* parent; std::vector< sofa::core::collision::DetectionOutput* > contacts; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl index f3af1c76aca..307053696ff 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl @@ -128,7 +128,7 @@ void StickContactConstraint::activateMappers( msg_info() << "Creating StickContactConstraint bilateral constraints"; MechanicalState1* mstate1 = mapper1.createMapping(mapper::GenerateStringID::generate().c_str()); MechanicalState2* mstate2 = mapper2.createMapping(mapper::GenerateStringID::generate().c_str()); - m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); + m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); m_constraint->setName( getName() ); } diff --git a/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h b/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h index dee006cf153..1751b2dbd22 100644 --- a/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h +++ b/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h") +SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl index 3581c3dc7a6..959515f874a 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl @@ -22,8 +22,8 @@ #pragma once #include #include -#include -#include +#include +#include #include #include namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h index 81bd14265a7..f69cd6a1029 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h @@ -47,7 +47,7 @@ class FixedProjectiveConstraintInternalData /** Maintain a constant velocity. * If the particle is initially fixed then it is attached to its initial position. * Otherwise it keeps on drifting. - * For maintaining particles fixed in any case, @sa ProjectToPointConstraint + * For maintaining particles fixed in any case, @sa ProjectToPointProjectiveConstraint */ template class FixedProjectiveConstraint : public core::behavior::ProjectiveConstraintSet diff --git a/Sofa/Component/Mapping/NonLinear/tests/SquareDistanceMapping_test.cpp b/Sofa/Component/Mapping/NonLinear/tests/SquareDistanceMapping_test.cpp index cf5d2724d67..8472a6f1a3c 100644 --- a/Sofa/Component/Mapping/NonLinear/tests/SquareDistanceMapping_test.cpp +++ b/Sofa/Component/Mapping/NonLinear/tests/SquareDistanceMapping_test.cpp @@ -168,7 +168,7 @@ struct SquareDistanceMappingCompare_test : NumericTest {{"position", "@../loader.position"}, {"edges", "@../loader.edges"}, {"name", "topology"}}); simpleapi::createObject(node, "MechanicalObject", {{"name", "defoDOF"}, {"template", "Vec3"}}); simpleapi::createObject(node, "EdgeSetGeometryAlgorithms"); - simpleapi::createObject(node, "FixedConstraint", {{"indices", "0"}}); + simpleapi::createObject(node, "FixedProjectiveConstraint", {{"indices", "0"}}); simpleapi::createObject(node, "DiagonalMass", {{"totalMass", "1e-2"}}); } diff --git a/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/StaticSolver.cpp b/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/StaticSolver.cpp index 04679365b1a..e999ad4621f 100644 --- a/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/StaticSolver.cpp +++ b/Sofa/Component/ODESolver/Backward/src/sofa/component/odesolver/backward/StaticSolver.cpp @@ -174,7 +174,7 @@ void StaticSolver::solve(const sofa::core::ExecParams* params, SReal dt, sofa::c // Step 2 Projective constraints // Calls the "projectResponse" method of every BaseProjectiveConstraintSet objects found in the - // current context tree. An example of such constraint set is the FixedConstraint. In this case, + // current context tree. An example of such constraint set is the FixedProjectiveConstraint. In this case, // it will set to 0 every row (i, _) of the right-hand side (force) vector for the ith degree of // freedom. mop.projectResponse(force); @@ -218,7 +218,7 @@ void StaticSolver::solve(const sofa::core::ExecParams* params, SReal dt, sofa::c // B. For LinearSolver using other type of matrices (FullMatrix, SparseMatrix, CompressedRowSparseMatrix), // the "addMBKToMatrix" method is called on each BaseForceField objects and the "applyConstraint" method // is called on every BaseProjectiveConstraintSet objects. An example of such constraint set is the - // FixedConstraint. In this case, it will set to 0 every column (_, i) and row (i, _) of the assembled + // FixedProjectiveConstraint. In this case, it will set to 0 every column (_, i) and row (i, _) of the assembled // matrix for the ith degree of freedom. matrix.setSystemMBKMatrix(MechanicalMatrix::K * -1.0); } diff --git a/Sofa/Component/ODESolver/Backward/tests/EulerImplicitSolverStatic_test.cpp b/Sofa/Component/ODESolver/Backward/tests/EulerImplicitSolverStatic_test.cpp index 226deeb18ca..6e35c3245b1 100644 --- a/Sofa/Component/ODESolver/Backward/tests/EulerImplicitSolverStatic_test.cpp +++ b/Sofa/Component/ODESolver/Backward/tests/EulerImplicitSolverStatic_test.cpp @@ -131,7 +131,7 @@ struct EulerImplicit_test_2_particles_to_equilibrium : public BaseSimulationTest 0.1 // damping ratio ); - simpleapi::createObject(string, "FixedConstraint", { + simpleapi::createObject(string, "FixedProjectiveConstraint", { { "indices", "0"} }); diff --git a/Sofa/Component/ODESolver/Backward/tests/StaticSolver_test.cpp b/Sofa/Component/ODESolver/Backward/tests/StaticSolver_test.cpp index 512f0f2a4fe..b13f1a66af3 100644 --- a/Sofa/Component/ODESolver/Backward/tests/StaticSolver_test.cpp +++ b/Sofa/Component/ODESolver/Backward/tests/StaticSolver_test.cpp @@ -71,7 +71,7 @@ class StaticSolverTest : public sofa::testing::BaseTest }); createObject(root, "BoxROI", {{"name", "top_roi"}, {"box", "-7.5 -7.5 -0.9 7.5 7.5 0.1"}}); - createObject(root, "FixedConstraint", {{"indices", "@top_roi.indices"}}); + createObject(root, "FixedProjectiveConstraint", {{"indices", "@top_roi.indices"}}); createObject(root, "BoxROI", {{"name", "base_roi"}, {"box", "-7.5 -7.5 79.9 7.5 7.5 80.1"}}); createObject(root, "SurfacePressureForceField", {{"pressure", "100"}, {"mainDirection", "0 -1 0"}, {"triangleIndices", "@base_roi.trianglesInROI"}}); diff --git a/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerSolver.cpp b/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerSolver.cpp index 59a9e6d7f90..40f671c2032 100644 --- a/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerSolver.cpp +++ b/Sofa/Component/ODESolver/Forward/src/sofa/component/odesolver/forward/EulerSolver.cpp @@ -297,7 +297,7 @@ void EulerExplicitSolver::projectResponse(sofa::simulation::common::MechanicalOp SCOPED_TIMER("projectResponse"); // Calls the "projectResponse" method of every BaseProjectiveConstraintSet objects found in the - // current context tree. An example of such constraint set is the FixedConstraint. In this case, + // current context tree. An example of such constraint set is the FixedProjectiveConstraint. In this case, // it will set to 0 every row (i, _) of the input vector for the ith degree of freedom. mop->projectResponse(vecId); } @@ -326,7 +326,7 @@ void EulerExplicitSolver::assembleSystemMatrix(core::behavior::MultiMatrix #include #include -#include +#include #include @@ -57,7 +57,7 @@ class ConstraintAttachBodyPerformer: public TInteractionPerformer typedef typename DataTypes::VecCoord VecCoord; typedef sofa::component::collision::response::mapper::BaseContactMapper< DataTypes > MouseContactMapper; typedef sofa::core::behavior::MechanicalState< DataTypes > MouseContainer; -// typedef sofa::component::constraint::lagrangian::model::BilateralInteractionConstraint< DataTypes > MouseConstraint; +// typedef sofa::component::constraint::lagrangian::model::BilateralInteractionLagrangianConstraint< DataTypes > MouseConstraint; // typedef sofa::core::behavior::BaseForceField MouseForceField; @@ -91,7 +91,7 @@ class ConstraintAttachBodyPerformer: public TInteractionPerformer virtual bool start_partial(const BodyPicked& picked); MouseContactMapper *mapper; - sofa::component::constraint::lagrangian::model::BilateralInteractionConstraint::SPtr m_constraint; + sofa::component::constraint::lagrangian::model::BilateralInteractionLagrangianConstraint::SPtr m_constraint; core::visual::DisplayFlags flags; diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl b/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl index 1c42a3fbdae..bce589b32d1 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl @@ -172,10 +172,10 @@ bool ConstraintAttachBodyPerformer::start_partial(const BodyPicked& p type::Vec3d point1; type::Vec3d point2; - using sofa::component::constraint::lagrangian::model::BilateralInteractionConstraint; + using sofa::component::constraint::lagrangian::model::BilateralInteractionLagrangianConstraint; - m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); - BilateralInteractionConstraint< DataTypes >* bconstraint = static_cast< BilateralInteractionConstraint< sofa::defaulttype::Vec3Types >* >(m_constraint.get()); + m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); + BilateralInteractionLagrangianConstraint< DataTypes >* bconstraint = static_cast< BilateralInteractionLagrangianConstraint< sofa::defaulttype::Vec3Types >* >(m_constraint.get()); bconstraint->setName("Constraint-Mouse-Contact"); type::Vec3d normal = point1-point2; diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl b/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl index 8cec4715378..a52c148ef2f 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/FixParticlePerformer.inl @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/applications/plugins/SofaAssimp/SceneColladaLoader.cpp b/applications/plugins/SofaAssimp/SceneColladaLoader.cpp index c13aae99da0..2021ecae599 100644 --- a/applications/plugins/SofaAssimp/SceneColladaLoader.cpp +++ b/applications/plugins/SofaAssimp/SceneColladaLoader.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -331,18 +331,18 @@ bool SceneColladaLoader::readDAE (std::ifstream &/*file*/, const char* /*filenam } } - // generating a SkeletalMotionConstraint and filling up its properties - SkeletalMotionConstraint::SPtr currentSkeletalMotionConstraint = sofa::core::objectmodel::New >(); + // generating a SkeletalMotionProjectiveConstraint and filling up its properties + SkeletalMotionProjectiveConstraint::SPtr currentSkeletalMotionProjectiveConstraint = sofa::core::objectmodel::New >(); { - // adding the generated SkeletalMotionConstraint to its parent Node - currentSubNode->addObject(currentSkeletalMotionConstraint); + // adding the generated SkeletalMotionProjectiveConstraint to its parent Node + currentSubNode->addObject(currentSkeletalMotionProjectiveConstraint); std::stringstream nameStream(meshName); if(meshName.empty()) nameStream << componentIndex++; - currentSkeletalMotionConstraint->setName(nameStream.str()); + currentSkeletalMotionProjectiveConstraint->setName(nameStream.str()); - currentSkeletalMotionConstraint->setAnimationSpeed(animationSpeed.getValue()); + currentSkeletalMotionProjectiveConstraint->setAnimationSpeed(animationSpeed.getValue()); aiNode* parentAiNode = NULL; if(parentNodeInfo) @@ -351,7 +351,7 @@ bool SceneColladaLoader::readDAE (std::ifstream &/*file*/, const char* /*filenam type::vector > skeletonJoints; type::vector skeletonBones; fillSkeletalInfo(currentAiScene, parentAiNode, currentAiNode, currentTransformation, currentAiMesh, skeletonJoints, skeletonBones); - currentSkeletalMotionConstraint->setSkeletalMotion(skeletonJoints, skeletonBones); + currentSkeletalMotionProjectiveConstraint->setSkeletalMotion(skeletonJoints, skeletonBones); } } else diff --git a/applications/plugins/SofaAssimp/SceneColladaLoader.h b/applications/plugins/SofaAssimp/SceneColladaLoader.h index 117a5ae5f6f..869e8519399 100644 --- a/applications/plugins/SofaAssimp/SceneColladaLoader.h +++ b/applications/plugins/SofaAssimp/SceneColladaLoader.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include // C++ importer interface #include // Output data structure @@ -130,7 +130,7 @@ class SOFA_ASSIMP_API SceneColladaLoader : public sofa::core::loader::SceneLoade private: - // build the joints and bones array used in the SkeletalMotionConstraint + // build the joints and bones array used in the SkeletalMotionProjectiveConstraint bool fillSkeletalInfo(const aiScene* scene, aiNode* meshParentNode, aiNode* meshNode, aiMatrix4x4 meshTransformation, aiMesh* mesh, type::vector >& skeletonJoints, type::vector& skeletonBones) const; // clean the scene graph of its empty and useless intermediary nodes diff --git a/applications/plugins/SofaTest/Elasticity_test.h b/applications/plugins/SofaTest/Elasticity_test.h index fbe0c742828..1dd3d658302 100644 --- a/applications/plugins/SofaTest/Elasticity_test.h +++ b/applications/plugins/SofaTest/Elasticity_test.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include namespace sofa { @@ -41,7 +41,7 @@ template struct PatchTestStruct { simulation::Node::SPtr SquareNode; - typename component::constraint::projective::AffineMovementConstraint::SPtr affineConstraint; + typename component::constraint::projective::AffineMovementProjectiveConstraint::SPtr affineConstraint; typename component::statecontainer::MechanicalObject::SPtr dofs; }; diff --git a/applications/plugins/SofaTest/Elasticity_test.inl b/applications/plugins/SofaTest/Elasticity_test.inl index f32feeac540..8d7bcc5048b 100644 --- a/applications/plugins/SofaTest/Elasticity_test.inl +++ b/applications/plugins/SofaTest/Elasticity_test.inl @@ -36,10 +36,10 @@ // Constraint -#include +#include #include -#include -#include +#include +#include // ForceField #include @@ -98,7 +98,7 @@ Elasticity_test::createRegularGridScene( typedef component::topology::container::grid::RegularGridTopology RegularGridTopology; typedef typename component::engine::select::BoxROI BoxRoi; typedef typename sofa::component::engine::select::PairBoxROI PairBoxRoi; - typedef typename sofa::component::constraint::projective::AffineMovementConstraint AffineMovementConstraint; + typedef typename sofa::component::constraint::projective::AffineMovementProjectiveConstraint AffineMovementProjectiveConstraint; typedef component::linearsolver::iterative::CGLinearSolver CGLinearSolver; // Root node @@ -144,7 +144,7 @@ Elasticity_test::createRegularGridScene( pairBoxRoi->includedBox.setValue(includedBox); //Affine constraint - patchStruct.affineConstraint = modeling::addNew(SquareNode,"affineConstraint"); + patchStruct.affineConstraint = modeling::addNew(SquareNode,"affineConstraint"); modeling::setDataLink(&boxRoi->d_indices,&patchStruct.affineConstraint->m_meshIndices); modeling::setDataLink(&pairBoxRoi->f_indices,& patchStruct.affineConstraint->m_indices); @@ -223,9 +223,9 @@ CylinderTractionStruct Elasticity_test::createCylinderTra typename component::constraint::projective::FixedConstraint::SPtr fc= modeling::addNew >(root); sofa::modeling::setDataLink(&boxRoi1->d_indices,&fc->d_indices); - // FixedPlaneConstraint - typename component::constraint::projective::FixedPlaneConstraint::SPtr fpc= - modeling::addNew >(root); + // FixedPlaneProjectiveConstraint + typename component::constraint::projective::FixedPlaneProjectiveConstraint::SPtr fpc= + modeling::addNew >(root); fpc->d_dmin= -0.01; fpc->d_dmax= 0.01; fpc->d_direction=Coord(0,0,1); @@ -241,9 +241,9 @@ CylinderTractionStruct Elasticity_test::createCylinderTra modeling::addNew >(root); tractionStruct.forceField=tpff; sofa::modeling::setDataLink(&boxRoi2->d_triangleIndices,&tpff->triangleList); - // ProjectToLineConstraint - typename component::constraint::projective::ProjectToLineConstraint::SPtr ptlc= - modeling::addNew >(root); + // ProjectToLineProjectiveConstraint + typename component::constraint::projective::ProjectToLineProjectiveConstraint::SPtr ptlc= + modeling::addNew >(root); ptlc->f_direction=Coord(1,0,0); ptlc->f_origin=Coord(0,0,0); sofa::type::vector vArray; diff --git a/applications/plugins/SofaTest/InitPlugin_test.h b/applications/plugins/SofaTest/InitPlugin_test.h index f79c0bdeb81..8594c83953a 100644 --- a/applications/plugins/SofaTest/InitPlugin_test.h +++ b/applications/plugins/SofaTest/InitPlugin_test.h @@ -95,7 +95,7 @@ Other solver tests are available in Compliant_test: AssembledSolver_test and Dam -if constrained particle have the expected position. -if unconstrained particle have not changed. -Some projective constraint tests are available in SofaTest_test: ProjectToLineConstraint and ProjectToPlaneConstraint. +Some projective constraint tests are available in SofaTest_test: ProjectToLineProjectiveConstraint and ProjectToPlaneConstraint. - Engine test: To test engine you set input values and check if the ouput values correspond to the expected ones. The test Engine_test tests if the update method is called only if necessary. To test this a minimal engine TestEngine was created with a counter in its update method. From c315181ceec28f6d3d0b7734b0df8d0b0d9b65dc Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 21 Nov 2023 17:17:45 +0100 Subject: [PATCH 04/28] Add compatibility layer for deprecated header in CUDA --- .../projective/CudaFixedConstraint.h | 26 +++++++++++++++++++ .../projective/CudaFixedConstraint.inl | 26 +++++++++++++++++++ .../CudaFixedProjectiveConstraint.h | 1 + .../projective/CudaLinearMovementConstraint.h | 26 +++++++++++++++++++ .../CudaLinearMovementConstraint.inl | 26 +++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h create mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl create mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h create mode 100644 applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h new file mode 100644 index 00000000000..f92c6941f62 --- /dev/null +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.h @@ -0,0 +1,26 @@ +/****************************************************************************** +* 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 + +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h") diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl new file mode 100644 index 00000000000..95ad8d25985 --- /dev/null +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedConstraint.inl @@ -0,0 +1,26 @@ +/****************************************************************************** +* 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 + +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.inl") diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h index aebbdb87fe4..1c4d1bf8b08 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaFixedProjectiveConstraint.h @@ -108,4 +108,5 @@ CudaFixedProjectiveConstraint_DeclMethods(gpu::cuda::CudaRigid3dTypes); #undef CudaFixedProjectiveConstraint_DeclMethods + } // namespace sofa::component::constraint::projective diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h new file mode 100644 index 00000000000..a5251686676 --- /dev/null +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.h @@ -0,0 +1,26 @@ +/****************************************************************************** +* 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 + +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.h") diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl new file mode 100644 index 00000000000..1771a40013b --- /dev/null +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/projective/CudaLinearMovementConstraint.inl @@ -0,0 +1,26 @@ +/****************************************************************************** +* 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 + +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "SofaCUDA/component/constraint/projective/CudaLinearMovementProjectiveConstraint.inl") From 39b00dd296ba2b5ce3a29de9c33a6a8f9989c5d5 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 21 Nov 2023 17:18:18 +0100 Subject: [PATCH 05/28] add alias for compatibility layer in scene construction --- .../projective/AffineMovementProjectiveConstraint.cpp | 1 + .../constraint/projective/AttachProjectiveConstraint.cpp | 1 + .../constraint/projective/FixedPlaneProjectiveConstraint.cpp | 1 + .../constraint/projective/FixedProjectiveConstraint.cpp | 2 +- .../projective/FixedRotationProjectiveConstraint.cpp | 2 ++ .../projective/FixedTranslationProjectiveConstraint.cpp | 4 ++-- .../projective/HermiteSplineProjectiveConstraint.cpp | 1 + .../projective/LinearMovementProjectiveConstraint.cpp | 4 +++- .../projective/LinearVelocityProjectiveConstraint.cpp | 2 +- .../constraint/projective/OscillatorProjectiveConstraint.cpp | 4 +++- .../constraint/projective/ParabolicProjectiveConstraint.cpp | 4 +++- .../projective/PartialFixedProjectiveConstraint.cpp | 1 + .../projective/PartialLinearMovementProjectiveConstraint.cpp | 1 + .../projective/PatchTestMovementProjectiveConstraint.cpp | 2 +- .../projective/PositionBasedDynamicsProjectiveConstraint.cpp | 2 +- .../projective/ProjectDirectionProjectiveConstraint.cpp | 2 +- .../projective/ProjectToLineProjectiveConstraint.cpp | 2 +- .../projective/ProjectToPlaneProjectiveConstraint.cpp | 2 +- .../projective/ProjectToPointProjectiveConstraint.cpp | 2 +- .../projective/SkeletalMotionProjectiveConstraint.cpp | 2 +- 20 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp index a34416970dc..1e4887d01e4 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp @@ -34,6 +34,7 @@ namespace sofa::component::constraint::projective int AffineMovementProjectiveConstraintRegister = core::RegisterObject("Constraint the movement by a rigid transform.") .add< AffineMovementProjectiveConstraint >() .add< AffineMovementProjectiveConstraint >() + .addAlias("AffineMovementConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp index 2c2683c9d1c..a4b0cf94002 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp @@ -36,6 +36,7 @@ int AttachProjectiveConstraintClass = core::RegisterObject("Attach given pair of .add< AttachProjectiveConstraint >() .add< AttachProjectiveConstraint >() .add< AttachProjectiveConstraint >() + .addAlias("AttachConstraint") ; template <> SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp index ab9c9e49cc6..14dd5857dad 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp @@ -36,6 +36,7 @@ int FixedPlaneProjectiveConstraintClass = core::RegisterObject("Project particle .add< FixedPlaneProjectiveConstraint >() .add< FixedPlaneProjectiveConstraint >() .add< FixedPlaneProjectiveConstraint >() + .addAlias("FixedPlaneConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp index 97cbfce8ba6..15aeffb660c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp @@ -39,7 +39,7 @@ int FixedProjectiveConstraintClass = core::RegisterObject("Attach given particle .add< FixedProjectiveConstraint >() .add< FixedProjectiveConstraint >() .add< FixedProjectiveConstraint >() - + .addAlias("FixedConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp index 0ce596ae483..1844831172d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp @@ -33,6 +33,8 @@ using namespace sofa::defaulttype; int FixedRotationProjectiveConstraintClass = core::RegisterObject("Prevents rotation around x or/and y or/and z axis") .add< FixedRotationProjectiveConstraint >() + .addAlias("FixedRotationConstraint") + ; template class FixedRotationProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp index 2d25df55ec8..0336e9a6f8d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp @@ -35,8 +35,8 @@ int FixedTranslationProjectiveConstraintClass = core::RegisterObject("Attach giv .add< FixedTranslationProjectiveConstraint >() .add< FixedTranslationProjectiveConstraint >() .add< FixedTranslationProjectiveConstraint >() - - ; + .addAlias("FixedTranslationConstraint") + ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp index aa10b586bf7..6dd49852e21 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp @@ -31,6 +31,7 @@ namespace sofa::component::constraint::projective int HermiteSplineProjectiveConstraintClass = core::RegisterObject("Apply a hermite cubic spline trajectory to given points") .add< HermiteSplineProjectiveConstraint >() .add< HermiteSplineProjectiveConstraint >() + .addAlias("HermiteSplineConstraint") ; template <> diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp index 0b528b78105..7feda4bdfb7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp @@ -47,7 +47,9 @@ int LinearMovementProjectiveConstraintClass = core::RegisterObject("translate gi .add< LinearMovementProjectiveConstraint >() .add< LinearMovementProjectiveConstraint >() .add< LinearMovementProjectiveConstraint >() - .add< LinearMovementProjectiveConstraint >(); + .add< LinearMovementProjectiveConstraint >() + .addAlias("LinearMovementConstraint") + ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp index a8baf97606b..fa21e76c8ae 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp @@ -38,7 +38,7 @@ int LinearVelocityProjectiveConstraintClass = core::RegisterObject("apply veloci .add< LinearVelocityProjectiveConstraint >() .add< LinearVelocityProjectiveConstraint >() .add< LinearVelocityProjectiveConstraint >() - + .addAlias("LinearVelocityConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp index dc805487a32..9b5d0b9e3c3 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp @@ -33,7 +33,9 @@ using namespace sofa::helper; int OscillatorProjectiveConstraintClass = core::RegisterObject("Apply a sinusoidal trajectory to given points") .add< OscillatorProjectiveConstraint >() - .add< OscillatorProjectiveConstraint >(); + .add< OscillatorProjectiveConstraint >() + .addAlias("OscillatorConstraint") + ; template class OscillatorProjectiveConstraint; template class OscillatorProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp index a25f89e4a0a..76f60aa6ee6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp @@ -30,7 +30,9 @@ namespace sofa::component::constraint::projective int ParabolicProjectiveConstraintClass = core::RegisterObject("Apply a parabolic trajectory to given points") .add< ParabolicProjectiveConstraint >() - .add< ParabolicProjectiveConstraint >(); + .add< ParabolicProjectiveConstraint >() + .addAlias("ParabolicConstraint") + ; template class ParabolicProjectiveConstraint; template class ParabolicProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp index 3a070fbc4d3..663c048c8d2 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp @@ -38,6 +38,7 @@ int PartialFixedProjectiveConstraintClass = core::RegisterObject("Attach given p .add< PartialFixedProjectiveConstraint >() .add< PartialFixedProjectiveConstraint >() .add< PartialFixedProjectiveConstraint >() + .addAlias("PartialFixedConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp index 896e5bb385f..3cb3e883968 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp @@ -35,6 +35,7 @@ int PartialLinearMovementProjectiveConstraintClass = core::RegisterObject("trans .add< PartialLinearMovementProjectiveConstraint >() .add< PartialLinearMovementProjectiveConstraint >() .add< PartialLinearMovementProjectiveConstraint >() + .addAlias("PartialLinearMovementConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp index 0c97c873ff1..4206b03ac40 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp @@ -32,7 +32,7 @@ namespace sofa::component::constraint::projective int PatchTestMovementProjectiveConstraintClass = core::RegisterObject("bilinear constraint") .add< PatchTestMovementProjectiveConstraint >() .add< PatchTestMovementProjectiveConstraint >() - + .addAlias("PatchTestMovementConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp index d0b0c03a4f8..c8c2c4a7b77 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp @@ -42,7 +42,7 @@ int PositionBasedDynamicsProjectiveConstraintClass = core::RegisterObject("Posit .add< PositionBasedDynamicsProjectiveConstraint >() .add< PositionBasedDynamicsProjectiveConstraint >() .add< PositionBasedDynamicsProjectiveConstraint >() -//.add< PositionBasedDynamicsProjectiveConstraint >() + .addAlias("PositionBasedDynamicsConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp index 70d1e00b0a1..c4e4338641a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp @@ -35,7 +35,7 @@ using namespace sofa::helper; int ProjectDirectionProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") .add< ProjectDirectionProjectiveConstraint >() .add< ProjectDirectionProjectiveConstraint >() - + .addAlias("ProjectDirectionConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp index beaab2ce92d..1e9798e0fb7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp @@ -33,7 +33,7 @@ using namespace sofa::helper; int ProjectToLineProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") .add< ProjectToLineProjectiveConstraint >() .add< ProjectToLineProjectiveConstraint >() - + .addAlias("ProjectToLineConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp index 0ce7f0dccee..1b05c12c2a9 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp @@ -33,7 +33,7 @@ using namespace sofa::helper; int ProjectToPlaneProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") .add< ProjectToPlaneProjectiveConstraint >() .add< ProjectToPlaneProjectiveConstraint >() - + .addAlias("ProjectToPlaneConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp index b80f6bc0c80..77ee9547b59 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp @@ -37,7 +37,7 @@ int ProjectToPointProjectiveConstraintClass = core::RegisterObject("Project part .add< ProjectToPointProjectiveConstraint >() .add< ProjectToPointProjectiveConstraint >() .add< ProjectToPointProjectiveConstraint >() - + .addAlias("ProjectToPointConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp index 03b01bcb1ed..3fb3bf05de1 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp @@ -30,7 +30,7 @@ namespace sofa::component::constraint::projective //declaration of the class, for the factory int SkeletalMotionProjectiveConstraintClass = core::RegisterObject("animate a skeleton") .add< SkeletalMotionProjectiveConstraint >() - + .addAlias("SkeletalMotionConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionProjectiveConstraint; From 42fe9f667dfdf797e9fc2173aee51efd4a4a95eb Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 21 Nov 2023 17:19:08 +0100 Subject: [PATCH 06/28] Report name modification to all scenes --- .../BilateralInteractionConstraint.scn | 2 +- .../scenes/TetrahedronDiffusionFEMForceField.scn | 6 +++--- .../scenes/EulerImplicitSpringDynamicTest.xml | 4 ++-- ...rahedronHyperelasticityFEMForceField_base.scn | 4 ++-- ...rahedronHyperelasticityFEMForceField_test.scn | 4 ++-- .../example/MultiMapping.py | 2 +- .../plugins/Sensable/examples/Carving.scn | 2 +- .../Sensable/examples/Deformable-Method1.scn | 2 +- applications/plugins/SofaAssimp/doc/index.html | 4 ++-- .../plugins/SofaCarving/examples/CarvingTool.scn | 4 ++-- .../examples/ComplianceMatrixExporter.scn | 4 ++-- .../examples/ComplianceMatrixImage.scn | 4 ++-- .../SofaTest/SofaTest_test/scenes/damping.py | 4 ++-- .../Accuracy/TriangleFEMForceField_compare.scn | 8 ++++---- .../Accuracy/cylinder_PhantomSolution.scn | 4 ++-- .../Bar16-fem-implicit-CudaVec3f.pscn | 2 +- .../Performance/Bar16-fem-implicit-Vec3d.pscn | 4 ++-- .../Performance/Bar16-fem-implicit-Vec3f.pscn | 2 +- .../Performance/Bar16-spring-rk4-CudaVec3f.pscn | 2 +- .../Performance/Bar16-spring-rk4-Vec3d.pscn | 4 ++-- .../Performance/Bar16-spring-rk4-Vec3f.pscn | 2 +- .../MatrixAssembly_assembledCG.scn | 4 ++-- .../MatrixAssembly_assembledCG_blocs.scn | 4 ++-- .../MatrixAssembly/MatrixAssembly_direct.scn | 4 ++-- .../MatrixAssembly_direct_blocs.scn | 4 ++-- .../MatrixAssembly_matrixfreeCG.scn | 4 ++-- ...ffineMovementConstraint__RemovingMeshTest.scn | 4 ++-- .../FixedConstraint_RemovingMeshTest.scn | 4 ++-- .../FixedPlaneConstraint_RemovingMeshTest.scn | 4 ++-- ...LinearMovementConstraint_RemovingMeshTest.scn | 4 ++-- ...ojectDirectionConstraint_RemovingMeshTest.scn | 4 ++-- .../ProjectToLineConstraint_RemovingMeshTest.scn | 4 ++-- ...ProjectToPlaneConstraint_RemovingMeshTest.scn | 4 ++-- ...ProjectToPointConstraint_RemovingMeshTest.scn | 4 ++-- .../BilateralInteractionConstraint_NNCG.scn | 10 +++++----- .../BilateralInteractionConstraint_PGS.scn | 12 ++++++------ .../BilateralInteractionConstraint_Rigid.scn | 6 +++--- .../BilateralInteractionConstraint_UGS.scn | 12 ++++++------ .../Lagrangian/InextensiblePendulum.scn | 4 ++-- .../Constraint/Lagrangian/SlidingConstraint.scn | 6 +++--- .../Projective/AffineMovementConstraint.scn | 4 ++-- .../Projective/AffineMovementConstraint3D.scn | 4 ++-- .../Constraint/Projective/AttachConstraint.scn | 10 +++++----- .../Projective/AttachConstraintMatrix.scn | 10 +++++----- .../Constraint/Projective/BilinearConstraint.scn | 4 ++-- .../Projective/BilinearConstraint3D.scn | 4 ++-- .../Projective/FixedPlaneConstraint.scn | 4 ++-- .../Projective/FixedRotationConstraint.scn | 4 ++-- .../Projective/HermiteSplineConstraint.scn | 6 +++--- .../Projective/LinearMovementConstraint.scn | 8 ++++---- .../Projective/OscillatorConstraint.scn | 4 ++-- .../Projective/OscillatorConstraint_rigid.scn | 6 +++--- .../Projective/ParabolicConstraint.scn | 4 ++-- .../Projective/PartialFixedConstraint.scn | 4 ++-- .../Projective/PatchTestConstraint.scn | 4 ++-- .../Projective/ProjectDirectionConstraint.scn | 4 ++-- .../Projective/ProjectToLineConstraint.scn | 4 ++-- .../Projective/ProjectToPlaneConstraint.scn | 4 ++-- .../Projective/ProjectToPointConstraint.scn | 4 ++-- .../TetrahedronDiffusionFEMForceField.scn | 6 +++--- .../Component/Engine/Analyze/ShapeMatching.scn | 4 ++-- .../Engine/Generate/GenerateCylinder.scn | 6 +++--- .../Component/Engine/Generate/GenerateGrid.scn | 10 +++++----- examples/Component/Engine/Select/BoxROI.scn | 2 +- .../Engine/Select/MeshSplittingEngine.scn | 2 +- .../Component/Engine/Select/NearestPointROI.scn | 16 ++++++++-------- .../Component/Engine/Select/ProximityROI.scn | 2 +- examples/Component/Engine/Select/SphereROI.scn | 2 +- .../Component/Engine/Select/SubsetTopology.scn | 2 +- .../Select/SubsetTopology_withtetrahedra.scn | 4 ++-- .../Transform/DisplacementMatrixEngine.scn | 4 ++-- examples/Component/IO/Mesh/GIDMeshLoader.scn | 4 ++-- examples/Component/IO/Mesh/GridMeshCreator.scn | 2 +- .../Component/IO/Mesh/LiverUseNewLoaders.scn | 4 ++-- examples/Component/IO/Mesh/MeshGmshLoader.scn | 6 +++--- .../Mapping/NonLinear/RigidMapping-basic.scn | 4 ++-- .../Mapping/NonLinear/RigidMapping2d-basic.scn | 4 ++-- .../NonLinear/RigidRigidMapping-basic.scn | 4 ++-- examples/Component/Mass/DiagonalMass.scn | 4 ++-- examples/Component/Mass/MeshMatrixMass.scn | 4 ++-- examples/Component/Mass/UniformMass.scn | 4 ++-- .../InteractionEllipsoidForceField.scn | 4 ++-- .../TrianglePressureForceField.scn | 4 ++-- .../SolidMechanics/FEM/TopoMap_cylinder3d.scn | 4 ++-- .../Spring/angularSpringForceField.scn | 4 ++-- .../TetrahedralTensorMassForceField.scn | 4 ++-- .../RemovingBilateralInteractionConstraint.scn | 4 ++-- ...vingTetra2TriangleProcess_performanceTest.scn | 4 ++-- ...trahedronForceFieldTopologyChangeHandling.scn | 6 +++--- .../Mapping/Tetra2TriangleTopologicalMapping.scn | 4 ++-- ...pologicalMapping_NoInitialTriangle_option.scn | 4 ++-- ...eTopologicalMapping_with_TetrahedronModel.scn | 4 ++-- .../Component/Visual/LinearBlendSkinningGPU.scn | 4 ++-- examples/Demos/TriangleSurfaceCutting.scn | 4 ++-- examples/Demos/include_test.scn | 2 +- examples/Demos/include_test.xml | 2 +- examples/Demos/liver.scn | 4 ++-- examples/Demos/liverConfiguration.scn | 4 ++-- examples/Demos/rigidifiedSectionsInBeam.scn | 6 +++--- examples/Demos/simpleBoundaryConditions.scn | 8 ++++---- examples/Demos/simpleSphere.scn | 4 ++-- examples/Demos/skybox.scn | 4 ++-- examples/Objects/BoxConstraint.xml | 2 +- examples/Objects/InstrumentCoil.xml | 2 +- examples/Objects/PlaneConstraint.xml | 2 +- .../TopologicalMapping/2_TopoMapping.html | 2 +- .../TopologicalMapping/2_TopoMapping.scn | 4 ++-- .../TopologicalMapping/3_TopoMapping.scn | 4 ++-- .../TopologicalMapping/4_TopoMapping.scn | 4 ++-- .../TopologyTetra2TriangleTopologicalMapping.scn | 4 ++-- 110 files changed, 242 insertions(+), 242 deletions(-) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn b/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn index 6bcda80a448..d2cb769cbb7 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn +++ b/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn @@ -33,5 +33,5 @@ - + diff --git a/Sofa/Component/Diffusion/tests/scenes/TetrahedronDiffusionFEMForceField.scn b/Sofa/Component/Diffusion/tests/scenes/TetrahedronDiffusionFEMForceField.scn index b54a164645c..c5a6db9c33b 100644 --- a/Sofa/Component/Diffusion/tests/scenes/TetrahedronDiffusionFEMForceField.scn +++ b/Sofa/Component/Diffusion/tests/scenes/TetrahedronDiffusionFEMForceField.scn @@ -1,6 +1,6 @@ - + @@ -36,8 +36,8 @@ - - + + diff --git a/Sofa/Component/ODESolver/Backward/tests/scenes/EulerImplicitSpringDynamicTest.xml b/Sofa/Component/ODESolver/Backward/tests/scenes/EulerImplicitSpringDynamicTest.xml index 9d80018d423..6164322ee8d 100644 --- a/Sofa/Component/ODESolver/Backward/tests/scenes/EulerImplicitSpringDynamicTest.xml +++ b/Sofa/Component/ODESolver/Backward/tests/scenes/EulerImplicitSpringDynamicTest.xml @@ -1,6 +1,6 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_base.scn b/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_base.scn index 811ad5f6b11..3d7c71d8fb3 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_base.scn +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_base.scn @@ -3,7 +3,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_test.scn b/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_test.scn index 275d2734611..cfcca0d0492 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_test.scn +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/tests/scenes/TetrahedronHyperelasticityFEMForceField_test.scn @@ -1,7 +1,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/ExternalBehaviorModel/example/MultiMapping.py b/applications/plugins/ExternalBehaviorModel/example/MultiMapping.py index 40912650f48..c3503363497 100644 --- a/applications/plugins/ExternalBehaviorModel/example/MultiMapping.py +++ b/applications/plugins/ExternalBehaviorModel/example/MultiMapping.py @@ -14,7 +14,7 @@ def createGraph(self,node): rigidNode = self.rootNode.createChild('rigid') rigidNode.createObject('MechanicalObject', template='Rigid', name='dofs', position="0 0 0 0 0 0 1", showObject='1', showObjectScale='0.8') rigidNode.createObject('UniformMass', template='Rigid', totalMass="1") - rigidNode.createObject('PartialFixedConstraint',indices="0",fixedDirections="1 1 1 0 0 0") + rigidNode.createObject('PartialFixedProjectiveConstraint',indices="0",fixedDirections="1 1 1 0 0 0") rigidCollisionNode = rigidNode.createChild('rigid') rigidCollisionNode.createObject('MeshOBJLoader', filename="mesh/cube.obj", name="loader") diff --git a/applications/plugins/Sensable/examples/Carving.scn b/applications/plugins/Sensable/examples/Carving.scn index f14b61c400f..0faf21331dc 100644 --- a/applications/plugins/Sensable/examples/Carving.scn +++ b/applications/plugins/Sensable/examples/Carving.scn @@ -21,7 +21,7 @@ - + diff --git a/applications/plugins/Sensable/examples/Deformable-Method1.scn b/applications/plugins/Sensable/examples/Deformable-Method1.scn index 39152d3c235..493310549a7 100644 --- a/applications/plugins/Sensable/examples/Deformable-Method1.scn +++ b/applications/plugins/Sensable/examples/Deformable-Method1.scn @@ -17,7 +17,7 @@ - + diff --git a/applications/plugins/SofaAssimp/doc/index.html b/applications/plugins/SofaAssimp/doc/index.html index 3b7b3d369a2..7c553b03b3b 100644 --- a/applications/plugins/SofaAssimp/doc/index.html +++ b/applications/plugins/SofaAssimp/doc/index.html @@ -131,11 +131,11 @@

Examples



      As you can see in Sofa Modeler, the scene to load a collada file is very simple. We have the SceneColladaLoader to load it and, important thing, we also have an EulerSolver -which will be used by the potential SkeletalMotionConstraints to "play" the animation updating positions and velocities. +which will be used by the potential SkeletalMotionProjectiveConstraints to "play" the animation updating positions and velocities. When you launch runSofa with this scene, a new node will be added which contains the whole collada scene. The name of this node is the name you gave to the SceneColladaLoader plus the string "_scene". On the right picture, the loader generated two child nodes call "mesh 0" which contains a mesh without skinning (the sphere), and "mesh 1" which contains a mesh with skinning and bones animation directly from the collada file. -The SkeletalMotionConstraint automatically interpolates between animation frames, play with the animation time step to slown down or speed up the animation. +The SkeletalMotionProjectiveConstraint automatically interpolates between animation frames, play with the animation time step to slown down or speed up the animation.

As you can see on the other example below, the woman's hair does not fit her head very well because its coordinates system belongs to a dummy object not supported for the moment. diff --git a/applications/plugins/SofaCarving/examples/CarvingTool.scn b/applications/plugins/SofaCarving/examples/CarvingTool.scn index 90f4e9fb695..56cebdcab64 100644 --- a/applications/plugins/SofaCarving/examples/CarvingTool.scn +++ b/applications/plugins/SofaCarving/examples/CarvingTool.scn @@ -5,7 +5,7 @@ - + @@ -66,7 +66,7 @@ - diff --git a/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn b/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn index d3eba819d21..4fc616e55a9 100644 --- a/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn +++ b/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn @@ -1,7 +1,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn b/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn index 98e93a04704..cd3a8a5f350 100644 --- a/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn +++ b/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn @@ -1,7 +1,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/applications/plugins/SofaTest/SofaTest_test/scenes/damping.py b/applications/plugins/SofaTest/SofaTest_test/scenes/damping.py index 3b5bd86d9c8..b5c763922e7 100644 --- a/applications/plugins/SofaTest/SofaTest_test/scenes/damping.py +++ b/applications/plugins/SofaTest/SofaTest_test/scenes/damping.py @@ -120,7 +120,7 @@ def createScene(node): angularNode.createObject('MechanicalObject', template="Rigid", name="dofs", position="0 0 0 0 0 0 1", velocity="0 0 0 "+str(INITIAL_VELOCITY)+" 0 0") angularNode.createObject('UniformMass', filename=rigidFilename) angularNode.createObject('UniformVelocityDampingForceField', dampingCoefficient=DAMPING_COEF) - #angularNode.createObject('PartialFixedConstraint', indices='0', fixedDirections="1 1 1 0 1 1") + #angularNode.createObject('PartialFixedProjectiveConstraint', indices='0', fixedDirections="1 1 1 0 1 1") # translation damping test @@ -130,7 +130,7 @@ def createScene(node): translationNode.createObject('MechanicalObject', template="Rigid", name="dofs", position="0 0 0 0 0 0 1", velocity=str(INITIAL_VELOCITY)+" 0 0 0 0 0") translationNode.createObject('UniformMass', filename=rigidFilename) translationNode.createObject('UniformVelocityDampingForceField', dampingCoefficient=DAMPING_COEF) - #translationNode.createObject('PartialFixedConstraint', indices='0', fixedDirections="0 1 1 1 1 1") + #translationNode.createObject('PartialFixedProjectiveConstraint', indices='0', fixedDirections="0 1 1 1 1 1") return node diff --git a/examples/Benchmark/Accuracy/TriangleFEMForceField_compare.scn b/examples/Benchmark/Accuracy/TriangleFEMForceField_compare.scn index acff67b6931..9d690bed376 100644 --- a/examples/Benchmark/Accuracy/TriangleFEMForceField_compare.scn +++ b/examples/Benchmark/Accuracy/TriangleFEMForceField_compare.scn @@ -1,7 +1,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -88,7 +88,7 @@ - + diff --git a/examples/Benchmark/Accuracy/cylinder_PhantomSolution.scn b/examples/Benchmark/Accuracy/cylinder_PhantomSolution.scn index c17a4fb2b37..85132630579 100644 --- a/examples/Benchmark/Accuracy/cylinder_PhantomSolution.scn +++ b/examples/Benchmark/Accuracy/cylinder_PhantomSolution.scn @@ -5,7 +5,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/examples/Benchmark/Performance/Bar16-fem-implicit-CudaVec3f.pscn b/examples/Benchmark/Performance/Bar16-fem-implicit-CudaVec3f.pscn index 1b2601cdefb..c25c4b47529 100644 --- a/examples/Benchmark/Performance/Bar16-fem-implicit-CudaVec3f.pscn +++ b/examples/Benchmark/Performance/Bar16-fem-implicit-CudaVec3f.pscn @@ -15,7 +15,7 @@ /> --> '."\n"; ?> - + diff --git a/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3d.pscn b/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3d.pscn index d8df5a99135..32580e91d45 100644 --- a/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3d.pscn +++ b/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3d.pscn @@ -2,7 +2,7 @@ - + @@ -27,7 +27,7 @@ /> --> '."\n"; ?> - + diff --git a/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3f.pscn b/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3f.pscn index f911693ab22..70b4cc28ff4 100644 --- a/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3f.pscn +++ b/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3f.pscn @@ -15,7 +15,7 @@ /> --> '."\n"; ?> - +
diff --git a/examples/Benchmark/Performance/Bar16-spring-rk4-CudaVec3f.pscn b/examples/Benchmark/Performance/Bar16-spring-rk4-CudaVec3f.pscn index 08e39fab926..c1f3e1d33d5 100644 --- a/examples/Benchmark/Performance/Bar16-spring-rk4-CudaVec3f.pscn +++ b/examples/Benchmark/Performance/Bar16-spring-rk4-CudaVec3f.pscn @@ -15,7 +15,7 @@ /> --> '."\n"; ?> - +
diff --git a/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3d.pscn b/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3d.pscn index 8529cfce5cc..0ed5c7c7531 100644 --- a/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3d.pscn +++ b/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3d.pscn @@ -2,7 +2,7 @@ - + @@ -27,7 +27,7 @@ /> --> '."\n"; ?> - + diff --git a/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3f.pscn b/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3f.pscn index e1f658a0562..b467e0639b5 100644 --- a/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3f.pscn +++ b/examples/Benchmark/Performance/Bar16-spring-rk4-Vec3f.pscn @@ -15,7 +15,7 @@ /> --> '."\n"; ?> - +
diff --git a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG.scn b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG.scn index ccd8c09cf70..41bab20a46f 100644 --- a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG.scn +++ b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG.scn @@ -10,7 +10,7 @@ The differences are in the way the global system matrix is built and solved: --> - + @@ -39,7 +39,7 @@ The differences are in the way the global system matrix is built and solved: - + diff --git a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG_blocs.scn b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG_blocs.scn index d82a67aabbf..01f2c6d497c 100644 --- a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG_blocs.scn +++ b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_assembledCG_blocs.scn @@ -10,7 +10,7 @@ The differences are in the way the global system matrix is built and solved: --> - + @@ -38,7 +38,7 @@ The differences are in the way the global system matrix is built and solved: - + diff --git a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct.scn b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct.scn index 02276f5d64c..e9d27faa57b 100644 --- a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct.scn +++ b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct.scn @@ -10,7 +10,7 @@ The differences are in the way the global system matrix is built and solved: --> - + @@ -40,7 +40,7 @@ The differences are in the way the global system matrix is built and solved: - + diff --git a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct_blocs.scn b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct_blocs.scn index 98675483b53..3a1e7a22ab2 100644 --- a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct_blocs.scn +++ b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_direct_blocs.scn @@ -10,7 +10,7 @@ The differences are in the way the global system matrix is built and solved: --> - + @@ -39,7 +39,7 @@ The differences are in the way the global system matrix is built and solved: - + diff --git a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_matrixfreeCG.scn b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_matrixfreeCG.scn index 3d13ce2db0d..e5f0867fd30 100644 --- a/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_matrixfreeCG.scn +++ b/examples/Benchmark/Performance/MatrixAssembly/MatrixAssembly_matrixfreeCG.scn @@ -10,7 +10,7 @@ The differences are in the way the global system matrix is built and solved: --> - + @@ -40,7 +40,7 @@ The differences are in the way the global system matrix is built and solved: - + diff --git a/examples/Benchmark/TopologicalChanges/AffineMovementConstraint__RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/AffineMovementConstraint__RemovingMeshTest.scn index 483706da240..281c96ff109 100644 --- a/examples/Benchmark/TopologicalChanges/AffineMovementConstraint__RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/AffineMovementConstraint__RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/FixedConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/FixedConstraint_RemovingMeshTest.scn index c0406f6cca1..84fa89acc83 100644 --- a/examples/Benchmark/TopologicalChanges/FixedConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/FixedConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/FixedPlaneConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/FixedPlaneConstraint_RemovingMeshTest.scn index 411c3c7bb3f..66d04efb6cc 100644 --- a/examples/Benchmark/TopologicalChanges/FixedPlaneConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/FixedPlaneConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/LinearMovementConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/LinearMovementConstraint_RemovingMeshTest.scn index 9f30bb75e82..662cb14f052 100644 --- a/examples/Benchmark/TopologicalChanges/LinearMovementConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/LinearMovementConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn index 6a59053485f..87abbf0dd2e 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn index d4d097c6af2..b3df9a28747 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn index f25820f316b..f171b5055b3 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn index 1ba14adfb2e..7ca3e60cdda 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn @@ -7,7 +7,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -150,5 +150,5 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn index 043835a1768..5553e710327 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -150,5 +150,5 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn index 0a387c66ad4..4d6cd05e366 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn @@ -1,10 +1,10 @@ - + - + @@ -44,5 +44,5 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn index 80c1002e8e1..b65ea20ca98 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -150,5 +150,5 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn b/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn index 939ff0fecea..10cbae2c41a 100644 --- a/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn +++ b/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn @@ -5,7 +5,7 @@ - + @@ -48,7 +48,7 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/SlidingConstraint.scn b/examples/Component/Constraint/Lagrangian/SlidingConstraint.scn index 615a001036d..0adb51d70a3 100644 --- a/examples/Component/Constraint/Lagrangian/SlidingConstraint.scn +++ b/examples/Component/Constraint/Lagrangian/SlidingConstraint.scn @@ -6,7 +6,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -81,5 +81,5 @@ - + diff --git a/examples/Component/Constraint/Projective/AffineMovementConstraint.scn b/examples/Component/Constraint/Projective/AffineMovementConstraint.scn index 5e87538455e..cf9dee066e4 100644 --- a/examples/Component/Constraint/Projective/AffineMovementConstraint.scn +++ b/examples/Component/Constraint/Projective/AffineMovementConstraint.scn @@ -1,6 +1,6 @@ - + @@ -21,6 +21,6 @@ - + diff --git a/examples/Component/Constraint/Projective/AffineMovementConstraint3D.scn b/examples/Component/Constraint/Projective/AffineMovementConstraint3D.scn index 6fe3cfe9ee2..9559ae20198 100644 --- a/examples/Component/Constraint/Projective/AffineMovementConstraint3D.scn +++ b/examples/Component/Constraint/Projective/AffineMovementConstraint3D.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/examples/Component/Constraint/Projective/AttachConstraint.scn b/examples/Component/Constraint/Projective/AttachConstraint.scn index e419879213c..222d1833721 100644 --- a/examples/Component/Constraint/Projective/AttachConstraint.scn +++ b/examples/Component/Constraint/Projective/AttachConstraint.scn @@ -1,5 +1,5 @@ - + @@ -50,8 +50,8 @@ - - + + @@ -80,7 +80,7 @@ - - + + diff --git a/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn b/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn index ec7ae3cf09a..e6b835075a0 100644 --- a/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn +++ b/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn @@ -1,5 +1,5 @@ - + @@ -37,8 +37,8 @@ --> - - + + @@ -66,7 +66,7 @@ --> - - + + diff --git a/examples/Component/Constraint/Projective/BilinearConstraint.scn b/examples/Component/Constraint/Projective/BilinearConstraint.scn index 3886aca51c9..86cf8836f0d 100644 --- a/examples/Component/Constraint/Projective/BilinearConstraint.scn +++ b/examples/Component/Constraint/Projective/BilinearConstraint.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - diff --git a/examples/Component/Constraint/Projective/BilinearConstraint3D.scn b/examples/Component/Constraint/Projective/BilinearConstraint3D.scn index ba7c8b1a8c6..790ebfd1aa1 100644 --- a/examples/Component/Constraint/Projective/BilinearConstraint3D.scn +++ b/examples/Component/Constraint/Projective/BilinearConstraint3D.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Component/Constraint/Projective/FixedRotationConstraint.scn b/examples/Component/Constraint/Projective/FixedRotationConstraint.scn index 9a1d330bced..bf7d63aa34c 100644 --- a/examples/Component/Constraint/Projective/FixedRotationConstraint.scn +++ b/examples/Component/Constraint/Projective/FixedRotationConstraint.scn @@ -2,7 +2,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Component/Constraint/Projective/HermiteSplineConstraint.scn b/examples/Component/Constraint/Projective/HermiteSplineConstraint.scn index 0e9cebd5f00..94c103f3313 100644 --- a/examples/Component/Constraint/Projective/HermiteSplineConstraint.scn +++ b/examples/Component/Constraint/Projective/HermiteSplineConstraint.scn @@ -1,5 +1,5 @@ - + @@ -41,7 +41,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/examples/Component/Constraint/Projective/LinearMovementConstraint.scn b/examples/Component/Constraint/Projective/LinearMovementConstraint.scn index 765e24d0691..a0c44039f02 100644 --- a/examples/Component/Constraint/Projective/LinearMovementConstraint.scn +++ b/examples/Component/Constraint/Projective/LinearMovementConstraint.scn @@ -1,7 +1,7 @@ - + @@ -15,7 +15,7 @@ - - - - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Constraint/Projective/OscillatorConstraint_rigid.scn b/examples/Component/Constraint/Projective/OscillatorConstraint_rigid.scn index 29e63ffcf16..ebf9b35dcdd 100644 --- a/examples/Component/Constraint/Projective/OscillatorConstraint_rigid.scn +++ b/examples/Component/Constraint/Projective/OscillatorConstraint_rigid.scn @@ -1,5 +1,5 @@ - + @@ -11,13 +11,13 @@ - + - + diff --git a/examples/Component/Constraint/Projective/ParabolicConstraint.scn b/examples/Component/Constraint/Projective/ParabolicConstraint.scn index 9ad9caf4787..3ca3981defe 100644 --- a/examples/Component/Constraint/Projective/ParabolicConstraint.scn +++ b/examples/Component/Constraint/Projective/ParabolicConstraint.scn @@ -3,7 +3,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/Constraint/Projective/PartialFixedConstraint.scn b/examples/Component/Constraint/Projective/PartialFixedConstraint.scn index 9e235784ff4..2d58937d7d5 100644 --- a/examples/Component/Constraint/Projective/PartialFixedConstraint.scn +++ b/examples/Component/Constraint/Projective/PartialFixedConstraint.scn @@ -3,7 +3,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Constraint/Projective/PatchTestConstraint.scn b/examples/Component/Constraint/Projective/PatchTestConstraint.scn index 4c1b2ad4c17..14a0cde03f6 100644 --- a/examples/Component/Constraint/Projective/PatchTestConstraint.scn +++ b/examples/Component/Constraint/Projective/PatchTestConstraint.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn b/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn index ecfa2892dd8..ae0094ef474 100644 --- a/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn @@ -1,6 +1,6 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn b/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn index 8c46fd43d58..3d0508725a3 100644 --- a/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn @@ -1,6 +1,6 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn b/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn index ebef7961b34..568d1f73812 100644 --- a/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn @@ -1,6 +1,6 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Diffusion/TetrahedronDiffusionFEMForceField.scn b/examples/Component/Diffusion/TetrahedronDiffusionFEMForceField.scn index b3b91f47d5a..6d8f39a209e 100644 --- a/examples/Component/Diffusion/TetrahedronDiffusionFEMForceField.scn +++ b/examples/Component/Diffusion/TetrahedronDiffusionFEMForceField.scn @@ -1,5 +1,5 @@ - + @@ -35,8 +35,8 @@ - - + + diff --git a/examples/Component/Engine/Analyze/ShapeMatching.scn b/examples/Component/Engine/Analyze/ShapeMatching.scn index 963419e8bb6..79d6cc58032 100644 --- a/examples/Component/Engine/Analyze/ShapeMatching.scn +++ b/examples/Component/Engine/Analyze/ShapeMatching.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Engine/Generate/GenerateCylinder.scn b/examples/Component/Engine/Generate/GenerateCylinder.scn index d2eefb6e655..3355808d9a1 100644 --- a/examples/Component/Engine/Generate/GenerateCylinder.scn +++ b/examples/Component/Engine/Generate/GenerateCylinder.scn @@ -1,6 +1,6 @@ - + @@ -22,9 +22,9 @@ - + - + diff --git a/examples/Component/Engine/Generate/GenerateGrid.scn b/examples/Component/Engine/Generate/GenerateGrid.scn index 5e3a62f1069..fae198ee822 100644 --- a/examples/Component/Engine/Generate/GenerateGrid.scn +++ b/examples/Component/Engine/Generate/GenerateGrid.scn @@ -1,6 +1,6 @@ - + @@ -22,9 +22,9 @@ - + - + @@ -37,9 +37,9 @@ - + - + diff --git a/examples/Component/Engine/Select/BoxROI.scn b/examples/Component/Engine/Select/BoxROI.scn index 446af45803e..5faea6b844d 100644 --- a/examples/Component/Engine/Select/BoxROI.scn +++ b/examples/Component/Engine/Select/BoxROI.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/Engine/Select/MeshSplittingEngine.scn b/examples/Component/Engine/Select/MeshSplittingEngine.scn index 8016eba6c8d..48e86e8323c 100644 --- a/examples/Component/Engine/Select/MeshSplittingEngine.scn +++ b/examples/Component/Engine/Select/MeshSplittingEngine.scn @@ -2,7 +2,7 @@ - + diff --git a/examples/Component/Engine/Select/NearestPointROI.scn b/examples/Component/Engine/Select/NearestPointROI.scn index d0db2545113..6eef96cbb89 100644 --- a/examples/Component/Engine/Select/NearestPointROI.scn +++ b/examples/Component/Engine/Select/NearestPointROI.scn @@ -2,9 +2,9 @@ - + - + @@ -34,7 +34,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -58,8 +58,8 @@ - - + + - + diff --git a/examples/Component/Engine/Select/SphereROI.scn b/examples/Component/Engine/Select/SphereROI.scn index 6b12d91a9f5..41f7d5eafa5 100644 --- a/examples/Component/Engine/Select/SphereROI.scn +++ b/examples/Component/Engine/Select/SphereROI.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/Engine/Select/SubsetTopology.scn b/examples/Component/Engine/Select/SubsetTopology.scn index 21e3ebf839d..5368d557aef 100644 --- a/examples/Component/Engine/Select/SubsetTopology.scn +++ b/examples/Component/Engine/Select/SubsetTopology.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn b/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn index c2ad7fcabc4..e89f7fcc39f 100644 --- a/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn +++ b/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn @@ -3,7 +3,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Engine/Transform/DisplacementMatrixEngine.scn b/examples/Component/Engine/Transform/DisplacementMatrixEngine.scn index 3ad1146f2b3..bda26fff218 100644 --- a/examples/Component/Engine/Transform/DisplacementMatrixEngine.scn +++ b/examples/Component/Engine/Transform/DisplacementMatrixEngine.scn @@ -1,6 +1,6 @@ - + @@ -13,7 +13,7 @@ - + diff --git a/examples/Component/IO/Mesh/GIDMeshLoader.scn b/examples/Component/IO/Mesh/GIDMeshLoader.scn index 67d832f36aa..30cc187f067 100644 --- a/examples/Component/IO/Mesh/GIDMeshLoader.scn +++ b/examples/Component/IO/Mesh/GIDMeshLoader.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/examples/Component/IO/Mesh/GridMeshCreator.scn b/examples/Component/IO/Mesh/GridMeshCreator.scn index 57ad5cb3d65..f7fc089de77 100644 --- a/examples/Component/IO/Mesh/GridMeshCreator.scn +++ b/examples/Component/IO/Mesh/GridMeshCreator.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/IO/Mesh/LiverUseNewLoaders.scn b/examples/Component/IO/Mesh/LiverUseNewLoaders.scn index feb56b80452..33fc1206e06 100644 --- a/examples/Component/IO/Mesh/LiverUseNewLoaders.scn +++ b/examples/Component/IO/Mesh/LiverUseNewLoaders.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/IO/Mesh/MeshGmshLoader.scn b/examples/Component/IO/Mesh/MeshGmshLoader.scn index 0acff14cbf5..4158c668ac3 100644 --- a/examples/Component/IO/Mesh/MeshGmshLoader.scn +++ b/examples/Component/IO/Mesh/MeshGmshLoader.scn @@ -5,7 +5,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/RigidMapping-basic.scn b/examples/Component/Mapping/NonLinear/RigidMapping-basic.scn index 7744bd8aec9..1288a343fcd 100644 --- a/examples/Component/Mapping/NonLinear/RigidMapping-basic.scn +++ b/examples/Component/Mapping/NonLinear/RigidMapping-basic.scn @@ -1,6 +1,6 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/RigidMapping2d-basic.scn b/examples/Component/Mapping/NonLinear/RigidMapping2d-basic.scn index 5f19f6a606d..f80e9ca2cc0 100644 --- a/examples/Component/Mapping/NonLinear/RigidMapping2d-basic.scn +++ b/examples/Component/Mapping/NonLinear/RigidMapping2d-basic.scn @@ -1,6 +1,6 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/RigidRigidMapping-basic.scn b/examples/Component/Mapping/NonLinear/RigidRigidMapping-basic.scn index 6027d7de902..cc1d920970c 100644 --- a/examples/Component/Mapping/NonLinear/RigidRigidMapping-basic.scn +++ b/examples/Component/Mapping/NonLinear/RigidRigidMapping-basic.scn @@ -1,6 +1,6 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/examples/Component/Mass/DiagonalMass.scn b/examples/Component/Mass/DiagonalMass.scn index ac24b41552c..f83e61ebcb5 100644 --- a/examples/Component/Mass/DiagonalMass.scn +++ b/examples/Component/Mass/DiagonalMass.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Mass/MeshMatrixMass.scn b/examples/Component/Mass/MeshMatrixMass.scn index b8abec1d314..a837db2e000 100644 --- a/examples/Component/Mass/MeshMatrixMass.scn +++ b/examples/Component/Mass/MeshMatrixMass.scn @@ -4,7 +4,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/examples/Component/Mass/UniformMass.scn b/examples/Component/Mass/UniformMass.scn index c85e272e18a..7de3a469e35 100644 --- a/examples/Component/Mass/UniformMass.scn +++ b/examples/Component/Mass/UniformMass.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn b/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn index 697072de215..6f689334ae7 100644 --- a/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn +++ b/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn @@ -3,7 +3,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/MechanicalLoad/TrianglePressureForceField.scn b/examples/Component/MechanicalLoad/TrianglePressureForceField.scn index 80d90907be9..28efd74f9b2 100644 --- a/examples/Component/MechanicalLoad/TrianglePressureForceField.scn +++ b/examples/Component/MechanicalLoad/TrianglePressureForceField.scn @@ -4,7 +4,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn b/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn index 334b284bed6..5885d3e06be 100644 --- a/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn +++ b/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/angularSpringForceField.scn b/examples/Component/SolidMechanics/Spring/angularSpringForceField.scn index 2054f6972a8..6befcf8641f 100644 --- a/examples/Component/SolidMechanics/Spring/angularSpringForceField.scn +++ b/examples/Component/SolidMechanics/Spring/angularSpringForceField.scn @@ -2,7 +2,7 @@ - + @@ -21,7 +21,7 @@ - + - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn b/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn index 99379c74861..ba9d315d81f 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn @@ -3,7 +3,7 @@ - + @@ -69,7 +69,7 @@ - diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn index a2f7b98388e..827911681f4 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn @@ -4,7 +4,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn b/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn index 5964665426c..f39abb2049c 100644 --- a/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn +++ b/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn @@ -3,7 +3,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -48,7 +48,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn index a3c10c569b0..6b56e0beacb 100644 --- a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn index 22a8eea5978..ed957f9a363 100644 --- a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn +++ b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn @@ -4,7 +4,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn index 6a54be5dd80..91f8769f1c6 100644 --- a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn +++ b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn @@ -3,7 +3,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Visual/LinearBlendSkinningGPU.scn b/examples/Component/Visual/LinearBlendSkinningGPU.scn index 8b2f2a3a17b..78f55310d59 100644 --- a/examples/Component/Visual/LinearBlendSkinningGPU.scn +++ b/examples/Component/Visual/LinearBlendSkinningGPU.scn @@ -1,6 +1,6 @@ - + @@ -13,7 +13,7 @@ - + diff --git a/examples/Demos/TriangleSurfaceCutting.scn b/examples/Demos/TriangleSurfaceCutting.scn index ff1ac8f95c0..6606ffde44a 100644 --- a/examples/Demos/TriangleSurfaceCutting.scn +++ b/examples/Demos/TriangleSurfaceCutting.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Demos/include_test.scn b/examples/Demos/include_test.scn index e87c364c0a6..2abaeecc312 100644 --- a/examples/Demos/include_test.scn +++ b/examples/Demos/include_test.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Demos/include_test.xml b/examples/Demos/include_test.xml index b9d0af04bd9..630c537c627 100644 --- a/examples/Demos/include_test.xml +++ b/examples/Demos/include_test.xml @@ -3,7 +3,7 @@ - + diff --git a/examples/Demos/liver.scn b/examples/Demos/liver.scn index f9a61bcd922..97cbaccc4cd 100644 --- a/examples/Demos/liver.scn +++ b/examples/Demos/liver.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Demos/liverConfiguration.scn b/examples/Demos/liverConfiguration.scn index 79bb8040f47..320b1c9cd4a 100644 --- a/examples/Demos/liverConfiguration.scn +++ b/examples/Demos/liverConfiguration.scn @@ -4,7 +4,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/examples/Demos/rigidifiedSectionsInBeam.scn b/examples/Demos/rigidifiedSectionsInBeam.scn index 6997800c1fd..1556d02f278 100644 --- a/examples/Demos/rigidifiedSectionsInBeam.scn +++ b/examples/Demos/rigidifiedSectionsInBeam.scn @@ -15,7 +15,7 @@ The distances do not vary over time for the rigidified beam, whereas we can obse - + @@ -41,7 +41,7 @@ The distances do not vary over time for the rigidified beam, whereas we can obse - + @@ -76,7 +76,7 @@ The distances do not vary over time for the rigidified beam, whereas we can obse - + diff --git a/examples/Demos/simpleBoundaryConditions.scn b/examples/Demos/simpleBoundaryConditions.scn index 4a2f8a3c4b5..41888f274aa 100644 --- a/examples/Demos/simpleBoundaryConditions.scn +++ b/examples/Demos/simpleBoundaryConditions.scn @@ -1,7 +1,7 @@ - + @@ -27,15 +27,15 @@ - + - + - + diff --git a/examples/Demos/simpleSphere.scn b/examples/Demos/simpleSphere.scn index ff25c96b2b5..3f368f5dc1e 100644 --- a/examples/Demos/simpleSphere.scn +++ b/examples/Demos/simpleSphere.scn @@ -4,7 +4,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Demos/skybox.scn b/examples/Demos/skybox.scn index 71debbb798b..6291ef1f642 100644 --- a/examples/Demos/skybox.scn +++ b/examples/Demos/skybox.scn @@ -2,7 +2,7 @@ - + @@ -46,7 +46,7 @@ - + diff --git a/examples/Objects/BoxConstraint.xml b/examples/Objects/BoxConstraint.xml index c0e071328df..c738f9b2ee3 100644 --- a/examples/Objects/BoxConstraint.xml +++ b/examples/Objects/BoxConstraint.xml @@ -1,4 +1,4 @@ - + diff --git a/examples/Objects/InstrumentCoil.xml b/examples/Objects/InstrumentCoil.xml index 487295942a2..8fe3e9883a9 100644 --- a/examples/Objects/InstrumentCoil.xml +++ b/examples/Objects/InstrumentCoil.xml @@ -12,7 +12,7 @@ - + diff --git a/examples/Objects/PlaneConstraint.xml b/examples/Objects/PlaneConstraint.xml index 38c58c77d7d..3584c1a658f 100644 --- a/examples/Objects/PlaneConstraint.xml +++ b/examples/Objects/PlaneConstraint.xml @@ -1,4 +1,4 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.html b/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.html index 6f85f2bb9fc..75bde4f22ea 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.html +++ b/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.html @@ -31,7 +31,7 @@

Add a DiagonalMass component. In the Property 2/2 tab, change the mass density to "2".

-

Add a FixedPlaneConstraint component. In the Property 2/2 tab, change the normal direction of the plane to (0 0 1), the minimum plane distance from the origin to "-0.1" and the maximum plane distance from the origin to "0.1".

+

Add a FixedPlaneProjectiveConstraint component. In the Property 2/2 tab, change the normal direction of the plane to (0 0 1), the minimum plane distance from the origin to "-0.1" and the maximum plane distance from the origin to "0.1".

Add a FixedConstraint component.

diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn index 62835d77397..8b2b9ec44de 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn @@ -2,7 +2,7 @@ - + @@ -29,7 +29,7 @@ - +
diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn index 8ceefb5a0a0..c09c77d9c8e 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn @@ -2,7 +2,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn index 08159c9da90..33ba1964c7e 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn @@ -3,7 +3,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn b/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn index f278c7c6683..f3f5a631066 100644 --- a/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn +++ b/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn @@ -5,7 +5,7 @@ - + @@ -37,7 +37,7 @@ - + From b9d94eadc984bdba6d74a1e455f6a3c4a40bfdab Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 21 Nov 2023 18:21:07 +0100 Subject: [PATCH 07/28] Revert Compat modification... --- .../src/SofaConstraint/BilateralInteractionConstraint.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h b/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h index 1751b2dbd22..dee006cf153 100644 --- a/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h +++ b/Sofa/Component/Compat/src/SofaConstraint/BilateralInteractionConstraint.h @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") +SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h") From d689871b1079b085a535b0ef4da9ead40fa131ea Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Wed, 22 Nov 2023 13:33:23 +0100 Subject: [PATCH 08/28] [LinearAlgera, Core] Fix linking with LTO on MacOS/Clang (#4293) Fix linking with LTO on macos --- Sofa/framework/Core/CMakeLists.txt | 1 + .../src/sofa/core/topology/TopologyData.cpp | 32 +++++++++++++++++++ .../src/sofa/core/topology/TopologyData.h | 4 +++ .../core/topology/TopologySubsetIndices.cpp | 1 - .../src/sofa/linearalgebra/FullVector.cpp | 2 +- .../src/sofa/linearalgebra/FullVector.h | 2 +- 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp diff --git a/Sofa/framework/Core/CMakeLists.txt b/Sofa/framework/Core/CMakeLists.txt index 88e44c0829c..8ba69b2f109 100644 --- a/Sofa/framework/Core/CMakeLists.txt +++ b/Sofa/framework/Core/CMakeLists.txt @@ -306,6 +306,7 @@ set(SOURCE_FILES ${SRC_ROOT}/topology/Topology.cpp ${SRC_ROOT}/topology/TopologyChange.cpp ${SRC_ROOT}/topology/TopologyHandler.cpp + ${SRC_ROOT}/topology/TopologyData.cpp ${SRC_ROOT}/topology/TopologySubsetIndices.cpp ${SRC_ROOT}/visual/Data[DisplayFlags].cpp ${SRC_ROOT}/visual/DisplayFlags.cpp diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp new file mode 100644 index 00000000000..ac1a0847a0c --- /dev/null +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp @@ -0,0 +1,32 @@ +/****************************************************************************** +* 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_CORE_TOPOLOGY_TOPOLOGYDATA_DEFINITION + +#include + + +namespace sofa::core::topology +{ + +template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector >; + +} //namespace sofa::core::topology diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h index 645fd16ce9b..25f5366c8d8 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.h @@ -164,5 +164,9 @@ template< class VecT > using QuadData = TopologyData using TetrahedronData = TopologyData; template< class VecT > using HexahedronData = TopologyData; +#if !defined(SOFA_CORE_TOPOLOGY_TOPOLOGYDATA_DEFINITION) +extern template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector >; +#endif + } //namespace sofa::core::topology diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp b/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp index 38770cc257c..59c5dfc48f1 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologySubsetIndices.cpp @@ -85,7 +85,6 @@ void TopologySubsetIndices::updateLastIndex(Index posLastIndex, Index newGlobalI } template class SOFA_CORE_API sofa::core::topology::TopologyDataHandler < core::topology::BaseMeshTopology::Point, type::vector >; -template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector >; //template class SOFA_CORE_API sofa::core::topology::BaseTopologyData < type::vector >; } //namespace sofa::core::topology diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp index 35e24709a93..104a3d23deb 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.cpp @@ -19,7 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFABASELINEARSOLVER_FULLMATRIX_DEFINITION +#define SOFA_LINEARALGEBRA_FULLVECTOR_DEFINITION #include namespace sofa::linearalgebra diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h index 628a702fe36..8f4e7b0a71e 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/FullVector.h @@ -220,7 +220,7 @@ class FullVector : public linearalgebra::BaseVector SOFA_LINEARALGEBRA_API std::ostream& operator <<(std::ostream& out, const FullVector& v); SOFA_LINEARALGEBRA_API std::ostream& operator <<(std::ostream& out, const FullVector& v); -#if !defined(SOFABASELINEARSOLVER_FULLMATRIX_DEFINITION) +#if !defined(SOFA_LINEARALGEBRA_FULLVECTOR_DEFINITION) extern template class SOFA_LINEARALGEBRA_API FullVector; extern template class SOFA_LINEARALGEBRA_API FullVector; #endif From 32d6b9817395831092bdbd2840be06241310e8b4 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 23 Nov 2023 17:42:08 +0100 Subject: [PATCH 09/28] [LinearSolver] Remove CSparse-based linear solvers (#4258) * [LinearSolver.Direct] Remove CSparse based solvers * Remove csparse extlib * Fetchable CSparseSolvers plugin * Remove references of SparseLUSolver * Remove references to SparseCholeskySolver * Remove csparse * Try to fix on Linux * Update the compat * [LinearSolver.Direct] Remove CSparse based solvers * Fix direct solver --- .../SofaSparseSolver/SparseCholeskySolver.h | 4 +- .../src/SofaSparseSolver/SparseLUSolver.h | 4 +- .../src/SofaSparseSolver/SparseLUSolver.inl | 4 +- .../LinearSolver/Direct/CMakeLists.txt | 6 +- ...mponent.LinearSolver.DirectConfig.cmake.in | 4 - .../Direct/extlibs/csparse/CMakeLists.txt | 32 - .../Direct/extlibs/csparse/COPYING.txt | 3 - .../extlibs/csparse/CSparseConfig.cmake.in | 12 - .../Direct/extlibs/csparse/UFconfig.h | 118 - .../Direct/extlibs/csparse/csparse.c | 2122 ----------------- .../Direct/extlibs/csparse/csparse.h | 144 -- .../LinearSolver/Direct/extlibs/csparse/ldl.c | 507 ---- .../LinearSolver/Direct/extlibs/csparse/ldl.h | 111 - .../direct/EigenDirectSparseSolver.inl | 9 +- .../direct/PrecomputedLinearSolver.h | 4 +- .../direct/PrecomputedLinearSolver.inl | 19 +- .../direct/SparseCholeskySolver.cpp | 44 - .../direct/SparseCholeskySolver.h | 61 +- .../direct/SparseCholeskySolver.inl | 206 +- .../linearsolver/direct/SparseCommon.cpp | 17 +- .../linearsolver/direct/SparseCommon.h | 9 +- .../linearsolver/direct/SparseLDLSolverImpl.h | 1 - .../linearsolver/direct/SparseLUSolver.cpp | 46 - .../linearsolver/direct/SparseLUSolver.h | 89 +- .../linearsolver/direct/SparseLUSolver.inl | 234 +- .../PrecomputedWarpPreconditioner.h | 4 +- .../PrecomputedWarpPreconditioner.inl | 21 +- .../src/sofa/core/topology/TopologyData.cpp | 2 +- .../src/sofa/helper/ComponentChange.cpp | 6 +- applications/plugins/CMakeLists.txt | 1 + .../ExternalProjectConfig.cmake.in | 14 + .../beam10x10x46-warp-preconditioner-CUDA.scn | 1 - .../examples/ComplianceMatrixExporter.scn | 4 +- .../examples/ComplianceMatrixImage.scn | 4 +- .../examples/FillReducingOrdering.scn | 6 +- .../Lagrangian/InextensiblePendulum.scn | 4 +- .../Direct/FEMBAR_SparseCholeskySolver.scn | 8 - .../Direct/FEMBAR_SparseLUSolver.scn | 8 - .../NonLinear/DistanceFromTargetMapping.scn | 4 +- .../FEM/RestShapeSpringsForceField3.scn | 4 +- .../Spring/RestShapeSpringsForceField2.scn | 4 +- .../RegressionStateScenes.regression-tests | 2 - 42 files changed, 89 insertions(+), 3818 deletions(-) delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/CMakeLists.txt delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/COPYING.txt delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/CSparseConfig.cmake.in delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/UFconfig.h delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.c delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.h delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.c delete mode 100644 Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.h delete mode 100644 Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.cpp delete mode 100644 Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.cpp create mode 100644 applications/plugins/CSparseSolvers/ExternalProjectConfig.cmake.in delete mode 100644 examples/Component/LinearSolver/Direct/FEMBAR_SparseCholeskySolver.scn delete mode 100644 examples/Component/LinearSolver/Direct/FEMBAR_SparseLUSolver.scn diff --git a/Sofa/Component/Compat/src/SofaSparseSolver/SparseCholeskySolver.h b/Sofa/Component/Compat/src/SofaSparseSolver/SparseCholeskySolver.h index c3829690869..e08378ac130 100644 --- a/Sofa/Component/Compat/src/SofaSparseSolver/SparseCholeskySolver.h +++ b/Sofa/Component/Compat/src/SofaSparseSolver/SparseCholeskySolver.h @@ -23,4 +23,6 @@ #include -SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/linearsolver/direct/SparseCholeskySolver.h") +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.h b/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.h index 406f08044d2..4e21871483e 100644 --- a/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.h +++ b/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.h @@ -23,4 +23,6 @@ #include -SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/linearsolver/direct/SparseLUSolver.h") +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.inl b/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.inl index 4610b2cc02d..a50573db9b0 100644 --- a/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.inl +++ b/Sofa/Component/Compat/src/SofaSparseSolver/SparseLUSolver.inl @@ -23,4 +23,6 @@ #include -SOFA_DISABLED_HEADER("v22.06", "v23.06", "sofa/component/linearsolver/direct/SparseLUSolver.inl") +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/LinearSolver/Direct/CMakeLists.txt b/Sofa/Component/LinearSolver/Direct/CMakeLists.txt index 898a186778f..51fa093de06 100644 --- a/Sofa/Component/LinearSolver/Direct/CMakeLists.txt +++ b/Sofa/Component/LinearSolver/Direct/CMakeLists.txt @@ -50,14 +50,10 @@ set(SOURCE_FILES ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/MatrixLinearSystem[BTDMatrix].cpp ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/PrecomputedLinearSolver.cpp ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SVDLinearSolver.cpp - ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SparseCholeskySolver.cpp ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SparseCommon.cpp ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SparseLDLSolver.cpp - ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/SparseLUSolver.cpp ${SOFACOMPONENTLINEARSOLVERDIRECT_SOURCE_DIR}/TypedMatrixLinearSystem[BTDMatrix].cpp ) -add_subdirectory(extlibs/csparse) -sofa_set_01(SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE VALUE TRUE) sofa_find_package(metis QUIET) # Unix users can have an installed version of metis if(NOT metis_FOUND) @@ -75,7 +71,7 @@ sofa_find_package(Sofa.Component.LinearSolver.Iterative REQUIRED) # Only for Mat add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${WRAPPER_FILES}) target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core Sofa.Component.LinearSolver.Iterative) -target_link_libraries(${PROJECT_NAME} PUBLIC metis csparse) +target_link_libraries(${PROJECT_NAME} PUBLIC metis) target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads) sofa_create_package_with_targets( diff --git a/Sofa/Component/LinearSolver/Direct/Sofa.Component.LinearSolver.DirectConfig.cmake.in b/Sofa/Component/LinearSolver/Direct/Sofa.Component.LinearSolver.DirectConfig.cmake.in index 0b4b584fb08..4025df0d43e 100644 --- a/Sofa/Component/LinearSolver/Direct/Sofa.Component.LinearSolver.DirectConfig.cmake.in +++ b/Sofa/Component/LinearSolver/Direct/Sofa.Component.LinearSolver.DirectConfig.cmake.in @@ -8,14 +8,10 @@ find_package(Sofa.Component.LinearSolver.Iterative QUIET REQUIRED) find_package(Threads QUIET REQUIRED) set(SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_METIS @SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_METIS@) -set(SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE @SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE@) if(SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_METIS) find_package(Metis QUIET REQUIRED HINTS "${CMAKE_CURRENT_LIST_DIR}/..") endif() -if(SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE) - find_package(CSparse QUIET REQUIRED HINTS "${CMAKE_CURRENT_LIST_DIR}/..") -endif() if(NOT TARGET @PROJECT_NAME@) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/CMakeLists.txt b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/CMakeLists.txt deleted file mode 100644 index 266aa286dd4..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.12) -project(csparse VERSION 1.2.0) - -set(HEADER_FILES - csparse.h - ldl.h - UFconfig.h) - -set(SOURCE_FILES - csparse.c - ldl.c) - -# The code must be relocatable if we want to link a shared library against it. -if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xGNU" OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") - add_compile_options(-fPIC) -endif() - -add_library(${PROJECT_NAME} STATIC ${HEADER_FILES} ${SOURCE_FILES}) -target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "$") -target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "$") - -if(WIN32) - # remove warnings about deprecation (CRT,etc) - target_compile_options(${PROJECT_NAME} PRIVATE "/wd4996") -endif() - -sofa_create_package_with_targets( - PACKAGE_NAME CSparse - PACKAGE_VERSION ${PROJECT_VERSION} - TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES - INCLUDE_INSTALL_DIR "extlibs/CSparse" - ) diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/COPYING.txt b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/COPYING.txt deleted file mode 100644 index 49ba8beccea..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/COPYING.txt +++ /dev/null @@ -1,3 +0,0 @@ -CSPARSE: a Concise Sparse matrix package. -Copyright (c) 2006, Timothy A. Davis. -http://www.cise.ufl.edu/research/sparse/CSparse diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/CSparseConfig.cmake.in b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/CSparseConfig.cmake.in deleted file mode 100644 index af532008d06..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/CSparseConfig.cmake.in +++ /dev/null @@ -1,12 +0,0 @@ -# CMake package configuration file for the csparse library - -@PACKAGE_INIT@ - -if(NOT TARGET csparse) - include("${CMAKE_CURRENT_LIST_DIR}/CSparseTargets.cmake") -endif() - -check_required_components(csparse) - -set(CSparse_LIBRARIES csparse) -set(CSparse_INCLUDE_DIRS @PACKAGE_CSPARSE_INCLUDE_DIR@) diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/UFconfig.h b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/UFconfig.h deleted file mode 100644 index 54208d58b79..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/UFconfig.h +++ /dev/null @@ -1,118 +0,0 @@ -/* ========================================================================== */ -/* === UFconfig.h =========================================================== */ -/* ========================================================================== */ - -/* Configuration file for SuiteSparse: a Suite of Sparse matrix packages - * (AMD, COLAMD, CCOLAMD, CAMD, CHOLMOD, UMFPACK, CXSparse, and others). - * - * UFconfig.h provides the definition of the long integer. On most systems, - * a C program can be compiled in LP64 mode, in which long's and pointers are - * both 64-bits, and int's are 32-bits. Windows 64, however, uses the LLP64 - * model, in which int's and long's are 32-bits, and long long's and pointers - * are 64-bits. - * - * SuiteSparse packages that include long integer versions are - * intended for the LP64 mode. However, as a workaround for Windows 64 - * (and perhaps other systems), the long integer can be redefined. - * - * If _WIN64 is defined, then the __int64 type is used instead of long. - * - * The long integer can also be defined at compile time. For example, this - * could be added to UFconfig.mk: - * - * CFLAGS = -O -D'UF_long=long long' -D'UF_long_max=9223372036854775801' \ - * -D'UF_long_id="%lld"' - * - * This file defines UF_long as either long (on all but _WIN64) or - * __int64 on Windows 64. The intent is that a UF_long is always a 64-bit - * integer in a 64-bit code. ptrdiff_t might be a better choice than long; - * it is always the same size as a pointer. - * - * This file also defines the SUITESPARSE_VERSION and related definitions. - * - * Copyright (c) 2007, University of Florida. No licensing restrictions - * apply to this file or to the UFconfig directory. Author: Timothy A. Davis. - */ - -#ifndef _UFCONFIG_H -#define _UFCONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* ========================================================================== */ -/* === UF_long ============================================================== */ -/* ========================================================================== */ - -#ifndef UF_long - -#ifdef _WIN64 - -#define UF_long __int64 -#define UF_long_max _I64_MAX -#define UF_long_id "%I64d" - -#else - -#define UF_long long -#define UF_long_max LONG_MAX -#define UF_long_id "%ld" - -#endif -#endif - -/* ========================================================================== */ -/* === SuiteSparse version ================================================== */ -/* ========================================================================== */ - -/* SuiteSparse is not a package itself, but a collection of packages, some of - * which must be used together (UMFPACK requires AMD, CHOLMOD requires AMD, - * COLAMD, CAMD, and CCOLAMD, etc). A version number is provided here for the - * collection itself. The versions of packages within each version of - * SuiteSparse are meant to work together. Combining one packge from one - * version of SuiteSparse, with another package from another version of - * SuiteSparse, may or may not work. - * - * SuiteSparse Version 3.2.0 contains the following packages: - * - * AMD version 2.2.0 - * CAMD version 2.2.0 - * COLAMD version 2.7.1 - * CCOLAMD version 2.7.1 - * CHOLMOD version 1.7.0 - * CSparse version 2.2.1 - * CXSparse version 2.2.1 - * KLU version 1.0.1 - * BTF version 1.0.1 - * LDL version 2.0.1 - * UFconfig version number is the same as SuiteSparse - * UMFPACK version 5.2.0 - * RBio version 1.1.1 - * UFcollection version 1.1.1 - * LINFACTOR version 1.1.0 - * MESHND version 1.1.0 - * SSMULT version 1.1.0 - * MATLAB_Tools no specific version number - * SuiteSparseQR version 1.1.0 - * - * Other package dependencies: - * BLAS required by CHOLMOD and UMFPACK - * LAPACK required by CHOLMOD - * METIS 4.0.1 required by CHOLMOD (optional) and KLU (optional) - */ - -#define SUITESPARSE_DATE "Sept 20, 2008" -#define SUITESPARSE_VER_CODE(main,sub) ((main) * 1000 + (sub)) -#define SUITESPARSE_MAIN_VERSION 3 -#define SUITESPARSE_SUB_VERSION 2 -#define SUITESPARSE_SUBSUB_VERSION 0 -#define SUITESPARSE_VERSION \ - SUITESPARSE_VER_CODE(SUITESPARSE_MAIN_VERSION,SUITESPARSE_SUB_VERSION) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.c b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.c deleted file mode 100644 index 14c7b342622..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.c +++ /dev/null @@ -1,2122 +0,0 @@ -# include -# include -# include -# include - -# include "csparse.h" - -cs *cs_add ( const cs *A, const cs *B, double alpha, double beta ) -/* - Purpose: - - CS_ADD computes C = alpha*A + beta*B for sparse A and B. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. -*/ -{ - int p, j, nz = 0, anz, *Cp, *Ci, *Bp, m, n, bnz, *w, values ; - double *x, *Bx, *Cx ; - cs *C ; - if (!A || !B) return (NULL) ; /* check inputs */ - m = A->m ; anz = A->p [A->n] ; - n = B->n ; Bp = B->p ; Bx = B->x ; bnz = Bp [n] ; - w = cs_calloc (m, sizeof (int)) ; - values = (A->x != NULL) && (Bx != NULL) ; - x = values ? cs_malloc (m, sizeof (double)) : NULL ; - C = cs_spalloc (m, n, anz + bnz, values, 0) ; - if (!C || !w || (values && !x)) return (cs_done (C, w, x, 0)) ; - Cp = C->p ; Ci = C->i ; Cx = C->x ; - for (j = 0 ; j < n ; j++) - { - Cp [j] = nz ; /* column j of C starts here */ - nz = cs_scatter (A, j, alpha, w, x, j+1, C, nz) ; /* alpha*A(:,j)*/ - nz = cs_scatter (B, j, beta, w, x, j+1, C, nz) ; /* beta*B(:,j) */ - if (values) for (p = Cp [j] ; p < nz ; p++) Cx [p] = x [Ci [p]] ; - } - Cp [n] = nz ; /* finalize the last column of C */ - cs_sprealloc (C, 0) ; /* remove extra space from C */ - return (cs_done (C, w, x, 1)) ; /* success; free workspace, return C */ -} -static int cs_wclear (int mark, int lemax, int *w, int n) -/* - Purpose: - - CS_WCLEAR clears W. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. -*/ -{ - int k ; - if (mark < 2 || (mark + lemax < 0)) - { - for (k = 0 ; k < n ; k++) if (w [k] != 0) w [k] = 1 ; - mark = 2 ; - } - return (mark) ; /* at this point, w [0..n-1] < mark holds */ -} - -/* keep off-diagonal entries; drop diagonal entries */ -static int cs_diag (int i, int j, double aij, void * other) -{ - return (i != j); - (void)aij; (void)other; // unused parameters -} - -/* p = amd(A+A') if symmetric is true, or amd(A'A) otherwise */ -int *cs_amd ( const cs *A, int order ) -/* - Purpose: - - CS_AMD carries out the approximate minimum degree algorithm. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. - - Parameters: - - Input, int ORDER: - -1:natural, - 0:Cholesky, - 1:LU, - 2:QR -*/ -{ - cs *C, *A2, *AT ; - int *Cp, *Ci, *last, *ww, *len, *nv, *next, *P, *head, *elen, *degree, *w, - *hhead, *ATp, *ATi, d, dk, dext, lemax = 0, e, elenk, eln, i, j, k, k1, - k2, k3, jlast, ln, dense, nzmax, mindeg = 0, nvi, nvj, nvk, mark, wnvi, - ok, cnz, nel = 0, p, p1, p2, p3, p4, pj, pk, pk1, pk2, pn, q, n, m ; - unsigned int h ; - /* --- Construct matrix C ----------------------------------------------- */ - if (!A || order < 0) return (NULL) ; /* check inputs; quick return */ - AT = cs_transpose (A, 0) ; /* compute A' */ - if (!AT) return (NULL) ; - m = A->m ; n = A->n ; - dense = (int)CS_MAX (16, 10 * sqrt ((double) n)) ; /* find dense threshold */ - dense = CS_MIN (n-2, dense) ; - if (order == 0 && n == m) - { - C = cs_add (A, AT, 0, 0) ; /* C = A+A' */ - } - else if (order == 1) - { - ATp = AT->p ; /* drop dense columns from AT */ - ATi = AT->i ; - for (p2 = 0, j = 0 ; j < m ; j++) - { - p = ATp [j] ; /* column j of AT starts here */ - ATp [j] = p2 ; /* new column j starts here */ - if (ATp [j+1] - p > dense) continue ; /* skip dense col j */ - for ( ; p < ATp [j+1] ; p++) ATi [p2++] = ATi [p] ; - } - ATp [m] = p2 ; /* finalize AT */ - A2 = cs_transpose (AT, 0) ; /* A2 = AT' */ - C = A2 ? cs_multiply (AT, A2) : NULL ; /* C=A'*A with no dense rows */ - cs_spfree (A2) ; - } - else - { - C = cs_multiply (AT, A) ; /* C=A'*A */ - } - cs_spfree (AT) ; - if (!C) return (NULL) ; - P = cs_malloc (n+1, sizeof (int)) ; /* allocate result */ - ww = cs_malloc (8*(n+1), sizeof (int)) ;/* get workspace */ - len = ww ; nv = ww + (n+1) ; next = ww + 2*(n+1) ; - head = ww + 3*(n+1) ; elen = ww + 4*(n+1) ; degree = ww + 5*(n+1) ; - w = ww + 6*(n+1) ; hhead = ww + 7*(n+1) ; - last = P ; /* use P as workspace for last */ - cs_fkeep (C, &cs_diag, NULL) ; /* drop diagonal entries */ - Cp = C->p ; - cnz = Cp [n] ; - if (!cs_sprealloc (C, cnz+cnz/5+2*n)) return (cs_idone (P, C, ww, 0)) ; - /* --- Initialize quotient graph ---------------------------------------- */ - for (k = 0 ; k < n ; k++) len [k] = Cp [k+1] - Cp [k] ; - len [n] = 0 ; - nzmax = C->nzmax ; - Ci = C->i ; - for (i = 0 ; i <= n ; i++) - { - head [i] = -1 ; /* degree list i is empty */ - last [i] = -1 ; - next [i] = -1 ; - hhead [i] = -1 ; /* hash list i is empty */ - nv [i] = 1 ; /* node i is just one node */ - w [i] = 1 ; /* node i is alive */ - elen [i] = 0 ; /* Ek of node i is empty */ - degree [i] = len [i] ; /* degree of node i */ - } - mark = cs_wclear (0, 0, w, n) ; /* clear w */ - elen [n] = -2 ; /* n is a dead element */ - Cp [n] = -1 ; /* n is a root of assembly tree */ - w [n] = 0 ; /* n is a dead element */ - /* --- Initialize degree lists ------------------------------------------ */ - for (i = 0 ; i < n ; i++) - { - d = degree [i] ; - if (d == 0) /* node i is empty */ - { - elen [i] = -2 ; /* element i is dead */ - nel++ ; - Cp [i] = -1 ; /* i is a root of assemby tree */ - w [i] = 0 ; - } - else if (d > dense) /* node i is dense */ - { - nv [i] = 0 ; /* absorb i into element n */ - elen [i] = -1 ; /* node i is dead */ - nel++ ; - Cp [i] = CS_FLIP (n) ; - nv [n]++ ; - } - else - { - if (head [d] != -1) last [head [d]] = i ; - next [i] = head [d] ; /* put node i in degree list d */ - head [d] = i ; - } - } - while (nel < n) /* while (selecting pivots) do */ - { - /* --- Select node of minimum approximate degree -------------------- */ - for (k = -1 ; mindeg < n && (k = head [mindeg]) == -1 ; mindeg++) ; - if (next [k] != -1) last [next [k]] = -1 ; - head [mindeg] = next [k] ; /* remove k from degree list */ - elenk = elen [k] ; /* elenk = |Ek| */ - nvk = nv [k] ; /* # of nodes k represents */ - nel += nvk ; /* nv[k] nodes of A eliminated */ - /* --- Garbage collection ------------------------------------------- */ - if (elenk > 0 && cnz + mindeg >= nzmax) - { - for (j = 0 ; j < n ; j++) - { - if ((p = Cp [j]) >= 0) /* j is a live node or element */ - { - Cp [j] = Ci [p] ; /* save first entry of object */ - Ci [p] = CS_FLIP (j) ; /* first entry is now CS_FLIP(j) */ - } - } - for (q = 0, p = 0 ; p < cnz ; ) /* scan all of memory */ - { - if ((j = CS_FLIP (Ci [p++])) >= 0) /* found object j */ - { - Ci [q] = Cp [j] ; /* restore first entry of object */ - Cp [j] = q++ ; /* new pointer to object j */ - for (k3 = 0 ; k3 < len [j]-1 ; k3++) Ci [q++] = Ci [p++] ; - } - } - cnz = q ; /* Ci [cnz...nzmax-1] now free */ - } - /* --- Construct new element ---------------------------------------- */ - dk = 0 ; - nv [k] = -nvk ; /* flag k as in Lk */ - p = Cp [k] ; - pk1 = (elenk == 0) ? p : cnz ; /* do in place if elen[k] == 0 */ - pk2 = pk1 ; - for (k1 = 1 ; k1 <= elenk + 1 ; k1++) - { - if (k1 > elenk) - { - e = k ; /* search the nodes in k */ - pj = p ; /* list of nodes starts at Ci[pj]*/ - ln = len [k] - elenk ; /* length of list of nodes in k */ - } - else - { - e = Ci [p++] ; /* search the nodes in e */ - pj = Cp [e] ; - ln = len [e] ; /* length of list of nodes in e */ - } - for (k2 = 1 ; k2 <= ln ; k2++) - { - i = Ci [pj++] ; - if ((nvi = nv [i]) <= 0) continue ; /* node i dead, or seen */ - dk += nvi ; /* degree[Lk] += size of node i */ - nv [i] = -nvi ; /* negate nv[i] to denote i in Lk*/ - Ci [pk2++] = i ; /* place i in Lk */ - if (next [i] != -1) last [next [i]] = last [i] ; - if (last [i] != -1) /* remove i from degree list */ - { - next [last [i]] = next [i] ; - } - else - { - head [degree [i]] = next [i] ; - } - } - if (e != k) - { - Cp [e] = CS_FLIP (k) ; /* absorb e into k */ - w [e] = 0 ; /* e is now a dead element */ - } - } - if (elenk != 0) cnz = pk2 ; /* Ci [cnz...nzmax] is free */ - degree [k] = dk ; /* external degree of k - |Lk\i| */ - Cp [k] = pk1 ; /* element k is in Ci[pk1..pk2-1] */ - len [k] = pk2 - pk1 ; - elen [k] = -2 ; /* k is now an element */ - /* --- Find set differences ----------------------------------------- */ - mark = cs_wclear (mark, lemax, w, n) ; /* clear w if necessary */ - for (pk = pk1 ; pk < pk2 ; pk++) /* scan 1: find |Le\Lk| */ - { - i = Ci [pk] ; - if ((eln = elen [i]) <= 0) continue ;/* skip if elen[i] empty */ - nvi = -nv [i] ; /* nv [i] was negated */ - wnvi = mark - nvi ; - for (p = Cp [i] ; p <= Cp [i] + eln - 1 ; p++) /* scan Ei */ - { - e = Ci [p] ; - if (w [e] >= mark) - { - w [e] -= nvi ; /* decrement |Le\Lk| */ - } - else if (w [e] != 0) /* ensure e is a live element */ - { - w [e] = degree [e] + wnvi ; /* 1st time e seen in scan 1 */ - } - } - } - /* --- Degree update ------------------------------------------------ */ - for (pk = pk1 ; pk < pk2 ; pk++) /* scan2: degree update */ - { - i = Ci [pk] ; /* consider node i in Lk */ - p1 = Cp [i] ; - p2 = p1 + elen [i] - 1 ; - pn = p1 ; - for (h = 0, d = 0, p = p1 ; p <= p2 ; p++) /* scan Ei */ - { - e = Ci [p] ; - if (w [e] != 0) /* e is an unabsorbed element */ - { - dext = w [e] - mark ; /* dext = |Le\Lk| */ - if (dext > 0) - { - d += dext ; /* sum up the set differences */ - Ci [pn++] = e ; /* keep e in Ei */ - h += e ; /* compute the hash of node i */ - } - else - { - Cp [e] = CS_FLIP (k) ; /* aggressive absorb. e->k */ - w [e] = 0 ; /* e is a dead element */ - } - } - } - elen [i] = pn - p1 + 1 ; /* elen[i] = |Ei| */ - p3 = pn ; - p4 = p1 + len [i] ; - for (p = p2 + 1 ; p < p4 ; p++) /* prune edges in Ai */ - { - j = Ci [p] ; - if ((nvj = nv [j]) <= 0) continue ; /* node j dead or in Lk */ - d += nvj ; /* degree(i) += |j| */ - Ci [pn++] = j ; /* place j in node list of i */ - h += j ; /* compute hash for node i */ - } - if (d == 0) /* check for mass elimination */ - { - Cp [i] = CS_FLIP (k) ; /* absorb i into k */ - nvi = -nv [i] ; - dk -= nvi ; /* |Lk| -= |i| */ - nvk += nvi ; /* |k| += nv[i] */ - nel += nvi ; - nv [i] = 0 ; - elen [i] = -1 ; /* node i is dead */ - } - else - { - degree [i] = CS_MIN (degree [i], d) ; /* update degree(i) */ - Ci [pn] = Ci [p3] ; /* move first node to end */ - Ci [p3] = Ci [p1] ; /* move 1st el. to end of Ei */ - Ci [p1] = k ; /* add k as 1st element in of Ei */ - len [i] = pn - p1 + 1 ; /* new len of adj. list of node i */ - h %= n ; /* finalize hash of i */ - next [i] = hhead [h] ; /* place i in hash bucket */ - hhead [h] = i ; - last [i] = h ; /* save hash of i in last[i] */ - } - } /* scan2 is done */ - degree [k] = dk ; /* finalize |Lk| */ - lemax = CS_MAX (lemax, dk) ; - mark = cs_wclear (mark+lemax, lemax, w, n) ; /* clear w */ - /* --- Supernode detection ------------------------------------------ */ - for (pk = pk1 ; pk < pk2 ; pk++) - { - i = Ci [pk] ; - if (nv [i] >= 0) continue ; /* skip if i is dead */ - h = last [i] ; /* scan hash bucket of node i */ - i = hhead [h] ; - hhead [h] = -1 ; /* hash bucket will be empty */ - for ( ; i != -1 && next [i] != -1 ; i = next [i], mark++) - { - ln = len [i] ; - eln = elen [i] ; - for (p = Cp[i]+1 ; p <= Cp[i]+ln-1 ; p++) w [Ci [p]] = mark ; - jlast = i ; - for (j = next [i] ; j != -1 ; ) /* compare i with all j */ - { - ok = (len [j] == ln) && (elen [j] == eln) ; - for (p = Cp [j] + 1 ; ok && p <= Cp [j] + ln - 1 ; p++) - { - if (w [Ci [p]] != mark) ok = 0 ; /* compare i and j*/ - } - if (ok) /* i and j are identical */ - { - Cp [j] = CS_FLIP (i) ; /* absorb j into i */ - nv [i] += nv [j] ; - nv [j] = 0 ; - elen [j] = -1 ; /* node j is dead */ - j = next [j] ; /* delete j from hash bucket */ - next [jlast] = j ; - } - else - { - jlast = j ; /* j and i are different */ - j = next [j] ; - } - } - } - } - /* --- Finalize new element------------------------------------------ */ - for (p = pk1, pk = pk1 ; pk < pk2 ; pk++) /* finalize Lk */ - { - i = Ci [pk] ; - if ((nvi = -nv [i]) <= 0) continue ;/* skip if i is dead */ - nv [i] = nvi ; /* restore nv[i] */ - d = degree [i] + dk - nvi ; /* compute external degree(i) */ - d = CS_MIN (d, n - nel - nvi) ; - if (head [d] != -1) last [head [d]] = i ; - next [i] = head [d] ; /* put i back in degree list */ - last [i] = -1 ; - head [d] = i ; - mindeg = CS_MIN (mindeg, d) ; /* find new minimum degree */ - degree [i] = d ; - Ci [p++] = i ; /* place i in Lk */ - } - nv [k] = nvk ; /* # nodes absorbed into k */ - if ((len [k] = p-pk1) == 0) /* length of adj list of element k*/ - { - Cp [k] = -1 ; /* k is a root of the tree */ - w [k] = 0 ; /* k is now a dead element */ - } - if (elenk != 0) cnz = p ; /* free unused space in Lk */ - } - /* --- Postordering ----------------------------------------------------- */ - for (i = 0 ; i < n ; i++) Cp [i] = CS_FLIP (Cp [i]) ;/* fix assembly tree */ - for (j = 0 ; j <= n ; j++) head [j] = -1 ; - for (j = n ; j >= 0 ; j--) /* place unordered nodes in lists */ - { - if (nv [j] > 0) continue ; /* skip if j is an element */ - next [j] = head [Cp [j]] ; /* place j in list of its parent */ - head [Cp [j]] = j ; - } - for (e = n ; e >= 0 ; e--) /* place elements in lists */ - { - if (nv [e] <= 0) continue ; /* skip unless e is an element */ - if (Cp [e] != -1) - { - next [e] = head [Cp [e]] ; /* place e in list of its parent */ - head [Cp [e]] = e ; - } - } - for (k = 0, i = 0 ; i <= n ; i++) /* postorder the assembly tree */ - { - if (Cp [i] == -1) k = cs_tdfs (i, k, head, next, P, w) ; - } - return (cs_idone (P, C, ww, 1)) ; -} - -/* compute nonzero pattern of L(k,:) */ -static -int cs_ereach (const cs *A, int k, const int *parent, int *s, int *w, - double *x, int top) -{ - int i, p, len, *Ap = A->p, *Ai = A->i ; - double *Ax = A->x ; - for (p = Ap [k] ; p < Ap [k+1] ; p++) /* get pattern of L(k,:) */ - { - i = Ai [p] ; /* A(i,k) is nonzero */ - if (i > k) continue ; /* only use upper triangular part of A */ - x [i] = Ax [p] ; /* x(i) = A(i,k) */ - for (len = 0 ; w [i] != k ; i = parent [i]) /* traverse up etree */ - { - s [len++] = i ; /* L(k,i) is nonzero */ - w [i] = k ; /* mark i as visited */ - } - while (len > 0) s [--top] = s [--len] ; /* push path onto stack */ - } - return (top) ; /* s [top..n-1] contains pattern of L(k,:)*/ -} - -/* L = chol (A, [Pinv parent cp]), Pinv is optional */ -csn *cs_chol (const cs *A, const css *S) -{ - double d, lki, *Lx, *x ; - int top, i, p, k, n, *Li, *Lp, *cp, *Pinv, *w, *s, *c, *parent ; - cs *L, *C, *E ; - csn *N ; - if (!A || !S || !S->cp || !S->parent) return (NULL) ; /* check inputs */ - n = A->n ; - N = cs_calloc (1, sizeof (csn)) ; - w = cs_malloc (3*n, sizeof (int)) ; s = w + n, c = w + 2*n ; - x = cs_malloc (n, sizeof (double)) ; - cp = S->cp ; Pinv = S->Pinv ; parent = S->parent ; - C = Pinv ? cs_symperm (A, Pinv, 1) : ((cs *) A) ; - E = Pinv ? C : NULL ; - if (!N || !w || !x || !C) return (cs_ndone (N, E, w, x, 0)) ; - N->L = L = cs_spalloc (n, n, cp [n], 1, 0) ; - if (!L) return (cs_ndone (N, E, w, x, 0)) ; - Lp = L->p ; Li = L->i ; Lx = L->x ; - for (k = 0 ; k < n ; k++) - { - /* --- Nonzero pattern of L(k,:) ------------------------------------ */ - Lp [k] = c [k] = cp [k] ; /* column k of L starts here */ - x [k] = 0 ; /* x (0:k) is now zero */ - w [k] = k ; /* mark node k as visited */ - top = cs_ereach (C, k, parent, s, w, x, n) ; /* find row k of L*/ - d = x [k] ; /* d = C(k,k) */ - x [k] = 0 ; /* clear workspace for k+1st iteration */ - /* --- Triangular solve --------------------------------------------- */ - for ( ; top < n ; top++) /* solve L(0:k-1,0:k-1) * x = C(:,k) */ - { - i = s [top] ; /* s [top..n-1] is pattern of L(k,:) */ - lki = x [i] / Lx [Lp [i]] ; /* L(k,i) = x (i) / L(i,i) */ - x [i] = 0 ; /* clear workspace for k+1st iteration */ - for (p = Lp [i] + 1 ; p < c [i] ; p++) - { - x [Li [p]] -= Lx [p] * lki ; - } - d -= lki * lki ; /* d = d - L(k,i)*L(k,i) */ - p = c [i]++ ; - Li [p] = k ; /* store L(k,i) in column i */ - Lx [p] = lki ; - } - /* --- Compute L(k,k) ----------------------------------------------- */ - if (d <= 0) return (cs_ndone (N, E, w, x, 0)) ; /* not pos def */ - p = c [k]++ ; - Li [p] = k ; /* store L(k,k) = sqrt (d) in column k */ - Lx [p] = sqrt (d) ; - } - Lp [n] = cp [n] ; /* finalize L */ - return (cs_ndone (N, E, w, x, 1)) ; /* success: free E,w,x; return N */ -} - - -/* x=A\b where A is symmetric positive definite; b overwritten with solution */ -int cs_cholsol (const cs *A, double *b, int order) -{ - double *x ; - css *S ; - csn *N ; - int n, ok ; - if (!A || !b) return (0) ; /* check inputs */ - n = A->n ; - S = cs_schol (A, order) ; /* ordering and symbolic analysis */ - N = cs_chol (A, S) ; /* numeric Cholesky factorization */ - x = cs_malloc (n, sizeof (double)) ; - ok = (S && N && x) ; - if (ok) - { - cs_ipvec (n, S->Pinv, b, x) ; /* x = P*b */ - cs_lsolve (N->L, x) ; /* x = L\x */ - cs_ltsolve (N->L, x) ; /* x = L'\x */ - cs_pvec (n, S->Pinv, x, b) ; /* b = P'*x */ - } - cs_free (x) ; - cs_sfree (S) ; - cs_nfree (N) ; - return (ok) ; -} - -/* process edge (j,i) of the matrix */ -static void cs_cedge (int j, int i, const int *first, int *maxfirst, int *delta, - int *prevleaf, int *ancestor) -{ - int q, s, sparent, jprev ; - if (i <= j || first [j] <= maxfirst [i]) return ; - maxfirst [i] = first [j] ; /* update max first[j] seen so far */ - jprev = prevleaf [i] ; /* j is a leaf of the ith subtree */ - delta [j]++ ; /* A(i,j) is in the skeleton matrix */ - if (jprev != -1) - { - /* q = least common ancestor of jprev and j */ - for (q = jprev ; q != ancestor [q] ; q = ancestor [q]) ; - for (s = jprev ; s != q ; s = sparent) - { - sparent = ancestor [s] ; /* path compression */ - ancestor [s] = q ; - } - delta [q]-- ; /* decrement to account for overlap in q */ - } - prevleaf [i] = j ; /* j is now previous leaf of ith subtree */ -} - -/* colcount = column counts of LL'=A or LL'=A'A, given parent & post ordering */ -int *cs_counts (const cs *A, const int *parent, const int *post, int ata) -{ - int i, j, k, p, n, m, ii, s, *ATp, *ATi, *maxfirst, *prevleaf, *ancestor, - *head = NULL, *next = NULL, *colcount, *w, *first, *delta ; - cs *AT ; - if (!A || !parent || !post) return (NULL) ; /* check inputs */ - m = A->m ; n = A->n ; - s = 4*n + (ata ? (n+m+1) : 0) ; - w = cs_malloc (s, sizeof (int)) ; first = w+3*n ; /* get workspace */ - ancestor = w ; maxfirst = w+n ; prevleaf = w+2*n ; - delta = colcount = cs_malloc (n, sizeof (int)) ; /* allocate result */ - AT = cs_transpose (A, 0) ; - if (!AT || !colcount || !w) return (cs_idone (colcount, AT, w, 1)) ; - for (k = 0 ; k < s ; k++) w [k] = -1 ; /* clear workspace w [0..s-1] */ - for (k = 0 ; k < n ; k++) /* find first [j] */ - { - j = post [k] ; - delta [j] = (first [j] == -1) ? 1 : 0 ; /* delta[j]=1 if j is a leaf */ - for ( ; j != -1 && first [j] == -1 ; j = parent [j]) first [j] = k ; - } - ATp = AT->p ; ATi = AT->i ; - if (ata) - { - head = w+4*n ; next = w+5*n+1 ; - for (k = 0 ; k < n ; k++) w [post [k]] = k ; /* invert post */ - for (i = 0 ; i < m ; i++) - { - k = n ; /* k = least postordered column in row i */ - for (p = ATp [i] ; p < ATp [i+1] ; p++) k = CS_MIN (k, w [ATi [p]]); - next [i] = head [k] ; /* place row i in link list k */ - head [k] = i ; - } - } - for (i = 0 ; i < n ; i++) ancestor [i] = i ; /* each node in its own set */ - for (k = 0 ; k < n ; k++) - { - j = post [k] ; /* j is the kth node in postordered etree */ - if (parent [j] != -1) delta [parent [j]]-- ; /* j is not a root */ - if (ata) - { - for (ii = head [k] ; ii != -1 ; ii = next [ii]) - { - for (p = ATp [ii] ; p < ATp [ii+1] ; p++) - cs_cedge (j, ATi [p], first, maxfirst, delta, prevleaf, - ancestor) ; - } - } - else - { - for (p = ATp [j] ; p < ATp [j+1] ; p++) - cs_cedge (j, ATi [p], first, maxfirst, delta, prevleaf, - ancestor) ; - } - if (parent [j] != -1) ancestor [j] = parent [j] ; - } - for (j = 0 ; j < n ; j++) /* sum up delta's of each child */ - { - if (parent [j] != -1) colcount [parent [j]] += colcount [j] ; - } - return (cs_idone (colcount, AT, w, 1)) ; /* success: free workspace */ -} - -/* p [0..n] = cumulative sum of c [0..n-1], and then copy p [0..n-1] into c */ -int cs_cumsum (int *p, int *c, int n) -{ - int i, nz = 0 ; - if (!p || !c) return (-1) ; /* check inputs */ - for (i = 0 ; i < n ; i++) - { - p [i] = nz ; - nz += c [i] ; - c [i] = p [i] ; - } - p [n] = nz ; - return (nz) ; /* return sum (c [0..n-1]) */ -} - -/* depth-first-search of the graph of a matrix, starting at node j */ -int cs_dfs (int j, cs *L, int top, int *xi, int *pstack, const int *Pinv) -{ - int i, p, p2, done, jnew, head = 0, *Lp, *Li ; - if (!L || !xi || !pstack) return (-1) ; - Lp = L->p ; Li = L->i ; - xi [0] = j ; /* initialize the recursion stack */ - while (head >= 0) - { - j = xi [head] ; /* get j from the top of the recursion stack */ - jnew = Pinv ? (Pinv [j]) : j ; - if (!CS_MARKED(Lp,j)) - { - CS_MARK (Lp,j) ; /* mark node j as visited */ - pstack [head] = (jnew < 0) ? 0 : CS_UNFLIP (Lp [jnew]) ; - } - done = 1 ; /* node j done if no unvisited neighbors */ - p2 = (jnew < 0) ? 0 : CS_UNFLIP (Lp [jnew+1]) ; - for (p = pstack [head] ; p < p2 ; p++) /* examine all neighbors of j */ - { - i = Li [p] ; /* consider neighbor node i */ - if (CS_MARKED (Lp,i)) continue ; /* skip visited node i */ - pstack [head] = p ; /* pause depth-first search of node j */ - xi [++head] = i ; /* start dfs at node i */ - done = 0 ; /* node j is not done */ - break ; /* break, to start dfs (i) */ - } - if (done) /* depth-first search at node j is done */ - { - head-- ; /* remove j from the recursion stack */ - xi [--top] = j ; /* and place in the output stack */ - } - } - return (top) ; -} - -/* breadth-first search for coarse decomposition (C0,C1,R1 or R0,R3,C3) */ -static int cs_bfs (const cs *A, int n, int *wi, int *wj, int *queue, - const int *imatch, const int *jmatch, int mark) -{ - int *Ap, *Ai, head = 0, tail = 0, j, i, p, j2 ; - cs *C ; - for (j = 0 ; j < n ; j++) /* place all unmatched nodes in queue */ - { - if (imatch [j] >= 0) continue ; /* skip j if matched */ - wj [j] = 0 ; /* j in set C0 (R0 if transpose) */ - queue [tail++] = j ; /* place unmatched col j in queue */ - } - if (tail == 0) return (1) ; /* quick return if no unmatched nodes */ - C = (mark == 1) ? ((cs *) A) : cs_transpose (A, 0) ; - if (!C) return (0) ; /* bfs of C=A' to find R0,R3,C3 */ - Ap = C->p ; Ai = C->i ; - while (head < tail) /* while queue is not empty */ - { - j = queue [head++] ; /* get the head of the queue */ - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - i = Ai [p] ; - if (wi [i] >= 0) continue ; /* skip if i is marked */ - wi [i] = mark ; /* i in set R1 (C3 if transpose) */ - j2 = jmatch [i] ; /* traverse alternating path to j2 */ - if (wj [j2] >= 0) continue ;/* skip j2 if it is marked */ - wj [j2] = mark ; /* j2 in set C1 (R3 if transpose) */ - queue [tail++] = j2 ; /* add j2 to queue */ - } - } - if (mark != 1) cs_spfree (C) ; /* free A' if it was created */ - return (1) ; -} - -/* collect matched rows and columns into P and Q */ -static void cs_matched (int m, const int *wi, const int *jmatch, int *P, int *Q, - int *cc, int *rr, int set, int mark) -{ - int kc = cc [set], i ; - int kr = rr [set-1] ; - for (i = 0 ; i < m ; i++) - { - if (wi [i] != mark) continue ; /* skip if i is not in R set */ - P [kr++] = i ; - Q [kc++] = jmatch [i] ; - } - cc [set+1] = kc ; - rr [set] = kr ; -} - - -static void cs_unmatched (int m, const int *wi, int *P, int *rr, int set) -/* - Purpose: - - CS_UNMATCHED collects unmatched rows into the permutation vector P. -*/ -{ - int i, kr = rr [set] ; - for (i = 0 ; i < m ; i++) if (wi [i] == 0) P [kr++] = i ; - rr [set+1] = kr ; -} - -/* return 1 if row i is in R2 */ -static int cs_rprune (int i, int j, double aij, void *other) -{ - int *rr = (int *) other ; - return (i >= rr [1] && i < rr [2]) ; - (void)j; (void)aij; // unused parameters -} - -/* Given A, find coarse dmperm */ -csd *cs_dmperm (const cs *A) -{ - int m, n, i, j, k, p, cnz, nc, *jmatch, *imatch, *wi, *wj, *Pinv, *Cp, *Ci, - *Ps, *Rs, nb1, nb2, *P, *Q, *cc, *rr, *R, *S, ok ; - cs *C ; - csd *D, *scc ; - /* --- Maximum matching ------------------------------------------------- */ - if (!A) return (NULL) ; /* check inputs */ - m = A->m ; n = A->n ; - D = cs_dalloc (m, n) ; /* allocate result */ - if (!D) return (NULL) ; - P = D->P ; Q = D->Q ; R = D->R ; S = D->S ; cc = D->cc ; rr = D->rr ; - jmatch = cs_maxtrans (A) ; /* max transversal */ - imatch = jmatch + m ; /* imatch = inverse of jmatch */ - if (!jmatch) return (cs_ddone (D, NULL, jmatch, 0)) ; - /* --- Coarse decomposition --------------------------------------------- */ - wi = R ; wj = S ; /* use R and S as workspace */ - for (j = 0 ; j < n ; j++) wj [j] = -1 ; /* unmark all cols for bfs */ - for (i = 0 ; i < m ; i++) wi [i] = -1 ; /* unmark all rows for bfs */ - cs_bfs (A, n, wi, wj, Q, imatch, jmatch, 1) ; /* find C0, C1, R1 */ - ok = cs_bfs (A, m, wj, wi, P, jmatch, imatch, 3) ; /* find R0, R3, C3 */ - if (!ok) return (cs_ddone (D, NULL, jmatch, 0)) ; - cs_unmatched (n, wj, Q, cc, 0) ; /* unmatched set C0 */ - cs_matched (m, wi, jmatch, P, Q, cc, rr, 1, 1) ; /* set R1 and C1 */ - cs_matched (m, wi, jmatch, P, Q, cc, rr, 2, -1) ; /* set R2 and C2 */ - cs_matched (m, wi, jmatch, P, Q, cc, rr, 3, 3) ; /* set R3 and C3 */ - cs_unmatched (m, wi, P, rr, 3) ; /* unmatched set R0 */ - cs_free (jmatch) ; - /* --- Fine decomposition ----------------------------------------------- */ - Pinv = cs_pinv (P, m) ; /* Pinv=P' */ - if (!Pinv) return (cs_ddone (D, NULL, NULL, 0)) ; - C = cs_permute (A, Pinv, Q, 0) ;/* C=A(P,Q) (it will hold A(R2,C2)) */ - cs_free (Pinv) ; - if (!C) return (cs_ddone (D, NULL, NULL, 0)) ; - Cp = C->p ; Ci = C->i ; - nc = cc [3] - cc [2] ; /* delete cols C0, C1, and C3 from C */ - if (cc [2] > 0) for (j = cc [2] ; j <= cc [3] ; j++) Cp [j-cc[2]] = Cp [j] ; - C->n = nc ; - if (rr [2] - rr [1] < m) /* delete rows R0, R1, and R3 from C */ - { - cs_fkeep (C, cs_rprune, rr) ; - cnz = Cp [nc] ; - if (rr [1] > 0) for (p = 0 ; p < cnz ; p++) Ci [p] -= rr [1] ; - } - C->m = nc ; - scc = cs_scc (C) ; /* find strongly-connected components of C*/ - if (!scc) return (cs_ddone (D, C, NULL, 0)) ; - /* --- Combine coarse and fine decompositions --------------------------- */ - Ps = scc->P ; /* C(Ps,Ps) is the permuted matrix */ - Rs = scc->R ; /* kth block is Rs[k]..Rs[k+1]-1 */ - nb1 = scc->nb ; /* # of blocks of A(*/ - for (k = 0 ; k < nc ; k++) wj [k] = Q [Ps [k] + cc [2]] ; /* combine */ - for (k = 0 ; k < nc ; k++) Q [k + cc [2]] = wj [k] ; - for (k = 0 ; k < nc ; k++) wi [k] = P [Ps [k] + rr [1]] ; - for (k = 0 ; k < nc ; k++) P [k + rr [1]] = wi [k] ; - nb2 = 0 ; /* create the fine block partitions */ - R [0] = 0 ; - S [0] = 0 ; - if (cc [2] > 0) nb2++ ; /* leading coarse block A (R1, [C0 C1]) */ - for (k = 0 ; k < nb1 ; k++) /* coarse block A (R2,C2) */ - { - R [nb2] = Rs [k] + rr [1] ; /* A (R2,C2) splits into nb1 fine blocks */ - S [nb2] = Rs [k] + cc [2] ; - nb2++ ; - } - if (rr [2] < m) - { - R [nb2] = rr [2] ; /* trailing coarse block A ([R3 R0], C3) */ - S [nb2] = cc [3] ; - nb2++ ; - } - R [nb2] = m ; - S [nb2] = n ; - D->nb = nb2 ; - cs_dfree (scc) ; - return (cs_ddone (D, C, NULL, 1)) ; -} - -static int cs_tol (int i, int j, double aij, void *tol) -{ - return (fabs (aij) > *((double *) tol)) ; - (void)i; (void)j; // unused parameters -} -int cs_droptol (cs *A, double tol) -{ - return (cs_fkeep (A, &cs_tol, &tol)) ; /* keep all large entries */ -} - -static int cs_nonzero (int i, int j, double aij, void *other) -{ - return (aij != 0) ; - (void)i; (void)j; (void)other; // unused parameters -} -int cs_dropzeros (cs *A) -{ - return (cs_fkeep (A, &cs_nonzero, NULL)) ; /* keep all nonzero entries */ -} -int cs_dupl (cs *A) -/* - Purpose: - - CS_DUPL removes duplicate entries from A. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. -*/ -{ - int i, j, p, q, nz = 0, n, m, *Ap, *Ai, *w ; - double *Ax ; - if (!A) return (0) ; /* check inputs */ - m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - w = cs_malloc (m, sizeof (int)) ; /* get workspace */ - if (!w) return (0) ; /* out of memory */ - for (i = 0 ; i < m ; i++) w [i] = -1 ; /* row i not yet seen */ - for (j = 0 ; j < n ; j++) - { - q = nz ; /* column j will start at q */ - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - i = Ai [p] ; /* A(i,j) is nonzero */ - if (w [i] >= q) - { - Ax [w [i]] += Ax [p] ; /* A(i,j) is a duplicate */ - } - else - { - w [i] = nz ; /* record where row i occurs */ - Ai [nz] = i ; /* keep A(i,j) */ - Ax [nz++] = Ax [p] ; - } - } - Ap [j] = q ; /* record start of column j */ - } - Ap [n] = nz ; /* finalize A */ - cs_free (w) ; /* free workspace */ - return (cs_sprealloc (A, 0)) ; /* remove extra space from A */ -} - -/* add an entry to a triplet matrix; return 1 if ok, 0 otherwise */ -int cs_entry (cs *T, int i, int j, double x) -{ - if (!T || (T->nz >= T->nzmax && !cs_sprealloc (T, 2*(T->nzmax)))) return(0); - if (T->x) T->x [T->nz] = x ; - T->i [T->nz] = i ; - T->p [T->nz++] = j ; - T->m = CS_MAX (T->m, i+1) ; - T->n = CS_MAX (T->n, j+1) ; - return (1) ; -} - -/* compute the etree of A (using triu(A), or A'A without forming A'A */ -int *cs_etree (const cs *A, int ata) -{ - int i, k, p, m, n, inext, *Ap, *Ai, *w, *parent, *ancestor, *prev ; - if (!A) return (NULL) ; /* check inputs */ - m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; - parent = cs_malloc (n, sizeof (int)) ; - w = cs_malloc (n + (ata ? m : 0), sizeof (int)) ; - ancestor = w ; prev = w + n ; - if (!w || !parent) return (cs_idone (parent, NULL, w, 0)) ; - if (ata) for (i = 0 ; i < m ; i++) prev [i] = -1 ; - for (k = 0 ; k < n ; k++) - { - parent [k] = -1 ; /* node k has no parent yet */ - ancestor [k] = -1 ; /* nor does k have an ancestor */ - for (p = Ap [k] ; p < Ap [k+1] ; p++) - { - i = ata ? (prev [Ai [p]]) : (Ai [p]) ; - for ( ; i != -1 && i < k ; i = inext) /* traverse from i to k */ - { - inext = ancestor [i] ; /* inext = ancestor of i */ - ancestor [i] = k ; /* path compression */ - if (inext == -1) parent [i] = k ; /* no anc., parent is k */ - } - if (ata) prev [Ai [p]] = k ; - } - } - return (cs_idone (parent, NULL, w, 1)) ; -} - -/* drop entries for which fkeep(A(i,j)) is false; return nz if OK, else -1 */ -int cs_fkeep (cs *A, int (*fkeep) (int, int, double, void *), void *other) -{ - int j, p, nz = 0, n, *Ap, *Ai ; - double *Ax ; - if (!A || !fkeep) return (-1) ; /* check inputs */ - n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - for (j = 0 ; j < n ; j++) - { - p = Ap [j] ; /* get current location of col j */ - Ap [j] = nz ; /* record new location of col j */ - for ( ; p < Ap [j+1] ; p++) - { - if (fkeep (Ai [p], j, Ax ? Ax [p] : 1, other)) - { - if (Ax) Ax [nz] = Ax [p] ; /* keep A(i,j) */ - Ai [nz++] = Ai [p] ; - } - } - } - return (Ap [n] = nz) ; /* finalize A and return nnz(A) */ -} - -/* y = A*x+y */ -int cs_gaxpy (const cs *A, const double *x, double *y) -{ - int p, j, n, *Ap, *Ai ; - double *Ax ; - if (!A || !x || !y) return (0) ; /* check inputs */ - n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - for (j = 0 ; j < n ; j++) - { - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - y [Ai [p]] += Ax [p] * x [j] ; - } - } - return (1) ; -} - -/* apply the ith Householder vector to x */ -int cs_happly (const cs *V, int i, double beta, double *x) -{ - int p, *Vp, *Vi ; - double *Vx, tau = 0 ; - if (!V || !x) return (0) ; /* check inputs */ - Vp = V->p ; Vi = V->i ; Vx = V->x ; - for (p = Vp [i] ; p < Vp [i+1] ; p++) /* tau = v'*x */ - { - tau += Vx [p] * x [Vi [p]] ; - } - tau *= beta ; /* tau = beta*(v'*x) */ - for (p = Vp [i] ; p < Vp [i+1] ; p++) /* x = x - v*tau */ - { - x [Vi [p]] -= Vx [p] * tau ; - } - return (1) ; -} - -/* create a Householder reflection [v,beta,s]=house(x), overwrite x with v, - * where (I-beta*v*v')*x = s*x. See Algo 5.1.1, Golub & Van Loan, 3rd ed. */ -double cs_house (double *x, double *beta, int n) -{ - double s, sigma = 0 ; - int i ; - if (!x || !beta) return (-1) ; /* check inputs */ - for (i = 1 ; i < n ; i++) sigma += x [i] * x [i] ; - if (sigma == 0) - { - s = fabs (x [0]) ; /* s = |x(0)| */ - (*beta) = (x [0] <= 0) ? 2 : 0 ; - x [0] = 1 ; - } - else - { - s = sqrt (x [0] * x [0] + sigma) ; /* s = norm (x) */ - x [0] = (x [0] <= 0) ? (x [0] - s) : (-sigma / (x [0] + s)) ; - (*beta) = -1. / (s * x [0]) ; - } - return (s) ; -} - -/* x(P) = b, for dense vectors x and b; P=NULL denotes identity */ -int cs_ipvec (int n, const int *P, const double *b, double *x) -{ - int k ; - if (!x || !b) return (0) ; /* check inputs */ - for (k = 0 ; k < n ; k++) x [P ? P [k] : k] = b [k] ; - return (1) ; -} -cs *cs_load ( FILE *f ) -/* - Purpose: - - CS_LOAD loads a triplet matrix from a file. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. -*/ -{ - int i, j ; - double x ; - cs *T ; - if (!f) return (NULL) ; - T = cs_spalloc (0, 0, 1, 1, 1) ; - while (fscanf (f, "%d %d %lg\n", &i, &j, &x) == 3) - { - if (!cs_entry (T, i, j, x)) return (cs_spfree (T)) ; - } - return (T) ; -} -int cs_lsolve ( const cs *L, double *x ) -/* - Purpose: - - CS_LSOLVE solves L*x=b. - - Discussion: - - On input, X contains the right hand side, and on output, the solution. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. -*/ -{ - int p, j, n, *Lp, *Li ; - double *Lx ; - if (!L || !x) return (0) ; /* check inputs */ - n = L->n ; Lp = L->p ; Li = L->i ; Lx = L->x ; - for (j = 0 ; j < n ; j++) - { - x [j] /= Lx [Lp [j]] ; - for (p = Lp [j]+1 ; p < Lp [j+1] ; p++) - { - x [Li [p]] -= Lx [p] * x [j] ; - } - } - return (1) ; -} -int cs_ltsolve ( const cs *L, double *x ) -/* - Purpose: - - CS_LTSOLVE solves L'*x=b. - - Discussion: - - On input, X contains the right hand side, and on output, the solution. - - Reference: - - Timothy Davis, - Direct Methods for Sparse Linear Systems, - SIAM, Philadelphia, 2006. -*/ -{ - int p, j, n, *Lp, *Li ; - double *Lx ; - if (!L || !x) return (0) ; /* check inputs */ - n = L->n ; Lp = L->p ; Li = L->i ; Lx = L->x ; - for (j = n-1 ; j >= 0 ; j--) - { - for (p = Lp [j]+1 ; p < Lp [j+1] ; p++) - { - x [j] -= Lx [p] * x [Li [p]] ; - } - x [j] /= Lx [Lp [j]] ; - } - return (1) ; -} - -/* [L,U,Pinv]=lu(A, [Q lnz unz]). lnz and unz can be guess */ -csn *cs_lu (const cs *A, const css *S, double tol) -{ - cs *L, *U ; - csn *N ; - double pivot, *Lx, *Ux, *x, a, t ; - int *Lp, *Li, *Up, *Ui, *Pinv, *xi, *Q, n, ipiv, k, top, p, i, col, lnz,unz; - if (!A || !S) return (NULL) ; /* check inputs */ - n = A->n ; - Q = S->Q ; lnz = S->lnz ; unz = S->unz ; - x = cs_malloc (n, sizeof (double)) ; - xi = cs_malloc (2*n, sizeof (int)) ; - N = cs_calloc (1, sizeof (csn)) ; - if (!x || !xi || !N) return (cs_ndone (N, NULL, xi, x, 0)) ; - N->L = L = cs_spalloc (n, n, lnz, 1, 0) ; /* initial L and U */ - N->U = U = cs_spalloc (n, n, unz, 1, 0) ; - N->Pinv = Pinv = cs_malloc (n, sizeof (int)) ; - if (!L || !U || !Pinv) return (cs_ndone (N, NULL, xi, x, 0)) ; - Lp = L->p ; Up = U->p ; - for (i = 0 ; i < n ; i++) x [i] = 0 ; /* clear workspace */ - for (i = 0 ; i < n ; i++) Pinv [i] = -1 ; /* no rows pivotal yet */ - for (k = 0 ; k <= n ; k++) Lp [k] = 0 ; /* no cols of L yet */ - lnz = unz = 0 ; - for (k = 0 ; k < n ; k++) /* compute L(:,k) and U(:,k) */ - { - /* --- Triangular solve --------------------------------------------- */ - Lp [k] = lnz ; /* L(:,k) starts here */ - Up [k] = unz ; /* U(:,k) starts here */ - if ((lnz + n > L->nzmax && !cs_sprealloc (L, 2*L->nzmax + n)) || - (unz + n > U->nzmax && !cs_sprealloc (U, 2*U->nzmax + n))) - { - return (cs_ndone (N, NULL, xi, x, 0)) ; - } - Li = L->i ; Lx = L->x ; Ui = U->i ; Ux = U->x ; - col = Q ? (Q [k]) : k ; - top = cs_splsolve (L, A, col, xi, x, Pinv) ; /* x = L\A(:,col) */ - /* --- Find pivot --------------------------------------------------- */ - ipiv = -1 ; - a = -1 ; - for (p = top ; p < n ; p++) - { - i = xi [p] ; /* x(i) is nonzero */ - if (Pinv [i] < 0) /* row i is not pivotal */ - { - if ((t = fabs (x [i])) > a) - { - a = t ; /* largest pivot candidate so far */ - ipiv = i ; - } - } - else /* x(i) is the entry U(Pinv[i],k) */ - { - Ui [unz] = Pinv [i] ; - Ux [unz++] = x [i] ; - } - } - if (ipiv == -1 || a <= 0) return (cs_ndone (N, NULL, xi, x, 0)) ; - if (Pinv [col] < 0 && fabs (x [col]) >= a*tol) ipiv = col ; - /* --- Divide by pivot ---------------------------------------------- */ - pivot = x [ipiv] ; /* the chosen pivot */ - Ui [unz] = k ; /* last entry in U(:,k) is U(k,k) */ - Ux [unz++] = pivot ; - Pinv [ipiv] = k ; /* ipiv is the kth pivot row */ - Li [lnz] = ipiv ; /* first entry in L(:,k) is L(k,k) = 1 */ - Lx [lnz++] = 1 ; - for (p = top ; p < n ; p++) /* L(k+1:n,k) = x / pivot */ - { - i = xi [p] ; - if (Pinv [i] < 0) /* x(i) is an entry in L(:,k) */ - { - Li [lnz] = i ; /* save unpermuted row in L */ - Lx [lnz++] = x [i] / pivot ; /* scale pivot column */ - } - x [i] = 0 ; /* x [0..n-1] = 0 for next k */ - } - } - /* --- Finalize L and U ------------------------------------------------- */ - Lp [n] = lnz ; - Up [n] = unz ; - Li = L->i ; /* fix row indices of L for final Pinv */ - for (p = 0 ; p < lnz ; p++) Li [p] = Pinv [Li [p]] ; - cs_sprealloc (L, 0) ; /* remove extra space from L and U */ - cs_sprealloc (U, 0) ; - return (cs_ndone (N, NULL, xi, x, 1)) ; /* success */ -} - -/* x=A\b where A is unsymmetric; b overwritten with solution */ -int cs_lusol (const cs *A, double *b, int order, double tol) -{ - double *x ; - css *S ; - csn *N ; - int n, ok ; - if (!A || !b) return (0) ; /* check inputs */ - n = A->n ; - S = cs_sqr (A, order, 0) ; /* ordering and symbolic analysis */ - N = cs_lu (A, S, tol) ; /* numeric LU factorization */ - x = cs_malloc (n, sizeof (double)) ; - ok = (S && N && x) ; - if (ok) - { - cs_ipvec (n, N->Pinv, b, x) ; /* x = P*b */ - cs_lsolve (N->L, x) ; /* x = L\x */ - cs_usolve (N->U, x) ; /* x = U\x */ - cs_ipvec (n, S->Q, x, b) ; /* b = Q*x */ - } - cs_free (x) ; - cs_sfree (S) ; - cs_nfree (N) ; - return (ok) ; -} - -#ifdef MATLAB_MEX_FILE -#define malloc mxMalloc -#define free mxFree -#define realloc mxRealloc -#define calloc mxCalloc -#endif - -/* wrapper for malloc */ -void *cs_malloc (int n, size_t size) -{ - return (CS_OVERFLOW (n,size) ? NULL : malloc (CS_MAX (n,1) * size)) ; -} - -/* wrapper for calloc */ -void *cs_calloc (int n, size_t size) -{ - return (CS_OVERFLOW (n,size) ? NULL : calloc (CS_MAX (n,1), size)) ; -} - -/* wrapper for free */ -void *cs_free (void *p) -{ - if (p) free (p) ; /* free p if it is not already NULL */ - return (NULL) ; /* return NULL to simplify the use of cs_free */ -} - -/* wrapper for realloc */ -void *cs_realloc (void *p, int n, size_t size, int *ok) -{ - void *p2 ; - *ok = !CS_OVERFLOW (n,size) ; /* guard against int overflow */ - if (!(*ok)) return (p) ; /* p unchanged if n too large */ - p2 = realloc (p, CS_MAX (n,1) * size) ; /* realloc the block */ - *ok = (p2 != NULL) ; - return ((*ok) ? p2 : p) ; /* return original p if failure */ -} - -/* find an augmenting path starting at column k and extend the match if found */ -static void cs_augment (int k, const cs *A, int *jmatch, int *cheap, int *w, - int *js, int *is, int *ps) -{ - int found = 0, p, i = -1, *Ap = A->p, *Ai = A->i, head = 0, j ; - js [0] = k ; /* start with just node k in jstack */ - while (head >= 0) - { - /* --- Start (or continue) depth-first-search at node j ------------- */ - j = js [head] ; /* get j from top of jstack */ - if (w [j] != k) /* 1st time j visited for kth path */ - { - w [j] = k ; /* mark j as visited for kth path */ - for (p = cheap [j] ; p < Ap [j+1] && !found ; p++) - { - i = Ai [p] ; /* try a cheap assignment (i,j) */ - found = (jmatch [i] == -1) ; - } - cheap [j] = p ; /* start here next time j is traversed*/ - if (found) - { - is [head] = i ; /* column j matched with row i */ - break ; /* end of augmenting path */ - } - ps [head] = Ap [j] ; /* no cheap match: start dfs for j */ - } - /* --- Depth-first-search of neighbors of j ------------------------- */ - for (p = ps [head] ; p < Ap [j+1] ; p++) - { - i = Ai [p] ; /* consider row i */ - if (w [jmatch [i]] == k) continue ; /* skip jmatch [i] if marked */ - ps [head] = p + 1 ; /* pause dfs of node j */ - is [head] = i ; /* i will be matched with j if found */ - js [++head] = jmatch [i] ; /* start dfs at column jmatch [i] */ - break ; - } - if (p == Ap [j+1]) head-- ; /* node j is done; pop from stack */ - } /* augment the match if path found: */ - if (found) for (p = head ; p >= 0 ; p--) jmatch [is [p]] = js [p] ; -} - -/* find a maximum transveral */ -int *cs_maxtrans (const cs *A) /* returns jmatch [0..m-1]; imatch [0..n-1] */ -{ - int i, j, k, n, m, p, n2 = 0, m2 = 0, *Ap, *jimatch, *w, *cheap, *js, *is, - *ps, *Ai, *Cp, *jmatch, *imatch ; - cs *C ; - if (!A) return (NULL) ; /* check inputs */ - n = A->n ; m = A->m ; Ap = A->p ; Ai = A->i ; - w = jimatch = cs_calloc (m+n, sizeof (int)) ; /* allocate result */ - if (!jimatch) return (NULL) ; - for (j = 0 ; j < n ; j++) /* count non-empty rows and columns */ - { - n2 += (Ap [j] < Ap [j+1]) ; - for (p = Ap [j] ; p < Ap [j+1] ; p++) w [Ai [p]] = 1 ; - } - for (i = 0 ; i < m ; i++) m2 += w [i] ; - C = (m2 < n2) ? cs_transpose (A,0) : ((cs *) A) ; /* transpose if needed */ - if (!C) return (cs_idone (jimatch, (m2 < n2) ? C : NULL, NULL, 0)) ; - n = C->n ; m = C->m ; Cp = C->p ; - jmatch = (m2 < n2) ? jimatch + n : jimatch ; - imatch = (m2 < n2) ? jimatch : jimatch + m ; - w = cs_malloc (5*n, sizeof (int)) ; /* allocate workspace */ - if (!w) return (cs_idone (jimatch, (m2 < n2) ? C : NULL, w, 0)) ; - cheap = w + n ; js = w + 2*n ; is = w + 3*n ; ps = w + 4*n ; - for (j = 0 ; j < n ; j++) cheap [j] = Cp [j] ; /* for cheap assignment */ - for (j = 0 ; j < n ; j++) w [j] = -1 ; /* all columns unflagged */ - for (i = 0 ; i < m ; i++) jmatch [i] = -1 ; /* nothing matched yet */ - for (k = 0 ; k < n ; k++) cs_augment (k, C, jmatch, cheap, w, js, is, ps) ; - for (j = 0 ; j < n ; j++) imatch [j] = -1 ; /* find row match */ - for (i = 0 ; i < m ; i++) if (jmatch [i] >= 0) imatch [jmatch [i]] = i ; - return (cs_idone (jimatch, (m2 < n2) ? C : NULL, w, 1)) ; -} - -/* C = A*B */ -cs *cs_multiply (const cs *A, const cs *B) -{ - int p, j, nz = 0, anz, *Cp, *Ci, *Bp, m, n, bnz, *w, values, *Bi ; - double *x, *Bx, *Cx ; - cs *C ; - if (!A || !B) return (NULL) ; /* check inputs */ - m = A->m ; anz = A->p [A->n] ; - n = B->n ; Bp = B->p ; Bi = B->i ; Bx = B->x ; bnz = Bp [n] ; - w = cs_calloc (m, sizeof (int)) ; - values = (A->x != NULL) && (Bx != NULL) ; - x = values ? cs_malloc (m, sizeof (double)) : NULL ; - C = cs_spalloc (m, n, anz + bnz, values, 0) ; - if (!C || !w || (values && !x)) return (cs_done (C, w, x, 0)) ; - Cp = C->p ; - for (j = 0 ; j < n ; j++) - { - if (nz + m > C->nzmax && !cs_sprealloc (C, 2*(C->nzmax)+m)) - { - return (cs_done (C, w, x, 0)) ; /* out of memory */ - } - Ci = C->i ; Cx = C->x ; /* C may have been reallocated */ - Cp [j] = nz ; /* column j of C starts here */ - for (p = Bp [j] ; p < Bp [j+1] ; p++) - { - nz = cs_scatter (A, Bi [p], Bx ? Bx [p] : 1, w, x, j+1, C, nz) ; - } - if (values) for (p = Cp [j] ; p < nz ; p++) Cx [p] = x [Ci [p]] ; - } - Cp [n] = nz ; /* finalize the last column of C */ - cs_sprealloc (C, 0) ; /* remove extra space from C */ - return (cs_done (C, w, x, 1)) ; /* success; free workspace, return C */ -} - -/* 1-norm of a sparse matrix = max (sum (abs (A))), largest column sum */ -double cs_norm (const cs *A) -{ - int p, j, n, *Ap ; - double *Ax, norm = 0, s ; - if (!A || !A->x) return (-1) ; /* check inputs */ - n = A->n ; Ap = A->p ; Ax = A->x ; - for (j = 0 ; j < n ; j++) - { - for (s = 0, p = Ap [j] ; p < Ap [j+1] ; p++) s += fabs (Ax [p]) ; - norm = CS_MAX (norm, s) ; - } - return (norm) ; -} - -/* C = A(P,Q) where P and Q are permutations of 0..m-1 and 0..n-1. */ -cs *cs_permute (const cs *A, const int *Pinv, const int *Q, int values) -{ - int p, j, k, nz = 0, m, n, *Ap, *Ai, *Cp, *Ci ; - double *Cx, *Ax ; - cs *C ; - if (!A) return (NULL) ; /* check inputs */ - m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - C = cs_spalloc (m, n, Ap [n], values && Ax != NULL, 0) ; - if (!C) return (cs_done (C, NULL, NULL, 0)) ; /* out of memory */ - Cp = C->p ; Ci = C->i ; Cx = C->x ; - for (k = 0 ; k < n ; k++) - { - Cp [k] = nz ; /* column k of C is column Q[k] of A */ - j = Q ? (Q [k]) : k ; - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - if (Cx) Cx [nz] = Ax [p] ; /* row i of A is row Pinv[i] of C */ - Ci [nz++] = Pinv ? (Pinv [Ai [p]]) : Ai [p] ; - } - } - Cp [n] = nz ; /* finalize the last column of C */ - return (cs_done (C, NULL, NULL, 1)) ; -} - -/* Pinv = P', or P = Pinv' */ -int *cs_pinv (int const *P, int n) -{ - int k, *Pinv ; - if (!P) return (NULL) ; /* P = NULL denotes identity */ - Pinv = cs_malloc (n, sizeof (int)) ; /* allocate resuult */ - if (!Pinv) return (NULL) ; /* out of memory */ - for (k = 0 ; k < n ; k++) Pinv [P [k]] = k ;/* invert the permutation */ - return (Pinv) ; /* return result */ -} - -/* post order a forest */ -int *cs_post (int n, const int *parent) -{ - int j, k = 0, *post, *w, *head, *next, *stack ; - if (!parent) return (NULL) ; /* check inputs */ - post = cs_malloc (n, sizeof (int)) ; /* allocate result */ - w = cs_malloc (3*n, sizeof (int)) ; /* 3*n workspace */ - head = w ; next = w + n ; stack = w + 2*n ; - if (!w || !post) return (cs_idone (post, NULL, w, 0)) ; - for (j = 0 ; j < n ; j++) head [j] = -1 ; /* empty link lists */ - for (j = n-1 ; j >= 0 ; j--) /* traverse nodes in reverse order*/ - { - if (parent [j] == -1) continue ; /* j is a root */ - next [j] = head [parent [j]] ; /* add j to list of its parent */ - head [parent [j]] = j ; - } - for (j = 0 ; j < n ; j++) - { - if (parent [j] != -1) continue ; /* skip j if it is not a root */ - k = cs_tdfs (j, k, head, next, post, stack) ; - } - return (cs_idone (post, NULL, w, 1)) ; /* success; free w, return post */ -} - -/* print a sparse matrix */ -int cs_print (const cs *A, int brief) -{ - int p, j, m, n, nzmax, nz, *Ap, *Ai ; - double *Ax ; - if (!A) { printf ("(null)\n") ; return (0) ; } - m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - nzmax = A->nzmax ; nz = A->nz ; - printf ("CSparse Version %d.%d.%d, %s. %s\n", CS_VER, CS_SUBVER, - CS_SUBSUB, CS_DATE, CS_COPYRIGHT) ; - if (nz < 0) - { - printf ("%d-by-%d, nzmax: %d nnz: %d, 1-norm: %g\n", m, n, nzmax, - Ap [n], cs_norm (A)) ; - for (j = 0 ; j < n ; j++) - { - printf (" col %d : locations %d to %d\n", j, Ap [j], Ap [j+1]-1); - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - printf (" %d : %g\n", Ai [p], Ax ? Ax [p] : 1) ; - if (brief && p > 20) { printf (" ...\n") ; return (1) ; } - } - } - } - else - { - printf ("triplet: %d-by-%d, nzmax: %d nnz: %d\n", m, n, nzmax, nz) ; - for (p = 0 ; p < nz ; p++) - { - printf (" %d %d : %g\n", Ai [p], Ap [p], Ax ? Ax [p] : 1) ; - if (brief && p > 20) { printf (" ...\n") ; return (1) ; } - } - } - return (1) ; -} - -/* x = b(P), for dense vectors x and b; P=NULL denotes identity */ -int cs_pvec (int n, const int *P, const double *b, double *x) -{ - int k ; - if (!x || !b) return (0) ; /* check inputs */ - for (k = 0 ; k < n ; k++) x [k] = b [P ? P [k] : k] ; - return (1) ; -} - -/* sparse QR factorization [V,beta,p,R] = qr (A) */ -csn *cs_qr (const cs *A, const css *S) -{ - double *Rx, *Vx, *Ax, *Beta, *x ; - int i, k, p, m, n, vnz, p1, top, m2, len, col, rnz, *s, *leftmost, *Ap, - *Ai, *parent, *Rp, *Ri, *Vp, *Vi, *w, *Pinv, *Q ; - cs *R, *V ; - csn *N ; - if (!A || !S || !S->parent || !S->Pinv) return (NULL) ; /* check inputs */ - m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - Q = S->Q ; parent = S->parent ; Pinv = S->Pinv ; m2 = S->m2 ; - vnz = S->lnz ; rnz = S->unz ; - leftmost = Pinv + m + n ; - w = cs_malloc (m2+n, sizeof (int)) ; - x = cs_malloc (m2, sizeof (double)) ; - N = cs_calloc (1, sizeof (csn)) ; - if (!w || !x || !N) return (cs_ndone (N, NULL, w, x, 0)) ; - s = w + m2 ; /* size n */ - for (k = 0 ; k < m2 ; k++) x [k] = 0 ; /* clear workspace x */ - N->L = V = cs_spalloc (m2, n, vnz, 1, 0) ; /* allocate V */ - N->U = R = cs_spalloc (m2, n, rnz, 1, 0) ; /* allocate R, m2-by-n */ - N->B = Beta = cs_malloc (n, sizeof (double)) ; - if (!R || !V || !Beta) return (cs_ndone (N, NULL, w, x, 0)) ; - Rp = R->p ; Ri = R->i ; Rx = R->x ; - Vp = V->p ; Vi = V->i ; Vx = V->x ; - for (i = 0 ; i < m2 ; i++) w [i] = -1 ; /* clear w, to mark nodes */ - rnz = 0 ; vnz = 0 ; - for (k = 0 ; k < n ; k++) /* compute V and R */ - { - Rp [k] = rnz ; /* R(:,k) starts here */ - Vp [k] = p1 = vnz ; /* V(:,k) starts here */ - w [k] = k ; /* add V(k,k) to pattern of V */ - Vi [vnz++] = k ; - top = n ; - col = Q ? Q [k] : k ; - for (p = Ap [col] ; p < Ap [col+1] ; p++) /* find R(:,k) pattern */ - { - i = leftmost [Ai [p]] ; /* i = min(find(A(i,Q))) */ - for (len = 0 ; w [i] != k ; i = parent [i]) /* traverse up to k */ - { - s [len++] = i ; - w [i] = k ; - } - while (len > 0) s [--top] = s [--len] ; /* push path on stack */ - i = Pinv [Ai [p]] ; /* i = permuted row of A(:,col) */ - x [i] = Ax [p] ; /* x (i) = A(.,col) */ - if (i > k && w [i] < k) /* pattern of V(:,k) = x (k+1:m) */ - { - Vi [vnz++] = i ; /* add i to pattern of V(:,k) */ - w [i] = k ; - } - } - for (p = top ; p < n ; p++) /* for each i in pattern of R(:,k) */ - { - i = s [p] ; /* R(i,k) is nonzero */ - cs_happly (V, i, Beta [i], x) ; /* apply (V(i),Beta(i)) to x */ - Ri [rnz] = i ; /* R(i,k) = x(i) */ - Rx [rnz++] = x [i] ; - x [i] = 0 ; - if (parent [i] == k) vnz = cs_scatter (V, i, 0, w, NULL, k, V, vnz); - } - for (p = p1 ; p < vnz ; p++) /* gather V(:,k) = x */ - { - Vx [p] = x [Vi [p]] ; - x [Vi [p]] = 0 ; - } - Ri [rnz] = k ; /* R(k,k) = norm (x) */ - Rx [rnz++] = cs_house (Vx+p1, Beta+k, vnz-p1) ; /* [v,beta]=house(x) */ - } - Rp [n] = rnz ; /* finalize R */ - Vp [n] = vnz ; /* finalize V */ - return (cs_ndone (N, NULL, w, x, 1)) ; /* success */ -} - -/* x=A\b where A can be rectangular; b overwritten with solution */ -int cs_qrsol (const cs *A, double *b, int order) -{ - double *x ; - css *S ; - csn *N ; - cs *AT = NULL ; - int k, m, n, ok ; - if (!A || !b) return (0) ; /* check inputs */ - n = A->n ; - m = A->m ; - if (m >= n) - { - S = cs_sqr (A, order, 1) ; /* ordering and symbolic analysis */ - N = cs_qr (A, S) ; /* numeric QR factorization */ - x = cs_calloc (S ? S->m2 : 1, sizeof (double)) ; - ok = (S && N && x) ; - if (ok) - { - cs_ipvec (m, S->Pinv, b, x) ; /* x(0:m-1) = P*b(0:m-1) */ - for (k = 0 ; k < n ; k++) /* apply Householder refl. to x */ - { - cs_happly (N->L, k, N->B [k], x) ; - } - cs_usolve (N->U, x) ; /* x = R\x */ - cs_ipvec (n, S->Q, x, b) ; /* b(0:n-1) = Q*x (permutation) */ - } - } - else - { - AT = cs_transpose (A, 1) ; /* Ax=b is underdetermined */ - S = cs_sqr (AT, order, 1) ; /* ordering and symbolic analysis */ - N = cs_qr (AT, S) ; /* numeric QR factorization of A' */ - x = cs_calloc (S ? S->m2 : 1, sizeof (double)) ; - ok = (AT && S && N && x) ; - if (ok) - { - cs_pvec (m, S->Q, b, x) ; /* x(0:m-1) = Q'*b (permutation) */ - cs_utsolve (N->U, x) ; /* x = R'\x */ - for (k = m-1 ; k >= 0 ; k--) /* apply Householder refl. to x */ - { - cs_happly (N->L, k, N->B [k], x) ; - } - cs_pvec (n, S->Pinv, x, b) ; /* b (0:n-1) = P'*x */ - } - } - cs_free (x) ; - cs_sfree (S) ; - cs_nfree (N) ; - cs_spfree (AT) ; - return (ok) ; -} - -/* xi [top...n-1] = nodes reachable from graph of L*P' via nodes in B(:,k). - * xi [n...2n-1] used as workspace */ -int cs_reach (cs *L, const cs *B, int k, int *xi, const int *Pinv) -{ - int p, n, top, *Bp, *Bi, *Lp ; - if (!L || !B || !xi) return (-1) ; - n = L->n ; Bp = B->p ; Bi = B->i ; Lp = L->p ; - top = n ; - for (p = Bp [k] ; p < Bp [k+1] ; p++) - { - if (!CS_MARKED (Lp, Bi [p])) /* start a dfs at unmarked node i */ - { - top = cs_dfs (Bi [p], L, top, xi, xi+n, Pinv) ; - } - } - for (p = top ; p < n ; p++) CS_MARK (Lp, xi [p]) ; /* restore L */ - return (top) ; -} - -/* x = x + beta * A(:,j), where x is a dense vector and A(:,j) is sparse */ -int cs_scatter (const cs *A, int j, double beta, int *w, double *x, int mark, - cs *C, int nz) -{ - int i, p, *Ap, *Ai, *Ci ; - double *Ax ; - if (!A || !w || !C) return (-1) ; /* ensure inputs are valid */ - Ap = A->p ; Ai = A->i ; Ax = A->x ; Ci = C->i ; - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - i = Ai [p] ; /* A(i,j) is nonzero */ - if (w [i] < mark) - { - w [i] = mark ; /* i is new entry in column j */ - Ci [nz++] = i ; /* add i to pattern of C(:,j) */ - if (x) x [i] = beta * Ax [p] ; /* x(i) = beta*A(i,j) */ - } - else if (x) x [i] += beta * Ax [p] ; /* i exists in C(:,j) already */ - } - return (nz) ; -} - -/* find the strongly connected components of a square matrix */ -csd *cs_scc (cs *A) /* matrix A temporarily modified, then restored */ -{ - int n, i, k, b = 0, top, *xi, *pstack, *P, *R, *Ap, *ATp ; - cs *AT ; - csd *D ; - if (!A) return (NULL) ; - n = A->n ; Ap = A->p ; - D = cs_dalloc (n, 0) ; - AT = cs_transpose (A, 0) ; /* AT = A' */ - xi = cs_malloc (2*n, sizeof (int)) ; /* allocate workspace */ - pstack = xi + n ; - if (!D || !AT || !xi) return (cs_ddone (D, AT, xi, 0)) ; - P = D->P ; R = D->R ; ATp = AT->p ; - top = n ; - for (i = 0 ; i < n ; i++) /* first dfs(A) to find finish times (xi) */ - { - if (!CS_MARKED (Ap,i)) top = cs_dfs (i, A, top, xi, pstack, NULL) ; - } - for (i = 0 ; i < n ; i++) CS_MARK (Ap, i) ; /* restore A; unmark all nodes*/ - top = n ; - b = n ; - for (k = 0 ; k < n ; k++) /* dfs(A') to find strongly connnected comp. */ - { - i = xi [k] ; /* get i in reverse order of finish times */ - if (CS_MARKED (ATp,i)) continue ; /* skip node i if already ordered */ - R [b--] = top ; /* node i is the start of a component in P */ - top = cs_dfs (i, AT, top, P, pstack, NULL) ; - } - R [b] = 0 ; /* first block starts at zero; shift R up */ - for (k = b ; k <= n ; k++) R [k-b] = R [k] ; - D->nb = R [n+1] = b = n-b ; /* b = # of strongly connected components */ - return (cs_ddone (D, AT, xi, 1)) ; -} - -/* ordering and symbolic analysis for a Cholesky factorization */ -css *cs_schol (const cs *A, int order) -{ - int n, *c, *post, *P ; - cs *C ; - css *S ; - if (!A) return (NULL) ; /* check inputs */ - n = A->n ; - S = cs_calloc (1, sizeof (css)) ; /* allocate symbolic analysis */ - if (!S) return (NULL) ; /* out of memory */ - P = cs_amd (A, order) ; /* P = amd(A+A'), or natural */ - S->Pinv = cs_pinv (P, n) ; /* find inverse permutation */ - cs_free (P) ; - if (order >= 0 && !S->Pinv) return (cs_sfree (S)) ; - C = cs_symperm (A, S->Pinv, 0) ; /* C = spones(triu(A(P,P))) */ - S->parent = cs_etree (C, 0) ; /* find etree of C */ - post = cs_post (n, S->parent) ; /* postorder the etree */ - c = cs_counts (C, S->parent, post, 0) ; /* find column counts of chol(C) */ - cs_free (post) ; - cs_spfree (C) ; - S->cp = cs_malloc (n+1, sizeof (int)) ; /* find column pointers for L */ - S->unz = S->lnz = cs_cumsum (S->cp, c, n) ; - cs_free (c) ; - return ((S->lnz >= 0) ? S : cs_sfree (S)) ; -} - -/* solve Lx=b(:,k), leaving pattern in xi[top..n-1], values scattered in x. */ -int cs_splsolve (cs *L, const cs *B, int k, int *xi, double *x, const int *Pinv) -{ - int j, jnew, p, px, top, n, *Lp, *Li, *Bp, *Bi ; - double *Lx, *Bx ; - if (!L || !B || !xi || !x) return (-1) ; - Lp = L->p ; Li = L->i ; Lx = L->x ; n = L->n ; - Bp = B->p ; Bi = B->i ; Bx = B->x ; - top = cs_reach (L, B, k, xi, Pinv) ; /* xi[top..n-1]=Reach(B(:,k)) */ - for (p = top ; p < n ; p++) x [xi [p]] = 0 ;/* clear x */ - for (p = Bp [k] ; p < Bp [k+1] ; p++) x [Bi [p]] = Bx [p] ; /* scatter B */ - for (px = top ; px < n ; px++) - { - j = xi [px] ; /* x(j) is nonzero */ - jnew = Pinv ? (Pinv [j]) : j ; /* j is column jnew of L */ - if (jnew < 0) continue ; /* column jnew is empty */ - for (p = Lp [jnew]+1 ; p < Lp [jnew+1] ; p++) - { - x [Li [p]] -= Lx [p] * x [j] ; /* x(i) -= L(i,j) * x(j) */ - } - } - return (top) ; /* return top of stack */ -} - -/* compute vnz, Pinv, leftmost, m2 from A and parent */ -static int *cs_vcount (const cs *A, const int *parent, int *m2, int *vnz) -{ - int i, k, p, pa, n = A->n, m = A->m, *Ap = A->p, *Ai = A->i ; - int *Pinv = cs_malloc (2*m+n, sizeof (int)), *leftmost = Pinv + m + n ; - int *w = cs_malloc (m+3*n, sizeof (int)) ; - int *next = w, *head = w + m, *tail = w + m + n, *nque = w + m + 2*n ; - if (!Pinv || !w) return (cs_idone (Pinv, NULL, w, 0)) ; - for (k = 0 ; k < n ; k++) head [k] = -1 ; /* queue k is empty */ - for (k = 0 ; k < n ; k++) tail [k] = -1 ; - for (k = 0 ; k < n ; k++) nque [k] = 0 ; - for (i = 0 ; i < m ; i++) leftmost [i] = -1 ; - for (k = n-1 ; k >= 0 ; k--) - { - for (p = Ap [k] ; p < Ap [k+1] ; p++) - { - leftmost [Ai [p]] = k ; /* leftmost[i] = min(find(A(i,:)))*/ - } - } - for (i = m-1 ; i >= 0 ; i--) /* scan rows in reverse order */ - { - Pinv [i] = -1 ; /* row i is not yet ordered */ - k = leftmost [i] ; - if (k == -1) continue ; /* row i is empty */ - if (nque [k]++ == 0) tail [k] = i ; /* first row in queue k */ - next [i] = head [k] ; /* put i at head of queue k */ - head [k] = i ; - } - (*vnz) = 0 ; - (*m2) = m ; - for (k = 0 ; k < n ; k++) /* find row permutation and nnz(V)*/ - { - i = head [k] ; /* remove row i from queue k */ - (*vnz)++ ; /* count V(k,k) as nonzero */ - if (i < 0) i = (*m2)++ ; /* add a fictitious row */ - Pinv [i] = k ; /* associate row i with V(:,k) */ - if (--nque [k] <= 0) continue ; /* skip if V(k+1:m,k) is empty */ - (*vnz) += nque [k] ; /* nque [k] = nnz (V(k+1:m,k)) */ - if ((pa = parent [k]) != -1) /* move all rows to parent of k */ - { - if (nque [pa] == 0) tail [pa] = tail [k] ; - next [tail [k]] = head [pa] ; - head [pa] = next [i] ; - nque [pa] += nque [k] ; - } - } - for (i = 0 ; i < m ; i++) if (Pinv [i] < 0) Pinv [i] = k++ ; - return (cs_idone (Pinv, NULL, w, 1)) ; -} - -/* symbolic analysis for QR or LU */ -css *cs_sqr (const cs *A, int order, int qr) -{ - int n, k, ok = 1, *post ; - css *S ; - if (!A) return (NULL) ; /* check inputs */ - n = A->n ; - S = cs_calloc (1, sizeof (css)) ; /* allocate symbolic analysis */ - if (!S) return (NULL) ; /* out of memory */ - S->Q = cs_amd (A, order) ; /* fill-reducing ordering */ - if (order >= 0 && !S->Q) return (cs_sfree (S)) ; - if (qr) /* QR symbolic analysis */ - { - cs *C = (order >= 0) ? cs_permute (A, NULL, S->Q, 0) : ((cs *) A) ; - S->parent = cs_etree (C, 1) ; /* etree of C'*C, where C=A(:,Q) */ - post = cs_post (n, S->parent) ; - S->cp = cs_counts (C, S->parent, post, 1) ; /* col counts chol(C'*C) */ - cs_free (post) ; - ok = C && S->parent && S->cp ; - if (ok) S->Pinv = cs_vcount (C, S->parent, &(S->m2), &(S->lnz)) ; - ok = ok && S->Pinv ; - if (ok) for (S->unz = 0, k = 0 ; k < n ; k++) S->unz += S->cp [k] ; - if (order >= 0) cs_spfree (C) ; - } - else - { - S->unz = 4*(A->p [n]) + n ; /* for LU factorization only, */ - S->lnz = S->unz ; /* guess nnz(L) and nnz(U) */ - } - return (ok ? S : cs_sfree (S)) ; -} - -/* C = A(p,p) where A and C are symmetric the upper part stored, Pinv not P */ -cs *cs_symperm (const cs *A, const int *Pinv, int values) -{ - int i, j, p, q, i2, j2, n, *Ap, *Ai, *Cp, *Ci, *w ; - double *Cx, *Ax ; - cs *C ; - if (!A) return (NULL) ; - n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - C = cs_spalloc (n, n, Ap [n], values && (Ax != NULL), 0) ; - w = cs_calloc (n, sizeof (int)) ; - if (!C || !w) return (cs_done (C, w, NULL, 0)) ; /* out of memory */ - Cp = C->p ; Ci = C->i ; Cx = C->x ; - for (j = 0 ; j < n ; j++) /* count entries in each column of C */ - { - j2 = Pinv ? Pinv [j] : j ; /* column j of A is column j2 of C */ - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - i = Ai [p] ; - if (i > j) continue ; /* skip lower triangular part of A */ - i2 = Pinv ? Pinv [i] : i ; /* row i of A is row i2 of C */ - w [CS_MAX (i2, j2)]++ ; /* column count of C */ - } - } - cs_cumsum (Cp, w, n) ; /* compute column pointers of C */ - for (j = 0 ; j < n ; j++) - { - j2 = Pinv ? Pinv [j] : j ; /* column j of A is column j2 of C */ - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - i = Ai [p] ; - if (i > j) continue ; /* skip lower triangular part of A*/ - i2 = Pinv ? Pinv [i] : i ; /* row i of A is row i2 of C */ - Ci [q = w [CS_MAX (i2, j2)]++] = CS_MIN (i2, j2) ; - if (Cx) Cx [q] = Ax [p] ; - } - } - return (cs_done (C, w, NULL, 1)) ; /* success; free workspace, return C */ -} - -/* depth-first search and postorder of a tree rooted at node j */ -int cs_tdfs (int j, int k, int *head, const int *next, int *post, int *stack) -{ - int i, p, top = 0 ; - if (!head || !next || !post || !stack) return (-1) ; /* check inputs */ - stack [0] = j ; /* place j on the stack */ - while (top >= 0) /* while (stack is not empty) */ - { - p = stack [top] ; /* p = top of stack */ - i = head [p] ; /* i = youngest child of p */ - if (i == -1) - { - top-- ; /* p has no unordered children left */ - post [k++] = p ; /* node p is the kth postordered node */ - } - else - { - head [p] = next [i] ; /* remove i from children of p */ - stack [++top] = i ; /* start dfs on child node i */ - } - } - return (k) ; -} - -/* C = A' */ -cs *cs_transpose (const cs *A, int values) -{ - int p, q, j, *Cp, *Ci, n, m, *Ap, *Ai, *w ; - double *Cx, *Ax ; - cs *C ; - if (!A) return (NULL) ; - m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; - C = cs_spalloc (n, m, Ap [n], values && Ax, 0) ; /* allocate result */ - w = cs_calloc (m, sizeof (int)) ; - if (!C || !w) return (cs_done (C, w, NULL, 0)) ; /* out of memory */ - Cp = C->p ; Ci = C->i ; Cx = C->x ; - for (p = 0 ; p < Ap [n] ; p++) w [Ai [p]]++ ; /* row counts */ - cs_cumsum (Cp, w, m) ; /* row pointers */ - for (j = 0 ; j < n ; j++) - { - for (p = Ap [j] ; p < Ap [j+1] ; p++) - { - Ci [q = w [Ai [p]]++] = j ; /* place A(i,j) as entry C(j,i) */ - if (Cx) Cx [q] = Ax [p] ; - } - } - return (cs_done (C, w, NULL, 1)) ; /* success; free w and return C */ -} - -/* C = compressed-column form of a triplet matrix T */ -cs *cs_triplet (const cs *T) -{ - int m, n, nz, p, k, *Cp, *Ci, *w, *Ti, *Tj ; - double *Cx, *Tx ; - cs *C ; - if (!T) return (NULL) ; /* check inputs */ - m = T->m ; n = T->n ; Ti = T->i ; Tj = T->p ; Tx = T->x ; nz = T->nz ; - C = cs_spalloc (m, n, nz, Tx != NULL, 0) ; /* allocate result */ - w = cs_calloc (n, sizeof (int)) ; /* get workspace */ - if (!C || !w) return (cs_done (C, w, NULL, 0)) ; /* out of memory */ - Cp = C->p ; Ci = C->i ; Cx = C->x ; - for (k = 0 ; k < nz ; k++) w [Tj [k]]++ ; /* column counts */ - cs_cumsum (Cp, w, n) ; /* column pointers */ - for (k = 0 ; k < nz ; k++) - { - Ci [p = w [Tj [k]]++] = Ti [k] ; /* A(i,j) is the pth entry in C */ - if (Cx) Cx [p] = Tx [k] ; - } - return (cs_done (C, w, NULL, 1)) ; /* success; free w and return C */ -} - -/* sparse Cholesky update/downdate, L*L' + sigma*w*w' (sigma = +1 or -1) */ -int cs_updown (cs *L, int sigma, const cs *C, const int *parent) -{ - int p, f, j, n, *Lp, *Li, *Cp, *Ci ; - double *Lx, *Cx, alpha, beta = 1, delta, gamma, w1, w2, *w, beta2 = 1 ; - if (!L || !C || !parent) return (0) ; - Lp = L->p ; Li = L->i ; Lx = L->x ; n = L->n ; - Cp = C->p ; Ci = C->i ; Cx = C->x ; - if ((p = Cp [0]) >= Cp [1]) return (1) ; /* return if C empty */ - w = cs_malloc (n, sizeof (double)) ; - if (!w) return (0) ; - f = Ci [p] ; - for ( ; p < Cp [1] ; p++) f = CS_MIN (f, Ci [p]) ; /* f = min (find (C)) */ - for (j = f ; j != -1 ; j = parent [j]) w [j] = 0 ; /* clear workspace w */ - for (p = Cp [0] ; p < Cp [1] ; p++) w [Ci [p]] = Cx [p] ; /* w = C */ - for (j = f ; j != -1 ; j = parent [j]) /* walk path f up to root */ - { - p = Lp [j] ; - alpha = w [j] / Lx [p] ; /* alpha = w(j) / L(j,j) */ - beta2 = beta*beta + sigma*alpha*alpha ; - if (beta2 <= 0) break ; /* not positive definite */ - beta2 = sqrt (beta2) ; - delta = (sigma > 0) ? (beta / beta2) : (beta2 / beta) ; - gamma = sigma * alpha / (beta2 * beta) ; - Lx [p] = delta * Lx [p] + ((sigma > 0) ? (gamma * w [j]) : 0) ; - beta = beta2 ; - for (p++ ; p < Lp [j+1] ; p++) - { - w1 = w [Li [p]] ; - w [Li [p]] = w2 = w1 - alpha * Lx [p] ; - Lx [p] = delta * Lx [p] + gamma * ((sigma > 0) ? w1 : w2) ; - } - } - cs_free (w) ; - return (beta2 > 0) ; -} - -/* solve Ux=b where x and b are dense. x=b on input, solution on output. */ -int cs_usolve (const cs *U, double *x) -{ - int p, j, n, *Up, *Ui ; - double *Ux ; - if (!U || !x) return (0) ; /* check inputs */ - n = U->n ; Up = U->p ; Ui = U->i ; Ux = U->x ; - for (j = n-1 ; j >= 0 ; j--) - { - x [j] /= Ux [Up [j+1]-1] ; - for (p = Up [j] ; p < Up [j+1]-1 ; p++) - { - x [Ui [p]] -= Ux [p] * x [j] ; - } - } - return (1) ; -} - -/* allocate a sparse matrix (triplet form or compressed-column form) */ -cs *cs_spalloc (int m, int n, int nzmax, int values, int triplet) -{ - cs *A = cs_calloc (1, sizeof (cs)) ; /* allocate the cs struct */ - if (!A) return (NULL) ; /* out of memory */ - A->m = m ; /* define dimensions and nzmax */ - A->n = n ; - A->nzmax = nzmax = CS_MAX (nzmax, 1) ; - A->nz = triplet ? 0 : -1 ; /* allocate triplet or comp.col */ - A->p = cs_malloc (triplet ? nzmax : n+1, sizeof (int)) ; - A->i = cs_malloc (nzmax, sizeof (int)) ; - A->x = values ? cs_malloc (nzmax, sizeof (double)) : NULL ; - return ((!A->p || !A->i || (values && !A->x)) ? cs_spfree (A) : A) ; -} - -/* change the max # of entries sparse matrix */ -int cs_sprealloc (cs *A, int nzmax) -{ - int ok, oki, okj = 1, okx = 1 ; - if (!A) return (0) ; - nzmax = (nzmax <= 0) ? (A->p [A->n]) : nzmax ; - A->i = cs_realloc (A->i, nzmax, sizeof (int), &oki) ; - if (A->nz >= 0) A->p = cs_realloc (A->p, nzmax, sizeof (int), &okj) ; - if (A->x) A->x = cs_realloc (A->x, nzmax, sizeof (double), &okx) ; - ok = (oki && okj && okx) ; - if (ok) A->nzmax = nzmax ; - return (ok) ; -} - -/* free a sparse matrix */ -cs *cs_spfree (cs *A) -{ - if (!A) return (NULL) ; /* do nothing if A already NULL */ - cs_free (A->p) ; - cs_free (A->i) ; - cs_free (A->x) ; - return (cs_free (A)) ; /* free the cs struct and return NULL */ -} - -/* free a numeric factorization */ -csn *cs_nfree (csn *N) -{ - if (!N) return (NULL) ; /* do nothing if N already NULL */ - cs_spfree (N->L) ; - cs_spfree (N->U) ; - cs_free (N->Pinv) ; - cs_free (N->B) ; - return (cs_free (N)) ; /* free the csn struct and return NULL */ -} - -/* free a symbolic factorization */ -css *cs_sfree (css *S) -{ - if (!S) return (NULL) ; /* do nothing if S already NULL */ - cs_free (S->Pinv) ; - cs_free (S->Q) ; - cs_free (S->parent) ; - cs_free (S->cp) ; - return (cs_free (S)) ; /* free the css struct and return NULL */ -} - -/* allocate a cs_dmperm or cs_scc result */ -csd *cs_dalloc (int m, int n) -{ - csd *D ; - D = cs_calloc (1, sizeof (csd)) ; - if (!D) return (NULL) ; - D->P = cs_malloc (m, sizeof (int)) ; - D->R = cs_malloc (m+6, sizeof (int)) ; - D->Q = cs_malloc (n, sizeof (int)) ; - D->S = cs_malloc (n+6, sizeof (int)) ; - return ((!D->P || !D->R || !D->Q || !D->S) ? cs_dfree (D) : D) ; -} - -/* free a cs_dmperm or cs_scc result */ -csd *cs_dfree (csd *D) -{ - if (!D) return (NULL) ; /* do nothing if D already NULL */ - cs_free (D->P) ; - cs_free (D->Q) ; - cs_free (D->R) ; - cs_free (D->S) ; - return (cs_free (D)) ; -} - -/* free workspace and return a sparse matrix result */ -cs *cs_done (cs *C, void *w, void *x, int ok) -{ - cs_free (w) ; /* free workspace */ - cs_free (x) ; - return (ok ? C : cs_spfree (C)) ; /* return result if OK, else free it */ -} - -/* free workspace and return int array result */ -int *cs_idone (int *p, cs *C, void *w, int ok) -{ - cs_spfree (C) ; /* free temporary matrix */ - cs_free (w) ; /* free workspace */ - return (ok ? p : cs_free (p)) ; /* return result if OK, else free it */ -} - -/* free workspace and return a numeric factorization (Cholesky, LU, or QR) */ -csn *cs_ndone (csn *N, cs *C, void *w, void *x, int ok) -{ - cs_spfree (C) ; /* free temporary matrix */ - cs_free (w) ; /* free workspace */ - cs_free (x) ; - return (ok ? N : cs_nfree (N)) ; /* return result if OK, else free it */ -} - -/* free workspace and return a csd result */ -csd *cs_ddone (csd *D, cs *C, void *w, int ok) -{ - cs_spfree (C) ; /* free temporary matrix */ - cs_free (w) ; /* free workspace */ - return (ok ? D : cs_dfree (D)) ; /* return result if OK, else free it */ -} - -/* solve U'x=b where x and b are dense. x=b on input, solution on output. */ -int cs_utsolve (const cs *U, double *x) -{ - int p, j, n, *Up, *Ui ; - double *Ux ; - if (!U || !x) return (0) ; /* check inputs */ - n = U->n ; Up = U->p ; Ui = U->i ; Ux = U->x ; - for (j = 0 ; j < n ; j++) - { - for (p = Up [j] ; p < Up [j+1]-1 ; p++) - { - x [j] -= Ux [p] * x [Ui [p]] ; - } - x [j] /= Ux [p] ; - } - return (1) ; -} diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.h b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.h deleted file mode 100644 index 1c0b8e514a3..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/csparse.h +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef _CS_H -#define _CS_H - -#ifdef MATLAB_MEX_FILE -#include "mex.h" -#endif -#define CS_VER 1 /* CSparse Version 1.2.0 */ -#define CS_SUBVER 2 -#define CS_SUBSUB 0 -#define CS_DATE "Mar 6, 2006" /* CSparse release date */ -#define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006" - -#if defined(__cplusplus) -extern "C" { -#endif - -/* --- primary CSparse routines and data structures ------------------------- */ -typedef struct cs_sparse /* matrix in compressed-column or triplet form */ -{ - int nzmax ; /* maximum number of entries */ - int m ; /* number of rows */ - int n ; /* number of columns */ - int *p ; /* column pointers (size n+1) or col indices (size nzmax) */ - int *i ; /* row indices, size nzmax */ - double *x ; /* numerical values, size nzmax */ - int nz ; /* # of entries in triplet matrix, -1 for compressed-col */ -} cs ; - -cs *cs_add (const cs *A, const cs *B, double alpha, double beta) ; -int cs_cholsol (const cs *A, double *b, int order) ; -int cs_dupl (cs *A) ; -int cs_entry (cs *T, int i, int j, double x) ; -int cs_lusol (const cs *A, double *b, int order, double tol) ; -int cs_gaxpy (const cs *A, const double *x, double *y) ; -cs *cs_multiply (const cs *A, const cs *B) ; -int cs_qrsol (const cs *A, double *b, int order) ; -cs *cs_transpose (const cs *A, int values) ; -cs *cs_triplet (const cs *T) ; -double cs_norm (const cs *A) ; -int cs_print (const cs *A, int brief) ; -cs *cs_load (FILE *f) ; -/* utilities */ -void *cs_calloc (int n, size_t size) ; -void *cs_free (void *p) ; -void *cs_realloc (void *p, int n, size_t size, int *ok) ; -cs *cs_spalloc (int m, int n, int nzmax, int values, int triplet) ; -cs *cs_spfree (cs *A) ; -int cs_sprealloc (cs *A, int nzmax) ; -void *cs_malloc (int n, size_t size) ; - -/* --- secondary CSparse routines and data structures ----------------------- */ -typedef struct cs_symbolic /* symbolic Cholesky, LU, or QR analysis */ -{ - int *Pinv ; /* inverse row perm. for QR, fill red. perm for Chol */ - int *Q ; /* fill-reducing column permutation for LU and QR */ - int *parent ; /* elimination tree for Cholesky and QR */ - int *cp ; /* column pointers for Cholesky, row counts for QR */ - int m2 ; /* # of rows for QR, after adding fictitious rows */ - int lnz ; /* # entries in L for LU or Cholesky; in V for QR */ - int unz ; /* # entries in U for LU; in R for QR */ -} css ; - -typedef struct cs_numeric /* numeric Cholesky, LU, or QR factorization */ -{ - cs *L ; /* L for LU and Cholesky, V for QR */ - cs *U ; /* U for LU, R for QR, not used for Cholesky */ - int *Pinv ; /* partial pivoting for LU */ - double *B ; /* beta [0..n-1] for QR */ -} csn ; - -typedef struct cs_dmperm_results /* cs_dmperm or cs_scc output */ -{ - int *P ; /* size m, row permutation */ - int *Q ; /* size n, column permutation */ - int *R ; /* size nb+1, block k is rows R[k] to R[k+1]-1 in A(P,Q) */ - int *S ; /* size nb+1, block k is cols S[k] to S[k+1]-1 in A(P,Q) */ - int nb ; /* # of blocks in fine dmperm decomposition */ - int rr [5] ; /* coarse row decomposition */ - int cc [5] ; /* coarse column decomposition */ -} csd ; - -int *cs_amd (const cs *A, int order) ; -csn *cs_chol (const cs *A, const css *S) ; -csd *cs_dmperm (const cs *A) ; -int cs_droptol (cs *A, double tol) ; -int cs_dropzeros (cs *A) ; -int cs_happly (const cs *V, int i, double beta, double *x) ; -int cs_ipvec (int n, const int *P, const double *b, double *x) ; -int cs_lsolve (const cs *L, double *x) ; -int cs_ltsolve (const cs *L, double *x) ; -csn *cs_lu (const cs *A, const css *S, double tol) ; -cs *cs_permute (const cs *A, const int *P, const int *Q, int values) ; -int *cs_pinv (const int *P, int n) ; -int cs_pvec (int n, const int *P, const double *b, double *x) ; -csn *cs_qr (const cs *A, const css *S) ; -css *cs_schol (const cs *A, int order) ; -css *cs_sqr (const cs *A, int order, int qr) ; -cs *cs_symperm (const cs *A, const int *Pinv, int values) ; -int cs_usolve (const cs *U, double *x) ; -int cs_utsolve (const cs *U, double *x) ; -int cs_updown (cs *L, int sigma, const cs *C, const int *parent) ; -/* utilities */ -css *cs_sfree (css *S) ; -csn *cs_nfree (csn *N) ; -csd *cs_dfree (csd *D) ; - -/* --- tertiary CSparse routines -------------------------------------------- */ -int *cs_counts (const cs *A, const int *parent, const int *post, int ata) ; -int cs_cumsum (int *p, int *c, int n) ; -int cs_dfs (int j, cs *L, int top, int *xi, int *pstack, const int *Pinv) ; -int *cs_etree (const cs *A, int ata) ; -int cs_fkeep (cs *A, int (*fkeep) (int, int, double, void *), void *other) ; -double cs_house (double *x, double *beta, int n) ; -int *cs_maxtrans (const cs *A) ; -int *cs_post (int n, const int *parent) ; -int cs_reach (cs *L, const cs *B, int k, int *xi, const int *Pinv) ; -csd *cs_scc (cs *A) ; -int cs_scatter (const cs *A, int j, double beta, int *w, double *x, int mark, - cs *C, int nz) ; -int cs_splsolve (cs *L, const cs *B, int k, int *xi, double *x, - const int *Pinv) ; -int cs_tdfs (int j, int k, int *head, const int *next, int *post, - int *stack) ; -/* utilities */ -csd *cs_dalloc (int m, int n) ; -cs *cs_done (cs *C, void *w, void *x, int ok) ; -int *cs_idone (int *p, cs *C, void *w, int ok) ; -csn *cs_ndone (csn *N, cs *C, void *w, void *x, int ok) ; -csd *cs_ddone (csd *D, cs *C, void *w, int ok) ; - -#define CS_MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define CS_MIN(a,b) (((a) < (b)) ? (a) : (b)) -#define CS_FLIP(i) (-(i)-2) -#define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i)) -#define CS_MARKED(Ap,j) (Ap [j] < 0) -#define CS_MARK(Ap,j) { Ap [j] = CS_FLIP (Ap [j]) ; } -#define CS_OVERFLOW(n,size) (n > INT_MAX / (int) size) - - -#if defined(__cplusplus) -} //extern "C" -#endif - -#endif diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.c b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.c deleted file mode 100644 index a9b35c846ef..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.c +++ /dev/null @@ -1,507 +0,0 @@ -/* ========================================================================== */ -/* === ldl.c: sparse LDL' factorization and solve package =================== */ -/* ========================================================================== */ - -/* LDL: a simple set of routines for sparse LDL' factorization. These routines - * are not terrifically fast (they do not use dense matrix kernels), but the - * code is very short. The purpose is to illustrate the algorithms in a very - * concise manner, primarily for educational purposes. Although the code is - * very concise, this package is slightly faster than the built-in sparse - * Cholesky factorization in MATLAB 7.0 (chol), when using the same input - * permutation. - * - * The routines compute the LDL' factorization of a real sparse symmetric - * matrix A (or PAP' if a permutation P is supplied), and solve upper - * and lower triangular systems with the resulting L and D factors. If A is - * positive definite then the factorization will be accurate. A can be - * indefinite (with negative values on the diagonal D), but in this case no - * guarantee of accuracy is provided, since no numeric pivoting is performed. - * - * The n-by-n sparse matrix A is in compressed-column form. The nonzero values - * in column j are stored in Ax [Ap [j] ... Ap [j+1]-1], with corresponding row - * indices in Ai [Ap [j] ... Ap [j+1]-1]. Ap [0] = 0 is required, and thus - * nz = Ap [n] is the number of nonzeros in A. Ap is an int array of size n+1. - * The int array Ai and the double array Ax are of size nz. This data structure - * is identical to the one used by MATLAB, except for the following - * generalizations. The row indices in each column of A need not be in any - * particular order, although they must be in the range 0 to n-1. Duplicate - * entries can be present; any duplicates are summed. That is, if row index i - * appears twice in a column j, then the value of A (i,j) is the sum of the two - * entries. The data structure used here for the input matrix A is more - * flexible than MATLAB's, which requires sorted columns with no duplicate - * entries. - * - * Only the diagonal and upper triangular part of A (or PAP' if a permutation - * P is provided) is accessed. The lower triangular parts of the matrix A or - * PAP' can be present, but they are ignored. - * - * The optional input permutation is provided as an array P of length n. If - * P [k] = j, the row and column j of A is the kth row and column of PAP'. - * If P is present then the factorization is LDL' = PAP' or L*D*L' = A(P,P) in - * 0-based MATLAB notation. If P is not present (a null pointer) then no - * permutation is performed, and the factorization is LDL' = A. - * - * The lower triangular matrix L is stored in the same compressed-column - * form (an int Lp array of size n+1, an int Li array of size Lp [n], and a - * double array Lx of the same size as Li). It has a unit diagonal, which is - * not stored. The row indices in each column of L are always returned in - * ascending order, with no duplicate entries. This format is compatible with - * MATLAB, except that it would be more convenient for MATLAB to include the - * unit diagonal of L. Doing so here would add additional complexity to the - * code, and is thus omitted in the interest of keeping this code short and - * readable. - * - * The elimination tree is held in the Parent [0..n-1] array. It is normally - * not required by the user, but it is required by ldl_numeric. The diagonal - * matrix D is held as an array D [0..n-1] of size n. - * - * -------------------- - * C-callable routines: - * -------------------- - * - * ldl_symbolic: Given the pattern of A, computes the Lp and Parent arrays - * required by ldl_numeric. Takes time proportional to the number of - * nonzeros in L. Computes the inverse Pinv of P if P is provided. - * Also returns Lnz, the count of nonzeros in each column of L below - * the diagonal (this is not required by ldl_numeric). - * ldl_numeric: Given the pattern and numerical values of A, the Lp array, - * the Parent array, and P and Pinv if applicable, computes the - * pattern and numerical values of L and D. - * ldl_lsolve: Solves Lx=b for a dense vector b. - * ldl_dsolve: Solves Dx=b for a dense vector b. - * ldl_ltsolve: Solves L'x=b for a dense vector b. - * ldl_perm: Computes x=Pb for a dense vector b. - * ldl_permt: Computes x=P'b for a dense vector b. - * ldl_valid_perm: checks the validity of a permutation vector - * ldl_valid_matrix: checks the validity of the sparse matrix A - * - * ---------------------------- - * Limitations of this package: - * ---------------------------- - * - * In the interest of keeping this code simple and readable, ldl_symbolic and - * ldl_numeric assume their inputs are valid. You can check your own inputs - * prior to calling these routines with the ldl_valid_perm and ldl_valid_matrix - * routines. Except for the two ldl_valid_* routines, no routine checks to see - * if the array arguments are present (non-NULL). Like all C routines, no - * routine can determine if the arrays are long enough and don't overlap. - * - * The ldl_numeric does check the numerical factorization, however. It returns - * n if the factorization is successful. If D (k,k) is zero, then k is - * returned, and L is only partially computed. - * - * No pivoting to control fill-in is performed, which is often critical for - * obtaining good performance. I recommend that you compute the permutation P - * using AMD or SYMAMD (approximate minimum degree ordering routines), or an - * appropriate graph-partitioning based ordering. See the ldldemo.m routine for - * an example in MATLAB, and the ldlmain.c stand-alone C program for examples of - * how to find P. Routines for manipulating compressed-column matrices are - * available in UMFPACK. AMD, SYMAMD, UMFPACK, and this LDL package are all - * available at http://www.cise.ufl.edu/research/sparse. - * - * ------------------------- - * Possible simplifications: - * ------------------------- - * - * These routines could be made even simpler with a few additional assumptions. - * If no input permutation were performed, the caller would have to permute the - * matrix first, but the computation of Pinv, and the use of P and Pinv could be - * removed. If only the diagonal and upper triangular part of A or PAP' are - * present, then the tests in the "if (i < k)" statement in ldl_symbolic and - * "if (i <= k)" in ldl_numeric, are always true, and could be removed (i can - * equal k in ldl_symbolic, but then the body of the if statement would - * correctly do no work since Flag [k] == k). If we could assume that no - * duplicate entries are present, then the statement Y [i] += Ax [p] could be - * replaced with Y [i] = Ax [p] in ldl_numeric. - * - * -------------------------- - * Description of the method: - * -------------------------- - * - * LDL computes the symbolic factorization by finding the pattern of L one row - * at a time. It does this based on the following theory. Consider a sparse - * system Lx=b, where L, x, and b, are all sparse, and where L comes from a - * Cholesky (or LDL') factorization. The elimination tree (etree) of L is - * defined as follows. The parent of node j is the smallest k > j such that - * L (k,j) is nonzero. Node j has no parent if column j of L is completely zero - * below the diagonal (j is a root of the etree in this case). The nonzero - * pattern of x is the union of the paths from each node i to the root, for - * each nonzero b (i). To compute the numerical solution to Lx=b, we can - * traverse the columns of L corresponding to nonzero values of x. This - * traversal does not need to be done in the order 0 to n-1. It can be done in - * any "topological" order, such that x (i) is computed before x (j) if i is a - * descendant of j in the elimination tree. - * - * The row-form of the LDL' factorization is shown in the MATLAB function - * ldlrow.m in this LDL package. Note that row k of L is found via a sparse - * triangular solve of L (1:k-1, 1:k-1) \ A (1:k-1, k), to use 1-based MATLAB - * notation. Thus, we can start with the nonzero pattern of the kth column of - * A (above the diagonal), follow the paths up to the root of the etree of the - * (k-1)-by-(k-1) leading submatrix of L, and obtain the pattern of the kth row - * of L. Note that we only need the leading (k-1)-by-(k-1) submatrix of L to - * do this. The elimination tree can be constructed as we go. - * - * The symbolic factorization does the same thing, except that it discards the - * pattern of L as it is computed. It simply counts the number of nonzeros in - * each column of L and then constructs the Lp index array when it's done. The - * symbolic factorization does not need to do this in topological order. - * Compare ldl_symbolic with the first part of ldl_numeric, and note that the - * while (len > 0) loop is not present in ldl_symbolic. - * - * LDL Version 1.3, Copyright (c) 2006 by Timothy A Davis, - * University of Florida. All Rights Reserved. Developed while on sabbatical - * at Stanford University and Lawrence Berkeley National Laboratory. Refer to - * the README file for the License. Available at - * http://www.cise.ufl.edu/research/sparse. - */ - -#include "ldl.h" - -/* ========================================================================== */ -/* === ldl_symbolic ========================================================= */ -/* ========================================================================== */ - -/* The input to this routine is a sparse matrix A, stored in column form, and - * an optional permutation P. The output is the elimination tree - * and the number of nonzeros in each column of L. Parent [i] = k if k is the - * parent of i in the tree. The Parent array is required by ldl_numeric. - * Lnz [k] gives the number of nonzeros in the kth column of L, excluding the - * diagonal. - * - * One workspace vector (Flag) of size n is required. - * - * If P is NULL, then it is ignored. The factorization will be LDL' = A. - * Pinv is not computed. In this case, neither P nor Pinv are required by - * ldl_numeric. - * - * If P is not NULL, then it is assumed to be a valid permutation. If - * row and column j of A is the kth pivot, the P [k] = j. The factorization - * will be LDL' = PAP', or A (p,p) in MATLAB notation. The inverse permutation - * Pinv is computed, where Pinv [j] = k if P [k] = j. In this case, both P - * and Pinv are required as inputs to ldl_numeric. - * - * The floating-point operation count of the subsequent call to ldl_numeric - * is not returned, but could be computed after ldl_symbolic is done. It is - * the sum of (Lnz [k]) * (Lnz [k] + 2) for k = 0 to n-1. - */ - -void LDL_symbolic -( - LDL_int n, /* A and L are n-by-n, where n >= 0 */ - LDL_int Ap [ ], /* input of size n+1, not modified */ - LDL_int Ai [ ], /* input of size nz=Ap[n], not modified */ - LDL_int Lp [ ], /* output of size n+1, not defined on input */ - LDL_int Parent [ ], /* output of size n, not defined on input */ - LDL_int Lnz [ ], /* output of size n, not defined on input */ - LDL_int Flag [ ], /* workspace of size n, not defn. on input or output */ - LDL_int P [ ], /* optional input of size n */ - LDL_int Pinv [ ] /* optional output of size n (used if P is not NULL) */ -) -{ - LDL_int i, k, p, kk, p2 ; - if (P) - { - /* If P is present then compute Pinv, the inverse of P */ - for (k = 0 ; k < n ; k++) - { - Pinv [P [k]] = k ; - } - } - for (k = 0 ; k < n ; k++) - { - /* L(k,:) pattern: all nodes reachable in etree from nz in A(0:k-1,k) */ - Parent [k] = -1 ; /* parent of k is not yet known */ - Flag [k] = k ; /* mark node k as visited */ - Lnz [k] = 0 ; /* count of nonzeros in column k of L */ - kk = (P) ? (P [k]) : (k) ; /* kth original, or permuted, column */ - p2 = Ap [kk+1] ; - for (p = Ap [kk] ; p < p2 ; p++) - { - /* A (i,k) is nonzero (original or permuted A) */ - i = (Pinv) ? (Pinv [Ai [p]]) : (Ai [p]) ; - if (i < k) - { - /* follow path from i to root of etree, stop at flagged node */ - for ( ; Flag [i] != k ; i = Parent [i]) - { - /* find parent of i if not yet determined */ - if (Parent [i] == -1) Parent [i] = k ; - Lnz [i]++ ; /* L (k,i) is nonzero */ - Flag [i] = k ; /* mark i as visited */ - } - } - } - } - /* construct Lp index array from Lnz column counts */ - Lp [0] = 0 ; - for (k = 0 ; k < n ; k++) - { - Lp [k+1] = Lp [k] + Lnz [k] ; - } -} - - -/* ========================================================================== */ -/* === ldl_numeric ========================================================== */ -/* ========================================================================== */ - -/* Given a sparse matrix A (the arguments n, Ap, Ai, and Ax) and its symbolic - * analysis (Lp and Parent, and optionally P and Pinv), compute the numeric LDL' - * factorization of A or PAP'. The outputs of this routine are arguments Li, - * Lx, and D. It also requires three size-n workspaces (Y, Pattern, and Flag). - */ - -LDL_int LDL_numeric /* returns n if successful, k if D (k,k) is zero */ -( - LDL_int n, /* A and L are n-by-n, where n >= 0 */ - LDL_int Ap [ ], /* input of size n+1, not modified */ - LDL_int Ai [ ], /* input of size nz=Ap[n], not modified */ - double Ax [ ], /* input of size nz=Ap[n], not modified */ - LDL_int Lp [ ], /* input of size n+1, not modified */ - LDL_int Parent [ ], /* input of size n, not modified */ - LDL_int Lnz [ ], /* output of size n, not defn. on input */ - LDL_int Li [ ], /* output of size lnz=Lp[n], not defined on input */ - double Lx [ ], /* output of size lnz=Lp[n], not defined on input */ - double D [ ], /* output of size n, not defined on input */ - double Y [ ], /* workspace of size n, not defn. on input or output */ - LDL_int Pattern [ ],/* workspace of size n, not defn. on input or output */ - LDL_int Flag [ ], /* workspace of size n, not defn. on input or output */ - LDL_int P [ ], /* optional input of size n */ - LDL_int Pinv [ ] /* optional input of size n */ -) -{ - double yi, l_ki ; - LDL_int i, k, p, kk, p2, len, top ; - for (k = 0 ; k < n ; k++) - { - /* compute nonzero Pattern of kth row of L, in topological order */ - Y [k] = 0.0 ; /* Y(0:k) is now all zero */ - top = n ; /* stack for pattern is empty */ - Flag [k] = k ; /* mark node k as visited */ - Lnz [k] = 0 ; /* count of nonzeros in column k of L */ - kk = (P) ? (P [k]) : (k) ; /* kth original, or permuted, column */ - p2 = Ap [kk+1] ; - for (p = Ap [kk] ; p < p2 ; p++) - { - i = (Pinv) ? (Pinv [Ai [p]]) : (Ai [p]) ; /* get A(i,k) */ - if (i <= k) - { - Y [i] += Ax [p] ; /* scatter A(i,k) into Y (sum duplicates) */ - for (len = 0 ; Flag [i] != k ; i = Parent [i]) - { - Pattern [len++] = i ; /* L(k,i) is nonzero */ - Flag [i] = k ; /* mark i as visited */ - } - while (len > 0) Pattern [--top] = Pattern [--len] ; - } - } - /* compute numerical values kth row of L (a sparse triangular solve) */ - D [k] = Y [k] ; /* get D(k,k) and clear Y(k) */ - Y [k] = 0.0 ; - for ( ; top < n ; top++) - { - i = Pattern [top] ; /* Pattern [top:n-1] is pattern of L(:,k) */ - yi = Y [i] ; /* get and clear Y(i) */ - Y [i] = 0.0 ; - p2 = Lp [i] + Lnz [i] ; - for (p = Lp [i] ; p < p2 ; p++) - { - Y [Li [p]] -= Lx [p] * yi ; - } - l_ki = yi / D [i] ; /* the nonzero entry L(k,i) */ - D [k] -= l_ki * yi ; - Li [p] = k ; /* store L(k,i) in column form of L */ - Lx [p] = l_ki ; - Lnz [i]++ ; /* increment count of nonzeros in col i */ - } - if (D [k] == 0.0) return (k) ; /* failure, D(k,k) is zero */ - } - return (n) ; /* success, diagonal of D is all nonzero */ -} - - -/* ========================================================================== */ -/* === ldl_lsolve: solve Lx=b ============================================== */ -/* ========================================================================== */ - -void LDL_lsolve -( - LDL_int n, /* L is n-by-n, where n >= 0 */ - double X [ ], /* size n. right-hand-side on input, soln. on output */ - LDL_int Lp [ ], /* input of size n+1, not modified */ - LDL_int Li [ ], /* input of size lnz=Lp[n], not modified */ - double Lx [ ] /* input of size lnz=Lp[n], not modified */ -) -{ - LDL_int j, p, p2 ; - for (j = 0 ; j < n ; j++) - { - p2 = Lp [j+1] ; - for (p = Lp [j] ; p < p2 ; p++) - { - X [Li [p]] -= Lx [p] * X [j] ; - } - } -} - - -/* ========================================================================== */ -/* === ldl_dsolve: solve Dx=b ============================================== */ -/* ========================================================================== */ - -void LDL_dsolve -( - LDL_int n, /* D is n-by-n, where n >= 0 */ - double X [ ], /* size n. right-hand-side on input, soln. on output */ - double D [ ] /* input of size n, not modified */ -) -{ - LDL_int j ; - for (j = 0 ; j < n ; j++) - { - X [j] /= D [j] ; - } -} - - -/* ========================================================================== */ -/* === ldl_ltsolve: solve L'x=b ============================================ */ -/* ========================================================================== */ - -void LDL_ltsolve -( - LDL_int n, /* L is n-by-n, where n >= 0 */ - double X [ ], /* size n. right-hand-side on input, soln. on output */ - LDL_int Lp [ ], /* input of size n+1, not modified */ - LDL_int Li [ ], /* input of size lnz=Lp[n], not modified */ - double Lx [ ] /* input of size lnz=Lp[n], not modified */ -) -{ - int j, p, p2 ; - for (j = n-1 ; j >= 0 ; j--) - { - p2 = Lp [j+1] ; - for (p = Lp [j] ; p < p2 ; p++) - { - X [j] -= Lx [p] * X [Li [p]] ; - } - } -} - - -/* ========================================================================== */ -/* === ldl_perm: permute a vector, x=Pb ===================================== */ -/* ========================================================================== */ - -void LDL_perm -( - LDL_int n, /* size of X, B, and P */ - double X [ ], /* output of size n. */ - double B [ ], /* input of size n. */ - LDL_int P [ ] /* input permutation array of size n. */ -) -{ - LDL_int j ; - for (j = 0 ; j < n ; j++) - { - X [j] = B [P [j]] ; - } -} - - -/* ========================================================================== */ -/* === ldl_permt: permute a vector, x=P'b =================================== */ -/* ========================================================================== */ - -void LDL_permt -( - LDL_int n, /* size of X, B, and P */ - double X [ ], /* output of size n. */ - double B [ ], /* input of size n. */ - LDL_int P [ ] /* input permutation array of size n. */ -) -{ - LDL_int j ; - for (j = 0 ; j < n ; j++) - { - X [P [j]] = B [j] ; - } -} - - -/* ========================================================================== */ -/* === ldl_valid_perm: check if a permutation vector is valid =============== */ -/* ========================================================================== */ - -LDL_int LDL_valid_perm /* returns 1 if valid, 0 otherwise */ -( - LDL_int n, - LDL_int P [ ], /* input of size n, a permutation of 0:n-1 */ - LDL_int Flag [ ] /* workspace of size n */ -) -{ - LDL_int j, k ; - if (n < 0 || !Flag) - { - return (0) ; /* n must be >= 0, and Flag must be present */ - } - if (!P) - { - return (1) ; /* If NULL, P is assumed to be the identity perm. */ - } - for (j = 0 ; j < n ; j++) - { - Flag [j] = 0 ; /* clear the Flag array */ - } - for (k = 0 ; k < n ; k++) - { - j = P [k] ; - if (j < 0 || j >= n || Flag [j] != 0) - { - return (0) ; /* P is not valid */ - } - Flag [j] = 1 ; - } - return (1) ; /* P is valid */ -} - - -/* ========================================================================== */ -/* === ldl_valid_matrix: check if a sparse matrix is valid ================== */ -/* ========================================================================== */ - -/* This routine checks to see if a sparse matrix A is valid for input to - * ldl_symbolic and ldl_numeric. It returns 1 if the matrix is valid, 0 - * otherwise. A is in sparse column form. The numerical values in column j - * are stored in Ax [Ap [j] ... Ap [j+1]-1], with row indices in - * Ai [Ap [j] ... Ap [j+1]-1]. The Ax array is not checked. - */ - -LDL_int LDL_valid_matrix -( - LDL_int n, - LDL_int Ap [ ], - LDL_int Ai [ ] -) -{ - LDL_int j, p ; - if (n < 0 || !Ap || !Ai || Ap [0] != 0) - { - return (0) ; /* n must be >= 0, and Ap and Ai must be present */ - } - for (j = 0 ; j < n ; j++) - { - if (Ap [j] > Ap [j+1]) - { - return (0) ; /* Ap must be monotonically nondecreasing */ - } - } - for (p = 0 ; p < Ap [n] ; p++) - { - if (Ai [p] < 0 || Ai [p] >= n) - { - return (0) ; /* row indices must be in the range 0 to n-1 */ - } - } - return (1) ; /* matrix is valid */ -} diff --git a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.h b/Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.h deleted file mode 100644 index 64d3dbb2d2e..00000000000 --- a/Sofa/Component/LinearSolver/Direct/extlibs/csparse/ldl.h +++ /dev/null @@ -1,111 +0,0 @@ -/* ========================================================================== */ -/* === ldl.h: include file for the LDL package ============================= */ -/* ========================================================================== */ - -/* LDL Copyright (c) Timothy A Davis, - * University of Florida. All Rights Reserved. See README for the License. - */ - -#include "UFconfig.h" - -#ifdef LDL_LONG -#define LDL_int UF_long -#define LDL_ID UF_long_id - -#define LDL_symbolic ldl_l_symbolic -#define LDL_numeric ldl_l_numeric -#define LDL_lsolve ldl_l_lsolve -#define LDL_dsolve ldl_l_dsolve -#define LDL_ltsolve ldl_l_ltsolve -#define LDL_perm ldl_l_perm -#define LDL_permt ldl_l_permt -#define LDL_valid_perm ldl_l_valid_perm -#define LDL_valid_matrix ldl_l_valid_matrix - -#else -#define LDL_int int -#define LDL_ID "%d" - -#define LDL_symbolic ldl_symbolic -#define LDL_numeric ldl_numeric -#define LDL_lsolve ldl_lsolve -#define LDL_dsolve ldl_dsolve -#define LDL_ltsolve ldl_ltsolve -#define LDL_perm ldl_perm -#define LDL_permt ldl_permt -#define LDL_valid_perm ldl_valid_perm -#define LDL_valid_matrix ldl_valid_matrix - -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -/* ========================================================================== */ -/* === int version ========================================================== */ -/* ========================================================================== */ - -void ldl_symbolic (int n, int Ap [ ], int Ai [ ], int Lp [ ], - int Parent [ ], int Lnz [ ], int Flag [ ], int P [ ], int Pinv [ ]) ; - -int ldl_numeric (int n, int Ap [ ], int Ai [ ], double Ax [ ], - int Lp [ ], int Parent [ ], int Lnz [ ], int Li [ ], double Lx [ ], - double D [ ], double Y [ ], int Pattern [ ], int Flag [ ], - int P [ ], int Pinv [ ]) ; - -void ldl_lsolve (int n, double X [ ], int Lp [ ], int Li [ ], - double Lx [ ]) ; - -void ldl_dsolve (int n, double X [ ], double D [ ]) ; - -void ldl_ltsolve (int n, double X [ ], int Lp [ ], int Li [ ], - double Lx [ ]) ; - -void ldl_perm (int n, double X [ ], double B [ ], int P [ ]) ; -void ldl_permt (int n, double X [ ], double B [ ], int P [ ]) ; - -int ldl_valid_perm (int n, int P [ ], int Flag [ ]) ; -int ldl_valid_matrix ( int n, int Ap [ ], int Ai [ ]) ; - -/* ========================================================================== */ -/* === long version ========================================================= */ -/* ========================================================================== */ - -void ldl_l_symbolic (UF_long n, UF_long Ap [ ], UF_long Ai [ ], UF_long Lp [ ], - UF_long Parent [ ], UF_long Lnz [ ], UF_long Flag [ ], UF_long P [ ], - UF_long Pinv [ ]) ; - -UF_long ldl_l_numeric (UF_long n, UF_long Ap [ ], UF_long Ai [ ], double Ax [ ], - UF_long Lp [ ], UF_long Parent [ ], UF_long Lnz [ ], UF_long Li [ ], - double Lx [ ], double D [ ], double Y [ ], UF_long Pattern [ ], - UF_long Flag [ ], UF_long P [ ], UF_long Pinv [ ]) ; - -void ldl_l_lsolve (UF_long n, double X [ ], UF_long Lp [ ], UF_long Li [ ], - double Lx [ ]) ; - -void ldl_l_dsolve (UF_long n, double X [ ], double D [ ]) ; - -void ldl_l_ltsolve (UF_long n, double X [ ], UF_long Lp [ ], UF_long Li [ ], - double Lx [ ]) ; - -void ldl_l_perm (UF_long n, double X [ ], double B [ ], UF_long P [ ]) ; -void ldl_l_permt (UF_long n, double X [ ], double B [ ], UF_long P [ ]) ; - -UF_long ldl_l_valid_perm (UF_long n, UF_long P [ ], UF_long Flag [ ]) ; -UF_long ldl_l_valid_matrix ( UF_long n, UF_long Ap [ ], UF_long Ai [ ]) ; - -/* ========================================================================== */ -/* === LDL version ========================================================== */ -/* ========================================================================== */ - -#define LDL_DATE "Nov 1, 2007" -#define LDL_VERSION_CODE(main,sub) ((main) * 1000 + (sub)) -#define LDL_MAIN_VERSION 2 -#define LDL_SUB_VERSION 0 -#define LDL_SUBSUB_VERSION 1 -#define LDL_VERSION LDL_VERSION_CODE(LDL_MAIN_VERSION,LDL_SUB_VERSION) - -#if defined(__cplusplus) -} //extern "C" -#endif diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/EigenDirectSparseSolver.inl b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/EigenDirectSparseSolver.inl index 6795096feaf..8416631c581 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/EigenDirectSparseSolver.inl +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/EigenDirectSparseSolver.inl @@ -66,11 +66,10 @@ void EigenDirectSparseSolver Mfiltered.compress(); } - if (!m_map) - { - m_map = std::make_unique(Mfiltered.rows(), Mfiltered.cols(), Mfiltered.getColsValue().size(), - (typename EigenSparseMatrixMap::StorageIndex*)Mfiltered.rowBegin.data(), (typename EigenSparseMatrixMap::StorageIndex*)Mfiltered.colsIndex.data(), Mfiltered.colsValue.data()); - } + m_map = std::make_unique(Mfiltered.rows(), Mfiltered.cols(), Mfiltered.getColsValue().size(), + (typename EigenSparseMatrixMap::StorageIndex*)Mfiltered.rowBegin.data(), + (typename EigenSparseMatrixMap::StorageIndex*)Mfiltered.colsIndex.data(), + Mfiltered.colsValue.data()); const bool analyzePattern = (MfilteredrowBegin != Mfiltered.rowBegin) || (MfilteredcolsIndex != Mfiltered.colsIndex); diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.h b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.h index 1b5f0363237..c813cee4291 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.h +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.h @@ -92,9 +92,7 @@ class PrecomputedLinearSolver : public sofa::component::linearsolver::MatrixLine void invert(TMatrix& M) override; void setSystemMBKMatrix(const core::MechanicalParams* mparams) override; void loadMatrix(TMatrix& M); -#if SOFASPARSESOLVER_HAVE_CSPARSE - void loadMatrixWithCSparse(TMatrix& M); -#endif + void loadMatrixWithCholeskyDecomposition(TMatrix& M); bool addJMInvJt(linearalgebra::BaseMatrix* result, linearalgebra::BaseMatrix* J, SReal fact) override; /// Returns the sofa template name. By default the name of the c++ class signature is exposed... diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.inl b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.inl index 0eb64a99dfb..03b9d5538b6 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.inl +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/PrecomputedLinearSolver.inl @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -37,10 +39,6 @@ #include -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) -#include -#endif - #include namespace sofa::component::linearsolver::direct @@ -89,13 +87,8 @@ void PrecomputedLinearSolver::loadMatrix(TMatrix& M) ss << this->getContext()->getName() << "-" << systemSize << "-" << dt << ".comp"; if(! use_file.getValue() || ! internalData.readFile(ss.str().c_str(),systemSize) ) { -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) - loadMatrixWithCSparse(M); + loadMatrixWithCholeskyDecomposition(M); if (use_file.getValue()) internalData.writeFile(ss.str().c_str(),systemSize); -#else - SOFA_UNUSED(M); - msg_error()<< "CSPARSE support is required to invert the matrix"; -#endif } for (unsigned int j=0; j::loadMatrix(TMatrix& M) } } -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) template -void PrecomputedLinearSolver::loadMatrixWithCSparse(TMatrix& M) +void PrecomputedLinearSolver::loadMatrixWithCholeskyDecomposition(TMatrix& M) { using namespace sofa::linearalgebra; msg_info() << "Compute the initial invert matrix with CS_PARSE" ; @@ -123,7 +115,7 @@ void PrecomputedLinearSolver::loadMatrixWithCSparse(TMatrix& M) matSolv.resize(systemSize,systemSize); r.resize(systemSize); b.resize(systemSize); - SparseCholeskySolver, FullVector > solver; + EigenSimplicialLLT solver; for (unsigned int j=0; j::loadMatrixWithCSparse(TMatrix& M) msg_info() << "Precomputing constraint correction : " << std::fixed << 100.0f << " % " << '\xd'; } -#endif // SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) template void PrecomputedLinearSolver::invert(TMatrix& /*M*/) {} diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.cpp b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.cpp deleted file mode 100644 index d283bea94ff..00000000000 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.cpp +++ /dev/null @@ -1,44 +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_LINEARSOLVER_SPARSECHOLESKYSOLVER_CPP -#include -#include - -namespace sofa::component::linearsolver::direct -{ - -using namespace sofa::linearalgebra; - -#ifdef SOFA_FLOAT -SOFA_PRAGMA_WARNING("SparseCholeskySolver does not support float as scalar.") -#else // SOFA_DOUBLE -int SparseCholeskySolverClass = - core::RegisterObject( - "Direct linear solver based on Sparse Cholesky factorization, implemented with the " - "CSPARSE library") - .add, FullVector > >(); - -template class SOFA_COMPONENT_LINEARSOLVER_DIRECT_API - SparseCholeskySolver, FullVector >; -#endif // SOFA_FLOAT - -} // namespace sofa::component::linearsolver::direct diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.h b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.h index 9fd72c37db4..e4bf3e0b8cf 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.h +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.h @@ -20,61 +20,8 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once +#include -#include - -#include -#include -#include -#include -#include - -namespace sofa::component::linearsolver::direct -{ - -// Direct linear solver based on Sparse Cholesky factorization, implemented with the CSPARSE library -template -class SparseCholeskySolver : public sofa::component::linearsolver::MatrixLinearSolver -{ -public: - SOFA_CLASS(SOFA_TEMPLATE2(SparseCholeskySolver,TMatrix,TVector),SOFA_TEMPLATE2(sofa::component::linearsolver::MatrixLinearSolver,TMatrix,TVector)); - - typedef TMatrix Matrix; - typedef TVector Vector; - - SparseCholeskySolver(); - ~SparseCholeskySolver() override; - - void solve (Matrix& M, Vector& x, Vector& b) override; - void invert(Matrix& M) override; - - void parse(core::objectmodel::BaseObjectDescription *arg) override; - -protected: - - SOFA_ATTRIBUTE_DEPRECATED__SOLVER_DIRECT_VERBOSEDATA() - Data f_verbose; ///< Dump system state at each iteration - - cs A; - cs* permuted_A; - css *S; - csn *N; - int * A_i; ///< row indices, size nzmax - int * A_p; ///< column pointers (size n+1) or col indices (size nzmax) - type::vector Previous_colptr,Previous_rowind; ///< shape of the matrix at the previous step - type::vector perm,iperm; ///< fill reducing permutation - type::vector A_x,z_tmp,r_tmp,tmp; - bool notSameShape; - - Data d_typePermutation; - - void suiteSparseFactorization(bool applyPermutation); - - css* symbolic_Chol(cs *A); -}; - -#if !defined(SOFA_COMPONENT_LINEARSOLVER_SPARSECHOLESKYSOLVER_CPP) -extern template class SOFA_COMPONENT_LINEARSOLVER_DIRECT_API SparseCholeskySolver< sofa::linearalgebra::CompressedRowSparseMatrix, sofa::linearalgebra::FullVector >; -#endif - -} // namespace sofa::component::linearsolver::direct +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.inl b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.inl index 70190cd92c5..e4bf3e0b8cf 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.inl +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCholeskySolver.inl @@ -20,206 +20,8 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once +#include -#include -#include - -namespace sofa::component::linearsolver::direct -{ - -template -SparseCholeskySolver::SparseCholeskySolver() - : S(nullptr), N(nullptr) - , d_typePermutation(initData(&d_typePermutation, {"None", "SuiteSparse", "METIS"}, - "permutation", "Type of fill reducing permutation")) -{} - -template -SparseCholeskySolver::~SparseCholeskySolver() -{ - if (S) cs_sfree (S); - if (N) cs_nfree (N); -} - -template -void SparseCholeskySolver::solve (Matrix& /*M*/, Vector& x, Vector& b) -{ - const int n = A.n; - - SCOPED_TIMER_VARNAME(solveTimer, "solve"); - - switch( d_typePermutation.getValue().getSelectedId() ) - { - case 0://None->identity - case 1://SuiteSparse - if(N) - { - cs_ipvec (n, S->Pinv, (double*)b.ptr() , tmp.data() ); //x = P*b , permutation on rows - cs_lsolve (N->L, tmp.data() ); //x = L\x - cs_ltsolve (N->L, tmp.data() ); //x = L'\x/ - cs_pvec (n, S->Pinv, tmp.data() , (double*)x.ptr() ); //x = P'*x , permutation on columns - } - else - { - msg_error() << "Cannot solve system due to invalid factorization"; - } - break; - - case 2://METIS - if(N) - { - cs_ipvec (n, perm.data(), (double*)b.ptr() , tmp.data() ); //x = P*b , permutation on rows - cs_lsolve (N->L, tmp.data() ); //x = L\x - cs_ltsolve (N->L, tmp.data() ); //x = L'\x/ - cs_pvec (n, perm.data() , tmp.data() , (double*)x.ptr() ); //x = P'*x , permutation on columns - } - else - { - msg_error() << "Cannot solve system due to invalid factorization"; - } - break; - - default: - break; - - } - -} - -template -void SparseCholeskySolver::invert(Matrix& M) -{ - if (N) cs_nfree(N); - M.compress(); - - A.nzmax = M.getColsValue().size(); // maximum number of entries - A_p = (int *) &(M.getRowBegin()[0]); - A_i = (int *) &(M.getColsIndex()[0]); - A_x.resize(A.nzmax); - for (int i=0; iidentity - suiteSparseFactorization(false); - break; - - case 1:// SuiteSparse - suiteSparseFactorization(true); - break; - - case 2:// METIS - if( notSameShape ) - { - perm.resize(A.n); - iperm.resize(A.n); - - fillReducingPermutation( A , iperm.data(), perm.data() ); // compute the fill reducing permutation - } - - permuted_A = cs_permute( &A , perm.data() , iperm.data() , 1); - - if ( notSameShape ) - { - if (S) cs_sfree(S); - S = symbolic_Chol( permuted_A ); - } // symbolic analysis - - N = cs_chol (permuted_A, S) ; // numeric Cholesky factorization - assert(N); - - cs_free(permuted_A); - break; - } - } - - // store the shape of the matrix - if ( notSameShape ) - { - Previous_rowind.clear(); - Previous_colptr.resize(A.n +1); - for(int i=0 ; i -void SparseCholeskySolver::parse(core::objectmodel::BaseObjectDescription* arg) -{ - if (arg->getAttribute("verbose")) - { - msg_warning() << "Attribute 'verbose' has no use in this component. " - "To disable this warning, remove the attribute from the scene."; - } - - Inherit1::parse(arg); -} - -template -void SparseCholeskySolver::suiteSparseFactorization(bool applyPermutation) -{ - if( notSameShape ) - { - if (S) - { - cs_sfree(S); - } - const auto order = applyPermutation ? 0 : -1; - S = cs_schol (&A, order); - } - assert(S); - assert(S->cp); - assert(S->parent); - N = cs_chol (&A, S) ; // numeric Cholesky factorization - msg_error_when(!N) << "Matrix could not be factorized: possibly not positive-definite"; -} - -template -css* SparseCholeskySolver::symbolic_Chol(cs *A) -{ //based on cs_schol - int n, *c, *post; - cs *C ; - css *S ; - if (!A) return (NULL) ; // check inputs - n = A->n ; - S = (css*)cs_calloc (1, sizeof (css)) ; // allocate symbolic analysis - if (!S) return (NULL) ; // out of memory - C = cs_symperm (A, S->Pinv, 0) ; // C = spones(triu(A(P,P))) - S->parent = cs_etree (C, 0) ; // find etree of C - post = cs_post (n, S->parent) ; // postorder the etree - c = cs_counts (C, S->parent, post, 0) ; // find column counts of chol(C) - cs_free (post) ; - cs_spfree (C) ; - S->cp = (int*)cs_malloc (n+1, sizeof (int)) ; // find column pointers for L - S->unz = S->lnz = cs_cumsum (S->cp, c, n) ; - // we do not use the permutation of SuiteSparse - S->Q = nullptr ; // permutation on columns set to identity - S->Pinv = nullptr; // permutation on rows set to identity - cs_free (c) ; - return ((S->lnz >= 0) ? S : cs_sfree (S)) ; -} - -} // namespace sofa::component::linearsolver::direct +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.cpp b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.cpp index 91439016f57..af4764e0ac3 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.cpp +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.cpp @@ -19,10 +19,12 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ - - #include +extern "C" { +#include +} + namespace sofa::component::linearsolver::direct { void csrToAdj(int n, int * M_colptr, int * M_rowind, type::vector& adj, type::vector& xadj , type::vector& t_adj , type::vector& t_xadj, type::vector& tran_countvec) @@ -86,14 +88,13 @@ void csrToAdj(int n, int * M_colptr, int * M_rowind, type::vector& adj, typ } } - -void fillReducingPermutation(const cs &A,int * perm,int * invperm) +void fillReducingPermutation(int nbColumns, int *columns, int* rowIndices, + int * perm,int * invperm) { - int n = A.n; sofa::type::vector adj, xadj, t_adj, t_xadj, tran_countvec; - csrToAdj( A.n, A.p , A.i , adj, xadj, t_adj, t_xadj, tran_countvec ); - METIS_NodeND(&n, xadj.data(), adj.data(), nullptr, nullptr, perm, invperm); - + csrToAdj( nbColumns, columns , rowIndices , adj, xadj, t_adj, t_xadj, tran_countvec ); + METIS_NodeND(&nbColumns, xadj.data(), adj.data(), nullptr, nullptr, perm, invperm); } + } diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.h b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.h index a2334a40010..37cf3400d52 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.h +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseCommon.h @@ -24,11 +24,6 @@ #include #include -#include - -extern "C" { -#include -} namespace sofa::component::linearsolver::direct { @@ -46,7 +41,9 @@ SOFA_COMPONENT_LINEARSOLVER_DIRECT_API void csrToAdj(int n, int * M_colptr, int * M_rowind, type::vector& adj, type::vector& xadj, type::vector& t_adj, type::vector& t_xadj, type::vector& tran_countvec ); // compute the fill reducing permutation via METIS -void fillReducingPermutation(const cs &A,int * perm,int * invperm); +SOFA_COMPONENT_LINEARSOLVER_DIRECT_API +void fillReducingPermutation(int nbColumns, int *columns, int* rowIndices, + int * perm,int * invperm); // compare the shape of two matrix given in CSR format, return false if the matrices have the same shape and return true if their shapes are different inline bool compareMatrixShape(int s_M, int * M_colptr,int * M_rowind, int s_P, int * P_colptr,int * P_rowind) { diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLDLSolverImpl.h b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLDLSolverImpl.h index cf1d51c1f4a..2baf93b64ee 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLDLSolverImpl.h +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLDLSolverImpl.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.cpp b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.cpp deleted file mode 100644 index dd4faff9814..00000000000 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.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_LINEARSOLVER_SPARSELUSOLVER_CPP -#include -#include -#include - -namespace sofa::component::linearsolver::direct -{ - -using namespace sofa::linearalgebra; - -// dont try to compile if floating point is float -#ifdef SOFA_FLOAT -SOFA_PRAGMA_WARNING("SparseLUSolver does not support float as scalar.") -#else // SOFA_DOUBLE -int SparseLUSolverClass = core::RegisterObject("Direct linear solver based on Sparse LU factorization, implemented with the CSPARSE library") - .add< SparseLUSolver< CompressedRowSparseMatrix, FullVector > >() - .add< SparseLUSolver< CompressedRowSparseMatrix >,FullVector > >() - ; - -template class SOFA_COMPONENT_LINEARSOLVER_DIRECT_API SparseLUSolver< CompressedRowSparseMatrix, FullVector >; -template class SOFA_COMPONENT_LINEARSOLVER_DIRECT_API SparseLUSolver< CompressedRowSparseMatrix >, FullVector >; -#endif // SOFA_FLOAT - -} // namespace sofa::component::linearsolver::direct - diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.h b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.h index b6ebba1a2ad..e4bf3e0b8cf 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.h +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.h @@ -20,89 +20,8 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include +#include -#include -#include -#include -#include - -namespace sofa::component::linearsolver::direct -{ - -//defaut structure for a LU factorization -template -class SparseLUInvertData : public MatrixInvertData { -public : - - css *S; ///< store the permutations and the number of non null values by rows and by lines of the LU factorization - csn *N; ///< store the partial pivot and the LU factorization - cs A; - cs* permuted_A; - type::vector perm,iperm; ///< fill reducing permutation - type::vector Previous_colptr,Previous_rowind; ///< shape of the matrix at the previous step - type::vector A_i, A_p; - type::vector A_x; - Real * tmp; - bool notSameShape; - SparseLUInvertData() - { - S=nullptr; N=nullptr; tmp=nullptr; - } - - ~SparseLUInvertData() - { - if (S) cs_sfree (S); - if (N) cs_nfree (N); - if (tmp) cs_free (tmp); - } -}; - -// Direct linear solver based on Sparse LU factorization, implemented with the CSPARSE library -template -class SparseLUSolver : public sofa::component::linearsolver::MatrixLinearSolver -{ -public: - SOFA_CLASS(SOFA_TEMPLATE3(SparseLUSolver,TMatrix,TVector,TThreadManager),SOFA_TEMPLATE3(sofa::component::linearsolver::MatrixLinearSolver,TMatrix,TVector,TThreadManager)); - - typedef TMatrix Matrix; - typedef TVector Vector; - typedef typename Matrix::Real Real; - - typedef sofa::component::linearsolver::MatrixLinearSolver Inherit; - - SOFA_ATTRIBUTE_DEPRECATED__SOLVER_DIRECT_VERBOSEDATA() - Data f_verbose; ///< Dump system state at each iteration - - Data f_tol; ///< tolerance of factorization - - void solve (Matrix& M, Vector& x, Vector& b) override; - void invert(Matrix& M) override; - - SparseLUSolver(); - - bool supportNonSymmetricSystem() const override { return true; } - - void parse(core::objectmodel::BaseObjectDescription *arg) override; - -protected : - - Data d_typePermutation; - Data d_L_nnz; ///< Number of non-zero values in the lower triangular matrix of the factorization. The lower, the faster the system is solved. - - css* symbolic_LU(cs *A); - - MatrixInvertData * createInvertData() override { - return new SparseLUInvertData(); - } - - std::unique_ptr > Mfiltered; - -}; - - -#if !defined(SOFA_COMPONENT_LINEARSOLVER_SPARSELUSOLVER_CPP) -extern template class SOFA_COMPONENT_LINEARSOLVER_DIRECT_API SparseLUSolver< sofa::linearalgebra::CompressedRowSparseMatrix< SReal>, sofa::linearalgebra::FullVector >; -#endif - -} // namespace sofa::component::linearsolver::direct +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.inl b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.inl index 7c0339024f2..e4bf3e0b8cf 100644 --- a/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.inl +++ b/Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLUSolver.inl @@ -20,234 +20,8 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once +#include -#include -#include - -namespace sofa::component::linearsolver::direct -{ - -using namespace sofa::defaulttype; -using namespace sofa::core::behavior; -using namespace sofa::simulation; -using namespace sofa::core::objectmodel; -using sofa::helper::system::thread::CTime; -using sofa::helper::system::thread::ctime_t; -using std::cerr; -using std::endl; - -template -SparseLUSolver::SparseLUSolver() - : f_tol( initData(&f_tol,0.001,"tolerance","tolerance of factorization") ) - , d_typePermutation(initData(&d_typePermutation , "permutation", "Type of fill reducing permutation")) - , d_L_nnz(initData(&d_L_nnz, 0, "L_nnz", "Number of non-zero values in the lower triangular matrix of the factorization. The lower, the faster the system is solved.", true, true)) -{ - sofa::helper::OptionsGroup d_typePermutationOptions{"None", "SuiteSparse", "METIS"}; - d_typePermutationOptions.setSelectedItem(0); // default None - d_typePermutation.setValue(d_typePermutationOptions); -} - -template -void SparseLUSolver::parse( - core::objectmodel::BaseObjectDescription* arg) -{ - if (arg->getAttribute("verbose")) - { - msg_warning() << "Attribute 'verbose' has no use in this component. " - "To disable this warning, remove the attribute from the scene."; - } - - Inherit::parse(arg); -} - - -template -void SparseLUSolver::solve (Matrix& M, Vector& x, Vector& b) -{ - SparseLUInvertData * invertData = (SparseLUInvertData*) this->getMatrixInvertData(&M); - const int n = invertData->A.n; - - { - SCOPED_TIMER_VARNAME(solveTimer, "solve"); - switch( d_typePermutation.getValue().getSelectedId() ) - { - - case 0://None->Identity - - { - cs_ipvec (n, nullptr, b.ptr(), x.ptr()) ; // copy - cs_lsolve (invertData->N->L, x.ptr() ) ; // x = L\x - cs_usolve (invertData->N->U, x.ptr() ) ; // x = U\x - break; - } - - case 1://SuiteSparse - { - cs_ipvec (n, invertData->N->Pinv, b.ptr(), invertData->tmp) ; // x = P*b , partial pivot - cs_lsolve (invertData->N->L, invertData->tmp) ; // x = L\x - cs_usolve (invertData->N->U, invertData->tmp) ; // x = U\x - cs_ipvec (n, invertData->S->Q, invertData->tmp, x.ptr()) ; // x = Q*x fill reducing permutation on columns only - break; - } - - case 2://METIS - { - // no partial pivoting - cs_pvec (n, invertData->perm.data() , b.ptr(), invertData->tmp) ; // x = P*b permutation on rows - cs_lsolve (invertData->N->L, invertData->tmp) ; // x = L\x - cs_usolve (invertData->N->U, invertData->tmp) ; // x = U\x - cs_pvec (n, invertData->iperm.data() , invertData->tmp , x.ptr()) ; // x = Q*x permutation on columns - break; - } - - default: - break; - } - } -} - -template -void SparseLUSolver::invert(Matrix& M) -{ - SparseLUInvertData * invertData = (SparseLUInvertData*) this->getMatrixInvertData(&M); - - sofa::linearalgebra::CompressedRowSparseMatrix* matrix; - - if constexpr (!std::is_same_v) - { - if (!Mfiltered) - { - Mfiltered = std::make_unique >(); - } - Mfiltered->copyNonZeros(M); - Mfiltered->compress(); - - matrix = Mfiltered.get(); - } - else - { - M.compress(); - matrix = &M; - } - - if (invertData->N) cs_nfree(invertData->N); - if (invertData->tmp) cs_free(invertData->tmp); - - //build A with M - invertData->A.nzmax = matrix->getColsValue().size(); // maximum number of entries - invertData->A.m = matrix->rowSize(); // number of rows - invertData->A.n = matrix->colSize(); // number of columns - invertData->A_p = matrix->getRowBegin(); - invertData->A.p = (int *) &(invertData->A_p[0]); // column pointers (size n+1) or col indices (size nzmax) - invertData->A_i = matrix->getColsIndex(); - invertData->A.i = (int *) &(invertData->A_i[0]); // row indices, size nzmax - invertData->A_x = matrix->getColsValue(); - invertData->A.x = (Real *) &(invertData->A_x[0]); // numerical values, size nzmax - invertData->A.nz = -1; // # of entries in triplet matrix, -1 for compressed-col - cs_dropzeros( &invertData->A ); - - invertData->notSameShape = compareMatrixShape(invertData->A.n , (int*) invertData->A_p.data() , (int*) invertData->A_i.data(), (invertData->Previous_colptr.size())-1 ,invertData->Previous_colptr.data() ,invertData->Previous_rowind.data() ); - - invertData->tmp = (Real *) cs_malloc (invertData->A.n, sizeof (Real)) ; - - { - SCOPED_TIMER_VARNAME(factorizationTimer, "factorization"); - switch( d_typePermutation.getValue().getSelectedId() ) - { - case 0://None->Identity - { - if (invertData->S) - { - cs_sfree(invertData->S); - } - invertData->S = symbolic_LU( &(invertData->A) ) ; // ordering and symbolic analysis - invertData->N = cs_lu (&invertData->A, invertData->S, f_tol.getValue()) ; // numeric LU factorization - break; - } - - case 1://SuiteSparse - { - if (invertData->notSameShape ) - { - if (invertData->S) - { - cs_sfree(invertData->S); - } - invertData->S = cs_sqr (&invertData->A, 1 , 0) ; // Suitsparse compute fill reducing permutation for LU decomposition - } - invertData->N = cs_lu (&invertData->A, invertData->S, f_tol.getValue()) ; // numeric LU factorization - break; - } - - case 2://Metis - { - if (invertData->notSameShape ) - { - invertData->perm.resize(invertData->A.n); - invertData->iperm.resize(invertData->A.n); - - fillReducingPermutation(invertData->A, invertData->perm.data(), invertData->iperm.data() ); //METIS compute the fill reducing permutation - } - - invertData->permuted_A = cs_permute(&(invertData->A), invertData->iperm.data(), invertData->perm.data(), 1); - - if (invertData->notSameShape ) - { - if (invertData->S) - { - cs_sfree(invertData->S); - } - invertData->S = symbolic_LU( invertData->permuted_A ); - } - - invertData->N = cs_lu ( invertData->permuted_A, invertData->S, f_tol.getValue()) ; // numeric LU factorization - - cs_free(invertData->permuted_A); // prevent memory leak - - break; - } - - default: - break; - } - } - - d_L_nnz.setValue(invertData->N->L->nzmax); - - // store the shape of the matrix - if ( invertData->notSameShape ) - { - invertData->Previous_rowind.clear(); - invertData->Previous_colptr.resize( (invertData->A.n) +1); - - for (int i=0 ; iA.n ; i++) - { - invertData->Previous_colptr[i+1] = invertData->A_p[i+1]; - - for ( int j = (int) invertData->A_p[i] ; j < (int)invertData->A_p[i+1] ; j++) - { - invertData->Previous_rowind.push_back( invertData->A_i[j]); - } - } - - } - -} - -template -css* SparseLUSolver::symbolic_LU(cs *A) -{// based on cs_sqr - - int n; - css *S ; - if (!A) return (NULL) ; /* check inputs */ - n = A->n ; - S = (css*)cs_calloc (1, sizeof (css)) ; /* allocate symbolic analysis */ - if (!S) return (NULL) ; /* out of memory */ - S->unz = 4*(A->p [n]) + n ; /* for LU factorization only, */ - S->lnz = S->unz ; /* guess nnz(L) and nnz(U) */ - S->Q = nullptr; // should have been the fill permutation computed by SuiteSparse, not used here - return S ; -} - -} // namespace sofa::component::linearsolver::direct +SOFA_PRAGMA_ERROR( \ + "This header has been DISABLED since v23.12. " \ + "To fix this error you must use the CSparseSolvers plugins. " ) diff --git a/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.h b/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.h index 9c71ecd0aa7..0ab268218b2 100644 --- a/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.h +++ b/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.h @@ -176,9 +176,7 @@ protected : PrecomputedWarpPreconditionerInternalData internalData; void rotateConstraints(); -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) - void loadMatrixWithCSparse(TMatrix& M); -#endif + void loadMatrixWithCholeskyDecomposition(TMatrix& M); void loadMatrixWithSolver(); template diff --git a/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.inl b/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.inl index 5155ed3691f..01627d1ace6 100644 --- a/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.inl +++ b/Sofa/Component/LinearSolver/Preconditioner/src/sofa/component/linearsolver/preconditioner/PrecomputedWarpPreconditioner.inl @@ -39,11 +39,8 @@ #include #include - -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) -#include -#endif -#include +#include +#include #include @@ -184,13 +181,7 @@ void PrecomputedWarpPreconditioner::loadMatrix(TMatrix& M) msg_info() << "Precompute : " << fname << " compliance."; if (l_linearSolver.empty()) { -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) - loadMatrixWithCSparse(M); -#else - msg_error() << "Link \"linearSolver\" is empty, but it is required to load matrix."; - this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); - return; -#endif // SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) + loadMatrixWithCholeskyDecomposition(M); } else { @@ -222,9 +213,8 @@ void PrecomputedWarpPreconditioner::loadMatrix(TMatrix& M) } } -#if SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) template -void PrecomputedWarpPreconditioner::loadMatrixWithCSparse(TMatrix& M) +void PrecomputedWarpPreconditioner::loadMatrixWithCholeskyDecomposition(TMatrix& M) { msg_info() << "Compute the initial invert matrix with CS_PARSE" ; @@ -237,7 +227,7 @@ void PrecomputedWarpPreconditioner::loadMatrixWithCSparse(TMatrix& M b.resize(systemSize); for (unsigned int j=0; j, FullVector > solver; + direct::EigenSimplicialLLT solver; msg_info() << "Precomputing constraint correction LU decomposition " ; solver.invert(M); @@ -277,7 +267,6 @@ void PrecomputedWarpPreconditioner::loadMatrixWithCSparse(TMatrix& M tmpStr << "Precomputing constraint correction : " << std::fixed << 100.0f << " %" ; msg_info() << tmpStr.str(); } -#endif // SOFA_COMPONENT_LINEARSOLVER_DIRECT_HAVE_CSPARSE && !defined(SOFA_FLOAT) template void PrecomputedWarpPreconditioner::loadMatrixWithSolver() diff --git a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp index ac1a0847a0c..433fed3d6b8 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp +++ b/Sofa/framework/Core/src/sofa/core/topology/TopologyData.cpp @@ -26,7 +26,7 @@ namespace sofa::core::topology { - + template class SOFA_CORE_API sofa::core::topology::TopologyData < core::topology::BaseMeshTopology::Point, type::vector >; } //namespace sofa::core::topology diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index b7958a4da16..a3cb1196bed 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -412,9 +412,7 @@ const std::map > uncreatableComponents // SofaSparseSolver was deprecated in #2717 { "FillReducingOrdering", Moved("v22.06", "SofaGeneralLinearSolver", "Sofa.Component.LinearSolver.Direct") }, { "PrecomputedLinearSolver", Moved("v22.06", "SofaGeneralLinearSolver", "Sofa.Component.LinearSolver.Direct") }, - { "SparseCholeskySolver", Moved("v22.06", "SofaSparseSolver", "Sofa.Component.LinearSolver.Direct") }, { "SparseLDLSolver", Moved("v22.06", "SofaSparseSolver", "Sofa.Component.LinearSolver.Direct") }, - { "SparseLUSolver", Moved("v22.06", "SofaSparseSolver", "Sofa.Component.LinearSolver.Direct") }, // SofaDenseSolver was deprecated in #2717 { "SVDLinearSolver", Moved("v22.06", "SofaDenseSolver", "Sofa.Component.LinearSolver.Direct") }, @@ -720,6 +718,10 @@ const std::map > uncreatableComponents // Removed in #4040, deprecated in #2777 { "MechanicalMatrixMapper", Removed("v23.06", "v23.12") }, { "MappingGeometricStiffnessForceField", Removed("v23.06", "v23.12") }, + + // Moved to CSparseSolvers + { "SparseCholeskySolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, + { "SparseLUSolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, }; } // namespace sofa::helper::lifecycle diff --git a/applications/plugins/CMakeLists.txt b/applications/plugins/CMakeLists.txt index 6d05efc1520..1e72b41f483 100644 --- a/applications/plugins/CMakeLists.txt +++ b/applications/plugins/CMakeLists.txt @@ -51,6 +51,7 @@ sofa_add_subdirectory(plugin SoftRobots SoftRobots EXTERNAL) sofa_add_subdirectory(plugin CollisionAlgorithm CollisionAlgorithm EXTERNAL) sofa_add_subdirectory(plugin ConstraintGeometry ConstraintGeometry EXTERNAL) sofa_add_subdirectory(plugin ShapeMatchingPlugin ShapeMatchingPlugin EXTERNAL) +sofa_add_subdirectory(plugin CSparseSolvers CSparseSolvers EXTERNAL) sofa_add_subdirectory(plugin PSL PSL EXTERNAL) diff --git a/applications/plugins/CSparseSolvers/ExternalProjectConfig.cmake.in b/applications/plugins/CSparseSolvers/ExternalProjectConfig.cmake.in new file mode 100644 index 00000000000..989dbe70379 --- /dev/null +++ b/applications/plugins/CSparseSolvers/ExternalProjectConfig.cmake.in @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.11) + +include(ExternalProject) +ExternalProject_Add(CSparseSolvers + GIT_REPOSITORY https://github.com/sofa-framework/CSparseSolvers + GIT_TAG origin/master + SOURCE_DIR "${CMAKE_SOURCE_DIR}/applications/plugins/CSparseSolvers" + BINARY_DIR "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + GIT_CONFIG "remote.origin.fetch=+refs/pull/*:refs/remotes/origin/pr/*" +) diff --git a/applications/plugins/SofaCUDA/examples/beam10x10x46-warp-preconditioner-CUDA.scn b/applications/plugins/SofaCUDA/examples/beam10x10x46-warp-preconditioner-CUDA.scn index 169c19466eb..50031644065 100644 --- a/applications/plugins/SofaCUDA/examples/beam10x10x46-warp-preconditioner-CUDA.scn +++ b/applications/plugins/SofaCUDA/examples/beam10x10x46-warp-preconditioner-CUDA.scn @@ -32,7 +32,6 @@ - diff --git a/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn b/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn index 4fc616e55a9..245bc21c6ce 100644 --- a/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn +++ b/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn @@ -6,7 +6,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn b/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn index cd3a8a5f350..b131e803661 100644 --- a/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn +++ b/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn @@ -6,7 +6,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn b/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn index f1b20911242..6e5f3c40528 100644 --- a/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn +++ b/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn @@ -10,7 +10,7 @@ The scene compares two simulations in which only the vertices order differs: - + @@ -33,7 +33,7 @@ The scene compares two simulations in which only the vertices order differs: - + @@ -49,7 +49,7 @@ The scene compares two simulations in which only the vertices order differs: - + diff --git a/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn b/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn index 10cbae2c41a..52d7979148e 100644 --- a/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn +++ b/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn @@ -10,7 +10,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/LinearSolver/Direct/FEMBAR_SparseCholeskySolver.scn b/examples/Component/LinearSolver/Direct/FEMBAR_SparseCholeskySolver.scn deleted file mode 100644 index a9e826a2956..00000000000 --- a/examples/Component/LinearSolver/Direct/FEMBAR_SparseCholeskySolver.scn +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/Component/LinearSolver/Direct/FEMBAR_SparseLUSolver.scn b/examples/Component/LinearSolver/Direct/FEMBAR_SparseLUSolver.scn deleted file mode 100644 index 241b8fb05d3..00000000000 --- a/examples/Component/LinearSolver/Direct/FEMBAR_SparseLUSolver.scn +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/Component/Mapping/NonLinear/DistanceFromTargetMapping.scn b/examples/Component/Mapping/NonLinear/DistanceFromTargetMapping.scn index 0a2144bea18..1dd85728358 100644 --- a/examples/Component/Mapping/NonLinear/DistanceFromTargetMapping.scn +++ b/examples/Component/Mapping/NonLinear/DistanceFromTargetMapping.scn @@ -1,7 +1,7 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/RestShapeSpringsForceField3.scn b/examples/Component/SolidMechanics/FEM/RestShapeSpringsForceField3.scn index b7680484750..6b034813594 100644 --- a/examples/Component/SolidMechanics/FEM/RestShapeSpringsForceField3.scn +++ b/examples/Component/SolidMechanics/FEM/RestShapeSpringsForceField3.scn @@ -5,7 +5,7 @@ - + @@ -21,7 +21,7 @@ - + - + @@ -23,7 +23,7 @@ - + diff --git a/examples/RegressionStateScenes.regression-tests b/examples/RegressionStateScenes.regression-tests index f430b475ae6..7ac5834edf8 100644 --- a/examples/RegressionStateScenes.regression-tests +++ b/examples/RegressionStateScenes.regression-tests @@ -33,9 +33,7 @@ Component/LinearSolver/Direct/FEMBAR_EigenSimplicialLLT.scn 100 1e-8 0 1 Component/LinearSolver/Direct/FEMBAR_EigenSparseLU.scn 100 1e-8 0 1 Component/LinearSolver/Direct/FEMBAR_EigenSparseQR.scn 100 1e-8 0 1 Component/LinearSolver/Direct/FEMBAR_PrecomputedLinearSolver.scn 100 1e-8 0 1 -Component/LinearSolver/Direct/FEMBAR_SparseCholeskySolver.scn 100 1e-8 0 1 Component/LinearSolver/Direct/FEMBAR_SparseLDLSolver.scn 100 1e-8 0 1 -Component/LinearSolver/Direct/FEMBAR_SparseLUSolver.scn 100 1e-8 0 1 Component/LinearSolver/Iterative/FEMBAR_MinResLinearSolver.scn 100 1e-8 0 1 Component/LinearSolver/Iterative/FEMBAR_ShewchukPCGLinearSolver.scn 1e-8 0 1 Component/LinearSolver/Iterative/FEMBAR_CGLinearSolver.scn 100 1e-8 0 1 From af572585b38464b4d4b5213d13a2f42c44297f6f Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 24 Nov 2023 17:47:57 +0100 Subject: [PATCH 10/28] [GUI.Qt] Minor single-line cleaning (#4308) Co-authored-by: erik pernod --- Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp b/Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp index 442d20d86ea..1f4b1d27d7b 100644 --- a/Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp +++ b/Sofa/GUI/Qt/src/sofa/gui/qt/RealGUI.cpp @@ -1180,7 +1180,7 @@ void RealGUI::registerViewer(BaseViewer* _viewer) BaseViewer* RealGUI::getViewer() { - return m_viewer!=nullptr ? m_viewer : nullptr; + return m_viewer; } //------------------------------------ From 0e7ccbe53e980907f124ff25dc25e64436fc5f31 Mon Sep 17 00:00:00 2001 From: Olivier Roussel Date: Wed, 29 Nov 2023 11:28:04 +0100 Subject: [PATCH 11/28] [Sofa.GUI.Qt] Add cmake module for QGLViewer (#4290) * Add cmake module for QGLViewer * Support library name for apt packages * Fix qglviewer cmake finder module to first seach for a config cmake file. * Update cmake/Modules/FindQGLViewer.cmake Co-authored-by: Hugo --------- Co-authored-by: Frederick Roy Co-authored-by: Hugo --- Sofa/GUI/Qt/CMakeLists.txt | 2 +- cmake/Modules/FindQGLViewer.cmake | 69 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 cmake/Modules/FindQGLViewer.cmake diff --git a/Sofa/GUI/Qt/CMakeLists.txt b/Sofa/GUI/Qt/CMakeLists.txt index 56256c3694d..8de94a80a93 100644 --- a/Sofa/GUI/Qt/CMakeLists.txt +++ b/Sofa/GUI/Qt/CMakeLists.txt @@ -74,7 +74,7 @@ if(Sofa.GL_FOUND) option(SOFA_GUI_QT_ENABLE_QGLVIEWER "Compile the QGLViewer for the Qt GUI" ON) if(SOFA_GUI_QT_ENABLE_QGLVIEWER) - find_package(QGLViewer QUIET) + find_package(QGLViewer) if(NOT QGLViewer_FOUND) add_subdirectory(libQGLViewer/QGLViewer) endif() diff --git a/cmake/Modules/FindQGLViewer.cmake b/cmake/Modules/FindQGLViewer.cmake new file mode 100644 index 00000000000..cbf284d949a --- /dev/null +++ b/cmake/Modules/FindQGLViewer.cmake @@ -0,0 +1,69 @@ +# Find the QGLViewer headers and libraries +# Behavior is to first look for config files. +# If no config files were found, tries to find +# the library by looking at headers / lib file. +# +# Defines: +# QGLViewer_FOUND : True if QGLViewer is found +# +# Provides target QGLViewer. + +find_package(QGLViewer NO_MODULE QUIET) + +if(NOT TARGET QGLViewer) + + if(NOT QGLViewer_INCLUDE_DIR) + find_path(QGLViewer_INCLUDE_DIR + NAMES qglviewer.h + PATH_SUFFIXES include/QGLViewer + ) + endif() + + if(NOT QGLViewer_LIBRARY) + find_library(QGLViewer_LIBRARY + NAMES QGLViewer QGLViewer-qt5 + PATH_SUFFIXES lib + ) + endif() + + if(QGLViewer_INCLUDE_DIR AND QGLViewer_LIBRARY) + set(QGLViewer_FOUND TRUE) + else() + if(QGLViewer_FIND_REQUIRED) + message(FATAL_ERROR "Cannot find QGLViewer") + endif() + endif() + + # Same checks as Sofa.GUI.Qt + # i.e find Qt5, then if not, Qt6, then if not error + find_package(Qt5 COMPONENTS Core QUIET) + if (NOT Qt5Core_FOUND) + if(${CMAKE_VERSION} VERSION_GREATER "3.16.0") + find_package(Qt6 COMPONENTS Core CoreTools QUIET) + endif() + endif() + + if (Qt5Core_FOUND) + find_package(Qt5 COMPONENTS Core Charts Gui Xml OpenGL Widgets REQUIRED) + set(QT_TARGETS Qt5::Core Qt5::Charts Qt5::Gui Qt5::Xml Qt5::OpenGL Qt5::Widgets) + elseif (Qt6Core_FOUND) + find_package(Qt6 COMPONENTS Gui Charts GuiTools Widgets WidgetsTools OpenGLWidgets Xml REQUIRED) + set(QT_TARGETS ${QT_TARGETS} Qt::Core Qt::Charts Qt::Gui Qt::Widgets Qt::OpenGLWidgets Qt::Xml) + endif() + + if(QGLViewer_FOUND) + set(QGLViewer_LIBRARIES ${QGLViewer_LIBRARY}) + set(QGLViewer_INCLUDE_DIRS ${QGLViewer_INCLUDE_DIR}) + + if(NOT QGLViewer_FIND_QUIETLY) + message(STATUS "Found QGLViewer: ${QGLVIEWER_LIBRARIES}") + endif(NOT QGLViewer_FIND_QUIETLY) + + if(NOT TARGET QGLViewer) + add_library(QGLViewer INTERFACE IMPORTED) + set_property(TARGET QGLViewer PROPERTY INTERFACE_LINK_LIBRARIES "${QGLViewer_LIBRARIES}" ${QT_TARGETS}) + set_property(TARGET QGLViewer PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${QGLViewer_INCLUDE_DIR}") + endif() + endif() + mark_as_advanced(QGLViewer_INCLUDE_DIR QGLViewer_LIBRARY) +endif() From 620bc51d13d93cb7bc15f801c7ea4e60ce218687 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 29 Nov 2023 11:30:14 +0100 Subject: [PATCH 12/28] [MultiThreading] Avoid Static Initialization Order Fiasco (#4307) --- .../ParallelImplementationsRegistry.cpp | 16 ++++++++++------ .../ParallelImplementationsRegistry.h | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.cpp b/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.cpp index e201063e013..78e33a5bb23 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.cpp @@ -25,7 +25,11 @@ namespace multithreading { -sofa::type::vector ParallelImplementationsRegistry::s_implementations; +sofa::type::vector& getStaticImplementations() +{ + static sofa::type::vector s_implementations; + return s_implementations; +} bool ParallelImplementationsRegistry::addEquivalentImplementations( const std::string& sequentialImplementation, const std::string& parallelImplementation) @@ -34,9 +38,9 @@ bool ParallelImplementationsRegistry::addEquivalentImplementations( const auto it = findParallelImplementationImpl(sequentialImplementation); - if (it == s_implementations.end()) + if (it == getStaticImplementations().end()) { - s_implementations.push_back(implementation); + getStaticImplementations().push_back(implementation); return true; } @@ -62,7 +66,7 @@ std::string ParallelImplementationsRegistry::findParallelImplementation( { const auto it = findParallelImplementationImpl(sequentialImplementation); - if (it != s_implementations.end()) + if (it != getImplementations().end()) { return it->parallel; } @@ -72,14 +76,14 @@ std::string ParallelImplementationsRegistry::findParallelImplementation( const sofa::type::vector& ParallelImplementationsRegistry::getImplementations() { - return s_implementations; + return getStaticImplementations(); } sofa::type::vector::const_iterator ParallelImplementationsRegistry::findParallelImplementationImpl( const std::string& sequentialImplementation) { - return std::find_if(s_implementations.begin(), s_implementations.end(), + return std::find_if(getStaticImplementations().begin(), getStaticImplementations().end(), [&sequentialImplementation](const Implementation& i) { return i.sequential == sequentialImplementation; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.h b/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.h index 37cd573edb7..f7c6d90ee0b 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.h +++ b/applications/plugins/MultiThreading/src/MultiThreading/ParallelImplementationsRegistry.h @@ -44,7 +44,6 @@ class SOFA_MULTITHREADING_PLUGIN_API ParallelImplementationsRegistry static const sofa::type::vector& getImplementations(); private: - static sofa::type::vector s_implementations; static sofa::type::vector::const_iterator findParallelImplementationImpl(const std::string& sequentialImplementation); }; From 7f4fdeffacd8fbb342ecc3856c361f669072c367 Mon Sep 17 00:00:00 2001 From: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:31:37 +0100 Subject: [PATCH 13/28] [Core] Minor clean of DefaultAnimationLoop (#4314) * Remove unlogical use of visitor * Delete unused methods --- .../sofa/simulation/DefaultAnimationLoop.cpp | 19 ------------------- .../sofa/simulation/DefaultAnimationLoop.h | 2 -- 2 files changed, 21 deletions(-) diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp index 1673a6940d9..0bf53d191c8 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp @@ -170,14 +170,6 @@ void DefaultAnimationLoop::propagateAnimateBeginEvent(const core::ExecParams* pa m_node->execute(act); } -void DefaultAnimationLoop::resetConstraint(const core::ExecParams* params) const -{ - SCOPED_TIMER("resetConstraint"); - const sofa::core::ConstraintParams cparams(*params); - sofa::simulation::mechanicalvisitor::MechanicalResetConstraintVisitor resetConstraint(&cparams); - m_node->execute(&resetConstraint); -} - void DefaultAnimationLoop::beginIntegration(const core::ExecParams* params, SReal dt) const { propagateIntegrateBeginEvent(params); @@ -195,14 +187,6 @@ void DefaultAnimationLoop::propagateIntegrateBeginEvent(const core::ExecParams* eventPropagation.execute(m_node); } -void DefaultAnimationLoop::buildConstraintMatrix(core::ConstraintParams cparams) const -{ - SCOPED_TIMER("buildConstraintMatrix"); - unsigned int constraintId = 0; - mechanicalvisitor::MechanicalBuildConstraintMatrix buildConstraintMatrix(&cparams, core::MatrixDerivId::constraintJacobian(), constraintId ); - buildConstraintMatrix.execute(m_node); -} - void DefaultAnimationLoop::accumulateMatrixDeriv(const core::ConstraintParams cparams) const { SCOPED_TIMER("accumulateMatrixDeriv"); @@ -292,14 +276,11 @@ void DefaultAnimationLoop::animate(const core::ExecParams* params, SReal dt) con behaviorUpdatePosition(params, dt); updateInternalData(params); - resetConstraint(params); - collisionDetection(params); beginIntegration(params, dt); { const core::ConstraintParams cparams; - buildConstraintMatrix(cparams); accumulateMatrixDeriv(cparams); solve(params, dt); diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.h index dff897be485..c11161170f0 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.h @@ -69,10 +69,8 @@ protected : void behaviorUpdatePosition(const sofa::core::ExecParams* params, SReal dt) const; void updateInternalData(const sofa::core::ExecParams* params) const; - void resetConstraint(const sofa::core::ExecParams* params) const; void beginIntegration(const sofa::core::ExecParams* params, SReal dt) const; void propagateIntegrateBeginEvent(const sofa::core::ExecParams* params) const; - void buildConstraintMatrix(sofa::core::ConstraintParams cparams) const; void accumulateMatrixDeriv(sofa::core::ConstraintParams cparams) const; void solve(const sofa::core::ExecParams* params, SReal dt) const; void propagateIntegrateEndEvent(const sofa::core::ExecParams* params) const; From c2af338510cabd78427ff1a9d33ac138cff40bc6 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 29 Nov 2023 11:32:03 +0100 Subject: [PATCH 14/28] [LinearSystem] Speedup computation of Jacobian matrices (#4317) * [LinearSystem] Speedup computation of Jacobian matrices in case both mstates are the same * minor reformat to align calls to computeJacobiansFrom --- .../component/linearsystem/MatrixLinearSystem.inl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/MatrixLinearSystem.inl b/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/MatrixLinearSystem.inl index 54964cd34fa..18231191cb6 100644 --- a/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/MatrixLinearSystem.inl +++ b/Sofa/Component/LinearSystem/src/sofa/component/linearsystem/MatrixLinearSystem.inl @@ -988,7 +988,8 @@ void MatrixLinearSystem::projectMappedMatrices(const core::Mec } const MappingJacobians J0 = computeJacobiansFrom(pair[0], mparams, crs); - const MappingJacobians J1 = computeJacobiansFrom(pair[1], mparams, crs); + const MappingJacobians J1 = + (pair[0] == pair[1]) ? J0 : computeJacobiansFrom(pair[1], mparams, crs); const sofa::type::fixed_array, 2> mappingMatricesMap { J0, J1 }; @@ -1039,6 +1040,10 @@ auto MatrixLinearSystem::computeJacobiansFrom(BaseMechanicalSt auto mappingJacobianId = sofa::core::MatrixDerivId::mappingJacobian(); + // optimisation to build only the relevent entries of the jacobian matrices + // The relevent entries are the ones that have a influence on the result + // of the product J^T * K * J. + // J does not need to be fully computed if K is sparse. { const std::vector listAffectedDoFs = identifyAffectedDoFs(mstate, crs); @@ -1049,12 +1054,17 @@ auto MatrixLinearSystem::computeJacobiansFrom(BaseMechanicalSt mstate->buildIdentityBlocksInJacobian(listAffectedDoFs, mappingJacobianId); } + // apply the mappings from the bottom to the top, so it builds the jacobian + // matrices, transforming the space from the input DoFs to the space of the + // top most DoFs const auto parentMappings = getMappingGraph().getBottomUpMappingsFrom(mstate); for (auto* mapping : parentMappings) { mapping->applyJT(&cparams, mappingJacobianId, mappingJacobianId); } + // copy the jacobian matrix stored in the mechanical states into a local + // matrix data structure const auto inputs = m_mappingGraph.getTopMostMechanicalStates(mstate); for (auto* input : inputs) { @@ -1062,7 +1072,7 @@ auto MatrixLinearSystem::computeJacobiansFrom(BaseMechanicalSt jacobians.addJacobianToTopMostParent(J, input); J->resize(mstate->getMatrixSize(), input->getMatrixSize()); unsigned int offset {}; - input->copyToBaseMatrix(J.get(), sofa::core::MatrixDerivId::mappingJacobian(), offset); + input->copyToBaseMatrix(J.get(), mappingJacobianId, offset); J->fullRows(); } From 7811db5bc75c31881c503ab62fae18f17e6ce0c9 Mon Sep 17 00:00:00 2001 From: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:32:25 +0100 Subject: [PATCH 15/28] [SofaCUDA] FIX compilation SofaCUDA along with SparseGrid with Cuda12 (#4319) * FIX compilation SofaCUDA along with SparseGrid with Cuda12 * Use a multiplication instead --- .../plugins/SofaCUDA/sofa/gpu/cuda/CudaContactMapper.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaContactMapper.cu b/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaContactMapper.cu index 80f8aefc737..a8e6be42025 100644 --- a/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaContactMapper.cu +++ b/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaContactMapper.cu @@ -85,7 +85,7 @@ __global__ void SubsetContactMapperCuda3f_setPoints1_kernel(unsigned int nbPoint GPUContact c = contacts[curTestEntry.firstIndex + threadIdx.x]; if (threadIdx.x < curTestEntry.curSize) { - map[curTestEntry.newIndex + threadIdx.x] = umul24(curTestEntry.elem1,nbPointsPerElem) + c.p1; + map[curTestEntry.newIndex + threadIdx.x] = curTestEntry.elem1 * nbPointsPerElem + c.p1; } } From 13e9031de7baf727f47826f118a5c9bf9db47f0e Mon Sep 17 00:00:00 2001 From: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:34:25 +0100 Subject: [PATCH 16/28] [Common] Add message to make the fetch mechanism less hidden (#4310) * Add message to make it more clear * slight modifications to be even more clear and add an error the dependency cannot be met --- Sofa/GUI/Common/CMakeLists.txt | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Sofa/GUI/Common/CMakeLists.txt b/Sofa/GUI/Common/CMakeLists.txt index b1eb06b7d1f..f6cb2e6dd63 100644 --- a/Sofa/GUI/Common/CMakeLists.txt +++ b/Sofa/GUI/Common/CMakeLists.txt @@ -1,24 +1,29 @@ cmake_minimum_required(VERSION 3.12) project(Sofa.GUI.Common LANGUAGES CXX) -find_package(cxxopts 3.1) +find_package(cxxopts 3.1 QUIET) if(NOT cxxopts_FOUND AND SOFA_ALLOW_FETCH_DEPENDENCIES) - include(FetchContent) - FetchContent_Declare(cxxopts - GIT_REPOSITORY https://github.com/jarro2783/cxxopts - GIT_TAG v3.1.1 - ) + message("Sofa.GUI.Common: DEPENDENCY cxxopt NOT FOUND. SOFA_ALLOW_FETCH_DEPENDENCIES is ON, fetching cxxopt...") - FetchContent_GetProperties(cxxopts) - if(NOT cxxopts_POPULATED) - FetchContent_Populate(cxxopts) + include(FetchContent) + FetchContent_Declare(cxxopts + GIT_REPOSITORY https://github.com/jarro2783/cxxopts + GIT_TAG v3.1.1 + ) + + FetchContent_GetProperties(cxxopts) + if(NOT cxxopts_POPULATED) + FetchContent_Populate(cxxopts) - set(CXXOPTS_BUILD_EXAMPLES OFF CACHE INTERNAL "") - set(CXXOPTS_BUILD_TESTS OFF CACHE INTERNAL "") - set(CXXOPTS_ENABLE_INSTALL ON CACHE INTERNAL "") + set(CXXOPTS_BUILD_EXAMPLES OFF CACHE INTERNAL "") + set(CXXOPTS_BUILD_TESTS OFF CACHE INTERNAL "") + set(CXXOPTS_ENABLE_INSTALL ON CACHE INTERNAL "") + message("Sofa.GUI.Common: adding subdirectory ${cxxopts_SOURCE_DIR}") - add_subdirectory(${cxxopts_SOURCE_DIR} ${cxxopts_BINARY_DIR}) - endif() + add_subdirectory(${cxxopts_SOURCE_DIR} ${cxxopts_BINARY_DIR}) + endif() +elseif (NOT cxxopts_FOUND) + message(FATAL_ERROR "Sofa.GUI.Common: DEPENDENCY cxxopt NOT FOUND. SOFA_ALLOW_FETCH_DEPENDENCIES is OFF and thus cannot be fetched. Install libcxxopts-dev (version>=3.1.0), or enable SOFA_ALLOW_FETCH_DEPENDENCIES to fix this issue.") endif() set(SOFAGUICOMMON_ROOT src/sofa/gui/common) From d696114a7bc2b52af336a561254bf9d34a8fc672 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Wed, 29 Nov 2023 19:51:01 +0900 Subject: [PATCH 17/28] [Collections] Remove reference to non-existing SofaSimulation (#4320) remove ref to non-existent sofasimu Co-authored-by: Paul Baksic <30337881+bakpaul@users.noreply.github.com> --- applications/collections/deprecated/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/collections/deprecated/CMakeLists.txt b/applications/collections/deprecated/CMakeLists.txt index 4b727117819..f8ae3ddeb9b 100644 --- a/applications/collections/deprecated/CMakeLists.txt +++ b/applications/collections/deprecated/CMakeLists.txt @@ -1,7 +1,6 @@ # meta-modules (SofaKernel) sofa_add_subdirectory(collection SofaFramework SofaFramework ON WHEN_TO_SHOW "SOFA_ENABLE_LEGACY_HEADERS" VALUE_IF_HIDDEN OFF) -sofa_add_subdirectory(collection SofaSimulation SofaSimulation ON WHEN_TO_SHOW "SOFA_ENABLE_LEGACY_HEADERS" VALUE_IF_HIDDEN OFF) sofa_add_subdirectory(collection SofaBase SofaBase ON WHEN_TO_SHOW "SOFA_ENABLE_LEGACY_HEADERS" VALUE_IF_HIDDEN OFF) From 109e4eef6fd5fefed845de6ee376b24fc1ffa580 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 29 Nov 2023 14:49:06 +0100 Subject: [PATCH 18/28] Remove repeating preffix from projective constraints --- .../Constraint/Projective/CMakeLists.txt | 24 ++++++------ ....cpp => DirectionProjectiveConstraint.cpp} | 14 +++---- ...aint.h => DirectionProjectiveConstraint.h} | 24 ++++++------ ....inl => DirectionProjectiveConstraint.inl} | 36 +++++++++--------- .../projective/FixedProjectiveConstraint.h | 2 +- ...raint.cpp => LineProjectiveConstraint.cpp} | 14 +++---- ...onstraint.h => LineProjectiveConstraint.h} | 24 ++++++------ ...raint.inl => LineProjectiveConstraint.inl} | 38 +++++++++---------- ...aint.cpp => PlaneProjectiveConstraint.cpp} | 14 +++---- ...nstraint.h => PlaneProjectiveConstraint.h} | 24 ++++++------ ...aint.inl => PlaneProjectiveConstraint.inl} | 36 +++++++++--------- ...aint.cpp => PointProjectiveConstraint.cpp} | 22 +++++------ ...nstraint.h => PointProjectiveConstraint.h} | 28 +++++++------- ...aint.inl => PointProjectiveConstraint.inl} | 34 ++++++++--------- .../projective/ProjectDirectionConstraint.h | 4 +- .../projective/ProjectDirectionConstraint.inl | 4 +- .../projective/ProjectToLineConstraint.h | 4 +- .../projective/ProjectToLineConstraint.inl | 4 +- .../projective/ProjectToPlaneConstraint.h | 4 +- .../projective/ProjectToPlaneConstraint.inl | 4 +- .../projective/ProjectToPointConstraint.h | 4 +- .../projective/ProjectToPointConstraint.inl | 4 +- .../Projective/tests/CMakeLists.txt | 8 ++-- ...=> DirectionProjectiveConstraint_test.cpp} | 20 +++++----- ....cpp => LineProjectiveConstraint_test.cpp} | 20 +++++----- ...cpp => PlaneProjectiveConstraint_test.cpp} | 20 +++++----- ...cpp => PointProjectiveConstraint_test.cpp} | 20 +++++----- .../simutests/LinearElasticity_test.cpp | 8 ++-- .../plugins/SofaTest/Elasticity_test.inl | 8 ++-- .../plugins/SofaTest/InitPlugin_test.h | 2 +- ...ctDirectionConstraint_RemovingMeshTest.scn | 4 +- ...ojectToLineConstraint_RemovingMeshTest.scn | 4 +- ...jectToPlaneConstraint_RemovingMeshTest.scn | 4 +- ...jectToPointConstraint_RemovingMeshTest.scn | 4 +- .../Projective/ProjectDirectionConstraint.scn | 4 +- .../Projective/ProjectToLineConstraint.scn | 4 +- .../Projective/ProjectToPlaneConstraint.scn | 4 +- .../Projective/ProjectToPointConstraint.scn | 4 +- .../Engine/Generate/GenerateCylinder.scn | 4 +- .../Engine/Generate/GenerateGrid.scn | 6 +-- examples/Demos/simpleBoundaryConditions.scn | 8 ++-- 41 files changed, 261 insertions(+), 261 deletions(-) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectDirectionProjectiveConstraint.cpp => DirectionProjectiveConstraint.cpp} (75%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectDirectionProjectiveConstraint.h => DirectionProjectiveConstraint.h} (83%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectDirectionProjectiveConstraint.inl => DirectionProjectiveConstraint.inl} (79%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToLineProjectiveConstraint.cpp => LineProjectiveConstraint.cpp} (75%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToLineProjectiveConstraint.h => LineProjectiveConstraint.h} (83%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToLineProjectiveConstraint.inl => LineProjectiveConstraint.inl} (80%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPlaneProjectiveConstraint.cpp => PlaneProjectiveConstraint.cpp} (75%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPlaneProjectiveConstraint.h => PlaneProjectiveConstraint.h} (84%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPlaneProjectiveConstraint.inl => PlaneProjectiveConstraint.inl} (79%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPointProjectiveConstraint.cpp => PointProjectiveConstraint.cpp} (67%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPointProjectiveConstraint.h => PointProjectiveConstraint.h} (82%) rename Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/{ProjectToPointProjectiveConstraint.inl => PointProjectiveConstraint.inl} (84%) rename Sofa/Component/Constraint/Projective/tests/{ProjectDirectionProjectiveConstraint_test.cpp => DirectionProjectiveConstraint_test.cpp} (91%) rename Sofa/Component/Constraint/Projective/tests/{ProjectToLineProjectiveConstraint_test.cpp => LineProjectiveConstraint_test.cpp} (91%) rename Sofa/Component/Constraint/Projective/tests/{ProjectToPlaneProjectiveConstraint_test.cpp => PlaneProjectiveConstraint_test.cpp} (91%) rename Sofa/Component/Constraint/Projective/tests/{ProjectToPointProjectiveConstraint_test.cpp => PointProjectiveConstraint_test.cpp} (91%) diff --git a/Sofa/Component/Constraint/Projective/CMakeLists.txt b/Sofa/Component/Constraint/Projective/CMakeLists.txt index bce59cfa94d..a6f2a49cda8 100644 --- a/Sofa/Component/Constraint/Projective/CMakeLists.txt +++ b/Sofa/Component/Constraint/Projective/CMakeLists.txt @@ -78,14 +78,14 @@ set(HEADER_FILES ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PositionBasedDynamicsProjectiveConstraint.inl ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionProjectiveConstraint.h ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionProjectiveConstraint.inl - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineProjectiveConstraint.h - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineProjectiveConstraint.inl - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneProjectiveConstraint.h - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneProjectiveConstraint.inl - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointProjectiveConstraint.h - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointProjectiveConstraint.inl - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionProjectiveConstraint.h - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LineProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LineProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PlaneProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PlaneProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PointProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PointProjectiveConstraint.inl + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/DirectionProjectiveConstraint.h + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/DirectionProjectiveConstraint.inl ) @@ -107,10 +107,10 @@ set(SOURCE_FILES ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PatchTestMovementProjectiveConstraint.cpp ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PositionBasedDynamicsProjectiveConstraint.cpp ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/SkeletalMotionProjectiveConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToLineProjectiveConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPlaneProjectiveConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectToPointProjectiveConstraint.cpp - ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/ProjectDirectionProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/LineProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PlaneProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/PointProjectiveConstraint.cpp + ${SOFACOMPONENTCONSTRAINTPROJECTIVE_SOURCE_DIR}/DirectionProjectiveConstraint.cpp ) sofa_find_package(Sofa.Simulation.Core REQUIRED) diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp similarity index 75% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp index c4e4338641a..a4f22a624ef 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectDirectionProjectiveConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_DirectionProjectiveConstraint_CPP +#include #include #include @@ -32,14 +32,14 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectDirectionProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< ProjectDirectionProjectiveConstraint >() - .add< ProjectDirectionProjectiveConstraint >() +int DirectionProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< DirectionProjectiveConstraint >() + .add< DirectionProjectiveConstraint >() .addAlias("ProjectDirectionConstraint") ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h similarity index 83% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h index 3da00ee882c..b68daa63860 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h @@ -41,7 +41,7 @@ namespace sofa::component::constraint::projective /// This class can be overridden if needed for additionnal storage within template specializations. template -class ProjectDirectionProjectiveConstraintInternalData +class DirectionProjectiveConstraintInternalData { }; @@ -49,10 +49,10 @@ class ProjectDirectionProjectiveConstraintInternalData /** Project particles to an affine straight line going through the particle original position. */ template -class ProjectDirectionProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +class DirectionProjectiveConstraint : public core::behavior::ProjectiveConstraintSet { public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectDirectionProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + SOFA_CLASS(SOFA_TEMPLATE(DirectionProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); using Index = sofa::Index; typedef typename DataTypes::VecCoord VecCoord; @@ -76,9 +76,9 @@ class ProjectDirectionProjectiveConstraint : public core::behavior::ProjectiveCo protected: - ProjectDirectionProjectiveConstraint(); + DirectionProjectiveConstraint(); - virtual ~ProjectDirectionProjectiveConstraint(); + virtual ~DirectionProjectiveConstraint(); public: IndexSubsetData f_indices; ///< the particles to project @@ -86,11 +86,11 @@ class ProjectDirectionProjectiveConstraint : public core::behavior::ProjectiveCo Data f_direction; ///< The direction of the line. Will be normalized by init() /// 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; + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; protected: - ProjectDirectionProjectiveConstraintInternalData* data; - friend class ProjectDirectionProjectiveConstraintInternalData; + DirectionProjectiveConstraintInternalData* data; + friend class DirectionProjectiveConstraintInternalData; type::vector m_origin; @@ -125,13 +125,13 @@ protected : }; -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectDirectionProjectiveConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectDirectionProjectiveConstraint; +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_DirectionProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; #endif template -using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectDirectionConstraint has been renamed to ProjectDirectionProjectiveConstraint") = ProjectDirectionProjectiveConstraint; +using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectDirectionConstraint has been renamed to DirectionProjectiveConstraint") = DirectionProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.inl similarity index 79% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.inl index af1d8f39f3f..77d50d83146 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.inl @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include @@ -34,13 +34,13 @@ namespace sofa::component::constraint::projective { template -ProjectDirectionProjectiveConstraint::ProjectDirectionProjectiveConstraint() +DirectionProjectiveConstraint::DirectionProjectiveConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectDirectionProjectiveConstraintInternalData()) + , data(new DirectionProjectiveConstraintInternalData()) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -48,27 +48,27 @@ ProjectDirectionProjectiveConstraint::ProjectDirectionProjectiveConst template -ProjectDirectionProjectiveConstraint::~ProjectDirectionProjectiveConstraint() +DirectionProjectiveConstraint::~DirectionProjectiveConstraint() { delete data; } template -void ProjectDirectionProjectiveConstraint::clearConstraints() +void DirectionProjectiveConstraint::clearConstraints() { f_indices.beginEdit()->clear(); f_indices.endEdit(); } template -void ProjectDirectionProjectiveConstraint::addConstraint(Index index) +void DirectionProjectiveConstraint::addConstraint(Index index) { f_indices.beginEdit()->push_back(index); f_indices.endEdit(); } template -void ProjectDirectionProjectiveConstraint::removeConstraint(Index index) +void DirectionProjectiveConstraint::removeConstraint(Index index) { sofa::type::removeValue(*f_indices.beginEdit(),index); f_indices.endEdit(); @@ -78,7 +78,7 @@ void ProjectDirectionProjectiveConstraint::removeConstraint(Index ind template -void ProjectDirectionProjectiveConstraint::init() +void DirectionProjectiveConstraint::init() { this->core::behavior::ProjectiveConstraintSet::init(); @@ -118,7 +118,7 @@ void ProjectDirectionProjectiveConstraint::init() } template -void ProjectDirectionProjectiveConstraint::reinit() +void DirectionProjectiveConstraint::reinit() { // normalize the normal vector CPos n = f_direction.getValue(); @@ -172,7 +172,7 @@ void ProjectDirectionProjectiveConstraint::reinit() } template -void ProjectDirectionProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +void DirectionProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) { J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state BaseSparseMatrix* E = dynamic_cast(M); @@ -183,7 +183,7 @@ void ProjectDirectionProjectiveConstraint::projectMatrix( sofa::linea template -void ProjectDirectionProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +void DirectionProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) { SOFA_UNUSED(mparams); @@ -192,19 +192,19 @@ void ProjectDirectionProjectiveConstraint::projectResponse(const core } template -void ProjectDirectionProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) +void DirectionProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) { msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; } template -void ProjectDirectionProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +void DirectionProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) { projectResponse(mparams,vData); } template -void ProjectDirectionProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) +void DirectionProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) { VecCoord& x = *xData.beginEdit(); @@ -223,22 +223,22 @@ void ProjectDirectionProjectiveConstraint::projectPosition(const core } template -void ProjectDirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +void DirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) { msg_error() << "applyConstraint is not implemented"; } template -void ProjectDirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +void DirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) { - dmsg_error() << "ProjectDirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented"; + dmsg_error() << "DirectionProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented"; } template -void ProjectDirectionProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +void DirectionProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { if (!vparams->displayFlags().getShowBehaviorModels()) return; if (!this->isActive()) return; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h index f69cd6a1029..ae2959a9bb7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h @@ -47,7 +47,7 @@ class FixedProjectiveConstraintInternalData /** Maintain a constant velocity. * If the particle is initially fixed then it is attached to its initial position. * Otherwise it keeps on drifting. - * For maintaining particles fixed in any case, @sa ProjectToPointProjectiveConstraint + * For maintaining particles fixed in any case, @sa PointProjectiveConstraint */ template class FixedProjectiveConstraint : public core::behavior::ProjectiveConstraintSet diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp similarity index 75% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp index 1e9798e0fb7..4ac4c9552ec 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToLineProjectiveConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LineProjectiveConstraint_CPP +#include #include namespace sofa::component::constraint::projective @@ -30,13 +30,13 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectToLineProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< ProjectToLineProjectiveConstraint >() - .add< ProjectToLineProjectiveConstraint >() +int LineProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< LineProjectiveConstraint >() + .add< LineProjectiveConstraint >() .addAlias("ProjectToLineConstraint") ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h similarity index 83% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h index c4e2f352b52..5d897a32283 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h @@ -40,7 +40,7 @@ namespace sofa::component::constraint::projective /// This class can be overridden if needed for additionnal storage within template specializations. template -class ProjectToLineProjectiveConstraintInternalData +class LineProjectiveConstraintInternalData { }; @@ -50,10 +50,10 @@ class ProjectToLineProjectiveConstraintInternalData @todo Optimized versions for lines parallel to the main directions */ template -class ProjectToLineProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +class LineProjectiveConstraint : public core::behavior::ProjectiveConstraintSet { public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectToLineProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + SOFA_CLASS(SOFA_TEMPLATE(LineProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); using Index = sofa::Index; typedef typename DataTypes::VecCoord VecCoord; @@ -77,9 +77,9 @@ class ProjectToLineProjectiveConstraint : public core::behavior::ProjectiveConst protected: - ProjectToLineProjectiveConstraint(); + LineProjectiveConstraint(); - virtual ~ProjectToLineProjectiveConstraint(); + virtual ~LineProjectiveConstraint(); public: IndexSubsetData f_indices; ///< the particles to project @@ -88,11 +88,11 @@ class ProjectToLineProjectiveConstraint : public core::behavior::ProjectiveConst Data f_direction; ///< The direction of the line. Will be normalized by init() /// 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; + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; protected: - ProjectToLineProjectiveConstraintInternalData* data; - friend class ProjectToLineProjectiveConstraintInternalData; + LineProjectiveConstraintInternalData* data; + friend class LineProjectiveConstraintInternalData; public: @@ -129,13 +129,13 @@ protected : }; -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToLineProjectiveConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToLineProjectiveConstraint; +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LineProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; #endif template -using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToLineConstraint has been renamed to ProjectToLineProjectiveConstraint") = ProjectToLineProjectiveConstraint; +using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToLineConstraint has been renamed to LineProjectiveConstraint") = LineProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.inl similarity index 80% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.inl index 51fa74ebcc9..2111e6be0f1 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.inl @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include @@ -33,14 +33,14 @@ namespace sofa::component::constraint::projective { template -ProjectToLineProjectiveConstraint::ProjectToLineProjectiveConstraint() +LineProjectiveConstraint::LineProjectiveConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , f_origin( initData(&f_origin,CPos(),"origin","A point in the line")) , f_direction( initData(&f_direction,CPos(),"direction","Direction of the line")) , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectToLineProjectiveConstraintInternalData()) + , data(new LineProjectiveConstraintInternalData()) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -48,27 +48,27 @@ ProjectToLineProjectiveConstraint::ProjectToLineProjectiveConstraint( template -ProjectToLineProjectiveConstraint::~ProjectToLineProjectiveConstraint() +LineProjectiveConstraint::~LineProjectiveConstraint() { delete data; } template -void ProjectToLineProjectiveConstraint::clearConstraints() +void LineProjectiveConstraint::clearConstraints() { f_indices.beginEdit()->clear(); f_indices.endEdit(); } template -void ProjectToLineProjectiveConstraint::addConstraint(Index index) +void LineProjectiveConstraint::addConstraint(Index index) { f_indices.beginEdit()->push_back(index); f_indices.endEdit(); } template -void ProjectToLineProjectiveConstraint::removeConstraint(Index index) +void LineProjectiveConstraint::removeConstraint(Index index) { sofa::type::removeValue(*f_indices.beginEdit(),index); f_indices.endEdit(); @@ -78,7 +78,7 @@ void ProjectToLineProjectiveConstraint::removeConstraint(Index index) template -void ProjectToLineProjectiveConstraint::init() +void LineProjectiveConstraint::init() { this->core::behavior::ProjectiveConstraintSet::init(); @@ -117,13 +117,13 @@ void ProjectToLineProjectiveConstraint::init() } template -void ProjectToLineProjectiveConstraint::reinit() +void LineProjectiveConstraint::reinit() { updateJacobian(); } template -void ProjectToLineProjectiveConstraint::updateJacobian() +void LineProjectiveConstraint::updateJacobian() { // normalize the normal vector CPos n = f_direction.getValue(); @@ -169,7 +169,7 @@ void ProjectToLineProjectiveConstraint::updateJacobian() } template -void ProjectToLineProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +void LineProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) { J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state BaseSparseMatrix* E = dynamic_cast(M); @@ -180,7 +180,7 @@ void ProjectToLineProjectiveConstraint::projectMatrix( sofa::linearal template -void ProjectToLineProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +void LineProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) { SOFA_UNUSED(mparams); @@ -196,19 +196,19 @@ void ProjectToLineProjectiveConstraint::projectResponse(const core::M } template -void ProjectToLineProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) +void LineProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) { msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; } template -void ProjectToLineProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +void LineProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) { projectResponse(mparams,vData); } template -void ProjectToLineProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) +void LineProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) { VecCoord& x = *xData.beginEdit(); @@ -229,22 +229,22 @@ void ProjectToLineProjectiveConstraint::projectPosition(const core::M // Matrix Integration interface template -void ProjectToLineProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +void LineProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) { msg_error() << "applyConstraint is not implemented "; } template -void ProjectToLineProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +void LineProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) { - msg_error() << "ProjectToLineProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; + msg_error() << "LineProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; } template -void ProjectToLineProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +void LineProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { if (!vparams->displayFlags().getShowBehaviorModels()) return; if (!this->isActive()) return; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp similarity index 75% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp index 1b05c12c2a9..11092578661 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPlaneProjectiveConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PlaneProjectiveConstraint_CPP +#include #include namespace sofa::component::constraint::projective @@ -30,14 +30,14 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectToPlaneProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") - .add< ProjectToPlaneProjectiveConstraint >() - .add< ProjectToPlaneProjectiveConstraint >() +int PlaneProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") + .add< PlaneProjectiveConstraint >() + .add< PlaneProjectiveConstraint >() .addAlias("ProjectToPlaneConstraint") ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PlaneProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PlaneProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h similarity index 84% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h index 49544d2395d..03912cad7bf 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h @@ -40,7 +40,7 @@ namespace sofa::component::constraint::projective /// This class can be overridden if needed for additionnal storage within template specializations. template -class ProjectToPlaneProjectiveConstraintInternalData +class PlaneProjectiveConstraintInternalData { }; @@ -50,10 +50,10 @@ class ProjectToPlaneProjectiveConstraintInternalData @todo Optimized versions for planes parallel to the main directions */ template -class ProjectToPlaneProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +class PlaneProjectiveConstraint : public core::behavior::ProjectiveConstraintSet { public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectToPlaneProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + SOFA_CLASS(SOFA_TEMPLATE(PlaneProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); using Index = sofa::Index; typedef typename DataTypes::VecCoord VecCoord; @@ -77,9 +77,9 @@ class ProjectToPlaneProjectiveConstraint : public core::behavior::ProjectiveCons SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); protected: - ProjectToPlaneProjectiveConstraint(); + PlaneProjectiveConstraint(); - virtual ~ProjectToPlaneProjectiveConstraint(); + virtual ~PlaneProjectiveConstraint(); public: IndexSubsetData f_indices; ///< the particles to project @@ -88,11 +88,11 @@ class ProjectToPlaneProjectiveConstraint : public core::behavior::ProjectiveCons Data f_drawSize; ///< The size of the display of the constrained particles /// 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; + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; protected: - ProjectToPlaneProjectiveConstraintInternalData* data; - friend class ProjectToPlaneProjectiveConstraintInternalData; + PlaneProjectiveConstraintInternalData* data; + friend class PlaneProjectiveConstraintInternalData; public: @@ -127,14 +127,14 @@ protected : }; -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPlaneProjectiveConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPlaneProjectiveConstraint; +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PlaneProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PlaneProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PlaneProjectiveConstraint; #endif template -using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPlaneConstraint has been renamed to ProjectToPlaneProjectiveConstraint") = ProjectToPlaneProjectiveConstraint; +using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPlaneConstraint has been renamed to PlaneProjectiveConstraint") = PlaneProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.inl similarity index 79% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.inl index a4a9ea7d627..9ba0cae1e0d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.inl @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include @@ -33,14 +33,14 @@ namespace sofa::component::constraint::projective { template -ProjectToPlaneProjectiveConstraint::ProjectToPlaneProjectiveConstraint() +PlaneProjectiveConstraint::PlaneProjectiveConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) , f_indices( initData(&f_indices,"indices","Indices of the fixed points") ) , f_origin( initData(&f_origin,CPos(),"origin","A point in the plane")) , f_normal( initData(&f_normal,CPos(),"normal","Normal vector to the plane")) , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectToPlaneProjectiveConstraintInternalData()) + , data(new PlaneProjectiveConstraintInternalData()) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -48,27 +48,27 @@ ProjectToPlaneProjectiveConstraint::ProjectToPlaneProjectiveConstrain template -ProjectToPlaneProjectiveConstraint::~ProjectToPlaneProjectiveConstraint() +PlaneProjectiveConstraint::~PlaneProjectiveConstraint() { delete data; } template -void ProjectToPlaneProjectiveConstraint::clearConstraints() +void PlaneProjectiveConstraint::clearConstraints() { f_indices.beginEdit()->clear(); f_indices.endEdit(); } template -void ProjectToPlaneProjectiveConstraint::addConstraint(Index index) +void PlaneProjectiveConstraint::addConstraint(Index index) { f_indices.beginEdit()->push_back(index); f_indices.endEdit(); } template -void ProjectToPlaneProjectiveConstraint::removeConstraint(Index index) +void PlaneProjectiveConstraint::removeConstraint(Index index) { sofa::type::removeValue(*f_indices.beginEdit(),index); f_indices.endEdit(); @@ -78,7 +78,7 @@ void ProjectToPlaneProjectiveConstraint::removeConstraint(Index index template -void ProjectToPlaneProjectiveConstraint::init() +void PlaneProjectiveConstraint::init() { this->core::behavior::ProjectiveConstraintSet::init(); @@ -118,7 +118,7 @@ void ProjectToPlaneProjectiveConstraint::init() } template -void ProjectToPlaneProjectiveConstraint::reinit() +void PlaneProjectiveConstraint::reinit() { // normalize the normal vector @@ -172,7 +172,7 @@ void ProjectToPlaneProjectiveConstraint::reinit() } template -void ProjectToPlaneProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +void PlaneProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) { J.copy(jacobian, M->colSize(), offset); // projection matrix for an assembled state BaseSparseMatrix* E = dynamic_cast(M); @@ -183,7 +183,7 @@ void ProjectToPlaneProjectiveConstraint::projectMatrix( sofa::lineara template -void ProjectToPlaneProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +void PlaneProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) { SOFA_UNUSED(mparams); @@ -192,19 +192,19 @@ void ProjectToPlaneProjectiveConstraint::projectResponse(const core:: } template -void ProjectToPlaneProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) +void PlaneProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* /*mparams*/ , DataMatrixDeriv& /*cData*/) { msg_error() << "projectJacobianMatrix(const core::MechanicalParams*, DataMatrixDeriv& ) is not implemented"; } template -void ProjectToPlaneProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) +void PlaneProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData) { projectResponse(mparams,vData); } template -void ProjectToPlaneProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) +void PlaneProjectiveConstraint::projectPosition(const core::MechanicalParams* /*mparams*/ , DataVecCoord& xData) { VecCoord& x = *xData.beginEdit(); @@ -224,19 +224,19 @@ void ProjectToPlaneProjectiveConstraint::projectPosition(const core:: } template -void ProjectToPlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +void PlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) { msg_error() << "applyConstraint is not implemented "; } template -void ProjectToPlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) +void PlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* /*mparams*/, linearalgebra::BaseVector* /*vector*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) { - msg_error() << "ProjectToPlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; + msg_error() << "PlaneProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) is not implemented "; } template -void ProjectToPlaneProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +void PlaneProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { if (!vparams->displayFlags().getShowBehaviorModels()) return; if (!this->isActive()) return; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp similarity index 67% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp index 77ee9547b59..2622f32391d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPointProjectiveConstraint_CPP -#include +#define SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PointProjectiveConstraint_CPP +#include #include #include @@ -32,17 +32,17 @@ using namespace sofa::defaulttype; using namespace sofa::helper; -int ProjectToPointProjectiveConstraintClass = core::RegisterObject("Project particles to a point") - .add< ProjectToPointProjectiveConstraint >() - .add< ProjectToPointProjectiveConstraint >() - .add< ProjectToPointProjectiveConstraint >() - .add< ProjectToPointProjectiveConstraint >() +int PointProjectiveConstraintClass = core::RegisterObject("Project particles to a point") + .add< PointProjectiveConstraint >() + .add< PointProjectiveConstraint >() + .add< PointProjectiveConstraint >() + .add< PointProjectiveConstraint >() .addAlias("ProjectToPointConstraint") ; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; -template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; +template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h similarity index 82% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h index db881be9af9..3349c24efd9 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h @@ -38,7 +38,7 @@ namespace sofa::component::constraint::projective /// This class can be overridden if needed for additionnal storage within template specializations. template -class ProjectToPointProjectiveConstraintInternalData +class PointProjectiveConstraintInternalData { }; @@ -48,10 +48,10 @@ class ProjectToPointProjectiveConstraintInternalData * @sa FixedConstraint */ template -class ProjectToPointProjectiveConstraint : public core::behavior::ProjectiveConstraintSet +class PointProjectiveConstraint : public core::behavior::ProjectiveConstraintSet { public: - SOFA_CLASS(SOFA_TEMPLATE(ProjectToPointProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); + SOFA_CLASS(SOFA_TEMPLATE(PointProjectiveConstraint,DataTypes),SOFA_TEMPLATE(sofa::core::behavior::ProjectiveConstraintSet, DataTypes)); using Index = sofa::Index; typedef typename DataTypes::VecCoord VecCoord; @@ -70,9 +70,9 @@ class ProjectToPointProjectiveConstraint : public core::behavior::ProjectiveCons SOFA_ATTRIBUTE_REPLACED__TYPEMEMBER(Vector3, sofa::type::Vec3); protected: - ProjectToPointProjectiveConstraint(); + PointProjectiveConstraint(); - virtual ~ProjectToPointProjectiveConstraint(); + virtual ~PointProjectiveConstraint(); public: SetIndex f_indices; ///< the indices of the points to project to the target @@ -81,11 +81,11 @@ class ProjectToPointProjectiveConstraint : public core::behavior::ProjectiveCons Data f_drawSize; ///< 0 -> point based rendering, >0 -> radius of spheres /// 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; + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology; protected: - ProjectToPointProjectiveConstraintInternalData* data; - friend class ProjectToPointProjectiveConstraintInternalData; + PointProjectiveConstraintInternalData* data; + friend class PointProjectiveConstraintInternalData; public: @@ -120,14 +120,14 @@ protected : }; -#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_ProjectToPointProjectiveConstraint_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; -extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API ProjectToPointProjectiveConstraint; +#if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PointProjectiveConstraint_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; +extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; #endif template -using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPointConstraint has been renamed to ProjectToPointProjectiveConstraint") = ProjectToPointProjectiveConstraint; +using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPointConstraint has been renamed to PointProjectiveConstraint") = PointProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.inl similarity index 84% rename from Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl rename to Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.inl index 7e567574f5d..b50b5aedd38 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.inl @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include @@ -35,14 +35,14 @@ namespace sofa::component::constraint::projective { template -ProjectToPointProjectiveConstraint::ProjectToPointProjectiveConstraint() +PointProjectiveConstraint::PointProjectiveConstraint() : core::behavior::ProjectiveConstraintSet(nullptr) , f_indices( initData(&f_indices,"indices","Indices of the points to project") ) , f_point( initData(&f_point,"point","Target of the projection") ) , f_fixAll( initData(&f_fixAll,false,"fixAll","filter all the DOF to implement a fixed object") ) , f_drawSize( initData(&f_drawSize,(SReal)0.0,"drawSize","0 -> point based rendering, >0 -> radius of spheres") ) , l_topology(initLink("topology", "link to the topology container")) - , data(new ProjectToPointProjectiveConstraintInternalData()) + , data(new PointProjectiveConstraintInternalData()) { f_indices.beginEdit()->push_back(0); f_indices.endEdit(); @@ -50,27 +50,27 @@ ProjectToPointProjectiveConstraint::ProjectToPointProjectiveConstrain template -ProjectToPointProjectiveConstraint::~ProjectToPointProjectiveConstraint() +PointProjectiveConstraint::~PointProjectiveConstraint() { delete data; } template -void ProjectToPointProjectiveConstraint::clearConstraints() +void PointProjectiveConstraint::clearConstraints() { f_indices.beginEdit()->clear(); f_indices.endEdit(); } template -void ProjectToPointProjectiveConstraint::addConstraint(Index index) +void PointProjectiveConstraint::addConstraint(Index index) { f_indices.beginEdit()->push_back(index); f_indices.endEdit(); } template -void ProjectToPointProjectiveConstraint::removeConstraint(Index index) +void PointProjectiveConstraint::removeConstraint(Index index) { sofa::type::removeValue(*f_indices.beginEdit(),index); f_indices.endEdit(); @@ -80,7 +80,7 @@ void ProjectToPointProjectiveConstraint::removeConstraint(Index index template -void ProjectToPointProjectiveConstraint::init() +void PointProjectiveConstraint::init() { this->core::behavior::ProjectiveConstraintSet::init(); @@ -121,7 +121,7 @@ void ProjectToPointProjectiveConstraint::init() } template -void ProjectToPointProjectiveConstraint::reinit() +void PointProjectiveConstraint::reinit() { // get the indices sorted @@ -130,7 +130,7 @@ void ProjectToPointProjectiveConstraint::reinit() } template -void ProjectToPointProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) +void PointProjectiveConstraint::projectMatrix( sofa::linearalgebra::BaseMatrix* M, unsigned offset ) { const unsigned blockSize = DataTypes::deriv_total_size; @@ -142,7 +142,7 @@ void ProjectToPointProjectiveConstraint::projectMatrix( sofa::lineara } template -void ProjectToPointProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) +void PointProjectiveConstraint::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData) { SOFA_UNUSED(mparams); @@ -169,7 +169,7 @@ void ProjectToPointProjectiveConstraint::projectResponse(const core:: } template -void ProjectToPointProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) +void PointProjectiveConstraint::projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData) { SOFA_UNUSED(mparams); @@ -193,13 +193,13 @@ void ProjectToPointProjectiveConstraint::projectJacobianMatrix(const } template -void ProjectToPointProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams , DataVecDeriv& vData) +void PointProjectiveConstraint::projectVelocity(const core::MechanicalParams* mparams , DataVecDeriv& vData) { projectResponse(mparams, vData); } template -void ProjectToPointProjectiveConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) +void PointProjectiveConstraint::projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData) { SOFA_UNUSED(mparams); @@ -226,7 +226,7 @@ void ProjectToPointProjectiveConstraint::projectPosition(const core:: } template -void ProjectToPointProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void PointProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { SOFA_UNUSED(mparams); if(const core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate.get())) @@ -247,7 +247,7 @@ void ProjectToPointProjectiveConstraint::applyConstraint(const core:: } template -void ProjectToPointProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void PointProjectiveConstraint::applyConstraint(const core::MechanicalParams* mparams, linearalgebra::BaseVector* vector, const sofa::core::behavior::MultiMatrixAccessor* matrix) { SOFA_UNUSED(mparams); const int o = matrix->getGlobalOffset(this->mstate.get()); @@ -269,7 +269,7 @@ void ProjectToPointProjectiveConstraint::applyConstraint(const core:: template -void ProjectToPointProjectiveConstraint::draw(const core::visual::VisualParams* vparams) +void PointProjectiveConstraint::draw(const core::visual::VisualParams* vparams) { if (!vparams->displayFlags().getShowBehaviorModels()) return; if (!this->isActive()) return; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h index fa767ebb33e..173a3d8a58c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/DirectionProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl index cb073b97a2a..8640eb081fd 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectDirectionProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/DirectionProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h index 4517e80a549..02c5f41deba 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LineProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl index 4517e80a549..b89742555da 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToLineProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LineProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h index b84d4e807d1..e2cbcbbb70e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PlaneProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl index 7720a8b39fc..3f721631ffb 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPlaneProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PlaneProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h index 46e68da759e..7a6231bd4a9 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PointProjectiveConstraint.h") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl index 03afaee1b2e..0a7a4499ec9 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ProjectToPointProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PointProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt b/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt index 0456bcd1434..7e271d937b6 100644 --- a/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt +++ b/Sofa/Component/Constraint/Projective/tests/CMakeLists.txt @@ -7,10 +7,10 @@ set(SOURCE_FILES FixedProjectiveConstraint_test.cpp FixedPlaneProjectiveConstraint_test.cpp PartialFixedProjectiveConstraint_test.cpp - ProjectDirectionProjectiveConstraint_test.cpp - ProjectToLineProjectiveConstraint_test.cpp - ProjectToPlaneProjectiveConstraint_test.cpp - ProjectToPointProjectiveConstraint_test.cpp + DirectionProjectiveConstraint_test.cpp + LineProjectiveConstraint_test.cpp + PlaneProjectiveConstraint_test.cpp + PointProjectiveConstraint_test.cpp ) add_executable(${PROJECT_NAME} ${SOURCE_FILES}) diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectDirectionProjectiveConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/DirectionProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectDirectionProjectiveConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/DirectionProjectiveConstraint_test.cpp index ec858101dca..697184f6f30 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectDirectionProjectiveConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/DirectionProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -41,11 +41,11 @@ using namespace component; using namespace defaulttype; using namespace core::objectmodel; -/** Test suite for ProjectDirectionProjectiveConstraint. +/** Test suite for DirectionProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectDirectionProjectiveConstraint_test : public BaseSimulationTest, NumericTest +struct DirectionProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -54,8 +54,8 @@ struct ProjectDirectionProjectiveConstraint_test : public BaseSimulationTest, Nu typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::CPos CPos; typedef typename Coord::value_type Real; - typedef constraint::projective::ProjectDirectionProjectiveConstraint ProjectDirectionProjectiveConstraint; - typedef typename ProjectDirectionProjectiveConstraint::Indices Indices; + typedef constraint::projective::DirectionProjectiveConstraint DirectionProjectiveConstraint; + typedef typename DirectionProjectiveConstraint::Indices Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -65,7 +65,7 @@ struct ProjectDirectionProjectiveConstraint_test : public BaseSimulationTest, Nu unsigned numNodes; ///< number of particles used for the test Indices indices; ///< indices of the nodes to project CPos direction; ///< direction to project to - typename ProjectDirectionProjectiveConstraint::SPtr projection; + typename DirectionProjectiveConstraint::SPtr projection; typename MechanicalObject::SPtr dofs; /// Create the context for the tests. @@ -85,7 +85,7 @@ struct ProjectDirectionProjectiveConstraint_test : public BaseSimulationTest, Nu root->addObject(dofs); // Project direction constraint - projection = New(); + projection = New(); root->addObject(projection); /// Set the values @@ -236,10 +236,10 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectDirectionProjectiveConstraint_test, DataTypes); +TYPED_TEST_SUITE(DirectionProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectDirectionProjectiveConstraint_test , oneConstrainedParticle ) +TYPED_TEST( DirectionProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -247,7 +247,7 @@ TYPED_TEST( ProjectDirectionProjectiveConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // second test case -TYPED_TEST( ProjectDirectionProjectiveConstraint_test , allParticlesConstrained ) +TYPED_TEST( DirectionProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectToLineProjectiveConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/LineProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectToLineProjectiveConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/LineProjectiveConstraint_test.cpp index ad77e7be8a9..bda02f7bf43 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectToLineProjectiveConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/LineProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -39,11 +39,11 @@ using namespace defaulttype; -/** Test suite for ProjectToLineProjectiveConstraint. +/** Test suite for LineProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectToLineProjectiveConstraint_test : public BaseSimulationTest, NumericTest +struct LineProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -52,8 +52,8 @@ struct ProjectToLineProjectiveConstraint_test : public BaseSimulationTest, Numer typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::CPos CPos; typedef typename Coord::value_type Real; - typedef constraint::projective::ProjectToLineProjectiveConstraint ProjectToLineProjectiveConstraint; - typedef typename ProjectToLineProjectiveConstraint::Indices Indices; + typedef constraint::projective::LineProjectiveConstraint LineProjectiveConstraint; + typedef typename LineProjectiveConstraint::Indices Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -64,7 +64,7 @@ struct ProjectToLineProjectiveConstraint_test : public BaseSimulationTest, Numer Indices indices; ///< indices of the nodes to project CPos origin; ///< origin of the plane to project to CPos direction; ///< direction of the line to project to - typename ProjectToLineProjectiveConstraint::SPtr projection; + typename LineProjectiveConstraint::SPtr projection; typename MechanicalObject::SPtr dofs; /// Create the context for the tests. @@ -82,7 +82,7 @@ const PointSetTopologyContainer::SPtr topology = core::objectmodel::New(); root->addObject(dofs); - projection = core::objectmodel::New(); + projection = core::objectmodel::New(); root->addObject(projection); /// Set the values @@ -221,9 +221,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectToLineProjectiveConstraint_test, DataTypes); +TYPED_TEST_SUITE(LineProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectToLineProjectiveConstraint_test , oneConstrainedParticle ) +TYPED_TEST( LineProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -231,7 +231,7 @@ TYPED_TEST( ProjectToLineProjectiveConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // next test case -TYPED_TEST( ProjectToLineProjectiveConstraint_test , allParticlesConstrained ) +TYPED_TEST( LineProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectToPlaneProjectiveConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/PlaneProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectToPlaneProjectiveConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/PlaneProjectiveConstraint_test.cpp index ed622ef6ddb..c09830aed0c 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectToPlaneProjectiveConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/PlaneProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -40,11 +40,11 @@ using namespace defaulttype; -/** Test suite for ProjectToPlaneProjectiveConstraint. +/** Test suite for PlaneProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectToPlaneProjectiveConstraint_test : public BaseSimulationTest, NumericTest +struct PlaneProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -53,8 +53,8 @@ struct ProjectToPlaneProjectiveConstraint_test : public BaseSimulationTest, Nume typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::CPos CPos; typedef typename Coord::value_type Real; - typedef constraint::projective::ProjectToPlaneProjectiveConstraint ProjectToPlaneProjectiveConstraint; - typedef typename ProjectToPlaneProjectiveConstraint::Indices Indices; + typedef constraint::projective::PlaneProjectiveConstraint PlaneProjectiveConstraint; + typedef typename PlaneProjectiveConstraint::Indices Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -65,7 +65,7 @@ struct ProjectToPlaneProjectiveConstraint_test : public BaseSimulationTest, Nume Indices indices; ///< indices of the nodes to project CPos origin; ///< origin of the plane to project to CPos normal; ///< normal of the plane to project to - typename ProjectToPlaneProjectiveConstraint::SPtr projection; + typename PlaneProjectiveConstraint::SPtr projection; typename MechanicalObject::SPtr dofs; /// Create the context for the matrix tests. @@ -83,7 +83,7 @@ const PointSetTopologyContainer::SPtr topology = core::objectmodel::New(); root->addObject(dofs); - projection = core::objectmodel::New(); + projection = core::objectmodel::New(); root->addObject(projection); /// Set the values @@ -220,9 +220,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectToPlaneProjectiveConstraint_test, DataTypes); +TYPED_TEST_SUITE(PlaneProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectToPlaneProjectiveConstraint_test , oneConstrainedParticle ) +TYPED_TEST( PlaneProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -230,7 +230,7 @@ TYPED_TEST( ProjectToPlaneProjectiveConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // next test case -TYPED_TEST( ProjectToPlaneProjectiveConstraint_test , allParticlesConstrained ) +TYPED_TEST( PlaneProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/Constraint/Projective/tests/ProjectToPointProjectiveConstraint_test.cpp b/Sofa/Component/Constraint/Projective/tests/PointProjectiveConstraint_test.cpp similarity index 91% rename from Sofa/Component/Constraint/Projective/tests/ProjectToPointProjectiveConstraint_test.cpp rename to Sofa/Component/Constraint/Projective/tests/PointProjectiveConstraint_test.cpp index e6455a9b5f6..fdcbc6ddfa5 100644 --- a/Sofa/Component/Constraint/Projective/tests/ProjectToPointProjectiveConstraint_test.cpp +++ b/Sofa/Component/Constraint/Projective/tests/PointProjectiveConstraint_test.cpp @@ -27,7 +27,7 @@ using sofa::testing::NumericTest; #include #include #include -#include +#include #include #include #include @@ -41,11 +41,11 @@ using namespace defaulttype; using sofa::core::objectmodel::New; -/** Test suite for ProjectToPointProjectiveConstraint. +/** Test suite for PointProjectiveConstraint. The test cases are defined in the #Test_Cases member group. */ template -struct ProjectToPointProjectiveConstraint_test : public BaseSimulationTest, NumericTest +struct PointProjectiveConstraint_test : public BaseSimulationTest, NumericTest { typedef _DataTypes DataTypes; typedef typename DataTypes::VecCoord VecCoord; @@ -54,8 +54,8 @@ struct ProjectToPointProjectiveConstraint_test : public BaseSimulationTest, Nume typedef typename DataTypes::Deriv Deriv; typedef typename DataTypes::CPos CPos; typedef typename Coord::value_type Real; - typedef constraint::projective::ProjectToPointProjectiveConstraint ProjectToPointProjectiveConstraint; - typedef typename ProjectToPointProjectiveConstraint::SetIndexArray Indices; + typedef constraint::projective::PointProjectiveConstraint PointProjectiveConstraint; + typedef typename PointProjectiveConstraint::SetIndexArray Indices; typedef component::topology::container::dynamic::PointSetTopologyContainer PointSetTopologyContainer; typedef statecontainer::MechanicalObject MechanicalObject; @@ -65,7 +65,7 @@ struct ProjectToPointProjectiveConstraint_test : public BaseSimulationTest, Nume unsigned numNodes; ///< number of particles used for the test Indices indices; ///< indices of the nodes to project CPos targetPoint; ///< target point to project to - typename ProjectToPointProjectiveConstraint::SPtr projection; + typename PointProjectiveConstraint::SPtr projection; typename MechanicalObject::SPtr dofs; /// Create the context for the tests. @@ -84,7 +84,7 @@ struct ProjectToPointProjectiveConstraint_test : public BaseSimulationTest, Nume root->addObject(dofs); // Project to point constraint - projection = New(); + projection = New(); root->addObject(projection); /// Set the values @@ -224,9 +224,9 @@ typedef Types< > DataTypes; // the types to instanciate. // Test suite for all the instanciations -TYPED_TEST_SUITE(ProjectToPointProjectiveConstraint_test, DataTypes); +TYPED_TEST_SUITE(PointProjectiveConstraint_test, DataTypes); // first test case -TYPED_TEST( ProjectToPointProjectiveConstraint_test , oneConstrainedParticle ) +TYPED_TEST( PointProjectiveConstraint_test , oneConstrainedParticle ) { EXPECT_MSG_NOEMIT(Error) ; this->init_oneConstrainedParticle(); @@ -234,7 +234,7 @@ TYPED_TEST( ProjectToPointProjectiveConstraint_test , oneConstrainedParticle ) ASSERT_TRUE( this->test_projectVelocity() ); } // next test case -TYPED_TEST( ProjectToPointProjectiveConstraint_test , allParticlesConstrained ) +TYPED_TEST( PointProjectiveConstraint_test , allParticlesConstrained ) { EXPECT_MSG_NOEMIT(Error) ; this->init_allParticlesConstrained(); diff --git a/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp b/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp index 5835e5266fb..b9d34e25cc2 100644 --- a/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp +++ b/Sofa/Component/SolidMechanics/simutests/LinearElasticity_test.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include namespace sofa { @@ -158,9 +158,9 @@ CylinderTractionStruct createCylinderTractionScene( modeling::addNew >(root); tractionStruct.forceField=tpff; sofa::modeling::setDataLink(&boxRoi2->d_triangleIndices,&tpff->triangleList); - // ProjectToLineProjectiveConstraint - typename component::constraint::projective::ProjectToLineProjectiveConstraint::SPtr ptlc= - modeling::addNew >(root); + // LineProjectiveConstraint + typename component::constraint::projective::LineProjectiveConstraint::SPtr ptlc= + modeling::addNew >(root); ptlc->f_direction=Coord(1,0,0); ptlc->f_origin=Coord(0,0,0); sofa::type::vector vArray; diff --git a/applications/plugins/SofaTest/Elasticity_test.inl b/applications/plugins/SofaTest/Elasticity_test.inl index 8d7bcc5048b..3433abc20af 100644 --- a/applications/plugins/SofaTest/Elasticity_test.inl +++ b/applications/plugins/SofaTest/Elasticity_test.inl @@ -36,7 +36,7 @@ // Constraint -#include +#include #include #include #include @@ -241,9 +241,9 @@ CylinderTractionStruct Elasticity_test::createCylinderTra modeling::addNew >(root); tractionStruct.forceField=tpff; sofa::modeling::setDataLink(&boxRoi2->d_triangleIndices,&tpff->triangleList); - // ProjectToLineProjectiveConstraint - typename component::constraint::projective::ProjectToLineProjectiveConstraint::SPtr ptlc= - modeling::addNew >(root); + // LineProjectiveConstraint + typename component::constraint::projective::LineProjectiveConstraint::SPtr ptlc= + modeling::addNew >(root); ptlc->f_direction=Coord(1,0,0); ptlc->f_origin=Coord(0,0,0); sofa::type::vector vArray; diff --git a/applications/plugins/SofaTest/InitPlugin_test.h b/applications/plugins/SofaTest/InitPlugin_test.h index 8594c83953a..140827304d8 100644 --- a/applications/plugins/SofaTest/InitPlugin_test.h +++ b/applications/plugins/SofaTest/InitPlugin_test.h @@ -95,7 +95,7 @@ Other solver tests are available in Compliant_test: AssembledSolver_test and Dam -if constrained particle have the expected position. -if unconstrained particle have not changed. -Some projective constraint tests are available in SofaTest_test: ProjectToLineProjectiveConstraint and ProjectToPlaneConstraint. +Some projective constraint tests are available in SofaTest_test: LineProjectiveConstraint and ProjectToPlaneConstraint. - Engine test: To test engine you set input values and check if the ouput values correspond to the expected ones. The test Engine_test tests if the update method is called only if necessary. To test this a minimal engine TestEngine was created with a counter in its update method. diff --git a/examples/Benchmark/TopologicalChanges/ProjectDirectionConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectDirectionConstraint_RemovingMeshTest.scn index 24ee68485ca..7cdb983d4d2 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectDirectionConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectDirectionConstraint_RemovingMeshTest.scn @@ -5,7 +5,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn index 87abbf0dd2e..82a7db960a9 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectToLineConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn index b3df9a28747..2171a27bc6b 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectToPlaneConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn b/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn index f171b5055b3..0fc9b098e3b 100644 --- a/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn +++ b/examples/Benchmark/TopologicalChanges/ProjectToPointConstraint_RemovingMeshTest.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn b/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn index 2683807a135..726794f8664 100644 --- a/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn @@ -1,6 +1,6 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn b/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn index ae0094ef474..6b7fecb9a70 100644 --- a/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn @@ -1,6 +1,6 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn b/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn index 3d0508725a3..c9c99fc9716 100644 --- a/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn @@ -1,6 +1,6 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn b/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn index 568d1f73812..d6289699af8 100644 --- a/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn @@ -1,6 +1,6 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Engine/Generate/GenerateCylinder.scn b/examples/Component/Engine/Generate/GenerateCylinder.scn index 3355808d9a1..0811e77902f 100644 --- a/examples/Component/Engine/Generate/GenerateCylinder.scn +++ b/examples/Component/Engine/Generate/GenerateCylinder.scn @@ -1,6 +1,6 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Component/Engine/Generate/GenerateGrid.scn b/examples/Component/Engine/Generate/GenerateGrid.scn index fae198ee822..716d48c1cd6 100644 --- a/examples/Component/Engine/Generate/GenerateGrid.scn +++ b/examples/Component/Engine/Generate/GenerateGrid.scn @@ -1,6 +1,6 @@ - + @@ -24,7 +24,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/examples/Demos/simpleBoundaryConditions.scn b/examples/Demos/simpleBoundaryConditions.scn index 41888f274aa..003ba8a71e6 100644 --- a/examples/Demos/simpleBoundaryConditions.scn +++ b/examples/Demos/simpleBoundaryConditions.scn @@ -1,7 +1,7 @@ - + @@ -27,15 +27,15 @@ - + - + - + From e43420d93e841a274c32e7eac6b078059b753786 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 29 Nov 2023 15:14:22 +0100 Subject: [PATCH 19/28] Moved alias to original header --- .../lagrangian/model/BilateralInteractionConstraint.h | 6 ++++++ .../model/BilateralInteractionLagrangianConstraint.h | 3 --- .../constraint/lagrangian/model/SlidingConstraint.h | 6 ++++++ .../lagrangian/model/SlidingLagrangianConstraint.h | 4 ---- .../constraint/lagrangian/model/StopperConstraint.h | 7 +++++++ .../lagrangian/model/StopperLagrangianConstraint.h | 4 ---- .../constraint/lagrangian/model/UniformConstraint.h | 6 ++++++ .../lagrangian/model/UniformLagrangianConstraint.h | 3 --- .../lagrangian/model/UnilateralInteractionConstraint.h | 6 ++++++ .../model/UnilateralInteractionLagrangianConstraint.h | 4 ---- .../constraint/projective/AffineMovementConstraint.h | 6 ++++++ .../projective/AffineMovementProjectiveConstraint.h | 4 ---- .../component/constraint/projective/AttachConstraint.h | 6 ++++++ .../constraint/projective/AttachProjectiveConstraint.h | 4 ---- .../constraint/projective/DirectionProjectiveConstraint.h | 4 ---- .../sofa/component/constraint/projective/FixedConstraint.h | 6 ++++++ .../component/constraint/projective/FixedPlaneConstraint.h | 6 ++++++ .../constraint/projective/FixedPlaneProjectiveConstraint.h | 5 ----- .../constraint/projective/FixedProjectiveConstraint.h | 5 ----- .../constraint/projective/FixedRotationConstraint.h | 6 ++++++ .../projective/FixedRotationProjectiveConstraint.h | 5 ----- .../constraint/projective/FixedTranslationConstraint.h | 6 ++++++ .../projective/FixedTranslationProjectiveConstraint.h | 5 ----- .../constraint/projective/HermiteSplineConstraint.h | 6 ++++++ .../projective/HermiteSplineProjectiveConstraint.h | 3 --- .../constraint/projective/LineProjectiveConstraint.h | 4 ---- .../constraint/projective/LinearMovementConstraint.h | 6 ++++++ .../projective/LinearMovementProjectiveConstraint.h | 3 --- .../constraint/projective/LinearVelocityConstraint.h | 6 ++++++ .../projective/LinearVelocityProjectiveConstraint.h | 3 --- .../component/constraint/projective/OscillatorConstraint.h | 6 ++++++ .../constraint/projective/OscillatorProjectiveConstraint.h | 3 --- .../component/constraint/projective/ParabolicConstraint.h | 6 ++++++ .../constraint/projective/ParabolicProjectiveConstraint.h | 4 ---- .../constraint/projective/PartialFixedConstraint.h | 6 ++++++ .../projective/PartialFixedProjectiveConstraint.h | 4 ---- .../projective/PartialLinearMovementConstraint.h | 6 ++++++ .../projective/PartialLinearMovementProjectiveConstraint.h | 3 --- .../constraint/projective/PatchTestMovementConstraint.h | 6 ++++++ .../projective/PatchTestMovementProjectiveConstraint.h | 3 --- .../constraint/projective/PlaneProjectiveConstraint.h | 3 --- .../constraint/projective/PointProjectiveConstraint.h | 3 --- .../projective/PositionBasedDynamicsConstraint.h | 6 ++++++ .../projective/PositionBasedDynamicsProjectiveConstraint.h | 3 --- .../constraint/projective/ProjectDirectionConstraint.h | 6 ++++++ .../constraint/projective/ProjectToLineConstraint.h | 6 ++++++ .../constraint/projective/ProjectToPlaneConstraint.h | 6 ++++++ .../constraint/projective/ProjectToPointConstraint.h | 6 ++++++ .../constraint/projective/SkeletalMotionConstraint.h | 6 ++++++ .../projective/SkeletalMotionProjectiveConstraint.h | 3 --- 50 files changed, 151 insertions(+), 92 deletions(-) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h index d7be47bbc7b..0bbd84d0db7 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") + +namespace sofa::component::constraint::lagrangian::model +{ +template +using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "BilateralInteractionConstraint has been renamed to BilateralInteractionLagrangianConstraint") = BilateralInteractionLagrangianConstraint; +} diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h index 4288af3456a..a9e87512df0 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h @@ -192,7 +192,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralIn extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint< Rigid3Types >; #endif -template -using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "BilateralInteractionConstraint has been renamed to BilateralInteractionLagrangianConstraint") = BilateralInteractionLagrangianConstraint; - } // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h index ae6e1f0482e..c51cdef4931 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h") + +namespace sofa::component::constraint::lagrangian::model +{ +template +using SlidingConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SlidingConstraint has been renamed to SlidingLagrangianConstraint") = SlidingLagrangianConstraint; +} diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h index a450eea0ce1..81015097548 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h @@ -110,8 +110,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API SlidingLagr #endif -template -using SlidingConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SlidingConstraint has been renamed to SlidingLagrangianConstraint") = SlidingLagrangianConstraint; - - } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h index 3f685373bd3..0743627e3e4 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h @@ -24,3 +24,10 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h") + + +namespace sofa::component::constraint::lagrangian::model +{ +template +using StopperConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "StopperConstraint has been renamed to StopperLagrangianConstraint") = StopperLagrangianConstraint; +} diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h index d285a11b53d..e9f6d463985 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h @@ -124,8 +124,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API StopperLagr #endif -template -using StopperConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "StopperConstraint has been renamed to StopperLagrangianConstraint") = StopperLagrangianConstraint; - - } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h index f7c7b8858f9..1aed74a9779 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h") + +namespace sofa::component::constraint::lagrangian::model +{ +template +using UniformConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UniformConstraint has been renamed to UniformLagrangianConstraint") = UniformLagrangianConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h index 647ac2754cf..7576ad73b2f 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h @@ -74,8 +74,5 @@ class UniformLagrangianConstraint : public sofa::core::behavior::Constraint< Dat extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UniformLagrangianConstraint; #endif -template -using UniformConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UniformConstraint has been renamed to UniformLagrangianConstraint") = UniformLagrangianConstraint; - } // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h index cf12d105c2b..56a2388bb99 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h") + +namespace sofa::component::constraint::lagrangian::model +{ +template +using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UnilateralInteractionConstraint has been renamed to UnilateralInteractionLagrangianConstraint") = UnilateralInteractionLagrangianConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h index 2669be18f93..d777b53b4fb 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h @@ -152,11 +152,7 @@ class UnilateralInteractionLagrangianConstraint : public core::behavior::PairInt #if !defined(SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP) extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionLagrangianConstraint; - #endif -template -using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UnilateralInteractionConstraint has been renamed to UnilateralInteractionLagrangianConstraint") = UnilateralInteractionLagrangianConstraint; - } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h index 43eadcfe07a..77386f89d0b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AffineMovementConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using AffineMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AffineMovementConstraint has been renamed to AffineMovementProjectiveConstraint") = AffineMovementProjectiveConstraint; +} diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h index f769a867a6b..74ca2823e84 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.h @@ -162,8 +162,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementPro extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; #endif //SOFABOUNDARYCONDITION_AFFINEMOVEMENTPROJECTIVECONSTRAINT_CPP -template -using AffineMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AffineMovementConstraint has been renamed to AffineMovementProjectiveConstraint") = AffineMovementProjectiveConstraint; - - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h index d93f7476b6f..de46a43327f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AttachProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using AttachConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AttachConstraint has been renamed to AttachProjectiveConstraint") = AttachProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h index a463114ff85..37ed886dc4b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.h @@ -121,8 +121,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveC extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AttachProjectiveConstraint; #endif -template -using AttachConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AttachConstraint has been renamed to AttachProjectiveConstraint") = AttachProjectiveConstraint; - - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h index b68daa63860..29c85fc63e0 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.h @@ -128,10 +128,6 @@ protected : #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_DirectionProjectiveConstraint_CPP) extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; - #endif -template -using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectDirectionConstraint has been renamed to DirectionProjectiveConstraint") = DirectionProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h index a12a7207113..c2120e5ab12 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using FixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedConstraint has been renamed to FixedProjectiveConstraint") = FixedProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h index 45b6a9c8d49..c541fca6554 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using FixedPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedPlaneConstraint has been renamed to FixedPlaneProjectiveConstraint") = FixedPlaneProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h index f86187d7549..6885db83f9e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h @@ -130,11 +130,6 @@ class FixedPlaneProjectiveConstraint : public ProjectiveConstraintSet extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedPlaneProjectiveConstraint; - #endif -template -using FixedPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedPlaneConstraint has been renamed to FixedPlaneProjectiveConstraint") = FixedPlaneProjectiveConstraint; - - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h index ae2959a9bb7..d2fad673643 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.h @@ -132,11 +132,6 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveCo extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedProjectiveConstraint; - #endif -template -using FixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedConstraint has been renamed to FixedProjectiveConstraint") = FixedProjectiveConstraint; - - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h index 77ae733eeb3..81266d144a2 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using FixedRotationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedRotationConstraint has been renamed to FixedRotationProjectiveConstraint") = FixedRotationProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h index d8cc61cb115..fa9800c22fe 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h @@ -74,11 +74,6 @@ protected : #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_FIXEDROTATIONPROJECTIVECONSTRAINT_CPP) extern template class FixedRotationProjectiveConstraint; - #endif -template -using FixedRotationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedRotationConstraint has been renamed to FixedRotationProjectiveConstraint") = FixedRotationProjectiveConstraint; - - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h index 34d2f8d097d..11124e60adf 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using FixedTranslationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedTranslationConstraint has been renamed to FixedTranslationProjectiveConstraint") = FixedTranslationProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h index 101762a6567..4290a2c6d13 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h @@ -100,11 +100,6 @@ class FixedTranslationProjectiveConstraint : public core::behavior::ProjectiveCo extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; - #endif -template -using FixedTranslationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedTranslationConstraint has been renamed to FixedTranslationProjectiveConstraint") = FixedTranslationProjectiveConstraint; - - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h index f059eb884ee..bc196dbc96c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using HermiteSplineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "HermiteSplineConstraint has been renamed to HermiteSplineProjectiveConstraint") = HermiteSplineProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h index 7a284739e2c..1777e0bda2f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h @@ -131,7 +131,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API HermiteSplineProj #endif -template -using HermiteSplineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "HermiteSplineConstraint has been renamed to HermiteSplineProjectiveConstraint") = HermiteSplineProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h index 5d897a32283..5a907598823 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.h @@ -132,10 +132,6 @@ protected : #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_LineProjectiveConstraint_CPP) extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; - #endif -template -using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToLineConstraint has been renamed to LineProjectiveConstraint") = LineProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h index a6087d6acb0..89e083b4972 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using LinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearMovementConstraint has been renamed to LinearMovementProjectiveConstraint") = LinearMovementProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h index af424d6d1ef..b5013c890a0 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h @@ -165,7 +165,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementPro extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearMovementProjectiveConstraint; #endif -template -using LinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearMovementConstraint has been renamed to LinearMovementProjectiveConstraint") = LinearMovementProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h index ea7a6b514e2..bfa83ace93f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using LinearVelocityConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearVelocityConstraint has been renamed to LinearVelocityProjectiveConstraint") = LinearVelocityProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h index 7b3ab049b69..74c67b83997 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h @@ -132,7 +132,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityPro #endif -template -using LinearVelocityConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearVelocityConstraint has been renamed to LinearVelocityProjectiveConstraint") = LinearVelocityProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h index b014a222ce4..55ac6c2b22a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using OscillatorConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "OscillatorConstraint has been renamed to OscillatorProjectiveConstraint") = OscillatorProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h index cedbc55efd2..dd97f5d8b45 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.h @@ -109,7 +109,4 @@ extern template class OscillatorProjectiveConstraint; extern template class OscillatorProjectiveConstraint; #endif -template -using OscillatorConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "OscillatorConstraint has been renamed to OscillatorProjectiveConstraint") = OscillatorProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h index ac6a825815f..a9e987edfa3 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using ParabolicConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ParabolicConstraint has been renamed to ParabolicProjectiveConstraint") = ParabolicProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h index 28f60603a96..422c9cb020b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.h @@ -121,10 +121,6 @@ class ParabolicProjectiveConstraint : public core::behavior::ProjectiveConstrain #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PARABOLICPROJECTIVECONSTRAINT_CPP) extern template class ParabolicProjectiveConstraint; extern template class ParabolicProjectiveConstraint; - #endif -template -using ParabolicConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ParabolicConstraint has been renamed to ParabolicProjectiveConstraint") = ParabolicProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h index 0154ef31dc4..34b0b50b64f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using PartialFixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialFixedConstraint has been renamed to PartialFixedProjectiveConstraint") = PartialFixedProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h index 71c31a7e1ff..89f347b303d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h @@ -100,10 +100,6 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProje extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; - #endif -template -using PartialFixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialFixedConstraint has been renamed to PartialFixedProjectiveConstraint") = PartialFixedProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h index 4a69e586d60..653e874c253 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using PartialLinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialLinearMovementConstraint has been renamed to PartialLinearMovementProjectiveConstraint") = PartialLinearMovementProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h index f8f95983474..336f0bf2ce6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h @@ -173,7 +173,4 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMove extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; #endif -template -using PartialLinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialLinearMovementConstraint has been renamed to PartialLinearMovementProjectiveConstraint") = PartialLinearMovementProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h index 36b07bb0bc6..ab88ed68a72 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using PatchTestMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PatchTestMovementConstraint has been renamed to PatchTestMovementProjectiveConstraint") = PatchTestMovementProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h index bd0def66848..5cabd8d460f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h @@ -159,10 +159,7 @@ public : #if !defined(SOFA_COMPONENT_PROJECTIVECONSTRAINTSET_PATCHTESTMOVEMENTPROJECTIVECONSTRAINT_CPP) extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; - #endif -template -using PatchTestMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PatchTestMovementConstraint has been renamed to PatchTestMovementProjectiveConstraint") = PatchTestMovementProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h index 03912cad7bf..13a325f7d8c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.h @@ -133,8 +133,5 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PlaneProjectiveCo #endif -template -using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPlaneConstraint has been renamed to PlaneProjectiveConstraint") = PlaneProjectiveConstraint; - } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h index 3349c24efd9..2055e7fe236 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.h @@ -125,9 +125,6 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveCo extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; - #endif -template -using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPointConstraint has been renamed to PointProjectiveConstraint") = PointProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h index a53ebf6f5f8..37cf77fcbcc 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using PositionBasedDynamicsConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PositionBasedDynamicsConstraint has been renamed to PositionBasedDynamicsProjectiveConstraint") = PositionBasedDynamicsProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h index 9915c63d8cc..ad225656f55 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h @@ -108,10 +108,7 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDyna extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; //extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; - #endif -template -using PositionBasedDynamicsConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PositionBasedDynamicsConstraint has been renamed to PositionBasedDynamicsProjectiveConstraint") = PositionBasedDynamicsProjectiveConstraint; } // namespace sofa::component::constraint::projective diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h index 173a3d8a58c..cdf8e40a0da 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/DirectionProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectDirectionConstraint has been renamed to DirectionProjectiveConstraint") = DirectionProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h index 02c5f41deba..e0d70b91d12 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LineProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToLineConstraint has been renamed to LineProjectiveConstraint") = LineProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h index e2cbcbbb70e..2e19fd9f70b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PlaneProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPlaneConstraint has been renamed to PlaneProjectiveConstraint") = PlaneProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h index 7a6231bd4a9..3e7d4ef408a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PointProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPointConstraint has been renamed to PointProjectiveConstraint") = PointProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h index 402c3538226..752ac24ed0f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h @@ -24,3 +24,9 @@ #include SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h") + +namespace sofa::component::constraint::projective +{ +template +using SkeletalMotionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SkeletalMotionConstraint has been renamed to SkeletalMotionProjectiveConstraint") = SkeletalMotionProjectiveConstraint; +} \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h index 220c7dfaaad..b47595e588e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h @@ -243,8 +243,5 @@ extern template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionPro #endif -template -using SkeletalMotionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SkeletalMotionConstraint has been renamed to SkeletalMotionProjectiveConstraint") = SkeletalMotionProjectiveConstraint; - } // namespace sofa::component::constraint::projective From 9a2a1d0088861712843522c87d5e8f59552f3688 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 29 Nov 2023 15:19:20 +0100 Subject: [PATCH 20/28] Changed deprecation date --- .../lagrangian/model/BilateralInteractionConstraint.h | 4 ++-- .../lagrangian/model/BilateralInteractionConstraint.inl | 2 +- .../component/constraint/lagrangian/model/SlidingConstraint.h | 4 ++-- .../constraint/lagrangian/model/SlidingConstraint.inl | 2 +- .../component/constraint/lagrangian/model/StopperConstraint.h | 4 ++-- .../constraint/lagrangian/model/StopperConstraint.inl | 2 +- .../component/constraint/lagrangian/model/UniformConstraint.h | 4 ++-- .../constraint/lagrangian/model/UniformConstraint.inl | 2 +- .../lagrangian/model/UnilateralInteractionConstraint.h | 4 ++-- .../lagrangian/model/UnilateralInteractionConstraint.inl | 2 +- .../constraint/projective/AffineMovementConstraint.h | 4 ++-- .../constraint/projective/AffineMovementConstraint.inl | 2 +- .../sofa/component/constraint/projective/AttachConstraint.h | 4 ++-- .../sofa/component/constraint/projective/AttachConstraint.inl | 2 +- .../sofa/component/constraint/projective/FixedConstraint.h | 4 ++-- .../sofa/component/constraint/projective/FixedConstraint.inl | 2 +- .../component/constraint/projective/FixedPlaneConstraint.h | 4 ++-- .../component/constraint/projective/FixedPlaneConstraint.inl | 2 +- .../component/constraint/projective/FixedRotationConstraint.h | 4 ++-- .../constraint/projective/FixedRotationConstraint.inl | 2 +- .../constraint/projective/FixedTranslationConstraint.h | 4 ++-- .../constraint/projective/FixedTranslationConstraint.inl | 2 +- .../component/constraint/projective/HermiteSplineConstraint.h | 4 ++-- .../constraint/projective/HermiteSplineConstraint.inl | 2 +- .../constraint/projective/LinearMovementConstraint.h | 4 ++-- .../constraint/projective/LinearMovementConstraint.inl | 2 +- .../constraint/projective/LinearVelocityConstraint.h | 4 ++-- .../constraint/projective/LinearVelocityConstraint.inl | 2 +- .../component/constraint/projective/OscillatorConstraint.h | 4 ++-- .../component/constraint/projective/OscillatorConstraint.inl | 2 +- .../component/constraint/projective/ParabolicConstraint.h | 4 ++-- .../component/constraint/projective/ParabolicConstraint.inl | 2 +- .../component/constraint/projective/PartialFixedConstraint.h | 4 ++-- .../constraint/projective/PartialFixedConstraint.inl | 2 +- .../constraint/projective/PartialLinearMovementConstraint.h | 4 ++-- .../constraint/projective/PartialLinearMovementConstraint.inl | 2 +- .../constraint/projective/PatchTestMovementConstraint.h | 4 ++-- .../constraint/projective/PatchTestMovementConstraint.inl | 2 +- .../constraint/projective/PositionBasedDynamicsConstraint.h | 4 ++-- .../constraint/projective/PositionBasedDynamicsConstraint.inl | 2 +- .../constraint/projective/ProjectDirectionConstraint.h | 4 ++-- .../constraint/projective/ProjectDirectionConstraint.inl | 2 +- .../component/constraint/projective/ProjectToLineConstraint.h | 4 ++-- .../constraint/projective/ProjectToLineConstraint.inl | 2 +- .../constraint/projective/ProjectToPlaneConstraint.h | 4 ++-- .../constraint/projective/ProjectToPlaneConstraint.inl | 2 +- .../constraint/projective/ProjectToPointConstraint.h | 4 ++-- .../constraint/projective/ProjectToPointConstraint.inl | 2 +- .../constraint/projective/SkeletalMotionConstraint.h | 4 ++-- .../constraint/projective/SkeletalMotionConstraint.inl | 2 +- 50 files changed, 75 insertions(+), 75 deletions(-) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h index 0bbd84d0db7..ef03dd20454 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "BilateralInteractionConstraint has been renamed to BilateralInteractionLagrangianConstraint") = BilateralInteractionLagrangianConstraint; +using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "BilateralInteractionConstraint has been renamed to BilateralInteractionLagrangianConstraint") = BilateralInteractionLagrangianConstraint; } diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl index 2b2c2abcc34..67fcf165710 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h index c51cdef4931..b78a9991843 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using SlidingConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SlidingConstraint has been renamed to SlidingLagrangianConstraint") = SlidingLagrangianConstraint; +using SlidingConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "SlidingConstraint has been renamed to SlidingLagrangianConstraint") = SlidingLagrangianConstraint; } diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl index c328ba4d984..777bbaf511e 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h index 0743627e3e4..f73e0306abe 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.h @@ -23,11 +23,11 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using StopperConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "StopperConstraint has been renamed to StopperLagrangianConstraint") = StopperLagrangianConstraint; +using StopperConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "StopperConstraint has been renamed to StopperLagrangianConstraint") = StopperLagrangianConstraint; } diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl index 574e86c8db3..9c4215fb990 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/StopperConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/StopperLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h index 1aed74a9779..23e3d697dec 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using UniformConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UniformConstraint has been renamed to UniformLagrangianConstraint") = UniformLagrangianConstraint; +using UniformConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "UniformConstraint has been renamed to UniformLagrangianConstraint") = UniformLagrangianConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl index 1fc4488730b..991bb0accc8 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UniformConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UniformLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h index 56a2388bb99..c7738de22e1 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "UnilateralInteractionConstraint has been renamed to UnilateralInteractionLagrangianConstraint") = UnilateralInteractionLagrangianConstraint; +using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "UnilateralInteractionConstraint has been renamed to UnilateralInteractionLagrangianConstraint") = UnilateralInteractionLagrangianConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl index 0da78f67d34..1b2dee107de 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h index 77386f89d0b..d17e1e9364d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AffineMovementConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/AffineMovementConstraint.h") namespace sofa::component::constraint::projective { template -using AffineMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AffineMovementConstraint has been renamed to AffineMovementProjectiveConstraint") = AffineMovementProjectiveConstraint; +using AffineMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "AffineMovementConstraint has been renamed to AffineMovementProjectiveConstraint") = AffineMovementProjectiveConstraint; } diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl index 20e6e0d8886..5230ec8026b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AffineMovementConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/AffineMovementConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h index de46a43327f..692f1178c2d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AttachProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/AttachProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using AttachConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "AttachConstraint has been renamed to AttachProjectiveConstraint") = AttachProjectiveConstraint; +using AttachConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "AttachConstraint has been renamed to AttachProjectiveConstraint") = AttachProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl index 83e8ee50264..ed5521f875d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/AttachProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/AttachProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h index c2120e5ab12..1ddf32be894 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using FixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedConstraint has been renamed to FixedProjectiveConstraint") = FixedProjectiveConstraint; +using FixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "FixedConstraint has been renamed to FixedProjectiveConstraint") = FixedProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl index 5b537294c99..4244fcd3b94 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h index c541fca6554..8848ba55069 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using FixedPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedPlaneConstraint has been renamed to FixedPlaneProjectiveConstraint") = FixedPlaneProjectiveConstraint; +using FixedPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "FixedPlaneConstraint has been renamed to FixedPlaneProjectiveConstraint") = FixedPlaneProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl index aee6c46621b..34acfcbe022 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h index 81266d144a2..511c63a88d4 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using FixedRotationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedRotationConstraint has been renamed to FixedRotationProjectiveConstraint") = FixedRotationProjectiveConstraint; +using FixedRotationConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "FixedRotationConstraint has been renamed to FixedRotationProjectiveConstraint") = FixedRotationProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl index aec31d964c6..0ecc0e7851c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedRotationProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h index 11124e60adf..47203f733ee 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using FixedTranslationConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "FixedTranslationConstraint has been renamed to FixedTranslationProjectiveConstraint") = FixedTranslationProjectiveConstraint; +using FixedTranslationConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "FixedTranslationConstraint has been renamed to FixedTranslationProjectiveConstraint") = FixedTranslationProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl index 525c736847f..7b1b96bad54 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h index bc196dbc96c..9d2f358ef52 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using HermiteSplineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "HermiteSplineConstraint has been renamed to HermiteSplineProjectiveConstraint") = HermiteSplineProjectiveConstraint; +using HermiteSplineConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "HermiteSplineConstraint has been renamed to HermiteSplineProjectiveConstraint") = HermiteSplineProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl index d11f87acb31..6064b936335 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h index 89e083b4972..f06082811df 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using LinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearMovementConstraint has been renamed to LinearMovementProjectiveConstraint") = LinearMovementProjectiveConstraint; +using LinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "LinearMovementConstraint has been renamed to LinearMovementProjectiveConstraint") = LinearMovementProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl index b652d73c8d9..1a8538c38a0 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/LinearMovementProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h index bfa83ace93f..297a56d6f2c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using LinearVelocityConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "LinearVelocityConstraint has been renamed to LinearVelocityProjectiveConstraint") = LinearVelocityProjectiveConstraint; +using LinearVelocityConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "LinearVelocityConstraint has been renamed to LinearVelocityProjectiveConstraint") = LinearVelocityProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl index bf7a13d8187..4e9baec9e9f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h index 55ac6c2b22a..9bbd88c7ce1 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using OscillatorConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "OscillatorConstraint has been renamed to OscillatorProjectiveConstraint") = OscillatorProjectiveConstraint; +using OscillatorConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "OscillatorConstraint has been renamed to OscillatorProjectiveConstraint") = OscillatorProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl index d9805d4210c..72eca9675a6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/OscillatorProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h index a9e987edfa3..9dcfe542353 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using ParabolicConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ParabolicConstraint has been renamed to ParabolicProjectiveConstraint") = ParabolicProjectiveConstraint; +using ParabolicConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "ParabolicConstraint has been renamed to ParabolicProjectiveConstraint") = ParabolicProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl index 711d390fcc7..7c6fa4b59a2 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/ParabolicProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h index 34b0b50b64f..b5d76e4379f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using PartialFixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialFixedConstraint has been renamed to PartialFixedProjectiveConstraint") = PartialFixedProjectiveConstraint; +using PartialFixedConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "PartialFixedConstraint has been renamed to PartialFixedProjectiveConstraint") = PartialFixedProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl index 55ffbb891af..1fd9f96ae7b 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PartialFixedProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h index 653e874c253..f3eb83d8868 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using PartialLinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PartialLinearMovementConstraint has been renamed to PartialLinearMovementProjectiveConstraint") = PartialLinearMovementProjectiveConstraint; +using PartialLinearMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "PartialLinearMovementConstraint has been renamed to PartialLinearMovementProjectiveConstraint") = PartialLinearMovementProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl index cf9428c4888..4d212e34cae 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h index ab88ed68a72..3857c8c889c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using PatchTestMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PatchTestMovementConstraint has been renamed to PatchTestMovementProjectiveConstraint") = PatchTestMovementProjectiveConstraint; +using PatchTestMovementConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "PatchTestMovementConstraint has been renamed to PatchTestMovementProjectiveConstraint") = PatchTestMovementProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl index ff6b2f45bbe..7a3a2a49a06 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h index 37cf77fcbcc..f27bc01bb64 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using PositionBasedDynamicsConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "PositionBasedDynamicsConstraint has been renamed to PositionBasedDynamicsProjectiveConstraint") = PositionBasedDynamicsProjectiveConstraint; +using PositionBasedDynamicsConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "PositionBasedDynamicsConstraint has been renamed to PositionBasedDynamicsProjectiveConstraint") = PositionBasedDynamicsProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl index 87e1d67275e..35018c27864 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h index cdf8e40a0da..53470fae7fd 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/DirectionProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/DirectionProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectDirectionConstraint has been renamed to DirectionProjectiveConstraint") = DirectionProjectiveConstraint; +using ProjectDirectionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "ProjectDirectionConstraint has been renamed to DirectionProjectiveConstraint") = DirectionProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl index 8640eb081fd..8f9d63e5751 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectDirectionConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/DirectionProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/DirectionProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h index e0d70b91d12..1824578181a 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LineProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/LineProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToLineConstraint has been renamed to LineProjectiveConstraint") = LineProjectiveConstraint; +using ProjectToLineConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "ProjectToLineConstraint has been renamed to LineProjectiveConstraint") = LineProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl index b89742555da..3b15b549d19 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToLineConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/LineProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/LineProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h index 2e19fd9f70b..d7fb513705e 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PlaneProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PlaneProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPlaneConstraint has been renamed to PlaneProjectiveConstraint") = PlaneProjectiveConstraint; +using ProjectToPlaneConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "ProjectToPlaneConstraint has been renamed to PlaneProjectiveConstraint") = PlaneProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl index 3f721631ffb..b003eab4b41 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPlaneConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PlaneProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PlaneProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h index 3e7d4ef408a..c5902f37823 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PointProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PointProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "ProjectToPointConstraint has been renamed to PointProjectiveConstraint") = PointProjectiveConstraint; +using ProjectToPointConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "ProjectToPointConstraint has been renamed to PointProjectiveConstraint") = PointProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl index 0a7a4499ec9..70213c8c05f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ProjectToPointConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/PointProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/PointProjectiveConstraint.inl") diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h index 752ac24ed0f..9a5b8fc1fca 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.h @@ -23,10 +23,10 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.h") namespace sofa::component::constraint::projective { template -using SkeletalMotionConstraint SOFA_ATTRIBUTE_DEPRECATED("v23.12 ", "v24.12", "SkeletalMotionConstraint has been renamed to SkeletalMotionProjectiveConstraint") = SkeletalMotionProjectiveConstraint; +using SkeletalMotionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "SkeletalMotionConstraint has been renamed to SkeletalMotionProjectiveConstraint") = SkeletalMotionProjectiveConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl index d8a93524815..2682541f635 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionConstraint.inl @@ -23,4 +23,4 @@ #include -SOFA_DEPRECATED_HEADER("v23.12", "v24.12", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.inl") From e9dc62a78c80214dc102a202e45b472f1e950abb Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 29 Nov 2023 17:01:15 +0100 Subject: [PATCH 21/28] add component change entry --- .../src/sofa/helper/ComponentChange.cpp | 29 +++++++++++++++++++ .../Helper/src/sofa/helper/ComponentChange.h | 14 +++++++++ 2 files changed, 43 insertions(+) diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index a3cb1196bed..b90405afd3c 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -722,6 +722,35 @@ const std::map > uncreatableComponents // Moved to CSparseSolvers { "SparseCholeskySolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, { "SparseLUSolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, + + // Change Constraint naming #4302 + {"AffineMovementConstraint", Renamed("v24.06","v25.06","AffineMovementProjectiveConstraint")}, + {"AttachConstraint", Renamed("v24.06","v25.06","AttachProjectiveConstraint")}, + {"FixedConstraint", Renamed("v24.06","v25.06","FixedProjectiveConstraint")}, + {"FixedPlaneConstraint", Renamed("v24.06","v25.06","FixedPlaneProjectiveConstraint")}, + {"FixedRotationConstraint", Renamed("v24.06","v25.06","FixedRotationProjectiveConstraint")}, + {"FixedTranslationConstraint", Renamed("v24.06","v25.06","FixedTranslationProjectiveConstraint")}, + {"HermiteSplineConstraint", Renamed("v24.06","v25.06","HermiteSplineProjectiveConstraint")}, + {"LinearMovementConstraint", Renamed("v24.06","v25.06","LinearMovementProjectiveConstraint")}, + {"LinearVelocityConstraint", Renamed("v24.06","v25.06","LinearVelocityProjectiveConstraint")}, + {"OscillatorConstraint", Renamed("v24.06","v25.06","OscillatorProjectiveConstraint")}, + {"ParabolicConstraint", Renamed("v24.06","v25.06","ParabolicProjectiveConstraint")}, + {"PartialFixedConstraint", Renamed("v24.06","v25.06","PartialFixedProjectiveConstraint")}, + {"PartialLinearMovementConstraint", Renamed("v24.06","v25.06","PartialLinearMovementProjectiveConstraint")}, + {"PatchTestMovementConstraint", Renamed("v24.06","v25.06","PatchTestMovementProjectiveConstraint")}, + {"PositionBasedDynamicsConstraint", Renamed("v24.06","v25.06","PositionBasedDynamicsProjectiveConstraint")}, + {"SkeletalMotionConstraint", Renamed("v24.06","v25.06","SkeletalMotionProjectiveConstraint")}, + {"ProjectToLineConstraint", Renamed("v24.06","v25.06","LineProjectiveConstraint")}, + {"ProjectToPlaneConstraint", Renamed("v24.06","v25.06","PlaneProjectiveConstraint")}, + {"ProjectToPointConstraint", Renamed("v24.06","v25.06","PointProjectiveConstraint")}, + {"ProjectDirectionConstraint", Renamed("v24.06","v25.06","DirectionProjectiveConstraint")}, + {"BilateralInteractionConstraint", Renamed("v24.06","v25.06","BilateralInteractionLagrangianConstraint")}, + {"SlidingConstraint", Renamed("v24.06","v25.06","SlidingLagrangianConstraint")}, + {"StopperConstraint", Renamed("v24.06","v25.06","StopperLagrangianConstraint")}, + {"UniformConstraint", Renamed("v24.06","v25.06","UniformLagrangianConstraint")}, + {"UnilateralInteractionConstraint", Renamed("v24.06","v25.06","UnilateralInteractionLagrangianConstraint")} + + }; } // namespace sofa::helper::lifecycle diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h index 732065b8bc9..bc92a04a532 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h @@ -111,6 +111,20 @@ class SOFA_HELPER_API Moved : public ComponentChange } }; +class SOFA_HELPER_API Renamed : public ComponentChange +{ +public: + Renamed(const std::string& sinceVersion, const std::string& untilVersion, const std::string& newName) + { + std::stringstream output; + output << "This component has been RENAMED to " << newName << " since SOFA " << sinceVersion + << ", and this alias will be removed in SOFA " << untilVersion << "." + << " To continue using this component after SOFA "<< untilVersion <<" you will need to update your scene "; + m_message = output.str(); + m_changeVersion = untilVersion; + } +}; + extern SOFA_HELPER_API const std::map< std::string, Deprecated, std::less<> > deprecatedComponents; extern SOFA_HELPER_API const std::map< std::string, ComponentChange, std::less<> > uncreatableComponents; From 78a1cb39f8be738ee1200295e10806e8e90632a3 Mon Sep 17 00:00:00 2001 From: bakpaul Date: Mon, 11 Dec 2023 17:25:59 +0100 Subject: [PATCH 22/28] Change name following discussion with Hugo --- .../response/contact/FrictionContact.h | 4 +- .../response/contact/FrictionContact.inl | 2 +- .../response/contact/StickContactConstraint.h | 4 +- .../contact/StickContactConstraint.inl | 2 +- .../Lagrangian/Model/CMakeLists.txt | 12 +- .../model/BilateralInteractionConstraint.h | 6 +- .../model/BilateralInteractionConstraint.inl | 4 +- ....cpp => BilateralLagrangianConstraint.cpp} | 156 +++++++++--------- ...aint.h => BilateralLagrangianConstraint.h} | 28 ++-- ....inl => BilateralLagrangianConstraint.inl} | 42 ++--- .../model/SlidingLagrangianConstraint.inl | 4 +- .../model/UnilateralInteractionConstraint.h | 6 +- .../model/UnilateralInteractionConstraint.inl | 4 +- ...cpp => UnilateralLagrangianConstraint.cpp} | 10 +- ...int.h => UnilateralLagrangianConstraint.h} | 12 +- ...inl => UnilateralLagrangianConstraint.inl} | 34 ++-- .../BilateralInteractionConstraint.scn | 2 +- .../performer/ConstraintAttachBodyPerformer.h | 6 +- .../ConstraintAttachBodyPerformer.inl | 6 +- .../src/sofa/helper/ComponentChange.cpp | 4 +- applications/plugins/SofaCUDA/CMakeLists.txt | 2 +- ... => CudaBilateralLagrangianConstraint.cpp} | 20 +-- .../BilateralInteractionConstraint_NNCG.scn | 10 +- .../BilateralInteractionConstraint_PGS.scn | 12 +- .../BilateralInteractionConstraint_Rigid.scn | 6 +- .../BilateralInteractionConstraint_UGS.scn | 12 +- .../Engine/Select/NearestPointROI.scn | 6 +- ...RemovingBilateralInteractionConstraint.scn | 4 +- 28 files changed, 210 insertions(+), 210 deletions(-) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{BilateralInteractionLagrangianConstraint.cpp => BilateralLagrangianConstraint.cpp} (55%) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{BilateralInteractionLagrangianConstraint.h => BilateralLagrangianConstraint.h} (85%) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{BilateralInteractionLagrangianConstraint.inl => BilateralLagrangianConstraint.inl} (87%) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{UnilateralInteractionLagrangianConstraint.cpp => UnilateralLagrangianConstraint.cpp} (89%) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{UnilateralInteractionLagrangianConstraint.h => UnilateralLagrangianConstraint.h} (91%) rename Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/{UnilateralInteractionLagrangianConstraint.inl => UnilateralLagrangianConstraint.inl} (83%) rename applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/{CudaBilateralInteractionLagrangianConstraint.cpp => CudaBilateralLagrangianConstraint.cpp} (70%) diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h index 3e71d5e0a69..a50fc209383 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -60,7 +60,7 @@ class FrictionContact : public core::collision::Contact, public ContactIdentifie mapper::ContactMapper mapper1; mapper::ContactMapper mapper2; - constraint::lagrangian::model::UnilateralInteractionLagrangianConstraint::SPtr m_constraint; + constraint::lagrangian::model::UnilateralLagrangianConstraint::SPtr m_constraint; core::objectmodel::BaseContext* parent; Data mu; ///< friction coefficient (0 for frictionless contacts) diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl index 6da62dd345b..d0d093e4db1 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/FrictionContact.inl @@ -144,7 +144,7 @@ void FrictionContact::activ { mmodel2 = mapper2.createMapping(getName().c_str()); } - m_constraint = sofa::core::objectmodel::New >(mmodel1, mmodel2); + m_constraint = sofa::core::objectmodel::New >(mmodel1, mmodel2); m_constraint->setName( getName() ); setInteractionTags(mmodel1, mmodel2); m_constraint->setCustomTolerance( tol.getValue() ); diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h index 381a414bdcc..f51e5f20b53 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ class StickContactConstraint : public core::collision::Contact, public ContactId mapper::ContactMapper mapper1; mapper::ContactMapper mapper2; - constraint::lagrangian::model::BilateralInteractionLagrangianConstraint::SPtr m_constraint; + constraint::lagrangian::model::BilateralLagrangianConstraint::SPtr m_constraint; core::objectmodel::BaseContext* parent; std::vector< sofa::core::collision::DetectionOutput* > contacts; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl index 307053696ff..49ad5f0e91a 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/StickContactConstraint.inl @@ -128,7 +128,7 @@ void StickContactConstraint::activateMappers( msg_info() << "Creating StickContactConstraint bilateral constraints"; MechanicalState1* mstate1 = mapper1.createMapping(mapper::GenerateStringID::generate().c_str()); MechanicalState2* mstate2 = mapper2.createMapping(mapper::GenerateStringID::generate().c_str()); - m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); + m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); m_constraint->setName( getName() ); } diff --git a/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt b/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt index 168cf437499..0271b551fcc 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt +++ b/Sofa/Component/Constraint/Lagrangian/Model/CMakeLists.txt @@ -19,25 +19,25 @@ set(HEADER_FILES ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionConstraint.inl - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionLagrangianConstraint.h - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionLagrangianConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralLagrangianConstraint.inl ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.inl ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.inl ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.h ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.inl - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionLagrangianConstraint.h - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionLagrangianConstraint.inl + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralLagrangianConstraint.h + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralLagrangianConstraint.inl ) set(SOURCE_FILES ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/init.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralInteractionLagrangianConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/BilateralLagrangianConstraint.cpp ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/SlidingLagrangianConstraint.cpp ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/StopperLagrangianConstraint.cpp ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UniformLagrangianConstraint.cpp - ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralInteractionLagrangianConstraint.cpp + ${SOFACOMPONENTCONSTRAINTLAGRANGIANMODEL_SOURCE_DIR}/UnilateralLagrangianConstraint.cpp ) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h index ef03dd20454..88739f76ee8 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.h @@ -21,12 +21,12 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "BilateralInteractionConstraint has been renamed to BilateralInteractionLagrangianConstraint") = BilateralInteractionLagrangianConstraint; +using BilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "BilateralInteractionConstraint has been renamed to BilateralLagrangianConstraint") = BilateralLagrangianConstraint; } diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl index 67fcf165710..35da6a06b6d 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionConstraint.inl @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.cpp similarity index 55% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.cpp index 94f1bfad358..fe045eab820 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.cpp @@ -19,9 +19,9 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP +#define SOFA_COMPONENT_CONSTRAINTSET_BILATERALLAGRANGIANCONSTRAINT_CPP -#include +#include #include #include @@ -33,37 +33,37 @@ class RigidImpl {}; template<> -class BilateralInteractionLagrangianConstraintSpecialization +class BilateralLagrangianConstraintSpecialization { public: template - static void bwdInit(BilateralInteractionLagrangianConstraint& self) { + static void bwdInit(BilateralLagrangianConstraint& self) { if (!self.keepOrientDiff.getValue()) return; - helper::WriteAccessor::VecDeriv > > wrest = self.restVector; + helper::WriteAccessor::VecDeriv > > wrest = self.restVector; if (wrest.size() > 0) { - msg_warning("BilateralInteractionLagrangianConstraintSpecialization") << "keepOrientationDifference is activated, rest_vector will be ignored! " ; + msg_warning("BilateralLagrangianConstraintSpecialization") << "keepOrientationDifference is activated, rest_vector will be ignored! " ; wrest.resize(0); } - const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); - const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); + const typename BilateralLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); + const typename BilateralLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); const unsigned minp = std::min(m1Indices.size(),m2Indices.size()); - const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x1 = *self.mstate1->read(core::ConstVecCoordId::position()); - const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x2 = *self.mstate2->read(core::ConstVecCoordId::position()); + const typename BilateralLagrangianConstraint::DataVecCoord &d_x1 = *self.mstate1->read(core::ConstVecCoordId::position()); + const typename BilateralLagrangianConstraint::DataVecCoord &d_x2 = *self.mstate2->read(core::ConstVecCoordId::position()); - const typename BilateralInteractionLagrangianConstraint::VecCoord &x1 = d_x1.getValue(); - const typename BilateralInteractionLagrangianConstraint::VecCoord &x2 = d_x2.getValue(); + const typename BilateralLagrangianConstraint::VecCoord &x1 = d_x1.getValue(); + const typename BilateralLagrangianConstraint::VecCoord &x2 = d_x2.getValue(); for (unsigned pid=0; pid::Coord P = x1[m1Indices[pid]]; - const typename BilateralInteractionLagrangianConstraint::Coord Q = x2[m2Indices[pid]]; + const typename BilateralLagrangianConstraint::Coord P = x1[m1Indices[pid]]; + const typename BilateralLagrangianConstraint::Coord Q = x2[m2Indices[pid]]; type::Quat qP, qQ, dQP; qP = P.getOrientation(); @@ -73,7 +73,7 @@ class BilateralInteractionLagrangianConstraintSpecialization dQP = qP.quatDiff(qQ, qP); dQP.normalize(); - typename BilateralInteractionLagrangianConstraint::Coord df; + typename BilateralLagrangianConstraint::Coord df; df.getCenter() = Q.getCenter() - P.getCenter(); df.getOrientation() = dQP; self.initialDifference.push_back(df); @@ -83,7 +83,7 @@ class BilateralInteractionLagrangianConstraintSpecialization template - static void getConstraintResolution(BilateralInteractionLagrangianConstraint& self, + static void getConstraintResolution(BilateralLagrangianConstraint& self, const ConstraintParams* cParams, std::vector& resTab, unsigned int& offset, double tolerance) @@ -104,26 +104,26 @@ class BilateralInteractionLagrangianConstraintSpecialization template - static void buildConstraintMatrix(BilateralInteractionLagrangianConstraint& self, + static void buildConstraintMatrix(BilateralLagrangianConstraint& self, const ConstraintParams* cParams, - typename BilateralInteractionLagrangianConstraint::DataMatrixDeriv &c1_d, - typename BilateralInteractionLagrangianConstraint::DataMatrixDeriv &c2_d, + typename BilateralLagrangianConstraint::DataMatrixDeriv &c1_d, + typename BilateralLagrangianConstraint::DataMatrixDeriv &c2_d, unsigned int &constraintId, - const typename BilateralInteractionLagrangianConstraint::DataVecCoord &/*x1*/, - const typename BilateralInteractionLagrangianConstraint::DataVecCoord &/*x2*/) + const typename BilateralLagrangianConstraint::DataVecCoord &/*x1*/, + const typename BilateralLagrangianConstraint::DataVecCoord &/*x2*/) { SOFA_UNUSED(cParams) ; - const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); - const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); + const typename BilateralLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); + const typename BilateralLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); unsigned minp = std::min(m1Indices.size(),m2Indices.size()); self.cid.resize(minp); - typename BilateralInteractionLagrangianConstraint::MatrixDeriv &c1 = *c1_d.beginEdit(); - typename BilateralInteractionLagrangianConstraint::MatrixDeriv &c2 = *c2_d.beginEdit(); + typename BilateralLagrangianConstraint::MatrixDeriv &c1 = *c1_d.beginEdit(); + typename BilateralLagrangianConstraint::MatrixDeriv &c2 = *c2_d.beginEdit(); - const Vec<3, typename BilateralInteractionLagrangianConstraint::Real> cx(1,0,0), cy(0,1,0), cz(0,0,1); - const Vec<3, typename BilateralInteractionLagrangianConstraint::Real> vZero(0,0,0); + const Vec<3, typename BilateralLagrangianConstraint::Real> cx(1,0,0), cy(0,1,0), cz(0,0,1); + const Vec<3, typename BilateralLagrangianConstraint::Real> vZero(0,0,0); for (unsigned pid=0; pid constraintId += 6; //Apply constraint for position - typename BilateralInteractionLagrangianConstraint::MatrixDerivRowIterator c1_it = c1.writeLine(self.cid[pid]); - c1_it.addCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(-cx, vZero)); + typename BilateralLagrangianConstraint::MatrixDerivRowIterator c1_it = c1.writeLine(self.cid[pid]); + c1_it.addCol(tm1, typename BilateralLagrangianConstraint::Deriv(-cx, vZero)); - typename BilateralInteractionLagrangianConstraint::MatrixDerivRowIterator c2_it = c2.writeLine(self.cid[pid]); - c2_it.addCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(cx, vZero)); + typename BilateralLagrangianConstraint::MatrixDerivRowIterator c2_it = c2.writeLine(self.cid[pid]); + c2_it.addCol(tm2, typename BilateralLagrangianConstraint::Deriv(cx, vZero)); c1_it = c1.writeLine(self.cid[pid] + 1); - c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(-cy, vZero)); + c1_it.setCol(tm1, typename BilateralLagrangianConstraint::Deriv(-cy, vZero)); c2_it = c2.writeLine(self.cid[pid] + 1); - c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(cy, vZero)); + c2_it.setCol(tm2, typename BilateralLagrangianConstraint::Deriv(cy, vZero)); c1_it = c1.writeLine(self.cid[pid] + 2); - c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(-cz, vZero)); + c1_it.setCol(tm1, typename BilateralLagrangianConstraint::Deriv(-cz, vZero)); c2_it = c2.writeLine(self.cid[pid] + 2); - c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(cz, vZero)); + c2_it.setCol(tm2, typename BilateralLagrangianConstraint::Deriv(cz, vZero)); //Apply constraint for orientation c1_it = c1.writeLine(self.cid[pid] + 3); - c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, -cx)); + c1_it.setCol(tm1, typename BilateralLagrangianConstraint::Deriv(vZero, -cx)); c2_it = c2.writeLine(self.cid[pid] + 3); - c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, cx)); + c2_it.setCol(tm2, typename BilateralLagrangianConstraint::Deriv(vZero, cx)); c1_it = c1.writeLine(self.cid[pid] + 4); - c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, -cy)); + c1_it.setCol(tm1, typename BilateralLagrangianConstraint::Deriv(vZero, -cy)); c2_it = c2.writeLine(self.cid[pid] + 4); - c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, cy)); + c2_it.setCol(tm2, typename BilateralLagrangianConstraint::Deriv(vZero, cy)); c1_it = c1.writeLine(self.cid[pid] + 5); - c1_it.setCol(tm1, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, -cz)); + c1_it.setCol(tm1, typename BilateralLagrangianConstraint::Deriv(vZero, -cz)); c2_it = c2.writeLine(self.cid[pid] + 5); - c2_it.setCol(tm2, typename BilateralInteractionLagrangianConstraint::Deriv(vZero, cz)); + c2_it.setCol(tm2, typename BilateralLagrangianConstraint::Deriv(vZero, cz)); } c1_d.endEdit(); @@ -178,34 +178,34 @@ class BilateralInteractionLagrangianConstraintSpecialization template - static void getConstraintViolation(BilateralInteractionLagrangianConstraint& self, + static void getConstraintViolation(BilateralLagrangianConstraint& self, const ConstraintParams* /*cParams*/, BaseVector *v, - const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x1, - const typename BilateralInteractionLagrangianConstraint::DataVecCoord &d_x2, - const typename BilateralInteractionLagrangianConstraint::DataVecDeriv &/*v1*/, - const typename BilateralInteractionLagrangianConstraint::DataVecDeriv &/*v2*/) + const typename BilateralLagrangianConstraint::DataVecCoord &d_x1, + const typename BilateralLagrangianConstraint::DataVecCoord &d_x2, + const typename BilateralLagrangianConstraint::DataVecDeriv &/*v1*/, + const typename BilateralLagrangianConstraint::DataVecDeriv &/*v2*/) { - const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); - const typename BilateralInteractionLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); + const typename BilateralLagrangianConstraint::SubsetIndices& m1Indices = self.m1.getValue(); + const typename BilateralLagrangianConstraint::SubsetIndices& m2Indices = self.m2.getValue(); unsigned min = std::min(m1Indices.size(), m2Indices.size()); - const typename BilateralInteractionLagrangianConstraint::VecDeriv& restVector = self.restVector.getValue(); + const typename BilateralLagrangianConstraint::VecDeriv& restVector = self.restVector.getValue(); self.dfree.resize(min); - const typename BilateralInteractionLagrangianConstraint::VecCoord &x1 = d_x1.getValue(); - const typename BilateralInteractionLagrangianConstraint::VecCoord &x2 = d_x2.getValue(); + const typename BilateralLagrangianConstraint::VecCoord &x1 = d_x1.getValue(); + const typename BilateralLagrangianConstraint::VecCoord &x2 = d_x2.getValue(); for (unsigned pid=0; pid::Coord dof1 = x1[m1Indices[pid]]; - //typename BilateralInteractionLagrangianConstraint::Coord dof2 = x2[m2Indices[pid]]; - typename BilateralInteractionLagrangianConstraint::Coord dof1; + //typename BilateralLagrangianConstraint::Coord dof1 = x1[m1Indices[pid]]; + //typename BilateralLagrangianConstraint::Coord dof2 = x2[m2Indices[pid]]; + typename BilateralLagrangianConstraint::Coord dof1; if (self.keepOrientDiff.getValue()) { - const typename BilateralInteractionLagrangianConstraint::Coord dof1c = x1[m1Indices[pid]]; + const typename BilateralLagrangianConstraint::Coord dof1c = x1[m1Indices[pid]]; - typename BilateralInteractionLagrangianConstraint::Coord corr=self.initialDifference[pid]; + typename BilateralLagrangianConstraint::Coord corr=self.initialDifference[pid]; type::Quat df = corr.getOrientation(); type::Quat o1 = dof1c.getOrientation(); type::Quat ro1 = o1 * df; @@ -215,7 +215,7 @@ class BilateralInteractionLagrangianConstraintSpecialization } else dof1 = x1[m1Indices[pid]]; - const typename BilateralInteractionLagrangianConstraint::Coord dof2 = x2[m2Indices[pid]]; + const typename BilateralLagrangianConstraint::Coord dof2 = x2[m2Indices[pid]]; getVCenter(self.dfree[pid]) = dof2.getCenter() - dof1.getCenter(); getVOrientation(self.dfree[pid]) = dof1.rotate(self.q.angularDisplacement(dof2.getOrientation() , @@ -229,14 +229,14 @@ class BilateralInteractionLagrangianConstraintSpecialization } - template > - static void addContact(BilateralInteractionLagrangianConstraint& self, typename MyClass::Deriv /*norm*/, + template > + static void addContact(BilateralLagrangianConstraint& self, typename MyClass::Deriv /*norm*/, typename MyClass::Coord P, typename MyClass::Coord Q, typename MyClass::Real /*contactDistance*/, int m1, int m2, typename MyClass::Coord /*Pfree*/, typename MyClass::Coord /*Qfree*/, long /*id*/, typename MyClass::PersistentID /*localid*/) { - helper::WriteAccessor::SubsetIndices > > wm1 = self.m1; - helper::WriteAccessor::SubsetIndices > > wm2 = self.m2; + helper::WriteAccessor::SubsetIndices > > wm1 = self.m1; + helper::WriteAccessor::SubsetIndices > > wm2 = self.m2; helper::WriteAccessor > wrest = self.restVector; wm1.push_back(m1); wm2.push_back(m2); @@ -251,52 +251,52 @@ class BilateralInteractionLagrangianConstraintSpecialization template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::init(){ +void BilateralLagrangianConstraint::init(){ unspecializedInit() ; } template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::bwdInit() { - BilateralInteractionLagrangianConstraintSpecialization::bwdInit(*this); +void BilateralLagrangianConstraint::bwdInit() { + BilateralLagrangianConstraintSpecialization::bwdInit(*this); } template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::getConstraintResolution(const ConstraintParams* cParams, +void BilateralLagrangianConstraint::getConstraintResolution(const ConstraintParams* cParams, std::vector& resTab, unsigned int& offset) { - BilateralInteractionLagrangianConstraintSpecialization::getConstraintResolution(*this, + BilateralLagrangianConstraintSpecialization::getConstraintResolution(*this, cParams, resTab, offset, d_numericalTolerance.getValue()) ; } template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::buildConstraintMatrix(const ConstraintParams* cParams, +void BilateralLagrangianConstraint::buildConstraintMatrix(const ConstraintParams* cParams, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &constraintId, const DataVecCoord &x1, const DataVecCoord &x2) { - BilateralInteractionLagrangianConstraintSpecialization::buildConstraintMatrix(*this, + BilateralLagrangianConstraintSpecialization::buildConstraintMatrix(*this, cParams, c1_d, c2_d, constraintId, x1, x2) ; } template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::getConstraintViolation(const ConstraintParams* cParams, +void BilateralLagrangianConstraint::getConstraintViolation(const ConstraintParams* cParams, BaseVector *v, const DataVecCoord &d_x1, const DataVecCoord &d_x2, const DataVecDeriv &v1, const DataVecDeriv &v2) { - BilateralInteractionLagrangianConstraintSpecialization::getConstraintViolation(*this, + BilateralLagrangianConstraintSpecialization::getConstraintViolation(*this, cParams, v, d_x1, d_x2, v1, v2) ; } template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::getVelocityViolation(BaseVector * /*v*/, +void BilateralLagrangianConstraint::getVelocityViolation(BaseVector * /*v*/, const DataVecCoord &/*x1*/, const DataVecCoord &/*x2*/, const DataVecDeriv &/*v1*/, @@ -306,25 +306,25 @@ void BilateralInteractionLagrangianConstraint::getVelocityViolation } template<> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API -void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, +void BilateralLagrangianConstraint::addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord Pfree, Coord Qfree, long id, PersistentID localid) { - BilateralInteractionLagrangianConstraintSpecialization::addContact(*this, + BilateralLagrangianConstraintSpecialization::addContact(*this, norm, P, Q, contactDistance, m1, m2, Pfree, Qfree, id, localid) ; } -int BilateralInteractionLagrangianConstraintClass = core::RegisterObject("BilateralInteractionLagrangianConstraint defining an holonomic equality constraint (attachment)") - .add< BilateralInteractionLagrangianConstraint >() - .add< BilateralInteractionLagrangianConstraint >() +int BilateralLagrangianConstraintClass = core::RegisterObject("BilateralLagrangianConstraint defining an holonomic equality constraint (attachment)") + .add< BilateralLagrangianConstraint >() + .add< BilateralLagrangianConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralLagrangianConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralLagrangianConstraint; } //namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h similarity index 85% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h index a9e87512df0..0b23e4521a1 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.h @@ -56,19 +56,19 @@ using sofa::defaulttype::Vec3Types ; template -class BilateralInteractionLagrangianConstraintSpecialization {}; +class BilateralLagrangianConstraintSpecialization {}; template -class BilateralInteractionLagrangianConstraint : public PairInteractionConstraint +class BilateralLagrangianConstraint : public PairInteractionConstraint { public: - SOFA_CLASS(SOFA_TEMPLATE(BilateralInteractionLagrangianConstraint,DataTypes), + SOFA_CLASS(SOFA_TEMPLATE(BilateralLagrangianConstraint,DataTypes), SOFA_TEMPLATE(PairInteractionConstraint,DataTypes)); - /// That any templates variation of BilateralInteractionLagrangianConstraintSpecialization are friend. + /// That any templates variation of BilateralLagrangianConstraintSpecialization are friend. template - friend class BilateralInteractionLagrangianConstraintSpecialization ; + friend class BilateralLagrangianConstraintSpecialization ; typedef PairInteractionConstraint Inherit; @@ -106,8 +106,8 @@ class BilateralInteractionLagrangianConstraint : public PairInteractionConstrain Data keepOrientDiff; ///< keep the initial difference in orientation (only for rigids) - SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology1; ///< Link to be set to the first topology container in order to support topological changes - SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology2; ///< Link to be set to the second topology container in order to support topological changes + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology1; ///< Link to be set to the first topology container in order to support topological changes + SingleLink, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology2; ///< Link to be set to the second topology container in order to support topological changes std::vector prevForces; @@ -121,11 +121,11 @@ class BilateralInteractionLagrangianConstraint : public PairInteractionConstrain sofa::core::objectmodel::lifecycle::RemovedData derivative{this, "v22.12", "v23.06", "derivative", "Its behavior was unused, undocumented, untested, and unclear (see PR #3328), please report to sofa-dev if you want the feature back."}; - BilateralInteractionLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) ; - BilateralInteractionLagrangianConstraint(MechanicalState* object) ; - BilateralInteractionLagrangianConstraint(); + BilateralLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) ; + BilateralLagrangianConstraint(MechanicalState* object) ; + BilateralLagrangianConstraint(); - virtual ~BilateralInteractionLagrangianConstraint(){} + virtual ~BilateralLagrangianConstraint(){} public: void init() override; @@ -187,9 +187,9 @@ class BilateralInteractionLagrangianConstraint : public PairInteractionConstrain }; -#if !defined(SOFA_COMPONENT_CONSTRAINTSET_BILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint< Vec3Types >; -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralInteractionLagrangianConstraint< Rigid3Types >; +#if !defined(SOFA_COMPONENT_CONSTRAINTSET_BILATERALLAGRANGIANCONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralLagrangianConstraint< Vec3Types >; +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BilateralLagrangianConstraint< Rigid3Types >; #endif } // namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl similarity index 87% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl index 3d0f88b221b..434272f872b 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralInteractionLagrangianConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/BilateralLagrangianConstraint.inl @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include +#include #include #include @@ -39,7 +39,7 @@ using sofa::helper::WriteAccessor ; using sofa::type::Vec; template -BilateralInteractionLagrangianConstraint::BilateralInteractionLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) +BilateralLagrangianConstraint::BilateralLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) : Inherit(object1, object2) , m1(initData(&m1, "first_point","index of the constraint on the first model")) , m2(initData(&m2, "second_point","index of the constraint on the second model")) @@ -55,19 +55,19 @@ BilateralInteractionLagrangianConstraint::BilateralInteractionLagrang } template -BilateralInteractionLagrangianConstraint::BilateralInteractionLagrangianConstraint(MechanicalState* object) - : BilateralInteractionLagrangianConstraint(object, object) +BilateralLagrangianConstraint::BilateralLagrangianConstraint(MechanicalState* object) + : BilateralLagrangianConstraint(object, object) { } template -BilateralInteractionLagrangianConstraint::BilateralInteractionLagrangianConstraint() - : BilateralInteractionLagrangianConstraint(nullptr, nullptr) +BilateralLagrangianConstraint::BilateralLagrangianConstraint() + : BilateralLagrangianConstraint(nullptr, nullptr) { } template -void BilateralInteractionLagrangianConstraint::unspecializedInit() +void BilateralLagrangianConstraint::unspecializedInit() { /// Do general check of validity for inputs Inherit1::init(); @@ -80,7 +80,7 @@ void BilateralInteractionLagrangianConstraint::unspecializedInit() } template -void BilateralInteractionLagrangianConstraint::init() +void BilateralLagrangianConstraint::init() { unspecializedInit(); @@ -108,14 +108,14 @@ void BilateralInteractionLagrangianConstraint::init() } template -void BilateralInteractionLagrangianConstraint::reinit() +void BilateralLagrangianConstraint::reinit() { prevForces.clear(); } template -void BilateralInteractionLagrangianConstraint::buildConstraintMatrix(const ConstraintParams*, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &constraintId +void BilateralLagrangianConstraint::buildConstraintMatrix(const ConstraintParams*, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &constraintId , const DataVecCoord &/*x1*/, const DataVecCoord &/*x2*/) { if (!d_activate.getValue()) @@ -168,7 +168,7 @@ void BilateralInteractionLagrangianConstraint::buildConstraintMatrix( template -void BilateralInteractionLagrangianConstraint::getConstraintViolation(const ConstraintParams* cParams, +void BilateralLagrangianConstraint::getConstraintViolation(const ConstraintParams* cParams, BaseVector *v, const DataVecCoord &d_x1, const DataVecCoord &d_x2 , const DataVecDeriv & d_v1, const DataVecDeriv & d_v2) @@ -208,7 +208,7 @@ void BilateralInteractionLagrangianConstraint::getConstraintViolation template -void BilateralInteractionLagrangianConstraint::getVelocityViolation(BaseVector *v, +void BilateralLagrangianConstraint::getVelocityViolation(BaseVector *v, const DataVecCoord &d_x1, const DataVecCoord &d_x2, const DataVecDeriv &d_v1, @@ -251,7 +251,7 @@ void BilateralInteractionLagrangianConstraint::getVelocityViolation(B template -void BilateralInteractionLagrangianConstraint::getConstraintResolution(const ConstraintParams* cParams, +void BilateralLagrangianConstraint::getConstraintResolution(const ConstraintParams* cParams, std::vector& resTab, unsigned int& offset) { @@ -267,7 +267,7 @@ void BilateralInteractionLagrangianConstraint::getConstraintResolutio } template -void BilateralInteractionLagrangianConstraint::addContact(Deriv /*norm*/, Coord P, Coord Q, +void BilateralLagrangianConstraint::addContact(Deriv /*norm*/, Coord P, Coord Q, Real /*contactDistance*/, int m1, int m2, Coord /*Pfree*/, Coord /*Qfree*/, long /*id*/, PersistentID /*localid*/) @@ -282,7 +282,7 @@ void BilateralInteractionLagrangianConstraint::addContact(Deriv /*nor template -void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, Coord P, Coord Q, Real +void BilateralLagrangianConstraint::addContact(Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id, PersistentID localid) { @@ -293,7 +293,7 @@ void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, } template -void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, Real contactDistance, +void BilateralLagrangianConstraint::addContact(Deriv norm, Real contactDistance, int m1, int m2, long id, PersistentID localid) { addContact(norm, @@ -307,7 +307,7 @@ void BilateralInteractionLagrangianConstraint::addContact(Deriv norm, template -void BilateralInteractionLagrangianConstraint::removeContact(int objectId, SubsetIndices indices) +void BilateralLagrangianConstraint::removeContact(int objectId, SubsetIndices indices) { WriteAccessor > m1Indices = this->m1; WriteAccessor > m2Indices = this->m2; @@ -340,7 +340,7 @@ void BilateralInteractionLagrangianConstraint::removeContact(int obje template -void BilateralInteractionLagrangianConstraint::clear(int reserve) +void BilateralLagrangianConstraint::clear(int reserve) { WriteAccessor > wm1 = this->m1; WriteAccessor > wm2 = this->m2; @@ -358,7 +358,7 @@ void BilateralInteractionLagrangianConstraint::clear(int reserve) template -Index BilateralInteractionLagrangianConstraint::indexOfElemConstraint(const SubsetIndices& cIndices, Index Id) +Index BilateralLagrangianConstraint::indexOfElemConstraint(const SubsetIndices& cIndices, Index Id) { const auto it = std::find(cIndices.begin(), cIndices.end(), Id); @@ -370,7 +370,7 @@ Index BilateralInteractionLagrangianConstraint::indexOfElemConstraint template -void BilateralInteractionLagrangianConstraint::draw(const core::visual::VisualParams* vparams) +void BilateralLagrangianConstraint::draw(const core::visual::VisualParams* vparams) { if (!vparams->displayFlags().getShowInteractionForceFields()) return; @@ -402,7 +402,7 @@ void BilateralInteractionLagrangianConstraint::draw(const core::visua //design for a component. Interaction should be defered to an independent Component implemented in the SofaInteraction //a second possibility is to implement this behavir using script. template -void BilateralInteractionLagrangianConstraint::handleEvent(Event *event) +void BilateralLagrangianConstraint::handleEvent(Event *event) { if (KeypressedEvent::checkEventType(event)) { diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl index 959515f874a..0a010e9a7e9 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/SlidingLagrangianConstraint.inl @@ -22,8 +22,8 @@ #pragma once #include #include -#include -#include +#include +#include #include #include namespace sofa::component::constraint::lagrangian::model diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h index c7738de22e1..70f6cfd932b 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.h @@ -21,12 +21,12 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.h") namespace sofa::component::constraint::lagrangian::model { template -using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "UnilateralInteractionConstraint has been renamed to UnilateralInteractionLagrangianConstraint") = UnilateralInteractionLagrangianConstraint; +using UnilateralInteractionConstraint SOFA_ATTRIBUTE_DEPRECATED("v24.06 ", "v25.06", "UnilateralInteractionConstraint has been renamed to UnilateralLagrangianConstraint") = UnilateralLagrangianConstraint; } \ No newline at end of file diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl index 1b2dee107de..d747c9ea9da 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionConstraint.inl @@ -21,6 +21,6 @@ ******************************************************************************/ #pragma once -#include +#include -SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl") +SOFA_DEPRECATED_HEADER("v24.06", "v25.06", "sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.inl") diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.cpp similarity index 89% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.cpp rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.cpp index 6e44411758f..911955ed2e5 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.cpp @@ -19,8 +19,8 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#define SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP -#include +#define SOFA_COMPONENT_CONSTRAINTSET_UNILATERALLAGRANGIANCONSTRAINT_CPP +#include #include #include @@ -31,13 +31,13 @@ using namespace sofa::defaulttype; using namespace sofa::helper; //TODO(dmarchal) What does this TODO mean ? -int UnilateralInteractionLagrangianConstraintClass = core::RegisterObject("TODO-UnilateralInteractionLagrangianConstraint") - .add< UnilateralInteractionLagrangianConstraint >() +int UnilateralLagrangianConstraintClass = core::RegisterObject("TODO-UnilateralLagrangianConstraint") + .add< UnilateralLagrangianConstraint >() ; -template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionLagrangianConstraint; +template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralLagrangianConstraint; diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.h similarity index 91% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.h index d777b53b4fb..f58a0ac1b72 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.h +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.h @@ -35,10 +35,10 @@ namespace sofa::component::constraint::lagrangian::model { template -class UnilateralInteractionLagrangianConstraint : public core::behavior::PairInteractionConstraint +class UnilateralLagrangianConstraint : public core::behavior::PairInteractionConstraint { public: - SOFA_CLASS(SOFA_TEMPLATE(UnilateralInteractionLagrangianConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::PairInteractionConstraint,DataTypes)); + SOFA_CLASS(SOFA_TEMPLATE(UnilateralLagrangianConstraint,DataTypes), SOFA_TEMPLATE(core::behavior::PairInteractionConstraint,DataTypes)); typedef typename DataTypes::VecCoord VecCoord; typedef typename DataTypes::VecDeriv VecDeriv; @@ -121,8 +121,8 @@ class UnilateralInteractionLagrangianConstraint : public core::behavior::PairInt } - UnilateralInteractionLagrangianConstraint(MechanicalState* object1=nullptr, MechanicalState* object2=nullptr); - virtual ~UnilateralInteractionLagrangianConstraint(); + UnilateralLagrangianConstraint(MechanicalState* object1=nullptr, MechanicalState* object2=nullptr); + virtual ~UnilateralLagrangianConstraint(); public: void setCustomTolerance(SReal tol) { customTolerance = tol; } @@ -150,8 +150,8 @@ class UnilateralInteractionLagrangianConstraint : public core::behavior::PairInt }; -#if !defined(SOFA_COMPONENT_CONSTRAINTSET_UNILATERALINTERACTIONLAGRANGIANCONSTRAINT_CPP) -extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralInteractionLagrangianConstraint; +#if !defined(SOFA_COMPONENT_CONSTRAINTSET_UNILATERALLAGRANGIANCONSTRAINT_CPP) +extern template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API UnilateralLagrangianConstraint; #endif diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.inl similarity index 83% rename from Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl rename to Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.inl index 4b65ac27673..ff7dbbe72c9 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralInteractionLagrangianConstraint.inl +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/UnilateralLagrangianConstraint.inl @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include +#include #include #include #include @@ -30,7 +30,7 @@ namespace sofa::component::constraint::lagrangian::model { template -UnilateralInteractionLagrangianConstraint::UnilateralInteractionLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) +UnilateralLagrangianConstraint::UnilateralLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) : Inherit(object1, object2) , epsilon(Real(0.001)) , yetIntegrated(false) @@ -40,14 +40,14 @@ UnilateralInteractionLagrangianConstraint::UnilateralInteractionLagra } template -UnilateralInteractionLagrangianConstraint::~UnilateralInteractionLagrangianConstraint() +UnilateralLagrangianConstraint::~UnilateralLagrangianConstraint() { if(contactsStatus) delete[] contactsStatus; } template -void UnilateralInteractionLagrangianConstraint::clear(int reserve) +void UnilateralLagrangianConstraint::clear(int reserve) { contacts.clear(); if (reserve) @@ -55,7 +55,7 @@ void UnilateralInteractionLagrangianConstraint::clear(int reserve) } template -void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id, PersistentID localid) +void UnilateralLagrangianConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, long id, PersistentID localid) { addContact(mu, norm, P, Q, contactDistance, m1, m2, this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue()[m2], @@ -64,7 +64,7 @@ void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, } template -void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, Deriv norm, Real contactDistance, int m1, int m2, long id, PersistentID localid) +void UnilateralLagrangianConstraint::addContact(SReal mu, Deriv norm, Real contactDistance, int m1, int m2, long id, PersistentID localid) { addContact(mu, norm, this->getMState2()->read(core::ConstVecCoordId::position())->getValue()[m2], @@ -76,7 +76,7 @@ void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, } template -void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord /*Pfree*/, Coord /*Qfree*/, long id, PersistentID localid) +void UnilateralLagrangianConstraint::addContact(SReal mu, Deriv norm, Coord P, Coord Q, Real contactDistance, int m1, int m2, Coord /*Pfree*/, Coord /*Qfree*/, long id, PersistentID localid) { contacts.resize(contacts.size() + 1); Contact &c = contacts.back(); @@ -98,7 +98,7 @@ void UnilateralInteractionLagrangianConstraint::addContact(SReal mu, template -void UnilateralInteractionLagrangianConstraint::buildConstraintMatrix(const core::ConstraintParams *, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &contactId +void UnilateralLagrangianConstraint::buildConstraintMatrix(const core::ConstraintParams *, DataMatrixDeriv &c1_d, DataMatrixDeriv &c2_d, unsigned int &contactId , const DataVecCoord &, const DataVecCoord &) { assert(this->mstate1); @@ -177,7 +177,7 @@ void UnilateralInteractionLagrangianConstraint::buildConstraintMatrix template -void UnilateralInteractionLagrangianConstraint::getPositionViolation(linearalgebra::BaseVector *v) +void UnilateralLagrangianConstraint::getPositionViolation(linearalgebra::BaseVector *v) { const VecCoord &PfreeVec = this->getMState2()->read(core::ConstVecCoordId::freePosition())->getValue(); const VecCoord &QfreeVec = this->getMState1()->read(core::ConstVecCoordId::freePosition())->getValue(); @@ -257,7 +257,7 @@ void UnilateralInteractionLagrangianConstraint::getPositionViolation( template -void UnilateralInteractionLagrangianConstraint::getVelocityViolation(linearalgebra::BaseVector *v) +void UnilateralLagrangianConstraint::getVelocityViolation(linearalgebra::BaseVector *v) { auto P = this->getMState2()->readPositions(); auto Q = this->getMState1()->readPositions(); @@ -290,7 +290,7 @@ void UnilateralInteractionLagrangianConstraint::getVelocityViolation( template -void UnilateralInteractionLagrangianConstraint::getConstraintViolation(const core::ConstraintParams *cparams, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & +void UnilateralLagrangianConstraint::getConstraintViolation(const core::ConstraintParams *cparams, linearalgebra::BaseVector *v, const DataVecCoord &, const DataVecCoord & , const DataVecDeriv &, const DataVecDeriv &) { switch (cparams->constOrder()) @@ -306,17 +306,17 @@ void UnilateralInteractionLagrangianConstraint::getConstraintViolatio break; default : - msg_error() << "UnilateralInteractionLagrangianConstraint doesn't implement " << cparams->getName() << " constraint violation\n"; + msg_error() << "UnilateralLagrangianConstraint doesn't implement " << cparams->getName() << " constraint violation\n"; break; } } template -void UnilateralInteractionLagrangianConstraint::getConstraintInfo(const core::ConstraintParams*, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& /*positions*/, VecConstDeriv& directions, VecConstArea& /*areas*/) +void UnilateralLagrangianConstraint::getConstraintInfo(const core::ConstraintParams*, VecConstraintBlockInfo& blocks, VecPersistentID& ids, VecConstCoord& /*positions*/, VecConstDeriv& directions, VecConstArea& /*areas*/) { if (contacts.empty()) return; - const bool friction = (contacts[0].mu > 0.0); /// @todo: can there be both friction-less and friction contacts in the same UnilateralInteractionLagrangianConstraint ??? + const bool friction = (contacts[0].mu > 0.0); /// @todo: can there be both friction-less and friction contacts in the same UnilateralLagrangianConstraint ??? ConstraintBlockInfo info; info.parent = this; info.const0 = contacts[0].id; @@ -345,7 +345,7 @@ void UnilateralInteractionLagrangianConstraint::getConstraintInfo(con } template -void UnilateralInteractionLagrangianConstraint::getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) +void UnilateralLagrangianConstraint::getConstraintResolution(const core::ConstraintParams *, std::vector& resTab, unsigned int& offset) { if(contactsStatus) { @@ -377,7 +377,7 @@ void UnilateralInteractionLagrangianConstraint::getConstraintResoluti } template -bool UnilateralInteractionLagrangianConstraint::isActive() const +bool UnilateralLagrangianConstraint::isActive() const { for(unsigned int i = 0; i < contacts.size(); i++) if(contacts[i].dfree < 0) @@ -387,7 +387,7 @@ bool UnilateralInteractionLagrangianConstraint::isActive() const } template -void UnilateralInteractionLagrangianConstraint::draw(const core::visual::VisualParams* vparams) +void UnilateralLagrangianConstraint::draw(const core::visual::VisualParams* vparams) { if (!vparams->displayFlags().getShowInteractionForceFields()) return; diff --git a/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn b/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn index d2cb769cbb7..7eb496cae65 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn +++ b/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn @@ -33,5 +33,5 @@ - + diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.h b/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.h index 40547d5856a..42e6bf06bb4 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.h +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include @@ -57,7 +57,7 @@ class ConstraintAttachBodyPerformer: public TInteractionPerformer typedef typename DataTypes::VecCoord VecCoord; typedef sofa::component::collision::response::mapper::BaseContactMapper< DataTypes > MouseContactMapper; typedef sofa::core::behavior::MechanicalState< DataTypes > MouseContainer; -// typedef sofa::component::constraint::lagrangian::model::BilateralInteractionLagrangianConstraint< DataTypes > MouseConstraint; +// typedef sofa::component::constraint::lagrangian::model::BilateralLagrangianConstraint< DataTypes > MouseConstraint; // typedef sofa::core::behavior::BaseForceField MouseForceField; @@ -91,7 +91,7 @@ class ConstraintAttachBodyPerformer: public TInteractionPerformer virtual bool start_partial(const BodyPicked& picked); MouseContactMapper *mapper; - sofa::component::constraint::lagrangian::model::BilateralInteractionLagrangianConstraint::SPtr m_constraint; + sofa::component::constraint::lagrangian::model::BilateralLagrangianConstraint::SPtr m_constraint; core::visual::DisplayFlags flags; diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl b/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl index bce589b32d1..921a7aacee7 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/ConstraintAttachBodyPerformer.inl @@ -172,10 +172,10 @@ bool ConstraintAttachBodyPerformer::start_partial(const BodyPicked& p type::Vec3d point1; type::Vec3d point2; - using sofa::component::constraint::lagrangian::model::BilateralInteractionLagrangianConstraint; + using sofa::component::constraint::lagrangian::model::BilateralLagrangianConstraint; - m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); - BilateralInteractionLagrangianConstraint< DataTypes >* bconstraint = static_cast< BilateralInteractionLagrangianConstraint< sofa::defaulttype::Vec3Types >* >(m_constraint.get()); + m_constraint = sofa::core::objectmodel::New >(mstate1, mstate2); + BilateralLagrangianConstraint< DataTypes >* bconstraint = static_cast< BilateralLagrangianConstraint< sofa::defaulttype::Vec3Types >* >(m_constraint.get()); bconstraint->setName("Constraint-Mouse-Contact"); type::Vec3d normal = point1-point2; diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index b4ae9d5101a..880cd7ac4d9 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -744,11 +744,11 @@ const std::map > uncreatableComponents {"ProjectToPlaneConstraint", Renamed("v24.06","v25.06","PlaneProjectiveConstraint")}, {"ProjectToPointConstraint", Renamed("v24.06","v25.06","PointProjectiveConstraint")}, {"ProjectDirectionConstraint", Renamed("v24.06","v25.06","DirectionProjectiveConstraint")}, - {"BilateralInteractionConstraint", Renamed("v24.06","v25.06","BilateralInteractionLagrangianConstraint")}, + {"BilateralInteractionConstraint", Renamed("v24.06","v25.06","BilateralLagrangianConstraint")}, {"SlidingConstraint", Renamed("v24.06","v25.06","SlidingLagrangianConstraint")}, {"StopperConstraint", Renamed("v24.06","v25.06","StopperLagrangianConstraint")}, {"UniformConstraint", Renamed("v24.06","v25.06","UniformLagrangianConstraint")}, - {"UnilateralInteractionConstraint", Renamed("v24.06","v25.06","UnilateralInteractionLagrangianConstraint")} + {"UnilateralInteractionConstraint", Renamed("v24.06","v25.06","UnilateralLagrangianConstraint")} }; diff --git a/applications/plugins/SofaCUDA/CMakeLists.txt b/applications/plugins/SofaCUDA/CMakeLists.txt index 25aded79541..cede9c498cc 100644 --- a/applications/plugins/SofaCUDA/CMakeLists.txt +++ b/applications/plugins/SofaCUDA/CMakeLists.txt @@ -155,7 +155,7 @@ set(SOURCE_FILES ${SOFACUDA_SOURCE_DIR}/component/collision/geometry/CudaTriangleModel.cpp ### Constraints - ${SOFACUDA_SOURCE_DIR}/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp + ${SOFACUDA_SOURCE_DIR}/component/constraint/lagrangian/model/CudaBilateralLagrangianConstraint.cpp ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedProjectiveConstraint.cpp ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaFixedTranslationProjectiveConstraint.cpp ${SOFACUDA_SOURCE_DIR}/component/constraint/projective/CudaLinearMovementProjectiveConstraint.cpp diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralLagrangianConstraint.cpp similarity index 70% rename from applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp rename to applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralLagrangianConstraint.cpp index 6904cb6b1f6..c014599a76f 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralInteractionLagrangianConstraint.cpp +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/constraint/lagrangian/model/CudaBilateralLagrangianConstraint.cpp @@ -21,18 +21,18 @@ ******************************************************************************/ #include #include -#include +#include #include namespace sofa::component::constraint::lagrangian::model { -template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; -template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; +template class SOFA_GPU_CUDA_API BilateralLagrangianConstraint; +template class SOFA_GPU_CUDA_API BilateralLagrangianConstraint; #ifdef SOFA_GPU_CUDA_DOUBLE -template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; -template class SOFA_GPU_CUDA_API BilateralInteractionLagrangianConstraint; +template class SOFA_GPU_CUDA_API BilateralLagrangianConstraint; +template class SOFA_GPU_CUDA_API BilateralLagrangianConstraint; #endif // SOFA_GPU_CUDA_DOUBLE } //namespace sofa::component::constraint::lagrangian::model @@ -42,12 +42,12 @@ namespace sofa::gpu::cuda using namespace sofa::component::constraint::lagrangian::model; -int BilateralInteractionLagrangianConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") - .add< BilateralInteractionLagrangianConstraint >() - .add< BilateralInteractionLagrangianConstraint >() +int BilateralLagrangianConstraintCudaClass = core::RegisterObject("Supports GPU-side computations using CUDA") + .add< BilateralLagrangianConstraint >() + .add< BilateralLagrangianConstraint >() #ifdef SOFA_GPU_CUDA_DOUBLE - .add< BilateralInteractionLagrangianConstraint >() - .add< BilateralInteractionLagrangianConstraint >() + .add< BilateralLagrangianConstraint >() + .add< BilateralLagrangianConstraint >() #endif // SOFA_GPU_CUDA_DOUBLE ; } // namespace sofa::gpu::cuda diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn index 7ca3e60cdda..abf4d2ca7be 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn @@ -7,7 +7,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -150,5 +150,5 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn index 5553e710327..b91d193492e 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_PGS.scn @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -124,7 +124,7 @@ - + @@ -150,5 +150,5 @@ - +
diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn index 4d6cd05e366..c0d5b83d584 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn @@ -1,10 +1,10 @@ - + - + @@ -44,5 +44,5 @@ - +
diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn index b65ea20ca98..a9a540b5824 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_UGS.scn @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + @@ -72,7 +72,7 @@
- + @@ -98,7 +98,7 @@
- + @@ -124,7 +124,7 @@
- + @@ -150,5 +150,5 @@
- +
diff --git a/examples/Component/Engine/Select/NearestPointROI.scn b/examples/Component/Engine/Select/NearestPointROI.scn index 6eef96cbb89..f54e0aa60ed 100644 --- a/examples/Component/Engine/Select/NearestPointROI.scn +++ b/examples/Component/Engine/Select/NearestPointROI.scn @@ -2,7 +2,7 @@ - + @@ -58,8 +58,8 @@ - - + + - + @@ -69,7 +69,7 @@
- From 6aa6ee1f38dc0fc36195f70a8708f9a57af8eb19 Mon Sep 17 00:00:00 2001 From: bakpaul Date: Mon, 11 Dec 2023 17:36:37 +0100 Subject: [PATCH 23/28] Change remaining scene with FixedConstraint --- .../projective/PartialFixedProjectiveConstraint.h | 2 +- .../gui/component/performer/SuturePointPerformer.h | 2 +- .../modules/SofaExporter/examples/OBJExporter.scn | 4 ++-- .../examples/ArticulatedSystemMapping.scn | 6 +++--- .../examples/BulletConvexHullDemo.scn | 4 ++-- .../examples/BulletLMDragon.scn | 2 +- .../examples/BulletSphere.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBCap.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBCap1.scn | 4 ++-- .../examples/OBBCapEdgeEdge.scn | 4 ++-- .../examples/OBBCapEdgeVertex.scn | 4 ++-- .../examples/OBBCapVertexEdge.scn | 4 ++-- .../examples/OBBCapVertexVertex.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBOBB.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBOBB2.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBOBBAlea.scn | 4 ++-- .../examples/OBBOBBCollision.scn | 4 ++-- .../examples/OBBOBBEdgeEdge.scn | 4 ++-- .../examples/OBBOBBEdgeVertex.scn | 4 ++-- .../examples/OBBOBBFaceEdge.scn | 4 ++-- .../examples/OBBOBBVertexVertex.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBSphere.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBSphere2.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBSphereEdge.scn | 4 ++-- .../examples/OBBSphereVertex.scn | 4 ++-- .../CollisionOBBCapsule/examples/OBBTri.scn | 4 ++-- .../examples/OBBTriEdgeEdge.scn | 4 ++-- .../examples/OBBTriEdgeEdge2.scn | 4 ++-- .../examples/OBBTriEdgeVerex.scn | 4 ++-- .../examples/OBBTriFaceVertex.scn | 4 ++-- .../examples/OBBTriVertexEdge.scn | 4 ++-- .../examples/OBBTriVertexFace.scn | 4 ++-- .../examples/OBBTriVertexVertex.scn | 4 ++-- .../ExternalBehaviorModel/example/simple.scn | 6 +++--- .../Geomagic/scenes/Geomagic-DeformableCubes.scn | 6 +++--- .../Geomagic/scenes/Geomagic-DeformableSphere.scn | 4 ++-- .../plugins/Geomagic/scenes/Geomagic-FEMLiver.scn | 4 ++-- .../plugins/LeapMotion/examples/buffoon.scn | 2 +- .../examples/BeamLinearMapping_mt.scn | 4 ++-- .../examples/ParallelCGLinearSolver.scn | 4 ++-- .../examples/ParallelHexahedronFEMForceField.scn | 4 ++-- .../examples/ParallelMeshSpringForceField.scn | 4 ++-- .../examples/ParallelTetrahedronFEMForceField.scn | 4 ++-- .../examples/TriangularForceFieldComparison.scn | 10 +++++----- .../plugins/MultiThreading/examples/livers.scn | 10 +++++----- .../examples/liversMeanPositions.scn | 12 ++++++------ applications/plugins/Sensable/examples/Carving.scn | 2 +- .../Sensable/examples/Deformable-Method1.scn | 2 +- .../examples/Old Examples/flexibleRaptor.scn | 2 +- .../examples/Old Examples/omni-probing-liver.scn | 2 +- .../plugins/SixenseHydra/Scenes/Hydra_buffon.scn | 2 +- .../SofaCUDA/examples/CudaDiagonalMass3f.scn | 4 ++-- .../SofaCUDA/examples/CudaMeshMatrixMass3f.scn | 4 ++-- .../plugins/SofaCUDA/examples/SquareTissue-cpu.scn | 4 ++-- .../SofaCUDA/examples/SquareTissue-cuda.scn | 4 ++-- .../plugins/SofaCUDA/examples/liver-CUDA.scn | 4 ++-- .../plugins/SofaCUDA/examples/quadSpringSphere.scn | 2 +- .../SofaCUDA/examples/quadSpringSphere2CUDA.scn | 2 +- .../plugins/SofaCUDA/examples/raptor-cpu.scn | 2 +- .../plugins/SofaCUDA/examples/raptor-cuda.scn | 4 ++-- .../SofaCUDA/examples/raptor-surface-cpu.scn | 4 ++-- .../SofaCUDA/examples/raptor-surface-cuda.scn | 4 ++-- applications/plugins/SofaCUDA/examples/raptor.scn | 4 ++-- ...daHexahedronTLEDForceField_beam10x10x40_gpu.scn | 4 ++-- ...aTetrahedronTLEDForceField_beam10x10x40_gpu.scn | 4 ++-- ...aTetrahedronTLEDForceField_beam16x16x76_gpu.scn | 4 ++-- .../HexahedronFEMForceField_beam10x10x40_cpu.scn | 4 ++-- .../HexahedronFEMForceField_beam10x10x40_gpu.scn | 4 ++-- .../HexahedronFEMForceField_beam16x16x76_cpu.scn | 4 ++-- .../HexahedronFEMForceField_beam16x16x76_gpu.scn | 4 ++-- .../MeshSpringForceField_beam10x10x40_cpu.scn | 4 ++-- .../MeshSpringForceField_beam10x10x40_gpu.scn | 4 ++-- .../scenes/benchmarks/QuadSpringsSphere_cpu.scn | 2 +- .../scenes/benchmarks/QuadSpringsSphere_gpu.scn | 2 +- .../TetrahedronFEMForceField_beam10x10x40_cpu.scn | 4 ++-- .../TetrahedronFEMForceField_beam10x10x40_gpu.scn | 4 ++-- .../TetrahedronFEMForceField_beam16x16x76_cpu.scn | 4 ++-- .../TetrahedronFEMForceField_beam16x16x76_gpu.scn | 4 ++-- ...angularFEMForceFieldOptim_tissue100x100_cpu.scn | 4 ++-- ...angularFEMForceFieldOptim_tissue100x100_gpu.scn | 4 ++-- ...xahedronFEMForceField_beam10x10x40_implicit.scn | 8 ++++---- ...udaHexahedronFEMForceField_beam10x10x40_rk4.scn | 8 ++++---- ...aMeshSpringForceField_beam10x10x40_implicit.scn | 8 ++++---- .../CudaMeshSpringForceField_beam10x10x40_rk4.scn | 8 ++++---- ...rahedronFEMForceField_beam10x10x40_implicit.scn | 8 ++++---- ...daTetrahedronFEMForceField_beam10x10x40_rk4.scn | 8 ++++---- ...arFEMForceFieldOptim_tissue100x100_implicit.scn | 8 ++++---- ...ularFEMForceFieldOptim_tissue20x20_implicit.scn | 8 ++++---- .../cpu-gpu_validation/QuadSpringsSphere.scn | 4 ++-- .../plugins/SofaCarving/examples/CarvingTool.scn | 4 ++-- .../plugins/SofaCarving/examples/SimpleCarving.scn | 4 ++-- .../examples/SimpleCarving_withPenetration.scn | 4 ++-- .../examples/FFDDistanceGridCollisionModel.scn | 4 ++-- .../plugins/SofaHAPI/examples/SofaHAPI1.scn | 4 ++-- .../examples/ComplianceMatrixExporter.scn | 4 ++-- .../SofaMatrix/examples/ComplianceMatrixImage.scn | 4 ++-- .../SofaMatrix/examples/FillReducingOrdering.scn | 6 +++--- .../examples/GlobalSystemMatrixExporter.scn | 10 +++++----- .../examples/GlobalSystemMatrixImage.scn | 6 +++--- .../SofaNewmat/examples/MatrixContributions121.scn | 6 +++--- .../SofaNewmat/examples/MatrixContributions122.scn | 10 +++++----- .../SofaNewmat/examples/MatrixContributions123.scn | 10 +++++----- .../examples/FEMBAR-SparsePARDISOSolver.scn | 2 +- .../plugins/SofaSimpleGUI/examples/liver.scn | 4 ++-- .../plugins/SofaSimpleGUI/examples/oneTet.scn | 4 ++-- .../examples/ParticlesRepulsionForceField.scn | 2 +- .../BilateralInteractionConstraint_Rigid.scn | 4 ++-- .../Constraint/Lagrangian/InextensiblePendulum.scn | 4 ++-- .../Constraint/Projective/AttachConstraint.scn | 2 +- .../Projective/AttachConstraintMatrix.scn | 2 +- .../Constraint/Projective/BoxConstraint.scn | 2 +- .../Constraint/Projective/FixedConstraint.scn | 4 ++-- .../Constraint/Projective/FixedPlaneConstraint.scn | 2 +- .../Projective/FixedRotationConstraint.scn | 6 +++--- .../Constraint/Projective/OscillatorConstraint.scn | 4 ++-- .../Constraint/Projective/PlaneConstraint.scn | 2 +- .../Projective/ProjectDirectionConstraint.scn | 2 +- .../Projective/ProjectToLineConstraint.scn | 2 +- .../Projective/ProjectToPlaneConstraint.scn | 2 +- .../Projective/ProjectToPointConstraint.scn | 2 +- .../Controller/MechanicalStateController.scn | 4 ++-- .../Component/Engine/Generate/GenerateCylinder.scn | 4 ++-- .../Component/Engine/Generate/GenerateGrid.scn | 6 +++--- examples/Component/Engine/Generate/MergePoints.scn | 2 +- .../Engine/Generate/MeshTetraStuffing.scn | 2 +- examples/Component/Engine/Select/BoxROI.scn | 2 +- examples/Component/Engine/Select/BoxROI_1d.scn | 4 ++-- examples/Component/Engine/Select/BoxROI_2d.scn | 4 ++-- .../Component/Engine/Select/MeshBoundaryROI.scn | 4 ++-- .../Engine/Select/MeshSplittingEngine.scn | 2 +- examples/Component/Engine/Select/PlaneROI.scn | 4 ++-- .../Component/Engine/Select/PointsFromIndices.scn | 4 ++-- examples/Component/Engine/Select/ProximityROI.scn | 2 +- examples/Component/Engine/Select/SphereROI.scn | 2 +- .../Component/Engine/Select/SubsetTopology.scn | 2 +- .../Select/SubsetTopology_localIndicesOption.scn | 4 ++-- .../Engine/Select/SubsetTopology_refiningMesh.scn | 2 +- .../Select/SubsetTopology_withtetrahedra.scn | 4 ++-- .../Select/ValuesFromPositions_vectorField.scn | 4 ++-- .../Component/LinearSolver/Direct/Eigen3-SVD.scn | 4 ++-- .../LinearSolver/Direct/FEMBAR_SVDLinearSolver.scn | 2 +- examples/Component/LinearSolver/FEMBAR-common.xml | 4 ++-- .../LinearSolver/Iterative/CGLinearSolver.scn | 4 ++-- .../LinearSystem/CompositeLinearSystem.scn | 8 ++++---- .../LinearSystem/ConstantSparsityPatternSystem.scn | 8 ++++---- .../Component/LinearSystem/MatrixLinearSystem.scn | 8 ++++---- .../PendulumSpringsDistanceMapping.scn | 6 +++--- .../Mapping/Linear/BarycentricMappingTrussBeam.scn | 4 ++-- .../Mapping/Linear/BarycentricTetraMapping.scn | 4 ++-- .../Mapping/Linear/CenterOfMassMapping.scn | 4 ++-- .../Linear/DeformableOnRigidFrameMapping.scn | 4 ++-- .../DeformableOnRigidFrameMappingConstraints.scn | 2 +- .../Component/Mapping/Linear/IdentityMapping.scn | 4 ++-- .../SimpleTesselatedTetraTopologicalMapping.scn | 4 ++-- .../Component/Mapping/Linear/SkinningMapping.scn | 4 ++-- .../Component/Mapping/Linear/SubsetMapping.scn | 4 ++-- .../Mapping/NonLinear/DistanceMapping.scn | 4 ++-- .../Mapping/NonLinear/DistanceMultiMapping.scn | 6 +++--- .../Mapping/NonLinear/RigidRigidMapping.scn | 4 ++-- .../Mapping/NonLinear/SquareDistanceMapping.scn | 4 ++-- .../Component/Mapping/NonLinear/SquareMapping.scn | 6 +++--- .../MechanicalLoad/ConstantForceField.scn | 2 +- .../MechanicalLoad/EllipsoidForceField.scn | 4 ++-- .../InteractionEllipsoidForceField.scn | 6 +++--- .../Component/MechanicalLoad/SphereForceField.scn | 2 +- .../MechanicalLoad/SurfacePressureForceField.scn | 2 +- .../TaitSurfacePressureForceField.scn | 2 +- .../MechanicalLoad/TrianglePressureForceField.scn | 4 ++-- .../Backward/EulerImplicitSolver-comparison.scn | 10 +++++----- .../ODESolver/Backward/EulerImplicitSolver.scn | 4 ++-- .../ODESolver/Backward/NewmarkImplicitSolver.scn | 8 ++++---- .../Component/ODESolver/Backward/StaticSolver.scn | 8 ++++---- .../Backward/VariationalSymplecticSolver.scn | 2 +- .../ODESolver/Forward/EulerExplicitSolver.scn | 4 ++-- .../Forward/EulerExplicitSolver_diagonal.scn | 4 ++-- .../ODESolver/Forward/EulerSymplecticSolver.scn | 4 ++-- .../Forward/EulerSymplecticSolver_diagonal.scn | 4 ++-- .../ODESolver/Forward/RungeKutta4Solver.scn | 4 ++-- examples/Component/SceneUtility/Monitor.scn | 4 ++-- .../SolidMechanics/FEM/BeamFEMForceField.scn | 8 ++++---- .../FEM/FastTetrahedralCorotationalForceField.scn | 10 +++++----- ...etrahedronCorotationalForceField_validation.scn | 6 +++--- .../FEM/Heterogeneous-TetrahedronFEMForceField.scn | 2 +- .../SolidMechanics/FEM/HexahedralFEMForceField.scn | 4 ++-- .../FEM/HexahedralFEMForceFieldAndMass.scn | 4 ++-- .../HexahedronCompositeFEMForceFieldAndMass.scn | 2 +- .../FEM/HexahedronCompositeFEMMapping.scn | 2 +- .../SolidMechanics/FEM/HexahedronFEMForceField.scn | 4 ++-- .../FEM/HexahedronFEMForceFieldAndMass.scn | 4 ++-- .../FEM/QuadBendingFEMForceField.scn | 4 ++-- .../FEM/StandardTetrahedralFEMForceField.scn | 12 ++++++------ .../FEM/TetrahedralCorotationalFEMForceField.scn | 8 ++++---- .../FEM/TetrahedronFEMForceField.scn | 10 +++++----- .../FEM/TetrahedronFEMForceField_assemble.scn | 6 +++--- .../TetrahedronHyperelasticityFEMForceField.scn | 12 ++++++------ .../SolidMechanics/FEM/TopoMap_cylinder3d.scn | 4 ++-- .../SolidMechanics/FEM/TriangleFEMForceField.scn | 8 ++++---- .../SolidMechanics/FEM/TriangularFEMForceField.scn | 4 ++-- .../FEM/TriangularFEMForceFieldOptim.scn | 6 +++--- .../FEM/TriangularForceFieldComparison.scn | 14 +++++++------- .../Spring/FastTriangularBendingSprings.scn | 4 ++-- .../SolidMechanics/Spring/GearSpringForceField.scn | 4 ++-- .../Spring/JointSpringForceField.scn | 4 ++-- .../Spring/PolynomialSpringsForceField.scn | 4 ++-- .../SolidMechanics/Spring/QuadBendingSprings.scn | 4 ++-- .../Spring/QuadularBendingSprings.scn | 4 ++-- .../Spring/StiffSpringForceField.scn | 4 ++-- .../Spring/StiffSpringForceField_simple.scn | 4 ++-- .../Spring/TriangleBendingSprings.scn | 8 ++++---- .../Spring/TriangularBendingSprings.scn | 4 ++-- .../TriangularBiquadraticSpringsForceField.scn | 4 ++-- .../TriangularQuadraticSpringsForceField.scn | 4 ++-- .../TensorMass/TriangularTensorMassForceField.scn | 4 ++-- .../Topology/Container/Constant/CubeTopology.scn | 4 ++-- .../Topology/Container/Constant/MeshTopology.scn | 4 ++-- .../Container/Dynamic/AddingHexa2QuadProcess.scn | 2 +- .../Dynamic/AddingQuad2TriangleProcess.scn | 4 ++-- .../Dynamic/AddingTetra2TriangleProcess.scn | 4 ++-- .../Container/Dynamic/AddingTetraProcess.scn | 4 ++-- .../Dynamic/AddingTriangle2EdgeProcess.scn | 4 ++-- .../Container/Dynamic/AddingTrianglesProcess.scn | 4 ++-- .../Container/Dynamic/IncisionTrianglesProcess.scn | 6 +++--- .../QuadForceFieldTopologyChangeHandling.scn | 6 +++--- .../RemovingBilateralInteractionConstraint.scn | 4 ++-- .../Container/Dynamic/RemovingHexa2QuadProcess.scn | 4 ++-- .../Dynamic/RemovingHexa2TetraProcess.scn | 4 ++-- .../Container/Dynamic/RemovingPointSprings.scn | 4 ++-- .../Dynamic/RemovingQuad2TriangleProcess.scn | 4 ++-- .../Dynamic/RemovingTetra2TriangleProcess.scn | 6 +++--- ...movingTetra2TriangleProcess_performanceTest.scn | 4 ++-- .../Dynamic/RemovingTetra2Triangle_options1.scn | 4 ++-- .../Dynamic/RemovingTetra2Triangle_options2.scn | 4 ++-- .../Container/Dynamic/RemovingTetraProcess.scn | 4 ++-- .../RemovingTetraProcess_withCollisionModel.scn | 4 ++-- .../Container/Dynamic/RemovingTrianglesProcess.scn | 4 ++-- ...TetrahedronForceFieldTopologyChangeHandling.scn | 6 +++--- .../TriangularForceFieldTopologyChangeHandling.scn | 14 +++++++------- .../Container/Grid/CylinderGridTopology.scn | 2 +- .../Container/Grid/RegularGridTopology.scn | 2 +- .../Grid/RegularGridTopology_TrianglesMesh.scn | 4 ++-- .../Grid/RegularGridTopology_dimension.scn | 8 ++++---- .../Grid/SparseGridRamificationTopology.scn | 2 +- .../Topology/Container/Grid/SparseGridTopology.scn | 2 +- .../Topology/Container/Grid/SphereGridTopology.scn | 2 +- .../Mapping/Edge2QuadTopologicalMapping.scn | 4 ++-- .../Mapping/Hexa2QuadTopologicalMapping.scn | 4 ++-- .../Mapping/Hexa2TetraTopologicalMapping.scn | 4 ++-- .../Hexa2TetraTopologicalMapping_export.scn | 4 ++-- .../Mapping/Mesh2PointTopologicalMapping.scn | 4 ++-- .../Mapping/Quad2TriangleTopologicalMapping.scn | 4 ++-- .../Topology/Mapping/SubsetTopologicalMapping.scn | 4 ++-- .../Topology/Mapping/SubsetTopologicalMapping2.scn | 4 ++-- .../Mapping/Tetra2TriangleTopologicalMapping.scn | 4 ++-- ...TopologicalMapping_NoInitialTriangle_option.scn | 4 ++-- ...gleTopologicalMapping_with_TetrahedronModel.scn | 4 ++-- .../Mapping/TopoMap_Hexa2Quad2Triangle.scn | 4 ++-- .../Mapping/Triangle2EdgeTopologicalMapping.scn | 4 ++-- examples/Component/Visual/DataDisplay.scn | 4 ++-- examples/Component/Visual/OglShader.scn | 4 ++-- .../Component/Visual/OglShader_tessellation.scn | 2 +- examples/Component/Visual/OglViewport.scn | 4 ++-- .../Visual/PostProcessManager_DepthOfField.scn | 4 ++-- examples/Component/Visual/VisualStyle.scn | 4 ++-- examples/Tutorials/Basic/TutorialBasicPendulum.scn | 4 ++-- .../ForceFields/TutorialForceFieldLiverFEM.scn | 4 ++-- .../ForceFields/TutorialForceFieldLiverHexaFEM.scn | 4 ++-- .../ForceFields/TutorialForceFieldLiverSprings.scn | 4 ++-- .../TutorialForceFieldLiverTriangleFEM.scn | 4 ++-- .../Mappings/TutorialMappingLiverBarycentric.scn | 4 ++-- examples/Tutorials/OldTutorials/demo1.scn | 2 +- examples/Tutorials/OldTutorials/demo2.scn | 2 +- examples/Tutorials/OldTutorials/demo3.scn | 4 ++-- examples/Tutorials/OldTutorials/demo4.scn | 4 ++-- examples/Tutorials/OldTutorials/demo5.scn | 4 ++-- examples/Tutorials/OldTutorials/demo6.scn | 4 ++-- examples/Tutorials/OldTutorials/demo6Triangle.scn | 4 ++-- examples/Tutorials/OldTutorials/demo7.scn | 4 ++-- examples/Tutorials/OldTutorials/demo7Triangle.scn | 4 ++-- .../Tutorials/StepByStep/Pendulum/2_Pendulum.scn | 4 ++-- .../Tutorials/StepByStep/Pendulum/3_Pendulum.scn | 4 ++-- .../Tutorials/StepByStep/Pendulum/4_Pendulum.scn | 4 ++-- .../Tutorials/StepByStep/Pendulum/5_Pendulum.scn | 4 ++-- .../Tutorials/StepByStep/Pendulum/6_Pendulum.scn | 4 ++-- .../Tutorials/StepByStep/Pendulum/7_Pendulum.scn | 4 ++-- .../TopologicalMapping/2_TopoMapping.scn | 4 ++-- .../TopologicalMapping/3_TopoMapping.scn | 4 ++-- .../TopologicalMapping/4_TopoMapping.scn | 4 ++-- .../TopologicalMapping/5_TopoMapping.scn | 4 ++-- .../TopologicalMapping/6_TopoMapping.scn | 4 ++-- .../Topologies/TopologyDynamicSurfaceMesh.scn | 6 +++--- .../TopologyHexa2QuadTopologicalMapping.scn | 4 ++-- .../TopologyHexa2TetraTopologicalMapping.scn | 4 ++-- .../Topologies/TopologyLinearDifferentMesh.scn | 8 ++++---- .../Tutorials/Topologies/TopologyLinearMesh.scn | 6 +++--- .../TopologyQuad2TriangleTopologicalMapping.scn | 4 ++-- .../Topologies/TopologySurfaceDifferentMesh.scn | 8 ++++---- .../TopologyTetra2TriangleTopologicalMapping.scn | 4 ++-- .../TopologyTriangle2EdgeTopologicalMapping.scn | 4 ++-- .../Topologies/TopologyVolumeDifferentMesh.scn | 8 ++++---- .../Tutorials/sandbox/explicit_singlehexaFEM.scn | 4 ++-- .../Tutorials/sandbox/implicit_singlehexaFEM.scn | 4 ++-- .../Tutorials/sandbox/implicit_singlehexaFEM_2.scn | 4 ++-- .../Tutorials/sandbox/rungekutta_singlehexaFEM.scn | 4 ++-- 303 files changed, 663 insertions(+), 663 deletions(-) diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h index 89f347b303d..28e99260259 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h b/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h index 4b93b261499..7412259eac9 100644 --- a/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h +++ b/Sofa/GUI/Component/src/sofa/gui/component/performer/SuturePointPerformer.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/applications/collections/deprecated/modules/SofaExporter/examples/OBJExporter.scn b/applications/collections/deprecated/modules/SofaExporter/examples/OBJExporter.scn index 7a3879a7e45..47ba602efd0 100644 --- a/applications/collections/deprecated/modules/SofaExporter/examples/OBJExporter.scn +++ b/applications/collections/deprecated/modules/SofaExporter/examples/OBJExporter.scn @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/applications/plugins/ArticulatedSystemPlugin/examples/ArticulatedSystemMapping.scn b/applications/plugins/ArticulatedSystemPlugin/examples/ArticulatedSystemMapping.scn index 59ff8a7857f..14f8ceb8057 100644 --- a/applications/plugins/ArticulatedSystemPlugin/examples/ArticulatedSystemMapping.scn +++ b/applications/plugins/ArticulatedSystemPlugin/examples/ArticulatedSystemMapping.scn @@ -5,7 +5,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/applications/plugins/BulletCollisionDetection/examples/BulletConvexHullDemo.scn b/applications/plugins/BulletCollisionDetection/examples/BulletConvexHullDemo.scn index 6941d64206f..8b451789701 100644 --- a/applications/plugins/BulletCollisionDetection/examples/BulletConvexHullDemo.scn +++ b/applications/plugins/BulletCollisionDetection/examples/BulletConvexHullDemo.scn @@ -6,7 +6,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/applications/plugins/BulletCollisionDetection/examples/BulletLMDragon.scn b/applications/plugins/BulletCollisionDetection/examples/BulletLMDragon.scn index dfe56efbf3f..d4d284f4e3c 100644 --- a/applications/plugins/BulletCollisionDetection/examples/BulletLMDragon.scn +++ b/applications/plugins/BulletCollisionDetection/examples/BulletLMDragon.scn @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/BulletCollisionDetection/examples/BulletSphere.scn b/applications/plugins/BulletCollisionDetection/examples/BulletSphere.scn index 5b6cf8c420f..5c549726185 100644 --- a/applications/plugins/BulletCollisionDetection/examples/BulletSphere.scn +++ b/applications/plugins/BulletCollisionDetection/examples/BulletSphere.scn @@ -6,7 +6,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBCap.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBCap.scn index 5b99c835abf..a3b22ccb2ba 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBCap.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBCap.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBCap1.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBCap1.scn index ad6980d15de..be3d5623649 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBCap1.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBCap1.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeEdge.scn index 69cb203fb53..f067b42d1a9 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeEdge.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeVertex.scn index 007317fed3d..b4bd1bff158 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBCapEdgeVertex.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexEdge.scn index 553a46dc083..8b5f3fd8f50 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexEdge.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexVertex.scn index 0df0fd3a3bf..74699c66456 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBCapVertexVertex.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBB.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBB.scn index bb2e1d1fcee..6e30f739230 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBB.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBB.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBB2.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBB2.scn index f07ebf0d8c1..b3b6f6f3737 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBB2.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBB2.scn @@ -4,7 +4,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBAlea.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBAlea.scn index 09785b19869..98404d9e504 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBAlea.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBAlea.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBCollision.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBCollision.scn index 8b4b816a814..cb722ba85a4 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBCollision.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBCollision.scn @@ -4,7 +4,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeEdge.scn index 2e592d5f536..8809f875aca 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeEdge.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeVertex.scn index 6db3a901805..39ba344e353 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBEdgeVertex.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBFaceEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBFaceEdge.scn index b717a476163..a8281fd12f9 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBFaceEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBFaceEdge.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBVertexVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBVertexVertex.scn index f7fe9535c12..48bff4ce98e 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBOBBVertexVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBOBBVertexVertex.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBSphere.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBSphere.scn index a21c57e5398..3986adc9c3b 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBSphere.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBSphere.scn @@ -5,7 +5,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBSphere2.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBSphere2.scn index 67dcef7f5bb..6958086322e 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBSphere2.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBSphere2.scn @@ -5,7 +5,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBSphereEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBSphereEdge.scn index 73ce0986e7d..fb19177217f 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBSphereEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBSphereEdge.scn @@ -5,7 +5,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBSphereVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBSphereVertex.scn index 532a53d0986..e1131d724bc 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBSphereVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBSphereVertex.scn @@ -5,7 +5,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTri.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTri.scn index d5c1c45527b..013b2b8509c 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTri.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTri.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge.scn index 0dfb625fa80..1fc60715158 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge2.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge2.scn index c8474887f48..940298e3d69 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge2.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeEdge2.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeVerex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeVerex.scn index 66ca20abf4d..182c5ef73da 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeVerex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriEdgeVerex.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriFaceVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriFaceVertex.scn index b2ebf71afec..73e1e1535ef 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriFaceVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriFaceVertex.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexEdge.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexEdge.scn index d30e39a726a..4db77349d71 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexEdge.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexEdge.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexFace.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexFace.scn index c1893aca86d..e25636aae4e 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexFace.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexFace.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexVertex.scn b/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexVertex.scn index 37a9abb241c..452b69386b4 100644 --- a/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexVertex.scn +++ b/applications/plugins/CollisionOBBCapsule/examples/OBBTriVertexVertex.scn @@ -5,7 +5,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/applications/plugins/ExternalBehaviorModel/example/simple.scn b/applications/plugins/ExternalBehaviorModel/example/simple.scn index b9e6b608b89..ef6ce72b566 100644 --- a/applications/plugins/ExternalBehaviorModel/example/simple.scn +++ b/applications/plugins/ExternalBehaviorModel/example/simple.scn @@ -3,7 +3,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/applications/plugins/Geomagic/scenes/Geomagic-DeformableCubes.scn b/applications/plugins/Geomagic/scenes/Geomagic-DeformableCubes.scn index b6ebff5c894..8447dc4d862 100644 --- a/applications/plugins/Geomagic/scenes/Geomagic-DeformableCubes.scn +++ b/applications/plugins/Geomagic/scenes/Geomagic-DeformableCubes.scn @@ -8,7 +8,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -86,7 +86,7 @@ - + diff --git a/applications/plugins/Geomagic/scenes/Geomagic-DeformableSphere.scn b/applications/plugins/Geomagic/scenes/Geomagic-DeformableSphere.scn index d6f8c9ff6ce..d3f88c411bb 100644 --- a/applications/plugins/Geomagic/scenes/Geomagic-DeformableSphere.scn +++ b/applications/plugins/Geomagic/scenes/Geomagic-DeformableSphere.scn @@ -8,7 +8,7 @@ - + @@ -56,7 +56,7 @@ - + diff --git a/applications/plugins/Geomagic/scenes/Geomagic-FEMLiver.scn b/applications/plugins/Geomagic/scenes/Geomagic-FEMLiver.scn index cdf81e4fab8..81d53f6df1b 100644 --- a/applications/plugins/Geomagic/scenes/Geomagic-FEMLiver.scn +++ b/applications/plugins/Geomagic/scenes/Geomagic-FEMLiver.scn @@ -8,7 +8,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/applications/plugins/LeapMotion/examples/buffoon.scn b/applications/plugins/LeapMotion/examples/buffoon.scn index bfd57985440..5e9cbdc251e 100644 --- a/applications/plugins/LeapMotion/examples/buffoon.scn +++ b/applications/plugins/LeapMotion/examples/buffoon.scn @@ -85,7 +85,7 @@ - + diff --git a/applications/plugins/MultiThreading/examples/BeamLinearMapping_mt.scn b/applications/plugins/MultiThreading/examples/BeamLinearMapping_mt.scn index defb33bfc4d..0bb5ba0765e 100644 --- a/applications/plugins/MultiThreading/examples/BeamLinearMapping_mt.scn +++ b/applications/plugins/MultiThreading/examples/BeamLinearMapping_mt.scn @@ -4,7 +4,7 @@ - + @@ -35,7 +35,7 @@ --> - + - + @@ -23,7 +23,7 @@ - + diff --git a/applications/plugins/MultiThreading/examples/ParallelHexahedronFEMForceField.scn b/applications/plugins/MultiThreading/examples/ParallelHexahedronFEMForceField.scn index e147745648a..1b5a5f24201 100644 --- a/applications/plugins/MultiThreading/examples/ParallelHexahedronFEMForceField.scn +++ b/applications/plugins/MultiThreading/examples/ParallelHexahedronFEMForceField.scn @@ -1,7 +1,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/applications/plugins/MultiThreading/examples/ParallelMeshSpringForceField.scn b/applications/plugins/MultiThreading/examples/ParallelMeshSpringForceField.scn index 726abe07d5b..64bb539add1 100644 --- a/applications/plugins/MultiThreading/examples/ParallelMeshSpringForceField.scn +++ b/applications/plugins/MultiThreading/examples/ParallelMeshSpringForceField.scn @@ -2,7 +2,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/applications/plugins/MultiThreading/examples/ParallelTetrahedronFEMForceField.scn b/applications/plugins/MultiThreading/examples/ParallelTetrahedronFEMForceField.scn index 655bd5c2f4a..31594029598 100644 --- a/applications/plugins/MultiThreading/examples/ParallelTetrahedronFEMForceField.scn +++ b/applications/plugins/MultiThreading/examples/ParallelTetrahedronFEMForceField.scn @@ -1,6 +1,6 @@ - + @@ -31,7 +31,7 @@ method="large" computeVonMisesStress="1" showVonMisesStressPerElement="true"/> - + diff --git a/applications/plugins/MultiThreading/examples/TriangularForceFieldComparison.scn b/applications/plugins/MultiThreading/examples/TriangularForceFieldComparison.scn index e1d4f772a79..a3e67630803 100644 --- a/applications/plugins/MultiThreading/examples/TriangularForceFieldComparison.scn +++ b/applications/plugins/MultiThreading/examples/TriangularForceFieldComparison.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -127,7 +127,7 @@ - + diff --git a/applications/plugins/MultiThreading/examples/livers.scn b/applications/plugins/MultiThreading/examples/livers.scn index 9a612b523a7..ec48c42ebc2 100644 --- a/applications/plugins/MultiThreading/examples/livers.scn +++ b/applications/plugins/MultiThreading/examples/livers.scn @@ -7,7 +7,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -138,7 +138,7 @@ - + diff --git a/applications/plugins/MultiThreading/examples/liversMeanPositions.scn b/applications/plugins/MultiThreading/examples/liversMeanPositions.scn index 537edd0c458..4338d44d9e8 100644 --- a/applications/plugins/MultiThreading/examples/liversMeanPositions.scn +++ b/applications/plugins/MultiThreading/examples/liversMeanPositions.scn @@ -7,7 +7,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -138,7 +138,7 @@ - + @@ -179,7 +179,7 @@ - + diff --git a/applications/plugins/Sensable/examples/Carving.scn b/applications/plugins/Sensable/examples/Carving.scn index 0faf21331dc..085515da169 100644 --- a/applications/plugins/Sensable/examples/Carving.scn +++ b/applications/plugins/Sensable/examples/Carving.scn @@ -22,7 +22,7 @@ - + diff --git a/applications/plugins/Sensable/examples/Deformable-Method1.scn b/applications/plugins/Sensable/examples/Deformable-Method1.scn index 493310549a7..2490a666f80 100644 --- a/applications/plugins/Sensable/examples/Deformable-Method1.scn +++ b/applications/plugins/Sensable/examples/Deformable-Method1.scn @@ -18,7 +18,7 @@ - + diff --git a/applications/plugins/Sensable/examples/Old Examples/flexibleRaptor.scn b/applications/plugins/Sensable/examples/Old Examples/flexibleRaptor.scn index 20955efe5e6..864a1e2dec6 100644 --- a/applications/plugins/Sensable/examples/Old Examples/flexibleRaptor.scn +++ b/applications/plugins/Sensable/examples/Old Examples/flexibleRaptor.scn @@ -25,7 +25,7 @@ - + diff --git a/applications/plugins/Sensable/examples/Old Examples/omni-probing-liver.scn b/applications/plugins/Sensable/examples/Old Examples/omni-probing-liver.scn index 72f342fe938..4031bae0c17 100644 --- a/applications/plugins/Sensable/examples/Old Examples/omni-probing-liver.scn +++ b/applications/plugins/Sensable/examples/Old Examples/omni-probing-liver.scn @@ -15,7 +15,7 @@ - + diff --git a/applications/plugins/SixenseHydra/Scenes/Hydra_buffon.scn b/applications/plugins/SixenseHydra/Scenes/Hydra_buffon.scn index b442bb87892..77a761c3713 100644 --- a/applications/plugins/SixenseHydra/Scenes/Hydra_buffon.scn +++ b/applications/plugins/SixenseHydra/Scenes/Hydra_buffon.scn @@ -69,7 +69,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/CudaDiagonalMass3f.scn b/applications/plugins/SofaCUDA/examples/CudaDiagonalMass3f.scn index a41d7f7d812..a050a77b4df 100644 --- a/applications/plugins/SofaCUDA/examples/CudaDiagonalMass3f.scn +++ b/applications/plugins/SofaCUDA/examples/CudaDiagonalMass3f.scn @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/CudaMeshMatrixMass3f.scn b/applications/plugins/SofaCUDA/examples/CudaMeshMatrixMass3f.scn index c37d31a435e..96be448a5c7 100644 --- a/applications/plugins/SofaCUDA/examples/CudaMeshMatrixMass3f.scn +++ b/applications/plugins/SofaCUDA/examples/CudaMeshMatrixMass3f.scn @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/SquareTissue-cpu.scn b/applications/plugins/SofaCUDA/examples/SquareTissue-cpu.scn index 8c4fc663c16..24a9bfef1f3 100644 --- a/applications/plugins/SofaCUDA/examples/SquareTissue-cpu.scn +++ b/applications/plugins/SofaCUDA/examples/SquareTissue-cpu.scn @@ -4,7 +4,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/SquareTissue-cuda.scn b/applications/plugins/SofaCUDA/examples/SquareTissue-cuda.scn index 0de5b702db0..dd98b0408bc 100644 --- a/applications/plugins/SofaCUDA/examples/SquareTissue-cuda.scn +++ b/applications/plugins/SofaCUDA/examples/SquareTissue-cuda.scn @@ -9,7 +9,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/liver-CUDA.scn b/applications/plugins/SofaCUDA/examples/liver-CUDA.scn index 5a0d97d9267..aab06f1e869 100644 --- a/applications/plugins/SofaCUDA/examples/liver-CUDA.scn +++ b/applications/plugins/SofaCUDA/examples/liver-CUDA.scn @@ -8,7 +8,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/quadSpringSphere.scn b/applications/plugins/SofaCUDA/examples/quadSpringSphere.scn index 68b670c1f6c..2bb630e301f 100644 --- a/applications/plugins/SofaCUDA/examples/quadSpringSphere.scn +++ b/applications/plugins/SofaCUDA/examples/quadSpringSphere.scn @@ -3,7 +3,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/quadSpringSphere2CUDA.scn b/applications/plugins/SofaCUDA/examples/quadSpringSphere2CUDA.scn index 93848be19a2..c64e31937aa 100644 --- a/applications/plugins/SofaCUDA/examples/quadSpringSphere2CUDA.scn +++ b/applications/plugins/SofaCUDA/examples/quadSpringSphere2CUDA.scn @@ -6,7 +6,7 @@ - + - + @@ -28,7 +28,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/raptor-surface-cpu.scn b/applications/plugins/SofaCUDA/examples/raptor-surface-cpu.scn index 3d81d8eee70..1b552f2fee4 100644 --- a/applications/plugins/SofaCUDA/examples/raptor-surface-cpu.scn +++ b/applications/plugins/SofaCUDA/examples/raptor-surface-cpu.scn @@ -1,5 +1,5 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/raptor-surface-cuda.scn b/applications/plugins/SofaCUDA/examples/raptor-surface-cuda.scn index c1f13507fcc..678a2fc71a1 100644 --- a/applications/plugins/SofaCUDA/examples/raptor-surface-cuda.scn +++ b/applications/plugins/SofaCUDA/examples/raptor-surface-cuda.scn @@ -4,7 +4,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/applications/plugins/SofaCUDA/examples/raptor.scn b/applications/plugins/SofaCUDA/examples/raptor.scn index 2578f49d39f..0a6c0019fe9 100644 --- a/applications/plugins/SofaCUDA/examples/raptor.scn +++ b/applications/plugins/SofaCUDA/examples/raptor.scn @@ -10,7 +10,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/CudaHexahedronTLEDForceField_beam10x10x40_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/CudaHexahedronTLEDForceField_beam10x10x40_gpu.scn index 8fa7c7bffd9..7627e77bd95 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/CudaHexahedronTLEDForceField_beam10x10x40_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/CudaHexahedronTLEDForceField_beam10x10x40_gpu.scn @@ -9,7 +9,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam10x10x40_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam10x10x40_gpu.scn index 2ef393cbcd6..978a4024548 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam10x10x40_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam10x10x40_gpu.scn @@ -9,7 +9,7 @@ - + @@ -42,7 +42,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam16x16x76_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam16x16x76_gpu.scn index 874433d4ddc..fb541d527d5 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam16x16x76_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/CudaTetrahedronTLEDForceField_beam16x16x76_gpu.scn @@ -11,7 +11,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_cpu.scn index 6252c3efb66..105193031cc 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_cpu.scn @@ -3,7 +3,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_gpu.scn index 380b07e84e9..5c3d6865027 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam10x10x40_gpu.scn @@ -10,7 +10,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_cpu.scn index 6e62626d07d..9a22dfc3dc9 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_cpu.scn @@ -3,7 +3,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_gpu.scn index a4dc1cf195e..a10083418e6 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/HexahedronFEMForceField_beam16x16x76_gpu.scn @@ -12,7 +12,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_cpu.scn index ac8153d6f7b..7796da7c44c 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_cpu.scn @@ -3,7 +3,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_gpu.scn index 5e6d8de2f26..d17803e7c3d 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/MeshSpringForceField_beam10x10x40_gpu.scn @@ -10,7 +10,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_cpu.scn index 1679a23ead9..0e8d83018f0 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_cpu.scn @@ -1,6 +1,6 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_gpu.scn index b6a75ba6749..04e69c0d70a 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/QuadSpringsSphere_gpu.scn @@ -7,7 +7,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_cpu.scn index 9582735633f..a927ece7da5 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_cpu.scn @@ -3,7 +3,7 @@ - + @@ -48,7 +48,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_gpu.scn index 04db6e4a562..62633ccb794 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam10x10x40_gpu.scn @@ -10,7 +10,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_cpu.scn index ff4eabb5c35..dee6efd1fca 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_cpu.scn @@ -3,7 +3,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_gpu.scn index 0e5df06504b..096de16b541 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/TetrahedronFEMForceField_beam16x16x76_gpu.scn @@ -12,7 +12,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_cpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_cpu.scn index b5e3b8c6510..9aa2db094bd 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_cpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_cpu.scn @@ -3,7 +3,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_gpu.scn b/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_gpu.scn index a8e58525301..437e8d591a1 100644 --- a/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_gpu.scn +++ b/applications/plugins/SofaCUDA/scenes/benchmarks/TriangularFEMForceFieldOptim_tissue100x100_gpu.scn @@ -9,7 +9,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_implicit.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_implicit.scn index 1d5b9a9ede3..718ffb9e7bc 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_implicit.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_implicit.scn @@ -3,7 +3,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_rk4.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_rk4.scn index 58965778e86..b8076ed393b 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_rk4.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaHexahedronFEMForceField_beam10x10x40_rk4.scn @@ -3,7 +3,7 @@ - + @@ -15,7 +15,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -66,7 +66,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_implicit.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_implicit.scn index 8fba50c8a84..e584d442fb7 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_implicit.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_implicit.scn @@ -3,7 +3,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -65,7 +65,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_rk4.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_rk4.scn index 80cf963b23a..dce457e8680 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_rk4.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaMeshSpringForceField_beam10x10x40_rk4.scn @@ -3,7 +3,7 @@ - + @@ -15,7 +15,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_implicit.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_implicit.scn index 35e427802eb..c44f740e076 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_implicit.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_implicit.scn @@ -3,7 +3,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -79,7 +79,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_rk4.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_rk4.scn index 02270abfece..1a5df4ad730 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_rk4.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTetrahedronFEMForceField_beam10x10x40_rk4.scn @@ -3,7 +3,7 @@ - + @@ -15,7 +15,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue100x100_implicit.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue100x100_implicit.scn index cbf2b07201e..e02a3548e2a 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue100x100_implicit.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue100x100_implicit.scn @@ -3,7 +3,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -61,7 +61,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue20x20_implicit.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue20x20_implicit.scn index 51687ad146c..7d5e1e5f69a 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue20x20_implicit.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/CudaTriangularFEMForceFieldOptim_tissue20x20_implicit.scn @@ -3,7 +3,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -61,7 +61,7 @@ - + diff --git a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/QuadSpringsSphere.scn b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/QuadSpringsSphere.scn index b974d155a30..9d0f01b6e19 100644 --- a/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/QuadSpringsSphere.scn +++ b/applications/plugins/SofaCUDA/scenes/cpu-gpu_validation/QuadSpringsSphere.scn @@ -1,6 +1,6 @@ - + @@ -12,7 +12,7 @@ - + diff --git a/applications/plugins/SofaCarving/examples/CarvingTool.scn b/applications/plugins/SofaCarving/examples/CarvingTool.scn index 56cebdcab64..c7be2d9f4be 100644 --- a/applications/plugins/SofaCarving/examples/CarvingTool.scn +++ b/applications/plugins/SofaCarving/examples/CarvingTool.scn @@ -5,7 +5,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/applications/plugins/SofaCarving/examples/SimpleCarving.scn b/applications/plugins/SofaCarving/examples/SimpleCarving.scn index 73eece42082..7fa29ef2fcb 100644 --- a/applications/plugins/SofaCarving/examples/SimpleCarving.scn +++ b/applications/plugins/SofaCarving/examples/SimpleCarving.scn @@ -5,7 +5,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/applications/plugins/SofaCarving/examples/SimpleCarving_withPenetration.scn b/applications/plugins/SofaCarving/examples/SimpleCarving_withPenetration.scn index b30466918a4..1150c133828 100644 --- a/applications/plugins/SofaCarving/examples/SimpleCarving_withPenetration.scn +++ b/applications/plugins/SofaCarving/examples/SimpleCarving_withPenetration.scn @@ -5,7 +5,7 @@ - + @@ -43,7 +43,7 @@ - + diff --git a/applications/plugins/SofaDistanceGrid/examples/FFDDistanceGridCollisionModel.scn b/applications/plugins/SofaDistanceGrid/examples/FFDDistanceGridCollisionModel.scn index 5f81a39f478..5917bf01f9c 100644 --- a/applications/plugins/SofaDistanceGrid/examples/FFDDistanceGridCollisionModel.scn +++ b/applications/plugins/SofaDistanceGrid/examples/FFDDistanceGridCollisionModel.scn @@ -4,7 +4,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/applications/plugins/SofaHAPI/examples/SofaHAPI1.scn b/applications/plugins/SofaHAPI/examples/SofaHAPI1.scn index 39df2f1751d..ef2c5275e58 100644 --- a/applications/plugins/SofaHAPI/examples/SofaHAPI1.scn +++ b/applications/plugins/SofaHAPI/examples/SofaHAPI1.scn @@ -71,7 +71,7 @@ - + @@ -91,7 +91,7 @@ - + diff --git a/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn b/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn index 245bc21c6ce..c25e38f1c05 100644 --- a/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn +++ b/applications/plugins/SofaMatrix/examples/ComplianceMatrixExporter.scn @@ -3,7 +3,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn b/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn index b131e803661..c84dbe04205 100644 --- a/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn +++ b/applications/plugins/SofaMatrix/examples/ComplianceMatrixImage.scn @@ -3,7 +3,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn b/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn index 6e5f3c40528..637e6cf2317 100644 --- a/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn +++ b/applications/plugins/SofaMatrix/examples/FillReducingOrdering.scn @@ -7,7 +7,7 @@ The scene compares two simulations in which only the vertices order differs: - The Node "Reorder" simulates the reordered mesh. --> - + @@ -41,7 +41,7 @@ The scene compares two simulations in which only the vertices order differs: - + @@ -63,7 +63,7 @@ The scene compares two simulations in which only the vertices order differs: - + diff --git a/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixExporter.scn b/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixExporter.scn index 7d8cb1f45ab..73aeaaefc6c 100644 --- a/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixExporter.scn +++ b/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixExporter.scn @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -47,14 +47,14 @@ - + - + diff --git a/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixImage.scn b/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixImage.scn index f7b91bace85..dabb9ac50b3 100644 --- a/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixImage.scn +++ b/applications/plugins/SofaMatrix/examples/GlobalSystemMatrixImage.scn @@ -1,5 +1,5 @@ - + @@ -22,14 +22,14 @@ - + - + diff --git a/applications/plugins/SofaNewmat/examples/MatrixContributions121.scn b/applications/plugins/SofaNewmat/examples/MatrixContributions121.scn index b62ead4bd7a..0531b6a07f9 100644 --- a/applications/plugins/SofaNewmat/examples/MatrixContributions121.scn +++ b/applications/plugins/SofaNewmat/examples/MatrixContributions121.scn @@ -7,7 +7,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -61,7 +61,7 @@ - + diff --git a/applications/plugins/SofaNewmat/examples/MatrixContributions122.scn b/applications/plugins/SofaNewmat/examples/MatrixContributions122.scn index 329845633a7..32e9dbdb8aa 100644 --- a/applications/plugins/SofaNewmat/examples/MatrixContributions122.scn +++ b/applications/plugins/SofaNewmat/examples/MatrixContributions122.scn @@ -7,7 +7,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -83,7 +83,7 @@ - + diff --git a/applications/plugins/SofaNewmat/examples/MatrixContributions123.scn b/applications/plugins/SofaNewmat/examples/MatrixContributions123.scn index 0b01f17072a..92de546a666 100644 --- a/applications/plugins/SofaNewmat/examples/MatrixContributions123.scn +++ b/applications/plugins/SofaNewmat/examples/MatrixContributions123.scn @@ -7,7 +7,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -104,7 +104,7 @@ - + diff --git a/applications/plugins/SofaPardisoSolver/examples/FEMBAR-SparsePARDISOSolver.scn b/applications/plugins/SofaPardisoSolver/examples/FEMBAR-SparsePARDISOSolver.scn index 3c0e22b9c78..72047b6b2c9 100644 --- a/applications/plugins/SofaPardisoSolver/examples/FEMBAR-SparsePARDISOSolver.scn +++ b/applications/plugins/SofaPardisoSolver/examples/FEMBAR-SparsePARDISOSolver.scn @@ -16,7 +16,7 @@ - + diff --git a/applications/plugins/SofaSimpleGUI/examples/liver.scn b/applications/plugins/SofaSimpleGUI/examples/liver.scn index e34960720fd..2ea0cb8954c 100644 --- a/applications/plugins/SofaSimpleGUI/examples/liver.scn +++ b/applications/plugins/SofaSimpleGUI/examples/liver.scn @@ -3,7 +3,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/applications/plugins/SofaSimpleGUI/examples/oneTet.scn b/applications/plugins/SofaSimpleGUI/examples/oneTet.scn index 59664aa0625..a11bac2929f 100644 --- a/applications/plugins/SofaSimpleGUI/examples/oneTet.scn +++ b/applications/plugins/SofaSimpleGUI/examples/oneTet.scn @@ -1,7 +1,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/applications/plugins/SofaSphFluid/examples/ParticlesRepulsionForceField.scn b/applications/plugins/SofaSphFluid/examples/ParticlesRepulsionForceField.scn index f297af3ddd5..c5e2feef46f 100644 --- a/applications/plugins/SofaSphFluid/examples/ParticlesRepulsionForceField.scn +++ b/applications/plugins/SofaSphFluid/examples/ParticlesRepulsionForceField.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn index c0d5b83d584..5f2c6b2249f 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_Rigid.scn @@ -6,7 +6,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn b/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn index 52d7979148e..0d8004f572e 100644 --- a/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn +++ b/examples/Component/Constraint/Lagrangian/InextensiblePendulum.scn @@ -7,7 +7,7 @@ - + @@ -42,7 +42,7 @@ - + diff --git a/examples/Component/Constraint/Projective/AttachConstraint.scn b/examples/Component/Constraint/Projective/AttachConstraint.scn index 222d1833721..80c6b41aa3f 100644 --- a/examples/Component/Constraint/Projective/AttachConstraint.scn +++ b/examples/Component/Constraint/Projective/AttachConstraint.scn @@ -1,5 +1,5 @@ - + diff --git a/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn b/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn index e6b835075a0..b793d815853 100644 --- a/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn +++ b/examples/Component/Constraint/Projective/AttachConstraintMatrix.scn @@ -1,5 +1,5 @@ - + diff --git a/examples/Component/Constraint/Projective/BoxConstraint.scn b/examples/Component/Constraint/Projective/BoxConstraint.scn index 91220946b68..567d0d4fd99 100644 --- a/examples/Component/Constraint/Projective/BoxConstraint.scn +++ b/examples/Component/Constraint/Projective/BoxConstraint.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/Constraint/Projective/FixedConstraint.scn b/examples/Component/Constraint/Projective/FixedConstraint.scn index f7d7b948cb3..91adbd6b917 100644 --- a/examples/Component/Constraint/Projective/FixedConstraint.scn +++ b/examples/Component/Constraint/Projective/FixedConstraint.scn @@ -3,7 +3,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Constraint/Projective/FixedPlaneConstraint.scn b/examples/Component/Constraint/Projective/FixedPlaneConstraint.scn index 52b7ecb3c56..e81e89fe67e 100644 --- a/examples/Component/Constraint/Projective/FixedPlaneConstraint.scn +++ b/examples/Component/Constraint/Projective/FixedPlaneConstraint.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/Constraint/Projective/FixedRotationConstraint.scn b/examples/Component/Constraint/Projective/FixedRotationConstraint.scn index bf7d63aa34c..dff0cbf791f 100644 --- a/examples/Component/Constraint/Projective/FixedRotationConstraint.scn +++ b/examples/Component/Constraint/Projective/FixedRotationConstraint.scn @@ -2,7 +2,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Constraint/Projective/OscillatorConstraint.scn b/examples/Component/Constraint/Projective/OscillatorConstraint.scn index 4484ced8519..00616311214 100644 --- a/examples/Component/Constraint/Projective/OscillatorConstraint.scn +++ b/examples/Component/Constraint/Projective/OscillatorConstraint.scn @@ -3,7 +3,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Constraint/Projective/PlaneConstraint.scn b/examples/Component/Constraint/Projective/PlaneConstraint.scn index 9a75dbad20f..544b3c203aa 100644 --- a/examples/Component/Constraint/Projective/PlaneConstraint.scn +++ b/examples/Component/Constraint/Projective/PlaneConstraint.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn b/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn index 726794f8664..eab3eae47e1 100644 --- a/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectDirectionConstraint.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn b/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn index 6b7fecb9a70..4174189da28 100644 --- a/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToLineConstraint.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn b/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn index c9c99fc9716..797dd281312 100644 --- a/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToPlaneConstraint.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn b/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn index d6289699af8..c8fbd99a6fd 100644 --- a/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn +++ b/examples/Component/Constraint/Projective/ProjectToPointConstraint.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/Controller/MechanicalStateController.scn b/examples/Component/Controller/MechanicalStateController.scn index 65db4fe0dbc..8c4010ccf6b 100644 --- a/examples/Component/Controller/MechanicalStateController.scn +++ b/examples/Component/Controller/MechanicalStateController.scn @@ -3,7 +3,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Engine/Generate/GenerateCylinder.scn b/examples/Component/Engine/Generate/GenerateCylinder.scn index 0811e77902f..c0510c1ad90 100644 --- a/examples/Component/Engine/Generate/GenerateCylinder.scn +++ b/examples/Component/Engine/Generate/GenerateCylinder.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/examples/Component/Engine/Generate/GenerateGrid.scn b/examples/Component/Engine/Generate/GenerateGrid.scn index 716d48c1cd6..3759be30c7b 100644 --- a/examples/Component/Engine/Generate/GenerateGrid.scn +++ b/examples/Component/Engine/Generate/GenerateGrid.scn @@ -1,6 +1,6 @@ - + @@ -21,7 +21,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/examples/Component/Engine/Generate/MergePoints.scn b/examples/Component/Engine/Generate/MergePoints.scn index 462b3657c57..14b1f6c0f46 100644 --- a/examples/Component/Engine/Generate/MergePoints.scn +++ b/examples/Component/Engine/Generate/MergePoints.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/Engine/Generate/MeshTetraStuffing.scn b/examples/Component/Engine/Generate/MeshTetraStuffing.scn index 1fc3eb5daf4..02736784952 100644 --- a/examples/Component/Engine/Generate/MeshTetraStuffing.scn +++ b/examples/Component/Engine/Generate/MeshTetraStuffing.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/Engine/Select/BoxROI.scn b/examples/Component/Engine/Select/BoxROI.scn index 5faea6b844d..d2aae26848b 100644 --- a/examples/Component/Engine/Select/BoxROI.scn +++ b/examples/Component/Engine/Select/BoxROI.scn @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Engine/Select/BoxROI_1d.scn b/examples/Component/Engine/Select/BoxROI_1d.scn index d7f3a38bfd3..29c05fad73b 100644 --- a/examples/Component/Engine/Select/BoxROI_1d.scn +++ b/examples/Component/Engine/Select/BoxROI_1d.scn @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Component/Engine/Select/BoxROI_2d.scn b/examples/Component/Engine/Select/BoxROI_2d.scn index 8ff3eed83f2..d8aa11229f4 100644 --- a/examples/Component/Engine/Select/BoxROI_2d.scn +++ b/examples/Component/Engine/Select/BoxROI_2d.scn @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Component/Engine/Select/MeshBoundaryROI.scn b/examples/Component/Engine/Select/MeshBoundaryROI.scn index 708f6c5f2ae..268abb6cc96 100644 --- a/examples/Component/Engine/Select/MeshBoundaryROI.scn +++ b/examples/Component/Engine/Select/MeshBoundaryROI.scn @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Component/Engine/Select/MeshSplittingEngine.scn b/examples/Component/Engine/Select/MeshSplittingEngine.scn index 48e86e8323c..9964396e546 100644 --- a/examples/Component/Engine/Select/MeshSplittingEngine.scn +++ b/examples/Component/Engine/Select/MeshSplittingEngine.scn @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Engine/Select/PlaneROI.scn b/examples/Component/Engine/Select/PlaneROI.scn index bea69c86a28..efea84dec9c 100644 --- a/examples/Component/Engine/Select/PlaneROI.scn +++ b/examples/Component/Engine/Select/PlaneROI.scn @@ -3,7 +3,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Engine/Select/PointsFromIndices.scn b/examples/Component/Engine/Select/PointsFromIndices.scn index ed1337aee5b..7725226bba4 100644 --- a/examples/Component/Engine/Select/PointsFromIndices.scn +++ b/examples/Component/Engine/Select/PointsFromIndices.scn @@ -1,6 +1,6 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Component/Engine/Select/ProximityROI.scn b/examples/Component/Engine/Select/ProximityROI.scn index 30ed2542691..7ba48a66000 100644 --- a/examples/Component/Engine/Select/ProximityROI.scn +++ b/examples/Component/Engine/Select/ProximityROI.scn @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Engine/Select/SphereROI.scn b/examples/Component/Engine/Select/SphereROI.scn index 41f7d5eafa5..0b9e6848cd1 100644 --- a/examples/Component/Engine/Select/SphereROI.scn +++ b/examples/Component/Engine/Select/SphereROI.scn @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Engine/Select/SubsetTopology.scn b/examples/Component/Engine/Select/SubsetTopology.scn index 5368d557aef..f16a84ab8db 100644 --- a/examples/Component/Engine/Select/SubsetTopology.scn +++ b/examples/Component/Engine/Select/SubsetTopology.scn @@ -50,7 +50,7 @@ - + diff --git a/examples/Component/Engine/Select/SubsetTopology_localIndicesOption.scn b/examples/Component/Engine/Select/SubsetTopology_localIndicesOption.scn index 31bd27fdd00..5e50f45b027 100644 --- a/examples/Component/Engine/Select/SubsetTopology_localIndicesOption.scn +++ b/examples/Component/Engine/Select/SubsetTopology_localIndicesOption.scn @@ -3,7 +3,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/examples/Component/Engine/Select/SubsetTopology_refiningMesh.scn b/examples/Component/Engine/Select/SubsetTopology_refiningMesh.scn index 9278d14c0f0..56a2d8dfcdc 100644 --- a/examples/Component/Engine/Select/SubsetTopology_refiningMesh.scn +++ b/examples/Component/Engine/Select/SubsetTopology_refiningMesh.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn b/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn index e89f7fcc39f..14972862716 100644 --- a/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn +++ b/examples/Component/Engine/Select/SubsetTopology_withtetrahedra.scn @@ -3,7 +3,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Engine/Select/ValuesFromPositions_vectorField.scn b/examples/Component/Engine/Select/ValuesFromPositions_vectorField.scn index 7dae968e1ec..effa36cf9d9 100644 --- a/examples/Component/Engine/Select/ValuesFromPositions_vectorField.scn +++ b/examples/Component/Engine/Select/ValuesFromPositions_vectorField.scn @@ -4,7 +4,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Component/LinearSolver/Direct/Eigen3-SVD.scn b/examples/Component/LinearSolver/Direct/Eigen3-SVD.scn index 6cdfe62062d..356075b7f5f 100644 --- a/examples/Component/LinearSolver/Direct/Eigen3-SVD.scn +++ b/examples/Component/LinearSolver/Direct/Eigen3-SVD.scn @@ -1,7 +1,7 @@ - + @@ -19,7 +19,7 @@ - + diff --git a/examples/Component/LinearSolver/Direct/FEMBAR_SVDLinearSolver.scn b/examples/Component/LinearSolver/Direct/FEMBAR_SVDLinearSolver.scn index 1496fe41a7c..4c26c5c7735 100644 --- a/examples/Component/LinearSolver/Direct/FEMBAR_SVDLinearSolver.scn +++ b/examples/Component/LinearSolver/Direct/FEMBAR_SVDLinearSolver.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/LinearSolver/FEMBAR-common.xml b/examples/Component/LinearSolver/FEMBAR-common.xml index 2162436968d..924dcf4aec3 100644 --- a/examples/Component/LinearSolver/FEMBAR-common.xml +++ b/examples/Component/LinearSolver/FEMBAR-common.xml @@ -1,7 +1,7 @@ - + @@ -25,5 +25,5 @@ - + \ No newline at end of file diff --git a/examples/Component/LinearSolver/Iterative/CGLinearSolver.scn b/examples/Component/LinearSolver/Iterative/CGLinearSolver.scn index 24a12bf6f83..c7770743c4a 100644 --- a/examples/Component/LinearSolver/Iterative/CGLinearSolver.scn +++ b/examples/Component/LinearSolver/Iterative/CGLinearSolver.scn @@ -1,6 +1,6 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/examples/Component/LinearSystem/CompositeLinearSystem.scn b/examples/Component/LinearSystem/CompositeLinearSystem.scn index b8db4d65117..d0c869966ad 100644 --- a/examples/Component/LinearSystem/CompositeLinearSystem.scn +++ b/examples/Component/LinearSystem/CompositeLinearSystem.scn @@ -1,5 +1,5 @@ - + @@ -41,7 +41,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -79,7 +79,7 @@ - + diff --git a/examples/Component/LinearSystem/ConstantSparsityPatternSystem.scn b/examples/Component/LinearSystem/ConstantSparsityPatternSystem.scn index db3ae28eb81..af5194c5e13 100644 --- a/examples/Component/LinearSystem/ConstantSparsityPatternSystem.scn +++ b/examples/Component/LinearSystem/ConstantSparsityPatternSystem.scn @@ -1,7 +1,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/examples/Component/LinearSystem/MatrixLinearSystem.scn b/examples/Component/LinearSystem/MatrixLinearSystem.scn index fa0299f2009..8b034949c81 100644 --- a/examples/Component/LinearSystem/MatrixLinearSystem.scn +++ b/examples/Component/LinearSystem/MatrixLinearSystem.scn @@ -1,7 +1,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -93,7 +93,7 @@ - + diff --git a/examples/Component/LinearSystem/PendulumSpringsDistanceMapping.scn b/examples/Component/LinearSystem/PendulumSpringsDistanceMapping.scn index 8266e71cc48..70341c2f496 100644 --- a/examples/Component/LinearSystem/PendulumSpringsDistanceMapping.scn +++ b/examples/Component/LinearSystem/PendulumSpringsDistanceMapping.scn @@ -5,7 +5,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -60,7 +60,7 @@ - + diff --git a/examples/Component/Mapping/Linear/BarycentricMappingTrussBeam.scn b/examples/Component/Mapping/Linear/BarycentricMappingTrussBeam.scn index 179bf348990..79102a5227b 100644 --- a/examples/Component/Mapping/Linear/BarycentricMappingTrussBeam.scn +++ b/examples/Component/Mapping/Linear/BarycentricMappingTrussBeam.scn @@ -3,7 +3,7 @@ - + @@ -53,7 +53,7 @@ - + diff --git a/examples/Component/Mapping/Linear/BarycentricTetraMapping.scn b/examples/Component/Mapping/Linear/BarycentricTetraMapping.scn index f98703a6526..7e22f035d0f 100644 --- a/examples/Component/Mapping/Linear/BarycentricTetraMapping.scn +++ b/examples/Component/Mapping/Linear/BarycentricTetraMapping.scn @@ -3,7 +3,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/examples/Component/Mapping/Linear/CenterOfMassMapping.scn b/examples/Component/Mapping/Linear/CenterOfMassMapping.scn index c570784c849..a50d9cdbc89 100644 --- a/examples/Component/Mapping/Linear/CenterOfMassMapping.scn +++ b/examples/Component/Mapping/Linear/CenterOfMassMapping.scn @@ -3,7 +3,7 @@ - + @@ -32,7 +32,7 @@ free_velocity="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" rest_position="0 0 0 0 0 0 1 1 0 0 0 0 0 1 3 0 0 0 0 0 1 5 0 0 0 0 0 1 7 0 0 0 0 0 1" /> - + - + @@ -42,7 +42,7 @@ - + diff --git a/examples/Component/Mapping/Linear/DeformableOnRigidFrameMappingConstraints.scn b/examples/Component/Mapping/Linear/DeformableOnRigidFrameMappingConstraints.scn index 463e57f4b12..b0cc566a42a 100644 --- a/examples/Component/Mapping/Linear/DeformableOnRigidFrameMappingConstraints.scn +++ b/examples/Component/Mapping/Linear/DeformableOnRigidFrameMappingConstraints.scn @@ -7,7 +7,7 @@ - + diff --git a/examples/Component/Mapping/Linear/IdentityMapping.scn b/examples/Component/Mapping/Linear/IdentityMapping.scn index a7758dd636f..ab825bf5fe3 100644 --- a/examples/Component/Mapping/Linear/IdentityMapping.scn +++ b/examples/Component/Mapping/Linear/IdentityMapping.scn @@ -4,7 +4,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Component/Mapping/Linear/SimpleTesselatedTetraTopologicalMapping.scn b/examples/Component/Mapping/Linear/SimpleTesselatedTetraTopologicalMapping.scn index 4d1cc74a819..4773230ce07 100644 --- a/examples/Component/Mapping/Linear/SimpleTesselatedTetraTopologicalMapping.scn +++ b/examples/Component/Mapping/Linear/SimpleTesselatedTetraTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Mapping/Linear/SkinningMapping.scn b/examples/Component/Mapping/Linear/SkinningMapping.scn index 351649d07ae..4d78200855f 100644 --- a/examples/Component/Mapping/Linear/SkinningMapping.scn +++ b/examples/Component/Mapping/Linear/SkinningMapping.scn @@ -3,7 +3,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/examples/Component/Mapping/Linear/SubsetMapping.scn b/examples/Component/Mapping/Linear/SubsetMapping.scn index d44ec9fc248..b3f9cc26273 100644 --- a/examples/Component/Mapping/Linear/SubsetMapping.scn +++ b/examples/Component/Mapping/Linear/SubsetMapping.scn @@ -4,7 +4,7 @@ - + @@ -41,7 +41,7 @@ /> - + diff --git a/examples/Component/Mapping/NonLinear/DistanceMapping.scn b/examples/Component/Mapping/NonLinear/DistanceMapping.scn index 2d79d67e6d1..fe92700c998 100644 --- a/examples/Component/Mapping/NonLinear/DistanceMapping.scn +++ b/examples/Component/Mapping/NonLinear/DistanceMapping.scn @@ -2,7 +2,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/DistanceMultiMapping.scn b/examples/Component/Mapping/NonLinear/DistanceMultiMapping.scn index 3a5f3a1e5f7..525c69acc04 100644 --- a/examples/Component/Mapping/NonLinear/DistanceMultiMapping.scn +++ b/examples/Component/Mapping/NonLinear/DistanceMultiMapping.scn @@ -2,7 +2,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -47,7 +47,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/RigidRigidMapping.scn b/examples/Component/Mapping/NonLinear/RigidRigidMapping.scn index 7ac77700c1c..a4a83f1ea47 100644 --- a/examples/Component/Mapping/NonLinear/RigidRigidMapping.scn +++ b/examples/Component/Mapping/NonLinear/RigidRigidMapping.scn @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/SquareDistanceMapping.scn b/examples/Component/Mapping/NonLinear/SquareDistanceMapping.scn index 60e7ce3bd35..03b54fc6d5b 100644 --- a/examples/Component/Mapping/NonLinear/SquareDistanceMapping.scn +++ b/examples/Component/Mapping/NonLinear/SquareDistanceMapping.scn @@ -2,7 +2,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/Mapping/NonLinear/SquareMapping.scn b/examples/Component/Mapping/NonLinear/SquareMapping.scn index dd96407b38a..db024529d70 100644 --- a/examples/Component/Mapping/NonLinear/SquareMapping.scn +++ b/examples/Component/Mapping/NonLinear/SquareMapping.scn @@ -2,7 +2,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -50,7 +50,7 @@ - + diff --git a/examples/Component/MechanicalLoad/ConstantForceField.scn b/examples/Component/MechanicalLoad/ConstantForceField.scn index f7f23dc35bb..c5969c4f212 100644 --- a/examples/Component/MechanicalLoad/ConstantForceField.scn +++ b/examples/Component/MechanicalLoad/ConstantForceField.scn @@ -22,7 +22,7 @@ - + diff --git a/examples/Component/MechanicalLoad/EllipsoidForceField.scn b/examples/Component/MechanicalLoad/EllipsoidForceField.scn index 73a6dbbef0a..717ab8d95db 100644 --- a/examples/Component/MechanicalLoad/EllipsoidForceField.scn +++ b/examples/Component/MechanicalLoad/EllipsoidForceField.scn @@ -5,7 +5,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn b/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn index 6f689334ae7..ef1a0060d8a 100644 --- a/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn +++ b/examples/Component/MechanicalLoad/InteractionEllipsoidForceField.scn @@ -3,7 +3,7 @@ - + @@ -37,9 +37,9 @@ - + - + diff --git a/examples/Component/MechanicalLoad/SphereForceField.scn b/examples/Component/MechanicalLoad/SphereForceField.scn index 298742dfc7b..fd6fd1d8992 100644 --- a/examples/Component/MechanicalLoad/SphereForceField.scn +++ b/examples/Component/MechanicalLoad/SphereForceField.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/MechanicalLoad/SurfacePressureForceField.scn b/examples/Component/MechanicalLoad/SurfacePressureForceField.scn index f8c69abde25..63a14b6b4ed 100644 --- a/examples/Component/MechanicalLoad/SurfacePressureForceField.scn +++ b/examples/Component/MechanicalLoad/SurfacePressureForceField.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/MechanicalLoad/TaitSurfacePressureForceField.scn b/examples/Component/MechanicalLoad/TaitSurfacePressureForceField.scn index 375558764ff..91e97efe3d4 100644 --- a/examples/Component/MechanicalLoad/TaitSurfacePressureForceField.scn +++ b/examples/Component/MechanicalLoad/TaitSurfacePressureForceField.scn @@ -3,7 +3,7 @@ - + diff --git a/examples/Component/MechanicalLoad/TrianglePressureForceField.scn b/examples/Component/MechanicalLoad/TrianglePressureForceField.scn index 28efd74f9b2..eebfa803818 100644 --- a/examples/Component/MechanicalLoad/TrianglePressureForceField.scn +++ b/examples/Component/MechanicalLoad/TrianglePressureForceField.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/ODESolver/Backward/EulerImplicitSolver-comparison.scn b/examples/Component/ODESolver/Backward/EulerImplicitSolver-comparison.scn index 9db818361d8..5cf7e86aba4 100644 --- a/examples/Component/ODESolver/Backward/EulerImplicitSolver-comparison.scn +++ b/examples/Component/ODESolver/Backward/EulerImplicitSolver-comparison.scn @@ -1,6 +1,6 @@ - + @@ -24,7 +24,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/examples/Component/ODESolver/Backward/EulerImplicitSolver.scn b/examples/Component/ODESolver/Backward/EulerImplicitSolver.scn index bc2b9b85373..bb30a06a950 100644 --- a/examples/Component/ODESolver/Backward/EulerImplicitSolver.scn +++ b/examples/Component/ODESolver/Backward/EulerImplicitSolver.scn @@ -1,5 +1,5 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/examples/Component/ODESolver/Backward/NewmarkImplicitSolver.scn b/examples/Component/ODESolver/Backward/NewmarkImplicitSolver.scn index 81796d0f426..3f391fb9ee9 100644 --- a/examples/Component/ODESolver/Backward/NewmarkImplicitSolver.scn +++ b/examples/Component/ODESolver/Backward/NewmarkImplicitSolver.scn @@ -1,5 +1,5 @@ - + @@ -24,7 +24,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -57,7 +57,7 @@ - + diff --git a/examples/Component/ODESolver/Backward/StaticSolver.scn b/examples/Component/ODESolver/Backward/StaticSolver.scn index 4689fba42e4..0a79f591aa5 100644 --- a/examples/Component/ODESolver/Backward/StaticSolver.scn +++ b/examples/Component/ODESolver/Backward/StaticSolver.scn @@ -1,5 +1,5 @@ - + @@ -26,7 +26,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -56,7 +56,7 @@ - + diff --git a/examples/Component/ODESolver/Backward/VariationalSymplecticSolver.scn b/examples/Component/ODESolver/Backward/VariationalSymplecticSolver.scn index a031face7c0..ea118addb4d 100644 --- a/examples/Component/ODESolver/Backward/VariationalSymplecticSolver.scn +++ b/examples/Component/ODESolver/Backward/VariationalSymplecticSolver.scn @@ -1,5 +1,5 @@ - + diff --git a/examples/Component/ODESolver/Forward/EulerExplicitSolver.scn b/examples/Component/ODESolver/Forward/EulerExplicitSolver.scn index 1272f33b10a..9f8fb209521 100644 --- a/examples/Component/ODESolver/Forward/EulerExplicitSolver.scn +++ b/examples/Component/ODESolver/Forward/EulerExplicitSolver.scn @@ -7,7 +7,7 @@ trivially, it requires a linear solver, here SparseLDLSolver. --> - + @@ -37,7 +37,7 @@ trivially, it requires a linear solver, here SparseLDLSolver. - + diff --git a/examples/Component/ODESolver/Forward/EulerExplicitSolver_diagonal.scn b/examples/Component/ODESolver/Forward/EulerExplicitSolver_diagonal.scn index a95b1a42dea..5a803ed22c5 100644 --- a/examples/Component/ODESolver/Forward/EulerExplicitSolver_diagonal.scn +++ b/examples/Component/ODESolver/Forward/EulerExplicitSolver_diagonal.scn @@ -7,7 +7,7 @@ trivially, it does not require a linear solver. --> - + @@ -36,7 +36,7 @@ trivially, it does not require a linear solver. - + diff --git a/examples/Component/ODESolver/Forward/EulerSymplecticSolver.scn b/examples/Component/ODESolver/Forward/EulerSymplecticSolver.scn index 14d46ad801f..a82b531ff07 100644 --- a/examples/Component/ODESolver/Forward/EulerSymplecticSolver.scn +++ b/examples/Component/ODESolver/Forward/EulerSymplecticSolver.scn @@ -7,7 +7,7 @@ trivially, it requires a linear solver, here SparseLDLSolver. --> - + @@ -29,7 +29,7 @@ trivially, it requires a linear solver, here SparseLDLSolver. - + diff --git a/examples/Component/ODESolver/Forward/EulerSymplecticSolver_diagonal.scn b/examples/Component/ODESolver/Forward/EulerSymplecticSolver_diagonal.scn index 6d5620fc725..f8a7a002d4a 100644 --- a/examples/Component/ODESolver/Forward/EulerSymplecticSolver_diagonal.scn +++ b/examples/Component/ODESolver/Forward/EulerSymplecticSolver_diagonal.scn @@ -7,7 +7,7 @@ trivially, it does not require a linear solver. --> - + @@ -29,7 +29,7 @@ trivially, it does not require a linear solver. - + diff --git a/examples/Component/ODESolver/Forward/RungeKutta4Solver.scn b/examples/Component/ODESolver/Forward/RungeKutta4Solver.scn index 5eb51e00eab..c45ca8d11f1 100644 --- a/examples/Component/ODESolver/Forward/RungeKutta4Solver.scn +++ b/examples/Component/ODESolver/Forward/RungeKutta4Solver.scn @@ -1,6 +1,6 @@ - + @@ -19,7 +19,7 @@ - + diff --git a/examples/Component/SceneUtility/Monitor.scn b/examples/Component/SceneUtility/Monitor.scn index 10a2bf4132a..1810517d79d 100644 --- a/examples/Component/SceneUtility/Monitor.scn +++ b/examples/Component/SceneUtility/Monitor.scn @@ -3,7 +3,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/BeamFEMForceField.scn b/examples/Component/SolidMechanics/FEM/BeamFEMForceField.scn index 6de3f836c54..f7d6d1850d5 100644 --- a/examples/Component/SolidMechanics/FEM/BeamFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/BeamFEMForceField.scn @@ -6,7 +6,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -70,7 +70,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/FastTetrahedralCorotationalForceField.scn b/examples/Component/SolidMechanics/FEM/FastTetrahedralCorotationalForceField.scn index ef62a08a3f6..f51bfdca6ef 100644 --- a/examples/Component/SolidMechanics/FEM/FastTetrahedralCorotationalForceField.scn +++ b/examples/Component/SolidMechanics/FEM/FastTetrahedralCorotationalForceField.scn @@ -1,6 +1,6 @@ - + @@ -31,7 +31,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -89,7 +89,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/FastTetrahedronCorotationalForceField_validation.scn b/examples/Component/SolidMechanics/FEM/FastTetrahedronCorotationalForceField_validation.scn index 47999c5dfac..5b222445625 100644 --- a/examples/Component/SolidMechanics/FEM/FastTetrahedronCorotationalForceField_validation.scn +++ b/examples/Component/SolidMechanics/FEM/FastTetrahedronCorotationalForceField_validation.scn @@ -3,7 +3,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/Heterogeneous-TetrahedronFEMForceField.scn b/examples/Component/SolidMechanics/FEM/Heterogeneous-TetrahedronFEMForceField.scn index 816e0241398..0fe9a314781 100644 --- a/examples/Component/SolidMechanics/FEM/Heterogeneous-TetrahedronFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/Heterogeneous-TetrahedronFEMForceField.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/HexahedralFEMForceField.scn b/examples/Component/SolidMechanics/FEM/HexahedralFEMForceField.scn index 7452f277823..1c34905cb0a 100644 --- a/examples/Component/SolidMechanics/FEM/HexahedralFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/HexahedralFEMForceField.scn @@ -4,7 +4,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/HexahedralFEMForceFieldAndMass.scn b/examples/Component/SolidMechanics/FEM/HexahedralFEMForceFieldAndMass.scn index 0ec0270db84..c7f7d2032f5 100644 --- a/examples/Component/SolidMechanics/FEM/HexahedralFEMForceFieldAndMass.scn +++ b/examples/Component/SolidMechanics/FEM/HexahedralFEMForceFieldAndMass.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMForceFieldAndMass.scn b/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMForceFieldAndMass.scn index 60154bce09b..d9cacbce533 100644 --- a/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMForceFieldAndMass.scn +++ b/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMForceFieldAndMass.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMMapping.scn b/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMMapping.scn index 2f336d01caf..4504389e56c 100644 --- a/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMMapping.scn +++ b/examples/Component/SolidMechanics/FEM/HexahedronCompositeFEMMapping.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/HexahedronFEMForceField.scn b/examples/Component/SolidMechanics/FEM/HexahedronFEMForceField.scn index f42cbc5ec94..5b04f5ba4c1 100644 --- a/examples/Component/SolidMechanics/FEM/HexahedronFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/HexahedronFEMForceField.scn @@ -4,7 +4,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/HexahedronFEMForceFieldAndMass.scn b/examples/Component/SolidMechanics/FEM/HexahedronFEMForceFieldAndMass.scn index db7bd372a48..9593a932fb6 100644 --- a/examples/Component/SolidMechanics/FEM/HexahedronFEMForceFieldAndMass.scn +++ b/examples/Component/SolidMechanics/FEM/HexahedronFEMForceFieldAndMass.scn @@ -4,7 +4,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/QuadBendingFEMForceField.scn b/examples/Component/SolidMechanics/FEM/QuadBendingFEMForceField.scn index bd43c7d7455..cf38273caee 100644 --- a/examples/Component/SolidMechanics/FEM/QuadBendingFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/QuadBendingFEMForceField.scn @@ -3,7 +3,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/StandardTetrahedralFEMForceField.scn b/examples/Component/SolidMechanics/FEM/StandardTetrahedralFEMForceField.scn index b986347c1f8..62ccba55d4c 100644 --- a/examples/Component/SolidMechanics/FEM/StandardTetrahedralFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/StandardTetrahedralFEMForceField.scn @@ -1,6 +1,6 @@  - + @@ -27,7 +27,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -121,7 +121,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TetrahedralCorotationalFEMForceField.scn b/examples/Component/SolidMechanics/FEM/TetrahedralCorotationalFEMForceField.scn index c6ce0dfa93c..c3df8204e17 100644 --- a/examples/Component/SolidMechanics/FEM/TetrahedralCorotationalFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/TetrahedralCorotationalFEMForceField.scn @@ -3,7 +3,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -78,7 +78,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField.scn b/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField.scn index a408d693b72..d0256eddc4b 100644 --- a/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField.scn @@ -1,6 +1,6 @@ - + @@ -32,7 +32,7 @@ method="small" computeVonMisesStress="2" showVonMisesStressPerElement="true"/> - + @@ -53,7 +53,7 @@ method="large" computeVonMisesStress="1" showVonMisesStressPerElement="true"/> - + @@ -73,7 +73,7 @@ method="polar" computeVonMisesStress="1" showVonMisesStressPerElement="true"/> - + @@ -93,7 +93,7 @@ method="svd" computeVonMisesStress="1" showVonMisesStressPerElement="true"/> - + diff --git a/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField_assemble.scn b/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField_assemble.scn index dc6c9526fe9..d3ca3afc6ef 100644 --- a/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField_assemble.scn +++ b/examples/Component/SolidMechanics/FEM/TetrahedronFEMForceField_assemble.scn @@ -1,6 +1,6 @@ - + @@ -32,7 +32,7 @@ method="small" computeVonMisesStress="2" showVonMisesStressPerElement="true"/> - + @@ -53,7 +53,7 @@ method="large" computeVonMisesStress="1" showVonMisesStressPerElement="true"/> - + diff --git a/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn b/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn index 153604ed412..33f6f9ec77f 100644 --- a/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn @@ -3,7 +3,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -81,7 +81,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn b/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn index 5885d3e06be..667747cdd90 100644 --- a/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn +++ b/examples/Component/SolidMechanics/FEM/TopoMap_cylinder3d.scn @@ -4,7 +4,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TriangleFEMForceField.scn b/examples/Component/SolidMechanics/FEM/TriangleFEMForceField.scn index 42e22aa28ac..de077cccc6f 100644 --- a/examples/Component/SolidMechanics/FEM/TriangleFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/TriangleFEMForceField.scn @@ -5,7 +5,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -57,7 +57,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TriangularFEMForceField.scn b/examples/Component/SolidMechanics/FEM/TriangularFEMForceField.scn index 93562748dea..b3af073835d 100644 --- a/examples/Component/SolidMechanics/FEM/TriangularFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/TriangularFEMForceField.scn @@ -2,7 +2,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TriangularFEMForceFieldOptim.scn b/examples/Component/SolidMechanics/FEM/TriangularFEMForceFieldOptim.scn index 11109678816..335f377b2cc 100644 --- a/examples/Component/SolidMechanics/FEM/TriangularFEMForceFieldOptim.scn +++ b/examples/Component/SolidMechanics/FEM/TriangularFEMForceFieldOptim.scn @@ -1,6 +1,6 @@ - + @@ -26,7 +26,7 @@ - + @@ -42,7 +42,7 @@ - + diff --git a/examples/Component/SolidMechanics/FEM/TriangularForceFieldComparison.scn b/examples/Component/SolidMechanics/FEM/TriangularForceFieldComparison.scn index 742e0ede096..6c1db8b3e1b 100644 --- a/examples/Component/SolidMechanics/FEM/TriangularForceFieldComparison.scn +++ b/examples/Component/SolidMechanics/FEM/TriangularForceFieldComparison.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -122,7 +122,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/FastTriangularBendingSprings.scn b/examples/Component/SolidMechanics/Spring/FastTriangularBendingSprings.scn index 2c641ed6442..d3248971fa9 100644 --- a/examples/Component/SolidMechanics/Spring/FastTriangularBendingSprings.scn +++ b/examples/Component/SolidMechanics/Spring/FastTriangularBendingSprings.scn @@ -1,6 +1,6 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/GearSpringForceField.scn b/examples/Component/SolidMechanics/Spring/GearSpringForceField.scn index d4e8365c1c4..8638f562f7a 100644 --- a/examples/Component/SolidMechanics/Spring/GearSpringForceField.scn +++ b/examples/Component/SolidMechanics/Spring/GearSpringForceField.scn @@ -1,6 +1,6 @@ - + @@ -19,7 +19,7 @@ - + - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/PolynomialSpringsForceField.scn b/examples/Component/SolidMechanics/Spring/PolynomialSpringsForceField.scn index 3fb4b48612c..4c371472940 100644 --- a/examples/Component/SolidMechanics/Spring/PolynomialSpringsForceField.scn +++ b/examples/Component/SolidMechanics/Spring/PolynomialSpringsForceField.scn @@ -1,6 +1,6 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/QuadBendingSprings.scn b/examples/Component/SolidMechanics/Spring/QuadBendingSprings.scn index f31183aff9c..a558ca9c461 100644 --- a/examples/Component/SolidMechanics/Spring/QuadBendingSprings.scn +++ b/examples/Component/SolidMechanics/Spring/QuadBendingSprings.scn @@ -4,7 +4,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/QuadularBendingSprings.scn b/examples/Component/SolidMechanics/Spring/QuadularBendingSprings.scn index e13e58e6e3d..cbd07d9dd5c 100644 --- a/examples/Component/SolidMechanics/Spring/QuadularBendingSprings.scn +++ b/examples/Component/SolidMechanics/Spring/QuadularBendingSprings.scn @@ -1,6 +1,6 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/StiffSpringForceField.scn b/examples/Component/SolidMechanics/Spring/StiffSpringForceField.scn index 32915c1e0f3..3c258b02abe 100644 --- a/examples/Component/SolidMechanics/Spring/StiffSpringForceField.scn +++ b/examples/Component/SolidMechanics/Spring/StiffSpringForceField.scn @@ -1,6 +1,6 @@ - + @@ -18,7 +18,7 @@ - + - + @@ -19,7 +19,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/TriangleBendingSprings.scn b/examples/Component/SolidMechanics/Spring/TriangleBendingSprings.scn index fbdf1ef7e0a..388c392d540 100644 --- a/examples/Component/SolidMechanics/Spring/TriangleBendingSprings.scn +++ b/examples/Component/SolidMechanics/Spring/TriangleBendingSprings.scn @@ -4,7 +4,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -59,7 +59,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/TriangularBendingSprings.scn b/examples/Component/SolidMechanics/Spring/TriangularBendingSprings.scn index 1b7c86c3000..8a54f619b88 100644 --- a/examples/Component/SolidMechanics/Spring/TriangularBendingSprings.scn +++ b/examples/Component/SolidMechanics/Spring/TriangularBendingSprings.scn @@ -1,7 +1,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/TriangularBiquadraticSpringsForceField.scn b/examples/Component/SolidMechanics/Spring/TriangularBiquadraticSpringsForceField.scn index a18fbb939a4..6e302f05d1e 100644 --- a/examples/Component/SolidMechanics/Spring/TriangularBiquadraticSpringsForceField.scn +++ b/examples/Component/SolidMechanics/Spring/TriangularBiquadraticSpringsForceField.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/SolidMechanics/Spring/TriangularQuadraticSpringsForceField.scn b/examples/Component/SolidMechanics/Spring/TriangularQuadraticSpringsForceField.scn index fad0a123be8..5eab98c9c75 100644 --- a/examples/Component/SolidMechanics/Spring/TriangularQuadraticSpringsForceField.scn +++ b/examples/Component/SolidMechanics/Spring/TriangularQuadraticSpringsForceField.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/SolidMechanics/TensorMass/TriangularTensorMassForceField.scn b/examples/Component/SolidMechanics/TensorMass/TriangularTensorMassForceField.scn index e36ea927bee..0c343ed0451 100644 --- a/examples/Component/SolidMechanics/TensorMass/TriangularTensorMassForceField.scn +++ b/examples/Component/SolidMechanics/TensorMass/TriangularTensorMassForceField.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Topology/Container/Constant/CubeTopology.scn b/examples/Component/Topology/Container/Constant/CubeTopology.scn index b609a805318..7bbc5019a00 100644 --- a/examples/Component/Topology/Container/Constant/CubeTopology.scn +++ b/examples/Component/Topology/Container/Constant/CubeTopology.scn @@ -2,7 +2,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Component/Topology/Container/Constant/MeshTopology.scn b/examples/Component/Topology/Container/Constant/MeshTopology.scn index 2fb0c26b4cb..bf9714109e2 100644 --- a/examples/Component/Topology/Container/Constant/MeshTopology.scn +++ b/examples/Component/Topology/Container/Constant/MeshTopology.scn @@ -3,7 +3,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/AddingHexa2QuadProcess.scn b/examples/Component/Topology/Container/Dynamic/AddingHexa2QuadProcess.scn index 7dfdc4189fd..12911430754 100644 --- a/examples/Component/Topology/Container/Dynamic/AddingHexa2QuadProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/AddingHexa2QuadProcess.scn @@ -32,7 +32,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/AddingQuad2TriangleProcess.scn b/examples/Component/Topology/Container/Dynamic/AddingQuad2TriangleProcess.scn index 978ed3cd0a5..f581f4b1cc4 100644 --- a/examples/Component/Topology/Container/Dynamic/AddingQuad2TriangleProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/AddingQuad2TriangleProcess.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/AddingTetra2TriangleProcess.scn b/examples/Component/Topology/Container/Dynamic/AddingTetra2TriangleProcess.scn index 9f72d246ceb..e2e194409a7 100644 --- a/examples/Component/Topology/Container/Dynamic/AddingTetra2TriangleProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/AddingTetra2TriangleProcess.scn @@ -5,7 +5,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/AddingTetraProcess.scn b/examples/Component/Topology/Container/Dynamic/AddingTetraProcess.scn index 49c575e37c0..9f03e52700f 100644 --- a/examples/Component/Topology/Container/Dynamic/AddingTetraProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/AddingTetraProcess.scn @@ -1,7 +1,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/AddingTriangle2EdgeProcess.scn b/examples/Component/Topology/Container/Dynamic/AddingTriangle2EdgeProcess.scn index 8d8f6ca94f9..9db682d2432 100644 --- a/examples/Component/Topology/Container/Dynamic/AddingTriangle2EdgeProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/AddingTriangle2EdgeProcess.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/AddingTrianglesProcess.scn b/examples/Component/Topology/Container/Dynamic/AddingTrianglesProcess.scn index 0d9105af026..b66e3a2506d 100644 --- a/examples/Component/Topology/Container/Dynamic/AddingTrianglesProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/AddingTrianglesProcess.scn @@ -2,7 +2,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/IncisionTrianglesProcess.scn b/examples/Component/Topology/Container/Dynamic/IncisionTrianglesProcess.scn index 2a5ca7c8d5b..56ab31ecb70 100644 --- a/examples/Component/Topology/Container/Dynamic/IncisionTrianglesProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/IncisionTrianglesProcess.scn @@ -1,7 +1,7 @@ - + @@ -30,9 +30,9 @@ - + - + diff --git a/examples/Component/Topology/Container/Dynamic/QuadForceFieldTopologyChangeHandling.scn b/examples/Component/Topology/Container/Dynamic/QuadForceFieldTopologyChangeHandling.scn index d78dd21bf32..da98e773a16 100644 --- a/examples/Component/Topology/Container/Dynamic/QuadForceFieldTopologyChangeHandling.scn +++ b/examples/Component/Topology/Container/Dynamic/QuadForceFieldTopologyChangeHandling.scn @@ -4,7 +4,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -60,7 +60,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn b/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn index 59138197d5b..f5add59b1cb 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingBilateralInteractionConstraint.scn @@ -5,7 +5,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingHexa2QuadProcess.scn b/examples/Component/Topology/Container/Dynamic/RemovingHexa2QuadProcess.scn index 8082325f57f..7e6a9ce7a36 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingHexa2QuadProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingHexa2QuadProcess.scn @@ -4,7 +4,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingHexa2TetraProcess.scn b/examples/Component/Topology/Container/Dynamic/RemovingHexa2TetraProcess.scn index 2aeabffa5ff..47e266cdb05 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingHexa2TetraProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingHexa2TetraProcess.scn @@ -4,7 +4,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingPointSprings.scn b/examples/Component/Topology/Container/Dynamic/RemovingPointSprings.scn index e8ca93ba73f..bd8f5173e25 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingPointSprings.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingPointSprings.scn @@ -1,6 +1,6 @@ - + @@ -23,7 +23,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingQuad2TriangleProcess.scn b/examples/Component/Topology/Container/Dynamic/RemovingQuad2TriangleProcess.scn index 5f768411e3d..0da9403d217 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingQuad2TriangleProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingQuad2TriangleProcess.scn @@ -4,7 +4,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess.scn index b14df973ec3..e24313c4e8d 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess.scn @@ -4,7 +4,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -70,7 +70,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn index 827911681f4..439d24d59d7 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetra2TriangleProcess_performanceTest.scn @@ -4,7 +4,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options1.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options1.scn index a2501516c7c..5f89f112722 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options1.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options1.scn @@ -4,7 +4,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options2.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options2.scn index bb16ddce2da..1354d9e00b3 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options2.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetra2Triangle_options2.scn @@ -4,7 +4,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess.scn index f2808233196..c54a981b324 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess.scn @@ -1,7 +1,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess_withCollisionModel.scn b/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess_withCollisionModel.scn index 568776286e5..dbe1160b8b9 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess_withCollisionModel.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTetraProcess_withCollisionModel.scn @@ -5,7 +5,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/RemovingTrianglesProcess.scn b/examples/Component/Topology/Container/Dynamic/RemovingTrianglesProcess.scn index 02d9577caba..47177d68a17 100644 --- a/examples/Component/Topology/Container/Dynamic/RemovingTrianglesProcess.scn +++ b/examples/Component/Topology/Container/Dynamic/RemovingTrianglesProcess.scn @@ -2,7 +2,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn b/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn index f39abb2049c..25e635fc489 100644 --- a/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn +++ b/examples/Component/Topology/Container/Dynamic/TetrahedronForceFieldTopologyChangeHandling.scn @@ -3,7 +3,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -49,7 +49,7 @@ - + diff --git a/examples/Component/Topology/Container/Dynamic/TriangularForceFieldTopologyChangeHandling.scn b/examples/Component/Topology/Container/Dynamic/TriangularForceFieldTopologyChangeHandling.scn index 7d2df8a5707..9967f3e8619 100644 --- a/examples/Component/Topology/Container/Dynamic/TriangularForceFieldTopologyChangeHandling.scn +++ b/examples/Component/Topology/Container/Dynamic/TriangularForceFieldTopologyChangeHandling.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -130,7 +130,7 @@ - + diff --git a/examples/Component/Topology/Container/Grid/CylinderGridTopology.scn b/examples/Component/Topology/Container/Grid/CylinderGridTopology.scn index 3a2c8fba836..c335012a561 100644 --- a/examples/Component/Topology/Container/Grid/CylinderGridTopology.scn +++ b/examples/Component/Topology/Container/Grid/CylinderGridTopology.scn @@ -1,5 +1,5 @@ - + diff --git a/examples/Component/Topology/Container/Grid/RegularGridTopology.scn b/examples/Component/Topology/Container/Grid/RegularGridTopology.scn index 98477edc65e..7e0a03a59ef 100644 --- a/examples/Component/Topology/Container/Grid/RegularGridTopology.scn +++ b/examples/Component/Topology/Container/Grid/RegularGridTopology.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/Topology/Container/Grid/RegularGridTopology_TrianglesMesh.scn b/examples/Component/Topology/Container/Grid/RegularGridTopology_TrianglesMesh.scn index 73c2db19208..ba5fa7211f6 100644 --- a/examples/Component/Topology/Container/Grid/RegularGridTopology_TrianglesMesh.scn +++ b/examples/Component/Topology/Container/Grid/RegularGridTopology_TrianglesMesh.scn @@ -4,7 +4,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/examples/Component/Topology/Container/Grid/RegularGridTopology_dimension.scn b/examples/Component/Topology/Container/Grid/RegularGridTopology_dimension.scn index 4b6013ae741..971036289a1 100644 --- a/examples/Component/Topology/Container/Grid/RegularGridTopology_dimension.scn +++ b/examples/Component/Topology/Container/Grid/RegularGridTopology_dimension.scn @@ -5,7 +5,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -80,7 +80,7 @@ - + diff --git a/examples/Component/Topology/Container/Grid/SparseGridRamificationTopology.scn b/examples/Component/Topology/Container/Grid/SparseGridRamificationTopology.scn index 775017e130f..89913d936e9 100644 --- a/examples/Component/Topology/Container/Grid/SparseGridRamificationTopology.scn +++ b/examples/Component/Topology/Container/Grid/SparseGridRamificationTopology.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/Topology/Container/Grid/SparseGridTopology.scn b/examples/Component/Topology/Container/Grid/SparseGridTopology.scn index a0b48814d93..665e19b7f72 100644 --- a/examples/Component/Topology/Container/Grid/SparseGridTopology.scn +++ b/examples/Component/Topology/Container/Grid/SparseGridTopology.scn @@ -5,7 +5,7 @@ - + diff --git a/examples/Component/Topology/Container/Grid/SphereGridTopology.scn b/examples/Component/Topology/Container/Grid/SphereGridTopology.scn index e945880d4b0..81d16006618 100644 --- a/examples/Component/Topology/Container/Grid/SphereGridTopology.scn +++ b/examples/Component/Topology/Container/Grid/SphereGridTopology.scn @@ -1,6 +1,6 @@ - + diff --git a/examples/Component/Topology/Mapping/Edge2QuadTopologicalMapping.scn b/examples/Component/Topology/Mapping/Edge2QuadTopologicalMapping.scn index 4e6356f8d3c..0c855327e74 100644 --- a/examples/Component/Topology/Mapping/Edge2QuadTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Edge2QuadTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Hexa2QuadTopologicalMapping.scn b/examples/Component/Topology/Mapping/Hexa2QuadTopologicalMapping.scn index 115562bf8aa..cb9a02fc91f 100644 --- a/examples/Component/Topology/Mapping/Hexa2QuadTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Hexa2QuadTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping.scn b/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping.scn index 376d4c23326..cb3e306da96 100644 --- a/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping_export.scn b/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping_export.scn index 563a1e0b03e..d3ccf4b4902 100644 --- a/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping_export.scn +++ b/examples/Component/Topology/Mapping/Hexa2TetraTopologicalMapping_export.scn @@ -3,7 +3,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Mesh2PointTopologicalMapping.scn b/examples/Component/Topology/Mapping/Mesh2PointTopologicalMapping.scn index a6441cb623a..e2785cc0585 100644 --- a/examples/Component/Topology/Mapping/Mesh2PointTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Mesh2PointTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Quad2TriangleTopologicalMapping.scn b/examples/Component/Topology/Mapping/Quad2TriangleTopologicalMapping.scn index 69841881ae3..acb1a15e14b 100644 --- a/examples/Component/Topology/Mapping/Quad2TriangleTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Quad2TriangleTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Topology/Mapping/SubsetTopologicalMapping.scn b/examples/Component/Topology/Mapping/SubsetTopologicalMapping.scn index b1cbb23bb12..71d80fd5ae9 100644 --- a/examples/Component/Topology/Mapping/SubsetTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/SubsetTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Topology/Mapping/SubsetTopologicalMapping2.scn b/examples/Component/Topology/Mapping/SubsetTopologicalMapping2.scn index 3fe5c8e41af..9a1dc9a39d4 100644 --- a/examples/Component/Topology/Mapping/SubsetTopologicalMapping2.scn +++ b/examples/Component/Topology/Mapping/SubsetTopologicalMapping2.scn @@ -4,7 +4,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn index 6b56e0beacb..bc4dab7563a 100644 --- a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn index ed957f9a363..3b75eb4a480 100644 --- a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn +++ b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_NoInitialTriangle_option.scn @@ -4,7 +4,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn index 91f8769f1c6..81b17db73c3 100644 --- a/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn +++ b/examples/Component/Topology/Mapping/Tetra2TriangleTopologicalMapping_with_TetrahedronModel.scn @@ -3,7 +3,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Component/Topology/Mapping/TopoMap_Hexa2Quad2Triangle.scn b/examples/Component/Topology/Mapping/TopoMap_Hexa2Quad2Triangle.scn index 84386d456b8..377d96cb032 100644 --- a/examples/Component/Topology/Mapping/TopoMap_Hexa2Quad2Triangle.scn +++ b/examples/Component/Topology/Mapping/TopoMap_Hexa2Quad2Triangle.scn @@ -3,7 +3,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Topology/Mapping/Triangle2EdgeTopologicalMapping.scn b/examples/Component/Topology/Mapping/Triangle2EdgeTopologicalMapping.scn index 8d6c7fe6234..0b9ac8859f7 100644 --- a/examples/Component/Topology/Mapping/Triangle2EdgeTopologicalMapping.scn +++ b/examples/Component/Topology/Mapping/Triangle2EdgeTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Component/Visual/DataDisplay.scn b/examples/Component/Visual/DataDisplay.scn index 186da9b83d9..056cb1104ac 100644 --- a/examples/Component/Visual/DataDisplay.scn +++ b/examples/Component/Visual/DataDisplay.scn @@ -4,7 +4,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/examples/Component/Visual/OglShader.scn b/examples/Component/Visual/OglShader.scn index 33a71916ab8..286a3e01e7f 100644 --- a/examples/Component/Visual/OglShader.scn +++ b/examples/Component/Visual/OglShader.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Component/Visual/OglShader_tessellation.scn b/examples/Component/Visual/OglShader_tessellation.scn index 8ba7a2f79c5..8cca789e0ad 100644 --- a/examples/Component/Visual/OglShader_tessellation.scn +++ b/examples/Component/Visual/OglShader_tessellation.scn @@ -4,7 +4,7 @@ - + diff --git a/examples/Component/Visual/OglViewport.scn b/examples/Component/Visual/OglViewport.scn index f0ee97506a7..861b877b84f 100644 --- a/examples/Component/Visual/OglViewport.scn +++ b/examples/Component/Visual/OglViewport.scn @@ -3,7 +3,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Component/Visual/PostProcessManager_DepthOfField.scn b/examples/Component/Visual/PostProcessManager_DepthOfField.scn index c64fa42544c..f7c484be59b 100644 --- a/examples/Component/Visual/PostProcessManager_DepthOfField.scn +++ b/examples/Component/Visual/PostProcessManager_DepthOfField.scn @@ -3,7 +3,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Component/Visual/VisualStyle.scn b/examples/Component/Visual/VisualStyle.scn index 7b728fc39a2..cdabc70aa44 100644 --- a/examples/Component/Visual/VisualStyle.scn +++ b/examples/Component/Visual/VisualStyle.scn @@ -1,7 +1,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/examples/Tutorials/Basic/TutorialBasicPendulum.scn b/examples/Tutorials/Basic/TutorialBasicPendulum.scn index f7427773fe8..4b798c38a5a 100644 --- a/examples/Tutorials/Basic/TutorialBasicPendulum.scn +++ b/examples/Tutorials/Basic/TutorialBasicPendulum.scn @@ -2,7 +2,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Tutorials/ForceFields/TutorialForceFieldLiverFEM.scn b/examples/Tutorials/ForceFields/TutorialForceFieldLiverFEM.scn index 42acfdc79f9..442c862eee6 100644 --- a/examples/Tutorials/ForceFields/TutorialForceFieldLiverFEM.scn +++ b/examples/Tutorials/ForceFields/TutorialForceFieldLiverFEM.scn @@ -5,7 +5,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Tutorials/ForceFields/TutorialForceFieldLiverHexaFEM.scn b/examples/Tutorials/ForceFields/TutorialForceFieldLiverHexaFEM.scn index 26348f81c47..f6664899646 100644 --- a/examples/Tutorials/ForceFields/TutorialForceFieldLiverHexaFEM.scn +++ b/examples/Tutorials/ForceFields/TutorialForceFieldLiverHexaFEM.scn @@ -5,7 +5,7 @@ - + @@ -31,7 +31,7 @@ - + diff --git a/examples/Tutorials/ForceFields/TutorialForceFieldLiverSprings.scn b/examples/Tutorials/ForceFields/TutorialForceFieldLiverSprings.scn index 1bf78a60459..3c20e7699fb 100644 --- a/examples/Tutorials/ForceFields/TutorialForceFieldLiverSprings.scn +++ b/examples/Tutorials/ForceFields/TutorialForceFieldLiverSprings.scn @@ -5,7 +5,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Tutorials/ForceFields/TutorialForceFieldLiverTriangleFEM.scn b/examples/Tutorials/ForceFields/TutorialForceFieldLiverTriangleFEM.scn index 839282b1a53..819b41a76a3 100644 --- a/examples/Tutorials/ForceFields/TutorialForceFieldLiverTriangleFEM.scn +++ b/examples/Tutorials/ForceFields/TutorialForceFieldLiverTriangleFEM.scn @@ -4,7 +4,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Tutorials/Mappings/TutorialMappingLiverBarycentric.scn b/examples/Tutorials/Mappings/TutorialMappingLiverBarycentric.scn index ab44da46044..d97b935f351 100644 --- a/examples/Tutorials/Mappings/TutorialMappingLiverBarycentric.scn +++ b/examples/Tutorials/Mappings/TutorialMappingLiverBarycentric.scn @@ -3,7 +3,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo1.scn b/examples/Tutorials/OldTutorials/demo1.scn index 83d3e361325..a25d89ff944 100644 --- a/examples/Tutorials/OldTutorials/demo1.scn +++ b/examples/Tutorials/OldTutorials/demo1.scn @@ -9,7 +9,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo2.scn b/examples/Tutorials/OldTutorials/demo2.scn index ca64909df40..d43f195bc7f 100644 --- a/examples/Tutorials/OldTutorials/demo2.scn +++ b/examples/Tutorials/OldTutorials/demo2.scn @@ -9,7 +9,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo3.scn b/examples/Tutorials/OldTutorials/demo3.scn index ef71cf6a933..78ebe2667a1 100644 --- a/examples/Tutorials/OldTutorials/demo3.scn +++ b/examples/Tutorials/OldTutorials/demo3.scn @@ -1,6 +1,6 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo4.scn b/examples/Tutorials/OldTutorials/demo4.scn index 651dca14589..f877377b70b 100644 --- a/examples/Tutorials/OldTutorials/demo4.scn +++ b/examples/Tutorials/OldTutorials/demo4.scn @@ -1,7 +1,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo5.scn b/examples/Tutorials/OldTutorials/demo5.scn index 3643ac61acf..5507e97dc42 100644 --- a/examples/Tutorials/OldTutorials/demo5.scn +++ b/examples/Tutorials/OldTutorials/demo5.scn @@ -1,7 +1,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo6.scn b/examples/Tutorials/OldTutorials/demo6.scn index 6a8c288693d..ed6e6094f90 100644 --- a/examples/Tutorials/OldTutorials/demo6.scn +++ b/examples/Tutorials/OldTutorials/demo6.scn @@ -3,7 +3,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo6Triangle.scn b/examples/Tutorials/OldTutorials/demo6Triangle.scn index 6680ccbe030..38bc1aad011 100644 --- a/examples/Tutorials/OldTutorials/demo6Triangle.scn +++ b/examples/Tutorials/OldTutorials/demo6Triangle.scn @@ -3,7 +3,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo7.scn b/examples/Tutorials/OldTutorials/demo7.scn index c5ef158c0f4..9acd9e08f3f 100644 --- a/examples/Tutorials/OldTutorials/demo7.scn +++ b/examples/Tutorials/OldTutorials/demo7.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Tutorials/OldTutorials/demo7Triangle.scn b/examples/Tutorials/OldTutorials/demo7Triangle.scn index 5029a221df6..ea0e55ddb40 100644 --- a/examples/Tutorials/OldTutorials/demo7Triangle.scn +++ b/examples/Tutorials/OldTutorials/demo7Triangle.scn @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/examples/Tutorials/StepByStep/Pendulum/2_Pendulum.scn b/examples/Tutorials/StepByStep/Pendulum/2_Pendulum.scn index 5321450246d..2c0ca124178 100644 --- a/examples/Tutorials/StepByStep/Pendulum/2_Pendulum.scn +++ b/examples/Tutorials/StepByStep/Pendulum/2_Pendulum.scn @@ -1,7 +1,7 @@ - + @@ -17,6 +17,6 @@ - + diff --git a/examples/Tutorials/StepByStep/Pendulum/3_Pendulum.scn b/examples/Tutorials/StepByStep/Pendulum/3_Pendulum.scn index 190879b5fbe..2b32034e94a 100644 --- a/examples/Tutorials/StepByStep/Pendulum/3_Pendulum.scn +++ b/examples/Tutorials/StepByStep/Pendulum/3_Pendulum.scn @@ -1,7 +1,7 @@ - + @@ -17,6 +17,6 @@ - + diff --git a/examples/Tutorials/StepByStep/Pendulum/4_Pendulum.scn b/examples/Tutorials/StepByStep/Pendulum/4_Pendulum.scn index 84def987c71..157cd1905a7 100644 --- a/examples/Tutorials/StepByStep/Pendulum/4_Pendulum.scn +++ b/examples/Tutorials/StepByStep/Pendulum/4_Pendulum.scn @@ -1,7 +1,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/examples/Tutorials/StepByStep/Pendulum/5_Pendulum.scn b/examples/Tutorials/StepByStep/Pendulum/5_Pendulum.scn index ab7cfce6485..52daf599a7c 100644 --- a/examples/Tutorials/StepByStep/Pendulum/5_Pendulum.scn +++ b/examples/Tutorials/StepByStep/Pendulum/5_Pendulum.scn @@ -1,7 +1,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/examples/Tutorials/StepByStep/Pendulum/6_Pendulum.scn b/examples/Tutorials/StepByStep/Pendulum/6_Pendulum.scn index 131dc8e3a0d..8eb715a9ed1 100644 --- a/examples/Tutorials/StepByStep/Pendulum/6_Pendulum.scn +++ b/examples/Tutorials/StepByStep/Pendulum/6_Pendulum.scn @@ -1,7 +1,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/examples/Tutorials/StepByStep/Pendulum/7_Pendulum.scn b/examples/Tutorials/StepByStep/Pendulum/7_Pendulum.scn index 716589198f6..279fb7443af 100644 --- a/examples/Tutorials/StepByStep/Pendulum/7_Pendulum.scn +++ b/examples/Tutorials/StepByStep/Pendulum/7_Pendulum.scn @@ -1,7 +1,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn index 8b2b9ec44de..aeb42eee4e1 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/2_TopoMapping.scn @@ -2,7 +2,7 @@ - + @@ -30,6 +30,6 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn index c09c77d9c8e..8934fadbd89 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/3_TopoMapping.scn @@ -2,7 +2,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn index 33ba1964c7e..f22e47f1f07 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/4_TopoMapping.scn @@ -3,7 +3,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/5_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/5_TopoMapping.scn index cd88d172300..2e3af39877c 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/5_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/5_TopoMapping.scn @@ -2,7 +2,7 @@ - + @@ -27,6 +27,6 @@ - + diff --git a/examples/Tutorials/StepByStep/TopologicalMapping/6_TopoMapping.scn b/examples/Tutorials/StepByStep/TopologicalMapping/6_TopoMapping.scn index 5d1e2c99581..71f1ee35826 100644 --- a/examples/Tutorials/StepByStep/TopologicalMapping/6_TopoMapping.scn +++ b/examples/Tutorials/StepByStep/TopologicalMapping/6_TopoMapping.scn @@ -3,7 +3,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyDynamicSurfaceMesh.scn b/examples/Tutorials/Topologies/TopologyDynamicSurfaceMesh.scn index b36132ea1d8..613ee62a277 100644 --- a/examples/Tutorials/Topologies/TopologyDynamicSurfaceMesh.scn +++ b/examples/Tutorials/Topologies/TopologyDynamicSurfaceMesh.scn @@ -5,7 +5,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -48,7 +48,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyHexa2QuadTopologicalMapping.scn b/examples/Tutorials/Topologies/TopologyHexa2QuadTopologicalMapping.scn index a373dbd4c10..24397ec455e 100644 --- a/examples/Tutorials/Topologies/TopologyHexa2QuadTopologicalMapping.scn +++ b/examples/Tutorials/Topologies/TopologyHexa2QuadTopologicalMapping.scn @@ -5,7 +5,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyHexa2TetraTopologicalMapping.scn b/examples/Tutorials/Topologies/TopologyHexa2TetraTopologicalMapping.scn index 147a8101d85..0988993861d 100644 --- a/examples/Tutorials/Topologies/TopologyHexa2TetraTopologicalMapping.scn +++ b/examples/Tutorials/Topologies/TopologyHexa2TetraTopologicalMapping.scn @@ -5,7 +5,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyLinearDifferentMesh.scn b/examples/Tutorials/Topologies/TopologyLinearDifferentMesh.scn index e69b5ab4ab0..2cba18085b8 100644 --- a/examples/Tutorials/Topologies/TopologyLinearDifferentMesh.scn +++ b/examples/Tutorials/Topologies/TopologyLinearDifferentMesh.scn @@ -5,7 +5,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -47,7 +47,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyLinearMesh.scn b/examples/Tutorials/Topologies/TopologyLinearMesh.scn index b74b106e104..8d0ab41eff5 100644 --- a/examples/Tutorials/Topologies/TopologyLinearMesh.scn +++ b/examples/Tutorials/Topologies/TopologyLinearMesh.scn @@ -5,7 +5,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyQuad2TriangleTopologicalMapping.scn b/examples/Tutorials/Topologies/TopologyQuad2TriangleTopologicalMapping.scn index df5bbe0f42e..405995b6f4e 100644 --- a/examples/Tutorials/Topologies/TopologyQuad2TriangleTopologicalMapping.scn +++ b/examples/Tutorials/Topologies/TopologyQuad2TriangleTopologicalMapping.scn @@ -5,7 +5,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologySurfaceDifferentMesh.scn b/examples/Tutorials/Topologies/TopologySurfaceDifferentMesh.scn index dfaa0ac1ecd..f106babd7c7 100644 --- a/examples/Tutorials/Topologies/TopologySurfaceDifferentMesh.scn +++ b/examples/Tutorials/Topologies/TopologySurfaceDifferentMesh.scn @@ -5,7 +5,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn b/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn index f3f5a631066..cd31606b43e 100644 --- a/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn +++ b/examples/Tutorials/Topologies/TopologyTetra2TriangleTopologicalMapping.scn @@ -5,7 +5,7 @@ - + @@ -38,7 +38,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyTriangle2EdgeTopologicalMapping.scn b/examples/Tutorials/Topologies/TopologyTriangle2EdgeTopologicalMapping.scn index 38bd3ad2a1f..864bbb4448b 100644 --- a/examples/Tutorials/Topologies/TopologyTriangle2EdgeTopologicalMapping.scn +++ b/examples/Tutorials/Topologies/TopologyTriangle2EdgeTopologicalMapping.scn @@ -4,7 +4,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/examples/Tutorials/Topologies/TopologyVolumeDifferentMesh.scn b/examples/Tutorials/Topologies/TopologyVolumeDifferentMesh.scn index ac65ea551bc..51c3c060145 100644 --- a/examples/Tutorials/Topologies/TopologyVolumeDifferentMesh.scn +++ b/examples/Tutorials/Topologies/TopologyVolumeDifferentMesh.scn @@ -5,7 +5,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -63,7 +63,7 @@ - + diff --git a/examples/Tutorials/sandbox/explicit_singlehexaFEM.scn b/examples/Tutorials/sandbox/explicit_singlehexaFEM.scn index 60262a2943f..106be54f5d5 100644 --- a/examples/Tutorials/sandbox/explicit_singlehexaFEM.scn +++ b/examples/Tutorials/sandbox/explicit_singlehexaFEM.scn @@ -1,6 +1,6 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/examples/Tutorials/sandbox/implicit_singlehexaFEM.scn b/examples/Tutorials/sandbox/implicit_singlehexaFEM.scn index 188ff6cd041..445f4f01c82 100644 --- a/examples/Tutorials/sandbox/implicit_singlehexaFEM.scn +++ b/examples/Tutorials/sandbox/implicit_singlehexaFEM.scn @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Tutorials/sandbox/implicit_singlehexaFEM_2.scn b/examples/Tutorials/sandbox/implicit_singlehexaFEM_2.scn index 66eb8938126..3eade952857 100644 --- a/examples/Tutorials/sandbox/implicit_singlehexaFEM_2.scn +++ b/examples/Tutorials/sandbox/implicit_singlehexaFEM_2.scn @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/Tutorials/sandbox/rungekutta_singlehexaFEM.scn b/examples/Tutorials/sandbox/rungekutta_singlehexaFEM.scn index 2cb127cc6ab..42be6a45efa 100644 --- a/examples/Tutorials/sandbox/rungekutta_singlehexaFEM.scn +++ b/examples/Tutorials/sandbox/rungekutta_singlehexaFEM.scn @@ -1,6 +1,6 @@ - + @@ -17,7 +17,7 @@ - + From 43b62946b448a3d8b9aa11b68a530d06c0d6d5d4 Mon Sep 17 00:00:00 2001 From: bakpaul Date: Tue, 12 Dec 2023 17:29:15 +0100 Subject: [PATCH 24/28] remove last occurences in py files --- .../tests/scenes_test/BilateralInteractionConstraint.scn | 2 +- .../examples/GlobalBulletCollision.py | 4 ++-- applications/plugins/SofaAssimp/examples/character_clothes.py | 2 +- applications/plugins/SofaCarving/examples/SimpleCarving.py | 2 +- .../Lagrangian/BilateralInteractionConstraint_NNCG.scn | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn b/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn index 7eb496cae65..b447ce22419 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn +++ b/Sofa/Component/Constraint/Lagrangian/Model/tests/scenes_test/BilateralInteractionConstraint.scn @@ -1,4 +1,4 @@ - + diff --git a/applications/plugins/BulletCollisionDetection/examples/GlobalBulletCollision.py b/applications/plugins/BulletCollisionDetection/examples/GlobalBulletCollision.py index 4d4f23c6de4..a2914792e0b 100644 --- a/applications/plugins/BulletCollisionDetection/examples/GlobalBulletCollision.py +++ b/applications/plugins/BulletCollisionDetection/examples/GlobalBulletCollision.py @@ -21,7 +21,7 @@ def createGraph(self,node): # a container floorNode = self.rootNode.createChild('Floor') rigid_meca = floorNode.createObject('MechanicalObject',name='father',template='Rigid',position='0 0 0 0 0 0 1') - floorNode.createObject('FixedConstraint',template='Rigid') + floorNode.createObject('FixedProjectiveConstraint',template='Rigid') #floorNode.createObject('UniformMass',template='Rigid',totalMass=1) mapped = floorNode.createChild('mapped') mapped.createObject('MeshOBJLoader', name='loader', filename='mesh/SaladBowl.obj') @@ -38,7 +38,7 @@ def createGraph(self,node): # meca = node.createObject('MechanicalObject',name='rigidDOF',template='Rigid',position='0 0 0 0 0 0 1') # mass = node.createObject('UniformMass',name='mass',totalMass=1,template='Rigid') - # node.createObject('FixedConstraint',template='Rigid') + # node.createObject('FixedProjectiveConstraint',template='Rigid') # node.createObject('BulletOBBModel',template='Rigid',name='BASE',extents='15 15 0.2',margin="0.5") diff --git a/applications/plugins/SofaAssimp/examples/character_clothes.py b/applications/plugins/SofaAssimp/examples/character_clothes.py index 7a22571e62e..9f6ae51734e 100644 --- a/applications/plugins/SofaAssimp/examples/character_clothes.py +++ b/applications/plugins/SofaAssimp/examples/character_clothes.py @@ -65,7 +65,7 @@ def createBox(parent): parent.createObject('MechanicalObject', template='Rigid', name='model', position='0 100.0 0 0 0 0 1') parent.createObject('UniformMass') - parent.createObject('FixedConstraint', indices='0') + parent.createObject('FixedProjectiveConstraint', indices='0') collisionNode = parent.createChild('collision') collisionNode.createObject('MeshOBJLoader', name='loader', filename=mesh_path + 'cube.obj') diff --git a/applications/plugins/SofaCarving/examples/SimpleCarving.py b/applications/plugins/SofaCarving/examples/SimpleCarving.py index 037de56f25b..9c453577571 100644 --- a/applications/plugins/SofaCarving/examples/SimpleCarving.py +++ b/applications/plugins/SofaCarving/examples/SimpleCarving.py @@ -59,7 +59,7 @@ def createScene(root): TT.addObject('TetrahedronSetGeometryAlgorithms', template="Vec3d", name="GeomAlgo") TT.addObject('DiagonalMass', massDensity=0.5) - TT.addObject('FixedConstraint', indices=[1, 3, 50]) + TT.addObject('FixedProjectiveConstraint', indices=[1, 3, 50]) TT.addObject('TetrahedralCorotationalFEMForceField', name="CFEM", youngModulus=160, poissonRatio=0.3, method="large") # Add corresponding surface topology diff --git a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn index abf4d2ca7be..f45125d24cf 100644 --- a/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn +++ b/examples/Component/Constraint/Lagrangian/BilateralInteractionConstraint_NNCG.scn @@ -1,5 +1,5 @@ - + From e4b68d681c182aad3d0872216953a823a0bccf40 Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 29 Nov 2023 17:16:32 +0100 Subject: [PATCH 25/28] Changed the message display of sceneCheckUsingAlias when aliased component is in component change --- .../src/sofa/helper/ComponentChange.cpp | 211 +++++++++--------- .../Helper/src/sofa/helper/ComponentChange.h | 1 + .../SceneChecking/SceneCheckUsingAlias.cpp | 2 +- 3 files changed, 110 insertions(+), 104 deletions(-) diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index 880cd7ac4d9..07626870d60 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -32,7 +32,7 @@ const std::map > deprecatedComponents = { {"RigidRigidMapping", Deprecated("v23.06", "v23.12", "You can use the component RigidMapping with template='Rigid3,Rigid3' instead.")}, }; -const std::map > uncreatableComponents = { +const std::map > movedComponents = { // SofaValidation was pluginized in #1302 {"CompareState", Pluginized("v20.06", "SofaValidation")}, {"CompareTopology", Pluginized("v20.06", "SofaValidation")}, @@ -66,107 +66,6 @@ const std::map > uncreatableComponents { "LMConstraintSolver", Pluginized("v20.12", "LMConstraint") }, { "LMConstraintDirectSolver", Pluginized("v20.12", "LMConstraint") }, - /***********************/ - // REMOVED SINCE v23.06 - - { "OglGrid", Removed("v22.12", "v23.06")}, - { "OglLineAxis", Removed("v22.12", "v23.06")}, - - /***********************/ - // REMOVED SINCE v22.06 - - {"PointConstraint", Removed("v21.12", "v22.06")}, - - /***********************/ - // REMOVED SINCE v21.12 - - { "LMDNewProximityIntersection", Removed("v21.12", "v21.12") }, - { "LocalMinDistanceFilter", Removed("v21.12", "v21.12") }, - { "LineLocalMinDistanceFilter", Removed("v21.12", "v21.12") }, - { "PointLocalMinDistanceFilter", Removed("v21.12", "v21.12") }, - { "TriangleLocalMinDistanceFilter", Removed("v21.12", "v21.12") }, - - /***********************/ - // REMOVED SINCE v21.06 - - {"LengthContainer", Removed("v21.06", "v21.06")}, - {"PoissonContainer", Removed("v21.06", "v21.06")}, - {"RadiusContainer", Removed("v21.06", "v21.06")}, - {"StiffnessContainer", Removed("v21.06", "v21.06")}, - - /***********************/ - // REMOVED SINCE v20.12 - - { "DynamicSparseGridTopologyAlgorithms", Removed("v20.12", "v20.12") }, - { "HexahedronSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, - { "TetrahedronSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, - { "QuadSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, - { "TriangleSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, - { "EdgeSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, - { "PointSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, - - /***********************/ - // REMOVED SINCE v20.06 - - {"Euler", Removed("v19.12", "v20.06")}, - {"EulerExplicit", Removed("v19.12", "v20.06")}, - {"ExplicitEuler", Removed("v19.12", "v20.06")}, - {"EulerSolver", Removed("v19.12", "v20.06")}, - {"ExplicitEulerSolver", Removed("v19.12", "v20.06")}, - - {"Capsule", Removed("v19.12", "v20.06")}, - {"CapsuleModel", Removed("v19.12", "v20.06")}, - {"TCapsuleModel", Removed("v19.12", "v20.06")}, - - {"Cube", Removed("v19.12", "v20.06")}, - {"CubeModel", Removed("v19.12", "v20.06")}, - - {"CudaPoint", Removed("v19.12", "v20.06")}, - {"CudaPointModel", Removed("v19.12", "v20.06")}, - - {"Cylinder", Removed("v19.12", "v20.06")}, - {"CylinderModel", Removed("v19.12", "v20.06")}, - - {"Line", Removed("v19.12", "v20.06")}, - {"TLineModel", Removed("v19.12", "v20.06")}, - {"LineMeshModel", Removed("v19.12", "v20.06")}, - {"LineSetModel", Removed("v19.12", "v20.06")}, - {"LineMesh", Removed("v19.12", "v20.06")}, - {"LineSet", Removed("v19.12", "v20.06")}, - {"LineModel", Removed("v19.12", "v20.06")}, - - {"OBB", Removed("v19.12", "v20.06")}, - {"OBBModel", Removed("v19.12", "v20.06")}, - {"TOBBModel", Removed("v19.12", "v20.06")}, - - {"Point", Removed("v19.12", "v20.06")}, - {"TPointModel", Removed("v19.12", "v20.06")}, - {"PointModel", Removed("v19.12", "v20.06")}, - {"PointMesh", Removed("v19.12", "v20.06")}, - {"PointSet", Removed("v19.12", "v20.06")}, - - {"Ray", Removed("v19.12", "v20.06")}, - {"RayModel", Removed("v19.12", "v20.06")}, - - {"RigidCapsule", Removed("v19.12", "v20.06")}, - {"RigidCapsuleModel", Removed("v19.12", "v20.06")}, - {"RigidCapsuleCollisionModel", Removed("v19.12", "v20.06")}, - - {"Sphere", Removed("v19.12", "v20.06")}, - {"SphereModel", Removed("v19.12", "v20.06")}, - {"TSphereModel", Removed("v19.12", "v20.06")}, - - {"Tetrahedron", Removed("v19.12", "v20.06")}, - {"TetrahedronModel", Removed("v19.12", "v20.06")}, - - {"Triangle", Removed("v19.12", "v20.06")}, - {"TriangleSet", Removed("v19.12", "v20.06")}, - {"TriangleMesh", Removed("v19.12", "v20.06")}, - {"TriangleSetModel", Removed("v19.12", "v20.06")}, - {"TriangleMeshModel", Removed("v19.12", "v20.06")}, - {"TriangleModel", Removed("v19.12", "v20.06")}, - {"TTriangleModel", Removed("v19.12", "v20.06")}, - /***********************/ // MOVED SINCE v21.06 { "SpatialGridPointModel", Moved("v21.06", "SofaMiscCollision", "SofaSphFluid") }, @@ -721,7 +620,113 @@ const std::map > uncreatableComponents // Moved to CSparseSolvers { "SparseCholeskySolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, - { "SparseLUSolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, + { "SparseLUSolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") } + +}; + +const std::map > uncreatableComponents = { + + /***********************/ + // REMOVED SINCE v23.06 + + { "OglGrid", Removed("v22.12", "v23.06")}, + { "OglLineAxis", Removed("v22.12", "v23.06")}, + + /***********************/ + // REMOVED SINCE v22.06 + + {"PointConstraint", Removed("v21.12", "v22.06")}, + + /***********************/ + // REMOVED SINCE v21.12 + + { "LMDNewProximityIntersection", Removed("v21.12", "v21.12") }, + { "LocalMinDistanceFilter", Removed("v21.12", "v21.12") }, + { "LineLocalMinDistanceFilter", Removed("v21.12", "v21.12") }, + { "PointLocalMinDistanceFilter", Removed("v21.12", "v21.12") }, + { "TriangleLocalMinDistanceFilter", Removed("v21.12", "v21.12") }, + + /***********************/ + // REMOVED SINCE v21.06 + + {"LengthContainer", Removed("v21.06", "v21.06")}, + {"PoissonContainer", Removed("v21.06", "v21.06")}, + {"RadiusContainer", Removed("v21.06", "v21.06")}, + {"StiffnessContainer", Removed("v21.06", "v21.06")}, + + /***********************/ + // REMOVED SINCE v20.12 + + { "DynamicSparseGridTopologyAlgorithms", Removed("v20.12", "v20.12") }, + { "HexahedronSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, + { "TetrahedronSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, + { "QuadSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, + { "TriangleSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, + { "EdgeSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, + { "PointSetTopologyAlgorithms", Removed("v20.12", "v20.12") }, + + /***********************/ + // REMOVED SINCE v20.06 + + {"Euler", Removed("v19.12", "v20.06")}, + {"EulerExplicit", Removed("v19.12", "v20.06")}, + {"ExplicitEuler", Removed("v19.12", "v20.06")}, + {"EulerSolver", Removed("v19.12", "v20.06")}, + {"ExplicitEulerSolver", Removed("v19.12", "v20.06")}, + + {"Capsule", Removed("v19.12", "v20.06")}, + {"CapsuleModel", Removed("v19.12", "v20.06")}, + {"TCapsuleModel", Removed("v19.12", "v20.06")}, + + {"Cube", Removed("v19.12", "v20.06")}, + {"CubeModel", Removed("v19.12", "v20.06")}, + + {"CudaPoint", Removed("v19.12", "v20.06")}, + {"CudaPointModel", Removed("v19.12", "v20.06")}, + + {"Cylinder", Removed("v19.12", "v20.06")}, + {"CylinderModel", Removed("v19.12", "v20.06")}, + + {"Line", Removed("v19.12", "v20.06")}, + {"TLineModel", Removed("v19.12", "v20.06")}, + {"LineMeshModel", Removed("v19.12", "v20.06")}, + {"LineSetModel", Removed("v19.12", "v20.06")}, + {"LineMesh", Removed("v19.12", "v20.06")}, + {"LineSet", Removed("v19.12", "v20.06")}, + {"LineModel", Removed("v19.12", "v20.06")}, + + {"OBB", Removed("v19.12", "v20.06")}, + {"OBBModel", Removed("v19.12", "v20.06")}, + {"TOBBModel", Removed("v19.12", "v20.06")}, + + {"Point", Removed("v19.12", "v20.06")}, + {"TPointModel", Removed("v19.12", "v20.06")}, + {"PointModel", Removed("v19.12", "v20.06")}, + {"PointMesh", Removed("v19.12", "v20.06")}, + {"PointSet", Removed("v19.12", "v20.06")}, + + {"Ray", Removed("v19.12", "v20.06")}, + {"RayModel", Removed("v19.12", "v20.06")}, + + {"RigidCapsule", Removed("v19.12", "v20.06")}, + {"RigidCapsuleModel", Removed("v19.12", "v20.06")}, + {"RigidCapsuleCollisionModel", Removed("v19.12", "v20.06")}, + + {"Sphere", Removed("v19.12", "v20.06")}, + {"SphereModel", Removed("v19.12", "v20.06")}, + {"TSphereModel", Removed("v19.12", "v20.06")}, + + {"Tetrahedron", Removed("v19.12", "v20.06")}, + {"TetrahedronModel", Removed("v19.12", "v20.06")}, + + {"Triangle", Removed("v19.12", "v20.06")}, + {"TriangleSet", Removed("v19.12", "v20.06")}, + {"TriangleMesh", Removed("v19.12", "v20.06")}, + {"TriangleSetModel", Removed("v19.12", "v20.06")}, + {"TriangleMeshModel", Removed("v19.12", "v20.06")}, + {"TriangleModel", Removed("v19.12", "v20.06")}, + {"TTriangleModel", Removed("v19.12", "v20.06")}, + // Change Constraint naming #4302 {"AffineMovementConstraint", Renamed("v24.06","v25.06","AffineMovementProjectiveConstraint")}, diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h index bc92a04a532..40c94c23b19 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h @@ -126,6 +126,7 @@ class SOFA_HELPER_API Renamed : public ComponentChange }; extern SOFA_HELPER_API const std::map< std::string, Deprecated, std::less<> > deprecatedComponents; +extern SOFA_HELPER_API const std::map< std::string, ComponentChange, std::less<> > movedComponents; extern SOFA_HELPER_API const std::map< std::string, ComponentChange, std::less<> > uncreatableComponents; } // namespace sofa::helper::lifecycle diff --git a/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp b/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp index dcdde083ad0..12c3208029d 100644 --- a/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp +++ b/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp @@ -91,7 +91,7 @@ void SceneCheckUsingAlias::doPrintSummary() auto searchAlias = uncreatableComponents.find(unique_alias); if( searchAlias != uncreatableComponents.end() ) { - usingAliasesWarning << " This alias will be REMOVED at the SOFA release " << searchAlias->second.getVersion() << ", please update your scenes."; + usingAliasesWarning << " " << searchAlias->second.getMessage(); } if(unique_alias != unique_aliases.back()) usingAliasesWarning << msgendl; From 181eb9acfef2481b5455d2e590f6ab68d3b7edcf Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Wed, 29 Nov 2023 17:26:12 +0100 Subject: [PATCH 26/28] Fix factory --- Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp b/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp index 412011f4879..172e3c98442 100644 --- a/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp +++ b/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp @@ -206,14 +206,20 @@ objectmodel::BaseObject::SPtr ObjectFactory::createObject(objectmodel::BaseConte using sofa::helper::lifecycle::ComponentChange; using sofa::helper::lifecycle::uncreatableComponents; + using sofa::helper::lifecycle::movedComponents; if(it == registry.end()) { arg->logError("The object '" + classname + "' is not in the factory."); auto uuncreatableComponent = uncreatableComponents.find(classname); + auto movedComponent = movedComponents.find(classname); if( uuncreatableComponent != uncreatableComponents.end() ) { arg->logError( uuncreatableComponent->second.getMessage() ); } + else if (movedComponent != movedComponents.end()) + { + arg->logError( movedComponent->second.getMessage() ); + } else { std::vector possibleNames; From d0dc32eeaa2a761043fbfb2b532390d27f129f73 Mon Sep 17 00:00:00 2001 From: bakpaul Date: Mon, 18 Dec 2023 17:30:16 +0100 Subject: [PATCH 27/28] Add alias creation when object in componentRenamed in factory --- Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp | 10 ++++++++++ .../Helper/src/sofa/helper/ComponentChange.cpp | 3 +++ .../framework/Helper/src/sofa/helper/ComponentChange.h | 10 ++++++++++ .../src/SceneChecking/SceneCheckUsingAlias.cpp | 6 +++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp b/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp index 172e3c98442..5777d2acae9 100644 --- a/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp +++ b/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp @@ -149,6 +149,16 @@ objectmodel::BaseObject::SPtr ObjectFactory::createObject(objectmodel::BaseConte //////////////////////////////////////////////////////////////////////////////////////////////// + //Check if object has been renamed + + using sofa::helper::lifecycle::renamedComponents; + auto renamedComponent = renamedComponents.find(classname); + if( renamedComponent != renamedComponents.end() ) + { + classname = renamedComponent->second.getNewName(); + } + + // In order to get the errors from the creators only, we save the current errors at this point // and we clear them. Once we extracted the errors from the creators, we put push them back. std::map> creators_errors; // (template_name, errors) diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index 07626870d60..1e7ada3fcc2 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -727,7 +727,10 @@ const std::map > uncreatableComponents {"TriangleModel", Removed("v19.12", "v20.06")}, {"TTriangleModel", Removed("v19.12", "v20.06")}, +}; + +const std::map< std::string, Renamed, std::less<> > renamedComponents = { // Change Constraint naming #4302 {"AffineMovementConstraint", Renamed("v24.06","v25.06","AffineMovementProjectiveConstraint")}, {"AttachConstraint", Renamed("v24.06","v25.06","AttachProjectiveConstraint")}, diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h index 40c94c23b19..6bd25e04c63 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.h @@ -122,11 +122,21 @@ class SOFA_HELPER_API Renamed : public ComponentChange << " To continue using this component after SOFA "<< untilVersion <<" you will need to update your scene "; m_message = output.str(); m_changeVersion = untilVersion; + m_newName = newName; } + + const std::string& getNewName() const + { + return m_newName; + } + +private: + std::string m_newName; }; extern SOFA_HELPER_API const std::map< std::string, Deprecated, std::less<> > deprecatedComponents; extern SOFA_HELPER_API const std::map< std::string, ComponentChange, std::less<> > movedComponents; +extern SOFA_HELPER_API const std::map< std::string, Renamed, std::less<> > renamedComponents; extern SOFA_HELPER_API const std::map< std::string, ComponentChange, std::less<> > uncreatableComponents; } // namespace sofa::helper::lifecycle diff --git a/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp b/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp index 12c3208029d..cde238845e9 100644 --- a/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp +++ b/applications/projects/SceneChecking/src/SceneChecking/SceneCheckUsingAlias.cpp @@ -85,11 +85,11 @@ void SceneCheckUsingAlias::doPrintSummary() const unsigned int count = std::count(i.second.begin(), i.second.end(), unique_alias); using sofa::helper::lifecycle::ComponentChange; - using sofa::helper::lifecycle::uncreatableComponents; + using sofa::helper::lifecycle::renamedComponents; usingAliasesWarning << " - " << i.first << ": " << count << " created with alias \"" << unique_alias << "\""; - auto searchAlias = uncreatableComponents.find(unique_alias); - if( searchAlias != uncreatableComponents.end() ) + auto searchAlias = renamedComponents.find(unique_alias); + if( searchAlias != renamedComponents.end() ) { usingAliasesWarning << " " << searchAlias->second.getMessage(); } From 9f8fe2edfeafecf54f097ef0ba0c8ae9e877a4f3 Mon Sep 17 00:00:00 2001 From: bakpaul Date: Mon, 18 Dec 2023 17:35:24 +0100 Subject: [PATCH 28/28] Remove precedently added aliases --- .../projective/AffineMovementProjectiveConstraint.cpp | 1 - .../constraint/projective/AttachProjectiveConstraint.cpp | 1 - .../constraint/projective/DirectionProjectiveConstraint.cpp | 1 - .../constraint/projective/FixedPlaneProjectiveConstraint.cpp | 1 - .../constraint/projective/FixedProjectiveConstraint.cpp | 1 - .../constraint/projective/FixedRotationProjectiveConstraint.cpp | 1 - .../projective/FixedTranslationProjectiveConstraint.cpp | 1 - .../constraint/projective/HermiteSplineProjectiveConstraint.cpp | 1 - .../constraint/projective/LineProjectiveConstraint.cpp | 1 - .../projective/LinearMovementProjectiveConstraint.cpp | 1 - .../projective/LinearVelocityProjectiveConstraint.cpp | 1 - .../constraint/projective/OscillatorProjectiveConstraint.cpp | 1 - .../constraint/projective/ParabolicProjectiveConstraint.cpp | 1 - .../constraint/projective/PartialFixedProjectiveConstraint.cpp | 2 -- .../projective/PartialLinearMovementProjectiveConstraint.cpp | 2 -- .../projective/PatchTestMovementProjectiveConstraint.cpp | 1 - .../constraint/projective/PlaneProjectiveConstraint.cpp | 1 - .../constraint/projective/PointProjectiveConstraint.cpp | 1 - .../projective/PositionBasedDynamicsProjectiveConstraint.cpp | 2 -- .../projective/SkeletalMotionProjectiveConstraint.cpp | 1 - 20 files changed, 23 deletions(-) diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp index 1e4887d01e4..a34416970dc 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AffineMovementProjectiveConstraint.cpp @@ -34,7 +34,6 @@ namespace sofa::component::constraint::projective int AffineMovementProjectiveConstraintRegister = core::RegisterObject("Constraint the movement by a rigid transform.") .add< AffineMovementProjectiveConstraint >() .add< AffineMovementProjectiveConstraint >() - .addAlias("AffineMovementConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API AffineMovementProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp index a4b0cf94002..2c2683c9d1c 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/AttachProjectiveConstraint.cpp @@ -36,7 +36,6 @@ int AttachProjectiveConstraintClass = core::RegisterObject("Attach given pair of .add< AttachProjectiveConstraint >() .add< AttachProjectiveConstraint >() .add< AttachProjectiveConstraint >() - .addAlias("AttachConstraint") ; template <> SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp index a4f22a624ef..2d0a68442dd 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/DirectionProjectiveConstraint.cpp @@ -35,7 +35,6 @@ using namespace sofa::helper; int DirectionProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") .add< DirectionProjectiveConstraint >() .add< DirectionProjectiveConstraint >() - .addAlias("ProjectDirectionConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API DirectionProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp index 14dd5857dad..ab9c9e49cc6 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedPlaneProjectiveConstraint.cpp @@ -36,7 +36,6 @@ int FixedPlaneProjectiveConstraintClass = core::RegisterObject("Project particle .add< FixedPlaneProjectiveConstraint >() .add< FixedPlaneProjectiveConstraint >() .add< FixedPlaneProjectiveConstraint >() - .addAlias("FixedPlaneConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp index 15aeffb660c..c622b3d4724 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedProjectiveConstraint.cpp @@ -39,7 +39,6 @@ int FixedProjectiveConstraintClass = core::RegisterObject("Attach given particle .add< FixedProjectiveConstraint >() .add< FixedProjectiveConstraint >() .add< FixedProjectiveConstraint >() - .addAlias("FixedConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp index 1844831172d..d812af0e473 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedRotationProjectiveConstraint.cpp @@ -33,7 +33,6 @@ using namespace sofa::defaulttype; int FixedRotationProjectiveConstraintClass = core::RegisterObject("Prevents rotation around x or/and y or/and z axis") .add< FixedRotationProjectiveConstraint >() - .addAlias("FixedRotationConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp index 0336e9a6f8d..e65ea931ed2 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/FixedTranslationProjectiveConstraint.cpp @@ -35,7 +35,6 @@ int FixedTranslationProjectiveConstraintClass = core::RegisterObject("Attach giv .add< FixedTranslationProjectiveConstraint >() .add< FixedTranslationProjectiveConstraint >() .add< FixedTranslationProjectiveConstraint >() - .addAlias("FixedTranslationConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API FixedTranslationProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp index 6dd49852e21..aa10b586bf7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/HermiteSplineProjectiveConstraint.cpp @@ -31,7 +31,6 @@ namespace sofa::component::constraint::projective int HermiteSplineProjectiveConstraintClass = core::RegisterObject("Apply a hermite cubic spline trajectory to given points") .add< HermiteSplineProjectiveConstraint >() .add< HermiteSplineProjectiveConstraint >() - .addAlias("HermiteSplineConstraint") ; template <> diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp index 4ac4c9552ec..e22a8f51b56 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LineProjectiveConstraint.cpp @@ -33,7 +33,6 @@ using namespace sofa::helper; int LineProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") .add< LineProjectiveConstraint >() .add< LineProjectiveConstraint >() - .addAlias("ProjectToLineConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LineProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp index 7feda4bdfb7..e3f98526572 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearMovementProjectiveConstraint.cpp @@ -48,7 +48,6 @@ int LinearMovementProjectiveConstraintClass = core::RegisterObject("translate gi .add< LinearMovementProjectiveConstraint >() .add< LinearMovementProjectiveConstraint >() .add< LinearMovementProjectiveConstraint >() - .addAlias("LinearMovementConstraint") ; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp index fa21e76c8ae..5c8c0ef4a29 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.cpp @@ -38,7 +38,6 @@ int LinearVelocityProjectiveConstraintClass = core::RegisterObject("apply veloci .add< LinearVelocityProjectiveConstraint >() .add< LinearVelocityProjectiveConstraint >() .add< LinearVelocityProjectiveConstraint >() - .addAlias("LinearVelocityConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API LinearVelocityProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp index 9b5d0b9e3c3..967fb6e369d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/OscillatorProjectiveConstraint.cpp @@ -34,7 +34,6 @@ using namespace sofa::helper; int OscillatorProjectiveConstraintClass = core::RegisterObject("Apply a sinusoidal trajectory to given points") .add< OscillatorProjectiveConstraint >() .add< OscillatorProjectiveConstraint >() - .addAlias("OscillatorConstraint") ; template class OscillatorProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp index 76f60aa6ee6..47503a2d77f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/ParabolicProjectiveConstraint.cpp @@ -31,7 +31,6 @@ namespace sofa::component::constraint::projective int ParabolicProjectiveConstraintClass = core::RegisterObject("Apply a parabolic trajectory to given points") .add< ParabolicProjectiveConstraint >() .add< ParabolicProjectiveConstraint >() - .addAlias("ParabolicConstraint") ; template class ParabolicProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp index 663c048c8d2..a28195e0254 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialFixedProjectiveConstraint.cpp @@ -38,8 +38,6 @@ int PartialFixedProjectiveConstraintClass = core::RegisterObject("Attach given p .add< PartialFixedProjectiveConstraint >() .add< PartialFixedProjectiveConstraint >() .add< PartialFixedProjectiveConstraint >() - .addAlias("PartialFixedConstraint") - ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialFixedProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp index 3cb3e883968..fed36af54b7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PartialLinearMovementProjectiveConstraint.cpp @@ -35,8 +35,6 @@ int PartialLinearMovementProjectiveConstraintClass = core::RegisterObject("trans .add< PartialLinearMovementProjectiveConstraint >() .add< PartialLinearMovementProjectiveConstraint >() .add< PartialLinearMovementProjectiveConstraint >() - .addAlias("PartialLinearMovementConstraint") - ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PartialLinearMovementProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp index 4206b03ac40..3b17d682ecd 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PatchTestMovementProjectiveConstraint.cpp @@ -32,7 +32,6 @@ namespace sofa::component::constraint::projective int PatchTestMovementProjectiveConstraintClass = core::RegisterObject("bilinear constraint") .add< PatchTestMovementProjectiveConstraint >() .add< PatchTestMovementProjectiveConstraint >() - .addAlias("PatchTestMovementConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PatchTestMovementProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp index 11092578661..dc33393e99f 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PlaneProjectiveConstraint.cpp @@ -33,7 +33,6 @@ using namespace sofa::helper; int PlaneProjectiveConstraintClass = core::RegisterObject("Attach given particles to their initial positions") .add< PlaneProjectiveConstraint >() .add< PlaneProjectiveConstraint >() - .addAlias("ProjectToPlaneConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PlaneProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp index 2622f32391d..cac90a54160 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PointProjectiveConstraint.cpp @@ -37,7 +37,6 @@ int PointProjectiveConstraintClass = core::RegisterObject("Project particles to .add< PointProjectiveConstraint >() .add< PointProjectiveConstraint >() .add< PointProjectiveConstraint >() - .addAlias("ProjectToPointConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PointProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp index c8c2c4a7b77..43655dd1df7 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/PositionBasedDynamicsProjectiveConstraint.cpp @@ -42,8 +42,6 @@ int PositionBasedDynamicsProjectiveConstraintClass = core::RegisterObject("Posit .add< PositionBasedDynamicsProjectiveConstraint >() .add< PositionBasedDynamicsProjectiveConstraint >() .add< PositionBasedDynamicsProjectiveConstraint >() - .addAlias("PositionBasedDynamicsConstraint") - ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API PositionBasedDynamicsProjectiveConstraint; diff --git a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp index 3fb3bf05de1..7116610d74d 100644 --- a/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp +++ b/Sofa/Component/Constraint/Projective/src/sofa/component/constraint/projective/SkeletalMotionProjectiveConstraint.cpp @@ -30,7 +30,6 @@ namespace sofa::component::constraint::projective //declaration of the class, for the factory int SkeletalMotionProjectiveConstraintClass = core::RegisterObject("animate a skeleton") .add< SkeletalMotionProjectiveConstraint >() - .addAlias("SkeletalMotionConstraint") ; template class SOFA_COMPONENT_CONSTRAINT_PROJECTIVE_API SkeletalMotionProjectiveConstraint;