SegmentMeshShape.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_MATH_SEGMENTMESHSHAPE_H
#define SURGSIM_MATH_SEGMENTMESHSHAPE_H
#include "SurgSim/DataStructures/AabbTree.h"
#include "SurgSim/DataStructures/SegmentMesh.h"
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Math/Geometry.h"
#include "SurgSim/Math/Shape.h"
namespace SurgSim
{
namespace Math
{
SURGSIM_STATIC_REGISTRATION(SegmentMeshShape);
class SegmentMeshShape : public Shape, public DataStructures::SegmentMeshPlain
{
public:
SegmentMeshShape();
explicit SegmentMeshShape(const SegmentMeshShape& other);
template <class VertexData, class EdgeData>
explicit SegmentMeshShape(const DataStructures::SegmentMesh<VertexData, EdgeData>& mesh,
double radius = Geometry::DistanceEpsilon);
SURGSIM_CLASSNAME(SurgSim::Math::SegmentMeshShape);
int getType() const override;
double getVolume() const override;
Vector3d getCenter() const override;
Matrix33d getSecondMomentOfVolume() const override;
bool isValid() const override;
void setRadius(double radius);
double getRadius() const;
std::shared_ptr<const DataStructures::AabbTree> getAabbTree() const;
bool isTransformable() const override;
std::shared_ptr<Shape> getTransformed(const RigidTransform3d& pose) const override;
protected:
bool doUpdate() override;
bool doLoad(const std::string& fileName) override;
void updateAabbTree();
private:
double m_radius;
std::shared_ptr<DataStructures::AabbTree> m_aabbTree;
Vector3d m_segmentEndBoundingBoxHalfExtent;
};
} // Math
} // SurgSim
#include "SurgSim/Math/SegmentMeshShape-inl.h"
#endif // SURGSIM_MATH_SEGMENTMESHSHAPE_H
SurgSim::Math::SegmentMeshShape::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Math::SegmentMeshShape)
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::SegmentMeshShape::getAabbTree
std::shared_ptr< const DataStructures::AabbTree > getAabbTree() const
Definition: SegmentMeshShape.cpp:115
SurgSim::Math::SegmentMeshShape::m_radius
double m_radius
Segment radius.
Definition: SegmentMeshShape.h:84
SurgSim::Math::SegmentMeshShape::setRadius
void setRadius(double radius)
Definition: SegmentMeshShape.cpp:76
SurgSim::Math::Shape::Vector3d
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:68
SurgSim::Math::SegmentMeshShape::SegmentMeshShape
SegmentMeshShape()
Constructor.
Definition: SegmentMeshShape.cpp:32
SurgSim::Math::SegmentMeshShape::isValid
bool isValid() const override
Check if the shape is valid.
Definition: SegmentMeshShape.cpp:68
ObjectFactory.h
SegmentMeshShape-inl.h
SurgSim::Math::SegmentMeshShape::m_aabbTree
std::shared_ptr< DataStructures::AabbTree > m_aabbTree
The aabb tree used to accelerate collision detection against the mesh.
Definition: SegmentMeshShape.h:87
SegmentMesh.h
SurgSim::DataStructures::SegmentMesh
Class to hold the type of a SegmentMesh.
Definition: SegmentMesh.h:33
SurgSim::Math::SegmentMeshShape::getCenter
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: SegmentMeshShape.cpp:56
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Math::SegmentMeshShape::doLoad
bool doLoad(const std::string &fileName) override
Derived classes will overwrite this method to do actual loading.
Definition: SegmentMeshShape.cpp:93
SurgSim::Math::SegmentMeshShape::getRadius
double getRadius() const
Definition: SegmentMeshShape.cpp:82
SurgSim::Math::SegmentMeshShape::m_segmentEndBoundingBoxHalfExtent
Vector3d m_segmentEndBoundingBoxHalfExtent
Half extent of the AABB of the sphere at one of the segment end.
Definition: SegmentMeshShape.h:90
AabbTree.h
SurgSim::Math::SegmentMeshShape
SegmentMeshShape defines a shape based on a mesh, like MeshShape.
Definition: SegmentMeshShape.h:36
SurgSim::Math::Shape::Matrix33d
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
SurgSim::Math::SegmentMeshShape::getType
int getType() const override
Definition: SegmentMeshShape.cpp:45
SurgSim::Math::SegmentMeshShape::updateAabbTree
void updateAabbTree()
Update the AabbTree, which is an axis-aligned bounding box r-tree used to accelerate spatial searches...
Definition: SegmentMeshShape.cpp:128
Shape.h
SurgSim::Math::SegmentMeshShape::getTransformed
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
SurgSim::Math::SegmentMeshShape::getSecondMomentOfVolume
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
SurgSim::Math::SegmentMeshShape::getVolume
double getVolume() const override
Get the volume of the shape.
Definition: SegmentMeshShape.cpp:50
SurgSim::Math::SegmentMeshShape::doUpdate
bool doUpdate() override
Performs any updates that are required when the vertices are modified.
Definition: SegmentMeshShape.cpp:87
Geometry.h
a collection of functions that calculation geometric properties of various basic geometric shapes...
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:65
SurgSim::Math::SegmentMeshShape::isTransformable
bool isTransformable() const override
Definition: SegmentMeshShape.cpp:152