OsgOctreeRepresentation.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_GRAPHICS_OSGOCTREEREPRESENTATION_H
#define SURGSIM_GRAPHICS_OSGOCTREEREPRESENTATION_H
#include <memory>
#include <string>
#include <osg/ref_ptr>
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Graphics/OctreeRepresentation.h"
#include "SurgSim/Graphics/OsgRepresentation.h"
#include "SurgSim/Math/OctreeShape.h"
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4250)
#endif
namespace SurgSim
{
namespace Graphics
{
class OsgUnitBox;
SURGSIM_STATIC_REGISTRATION(OsgOctreeRepresentation);
class OsgOctreeRepresentation : public OctreeRepresentation, public OsgRepresentation
{
public:
explicit OsgOctreeRepresentation(const std::string& name);
~OsgOctreeRepresentation();
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgOctreeRepresentation);
void doUpdate(double dt) override;
void setOctreeShape(const std::shared_ptr<SurgSim::Math::Shape>& shape) override;
std::shared_ptr<SurgSim::Math::OctreeShape> getOctreeShape() const override;
void setNodeVisible(const SurgSim::DataStructures::OctreePath& path, bool visibility) override;
private:
void buildOctree(osg::ref_ptr<osg::PositionAttitudeTransform> parentTransformNode,
std::shared_ptr<SurgSim::Math::OctreeShape::NodeType> octree);
std::shared_ptr<OsgUnitBox> m_sharedUnitBox;
std::shared_ptr<SurgSim::Math::OctreeShape> m_octreeShape;
static std::shared_ptr<OsgUnitBox> getSharedUnitBox();
};
}; // Graphics
}; // SurgSim
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif // SURGSIM_GRAPHICS_OSGOCTREEREPRESENTATION_H
SurgSim::Graphics::OsgOctreeRepresentation::getSharedUnitBox
static std::shared_ptr< OsgUnitBox > getSharedUnitBox()
Returns the shared unit box.
Definition: OsgOctreeRepresentation.cpp:120
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgOctreeRepresentation::m_octreeShape
std::shared_ptr< SurgSim::Math::OctreeShape > m_octreeShape
The OctreeShape whose Octree will be visualized.
Definition: OsgOctreeRepresentation.h:84
SurgSim::Graphics::OsgOctreeRepresentation::buildOctree
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
ObjectFactory.h
SurgSim::DataStructures::OctreePath
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
SurgSim::Graphics::OsgOctreeRepresentation::setOctreeShape
void setOctreeShape(const std::shared_ptr< SurgSim::Math::Shape > &shape) override
Set the OctreeShape of this representation.
Definition: OsgOctreeRepresentation.cpp:89
SurgSim::Graphics::OsgOctreeRepresentation::~OsgOctreeRepresentation
~OsgOctreeRepresentation()
Destructor.
Definition: OsgOctreeRepresentation.cpp:44
SurgSim::Graphics::OsgOctreeRepresentation::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgOctreeRepresentation)
SurgSim::Graphics::OctreeRepresentation
Graphic representation of an Octree.
Definition: OctreeRepresentation.h:31
OctreeRepresentation.h
SurgSim::Graphics::OsgOctreeRepresentation::doUpdate
void doUpdate(double dt) override
Executes the update operation.
Definition: OsgOctreeRepresentation.cpp:48
SurgSim::Graphics::OsgOctreeRepresentation::getOctreeShape
std::shared_ptr< SurgSim::Math::OctreeShape > getOctreeShape() const override
Definition: OsgOctreeRepresentation.cpp:100
SurgSim::Graphics::OsgOctreeRepresentation
OSG octree representation, implements an OctreeRepresenation using OSG.
Definition: OsgOctreeRepresentation.h:48
OsgRepresentation.h
OctreeShape.h
SurgSim::Graphics::OsgRepresentation
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
SurgSim::Graphics::OsgOctreeRepresentation::setNodeVisible
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
SurgSim::Graphics::OsgOctreeRepresentation::OsgOctreeRepresentation
OsgOctreeRepresentation(const std::string &name)
Constructor.
Definition: OsgOctreeRepresentation.cpp:36
SurgSim::Graphics::OsgOctreeRepresentation::m_sharedUnitBox
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