opensurgsim
ParticlesShape.h
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 
21 #include "SurgSim/DataStructures/EmptyData.h"
22 #include "SurgSim/DataStructures/Vertices.h"
23 #include "SurgSim/Framework/ObjectFactory.h"
24 #include "SurgSim/Math/Matrix.h"
25 #include "SurgSim/Math/Shape.h"
26 #include "SurgSim/Math/Vector.h"
27 #include "SurgSim/Math/VerticesShape.h"
28 
29 namespace SurgSim
30 {
31 namespace DataStructures
32 {
33 class AabbTree;
34 };
35 
36 namespace Math
37 {
38 
39 SURGSIM_STATIC_REGISTRATION(ParticlesShape);
40 
42 class ParticlesShape : public VerticesShape, public SurgSim::DataStructures::Vertices<DataStructures::EmptyData>
43 {
44 public:
47  explicit ParticlesShape(double radius = 0.0);
48 
51  explicit ParticlesShape(const ParticlesShape& other);
52 
56  template <class V>
58 
62  template <class V>
63  ParticlesShape& operator=(const Vertices<V>& other);
64 
65  SURGSIM_CLASSNAME(SurgSim::Math::ParticlesShape);
66 
69  const std::shared_ptr<const SurgSim::DataStructures::AabbTree> getAabbTree() const;
70 
73  void setRadius(double radius);
74 
77  double getRadius() const;
78 
79  int getType() const override;
80 
81  double getVolume() const override;
82 
83  Vector3d getCenter() const override;
84 
85  Matrix33d getSecondMomentOfVolume() const override;
86 
87  std::shared_ptr<Shape> getTransformed(const RigidTransform3d& pose) const override;
88 
89  bool isValid() const override;
90 
91  const Math::Aabbd& getBoundingBox() const override;
92 
93  void setPose(const RigidTransform3d& pose) override;
94 
95  void updateShape() override;
96  void updateShapePartial() override;
97 
98 private:
99  bool doUpdate() override;
100 
102  std::shared_ptr<SurgSim::DataStructures::AabbTree> m_aabbTree;
103 
105  double m_radius;
106 
108  Vector3d m_center;
109 
111  double m_volume = std::numeric_limits<double>::signaling_NaN();
112 
114  Matrix33d m_secondMomentOfVolume;
115 };
116 
117 };
118 };
119 
120 #include "SurgSim/Math/ParticlesShape-inl.h"
121 
122 #endif // SURGSIM_MATH_PARTICLESSHAPE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
A Shape that also inherits from Vertices is transformable and carries a member variable of the initia...
Definition: VerticesShape.h:30
Definitions of small fixed-size square matrix types.
Definitions of small fixed-size vector types.
bool isValid(float value)
Check if a float value is valid.
Definition: Valid-inl.h:97
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51
Particles Shape: A shape consisting of a group of particles of equal radius.
Definition: ParticlesShape.h:42