MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / getDepthFirstObject

Function getDepthFirstObject

source/MRMesh/MRObjectsAccess.hpp:96–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95template<typename ObjectT>
96std::shared_ptr<ObjectT> getDepthFirstObject( Object* root, const ObjectSelectivityType& type )
97{
98 if ( !root )
99 return {};
100
101 std::stack<Object*> todo;
102 todo.push( root );
103 while ( !todo.empty() )
104 {
105 root = todo.top();
106 todo.pop();
107 const auto & children = root->children();
108 for ( const auto& child : children )
109 if ( auto visObj = asSelectivityType<ObjectT>( child, type ) )
110 return visObj;
111 for ( auto it = children.rbegin(); it != children.rend(); ++it )
112 {
113 if ( auto * child = it->get() )
114 todo.push( child );
115 }
116 }
117 return {};
118}
119
120}

Callers 2

saveSceneAs_Method · 0.85
isAvailableMethod · 0.85

Calls 4

pushMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected