iMSTK
Interactive Medical Simulation Toolkit
imstkDynamicalModel.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 "imstkAbstractDynamicalModel.h"
10 
11 namespace imstk
12 {
19 template<class StateType>
21 {
22 public:
23  DynamicalModel(DynamicalModelType type = DynamicalModelType::None) : AbstractDynamicalModel(type),
24  m_initialState(std::make_shared<StateType>()),
25  m_currentState(std::make_shared<StateType>()),
26  m_previousState(std::make_shared<StateType>())
27  {
28  }
29 
30  ~DynamicalModel() override = default;
31 
35  std::shared_ptr<StateType> getInitialState() const { return m_initialState; }
36 
40  std::shared_ptr<StateType> getCurrentState() const { return m_currentState; }
41 
45  std::shared_ptr<StateType> getPreviousState() const { return m_previousState; }
46 
50  void resetToInitialState() override
51  {
52  m_currentState->setState(m_initialState);
54  }
55 
56 protected:
57  // Body states
58  std::shared_ptr<StateType> m_initialState;
59  std::shared_ptr<StateType> m_currentState;
60  std::shared_ptr<StateType> m_previousState;
61 };
62 } // namespace imstk
std::shared_ptr< StateType > m_initialState
Initial state.
void resetToInitialState() override
Reset the current state to the initial state.
std::shared_ptr< StateType > getPreviousState() const
Return the previous state of the problem.
Compound Geometry.
Abstract class for mathematical model of the physics governing the dynamic object.
DynamicalModelType
Type of the time dependent mathematical model.
std::shared_ptr< StateType > m_previousState
Previous state.
std::shared_ptr< StateType > getInitialState() const
Return the initial state of the problem.
Base class for mathematical model of the physics governing the dynamic object.
std::shared_ptr< StateType > m_currentState
Current state.
std::shared_ptr< StateType > getCurrentState() const
Return the current state of the problem.