Skip to content

Commit ef31d88

Browse files
committed
Merge branch 'master' into dev_demo-25-11-07
2 parents 3ecfd59 + 514e999 commit ef31d88

File tree

91 files changed

+1541
-725
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1541
-725
lines changed

Sofa/Component/AnimationLoop/src/sofa/component/animationloop/ConstraintAnimationLoop.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#pragma once
2323
#include <sofa/component/animationloop/config.h>
2424

25+
SOFA_HEADER_DEPRECATED_NOT_REPLACED("v26.06", "v26.12")
26+
2527

2628
#include <sofa/helper/map.h>
2729
#include <sofa/linearalgebra/FullMatrix.h>

Sofa/Component/Collision/Detection/Algorithm/tests/CollisionPipeline_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void TestCollisionPipeline::checkCollisionPipelineWithNoAttributes()
111111
ASSERT_NE(root.get(), nullptr) ;
112112
root->init(sofa::core::execparams::defaultInstance()) ;
113113

114-
BaseObject* clp = root->getObject("pipeline") ;
114+
sofa::core::objectmodel::BaseObject* clp = root->getObject("pipeline") ;
115115
ASSERT_NE(clp, nullptr) ;
116116
}
117117

@@ -133,7 +133,7 @@ void TestCollisionPipeline::checkCollisionPipelineWithMissingIntersection()
133133
ASSERT_NE(root.get(), nullptr) ;
134134
root->init(sofa::core::execparams::defaultInstance()) ;
135135

136-
BaseObject* clp = root->getObject("pipeline") ;
136+
sofa::core::objectmodel::BaseObject* clp = root->getObject("pipeline") ;
137137
ASSERT_NE(clp, nullptr) ;
138138
}
139139

@@ -155,7 +155,7 @@ void TestCollisionPipeline::checkCollisionPipelineWithMissingBroadPhase()
155155
ASSERT_NE(root.get(), nullptr) ;
156156
root->init(sofa::core::execparams::defaultInstance()) ;
157157

158-
BaseObject* clp = root->getObject("pipeline") ;
158+
sofa::core::objectmodel::BaseObject* clp = root->getObject("pipeline") ;
159159
ASSERT_NE(clp, nullptr) ;
160160
}
161161
void TestCollisionPipeline::checkCollisionPipelineWithMissingNarrowPhase()
@@ -176,7 +176,7 @@ void TestCollisionPipeline::checkCollisionPipelineWithMissingNarrowPhase()
176176
ASSERT_NE(root.get(), nullptr) ;
177177
root->init(sofa::core::execparams::defaultInstance()) ;
178178

179-
BaseObject* clp = root->getObject("pipeline") ;
179+
sofa::core::objectmodel::BaseObject* clp = root->getObject("pipeline") ;
180180
ASSERT_NE(clp, nullptr) ;
181181
}
182182
void TestCollisionPipeline::checkCollisionPipelineWithMissingContactManager()
@@ -197,7 +197,7 @@ void TestCollisionPipeline::checkCollisionPipelineWithMissingContactManager()
197197
ASSERT_NE(root.get(), nullptr) ;
198198
root->init(sofa::core::execparams::defaultInstance()) ;
199199

200-
BaseObject* clp = root->getObject("pipeline") ;
200+
sofa::core::objectmodel::BaseObject* clp = root->getObject("pipeline") ;
201201
ASSERT_NE(clp, nullptr) ;
202202

203203
}

Sofa/Component/Collision/Geometry/tests/Sphere_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void checkAttributes()
434434
EXPECT_NE(root.get(), nullptr) ;
435435
root->init(sofa::core::execparams::defaultInstance()) ;
436436

437-
BaseObject* theSphere = root->getTreeNode("Level 1")->getObject("spheremodel") ;
437+
sofa::core::objectmodel::BaseObject* theSphere = root->getTreeNode("Level 1")->getObject("spheremodel") ;
438438
EXPECT_NE(theSphere, nullptr) ;
439439

