Skip to content

Commit e705dca

Browse files
authored
Merge branch 'master' into hugtalbot-patch-5
2 parents 85aa9e8 + fc75967 commit e705dca

File tree

24 files changed

+280
-137
lines changed

24 files changed

+280
-137
lines changed

bindings/Modules/tests/SofaConstraintSolver/matrix_access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def simulate_pendulum(self):
3939
ext.addObject("DistanceMapping", name="distanceMapping", topology="@../edge_container")
4040
ext.addObject("UniformConstraint", template="Vec1d", iterative=True)
4141

42-
Sofa.Simulation.init(root)
42+
Sofa.Simulation.initRoot(root)
4343
Sofa.Simulation.animate(root, 0.0001)
4444

4545
return root

bindings/Modules/tests/SofaDeformable/SpringForceField.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Test(unittest.TestCase):
3838
def setUp(self) -> None:
3939
self.root = Sofa.Core.Node()
4040
create_scene(self.root)
41-
Sofa.Simulation.init(self.root)
41+
Sofa.Simulation.initRoot(self.root)
4242

4343
def tearDown(self) -> None:
4444
Sofa.Simulation.unload(self.root)

bindings/Modules/tests/SofaLinearSolver/matrix_access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def simulate_beam(self, linear_solver_template):
2626
root.addObject('FixedConstraint', indices="@box.indices")
2727
root.addObject('HexahedronFEMForceField', name="FEM", youngModulus="4000", poissonRatio="0.3", method="large")
2828

29-
Sofa.Simulation.init(root)
29+
Sofa.Simulation.initRoot(root)
3030
Sofa.Simulation.animate(root, 0.0001)
3131

3232
return root

