Home › Forum › SOFA › Using SOFA › [SOLVED] Preserve graph component's order
- This topic has 2 replies, 2 voices, and was last updated 7 years, 9 months ago by Bruno Marques.
-
AuthorPosts
-
16 February 2017 at 09:07 #8591Bruno MarquesBlocked
Hi,
I have a scene that looks basically like this:
<Node root> <Node 1> <Component1 /> </Node> <Node 2> <Component2 /> </Node> <Component3/> <Component4 /> </Node>
Component 3 uses some data from 1 and 2, and outputs some stuff to Component4.
Each component implements handleEvent() and prints its name when AnimateBeginEvent is called.
I expected the workflow of my scene to act as follow: first Component 1 does its stuff, then 2, 3 and 4, as named in the scene file.
But what really happen is that first my components in root are called, and only then are my 2 first components, stored in separated nodes.Is there a way to force this behavior? Or even better, since my components are sort of engines (using DataTrackers), is there an event type that triggers only when a data’s dirty flag is set?
Thanks in advance for your answers!
16 February 2017 at 16:29 #8599HugoKeymasterHi Bruno,
As far as I know, it works this way:
- runSofa reads the scene file, and create the components (in the order 1,2,3,4)
- then, all the steps of the simulation (init(), step(), handleEvent()) are launched through visitors and follow the scene graph (3,4,1,2), i.e. the components in the root node, then in its first child and so on.
To change this behavior, you need to write your own AnimationLoop (see below in the SceneGraph page). Using the tag mechanism, you can define a custom order.
About the DataTracker, it is the right mechanism to use. It has been recently introduced in SOFA V16.12. You can use this DataTracker and the build-in callback function.
Let us know about your progress.
Cheers,Hugo
4 March 2017 at 16:18 #8755Bruno MarquesBlockedThank you Hugo,
After discussion with some pro users, it happens that my problem is a fake problem:
in the scene example of my first post, I show an example where component 3 and 4 actually depends on the output of Node1 and Node2.So logic would have that my components 3 and 4 would be in a subNode, whose parents are Node1 and Node2.
This is sadly not possible with XML, as an XML node can only have 1 parent, but with Python, it’s OK.
A possible alternative to my problem could be to nest Node2 in Node1, add an Node3, nested in Node2, and set my component3 and component4 inside.
Thanks a lot for your input, though, I learned a lot about Sofa’s animation loop thanks to you 🙂
– Bruno
-
AuthorPosts
- You must be logged in to reply to this topic.