440440
/// List of the supported attributes the user expect to find
@@ -462,7 +462,7 @@ void checkSceneWithVec3MechanicalModel()
462462
EXPECT_NE(root.get(), nullptr) ;
463463
root->init(sofa::core::execparams::defaultInstance()) ;
464464

465-
BaseObject* theSphere = root->getTreeNode("Level 1")->getObject("spheremodel") ;
465+
sofa::core::objectmodel::BaseObject* theSphere = root->getTreeNode("Level 1")->getObject("spheremodel") ;
466466
EXPECT_NE(theSphere, nullptr) ;
467467
}
468468

@@ -481,7 +481,7 @@ void checkSceneWithRigid3dMechanicalModel()
481481
EXPECT_NE(root.get(), nullptr) ;
482482
root->init(sofa::core::execparams::defaultInstance()) ;
483483

484-
BaseObject* theSphere = root->getTreeNode("Level 1")->getObject("spheremodel") ;
484+
sofa::core::objectmodel::BaseObject* theSphere = root->getTreeNode("Level 1")->getObject("spheremodel") ;
485485
EXPECT_NE(theSphere, nullptr) ;
486486
}
487487

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/GenericConstraintSolver.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,6 @@ GenericConstraintSolver::GenericConstraintSolver()
112112
d_tolerance.setRequired(true);
113113
}
114114

