7 #include "imstkSceneObject.h" 8 #include "imstkGeometry.h" 9 #include "imstkLogger.h" 10 #include "imstkTaskGraph.h" 11 #include "imstkVisualModel.h" 15 SceneObject::SceneObject(
const std::string& name) : Entity(name),
16 m_taskGraph(
std::make_shared<TaskGraph>(
17 "SceneObject_" + m_name +
"_Source",
18 "SceneObject_" + m_name +
"_Sink"))
24 std::shared_ptr<Geometry>
27 auto visualModel = getComponent<VisualModel>();
28 if (visualModel !=
nullptr)
30 return visualModel->getGeometry();
36 SceneObject::setVisualGeometry(std::shared_ptr<Geometry> geometry)
38 auto iter = std::find_if(m_components.begin(), m_components.end(),
39 [](std::shared_ptr<Component> comp)
41 return std::dynamic_pointer_cast<
VisualModel>(comp) !=
nullptr;
43 if (iter != m_components.end())
45 std::dynamic_pointer_cast<
VisualModel>(*iter)->setGeometry(geometry);
49 auto visualModel = addComponent<VisualModel>();
50 visualModel->setName(
m_name +
"_VisualModel");
51 visualModel->setGeometry(geometry);
55 std::shared_ptr<VisualModel>
58 return getComponentN<VisualModel>(index);
62 SceneObject::addVisualModel(std::shared_ptr<VisualModel> visualModel)
68 SceneObject::removeVisualModel(std::shared_ptr<VisualModel> visualModel)
84 m_taskGraph->addEdge(m_updateNode, m_updateGeometryNode);
92 for (
auto comp : m_components)
94 if (
auto visualModel = std::dynamic_pointer_cast<VisualModel>(comp))
96 if (visualModel->getGeometry() !=
nullptr)
98 visualModel->getGeometry()->postModified();
std::shared_ptr< Geometry > getVisualGeometry() const
Sets the visual geometry, adds (sets the first) VisualModel.
void removeComponent(std::shared_ptr< Component > component)
Remove component if it exists.
void update() override
Update the SceneObject, called during scene update.
std::shared_ptr< VisualModel > getVisualModel(const int index) const
Get/add visual model.
void updateGeometries() final
Update the physics geometry and the apply the maps (if defined)
std::shared_ptr< T > addComponent()
Create and return a component on this entity.
std::shared_ptr< TaskGraph > m_taskGraph
Computational Graph.
std::string m_name
Not unique name.
void initGraphEdges()
Initializes the edges of the SceneObject's computational graph.
virtual void postModifiedAll()
Posts modified for all geometries.
Contains geometric, material, and render information.