New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SceneChecker] Check that only one topology per node is allowed #744
Comments
Hi Erik, Thanks for reporting this bug. I looked into BaseContext and found the following: core::topology::Topology* BaseContext::getTopology() const
core::topology::BaseMeshTopology* BaseContext::getMeshTopology() const
core::topology::BaseMeshTopology* BaseContext::getLocalMeshTopology() const
core::topology::BaseMeshTopology* BaseContext::getActiveMeshTopology() const All of them only returns the "first" topology found which can cause a lot of trouble to users. I think your suggestion to provide warning message using the scene checker is a good idea unless there is good reasons for ppl to have multiple topologies in the same node (I don't know if this is the case) I can give it a try. |
You could have two topologies if, for example, a mesh contains both hexahedral and tetrahedral elements inside one simulated object. You will have one mechanical object with all the positions of the mesh, two topologies and two forcefields, all in one node. Of course, you could split those in two or more nodes, but then you will complexify the scene with subset mappings... |
According to @jnbrunet 's feedback I would say that the right approach to fix this is to stop using implicit and hidden link between objects. In defrost we are doing this kind of pattern (in pseudo code) this: class MyObject {
....
SingleLink<Topology> topologyLink;
}
MyObject::init(){
/// Check if the link is explicitely set,
if( !topologyLink.isSet() ){
/// If this is not the case so fallback to get the first topology in the context (buisness as usual) topologyLink.setLinkTo( getTopology() );
}
/// Here we use linked object.
} Such an approach:
But it brings the following:
So to me we juste need to generalize this way of doing to all sofa objects. |
I would add that those kind of functions:
should be made depreciated as they imply that only one of such component can be contained inside a node. |
digging into old issues and in fact this is reaching the top of my todo list before the 19.12
thanks for your inputs. |
This is not anymore mandatory if scene are well created. That is to say, setting link l_topology in each component relying on a topology. Thus the getMeshTopology method is not used. |
A node including
<MeshTopology />
and<TopologyContainer />
component is possible and will crash if some topological changes are performed.Other component could perform this->getContext()->getMeshTopology() which will return either one or the other depending on the order in the Node I assume.
Suggested labels:
The text was updated successfully, but these errors were encountered: