opensurgsim
OsgPointCloudRepresentation.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, 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_OSGPOINTCLOUDREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGPOINTCLOUDREPRESENTATION_H
18 
19 #include <osg/Array>
20 #include <osg/Geometry>
21 #include <osg/Point>
22 
23 #include "SurgSim/Framework/Macros.h"
24 #include "SurgSim/Framework/ObjectFactory.h"
25 #include "SurgSim/Graphics/PointCloudRepresentation.h"
26 #include "SurgSim/Graphics/OsgRepresentation.h"
27 
28 namespace SurgSim
29 {
30 namespace DataStructures
31 {
32 class EmptyData;
33 
34 template<class Data>
35 class Vertices;
36 }
37 
38 namespace Graphics
39 {
40 
41 #if defined(_MSC_VER)
42 #pragma warning(push)
43 #pragma warning(disable:4250)
44 #endif
45 SURGSIM_STATIC_REGISTRATION(OsgPointCloudRepresentation);
46 
49 {
50 public:
53  explicit OsgPointCloudRepresentation(const std::string& name);
54 
57 
59 
60  std::shared_ptr<PointCloud> getVertices() const override;
61 
62  void setPointSize(double val) override;
63 
64  double getPointSize() const override;
65 
66  void doUpdate(double dt) override;
67 
68  void setColor(const SurgSim::Math::Vector4d& color) override;
69 
70  SurgSim::Math::Vector4d getColor() const override;
71 
72 private:
73 
75  std::shared_ptr<PointCloud> m_vertices;
76 
78  osg::ref_ptr<osg::Vec3Array> m_vertexData;
79 
81  osg::ref_ptr<osg::Geometry> m_geometry;
82 
84  osg::ref_ptr<osg::DrawArrays> m_drawArrays;
85 
87  osg::ref_ptr<osg::Point> m_point;
88 
91 
94  void updateGeometry(const DataStructures::VerticesPlain& vertices);
95 };
96 
97 #if defined(_MSC_VER)
98 #pragma warning(pop)
99 #endif
100 
101 }; // Graphics
102 }; // SurgSim
103 
104 #endif // SURGSIM_GRAPHICS_OSGPOINTCLOUDREPRESENTATION_H
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
Osg point cloud representation, implementation of a PointCloudRepresenation using OSG...
Definition: OsgPointCloudRepresentation.h:48
Graphic representation of a point cloud, hase a very basic interface and is intentionally kept generi...
Definition: PointCloudRepresentation.h:36
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51