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

Method fromHandlersToScreen

visualization/src/pcl_visualizer.cpp:4027–4088  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

4025
4026//////////////////////////////////////////////////////////////////////////////////////////////
4027bool
4028pcl::visualization::PCLVisualizer::fromHandlersToScreen (
4029 const GeometryHandlerConstPtr &geometry_handler,
4030 const ColorHandlerConstPtr &color_handler,
4031 const std::string &id,
4032 int viewport,
4033 const Eigen::Vector4f& sensor_origin,
4034 const Eigen::Quaternion<float>& sensor_orientation)
4035{
4036 if (!geometry_handler->isCapable ())
4037 {
4038 PCL_WARN ("[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n", id.c_str (), geometry_handler->getName ().c_str ());
4039 return (false);
4040 }
4041
4042 if (!color_handler->isCapable ())
4043 {
4044 PCL_WARN ("[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n", id.c_str (), color_handler->getName ().c_str ());
4045 return (false);
4046 }
4047
4048 vtkSmartPointer<vtkPolyData> polydata;
4049 vtkSmartPointer<vtkIdTypeArray> initcells;
4050
4051 // Convert the PointCloud to VTK PolyData
4052 convertPointCloudToVTKPolyData (geometry_handler, polydata, initcells);
4053
4054 // Get the colors from the handler
4055 bool has_colors = false;
4056 double minmax[2];
4057 if (auto scalars = color_handler->getColor ())
4058 {
4059 polydata->GetPointData ()->SetScalars (scalars);
4060 scalars->GetRange (minmax);
4061 has_colors = true;
4062 }
4063
4064 // Create an Actor
4065 vtkSmartPointer<vtkLODActor> actor;
4066 createActorFromVTKDataSet (polydata, actor);
4067 if (has_colors)
4068 actor->GetMapper ()->SetScalarRange (minmax);
4069
4070 // Add it to all renderers
4071 addActorToRenderer (actor, viewport);
4072
4073 // Save the pointer/ID pair to the global actor map
4074 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
4075 cloud_actor.actor = actor;
4076 cloud_actor.cells = reinterpret_cast<vtkPolyDataMapper*>(actor->GetMapper ())->GetInput ()->GetVerts ()->GetData ();
4077 cloud_actor.geometry_handlers.push_back (geometry_handler);
4078 cloud_actor.color_handlers.push_back (color_handler);
4079
4080 // Save the viewpoint transformation matrix to the global actor map
4081 vtkSmartPointer<vtkMatrix4x4> transformation = vtkSmartPointer<vtkMatrix4x4>::New ();
4082 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
4083 cloud_actor.viewpoint_transformation_ = transformation;
4084 cloud_actor.actor->SetUserMatrix (transformation);

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
isCapableMethod · 0.45
getNameMethod · 0.45
getColorMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected