Skip to content

Commit c781647

Browse files
committed
Merge remote-tracking branch 'origin/master' into pr-typehint-example-how-to-fix-definition
2 parents fca789f + a17d1e4 commit c781647

5 files changed

Lines changed: 13 additions & 6 deletions

File tree

bindings/Sofa/tests/Core/BaseData.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ def t(c):
248248
self.assertRaises(ValueError, (lambda c: t(c)), color)
249249

250250
def test_DataAsContainerNumpyArray_testIsDirtyOnDoubleAccess_(self):
251+
SofaRuntime.importPlugin("Sofa.Component.Topology.Container.Dynamic")
252+
251253
root = create_scene("rootNode")
252254

253255
root.addObject("PointSetTopologyContainer", points=[[0, 0, 0], [1, 0, 0]])

bindings/Sofa/tests/Core/BaseMeshTopology.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def test_regular_grid_hexas(self):
5757

5858
def test_regular_grid_tetra(self):
5959
SofaRuntime.importPlugin("Sofa.Component.Topology.Container.Grid")
60+
SofaRuntime.importPlugin("Sofa.Component.Topology.Container.Constant")
61+
SofaRuntime.importPlugin("Sofa.Component.Topology.Container.Dynamic")
6062
SofaRuntime.importPlugin("Sofa.Component.Topology.Mapping")
6163

6264
root = Sofa.Core.Node("rootNode")

bindings/Sofa/tests/Core/BaseObject.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
def create_scene(rootName="root"):
77
root = Sofa.Core.Node(rootName)
88
root.addObject("RequiredPlugin", name="Sofa.Component.StateContainer")
9+
root.addObject("RequiredPlugin", name="Sofa.Component.Topology.Container.Constant")
910
return root
1011

1112
class Test(unittest.TestCase):

bindings/Sofa/tests/Core/Mass.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def simulate_beam(linear_solver_template):
2222
root.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective')
2323
root.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic')
2424
root.addObject('RequiredPlugin', name='Sofa.Component.Mass')
25+
root.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Grid')
2526

2627
root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
2728
root.addObject('SparseLDLSolver', applyPermutation="false", template=linear_solver_template)

bindings/SofaTypes/src/SofaPython3/SofaTypes/Binding_Vec.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@
2222
#include <functional>
2323
#include <pybind11/operators.h>
2424
#include <sstream>
25-
using sofa::type::Vec;
2625

27-
#define BINDING_VEC_MAKE_NAME(N, T) \
28-
std::string(std::string("Vec") + std::to_string(N) + typeid(T).name())
26+
#include <sofa/defaulttype/typeinfo/TypeInfo_Vec.h>
27+
28+
using sofa::type::Vec;
2929

30-
namespace pyVec {
30+
namespace pyVec
31+
{
3132
template <sofa::Size N, class T> std::string __str__(const Vec<N, T> &v, bool repr)
3233
{
3334
std::stringstream s ;
3435
s.imbue(std::locale("C"));
35-
s << ((repr) ? (BINDING_VEC_MAKE_NAME(N, T) + "(") : ("("));
36+
s << ((repr) ? (sofa::defaulttype::DataTypeInfo< Vec<N, T> >::name() + "(") : ("("));
3637
s << v[0];
3738
for (size_t i = 1; i < v.size(); ++i)
3839
s << ", " << v[i];
@@ -86,7 +87,7 @@ template <sofa::Size N, class T>
8687
py::class_<Vec<N,T>> addVec(py::module &m)
8788
{
8889
typedef Vec<N, T> VecClass;
89-
py::class_<Vec<N, T>> p(m, BINDING_VEC_MAKE_NAME(N, T).c_str());
90+
py::class_<Vec<N, T>> p(m, sofa::defaulttype::DataTypeInfo< Vec<N, T> >::name().c_str());
9091

9192
p.def(py::init<>()); // empty ctor
9293
p.def(py::init<const VecClass &>()); // copy ctor

0 commit comments

Comments
 (0)