OsgCapsuleRepresentation.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_OSGCAPSULEREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGCAPSULEREPRESENTATION_H
18 
22 
24 
25 #include <osg/PositionAttitudeTransform>
26 
27 #if defined(_MSC_VER)
28 #pragma warning(push)
29 #pragma warning(disable:4250)
30 #endif
31 
32 namespace SurgSim
33 {
34 
35 namespace Graphics
36 {
37 
38 class OsgUnitCylinder;
39 class OsgUnitSphere;
40 
41 SURGSIM_STATIC_REGISTRATION(OsgCapsuleRepresentation);
42 
45 {
46 public:
49  explicit OsgCapsuleRepresentation(const std::string& name);
50 
52 
55  virtual void setRadius(double radius) override;
58  virtual double getRadius() const override;
59 
62  virtual void setHeight(double height) override;
65  virtual double getHeight() const override;
66 
70  virtual void setSize(double radius, double height) override;
74  virtual void getSize(double* radius, double* height) override;
75 
78  virtual void setSize(const SurgSim::Math::Vector2d& size) override;
81  virtual SurgSim::Math::Vector2d getSize() const override;
82 
83 private:
86  osg::Vec2d m_scale;
87 
89  std::shared_ptr<OsgUnitCylinder> m_sharedUnitCylinder;
90  std::shared_ptr<OsgUnitSphere> m_sharedUnitSphere;
92  static std::shared_ptr<OsgUnitCylinder> getSharedUnitCylinder();
93  static std::shared_ptr<OsgUnitSphere> getSharedUnitSphere();
94 
95  osg::ref_ptr<osg::PositionAttitudeTransform> m_patCylinder;
96  osg::ref_ptr<osg::PositionAttitudeTransform> m_patSphere1;
97  osg::ref_ptr<osg::PositionAttitudeTransform> m_patSphere2;
98 };
99 
100 }; // namespace Graphics
101 
102 }; // namespace SurgSim
103 
104 #if defined(_MSC_VER)
105 #pragma warning(pop)
106 #endif
107 
108 #endif // SURGSIM_GRAPHICS_OSGCAPSULEREPRESENTATION_H
Definition: DriveElementFromInputBehavior.cpp:27
osg::Vec2d m_scale
The OSG Capsule shape consist of one unit cylinder and two unit spheres This transform scales it to t...
Definition: OsgCapsuleRepresentation.h:86
OsgCapsuleRepresentation(const std::string &name)
Constructor.
Definition: OsgCapsuleRepresentation.cpp:26
std::shared_ptr< OsgUnitCylinder > m_sharedUnitCylinder
Shared capsule, so that the geometry can be instanced rather than having multiple copies...
Definition: OsgCapsuleRepresentation.h:89
SURGSIM_STATIC_REGISTRATION(OsgBoxRepresentation)
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgCapsuleRepresentation)
osg::ref_ptr< osg::PositionAttitudeTransform > m_patSphere2
Definition: OsgCapsuleRepresentation.h:97
virtual void setRadius(double radius) override
Sets the radius of the capsule.
Definition: OsgCapsuleRepresentation.cpp:51
OSG implementation of a graphics capsule representation.
Definition: OsgCapsuleRepresentation.h:44
virtual double getRadius() const override
Returns the radius of the capsule.
Definition: OsgCapsuleRepresentation.cpp:58
osg::ref_ptr< osg::PositionAttitudeTransform > m_patSphere1
Definition: OsgCapsuleRepresentation.h:96
virtual double getHeight() const override
Returns the height of the capsule.
Definition: OsgCapsuleRepresentation.cpp:70
virtual void setHeight(double height) override
Sets the height of the capsule.
Definition: OsgCapsuleRepresentation.cpp:63
Eigen::Matrix< double, 2, 1 > Vector2d
A 2D vector of doubles.
Definition: Vector.h:52
Base graphics capsule representation class, which defines the basic interface for a capsule that can ...
Definition: CapsuleRepresentation.h:30
osg::ref_ptr< osg::PositionAttitudeTransform > m_patCylinder
Definition: OsgCapsuleRepresentation.h:95
virtual void setSize(double radius, double height) override
Sets the size of the capsule.
Definition: OsgCapsuleRepresentation.cpp:75
virtual SurgSim::Math::Vector2d getSize() const override
Returns the radius of the capsule.
Definition: OsgCapsuleRepresentation.cpp:104
static std::shared_ptr< OsgUnitSphere > getSharedUnitSphere()
Definition: OsgCapsuleRepresentation.cpp:115
std::shared_ptr< OsgUnitSphere > m_sharedUnitSphere
Definition: OsgCapsuleRepresentation.h:90
static std::shared_ptr< OsgUnitCylinder > getSharedUnitCylinder()
Returns the shared geometry.
Definition: OsgCapsuleRepresentation.cpp:109
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:42