From c963f89ab04591ea651fc3c7474c233679368f13 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 4 Nov 2026 16:57:29 +0100 Subject: [PATCH] [Core] Rename `BaseMechanicalState` to `BaseVectorState` --- .../src/sofa/component/io/mesh/MeshExporter.h | 15 ------- .../src/sofa/component/visual/Visual3DText.h | 10 ----- .../component/rendering3d/PointSplatModel.h | 10 ----- .../rendering3d/SlicedVolumetricModel.h | 10 ----- Sofa/framework/Core/CMakeLists.txt | 5 ++- .../sofa/core/behavior/BaseMechanicalState.h | 30 +++++++++++++ ...echanicalState.cpp => BaseVectorState.cpp} | 16 +++---- ...aseMechanicalState.h => BaseVectorState.h} | 43 ++++--------------- .../Core/src/sofa/core/behavior/fwd.h | 3 +- Sofa/framework/Core/src/sofa/core/config.h.in | 7 +++ Sofa/framework/Core/src/sofa/core/fwd.cpp | 4 +- Sofa/framework/Core/src/sofa/core/fwd.h | 6 +-- .../Core/src/sofa/core/objectmodel/Base.h | 5 ++- .../Core/src/sofa/core/objectmodel/BaseNode.h | 2 +- 14 files changed, 68 insertions(+), 98 deletions(-) create mode 100644 Sofa/framework/Core/compat/sofa/core/behavior/BaseMechanicalState.h rename Sofa/framework/Core/src/sofa/core/behavior/{BaseMechanicalState.cpp => BaseVectorState.cpp} (88%) rename Sofa/framework/Core/src/sofa/core/behavior/{BaseMechanicalState.h => BaseVectorState.h} (91%) diff --git a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshExporter.h b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshExporter.h index f7f3f280d73..90d3e95c897 100644 --- a/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshExporter.h +++ b/Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/MeshExporter.h @@ -29,21 +29,6 @@ #include #include -///////////////////////////// FORWARD DECLARATION ////////////////////////////////////////////////// -namespace sofa::core -{ -namespace objectmodel { - class Event ; -} -namespace behavior { - class BaseMechanicalState; -} -namespace topology { - class BaseMeshTopology ; -} -} - - ////////////////////////////////// DECLARATION ///////////////////////////////////////////////////// namespace sofa::component::_meshexporter_ { diff --git a/Sofa/Component/Visual/src/sofa/component/visual/Visual3DText.h b/Sofa/Component/Visual/src/sofa/component/visual/Visual3DText.h index d8c7c5c9940..49578f1e445 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/Visual3DText.h +++ b/Sofa/Component/Visual/src/sofa/component/visual/Visual3DText.h @@ -25,16 +25,6 @@ #include #include -namespace sofa::core::topology -{ - class BaseMeshTopology; -} // namespace sofa::core::topology - -namespace sofa::core::behavior -{ - class BaseMechanicalState; -} // namespace sofa::core::behavior - namespace sofa::component::visual { diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/PointSplatModel.h b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/PointSplatModel.h index 575afe21600..b8694570d0f 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/PointSplatModel.h +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/PointSplatModel.h @@ -27,16 +27,6 @@ #include #include -namespace sofa::core::topology -{ - class BaseMeshTopology; -} // namespace sofa::core::topology - -namespace sofa::core::behavior -{ - class BaseMechanicalState; -} // namespace sofa::core::behavior - namespace sofa::gl::component::rendering3d { diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/SlicedVolumetricModel.h b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/SlicedVolumetricModel.h index 5e51a665b14..3f41491f47c 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/SlicedVolumetricModel.h +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/SlicedVolumetricModel.h @@ -29,16 +29,6 @@ #include #include -namespace sofa::core::topology -{ - class BaseMeshTopology; -} // namespace sofa::core::topology - -namespace sofa::core::behavior -{ - class BaseMechanicalState; -} // namespace sofa::core::behavior - namespace sofa::gl::component::rendering3d { diff --git a/Sofa/framework/Core/CMakeLists.txt b/Sofa/framework/Core/CMakeLists.txt index 163f5ecbe6c..81a284e73a8 100644 --- a/Sofa/framework/Core/CMakeLists.txt +++ b/Sofa/framework/Core/CMakeLists.txt @@ -83,11 +83,11 @@ set(HEADER_FILES ${SRC_ROOT}/behavior/BaseLocalMassMatrix.h ${SRC_ROOT}/behavior/BaseMass.h ${SRC_ROOT}/behavior/BaseMatrixLinearSystem.h - ${SRC_ROOT}/behavior/BaseMechanicalState.h ${SRC_ROOT}/behavior/BaseOrderingMethod.h ${SRC_ROOT}/behavior/BaseProjectiveConstraintSet.h ${SRC_ROOT}/behavior/BaseRotationFinder.h ${SRC_ROOT}/behavior/BaseVectorOperations.h + ${SRC_ROOT}/behavior/BaseVectorState.h ${SRC_ROOT}/behavior/BlocMatrixWriter.h ${SRC_ROOT}/behavior/BlockType.h ${SRC_ROOT}/behavior/Constraint.h @@ -273,9 +273,9 @@ set(SOURCE_FILES ${SRC_ROOT}/behavior/BaseLinearSolver.cpp ${SRC_ROOT}/behavior/BaseMass.cpp ${SRC_ROOT}/behavior/BaseMatrixLinearSystem.cpp - ${SRC_ROOT}/behavior/BaseMechanicalState.cpp ${SRC_ROOT}/behavior/BaseOrderingMethod.cpp ${SRC_ROOT}/behavior/BaseProjectiveConstraintSet.cpp + ${SRC_ROOT}/behavior/BaseVectorState.cpp ${SRC_ROOT}/behavior/ConstraintCorrection.cpp ${SRC_ROOT}/behavior/ConstraintResolution.cpp ${SRC_ROOT}/behavior/ConstraintSolver.cpp @@ -371,6 +371,7 @@ set(SOURCE_FILES set(DEPRECATED_DIR "compat/sofa/core") set(DEPRECATED_HEADER_FILES + ${DEPRECATED_DIR}/behavior/BaseMechanicalState.h ${DEPRECATED_DIR}/objectmodel/BaseObject.h ) diff --git a/Sofa/framework/Core/compat/sofa/core/behavior/BaseMechanicalState.h b/Sofa/framework/Core/compat/sofa/core/behavior/BaseMechanicalState.h new file mode 100644 index 00000000000..0420ed36a58 --- /dev/null +++ b/Sofa/framework/Core/compat/sofa/core/behavior/BaseMechanicalState.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* SOFA, Simulation Open-Framework Architecture * +* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by * +* the Free Software Foundation; either version 2.1 of the License, or (at * +* your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this program. If not, see . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#pragma once +#include + +namespace sofa::core::behavior +{ + +using BaseMechanicalState = BaseVectorState; + +} diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.cpp b/Sofa/framework/Core/src/sofa/core/behavior/BaseVectorState.cpp similarity index 88% rename from Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.cpp rename to Sofa/framework/Core/src/sofa/core/behavior/BaseVectorState.cpp index 3c906d7a3bf..1946f3b0f7d 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.cpp +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseVectorState.cpp @@ -19,18 +19,18 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#include +#include #include namespace sofa::core::behavior { -BaseMechanicalState::BaseMechanicalState() +BaseVectorState::BaseVectorState() { } -BaseMechanicalState::~BaseMechanicalState() +BaseVectorState::~BaseVectorState() { } @@ -39,7 +39,7 @@ BaseMechanicalState::~BaseMechanicalState() /// This is used to compute in on steps operations such as $v = v + a*dt, x = x + v*dt$. /// Note that if the result vector appears inside the expression, it must be the first operand. /// By default this method decompose the computation into multiple vOp calls. -void BaseMechanicalState::vMultiOp(const ExecParams* params, const VMultiOp& ops) +void BaseVectorState::vMultiOp(const ExecParams* params, const VMultiOp& ops) { for (const auto& op : ops) { @@ -79,7 +79,7 @@ void BaseMechanicalState::vMultiOp(const ExecParams* params, const VMultiOp& ops } /// Handle state Changes from a given Topology -void BaseMechanicalState::handleStateChange(core::topology::Topology* /*t*/) +void BaseVectorState::handleStateChange(core::topology::Topology* /*t*/) { // if (t == this->getContext()->getTopology()) // { @@ -87,17 +87,17 @@ void BaseMechanicalState::handleStateChange(core::topology::Topology* /*t*/) // } } -void BaseMechanicalState::writeState( std::ostream& ) +void BaseVectorState::writeState( std::ostream& ) { } -bool BaseMechanicalState::insertInNode( objectmodel::BaseNode* node ) +bool BaseVectorState::insertInNode( objectmodel::BaseNode* node ) { node->addMechanicalState(this); Inherit1::insertInNode(node); return true; } -bool BaseMechanicalState::removeInNode( objectmodel::BaseNode* node ) +bool BaseVectorState::removeInNode( objectmodel::BaseNode* node ) { node->removeMechanicalState(this); Inherit1::removeInNode(node); diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h b/Sofa/framework/Core/src/sofa/core/behavior/BaseVectorState.h similarity index 91% rename from Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h rename to Sofa/framework/Core/src/sofa/core/behavior/BaseVectorState.h index b02006174cc..aea52b1e2d9 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseMechanicalState.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseVectorState.h @@ -31,47 +31,20 @@ namespace sofa::core::behavior { -/** - * \brief Component storing all state vectors of a simulated body (position, velocity, etc). - * - * This class only contains the data of the body and not any of its - * active computations, which are handled by the Mass, ForceField, and - * LagrangianConstraint components. - * - * Two types of vectors are used : - * \li \code VecCoord \endcode : containing positions. - * \li \code VecDeriv \endcode : derivative values, i.e. velocity, forces, displacements. - * In most cases they are the same (i.e. 3D/2D point particles), but they can - * be different (rigid frames for instance). - * - * Several pre-defined vectors are stored : - * \li \code position \endcode - * \li \code velocity \endcode - * \li \code force \endcode - * \li \code dx \endcode (displacement) - * - * Other vectors can be allocated to store other temporary values. - * Vectors can be assigned efficiently by just swapping pointers. - * - * In addition to state vectors, the current constraint system matrix is also - * stored, containing the coefficient of each constraint defined over the DOFs - * in this body. - * - */ -class SOFA_CORE_API BaseMechanicalState : public virtual BaseState +class SOFA_CORE_API BaseVectorState : public virtual BaseState { public: - SOFA_ABSTRACT_CLASS(BaseMechanicalState, BaseState); - SOFA_BASE_CAST_IMPLEMENTATION(BaseMechanicalState); + SOFA_ABSTRACT_CLASS(BaseVectorState, BaseState); + SOFA_BASE_CAST_IMPLEMENTATION(BaseVectorState); using Index = sofa::Index; protected: - BaseMechanicalState(); + BaseVectorState(); - ~BaseMechanicalState() override; + ~BaseVectorState() override; private: - BaseMechanicalState(const BaseMechanicalState& n) = delete; - BaseMechanicalState& operator=(const BaseMechanicalState& n) = delete; + BaseVectorState(const BaseVectorState& n) = delete; + BaseVectorState& operator=(const BaseVectorState& n) = delete; public: /// @name Methods allowing to have access to the geometry without a template class (generic but not efficient) @@ -299,7 +272,7 @@ class SOFA_CORE_API BaseMechanicalState : public virtual BaseState virtual bool pickParticles(const ExecParams* /* params */, double /*rayOx*/, double /*rayOy*/, double /*rayOz*/, double /*rayDx*/, double /*rayDy*/, double /*rayDz*/, double /*radius0*/, double /*dRadius*/, - std::multimap< double, std::pair >& /*particles*/) + std::multimap< double, std::pair >& /*particles*/) { return false; } diff --git a/Sofa/framework/Core/src/sofa/core/behavior/fwd.h b/Sofa/framework/Core/src/sofa/core/behavior/fwd.h index a6c4927f9ac..8cca7d8b0a9 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/fwd.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/fwd.h @@ -32,6 +32,7 @@ namespace sofa::core::behavior class BaseInteractionForceField; class BaseInteractionProjectiveConstraintSet; class BaseMass; - class BaseMechanicalState; + class BaseVectorState; + using BaseMechanicalState = BaseVectorState; class MultiMatrixAccessor; } diff --git a/Sofa/framework/Core/src/sofa/core/config.h.in b/Sofa/framework/Core/src/sofa/core/config.h.in index 8e691846ce4..7be88e4f3de 100644 --- a/Sofa/framework/Core/src/sofa/core/config.h.in +++ b/Sofa/framework/Core/src/sofa/core/config.h.in @@ -188,3 +188,10 @@ SOFA_ATTRIBUTE_DISABLED("v26.12", "v27.06", "Use solveLinearSystem instead of ac #define SOFA_CORE_DEPRECATED_GETDATAVECFROMMULTIVECID() \ SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.12", "") #endif + +#ifdef SOFA_BUILD_SOFA_CORE +#define SOFA_ATTRIBUTE_DEPRECATED__TOBASEMECHANICALSTATE() +#else +#define SOFA_ATTRIBUTE_DEPRECATED__TOBASEMECHANICALSTATE() \ + SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.06", "Use toBaseVectorState instead.") +#endif diff --git a/Sofa/framework/Core/src/sofa/core/fwd.cpp b/Sofa/framework/Core/src/sofa/core/fwd.cpp index c3d2a4fd83b..601c8ded6b8 100644 --- a/Sofa/framework/Core/src/sofa/core/fwd.cpp +++ b/Sofa/framework/Core/src/sofa/core/fwd.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -174,7 +174,7 @@ SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseMass); SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseIntegrationScheme); SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::ConstraintSolver); SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseLinearSolver); -SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseMechanicalState); +SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseVectorState); SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseForceField); SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseInteractionForceField); SOFA_DEFINE_OPAQUE_FUNCTIONS_BETWEEN_BASE_AND(sofa::core::behavior::BaseProjectiveConstraintSet); diff --git a/Sofa/framework/Core/src/sofa/core/fwd.h b/Sofa/framework/Core/src/sofa/core/fwd.h index 5d9a42b9759..fa0897437f4 100644 --- a/Sofa/framework/Core/src/sofa/core/fwd.h +++ b/Sofa/framework/Core/src/sofa/core/fwd.h @@ -99,7 +99,8 @@ namespace sofa::core::behavior { class BaseForceField; class BaseMass; -class BaseMechanicalState; +class BaseVectorState; +using BaseMechanicalState = BaseVectorState; class BaseAnimationLoop; class BaseLagrangianConstraint; class BaseConstraintSet; @@ -111,7 +112,6 @@ class BaseInteractionForceField; class BaseProjectiveConstraintSet; class BaseInteractionProjectiveConstraintSet; class BaseInteractionConstraint; -class BaseMechanicalState; class LinearSolver; class MultiMatrixAccessor; @@ -276,7 +276,7 @@ SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseMass); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseIntegrationScheme); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::ConstraintSolver); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseLinearSolver); -SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseMechanicalState); +SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseVectorState); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseForceField); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseInteractionForceField); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::behavior::BaseProjectiveConstraintSet); diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h b/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h index 7ab96eadc3b..8c06e298139 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h @@ -439,7 +439,7 @@ class SOFA_CORE_API Base : public IntrusiveObject SOFA_BASE_CAST_DEFINITION( behavior, LinearSolver ) SOFA_BASE_CAST_DEFINITION( behavior, ConstraintSolver ) SOFA_BASE_CAST_DEFINITION( behavior, BaseMass ) - SOFA_BASE_CAST_DEFINITION( behavior, BaseMechanicalState ) + SOFA_BASE_CAST_DEFINITION( behavior, BaseVectorState ) SOFA_BASE_CAST_DEFINITION( behavior, BaseInteractionForceField ) SOFA_BASE_CAST_DEFINITION( behavior, BaseInteractionConstraint ) SOFA_BASE_CAST_DEFINITION( behavior, BaseForceField ) @@ -469,6 +469,9 @@ class SOFA_CORE_API Base : public IntrusiveObject SOFA_ATTRIBUTE_DEPRECATED__TOBASEOBJECT() virtual const objectmodel::BaseComponent* toBaseObject() const { return toBaseComponent(); } SOFA_ATTRIBUTE_DEPRECATED__TOBASEOBJECT() virtual objectmodel::BaseComponent* toBaseObject() { return toBaseComponent(); } + SOFA_ATTRIBUTE_DEPRECATED__TOBASEMECHANICALSTATE() virtual const behavior::BaseVectorState* toBaseMechanicalState() const { return toBaseVectorState(); } + SOFA_ATTRIBUTE_DEPRECATED__TOBASEMECHANICALSTATE() virtual behavior::BaseVectorState* toBaseMechanicalState() { return toBaseVectorState(); } + /// @} }; diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.h index 4e482ca6222..987bbafe3ba 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseNode.h @@ -171,7 +171,7 @@ class SOFA_CORE_API BaseNode : public virtual Base BASENODE_ADD_SPECIAL_COMPONENT( core::topology::BaseMeshTopology, MeshTopology, meshTopology ) BASENODE_ADD_SPECIAL_COMPONENT( core::topology::BaseTopologyObject, TopologyObject, topologyObject ) BASENODE_ADD_SPECIAL_COMPONENT( core::BaseState, State, state ) - BASENODE_ADD_SPECIAL_COMPONENT( core::behavior::BaseMechanicalState,MechanicalState, mechanicalState ) + BASENODE_ADD_SPECIAL_COMPONENT( core::behavior::BaseVectorState,MechanicalState, mechanicalState ) BASENODE_ADD_SPECIAL_COMPONENT( core::BaseMapping, MechanicalMapping, mechanicalMapping ) BASENODE_ADD_SPECIAL_COMPONENT( core::behavior::BaseMass, Mass, mass ) BASENODE_ADD_SPECIAL_COMPONENT( core::behavior::BaseForceField, ForceField, forceField )