OsgBoxRepresentation.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_OSGBOXREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGBOXREPRESENTATION_H
18 
24 
25 #include <osg/PositionAttitudeTransform>
26 #include <osg/Switch>
27 
28 #if defined(_MSC_VER)
29 #pragma warning(push)
30 #pragma warning(disable:4250)
31 #endif
32 
33 namespace SurgSim
34 {
35 
36 namespace Graphics
37 {
38 class OsgUnitBox;
39 
40 SURGSIM_STATIC_REGISTRATION(OsgBoxRepresentation);
41 
44 {
45 public:
48  explicit OsgBoxRepresentation(const std::string& name);
49 
51 
54  void setSizeX(double sizeX) override;
55 
58  double getSizeX() const override;
59 
62  void setSizeY(double sizeY) override;
63 
66  double getSizeY() const override;
67 
70  void setSizeZ(double sizeZ) override;
71 
74  double getSizeZ() const override;
75 
80  virtual void setSizeXYZ(double sizeX, double sizeY, double sizeZ);
85  virtual void getSizeXYZ(double* sizeX, double* sizeY, double* sizeZ) const;
86 
89  void setSize(const SurgSim::Math::Vector3d& size) override;
90 
93  SurgSim::Math::Vector3d getSize() const override;
94 
95 private:
97  osg::Vec3d m_scale;
98 
100  std::shared_ptr<OsgUnitBox> m_sharedUnitBox;
102  static std::shared_ptr<OsgUnitBox> getSharedUnitBox();
103 };
104 
105 }; // namespace Graphics
106 
107 }; // namespace SurgSim
108 
109 #if defined(_MSC_VER)
110 #pragma warning(pop)
111 #endif
112 
113 #endif // SURGSIM_GRAPHICS_OSGBOXREPRESENTATION_H
SurgSim::Graphics::OsgBoxRepresentation::OsgBoxRepresentation
OsgBoxRepresentation(const std::string &name)
Constructor.
Definition: OsgBoxRepresentation.cpp:32
SurgSim::Graphics::OsgBoxRepresentation::getSizeZ
double getSizeZ() const override
Returns the size along Z-axis of the box.
Definition: OsgBoxRepresentation.cpp:68
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
SurgSim::Graphics::OsgBoxRepresentation::getSize
SurgSim::Math::Vector3d getSize() const override
Returns the extents of the box.
Definition: OsgBoxRepresentation.cpp:92
SurgSim::Graphics::OsgBoxRepresentation::getSizeY
double getSizeY() const override
Returns the size along Y-axis of the box.
Definition: OsgBoxRepresentation.cpp:58
BoxRepresentation.h
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
ObjectFactory.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgBoxRepresentation::setSize
void setSize(const SurgSim::Math::Vector3d &size) override
Sets the size of the box.
Definition: OsgBoxRepresentation.cpp:87
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
SurgSim::Graphics::OsgBoxRepresentation::setSizeY
void setSizeY(double sizeY) override
Sets the size along Y-axis of the box.
Definition: OsgBoxRepresentation.cpp:53
SurgSim::Graphics::OsgBoxRepresentation
OSG implementation of a graphics box representation.
Definition: OsgBoxRepresentation.h:43
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
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::OsgBoxRepresentation::setSizeZ
void setSizeZ(double sizeZ) override
Sets the size along Z-axis of the box.
Definition: OsgBoxRepresentation.cpp:63
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
SurgSim::Graphics::OsgBoxRepresentation::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgBoxRepresentation)
SurgSim::Graphics::OsgBoxRepresentation::getSharedUnitBox
static std::shared_ptr< OsgUnitBox > getSharedUnitBox()
Returns the shared unit box.
Definition: OsgBoxRepresentation.cpp:97
SharedInstance.h
OsgRepresentation.h
SurgSim::Graphics::OsgRepresentation
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
SurgSim::Graphics::OsgBoxRepresentation::getSizeX
double getSizeX() const override
Returns the size along X-axis of the box.
Definition: OsgBoxRepresentation.cpp:48