grid.cpp
Go to the documentation of this file.
00001 // PCL
00002 #include <pcl/outofcore/visualization/geometry.h>
00003 #include <pcl/outofcore/visualization/grid.h>
00004 
00005 // VTK
00006 #include <vtkActor.h>
00007 #include <vtkRectilinearGrid.h>
00008 #include <vtkDoubleArray.h>
00009 #include <vtkProperty.h>
00010 #include <vtkSmartPointer.h>
00011 
00012 // Operators
00013 // -----------------------------------------------------------------------------
00014 Grid::Grid (std::string name, int size/*=10*/, double spacing/*=1.0*/) :
00015     Object (name)
00016 {
00017   grid_ = vtkSmartPointer<vtkRectilinearGrid>::New ();
00018   grid_actor_ = vtkSmartPointer<vtkActor>::New ();
00019 
00020   vtkSmartPointer<vtkDataSetMapper> grid_mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
00021 
00022   vtkSmartPointer<vtkDoubleArray> xz_array = vtkSmartPointer<vtkDoubleArray>::New ();
00023   vtkSmartPointer<vtkDoubleArray> y_array = vtkSmartPointer<vtkDoubleArray>::New ();
00024 
00025   size++;
00026 
00027   // Create a grid
00028   grid_->SetDimensions (size, 1, size);
00029 
00030   // Fill arrays
00031   for (int i = -size / 2; i <= size / 2; i++)
00032     xz_array->InsertNextValue ((double)i * spacing);
00033   y_array->InsertNextValue (0.0);
00034 
00035   grid_->SetXCoordinates (xz_array);
00036   grid_->SetYCoordinates (y_array);
00037   grid_->SetZCoordinates (xz_array);
00038 
00039 #if VTK_MAJOR_VERSION <= 5
00040   grid_mapper->SetInputConnection (grid_->GetProducerPort ());
00041 #else
00042   grid_mapper->SetInputData(grid_);
00043 #endif
00044 
00045   vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New ();
00046   grid_actor_->SetMapper (grid_mapper);
00047 
00048   grid_actor_->GetProperty ()->SetRepresentationToWireframe ();
00049   grid_actor_->GetProperty ()->SetColor (0.5, 0.5, 0.5);
00050   grid_actor_->GetProperty ()->SetLighting (false);
00051 
00052   addActor (grid_actor_);
00053 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:24:36