Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <pcl/apps/modeler/points_actor_item.h>
00038
00039 #include <pcl/apps/modeler/cloud_mesh.h>
00040
00041 #include <vtkVertexGlyphFilter.h>
00042 #include <vtkLODActor.h>
00043 #include <vtkDataSetMapper.h>
00044 #include <vtkPointData.h>
00045 #include <vtkProperty.h>
00046
00047
00049 pcl::modeler::PointsActorItem::PointsActorItem(QTreeWidgetItem* parent,
00050 const boost::shared_ptr<CloudMesh>& cloud_mesh,
00051 const vtkSmartPointer<vtkRenderWindow>& render_window)
00052 :ChannelActorItem(parent, cloud_mesh, render_window, vtkSmartPointer<vtkLODActor>::New(), "Points")
00053 {
00054 }
00055
00057 pcl::modeler::PointsActorItem::~PointsActorItem ()
00058 {
00059
00060 }
00061
00063 void
00064 pcl::modeler::PointsActorItem::initImpl()
00065 {
00066 poly_data_->SetPoints(cloud_mesh_->getVtkPoints());
00067 poly_data_->Update();
00068
00069 vtkSmartPointer<vtkVertexGlyphFilter> vertex_glyph_filter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
00070 #if VTK_MAJOR_VERSION <= 5
00071 vertex_glyph_filter->AddInput(poly_data_);
00072 #else
00073 vertex_glyph_filter->AddInputData(polydata);
00074 #endif
00075 vertex_glyph_filter->Update();
00076
00077 vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
00078 mapper->SetInputConnection(vertex_glyph_filter->GetOutputPort());
00079
00080 vtkSmartPointer<vtkDataArray> scalars;
00081 cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
00082 poly_data_->GetPointData ()->SetScalars (scalars);
00083
00084 double minmax[2];
00085 scalars->GetRange(minmax);
00086 mapper->SetScalarRange(minmax);
00087
00088 mapper->SetScalarModeToUsePointData();
00089 mapper->InterpolateScalarsBeforeMappingOn();
00090 mapper->ScalarVisibilityOn();
00091 mapper->ImmediateModeRenderingOff();
00092
00093 vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
00094 actor->SetMapper(mapper);
00095
00096 actor->SetNumberOfCloudPoints(int(std::max<vtkIdType> (1, poly_data_->GetNumberOfPoints () / 10)));
00097 actor->GetProperty()->SetInterpolationToFlat();
00098 }
00099
00101 void
00102 pcl::modeler::PointsActorItem::updateImpl()
00103 {
00104 vtkSmartPointer<vtkDataArray> scalars;
00105 cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
00106 poly_data_->GetPointData ()->SetScalars (scalars);
00107
00108 double minmax[2];
00109 scalars->GetRange(minmax);
00110 actor_->GetMapper()->SetScalarRange(minmax);
00111
00112 poly_data_->Update();
00113
00114 return;
00115 }
00116
00117
00119 void
00120 pcl::modeler::PointsActorItem::prepareContextMenu(QMenu*) const
00121 {
00122
00123 }
00124
00126 void
00127 pcl::modeler::PointsActorItem::prepareProperties(ParameterDialog*)
00128 {
00129
00130 }
00131
00133 void
00134 pcl::modeler::PointsActorItem::setProperties()
00135 {
00136
00137 }