All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceMeshShape.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_MATH_SURFACEMESHSHAPE_H
17 #define SURGSIM_MATH_SURFACEMESHSHAPE_H
18 
22 #include "SurgSim/Math/Shape.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace Math
28 {
29 SURGSIM_STATIC_REGISTRATION(SurfaceMeshShape);
30 
53 class SurfaceMeshShape : public Shape
54 {
55 public:
58 
63  template <class VertexData, class EdgeData, class TriangleData>
66  double thickness = 1e-2);
67 
69 
71  virtual int getType() override;
72 
75  std::shared_ptr<SurgSim::DataStructures::TriangleMesh> getMesh();
76 
79  virtual double getVolume() const override;
80 
83  virtual Vector3d getCenter() const override;
84 
88  virtual Matrix33d getSecondMomentOfVolume() const override;
89 
96  void setFileName(const std::string& fileName);
97 
100  std::string getFileName() const;
101 
105  virtual bool isValid() const override;
106 
107 private:
108 
111  void computeVolumeIntegrals();
112 
115 
117  double m_volume;
118 
121 
123  std::shared_ptr<SurgSim::DataStructures::TriangleMesh> m_mesh;
124 
126  double m_thickness;
127 
129  std::string m_fileName;
130 };
131 
132 }; // Math
133 }; // SurgSim
134 
136 
137 #endif // SURGSIM_MATH_SURFACEMESHSHAPE_H
std::shared_ptr< SurgSim::DataStructures::TriangleMesh > getMesh()
Get mesh.
Definition: SurfaceMeshShape.cpp:55
virtual Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: SurfaceMeshShape.cpp:70
std::string m_fileName
File name of the external file which contains the triangle mesh.
Definition: SurfaceMeshShape.h:129
SURGSIM_STATIC_REGISTRATION(BoxShape)
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:62
virtual int getType() override
Definition: SurfaceMeshShape.cpp:37
SurfaceMeshShape()
Constructor.
Definition: SurfaceMeshShape.cpp:32
SurgSim::Math::Matrix33d m_secondMomentOfVolume
Second moment of volume.
Definition: SurfaceMeshShape.h:120
std::string getFileName() const
Get the file name of the external file which contains the triangle mesh.
Definition: SurfaceMeshShape.cpp:50
void computeVolumeIntegrals()
Compute useful volume integrals based on the triangle mesh, which are used to get the volume ...
Definition: SurfaceMeshShape.cpp:90
virtual double getVolume() const override
Get the volume of the shape.
Definition: SurfaceMeshShape.cpp:60
double m_volume
Volume (in m-3)
Definition: SurfaceMeshShape.h:117
double m_thickness
Surface mesh thickness.
Definition: SurfaceMeshShape.h:126
SURGSIM_CLASSNAME(SurgSim::Math::SurfaceMeshShape)
SurgSim::Math::Vector3d m_center
Center (considering a uniform distribution in the mesh volume)
Definition: SurfaceMeshShape.h:114
SurfaceMeshShape defines a shape based on a mesh, like MeshShape.
Definition: SurfaceMeshShape.h:53
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMeshBase.h:58
void setFileName(const std::string &fileName)
Set loading filename.
Definition: SurfaceMeshShape.cpp:43
virtual Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix...
Definition: SurfaceMeshShape.cpp:80
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:63
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
std::shared_ptr< SurgSim::DataStructures::TriangleMesh > m_mesh
Collision mesh associated to this MeshShape.
Definition: SurfaceMeshShape.h:123
virtual bool isValid() const override
Check if this shape contains a valid mesh and the thickness is at least 1e-5 (in meter, to avoid formal and numerical issues).
Definition: SurfaceMeshShape.cpp:191
Generic rigid shape class defining a shape.
Definition: Shape.h:59