axes.h
Go to the documentation of this file.
00001 #ifndef PCL_OUTOFCORE_AXES_H_
00002 #define PCL_OUTOFCORE_AXES_H_
00003 
00004 // C++
00005 #include <iostream>
00006 #include <string>
00007 
00008 // PCL
00009 #include "object.h"
00010 
00011 // VTK
00012 #include <vtkActor.h>
00013 #include <vtkTubeFilter.h>
00014 #include <vtkAxes.h>
00015 //#include <vtkDataSetMapper.h>
00016 #include <vtkFloatArray.h>
00017 #include <vtkProperty.h>
00018 #include <vtkPolyData.h>
00019 #include <vtkPolyDataMapper.h>
00020 #include <vtkSmartPointer.h>
00021 
00022 class Axes : public Object
00023 {
00024 public:
00025 
00026   // Operators
00027   // -----------------------------------------------------------------------------
00028   Axes (std::string name, float size = 1.0) :
00029       Object (name)
00030   {
00031     axes_ = vtkSmartPointer<vtkAxes>::New ();
00032     axes_->SetOrigin (0, 0, 0);
00033     axes_->SetScaleFactor (size);
00034 
00035     vtkSmartPointer<vtkFloatArray> axes_colors = vtkSmartPointer<vtkFloatArray>::New ();
00036     axes_colors->Allocate (6);
00037     axes_colors->InsertNextValue (0.0);
00038     axes_colors->InsertNextValue (0.0);
00039     axes_colors->InsertNextValue (0.5);
00040     axes_colors->InsertNextValue (0.5);
00041     axes_colors->InsertNextValue (1.0);
00042     axes_colors->InsertNextValue (1.0);
00043 
00044     vtkSmartPointer<vtkPolyData> axes_data = axes_->GetOutput ();
00045     axes_data->Update ();
00046     axes_data->GetPointData ()->SetScalars (axes_colors);
00047 
00048     vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New ();
00049     axes_tubes->SetInput (axes_data);
00050     axes_tubes->SetRadius (axes_->GetScaleFactor () / 100.0);
00051     axes_tubes->SetNumberOfSides (6);
00052 
00053     vtkSmartPointer<vtkPolyDataMapper> axes_mapper = vtkSmartPointer<vtkPolyDataMapper>::New ();
00054     axes_mapper->SetScalarModeToUsePointData ();
00055     axes_mapper->SetInput (axes_tubes->GetOutput ());
00056 
00057     axes_actor_ = vtkSmartPointer<vtkActor>::New ();
00058     axes_actor_->GetProperty ()->SetLighting (false);
00059     axes_actor_->SetMapper (axes_mapper);
00060 
00061     addActor (axes_actor_);
00062   }
00063   //~Axes () { }
00064 
00065   // Accessors
00066   // -----------------------------------------------------------------------------
00067   inline vtkSmartPointer<vtkAxes>
00068   getAxes () const
00069   {
00070     return axes_;
00071   }
00072 
00073   vtkSmartPointer<vtkActor>
00074   getAxesActor () const
00075   {
00076     return axes_actor_;
00077   }
00078 
00079 private:
00080 
00081   // Members
00082   // -----------------------------------------------------------------------------
00083   vtkSmartPointer<vtkAxes> axes_;
00084   vtkSmartPointer<vtkActor> axes_actor_;
00085 
00086 };
00087 
00088 #endif
00089 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:22:35