iMSTK
Interactive Medical Simulation Toolkit
imstkSceneObject.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkEntity.h"
10 #include "imstkMacros.h"
11 
12 #include <vector>
13 
14 namespace imstk
15 {
16 class VisualModel;
17 class Geometry;
18 class TaskGraph;
19 class TaskNode;
20 
27 class SceneObject : public Entity
28 {
29 public:
30  SceneObject(const std::string& name = "SceneObject");
31  ~SceneObject() override = default;
32 
33  IMSTK_TYPE_NAME(SceneObject)
34 
35 
36  std::shared_ptr<TaskGraph> getTaskGraph() const { return m_taskGraph; }
39 
43  std::shared_ptr<Geometry> getVisualGeometry() const;
44  void setVisualGeometry(std::shared_ptr<Geometry> geometry);
45 
49  std::shared_ptr<VisualModel> getVisualModel(const int index) const;
50  void addVisualModel(std::shared_ptr<VisualModel> visualModel);
51  void removeVisualModel(std::shared_ptr<VisualModel> visualModel);
52 
56  std::shared_ptr<TaskNode> getUpdateNode() const { return m_updateNode; }
57 
61  std::shared_ptr<TaskNode> getUpdateGeometryNode() const { return m_updateGeometryNode; }
62 
66  virtual void update() { }
67 
71  virtual void visualUpdate() { }
72 
76  virtual void updateGeometries() { }
77 
81  virtual bool initialize() { return true; }
82 
86  void initGraphEdges();
87 
91  virtual void reset() { }
92 
93 protected:
97  virtual void initGraphEdges(std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink);
98 
102  virtual void postModifiedAll();
103 
104  std::shared_ptr<TaskGraph> m_taskGraph = nullptr;
105 
106 private:
107  // Dissallow reassignment of these in subclasses
108  std::shared_ptr<TaskNode> m_updateNode = nullptr;
109  std::shared_ptr<TaskNode> m_updateGeometryNode = nullptr;
110 };
111 } // namespace imstk
virtual void visualUpdate()
Update the visuals, called before render.
std::shared_ptr< Geometry > getVisualGeometry() const
Sets the visual geometry, adds (sets the first) VisualModel.
std::shared_ptr< TaskNode > getUpdateNode() const
Returns the computational node for updating.
virtual void updateGeometries()
Update the geometries.
Compound Geometry.
std::shared_ptr< TaskNode > getUpdateGeometryNode() const
Returns the computational node for updating geometry.
std::shared_ptr< TaskGraph > getTaskGraph() const
Get the computational graph.
std::shared_ptr< VisualModel > getVisualModel(const int index) const
Get/add visual model.
virtual bool initialize()
Initialize the scene object.
Top-level class for entities. Entities contain a collection of components which define how to be used...
Definition: imstkEntity.h:26
virtual void update()
Update the SceneObject, called during scene update.
Base class for all scene objects. A scene object can optionally be visible and collide with other sce...
std::shared_ptr< TaskGraph > m_taskGraph
Computational Graph.
void initGraphEdges()
Initializes the edges of the SceneObject&#39;s computational graph.
virtual void postModifiedAll()
Posts modified for all geometries.