Point Cloud Library (PCL)  1.9.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)
30  {
32  axes_->SetOrigin (0, 0, 0);
33  axes_->SetScaleFactor (size);
34  axes_->Update ();
35 
37  axes_colors->Allocate (6);
38  axes_colors->InsertNextValue (0.0);
39  axes_colors->InsertNextValue (0.0);
40  axes_colors->InsertNextValue (0.5);
41  axes_colors->InsertNextValue (0.5);
42  axes_colors->InsertNextValue (1.0);
43  axes_colors->InsertNextValue (1.0);
44 
45  vtkSmartPointer<vtkPolyData> axes_data = axes_->GetOutput ();
46  axes_data->GetPointData ()->SetScalars (axes_colors);
47 
49  axes_tubes->SetInputData (axes_data);
50  axes_tubes->SetRadius (axes_->GetScaleFactor () / 100.0);
51  axes_tubes->SetNumberOfSides (6);
52 
54  axes_mapper->SetScalarModeToUsePointData ();
55  axes_mapper->SetInputData (axes_tubes->GetOutput ());
56 
57  axes_actor_ = vtkSmartPointer<vtkActor>::New ();
58  axes_actor_->GetProperty ()->SetLighting (false);
59  axes_actor_->SetMapper (axes_mapper);
60 
61  addActor (axes_actor_);
62  }
63  //~Axes () { }
64 
65  // Accessors
66  // -----------------------------------------------------------------------------
68  getAxes () const
69  {
70  return axes_;
71  }
72 
74  getAxesActor () const
75  {
76  return axes_actor_;
77  }
78 
79 private:
80 
81  // Members
82  // -----------------------------------------------------------------------------
84  vtkSmartPointer<vtkActor> axes_actor_;
85 
86 };
Definition: axes.h:22
vtkSmartPointer< vtkAxes > getAxes() const
Definition: axes.h:68
vtkSmartPointer< vtkActor > getAxesActor() const
Definition: axes.h:74
Axes(std::string name, float size=1.0)
Definition: axes.h:28
void addActor(vtkActor *actor)
Definition: object.h:18