MeshShape.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_MESHSHAPE_H
#define SURGSIM_MATH_MESHSHAPE_H
#include <memory>
#include "SurgSim/DataStructures/EmptyData.h"
#include "SurgSim/DataStructures/NormalData.h"
#include "SurgSim/DataStructures/TriangleMesh.h"
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Math/RigidTransform.h"
#include "SurgSim/Math/Shape.h"
namespace SurgSim
{
namespace DataStructures
{
class AabbTree;
}
namespace Math
{
SURGSIM_STATIC_REGISTRATION(MeshShape);
class MeshShape : public Shape, public SurgSim::DataStructures::TriangleMesh<SurgSim::DataStructures::EmptyData,
SurgSim::DataStructures::EmptyData, SurgSim::DataStructures::NormalData>
{
public:
MeshShape();
explicit MeshShape(const MeshShape& other);
template <class V, class E, class T>
explicit MeshShape(const SurgSim::DataStructures::TriangleMesh<V, E, T>& other);
SURGSIM_CLASSNAME(SurgSim::Math::MeshShape);
int getType() const override;
const SurgSim::Math::Vector3d& getNormal(size_t triangleId) const;
double getVolume() const override;
Vector3d getCenter() const override;
Matrix33d getSecondMomentOfVolume() const override;
std::shared_ptr<Shape> getTransformed(const RigidTransform3d& pose) const override;
const std::shared_ptr<const SurgSim::DataStructures::AabbTree> getAabbTree() const;
bool isValid() const override;
bool isTransformable() const override;
protected:
bool doUpdate() override;
bool doLoad(const std::string& fileName) override;
bool calculateNormals();
void updateAabbTree();
virtual void computeVolumeIntegrals();
SurgSim::Math::Vector3d m_center;
double m_volume;
SurgSim::Math::Matrix33d m_secondMomentOfVolume;
private:
std::shared_ptr<SurgSim::DataStructures::AabbTree> m_aabbTree;
};
}; // Math
}; // SurgSim
#include "SurgSim/Math/MeshShape-inl.h"
#endif // SURGSIM_MATH_MESHSHAPE_H
MeshShape-inl.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::Shape::Vector3d
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:68
SurgSim::Math::MeshShape
Mesh shape: shape made of a triangle mesh The triangle mesh needs to be watertight to produce valid v...
Definition: MeshShape.h:54
SurgSim::Math::MeshShape::m_volume
double m_volume
Volume (in m^-3)
Definition: MeshShape.h:119
ObjectFactory.h
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Math::isValid
bool isValid(float value)
Check if a float value is valid.
Definition: Valid-inl.h:98
SurgSim::Math::MeshShape::m_aabbTree
std::shared_ptr< SurgSim::DataStructures::AabbTree > m_aabbTree
The aabb tree used to accelerate collision detection against the mesh.
Definition: MeshShape.h:126
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
NormalData.h
SurgSim::Math::MeshShape::m_secondMomentOfVolume
SurgSim::Math::Matrix33d m_secondMomentOfVolume
Second moment of volume.
Definition: MeshShape.h:122
SurgSim::DataStructures::TriangleMesh
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMesh.h:62
SurgSim::Math::Shape::Matrix33d
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
SurgSim::Math::MeshShape::m_center
SurgSim::Math::Vector3d m_center
Center (considering a uniform distribution in the mesh volume)
Definition: MeshShape.h:116
SurgSim::Math::Matrix33d
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > Matrix33d
A 3x3 matrix of doubles.
Definition: Matrix.h:51
Shape.h
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
TriangleMesh.h
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:65
EmptyData.h