OsgCylinderRepresentation.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_OSGCYLINDERREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGCYLINDERREPRESENTATION_H
18 
22 
23 #include <osg/PositionAttitudeTransform>
24 
25 #if defined(_MSC_VER)
26 #pragma warning(push)
27 #pragma warning(disable:4250)
28 #endif
29 
30 namespace SurgSim
31 {
32 
33 namespace Graphics
34 {
35 class OsgUnitCylinder;
36 
37 SURGSIM_STATIC_REGISTRATION(OsgCylinderRepresentation);
38 
41 {
42 public:
45  explicit OsgCylinderRepresentation(const std::string& name);
46 
48 
51  virtual void setRadius(double radius) override;
54  virtual double getRadius() const override;
55 
58  virtual void setHeight(double height) override;
61  virtual double getHeight() const override;
62 
66  virtual void setSize(double radius, double height) override;
70  virtual void getSize(double* radius, double* height) override;
71 
74  virtual void setSize(const SurgSim::Math::Vector2d& size) override;
77  virtual SurgSim::Math::Vector2d getSize() const override;
78 
79 private:
81  osg::Vec2d m_scale;
82 
84  std::shared_ptr<OsgUnitCylinder> m_sharedUnitCylinder;
86  static std::shared_ptr<OsgUnitCylinder> getSharedUnitCylinder();
87 
88  osg::ref_ptr<osg::PositionAttitudeTransform> m_patCylinder;
89 };
90 
91 }; // namespace Graphics
92 
93 }; // namespace SurgSim
94 
95 #if defined(_MSC_VER)
96 #pragma warning(pop)
97 #endif
98 
99 #endif // SURGSIM_GRAPHICS_OSGCYLINDERREPRESENTATION_H
Definition: DriveElementFromInputBehavior.cpp:27
osg::ref_ptr< osg::PositionAttitudeTransform > m_patCylinder
Definition: OsgCylinderRepresentation.h:88
SURGSIM_STATIC_REGISTRATION(OsgBoxRepresentation)
osg::Vec2d m_scale
The OSG Cylinder shape is a unit Cylinder and this transform scales it to the size set...
Definition: OsgCylinderRepresentation.h:81
virtual SurgSim::Math::Vector2d getSize() const override
Returns the size of the cylinder.
Definition: OsgCylinderRepresentation.cpp:85
OsgCylinderRepresentation(const std::string &name)
Constructor.
Definition: OsgCylinderRepresentation.cpp:34
OSG implementation of a graphics Cylinder representation.
Definition: OsgCylinderRepresentation.h:40
virtual void setSize(double radius, double height) override
Sets the size of the cylinder.
Definition: OsgCylinderRepresentation.cpp:68
Base graphics cylinder representation class, which defines the basic interface for a cylinder that ca...
Definition: CylinderRepresentation.h:31
Eigen::Matrix< double, 2, 1 > Vector2d
A 2D vector of doubles.
Definition: Vector.h:52
static std::shared_ptr< OsgUnitCylinder > getSharedUnitCylinder()
Returns the shared unit cylinder.
Definition: OsgCylinderRepresentation.cpp:90
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgCylinderRepresentation)
std::shared_ptr< OsgUnitCylinder > m_sharedUnitCylinder
Shared unit Cylinder, so that the geometry can be instanced rather than having multiple copies...
Definition: OsgCylinderRepresentation.h:84
virtual double getHeight() const override
Returns the height of the cylinder.
Definition: OsgCylinderRepresentation.cpp:63
virtual void setRadius(double radius) override
Sets the radius of the cylinder.
Definition: OsgCylinderRepresentation.cpp:48
virtual double getRadius() const override
Returns the radius of the cylinder.
Definition: OsgCylinderRepresentation.cpp:53
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:42
virtual void setHeight(double height) override
Sets the height of the cylinder.
Definition: OsgCylinderRepresentation.cpp:58