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