Home › Forum › SOFA › Programming with SOFA › [SOLVED] What is TopologyEngine for ?
Tagged: TopologyEngine
- This topic has 3 replies, 2 voices, and was last updated 8 years, 10 months ago by Weng.
-
AuthorPosts
-
29 October 2015 at 07:25 #3884WengBlocked
What is TopologyEngine for ?
In BaseObject.h
the method “handleTopologyChange” is commented as “@deprecated topological changes now rely on TopologyEngine” :
/// Handle topological Changes
/// @deprecated topological changes now rely on TopologyEngine
virtual void handleTopologyChange() {}/// Handle topological Changes from a given Topology
/// @deprecated topological changes now rely on TopologyEngine
virtual void handleTopologyChange(core::topology::Topology* t);Also, in BaseMechanicalState.h, “handleStateChange” is commented as “@deprecated topological changes now rely on TopologyEngine” :
/// Handle state Changes
/// @deprecated topological changes now rely on TopologyEngine
virtual void handleStateChange() {}/// Handle state Changes from a given Topology
/// @deprecated topological changes now rely on TopologyEngine
virtual void handleStateChange(core::topology::Topology* t);However, I found a lot of places using “handleTopologyChange” method, e.g. TLineModel, HexahedronFEMForceField, BarycentricMapping, etc. And “handleStateChange” seems still working too.
At the same time, there are also a lot of places using TopologyEngine, e.g. EdgeSetTopologyModifier, HexahedronSetTopologyModifier, etc..
I tried to remove triangles using TriangleSetTopologyModifier, and monitored the “m_enginesList” in TriangleSetTopologyContainer, “m_enginesList” seems to be empty during the removal (I maybe wrong).
What is TopologyEngine for ?
What are “TriangleSetTopologyModifier::propagateTopologicalEngineChanges()”, “TriangleSetTopologyContainer::updateTopologyEngineGraph()” and some other functions related to TopologyEngine for ?Regards,
Weng Bin4 November 2015 at 07:48 #3916WengBlockedIt has been 6 days… no one answer…
Currently, what I know:
(1) TopologyEngine and handleTopologyChange() are both used in SOFA.
(2) TopologyEngine supports: PointData, EdgeData, …, HexahedronData (see TopologyData.h), all these data (variable) will be automatically updated according to the topology changes, no need to handleTopologyChange for them.
for example:
in BarycentricMapping.h : in BarycentricMapperHexahedronSetTopology
topology::PointData< sofa::helper::vector<MappingData> > map;in the init()
if (this->toTopology)
{
map.createTopologicalEngine(this->toTopology);
map.registerTopologicalData();
}indicates that map is using TopologyEngine,
(3) All the other situations rely one handleTopologyChange
for example, in TriangleModel.inl: void TTriangleModel<DataTypes>::handleTopologyChange()If I misunderstood anything, please reply
regards,
Weng Bin15 February 2016 at 16:18 #5680epernodBlockedHi,
yes you are right, the
TopologyEngine
was a new mechanism to handle topological changes.
This work has not been totally finished, that is why you can find some duplicated mechanisms.The main idea was to change the previous mechanism that was propagating topological changes through the scene graph by a new one using only the Data graph dependencies.
Thus, each Data will automatically update itself only when his parentData is dirty and propagate the change to his children.It is very old for me now… so I will need to go deeper in the code if you want a full explaination but basically let’s take the example of the
TriangularFEMForcefield
.This FEM store several data/values for each triangle, edge and vertex, through the inner classes:
TriangleInformation
,EdgeInformation
andVertexInformation
Looking only at the triangles (but it is the same for each topological element), all the information on the triangulation is stored on a single Data:
TriangleData<sofa::helper::vector<TriangleInformation> > triangleInfo;
By default a
TriangleData
will be set as Child of the Data m_triangles (from the Topology Container) using the line of code:
triangleInfo.registerTopologicalData();
Thus, changing the number of triangles in the topology imply that the child Data triangleInfo is dirty and need an update.
This will be automatically handle by theTopologyEngine
if you add aTopologyHandler
to thatTriangleData
. You need to implement thatTopologyHandler
. Here it correspond to the class:
class TRQSTriangleHandler : public TopologyDataHandler<Triangle,vector<TriangleInformation> >
and you register it using the line of code:
triangleInfo.createTopologicalEngine(_topology, triangleHandler);
In this Handler you describes all the rules to create/destroy/… the corresponding Data. Look at the method for example:
void TriangularFEMForceField<DataTypes>::TRQSTriangleHandler::applyCreateFunction(
You can see the list of method to overwrite in the file
TopologyDataHandler.h
The event corresponding to the topological change is automatically handle from theTopologyEngine
, it will know which method to call between creation, destruction, swap of elements.Hope this is clear… at least it just removed a big pile of dust from my brain 🙂
Erik
19 February 2016 at 08:07 #5841WengBlockedHi, Erik
Thanks for your reply.
This is really helpful for anyone working on cutting.Best regards,
Weng Bin -
AuthorPosts
- You must be logged in to reply to this topic.