surface_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/surface_actor_item.h>
00038 
00039 #include <pcl/apps/modeler/cloud_mesh.h>
00040 
00041 #include <vtkLODActor.h>
00042 #include <vtkPolyData.h>
00043 #include <vtkCellArray.h>
00044 #include <vtkDataSetMapper.h>
00045 #include <vtkPointData.h>
00046 #include <vtkProperty.h>
00047 
00049 pcl::modeler::SurfaceActorItem::SurfaceActorItem(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(), "Surface")
00053 {
00054 }
00055 
00057 pcl::modeler::SurfaceActorItem::~SurfaceActorItem ()
00058 {
00059 
00060 }
00061 
00063 void
00064 pcl::modeler::SurfaceActorItem::initImpl()
00065 {
00066   poly_data_->SetPoints(cloud_mesh_->getVtkPoints());
00067   poly_data_->SetStrips(cloud_mesh_->getVtkPolygons());
00068 
00069   vtkSmartPointer<vtkDataArray> scalars;
00070   cloud_mesh_->getColorScalarsFromField(scalars, color_scheme_);
00071   poly_data_->GetPointData ()->SetScalars (scalars);
00072   poly_data_->Update();
00073 
00074   vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
00075   mapper->SetInput(poly_data_);
00076 
00077   double minmax[2];
00078   scalars->GetRange(minmax);
00079   mapper->SetScalarRange(minmax);
00080 
00081   mapper->SetScalarModeToUsePointData ();
00082   mapper->InterpolateScalarsBeforeMappingOn ();
00083   mapper->ScalarVisibilityOn ();
00084   mapper->ImmediateModeRenderingOff ();
00085 
00086   vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>(dynamic_cast<vtkLODActor*>(actor_.GetPointer()));
00087   actor->SetMapper(mapper);
00088 
00089   actor->SetNumberOfCloudPoints(int(std::max<vtkIdType> (1, poly_data_->GetNumberOfPoints () / 10)));
00090   actor->GetProperty ()->SetInterpolationToFlat ();
00091 
00092   actor->GetProperty ()->SetRepresentationToSurface ();
00093   actor->GetProperty ()->BackfaceCullingOn ();
00094   actor->GetProperty ()->EdgeVisibilityOff ();
00095   actor->GetProperty ()->ShadingOff ();
00096 
00097   return;
00098 }
00099 
00101 void
00102 pcl::modeler::SurfaceActorItem::updateImpl()
00103 {
00104   vtkSmartPointer<vtkDataArray> scalars;
00105   cloud_mesh_->getColorScalarsFromField(scalars, "random");
00106   poly_data_->GetPointData ()->SetScalars (scalars);
00107   double minmax[2];
00108   scalars->GetRange(minmax);
00109   actor_->GetMapper()->SetScalarRange(minmax);
00110 
00111   poly_data_->Update();
00112 
00113   return;
00114 }
00115 
00117 void
00118 pcl::modeler::SurfaceActorItem::prepareContextMenu(QMenu *) const
00119 {
00120 
00121 }
00122 
00124 void
00125 pcl::modeler::SurfaceActorItem::prepareProperties(ParameterDialog *)
00126 {
00127 
00128 }
00129 
00131 void
00132 pcl::modeler::SurfaceActorItem::setProperties()
00133 {
00134 
00135 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:34:09