bindings/Sofa/package/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
n.addChild("Node2")
1414
n.addObject("MechanicalObject", name="dofs")
1515
16-
Sofa.Simulation.init(n)
16+
Sofa.Simulation.initRoot(n)
1717
Sofa.Simulation.print(n)
1818
1919
"""

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseMeshTopology.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ void moduleAddBaseMeshTopology(py::module& m) {
6565
c.def("getNbTriangles", &BaseMeshTopology::getNbTriangles);
6666
c.def("getNbTetrahedra", &BaseMeshTopology::getNbTetrahedra);
6767
c.def("getNbHexahedra", &BaseMeshTopology::getNbHexahedra);
68+
c.def("getNbPrisms", &BaseMeshTopology::getNbPrisms);
69+
c.def("getNbPyramids", &BaseMeshTopology::getNbPyramids);
6870
c.def("getNbQuads", &BaseMeshTopology::getNbQuads);
6971
c.def("getNbTetras", &BaseMeshTopology::getNbTetras);
7072

7173
c.def("getEdge",
72-
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 2> {
74+
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Edge::NumberOfNodes> {
7375
const auto & e = self.getEdge(index);
7476
return {{e[0], e[1]}};
7577
},
@@ -78,7 +80,7 @@ void moduleAddBaseMeshTopology(py::module& m) {
7880
);
7981

8082
c.def("getTriangle",
81-
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 3> {
83+
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Triangle::NumberOfNodes> {
8284
const auto & t = self.getTriangle(index);
8385
return {{t[0], t[1], t[2]}};
8486
},
@@ -87,7 +89,7 @@ void moduleAddBaseMeshTopology(py::module& m) {
8789
);
8890

8991
c.def("getQuad",
90-
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, 4> {
92+
[] (BaseMeshTopology &self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Quad::NumberOfNodes> {
9193
const auto & q = self.getQuad(index);
9294
return {{q[0], q[1], q[2], q[3]}};
9395
},
@@ -96,7 +98,7 @@ void moduleAddBaseMeshTopology(py::module& m) {
9698
);
9799

98100
c.def("getTetrahedron",
99-
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 4> {
101+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Tetrahedron::NumberOfNodes> {
100102
const auto & n = self.getTetrahedron(index);
101103
return {{n[0], n[1], n[2], n[3]}};
102104
},
@@ -105,14 +107,32 @@ void moduleAddBaseMeshTopology(py::module& m) {
105107
);
106108

107109
c.def("getHexahedron",
108-
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 8> {
110+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Hexahedron::NumberOfNodes> {
109111
const auto & n = self.getHexahedron(index);
110112
return {{n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7]}};
111113
},
112114
py::arg("index"),
113115
"Returns the vertices of Hexahedron at index."
114116
);
115117

118+
c.def("getPrism",
119+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Prism::NumberOfNodes> {
120+
const auto & n = self.getPrism(index);
121+
return {{n[0], n[1], n[2], n[3], n[4], n[5]}};
122+
},
123+
py::arg("index"),
124+
"Returns the vertices of Prism at index."
125+
);
126+
127+
c.def("getPyramid",
128+
[] (BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, sofa::geometry::Pyramid::NumberOfNodes> {
129+
const auto & n = self.getPyramid(index);
130+
return {{n[0], n[1], n[2], n[3], n[4]}};
131+
},
132+
py::arg("index"),
133+
"Returns the vertices of Pyramid at index."
134+
);
135+
116136
c.def("getLocalEdgesInTetrahedron",
117137
[] (const BaseMeshTopology & self, const sofa::Index & index) -> std::array<sofa::Index, 2> {
118138
const auto & e = self.getLocalEdgesInTetrahedron(index);

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseObject.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
#pragma once
2222

2323
#include <pybind11/pybind11.h>
24+
#include <sofa/core/fwd.h>
2425

25-
namespace sofa::core::objectmodel {
26-
class BaseObject;
27-
}
28-
29-
namespace sofapython3 {
26+
namespace sofapython3
27+
{
3028

3129
pybind11::object getItem(const sofa::core::objectmodel::BaseObject & self, const std::string& path);
3230

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node_doc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static auto Class =
4848
# Add a mechanical component to MyNode
4949
n.addObject("MechanicalObject", name="dofs")
5050
51-
Sofa.Simulation.init(root)
51+
Sofa.Simulation.initRoot(root)
5252
Sofa.Simulation.print(root)
5353
5454
The child nodes, components and parents can be accessed using generator attributes.

bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ PYBIND11_MODULE(Core, core)
100100
# Add a mechanical component to MyNode
101101
n.addObject("MechanicalObject", name="dofs")
102102
103-
Sofa.Simulation.init(root)
103+
Sofa.Simulation.initRoot(root)
104104
Sofa.Simulation.print(root)
105105
106106
)doc";

bindings/Sofa/src/SofaPython3/Sofa/Simulation/Submodule_Simulation_doc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static auto Class =
3737
SofaRuntime.importPlugin("SofaComponentAll")
3838
3939
n = Sofa.Core.Node("MyNode")
40-
Sofa.Simulation.init(n)
40+
Sofa.Simulation.initRoot(n)
4141
Sofa.Simulation.print(n)
4242
)";
4343
static auto print =

bindings/Sofa/tests/Core/BaseData.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def test_DataAsContainerNumpyArray_testIsDirtyOnDoubleAccess_(self):
255255
root.addObject("PointSetTopologyContainer", points=[[0, 0, 0], [1, 0, 0]])
256256
modifier = root.addObject("PointSetTopologyModifier")
257257
mo = root.addObject("MechanicalObject")
258-
Sofa.Simulation.init(root)
258+
Sofa.Simulation.initRoot(root)
259259

260260
modifier.addPoints(10, True)
261261
self.assertEqual(len(mo.position), 12)
@@ -269,7 +269,7 @@ def test_DataAsContainerNumpyArray_testIsDirtyOnDoubleWriteAccess_(self):
269269
root.addObject("PointSetTopologyContainer", points=[[0, 0, 0], [1, 0, 0]])
270270
modifier = root.addObject("PointSetTopologyModifier")
271271
mo = root.addObject("MechanicalObject")
272-
Sofa.Simulation.init(root)
272+
Sofa.Simulation.initRoot(root)
273273

274274
modifier.addPoints(10, True)
275275
with mo.position.writeable() as w:
@@ -283,7 +283,7 @@ def test_DataAsContainerNumpyArray_(self):
283283
root = create_scene("rootNode")
284284
v = numpy.array([[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3]])
285285
c = root.addObject("MechanicalObject", name="t", position=v.tolist())
286-
Sofa.Simulation.init(root)
286+
Sofa.Simulation.initRoot(root)
287287

288288
numpy.testing.assert_array_equal(c.position.array(), v)
289289

0 commit comments

Comments
 (0)