SegmentMeshShape.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_SEGMENTMESHSHAPE_H
17 #define SURGSIM_MATH_SEGMENTMESHSHAPE_H
18 
22 #include "SurgSim/Math/Geometry.h"
23 #include "SurgSim/Math/Shape.h"
24 
25 namespace SurgSim
26 {
27 
28 namespace Math
29 {
30 SURGSIM_STATIC_REGISTRATION(SegmentMeshShape);
31 
37 {
38 public:
41 
44  explicit SegmentMeshShape(const SegmentMeshShape& other);
45 
50  template <class VertexData, class EdgeData>
52  double radius = Geometry::DistanceEpsilon);
53 
55 
56  int getType() const override;
57  double getVolume() const override;
58  Vector3d getCenter() const override;
59  Matrix33d getSecondMomentOfVolume() const override;
60  bool isValid() const override;
61 
63  void setRadius(double radius);
64 
66  double getRadius() const;
67 
69  std::shared_ptr<const DataStructures::AabbTree> getAabbTree() const;
70 
71  bool isTransformable() const override;
72 
73  std::shared_ptr<Shape> getTransformed(const RigidTransform3d& pose) const override;
74 
75 protected:
76  bool doUpdate() override;
77  bool doLoad(const std::string& fileName) override;
78 
80  void updateAabbTree();
81 
82 private:
84  double m_radius;
85 
87  std::shared_ptr<DataStructures::AabbTree> m_aabbTree;
88 
91 };
92 
93 } // Math
94 } // SurgSim
95 
97 
98 #endif // SURGSIM_MATH_SEGMENTMESHSHAPE_H
SURGSIM_CLASSNAME(SurgSim::Math::SegmentMeshShape)
Definition: CompoundShapeToGraphics.cpp:29
std::shared_ptr< const DataStructures::AabbTree > getAabbTree() const
Definition: SegmentMeshShape.cpp:115
double m_radius
Segment radius.
Definition: SegmentMeshShape.h:84
void setRadius(double radius)
Definition: SegmentMeshShape.cpp:76
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:68
SegmentMeshShape()
Constructor.
Definition: SegmentMeshShape.cpp:32
bool isValid() const override
Check if the shape is valid.
Definition: SegmentMeshShape.cpp:68
std::shared_ptr< DataStructures::AabbTree > m_aabbTree
The aabb tree used to accelerate collision detection against the mesh.
Definition: SegmentMeshShape.h:87
Class to hold the type of a SegmentMesh.
Definition: SegmentMesh.h:33
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: SegmentMeshShape.cpp:56
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
bool doLoad(const std::string &fileName) override
Derived classes will overwrite this method to do actual loading.
Definition: SegmentMeshShape.cpp:93
double getRadius() const
Definition: SegmentMeshShape.cpp:82
Vector3d m_segmentEndBoundingBoxHalfExtent
Half extent of the AABB of the sphere at one of the segment end.
Definition: SegmentMeshShape.h:90
SegmentMeshShape defines a shape based on a mesh, like MeshShape.
Definition: SegmentMeshShape.h:36
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
int getType() const override
Definition: SegmentMeshShape.cpp:45
void updateAabbTree()
Update the AabbTree, which is an axis-aligned bounding box r-tree used to accelerate spatial searches...
Definition: SegmentMeshShape.cpp:128
std::shared_ptr< Shape > getTransformed(const RigidTransform3d &pose) const override
Get a copy of this shape with an applied rigid transform.
Definition: SegmentMeshShape.cpp:120
Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix...
Definition: SegmentMeshShape.cpp:62
double getVolume() const override
Get the volume of the shape.
Definition: SegmentMeshShape.cpp:50
bool doUpdate() override
Performs any updates that are required when the vertices are modified.
Definition: SegmentMeshShape.cpp:87
a collection of functions that calculation geometric properties of various basic geometric shapes...
Generic rigid shape class defining a shape.
Definition: Shape.h:65
bool isTransformable() const override
Definition: SegmentMeshShape.cpp:152