opensurgsim
OsgCurveRepresentation.h
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_OSGCURVEREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGCURVEREPRESENTATION_H
18 
19 #include "SurgSim/Graphics/CurveRepresentation.h"
20 #include "SurgSim/Graphics/OsgRepresentation.h"
21 
22 #include <osg/Array>
23 #include <osg/ref_ptr>
24 
25 #if defined(_MSC_VER)
26 #pragma warning(push)
27 #pragma warning(disable:4250)
28 #endif
29 
30 namespace osg
31 {
32 class Geometry;
33 class DrawArrays;
34 }
35 
36 namespace SurgSim
37 {
38 
39 namespace Graphics
40 {
41 
42 SURGSIM_STATIC_REGISTRATION(OsgCurveRepresentation)
43 
44 class OsgCurveRepresentation : public OsgRepresentation, public CurveRepresentation
48 {
49 public:
52  explicit OsgCurveRepresentation(const std::string& name);
53 
54  ~OsgCurveRepresentation();
55 
57 
58  bool doInitialize() override;
59 
60  bool doWakeUp() override;
61 
62  void doUpdate(double dt) override;
63 
64  void setSubdivisions(size_t num) override;
65 
66  size_t getSubdivisions() const override;
67 
68  void setTension(double tension) override;
69 
70  double getTension() const override;
71 
72  void setColor(const SurgSim::Math::Vector4d& color) override;
73 
74  Math::Vector4d getColor() const override;
75 
76  void setWidth(double width) override;
77 
78  double getWidth() const override;
79 
80  void setAntiAliasing(bool val) override;
81 
82  bool isAntiAliasing() const override;
83 
84 private:
85 
88  void updateGraphics(const DataStructures::VerticesPlain& controlPoints);
89 
92  osg::ref_ptr<osg::Geometry> m_geometry;
93  osg::ref_ptr<osg::Vec3Array> m_vertexData;
94  osg::ref_ptr<osg::Vec3Array> m_normalData;
95  osg::ref_ptr<osg::DrawArrays> m_drawArrays;
97 
100  Math::Vector4d m_color;
101  size_t m_subdivision;
102  double m_tension;
103  double m_width;
105 
108  std::vector<Math::Vector3d> m_controlPoints;
109  std::vector<Math::Vector3d> m_vertices;
111 
112 };
113 
114 #if defined(_MSC_VER)
115 #pragma warning(pop)
116 #endif
117 
118 }
119 }
120 
121 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:61
Definition: OsgImGuiHandler.h:8
Implements the CurveRepresentation for OpenSceneGraph, it uses Catmull Rom interpolation, to draw the line as a GL_LINESTRIP.
Definition: OsgCurveRepresentation.h:47