misc.h
Go to the documentation of this file.
00001 #ifndef PCL_CLOUD_TOOLS_MISC_H_
00002 #define PCL_CLOUD_TOOLS_MISC_H_
00003 
00004 #include <vtkLODActor.h> 
00005 #include <vtkProperty.h> 
00006 #include <vtkPolyDataReader.h>
00007 #include <vtkMaskPoints.h>
00008 #include <vtkSmartPointer.h> 
00009 #include <vtkDataSetMapper.h>
00010 /* #include <vector> */
00011 #include <vtkCellArray.h>
00012 
00013 
00014 
00015 
00017 // Loads a 3D point cloud from a given fileName.
00018 // Returns: a vtkPolyData object containing the point cloud.
00019 vtkPolyData*
00020 load_poly_data_as_data_set (const char* fileName)
00021 {
00022   vtkPolyDataReader* reader = vtkPolyDataReader::New ();
00023   reader->SetFileName (fileName);
00024   reader->Update ();
00025   return reader->GetOutput ();
00026 }
00027 
00029 // ---[ Create a vtkActor from vtkDataSet
00030 vtkActor* create_actor_from_data_set (vtkDataSet *data, double c1, double c2, double c3, bool lod_enable = false)
00031 {
00032   vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
00033   //  vtkSmartPointer<vtkPainterPolyDataMapper> mapper = vtkSmartPointer<vtkPainterPolyDataMapper>::New ();
00034   //vtkSmartPointer<vtkOpenGLPolyDataMapper> mapper = vtkSmartPointer<vtkOpenGLPolyDataMapper>::New ();
00035   mapper->SetInput ((vtkPolyData*)data);
00036   mapper->ScalarVisibilityOff ();
00037   
00038   vtkActor *actor;
00039   if (lod_enable)
00040     {
00041       vtkSmartPointer<vtkMaskPoints> low_mask = vtkSmartPointer<vtkMaskPoints>::New ();
00042       low_mask->SetMaximumNumberOfPoints (data->GetNumberOfPoints () / 16);
00043       actor = vtkLODActor::New ();
00044       reinterpret_cast<vtkLODActor*>(actor)->SetNumberOfCloudPoints (data->GetNumberOfPoints () / 4);
00045       reinterpret_cast<vtkLODActor*>(actor)->SetLowResFilter (low_mask);
00046       actor->GetProperty ()->SetInterpolationToFlat ();
00047     }
00048   else
00049     {
00050       actor = vtkActor::New ();
00051       actor->GetProperty ()->SetInterpolationToPhong ();
00052       //    actor->GetProperty ()->SetInterpolationToFlat ();
00053     }
00054   actor->GetProperty ()->SetColor         (c1, c2, c3);
00055   actor->GetProperty ()->SetAmbientColor  (c1, c2, c3);
00056   actor->GetProperty ()->SetSpecularColor (c1, c2, c3);
00057   actor->GetProperty ()->SetAmbient (0.8);
00058   actor->SetMapper (mapper);
00059   //  actor->GetProperty ()->SetPointSize (0);
00060   //  actor->GetProperty ()->SetRepresentationToPoints ();
00061   //  actor->GetProperty ()->SetRepresentationToSurface();
00062   return actor;
00063 }
00064 
00065 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


pcl_cloud_tools
Author(s): Nico Blodow, Zoltan-Csaba Marton, Dejan Pangercic
autogenerated on Thu May 23 2013 17:11:36