iMSTK
Interactive Medical Simulation Toolkit
imstkPbdObject.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 "imstkDynamicObject.h"
10 #include "imstkMacros.h"
11 #include "imstkPbdConstraint.h"
12 
13 namespace imstk
14 {
15 class PbdModel;
16 class PointSet;
17 
24 class PbdObject : public DynamicObject
25 {
26 public:
27  PbdObject(const std::string& name = "PbdObject") : DynamicObject(name) { }
28  ~PbdObject() override = default;
29 
30  IMSTK_TYPE_NAME(PbdObject)
31 
32 
33  std::shared_ptr<PbdModel> getPbdModel();
36 
40  std::shared_ptr<PbdBody> getPbdBody()
41  {
42  if (m_pbdBody == nullptr)
43  {
44  LOG(FATAL) << "Set the PbdModel on the PbdObject before trying to acquire the body";
45  }
46  return m_pbdBody;
47  }
48 
52  void setDynamicalModel(std::shared_ptr<AbstractDynamicalModel> dynaModel) override;
53 
58  void updatePhysicsGeometry() override;
59 
63  void setBodyFromGeometry();
64 
68  bool initialize() override;
69 
71 
72  const std::vector<std::shared_ptr<PbdConstraint>>& getCellConstraints(int cellId)
73  {
74  return m_pbdBody->cellConstraintMap[cellId];
75  }
76 
77 protected:
81  void setDeformBodyFromGeometry(PbdBody& body, std::shared_ptr<PointSet> geom);
82 
86  void setRigidBody(PbdBody& body);
87 
88 protected:
89  std::shared_ptr<PbdModel> m_pbdModel = nullptr;
90  std::shared_ptr<PbdBody> m_pbdBody = nullptr;
91 };
92 } // namespace imstk
Represents a pbd body in the model. This is a data only object. It does no function. PbdBody can be of different types. The types effect what properties it has.
Definition: imstkPbdBody.h:53
void setDeformBodyFromGeometry(PbdBody &body, std::shared_ptr< PointSet > geom)
Creates a deformable PbdBody from Geometry.
Base class for scene objects that move and/or deform.
std::shared_ptr< PbdModel > getPbdModel()
Compound Geometry.
std::shared_ptr< PbdBody > m_pbdBody
Handle to this object in the model/system.
bool initialize() override
Initialize the Pbd scene object.
void setBodyFromGeometry()
Sets the PbdBody representing this object given its geometry.
std::shared_ptr< PbdModel > m_pbdModel
Pbd mathematical model.
void computeCellConstraintMap()
Base class for scene objects that move and/or deform under position based dynamics formulation...
std::shared_ptr< PbdBody > getPbdBody()
Returns body in the model.
void setDynamicalModel(std::shared_ptr< AbstractDynamicalModel > dynaModel) override
Sets the model, and creates the body within the model.
void setRigidBody(PbdBody &body)
Creates a rigid PbdBody from values.
void updatePhysicsGeometry() override
Update physics geometry, overrided to set transform should the PbdObject be a rigid body...