115-
GenericConstraintSolver::~GenericConstraintSolver()
116-
{
117-
for (unsigned i=0; i< CP_BUFFER_SIZE; ++i)
118-
{
119-
delete m_cpBuffer[i];
120-
}
121-
}
122-
123-
124-
125115
void GenericConstraintSolver:: init()
126116
{
127117
this->initializeConstraintProblems();
@@ -144,9 +134,9 @@ void GenericConstraintSolver::initializeConstraintProblems()
144134
{
145135
for (unsigned i=0; i< CP_BUFFER_SIZE; ++i)
146136
{
147-
m_cpBuffer[i] = new GenericConstraintProblem(this);
137+
m_cpBuffer[i] = std::make_unique<GenericConstraintProblem>(this);
148138
}
149-
current_cp = m_cpBuffer[0];
139+
current_cp = m_cpBuffer[0].get();
150140
}
151141

152142
void GenericConstraintSolver::cleanup()
@@ -414,7 +404,7 @@ void GenericConstraintSolver::lockConstraintProblem(sofa::core::objectmodel::Bas
414404

415405
for (unsigned int i = 0; i < CP_BUFFER_SIZE; ++i)
416406
{
417-
GenericConstraintProblem* p = m_cpBuffer[i];
407+
GenericConstraintProblem* p = m_cpBuffer[i].get();
418408
if (p == p1 || p == p2)
419409
{
420410
m_cpIsLocked[i] = true;

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/GenericConstraintSolver.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_SOLVER_API GenericConstraintSolver :
4545
SOFA_CLASS(GenericConstraintSolver, ConstraintSolverImpl);
4646
protected:
4747
GenericConstraintSolver();
48-
~GenericConstraintSolver() override;
4948
public:
5049
void init() override;
5150

@@ -89,8 +88,8 @@ class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_SOLVER_API GenericConstraintSolver :
8988
void clearConstraintProblemLocks();
9089

9190
static constexpr auto CP_BUFFER_SIZE = 10;
92-
sofa::type::fixed_array<GenericConstraintProblem * , CP_BUFFER_SIZE> m_cpBuffer;
93-
sofa::type::fixed_array<bool, CP_BUFFER_SIZE> m_cpIsLocked;
91+
sofa::type::fixed_array<std::unique_ptr<GenericConstraintProblem>, CP_BUFFER_SIZE> m_cpBuffer;
92+
sofa::type::fixed_array<bool, CP_BUFFER_SIZE> m_cpIsLocked = sofa::type::makeHomogeneousArray<bool, CP_BUFFER_SIZE>(false);
9493
GenericConstraintProblem *current_cp, *last_cp;
9594

9695
sofa::core::MultiVecDerivId m_lambdaId;

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/UnbuiltConstraintSolver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ void UnbuiltConstraintSolver::initializeConstraintProblems()
9797
{
9898
for (unsigned i=0; i< CP_BUFFER_SIZE; ++i)
9999
{
100-
m_cpBuffer[i] = new UnbuiltConstraintProblem(this);
100+
m_cpBuffer[i] = std::make_unique<UnbuiltConstraintProblem>(this);
101101
}
102-
current_cp = m_cpBuffer[0];
102+
current_cp = m_cpBuffer[0].get();
103103
}
104104

105105

106-
}
106+
}

Sofa/Component/Engine/Select/tests/BoxROI_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct BoxROITest : public sofa::testing::BaseTest
133133
EXPECT_NE(root.get(), nullptr);
134134
root->init(sofa::core::execparams::defaultInstance());
135135

136-
BaseObject* boxroi = root->getTreeNode("Level 1")->getObject("myBoxROI");
136+
sofa::core::objectmodel::BaseObject* boxroi = root->getTreeNode("Level 1")->getObject("myBoxROI");
137137
EXPECT_NE(boxroi, nullptr);
138138

139139
EXPECT_EQ(boxroi->getComponentState(), ComponentState::Invalid ) << "The component cannot be initialized because it is missing a MechanicalObject. "
@@ -202,7 +202,7 @@ struct BoxROITest : public sofa::testing::BaseTest
202202
const Node::SPtr root = SceneLoaderXML::loadFromMemory("testscene", scene.c_str());
203203
EXPECT_NE(root.get(), nullptr);
204204
root->init(sofa::core::execparams::defaultInstance());
205-
BaseObject* boxroi = root->getTreeNode("Level 1")->getObject("myBoxROI");
205+
sofa::core::objectmodel::BaseObject* boxroi = root->getTreeNode("Level 1")->getObject("myBoxROI");
206206

207207
EXPECT_NE(boxroi, nullptr);
208208
EXPECT_EQ(boxroi->getComponentState(), ComponentState::Valid ) << "The component should succeed in being initialized because there is a MeshLoader and a TopologyContainer in the current context. ";

Sofa/Component/IO/Mesh/src/sofa/component/io/mesh/BaseVTKReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ enum class VTKDatasetFormat { IMAGE_DATA, STRUCTURED_POINTS,
4949
POLYDATA, UNSTRUCTURED_GRID
5050
};
5151

52-
class BaseVTKReader : public BaseObject
52+
class BaseVTKReader : public sofa::core::objectmodel::BaseObject
5353
{
5454
public:
55-
class BaseVTKDataIO : public BaseObject
55+
class BaseVTKDataIO : public sofa::core::objectmodel::BaseObject
5656
{
5757
public:
5858
string name;

Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@
2121
******************************************************************************/
2222
#pragma once
2323

24+
#include <sofa/component/mass/RigidMassType.h>
25+
#include <sofa/component/mass/VecMassType.h>
2426
#include <sofa/component/mass/config.h>
25-
26-
#include <sofa/type/vector.h>
27-
#include <sofa/type/Vec.h>
28-
#include <sofa/defaulttype/VecTypes.h>
29-
#include <sofa/defaulttype/RigidTypes.h>
3027
#include <sofa/core/behavior/Mass.h>
31-
#include <sofa/core/topology/TopologyData.h>
28+
#include <sofa/core/behavior/TopologyAccessor.h>
3229
#include <sofa/core/objectmodel/DataFileName.h>
33-
34-
#include <sofa/component/mass/VecMassType.h>
35-
#include <sofa/component/mass/RigidMassType.h>
30+
#include <sofa/core/topology/TopologyData.h>
31+
#include <sofa/defaulttype/RigidTypes.h>
32+
#include <sofa/defaulttype/VecTypes.h>
33+
#include <sofa/type/Vec.h>
34+
#include <sofa/type/vector.h>
3635

3736
#include <type_traits>
3837

@@ -60,10 +59,10 @@ public :
6059
* @tparam GeometricalTypes type of the geometry, i.e type of the state associated with the topology (if the topology and the mass relates to the same state, this will be the same as DataTypes)
6160
*/
6261
template <class DataTypes, class GeometricalTypes = DataTypes>
63-
class DiagonalMass : public core::behavior::Mass<DataTypes>
62+
class DiagonalMass : public core::behavior::Mass<DataTypes>, public virtual sofa::core::behavior::TopologyAccessor
6463
{
6564
public:
66-
SOFA_CLASS(SOFA_TEMPLATE2(DiagonalMass,DataTypes, GeometricalTypes), SOFA_TEMPLATE(core::behavior::Mass,DataTypes));
65+
SOFA_CLASS2(SOFA_TEMPLATE2(DiagonalMass,DataTypes, GeometricalTypes), SOFA_TEMPLATE(core::behavior::Mass,DataTypes), sofa::core::behavior::TopologyAccessor);
6766

6867
using TMassType = typename sofa::component::mass::MassType<DataTypes>::type;
6968

@@ -113,8 +112,6 @@ class DiagonalMass : public core::behavior::Mass<DataTypes>
113112
/// value defining the initialization process of the mass (0 : totalMass, 1 : massDensity, 2 : vertexMass)
114113
int m_initializationProcess;
115114

116-
/// Link to be set to the topology container in the component graph.
117-
SingleLink<DiagonalMass<DataTypes, GeometricalTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
118115
/// Link to be set to the MechanicalObject associated with the geometry
119116
SingleLink<DiagonalMass<DataTypes, GeometricalTypes>, sofa::core::behavior::MechanicalState<GeometricalTypes>, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_geometryState;
120117

Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.inl

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ DiagonalMass<DataTypes, GeometricalTypes>::DiagonalMass()
5050
, d_showCenterOfGravity( initData(&d_showCenterOfGravity, false, "showGravityCenter", "Display the center of gravity of the system" ) )
5151
, d_showAxisSize( initData(&d_showAxisSize, 1.0f, "showAxisSizeFactor", "Factor length of the axis displayed (only used for rigids)" ) )
5252
, d_fileMass( initData(&d_fileMass, "filename", "Xsp3.0 file to specify the mass parameters" ) )
53-
, l_topology(initLink("topology", "link to the topology container"))
5453
, l_geometryState(initLink("geometryState", "link to the MechanicalObject associated with the geometry"))
5554
, m_massTopologyType(sofa::geometry::ElementType::UNKNOWN)
5655
{
@@ -756,22 +755,9 @@ void DiagonalMass<DataTypes, GeometricalTypes>::initTopologyHandlers()
756755
template <class DataTypes, class GeometricalTypes>
757756
bool DiagonalMass<DataTypes, GeometricalTypes>::checkTopology()
758757
{
759-
if (l_topology.empty())
760-
{
761-
msg_info() << "Link \"topology\" to the Topology container should be set to ensure right behavior. First Topology found in current context will be used.";
762-
l_topology.set(this->getContext()->getMeshTopologyLink());
763-
}
764-
765-
if (l_topology.get() == nullptr)
766-
{
767-
msg_error() << "No topology component found at path: " << l_topology.getLinkedPath() << ", nor in current context: " << this->getContext()->name;
768-
sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
758+
this->validateTopology();
759+
if (this->isComponentStateInvalid())
769760
return false;
770-
}
771-
else
772-
{
773-
msg_info() << "Topology path used: '" << l_topology.getLinkedPath() << "'";
774-
}
775761

776762
if (l_geometryState.empty())
777763
{

0 commit comments

Comments
 (0)