Point Cloud Library (PCL)  1.14.1-dev
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 
22 class Axes : public Object
23 {
24 public:
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  axes_colors->Allocate (6);
37  axes_colors->InsertNextValue (0.0);
38  axes_colors->InsertNextValue (0.0);
39  axes_colors->InsertNextValue (0.5);
40  axes_colors->InsertNextValue (0.5);
41  axes_colors->InsertNextValue (1.0);
42  axes_colors->InsertNextValue (1.0);
43 
44  vtkSmartPointer<vtkPolyData> axes_data = axes_->GetOutput ();
45  axes_data->GetPointData ()->SetScalars (axes_colors);
46 
48  axes_tubes->SetInputData (axes_data);
49  axes_tubes->SetRadius (axes_->GetScaleFactor () / 100.0);
50  axes_tubes->SetNumberOfSides (6);
51 
53  axes_mapper->SetScalarModeToUsePointData ();
54  axes_mapper->SetInputData (axes_tubes->GetOutput ());
55 
56  axes_actor_ = vtkSmartPointer<vtkActor>::New ();
57  axes_actor_->GetProperty ()->SetLighting (false);
58  axes_actor_->SetMapper (axes_mapper);
59 
60  addActor (axes_actor_);
61  }
62 
63  // Accessors
64  // -----------------------------------------------------------------------------
66  getAxes () const
67  {
68  return axes_;
69  }
70 
72  getAxesActor () const
73  {
74  return axes_actor_;
75  }
76 
77 private:
78 
79  // Members
80  // -----------------------------------------------------------------------------
82  vtkSmartPointer<vtkActor> axes_actor_;
83 
84 };
Definition: axes.h:23
vtkSmartPointer< vtkAxes > getAxes() const
Definition: axes.h:66
vtkSmartPointer< vtkActor > getAxesActor() const
Definition: axes.h:72
Axes(std::string name, float size=1.0)
Definition: axes.h:28
Definition: object.h:19
void addActor(vtkActor *actor)