Index-dependent objects in combination with SofaCarving #3008
-
Hi, If I delete triangles through the SofaCarving plugin (CarvingManager + CarvingSurface + CarvingTool), the size of the MechanicalObject changes and the RestShapeSpringsForceField crashes because the indices are no longer valid.
Does anyone have an idea on how I could keep the indices valid? The scene graph is basically the same as https://github.com/sofa-framework/sofa/blob/master/examples/Demos/TriangleSurfaceCutting.scn, but with a CarvingTool like in https://github.com/sofa-framework/sofa/blob/master/applications/plugins/SofaCarving/examples/CarvingTool.scn Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Hi @ScheiklP Interesting question! I am not using myself topological changes extensively. @epernod how do you handle such id changes on your end? |
Beta Was this translation helpful? Give feedback.
-
Further to a discussion with @epernod, he reminded me that such data (automatically updated with the topological changes) should be TopologyData. Erik presented this API in the STC#13 (see slide 3) We could make it as an issue, instead. |
Beta Was this translation helpful? Give feedback.
-
Hi, yes this is a bug, the RestShapeSpringsForceField should use a TopologySubsetIndices for its indices vector instead of Data< type::vector< sofa::Index > >. This special Data follow topological changes and update itself when element are removed. See for example how FixedConstraint is managing its fixed indices: Can you do the changes? |
Beta Was this translation helpful? Give feedback.
-
Hi @hugtalbot and @epernod , I tried to make the changes (compiles and runs), but the indices are not updated.
I guess the |
Beta Was this translation helpful? Give feedback.
Further to a discussion with @epernod, he reminded me that such data (automatically updated with the topological changes) should be TopologyData. Erik presented this API in the STC#13 (see slide 3)
In your case, this means that the
Data< type::vector< sofa::Index > > d_points
data field of the RestShapeSpringsForceField should be defined assofa::core::topology::TopologySubsetIndices
(like in the FixedConstraint)We could make it as an issue, instead.