ParticlesShape.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_PARTICLESSHAPE_H
17 #define SURGSIM_MATH_PARTICLESSHAPE_H
18 
19 #include <memory>
20 
24 #include "SurgSim/Math/Matrix.h"
25 #include "SurgSim/Math/Shape.h"
26 #include "SurgSim/Math/Vector.h"
27 
28 namespace SurgSim
29 {
30 namespace DataStructures
31 {
32 class AabbTree;
33 };
34 
35 namespace Math
36 {
37 
38 SURGSIM_STATIC_REGISTRATION(ParticlesShape);
39 
41 class ParticlesShape : public Shape, public SurgSim::DataStructures::Vertices<DataStructures::EmptyData>
42 {
43 public:
46  explicit ParticlesShape(double radius = 0.0);
47 
50  explicit ParticlesShape(const ParticlesShape& other);
51 
55  template <class V>
57 
61  template <class V>
62  ParticlesShape& operator=(const Vertices<V>& other);
63 
65 
68  const std::shared_ptr<const SurgSim::DataStructures::AabbTree> getAabbTree() const;
69 
72  void setRadius(double radius);
73 
76  double getRadius() const;
77 
78  int getType() const override;
79 
80  double getVolume() const override;
81 
82  Vector3d getCenter() const override;
83 
84  Matrix33d getSecondMomentOfVolume() const override;
85 
86  std::shared_ptr<Shape> getTransformed(const RigidTransform3d& pose) const override;
87 
88  bool isValid() const override;
89 
90  bool isTransformable() const override;
91 
92  const Math::Aabbd& getBoundingBox() const override;
93 
94 private:
95  bool doUpdate() override;
96 
98  std::shared_ptr<SurgSim::DataStructures::AabbTree> m_aabbTree;
99 
101  double m_radius;
102 
105 
107  double m_volume;
108 
111 };
112 
113 };
114 };
115 
117 
118 #endif // SURGSIM_MATH_PARTICLESSHAPE_H
Shape.h
SurgSim::Math::ParticlesShape::getType
int getType() const override
Definition: ParticlesShape.cpp:46
SurgSim::Math::ParticlesShape::doUpdate
bool doUpdate() override
Performs any updates that are required when the vertices are modified.
Definition: ParticlesShape.cpp:81
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Math::ParticlesShape::m_center
Vector3d m_center
Volumetric center of particles.
Definition: ParticlesShape.h:104
SurgSim::Math::ParticlesShape
Particles Shape: A shape consisting of a group of particles of equal radius.
Definition: ParticlesShape.h:42
SurgSim::DataStructures::Vertices
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:52
Vertices.h
SurgSim::Math::ParticlesShape::isTransformable
bool isTransformable() const override
Definition: ParticlesShape.cpp:131
ParticlesShape-inl.h
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Math::ParticlesShape::getBoundingBox
const Math::Aabbd & getBoundingBox() const override
Definition: ParticlesShape.cpp:136
SurgSim::Math::ParticlesShape::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Math::ParticlesShape)
SurgSim::Math::Shape::Matrix33d
::SurgSim::Math::Matrix33d Matrix33d
Definition: Shape.h:69
Matrix.h
Definitions of small fixed-size square matrix types.
SurgSim::Math::ParticlesShape::getTransformed
std::shared_ptr< Shape > getTransformed(const RigidTransform3d &pose) const override
Get a copy of this shape with an applied rigid transform.
Definition: ParticlesShape.cpp:118
SurgSim::Math::ParticlesShape::m_radius
double m_radius
Particles' radius.
Definition: ParticlesShape.h:101
EmptyData.h
ObjectFactory.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Math::ParticlesShape::getRadius
double getRadius() const
Get the radius of the particles.
Definition: ParticlesShape.cpp:71
SurgSim::Math::ParticlesShape::getCenter
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: ParticlesShape.cpp:56
SurgSim::Math::ParticlesShape::getVolume
double getVolume() const override
Get the volume of the shape.
Definition: ParticlesShape.cpp:51
SurgSim::Math::Aabbd
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
SurgSim::Math::ParticlesShape::m_aabbTree
std::shared_ptr< SurgSim::DataStructures::AabbTree > m_aabbTree
The aabb tree of the ParticlesShape.
Definition: ParticlesShape.h:98
SurgSim::Math::ParticlesShape::m_volume
double m_volume
Total volume of particles.
Definition: ParticlesShape.h:107
SurgSim::Math::ParticlesShape::ParticlesShape
ParticlesShape(double radius=0.0)
Constructor.
Definition: ParticlesShape.cpp:29
SurgSim::Math::ParticlesShape::m_secondMomentOfVolume
Matrix33d m_secondMomentOfVolume
Second moment of volume.
Definition: ParticlesShape.h:110
SurgSim::Math::ParticlesShape::getSecondMomentOfVolume
Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix.
Definition: ParticlesShape.cpp:61
SurgSim::Math::ParticlesShape::getAabbTree
const std::shared_ptr< const SurgSim::DataStructures::AabbTree > getAabbTree() const
Get the AabbTree.
Definition: ParticlesShape.cpp:126
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:66
SurgSim::Math::Shape::Vector3d
::SurgSim::Math::Vector3d Vector3d
Definition: Shape.h:68
SurgSim::Math::ParticlesShape::isValid
bool isValid() const override
Check if the shape is valid.
Definition: ParticlesShape.cpp:66
SurgSim::Math::ParticlesShape::setRadius
void setRadius(double radius)
Set the particles' radius.
Definition: ParticlesShape.cpp:76
SurgSim::Math::ParticlesShape::operator=
ParticlesShape & operator=(const Vertices< V > &other)
Assignment when the template data is a different type.