iMSTK
Interactive Medical Simulation Toolkit
imstkDynamicObject.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 "imstkCollidingObject.h"
10 
11 namespace imstk
12 {
13 class Geometry;
14 class GeometryMap;
15 class AbstractDynamicalModel;
16 
23 {
24 public:
25  ~DynamicObject() override = default;
26 
30  std::shared_ptr<Geometry> getPhysicsGeometry() const { return m_physicsGeometry; }
31  virtual void setPhysicsGeometry(std::shared_ptr<Geometry> geometry) { m_physicsGeometry = geometry; }
33 
37  std::shared_ptr<GeometryMap> getPhysicsToCollidingMap() const { return m_physicsToCollidingGeomMap; }
38  void setPhysicsToCollidingMap(std::shared_ptr<GeometryMap> map) { m_physicsToCollidingGeomMap = map; }
40 
44  std::shared_ptr<GeometryMap> getPhysicsToVisualMap() const { return m_physicsToVisualGeomMap; }
45  void setPhysicsToVisualMap(std::shared_ptr<GeometryMap> map) { m_physicsToVisualGeomMap = map; }
47 
51  virtual std::shared_ptr<AbstractDynamicalModel> getDynamicalModel() const { return m_dynamicalModel; }
52  virtual void setDynamicalModel(std::shared_ptr<AbstractDynamicalModel> dynaModel) { m_dynamicalModel = dynaModel; }
54 
58  size_t getNumOfDOF() const;
59 
63  void updateGeometries() final;
64 
68  virtual void updatePhysicsGeometry();
69 
73  bool initialize() override;
74 
78  void reset() override;
79 
80 protected:
84  void initGraphEdges(std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink) override;
85 
86  void postModifiedAll() override;
87 
88  DynamicObject(const std::string& name) : CollidingObject(name) { }
89 
90  std::shared_ptr<AbstractDynamicalModel> m_dynamicalModel = nullptr;
91  std::shared_ptr<Geometry> m_physicsGeometry = nullptr;
92 
93  // Maps
94  std::shared_ptr<GeometryMap> m_physicsToCollidingGeomMap = nullptr;
95  std::shared_ptr<GeometryMap> m_physicsToVisualGeomMap = nullptr;
96 };
97 } // namespace imstk
void reset() override
Reset the dynamic object by reseting the respective DynamicalModel and Geometry.
void postModifiedAll() override
Posts modified for all geometries.
std::shared_ptr< GeometryMap > getPhysicsToCollidingMap() const
Set/Get the Physics-to-Collision map.
Base class for scene objects that move and/or deform.
Compound Geometry.
size_t getNumOfDOF() const
Returns the number of degree of freedom.
virtual std::shared_ptr< AbstractDynamicalModel > getDynamicalModel() const
Set/Get dynamical model.
virtual void updatePhysicsGeometry()
Update only the physics geometry and apply collision map.
bool initialize() override
Initialize the scene object.
std::shared_ptr< AbstractDynamicalModel > m_dynamicalModel
Dynamical model.
std::shared_ptr< GeometryMap > getPhysicsToVisualMap() const
Set/Get the Physics-to-Visual map.
std::shared_ptr< GeometryMap > m_physicsToVisualGeomMap
Maps from Physics to visual geometry.
void updateGeometries() final
Update the physics geometry and the apply the maps (if defined)
std::shared_ptr< Geometry > getPhysicsGeometry() const
Set/Get the geometry used for Physics computations.
std::shared_ptr< GeometryMap > m_physicsToCollidingGeomMap
Maps from Physics to collision geometry.
A SceneObject with a geometry for collision.
std::shared_ptr< Geometry > m_physicsGeometry
Geometry used for Physics.
void initGraphEdges()
Initializes the edges of the SceneObject&#39;s computational graph.