Home › Forum › SOFA › Using SOFA › [SOLVED] changing tetra mesh topology + collisions
- This topic has 5 replies, 3 voices, and was last updated 9 years, 3 months ago by Froy.
-
AuthorPosts
-
4 August 2015 at 22:01 #3443AnonymousInactive
I am trying to implement fracturing of a tetra mesh by splitting tetra elements and remeshing accordingly. I am using SOFA as a library in some c++ code.
The issue that I am running into is that the collisions don’t seem to be updating for the new tetra elements so self collision doesn’t work.
I have a TTriangleModel but the number of triangles isn’t increased to correspond with the number of new tetra elements.
I am adding new tetra elements to the mesh with this code:
core::topology::BaseMeshTopology* topology = root->getChild(“tetramesh”)->getMeshTopology();
topology->addTetra(ni[0],ni[1],ni[2],ni[3]);My question is what am I doing wrong and what is the proper way to be able to manipulate the tetra mesh (rearranging and adding new elements) so that collisions work properly.
6 August 2015 at 08:38 #3460FroyKeymasterHi,
When you add a new tetrahedron, do you add the new points in the related mechanical object ?
Furthermore, how do you find/manage/create triangles on which you want to apply the collision model ? Because TriangleModel is just searching triangles from the attached topology (i.e in the same node) so if you have only tetrahedra in your topology, TriangleModel won’t find any triangles to perform the collision detection.
You should take a look at the Tetra2TriangleTopologicalMapping, which is filling a triangular topology from the surface of the volumetric mesh.26 August 2015 at 13:07 #3494Jeremie AllardBlockedHello,
The addTetra method should only be used before the components are initialized (i.e. the init() methods are called).
If you want to dynamically update the topology once the simulation is initialized they you should use the TetrahedronSetTopologyModifier::addTetrahedra() method (and similar methods to remove the previous ones, add/remove points, …).
After you finished all your changes, you should also call the methods notifyEndingEvent() followed by propagateTopologicalChanges().
By using these methods as well as the Tetra2TriangleTopologicalMapping that Froy indicated, then you should see the collision mesh being correctly updated.Jeremie.
3 September 2015 at 05:31 #3556AnonymousInactivethanks for the reply. i’m going to be looking into triangle issue, but right now i’m investigating adding new tetras to the mesh after initialization.
i have two questions:
1) is this the general pseudo code
-add points to mesh first
-then add tetra by assigning new points to tetra2) in the code that i pasted, the part that i haven’t been able to figure out is how do i actually update the coordinates of the new points that i added? i can’t seem to find a method that will allow me to do that.
here is code that i came up with so far
sofa::component::topology::TetrahedronSetTopologyModifier* topoMod;
core::topology::BaseMeshTopology* topology = root->getChild(“tetramesh”)->getMeshTopology();
topology->getContext()->get(topoMod);
int oldLastIndex = topology->getNbPoints();
topoMod->addPoints(4,true);//****** DON’T KNOW HOW TO UPDATE COORDINATES OF NEW POINTS *********
helper::vector<core::topology::Topology::Tetrahedron > vitems;
vitems.resize(1);
vitems[0][0] = oldLastIndex + 1;
vitems[0][1] = oldLastIndex + 2;
vitems[0][2] = oldLastIndex + 3;
vitems[0][3] = oldLastIndex + 4;
topoMod->addTetrahedra(vitems);
topoMod->notifyEndingEvent();
topoMod->propagateTopologicalChanges();16 September 2015 at 05:10 #3593AnonymousInactiveI was hoping to get some more help on this.
I think I may have gotten the mesh to update, but the collision elements in TetrahedronDiscreteIntersection.cpp doesn’t seem to be updated with the new topology (i.e. the collision tetra elements still have the old node/point indices). When I print out debugging information from TetrahedronModel.cpp it seems like the topology is updated there.
I’m not sure as to how to proceed.
23 September 2015 at 08:28 #3665FroyKeymasterHello,
Unfortunately, TetrahedronDiscreteIntersection (or more generally collision with volumetric primitives such has TetrahedronModel) is not really supported.
I just looked at the code of the TopologicalChangeManager class and it seems the code handling TetrahedronModel has been disabled.
That’s why I would advise you to use just surface element such as TriangleModel and try to use the Tetra2TriangleTopologicalMapping. This element will automatically update the (triangular) collision model from the (tetrahedral) mechanical model. -
AuthorPosts
- You must be logged in to reply to this topic.