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
00011 #include <vtkCellArray.h>
00012
00013
00014
00015
00017
00018
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
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
00034
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
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
00060
00061
00062 return actor;
00063 }
00064
00065 #endif