OsgOctreeRepresentation.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_GRAPHICS_OSGOCTREEREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGOCTREEREPRESENTATION_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include <osg/ref_ptr>
23 
28 
29 #if defined(_MSC_VER)
30 #pragma warning(push)
31 #pragma warning(disable:4250)
32 #endif
33 
34 namespace SurgSim
35 {
36 namespace Graphics
37 {
38 
39 class OsgUnitBox;
40 
41 SURGSIM_STATIC_REGISTRATION(OsgOctreeRepresentation);
42 
49 {
50 public:
53  explicit OsgOctreeRepresentation(const std::string& name);
54 
57 
59 
62  virtual void doUpdate(double dt) override;
63 
64  virtual void setOctreeShape(const std::shared_ptr<SurgSim::Math::Shape>& shape) override;
65  virtual std::shared_ptr<SurgSim::Math::OctreeShape> getOctreeShape() const override;
66 
70  virtual void setNodeVisible(const SurgSim::DataStructures::OctreePath& path, bool visibility) override;
71 
72 private:
77  void buildOctree(osg::ref_ptr<osg::PositionAttitudeTransform> parentTransformNode,
78  std::shared_ptr<SurgSim::Math::OctreeShape::NodeType> octree);
79 
81  std::shared_ptr<OsgUnitBox> m_sharedUnitBox;
82 
84  std::shared_ptr<SurgSim::Math::OctreeShape> m_octreeShape;
85 
87  static std::shared_ptr<OsgUnitBox> getSharedUnitBox();
88 };
89 
90 }; // Graphics
91 }; // SurgSim
92 
93 #if defined(_MSC_VER)
94 #pragma warning(pop)
95 #endif
96 
97 #endif // SURGSIM_GRAPHICS_OSGOCTREEREPRESENTATION_H
static std::shared_ptr< OsgUnitBox > getSharedUnitBox()
Returns the shared unit box.
Definition: OsgOctreeRepresentation.cpp:120
Definition: DriveElementFromInputBehavior.cpp:27
SURGSIM_STATIC_REGISTRATION(OsgBoxRepresentation)
std::shared_ptr< SurgSim::Math::OctreeShape > m_octreeShape
The OctreeShape whose Octree will be visualized.
Definition: OsgOctreeRepresentation.h:84
void buildOctree(osg::ref_ptr< osg::PositionAttitudeTransform > parentTransformNode, std::shared_ptr< SurgSim::Math::OctreeShape::NodeType > octree)
Draw the Octree associated with this OSG representation.
Definition: OsgOctreeRepresentation.cpp:63
std::vector< size_t > OctreePath
Typedef of octree path The path is a vector of children indexes (each within 0 to 7) that lead to the...
Definition: OctreeNode.h:43
virtual void setOctreeShape(const std::shared_ptr< SurgSim::Math::Shape > &shape) override
Set the OctreeShape of this representation.
Definition: OsgOctreeRepresentation.cpp:89
~OsgOctreeRepresentation()
Destructor.
Definition: OsgOctreeRepresentation.cpp:44
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgOctreeRepresentation)
Graphic representation of an Octree.
Definition: OctreeRepresentation.h:31
virtual void doUpdate(double dt) override
Executes the update operation.
Definition: OsgOctreeRepresentation.cpp:48
virtual std::shared_ptr< SurgSim::Math::OctreeShape > getOctreeShape() const override
Definition: OsgOctreeRepresentation.cpp:100
OSG octree representation, implements an OctreeRepresenation using OSG.
Definition: OsgOctreeRepresentation.h:48
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:42
virtual void setNodeVisible(const SurgSim::DataStructures::OctreePath &path, bool visibility) override
Mark the OctreeNode visible/invisible in the given a OctreePath (typedef-ed in OctreeNode.h).
Definition: OsgOctreeRepresentation.cpp:105
OsgOctreeRepresentation(const std::string &name)
Constructor.
Definition: OsgOctreeRepresentation.cpp:36
std::shared_ptr< OsgUnitBox > m_sharedUnitBox
Shared unit box, so that the geometry can be instanced rather than having multiple copies...
Definition: OsgOctreeRepresentation.h:81