OsgBoxRepresentation.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_OSGBOXREPRESENTATION_H
#define SURGSIM_GRAPHICS_OSGBOXREPRESENTATION_H
#include "SurgSim/Framework/SharedInstance.h"
#include "SurgSim/Framework/ObjectFactory.h"
#include "SurgSim/Graphics/BoxRepresentation.h"
#include "SurgSim/Graphics/OsgRepresentation.h"
#include "SurgSim/Math/RigidTransform.h"
#include <osg/PositionAttitudeTransform>
#include <osg/Switch>
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4250)
#endif
namespace SurgSim
{
namespace Graphics
{
class OsgUnitBox;
SURGSIM_STATIC_REGISTRATION(OsgBoxRepresentation);
class OsgBoxRepresentation : public OsgRepresentation, public BoxRepresentation
{
public:
explicit OsgBoxRepresentation(const std::string& name);
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgBoxRepresentation);
void setSizeX(double sizeX) override;
double getSizeX() const override;
void setSizeY(double sizeY) override;
double getSizeY() const override;
void setSizeZ(double sizeZ) override;
double getSizeZ() const override;
virtual void setSizeXYZ(double sizeX, double sizeY, double sizeZ);
virtual void getSizeXYZ(double* sizeX, double* sizeY, double* sizeZ) const;
void setSize(const SurgSim::Math::Vector3d& size) override;
SurgSim::Math::Vector3d getSize() const override;
private:
osg::Vec3d m_scale;
std::shared_ptr<OsgUnitBox> m_sharedUnitBox;
static std::shared_ptr<OsgUnitBox> getSharedUnitBox();
};
}; // namespace Graphics
}; // namespace SurgSim
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif // SURGSIM_GRAPHICS_OSGBOXREPRESENTATION_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgBoxRepresentation::getSize
SurgSim::Math::Vector3d getSize() const override
Returns the extents of the box.
Definition: OsgBoxRepresentation.cpp:92
BoxRepresentation.h
SurgSim::Graphics::OsgBoxRepresentation::m_sharedUnitBox
std::shared_ptr< OsgUnitBox > m_sharedUnitBox
Shared unit box, so that the geometry can be instanced rather than having multiple copies...
Definition: OsgBoxRepresentation.h:100
ObjectFactory.h
SurgSim::Graphics::OsgBoxRepresentation::getSizeXYZ
virtual void getSizeXYZ(double *sizeX, double *sizeY, double *sizeZ) const
Gets the size of the box.
Definition: OsgBoxRepresentation.cpp:80
SurgSim::Graphics::OsgBoxRepresentation::m_scale
osg::Vec3d m_scale
The OSG box shape is a unit box and this transform scales it to the size set.
Definition: OsgBoxRepresentation.h:97
SurgSim::Graphics::BoxRepresentation
Base graphics box representation class, which defines the basic interface for a box that can be visua...
Definition: BoxRepresentation.h:31
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
SharedInstance.h
SurgSim::Graphics::OsgBoxRepresentation::setSize
void setSize(const SurgSim::Math::Vector3d &size) override
Sets the size of the box.
Definition: OsgBoxRepresentation.cpp:87
SurgSim::Graphics::OsgBoxRepresentation::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgBoxRepresentation)
SurgSim::Graphics::OsgBoxRepresentation::OsgBoxRepresentation
OsgBoxRepresentation(const std::string &name)
Constructor.
Definition: OsgBoxRepresentation.cpp:32
SurgSim::Graphics::OsgBoxRepresentation::getSizeX
double getSizeX() const override
Returns the size along X-axis of the box.
Definition: OsgBoxRepresentation.cpp:48
SurgSim::Graphics::OsgBoxRepresentation
OSG implementation of a graphics box representation.
Definition: OsgBoxRepresentation.h:43
SurgSim::Graphics::OsgBoxRepresentation::setSizeZ
void setSizeZ(double sizeZ) override
Sets the size along Z-axis of the box.
Definition: OsgBoxRepresentation.cpp:63
SurgSim::Graphics::OsgBoxRepresentation::setSizeXYZ
virtual void setSizeXYZ(double sizeX, double sizeY, double sizeZ)
Sets the size of the box.
Definition: OsgBoxRepresentation.cpp:73
SurgSim::Graphics::OsgBoxRepresentation::setSizeX
void setSizeX(double sizeX) override
Sets the size along X-axis of the box.
Definition: OsgBoxRepresentation.cpp:43
OsgRepresentation.h
SurgSim::Graphics::OsgBoxRepresentation::getSizeY
double getSizeY() const override
Returns the size along Y-axis of the box.
Definition: OsgBoxRepresentation.cpp:58
SurgSim::Graphics::OsgBoxRepresentation::getSharedUnitBox
static std::shared_ptr< OsgUnitBox > getSharedUnitBox()
Returns the shared unit box.
Definition: OsgBoxRepresentation.cpp:97
SurgSim::Graphics::OsgBoxRepresentation::setSizeY
void setSizeY(double sizeY) override
Sets the size along Y-axis of the box.
Definition: OsgBoxRepresentation.cpp:53
SurgSim::Graphics::OsgRepresentation
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Graphics::OsgBoxRepresentation::getSizeZ
double getSizeZ() const override
Returns the size along Z-axis of the box.
Definition: OsgBoxRepresentation.cpp:68