Point Cloud Library (PCL) 1.15.1-dev
Loading...
Searching...
No Matches
axes.h
1#pragma once
2
3// C++
4#include <iostream>
5#include <string>
6
7// PCL
8#include "object.h"
9
10// VTK
11#include <vtkVersion.h>
12#include <vtkActor.h>
13#include <vtkTubeFilter.h>
14#include <vtkAxes.h>
15//#include <vtkDataSetMapper.h>
16#include <vtkFloatArray.h>
17#include <vtkProperty.h>
18#include <vtkPolyData.h>
19#include <vtkPolyDataMapper.h>
20#include <vtkSmartPointer.h>
21
22class Axes : public Object
23{
24public:
25
26 // Operators
27 // -----------------------------------------------------------------------------
28 Axes (std::string name, float size = 1.0) :
29 Object (name), axes_ (vtkSmartPointer<vtkAxes>::New ())
30 {
31 axes_->SetOrigin (0, 0, 0);
32 axes_->SetScaleFactor (size);
33 axes_->Update ();
34
36#if (VTK_MAJOR_VERSION > 9) || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 7)
37 axes_colors->ReserveValues (6);
38#else
39 axes_colors->Allocate (6);
40#endif
41 axes_colors->InsertNextValue (0.0);
42 axes_colors->InsertNextValue (0.0);
43 axes_colors->InsertNextValue (0.5);
44 axes_colors->InsertNextValue (0.5);
45 axes_colors->InsertNextValue (1.0);
46 axes_colors->InsertNextValue (1.0);
47
48 vtkSmartPointer<vtkPolyData> axes_data = axes_->GetOutput ();
49 axes_data->GetPointData ()->SetScalars (axes_colors);
50
52 axes_tubes->SetInputData (axes_data);
53 axes_tubes->SetRadius (axes_->GetScaleFactor () / 100.0);
54 axes_tubes->SetNumberOfSides (6);
55
57 axes_mapper->SetScalarModeToUsePointData ();
58 axes_mapper->SetInputData (axes_tubes->GetOutput ());
59
60 axes_actor_ = vtkSmartPointer<vtkActor>::New ();
61 axes_actor_->GetProperty ()->SetLighting (false);
62 axes_actor_->SetMapper (axes_mapper);
63
64 addActor (axes_actor_);
65 }
66
67 // Accessors
68 // -----------------------------------------------------------------------------
70 getAxes () const
71 {
72 return axes_;
73 }
74
76 getAxesActor () const
77 {
78 return axes_actor_;
79 }
80
81private:
82
83 // Members
84 // -----------------------------------------------------------------------------
86 vtkSmartPointer<vtkActor> axes_actor_;
87
88};
Definition axes.h:23
vtkSmartPointer< vtkActor > getAxesActor() const
Definition axes.h:76
vtkSmartPointer< vtkAxes > getAxes() const
Definition axes.h:70
Axes(std::string name, float size=1.0)
Definition axes.h:28
void addActor(vtkActor *actor)