Skip to content
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

[SofaSimulationGraph] Stop DAGNode get parent topology process in BarycentricMapping #1176

Merged
merged 3 commits into from Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 26 additions & 35 deletions SofaKernel/modules/SofaSimulationGraph/DAGNode.cpp
Expand Up @@ -159,7 +159,7 @@ Node::SPtr DAGNode::createChild(const std::string& nodeName)
}
}
msg_error("Node::createChild()") << "Empty string given to property 'name': Forcefully setting an empty name is forbidden.\n"
"Renaming to " + newName + " to avoid unexpected behaviors.";
"Renaming to " + newName + " to avoid unexpected behaviors.";
newchild = sofa::core::objectmodel::New<DAGNode>(newName);
}
else
Expand Down Expand Up @@ -229,29 +229,18 @@ void* DAGNode::getObject(const sofa::core::objectmodel::ClassInfo& class_info, c
else dir = SearchDown; // we are the root, search down from here.
}
void *result = nullptr;
#ifdef DEBUG_GETOBJECT
std::string cname = class_info.name();
if (cname != std::string("N4sofa4core6ShaderE"))
std::cout << "DAGNode: search for object of type " << class_info.name() ;
std::string gname = "N4sofa9component8topology32TetrahedronSetGeometryAlgorithms";
bool isg = cname.length() >= gname.length() && std::string(cname, 0, gname.length()) == gname;
#endif

if (dir != SearchParents)
for (ObjectIterator it = this->object.begin(); it != this->object.end(); ++it)
{
core::objectmodel::BaseObject* obj = it->get();
if (tags.empty() || (obj)->getTags().includes(tags))
{
#ifdef DEBUG_GETOBJECT
if (isg)
std::cout << "DAGNode: testing object " << (obj)->getName() << " of type " << (obj)->getClassName() ;
#endif

result = class_info.dynamicCast(obj);
if (result != nullptr)
{
#ifdef DEBUG_GETOBJECT
std::cout << "DAGNode: found object " << (obj)->getName() << " of type " << (obj)->getClassName() ;
#endif

break;
}
}
Expand All @@ -261,26 +250,28 @@ void* DAGNode::getObject(const sofa::core::objectmodel::ClassInfo& class_info, c
{
switch(dir)
{
case Local:
break;
case SearchParents:
case SearchUp:
{
const LinkParents::Container& parents = l_parents.getValue();
for ( unsigned int i = 0; i < parents.size() ; ++i)
result = parents[i]->getObject(class_info, tags, SearchUp);
}
break;
case SearchDown:
for(ChildIterator it = child.begin(); it != child.end(); ++it)
case Local:
break;
case SearchParents:
case SearchUp:
{
result = (*it)->getObject(class_info, tags, dir);
if (result != nullptr) break;
const LinkParents::Container& parents = l_parents.getValue();
for ( unsigned int i = 0; i < parents.size() ; ++i){
result = parents[i]->getObject(class_info, tags, SearchUp);
if (result != nullptr) break;
}
}
break;
case SearchRoot:
dmsg_error("DAGNode") << "SearchRoot SHOULD NOT BE POSSIBLE HERE.";
break;
break;
case SearchDown:
for(ChildIterator it = child.begin(); it != child.end(); ++it)
{
result = (*it)->getObject(class_info, tags, dir);
if (result != nullptr) break;
}
break;
case SearchRoot:
dmsg_error("DAGNode") << "SearchRoot SHOULD NOT BE POSSIBLE HERE.";
break;
}
}

Expand Down Expand Up @@ -401,7 +392,7 @@ void DAGNode::getObjects(const sofa::core::objectmodel::ClassInfo& class_info, G
GetUpObjectsVisitor vis( const_cast<DAGNode*>(this), class_info, container, tags);
getRootContext()->executeVisitor(&vis);
}
break;
break;

case SearchDown:
{
Expand Down Expand Up @@ -475,7 +466,7 @@ bool DAGNode::hasAncestor(const BaseContext* context) const
const LinkParents::Container& parents = l_parents.getValue();
for ( unsigned int i = 0; i < parents.size() ; ++i)
if (context == parents[i]->getContext()
|| parents[i]->hasAncestor(context))
|| parents[i]->hasAncestor(context))
return true;
return false;
}
Expand Down