points_actor_item.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2012, Willow Garage, Inc.
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of Willow Garage, Inc. nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
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 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:31:03