Home › Forum › SOFA › Using SOFA › Changing topology during runtime
Tagged: 64_bits, Linux_ubuntu, refine coarse, SOFA_1608
- This topic has 7 replies, 2 voices, and was last updated 7 years, 9 months ago by epernod.
-
AuthorPosts
-
1 February 2017 at 17:23 #8489jjcasmarBlocked
Hi,
I would like to know if it’s possible to change a mesh topology during runtime. My idea is to have a metric which defines if a triangle or tetrahedron must be refined or coarsed and during runtime (like in http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/Narain-AAR-2012-11.pdf).
I would like to know how to handle mechanical dofs data initialization (how the values for the new vertexes in the mechanicalObject are initialized, such as forces, position, velocities…) and collision models based on the topology (mesh colliders for example).
Thanks!
2 February 2017 at 12:01 #8492epernodBlockedHi,
yes this is possible using topologyEngines. Could you explain how you would like to initiate those changes. Is it using a component that will have act as “topology observer” and change it if needed?
There is a set of examples using topologicalModifiers here: examples/Components/topology/TopologicalModifiers/
Maybe they could give you a first approach.Regards,
Erik2 February 2017 at 12:41 #8496jjcasmarBlockedI was thinking about an engine which after each frame, updates a scalar field stored in the nodes and based on that scalar field, check which triangles should be refined or coarsed. So maybe I can inherit from topologyEngine to do this 🙂
Thanks
3 February 2017 at 11:40 #8506epernodBlockedHi,
ok then if you are using an engine, the idea is in the update method, you filter the triangles/vertices to changes. And then using the TriangleSetTopologyAlgorithms or TriangleSetTopologyModifier components, you can access different methods to change the triangulation. I.e removeTriangle, AddPoint, AddTriangles etc..
You should have dynamique topology inside your scene: TriangleSetTopolgyContainer/Modifier/… components.
Look at the component TopologicalChangeProcessor which does this kind of action using a timer thougth those examples:
src/examples/Components/topology/TopologicalModifiers/IncisionTrianglesProcess.scn
src/examples/Components/topology/TopologicalModifiers/AddingTrianglesProcess.scnRegards,
Erik3 February 2017 at 12:05 #8508jjcasmarBlockedGreat, thanks Perdon.
Just one more question. When I modify a triangle, how are the new mechanical DOFs for the new vertexes calculated? For example if I remove one triangle and insert 3 triangles inside, in order to refine the mesh, there will be one extra vertex. If that mesh is used for cloth computations, how are the velocities, strain… computed?
7 February 2017 at 11:00 #8512epernodBlockedHi,
sorry I missed your last post.
Everything is handle in the topologyModifier methods using add/removeItems but if you want more details here is for example for triangle:TriangleSetTopologyModifier::removeTriangles(...){ ... if (removeTrianglesPreconditions(triangleIds_filtered)) // Test if the topology will still fulfill the conditions if these triangles are removed. { /// add the topological changes in the queue removeTrianglesWarning(triangleIds_filtered); // inform other objects that the triangles are going to be removed propagateTopologicalChanges(); // now destroy the old triangles. removeTrianglesProcess(triangleIds_filtered ,removeIsolatedEdges, removeIsolatedPoints); m_container->checkTopology(); } ... }
For removal, you first warn other components like FEM and mechanicalObject that triangles and maybe points are going to be removed. Thus they can update them self using topologyDataHandler. Look for example this example when a triangle is removed:
void TriangularBendingSprings<DataTypes>::TriangularBSEdgeHandler::ApplyTopologyChange(const core::topology::TrianglesRemoved* e) { const sofa::helper::vector<unsigned int> &triangleRemoved = e->getArray(); applyTriangleDestruction(triangleRemoved); }
Then when all the components do not point to the “future removed triangles” it is removed from topology buffers.
To Add triangles, it is the inverse, you first add to the buffer then warn components.Regards,
Erik
ps: btw, may I ask what is your project target on cloth simulation using Sofa?
7 February 2017 at 16:06 #8513jjcasmarBlockedRight now nothing important, just some playing with SOFA and state of the art force models like VegaFEM or ArcSIM.
So if I understand correctly, for a FF or a MO to take care of the addtion, deletion or modification of topology, the topologyDataHandler must be implemented? What happens when this modification affects a mapping? Does the current MO, FF, colliders or mappings support topology modifications?
Thanks!
15 February 2017 at 11:38 #8586epernodBlockedHi,
you do not need to change the MO, neither the topology Components. This is already implemented.
The only thing you need to do when creating a new FF is to add this topologyDataHandler.For mapping etc, it doesn’t change the mechanism.
In fact the topology changes use the implicit Data graph.
If you are using a FF based on triangles any TriangleData inside this FF is automatically a child of the containerData<Triangles>
. So any change on the container set all TriangleData of all components to dirty and theTriangleDataHandler
is used toupdateIfDirty
Then it propagate to edges and points (or the other way, I don’t remember)Erik
-
AuthorPosts
- You must be logged in to reply to this topic.