MeshLib C++ Docs
Loading...
Searching...
No Matches
MRObjectsAccess.h
Go to the documentation of this file.
1#pragma once
2#include "MRObject.h"
3#include "MRPch/MRBindingMacros.h"
4
5namespace MR
6{
7
10
12{
15 Any
16};
17
19template<typename ObjectT = Object>
20std::shared_ptr<ObjectT> asSelectivityType( std::shared_ptr<Object> obj, const ObjectSelectivityType& type );
21
24template<typename ObjectT = Object>
25std::vector<std::shared_ptr<ObjectT>> getAllObjectsInTree( Object* root, const ObjectSelectivityType& type = ObjectSelectivityType::Selectable );
26template<typename ObjectT = Object>
27MR_BIND_IGNORE inline std::vector<std::shared_ptr<ObjectT>> getAllObjectsInTree( Object& root, const ObjectSelectivityType& type = ObjectSelectivityType::Selectable )
28 { return getAllObjectsInTree<ObjectT>( &root, type ); }
29
31template<typename ObjectT = Object>
32std::vector<std::shared_ptr<ObjectT>> getTopmostVisibleObjects( Object* root, const ObjectSelectivityType& type = ObjectSelectivityType::Selectable );
33template<typename ObjectT = Object>
34MR_BIND_IGNORE inline std::vector<std::shared_ptr<ObjectT>> getTopmostVisibleObjects( Object& root, const ObjectSelectivityType& type = ObjectSelectivityType::Selectable )
35 { return getTopmostVisibleObjects<ObjectT>( &root, type ); }
36
38template<typename ObjectT = Object>
39std::shared_ptr<ObjectT> getDepthFirstObject( Object* root, const ObjectSelectivityType& type );
40template<typename ObjectT = Object>
41MR_BIND_IGNORE inline std::shared_ptr<ObjectT> getDepthFirstObject( Object& root, const ObjectSelectivityType& type )
42 { return getDepthFirstObject<ObjectT>( &root, type ); }
43
45
46inline bool objectHasSelectableChildren( const MR::Object& object )
47{
48 for ( const auto& child : object.children() )
49 {
50 if ( !child->isAncillary() || objectHasSelectableChildren( *child ) )
51 return true;
52 }
53 return false;
54}
55
56}
57
58#include "MRObjectsAccess.hpp"
named object in the data model
Definition MRObject.h:60
ObjectSelectivityType
Definition MRObjectsAccess.h:12
std::vector< std::shared_ptr< ObjectT > > getAllObjectsInTree(Object *root, const ObjectSelectivityType &type=ObjectSelectivityType::Selectable)
std::shared_ptr< ObjectT > asSelectivityType(std::shared_ptr< Object > obj, const ObjectSelectivityType &type)
if input object is of given type then returns another pointer on it
std::vector< std::shared_ptr< ObjectT > > getTopmostVisibleObjects(Object *root, const ObjectSelectivityType &type=ObjectSelectivityType::Selectable)
Returns all topmost visible objects of given type (if an object is returned, its children are not) ex...
std::shared_ptr< ObjectT > getDepthFirstObject(Object *root, const ObjectSelectivityType &type)
return first object of given type in depth-first traverse order excluding root
bool objectHasSelectableChildren(const MR::Object &object)
Definition MRObjectsAccess.h:46