opensurgsim
OctreeShape.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_OCTREESHAPE_H
17 #define SURGSIM_MATH_OCTREESHAPE_H
18 
19 #include "SurgSim/DataStructures/EmptyData.h"
20 #include "SurgSim/DataStructures/OctreeNode.h"
21 #include "SurgSim/Framework/Asset.h"
22 #include "SurgSim/Framework/ObjectFactory.h"
23 #include "SurgSim/Math/Shape.h"
24 
25 namespace SurgSim
26 {
27 
28 namespace Math
29 {
30 SURGSIM_STATIC_REGISTRATION(OctreeShape);
31 
34 class OctreeShape : public Shape
35 {
36 public:
38 
40  OctreeShape();
41 
42  SURGSIM_CLASSNAME(SurgSim::Math::OctreeShape);
43 
49  template<class T>
51 
53  virtual ~OctreeShape();
54 
56  int getType() const override;
57 
60  double getVolume() const override;
61 
64  Vector3d getCenter() const override;
65 
69  Matrix33d getSecondMomentOfVolume() const override;
70 
73  std::shared_ptr<NodeType> getOctree();
74 
77  void setOctree(std::shared_ptr<SurgSim::Framework::Asset> node);
78 
80  bool isValid() const override;
81 
82  void loadOctree(const std::string& filePath);
83 
84  const Math::Aabbd& getBoundingBox() const override;
85 
86 private:
87 
90  bool isValid(std::shared_ptr<NodeType> node) const;
91 
93  std::shared_ptr<NodeType> m_rootNode;
94 };
95 
96 }; // Math
97 }; // SurgSim
98 
99 #include "SurgSim/Math/OctreeShape-inl.h"
100 
101 #endif // SURGSIM_MATH_OCTREESHAPE_H
virtual ~OctreeShape()
Destructor.
Definition: OctreeShape.cpp:42
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
int getType() const override
Definition: OctreeShape.cpp:46
std::shared_ptr< NodeType > getOctree()
Get the root node.
Definition: OctreeShape.cpp:79
void setOctree(std::shared_ptr< SurgSim::Framework::Asset > node)
Set the root node.
Definition: OctreeShape.cpp:84
Matrix33d getSecondMomentOfVolume() const override
Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix...
Definition: OctreeShape.cpp:73
double getVolume() const override
Get the volume of the shape.
Definition: OctreeShape.cpp:62
bool isValid() const override
Definition: OctreeShape.cpp:100
OctreeShape()
Constructor.
Definition: OctreeShape.cpp:29
Vector3d getCenter() const override
Get the volumetric center of the shape.
Definition: OctreeShape.cpp:68
Octree data structure.
Definition: OctreeNode.h:131
Octree Shape A defined by an octree data structure.
Definition: OctreeShape.h:34
Generic rigid shape class defining a shape.
Definition: Shape.h:65
const Math::Aabbd & getBoundingBox() const override
Definition: OctreeShape.cpp:105