iMSTK
Interactive Medical Simulation Toolkit
imstkTearable.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 #include "imstkComponent.h"
8 #include "imstkMath.h"
9 
10 #pragma once
11 
12 namespace imstk
13 {
14 class PbdConstraint;
15 class PbdObject;
16 class PbdObjectCellRemoval;
17 class TaskNode;
18 
28 class Tearable : public SceneBehaviour
29 {
30 public:
31  Tearable(const std::string& name = "TearablePbdObjectBehavior");
32 
33  void init() override;
34 
38  std::shared_ptr<PbdObject> getPbdObject() const { return m_tearableObject; }
40 
46  double getMaxStrain() const { return m_maxStrain; }
47  void setMaxStrain(const double maxStrain) { m_maxStrain = maxStrain; }
49 
50 protected:
51 
52  // The handle checks the constraint value (strain) of each cell, and if it
53  // is greater than the max strain removes the cell.
54  void handleTearable();
55 
56  void initGraphEdges(std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink) override;
57 
58  std::shared_ptr<PbdObject> m_tearableObject;
59  std::shared_ptr<PbdObjectCellRemoval> m_cellRemover = nullptr;
60 
61  std::shared_ptr<TaskNode> m_tearableHandleNode;
62 
63  // Failure (strain) of the PbdObject. Measured by (current constraint value / reference value) where the
64  // reference value is not zero. If the reference value is zero, the constraint value is used.
65  double m_maxStrain = 0.5;
66 };
67 } // namespace imstk
void init() override
Initialize the component, called at a later time after all component construction is complete...
double getMaxStrain() const
Get/Set the maximum strain. This measure is defined by (current constraint value / reference value) w...
Definition: imstkTearable.h:46
Compound Geometry.
std::shared_ptr< PbdObjectCellRemoval > m_cellRemover
Cell remover for removing cells.
Definition: imstkTearable.h:59
A Behaviour represents a single component system A template is used here for UpdateInfo to keep the C...
Defines the behaviour to allow a mesh to seperate based on strain in a given cell. This class approximates strain using the constraint value in from the PBD solver. This is well defined for line meshes, but the behavior may not be what is expected for surface or tet meshes.
Definition: imstkTearable.h:28
std::shared_ptr< PbdObject > getPbdObject() const
Get the PBD object to be torn.
Definition: imstkTearable.h:38
std::shared_ptr< PbdObject > m_tearableObject
Object being torn.
Definition: imstkTearable.h:58