DeformableCollisionRepresentation.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_PHYSICS_DEFORMABLECOLLISIONREPRESENTATION_H
17 #define SURGSIM_PHYSICS_DEFORMABLECOLLISIONREPRESENTATION_H
18 
19 #include <memory>
20 #include <string>
21 
24 
25 namespace SurgSim
26 {
27 namespace DataStructures
28 {
29 class TriangleMesh;
30 }
31 
32 namespace Math
33 {
34 class Shape;
35 class MeshShape;
36 }
37 
38 namespace Physics
39 {
40 class DeformableRepresentation;
41 
42 SURGSIM_STATIC_REGISTRATION(DeformableCollisionRepresentation);
43 
48 {
49 public:
50 
53  explicit DeformableCollisionRepresentation(const std::string& name);
54 
57 
59 
64  void setMesh(std::shared_ptr<SurgSim::DataStructures::TriangleMesh> mesh);
65 
67  std::shared_ptr<SurgSim::DataStructures::TriangleMesh> getMesh() const;
68 
72  void setShape(std::shared_ptr<SurgSim::Math::Shape> shape);
73 
74  virtual const std::shared_ptr<SurgSim::Math::Shape> getShape() const override;
75 
78  void setDeformableRepresentation(std::shared_ptr<SurgSim::Physics::DeformableRepresentation> representation);
79 
81  const std::shared_ptr<SurgSim::Physics::DeformableRepresentation> getDeformableRepresentation() const;
82 
83  virtual int getShapeType() const override;
84 
85  virtual void update(const double& dt) override;
86 
87 private:
88  virtual bool doInitialize() override;
89  virtual bool doWakeUp() override;
90 
92  std::shared_ptr<SurgSim::Math::MeshShape> m_shape;
93 
95  std::shared_ptr<SurgSim::DataStructures::TriangleMesh> m_mesh;
96 
98  std::weak_ptr<SurgSim::Physics::DeformableRepresentation> m_deformable;
99 };
100 
101 } // namespace Physics
102 } // namespace SurgSim
103 
104 #endif
SURGSIM_CLASSNAME(SurgSim::Physics::DeformableCollisionRepresentation)
Definition: DriveElementFromInputBehavior.cpp:27
void setShape(std::shared_ptr< SurgSim::Math::Shape > shape)
Set the shape for this collision representation, has to be a SurgSim::Math::MeshShape.
Definition: DeformableCollisionRepresentation.cpp:114
std::shared_ptr< SurgSim::DataStructures::TriangleMesh > m_mesh
Mesh used for collision detection.
Definition: DeformableCollisionRepresentation.h:95
void setDeformableRepresentation(std::shared_ptr< SurgSim::Physics::DeformableRepresentation > representation)
Sets the deformable to which this collision representation is connected.
Definition: DeformableCollisionRepresentation.cpp:129
virtual bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: DeformableCollisionRepresentation.cpp:91
A collision representation that can be attached to a deformable, when this contains a mesh with the s...
Definition: DeformableCollisionRepresentation.h:47
DeformableCollisionRepresentation(const std::string &name)
Constructor.
Definition: DeformableCollisionRepresentation.cpp:33
virtual void update(const double &dt) override
Update the representation.
Definition: DeformableCollisionRepresentation.cpp:58
std::shared_ptr< SurgSim::Math::MeshShape > m_shape
Shape used for collision detection.
Definition: DeformableCollisionRepresentation.h:92
const std::shared_ptr< SurgSim::Physics::DeformableRepresentation > getDeformableRepresentation() const
Definition: DeformableCollisionRepresentation.cpp:136
std::shared_ptr< SurgSim::DataStructures::TriangleMesh > getMesh() const
Definition: DeformableCollisionRepresentation.cpp:53
virtual bool doInitialize() override
Interface to be implemented by derived classes.
Definition: DeformableCollisionRepresentation.cpp:79
virtual const std::shared_ptr< SurgSim::Math::Shape > getShape() const override
Get the shape.
Definition: DeformableCollisionRepresentation.cpp:124
Wrapper class to use for the collision operation, handles its enclosed shaped and a possible local to...
Definition: Representation.h:52
std::weak_ptr< SurgSim::Physics::DeformableRepresentation > m_deformable
Reference to the deformable driving changes to this mesh.
Definition: DeformableCollisionRepresentation.h:98
void setMesh(std::shared_ptr< SurgSim::DataStructures::TriangleMesh > mesh)
Set the mesh to be used in this collision representation the vertices in the mesh need to be the same...
Definition: DeformableCollisionRepresentation.cpp:44
virtual ~DeformableCollisionRepresentation()
Destructor.
Definition: DeformableCollisionRepresentation.cpp:40
virtual int getShapeType() const override
Get the shape type id.
Definition: DeformableCollisionRepresentation.cpp:108
SURGSIM_STATIC_REGISTRATION(DeformableCollisionRepresentation)