Skip to content

Commit b9d122d

Browse files
committed
Add binding for dfree
1 parent 023bfcb commit b9d122d

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

bindings/Modules/src/SofaPython3/SofaConstraintSolver/Binding_ConstraintSolver.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ void moduleAddConstraintSolver(py::module &m)
5656
return { lambda.ptr(), lambda.size()};
5757
}, sofapython3::doc::constraintsolver::constraintSolver_lambda);
5858

59+
c.def("dfree", [](ConstraintSolverImpl& self) -> Eigen::Map<Eigen::Matrix<SReal, Eigen::Dynamic, 1> >
60+
{
61+
assert(self.getConstraintProblem());
62+
auto& dfree = self.getConstraintProblem()->dFree;
63+
return { dfree.ptr(), dfree.size()};
64+
}, sofapython3::doc::constraintsolver::constraintSolver_dfree);
65+
5966
/// register the binding in the downcasting subsystem
6067
PythonFactory::registerType<ConstraintSolverImpl>([](sofa::core::objectmodel::Base* object)
6168
{

bindings/Modules/src/SofaPython3/SofaConstraintSolver/Binding_ConstraintSolver_doc.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,18 @@ Returns the force resulting from the constraints
4646
------------
4747
4848
constraint_solver = root.addObject("GenericConstraintSolver", tolerance=1e-9, maxIterations=1000)
49-
matrix = constraint_solver.lambda_force()
49+
lambda = constraint_solver.lambda_force()
50+
)";
51+
52+
static auto constraintSolver_dfree =
53+
R"(
54+
Returns the displacement computed without any constraint
55+
56+
example:
57+
------------
58+
59+
constraint_solver = root.addObject("GenericConstraintSolver", tolerance=1e-9, maxIterations=1000)
60+
dfree = constraint_solver.dfree()
5061
)";
5162

5263
} // namespace sofapython3::doc::constraintsolver

0 commit comments

Comments
 (0)