MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / updateColorHandlerIndex

Method updateColorHandlerIndex

visualization/src/pcl_visualizer.cpp:2945–2983  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

2943
2944/////////////////////////////////////////////////////////////////////////////////////////////
2945bool
2946pcl::visualization::PCLVisualizer::updateColorHandlerIndex (const std::string &id, int index)
2947{
2948 auto am_it = cloud_actor_map_->find (id);
2949 if (am_it == cloud_actor_map_->end ())
2950 {
2951 pcl::console::print_warn (stderr, "[updateColorHandlerIndex] PointCloud with id <%s> doesn't exist!\n", id.c_str ());
2952 return (false);
2953 }
2954
2955 std::size_t color_handler_size = am_it->second.color_handlers.size ();
2956 if (!(static_cast<std::size_t>(index) < color_handler_size))
2957 {
2958 pcl::console::print_warn (stderr, "[updateColorHandlerIndex] Invalid index <%d> given! Index must be less than %d.\n", index, static_cast<int>(color_handler_size));
2959 return (false);
2960 }
2961 // Get the handler
2962 PointCloudColorHandler<pcl::PCLPointCloud2>::ConstPtr color_handler = am_it->second.color_handlers[index];
2963
2964 auto scalars = color_handler->getColor ();
2965 double minmax[2];
2966 scalars->GetRange (minmax);
2967 // Update the data
2968 auto *data = dynamic_cast<vtkPolyData*>(am_it->second.actor->GetMapper ()->GetInput ());
2969 data->GetPointData ()->SetScalars (scalars);
2970 // Modify the mapper
2971 auto* mapper = dynamic_cast<vtkDataSetMapper*>(am_it->second.actor->GetMapper ());
2972 mapper->SetScalarRange (minmax);
2973 mapper->SetScalarModeToUsePointData ();
2974 mapper->SetInputData (data);
2975 // Modify the actor
2976 am_it->second.actor->SetMapper (mapper);
2977 am_it->second.actor->Modified ();
2978 am_it->second.color_handler_index_ = index;
2979
2980 //style_->setCloudActorMap (cloud_actor_map_);
2981
2982 return (true);
2983}
2984
2985
2986

Callers 2

mainFunction · 0.80
TESTFunction · 0.80

Calls 4

findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
getColorMethod · 0.45

Tested by 1

TESTFunction · 0.64