Skip to content

Commit

Permalink
Added check for rgba field in pcl_visualizer.hpp and removed extraneo…
Browse files Browse the repository at this point in the history
…us check for rgba field in PointCloudColorHandlerRGBField in response to comment by taketwo in pull request #1295.
  • Loading branch information
indianajohn-aemass committed Aug 11, 2015
1 parent 609399e commit 0f5f3ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,13 @@ pcl::visualization::PCLVisualizer::addPointCloud (
return (false);
}

if (pcl::traits::has_field<PointT, pcl::fields::rgb>::value)
if (pcl::traits::has_field<PointT, pcl::fields::rgb>::value || pcl::traits::has_field<PointT, pcl::fields::rgba>::value)
{
PointCloudColorHandlerRGBField<PointT> color_handler_rgb_field (cloud);
return (fromHandlersToScreen (geometry_handler, color_handler_rgb_field, id, viewport, cloud->sensor_origin_, cloud->sensor_orientation_));
}
else
{
PointCloudColorHandlerCustom<PointT> color_handler (cloud, 255, 255, 255);
return (fromHandlersToScreen (geometry_handler, color_handler, id, viewport, cloud->sensor_origin_, cloud->sensor_orientation_));
}
PointCloudColorHandlerCustom<PointT> color_handler (cloud, 255, 255, 255);
return (fromHandlersToScreen (geometry_handler, color_handler, id, viewport, cloud->sensor_origin_, cloud->sensor_orientation_));
}

//////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,10 @@ pcl::visualization::PointCloudColorHandlerRGBField<PointT>::getColor (vtkSmartPo
!pcl_isfinite (cloud_->points[cp].z))
continue;

if (rgba_index != -1)
{
memcpy (&rgb, (reinterpret_cast<const char *> (&cloud_->points[cp])) + rgba_index, sizeof (pcl::RGB));
colors[j ] = rgb.r;
colors[j + 1] = rgb.g;
colors[j + 2] = rgb.b;
}
else
{
// If no RGB field is available, color the point white
colors[j ] = 255;
colors[j + 1] = 255;
colors[j + 2] = 255;
}
memcpy (&rgb, (reinterpret_cast<const char *> (&cloud_->points[cp])) + rgba_index, sizeof (pcl::RGB));
colors[j ] = rgb.r;
colors[j + 1] = rgb.g;
colors[j + 2] = rgb.b;
j += 3;
}
}
Expand All @@ -193,20 +183,10 @@ pcl::visualization::PointCloudColorHandlerRGBField<PointT>::getColor (vtkSmartPo
for (vtkIdType cp = 0; cp < nr_points; ++cp)
{
int idx = static_cast<int> (cp) * 3;
if (rgba_index != -1)
{
memcpy (&rgb, (reinterpret_cast<const char *> (&cloud_->points[cp])) + rgba_index, sizeof (pcl::RGB));
colors[j ] = rgb.r;
colors[j + 1] = rgb.g;
colors[j + 2] = rgb.b;
}
else
{
// If no RGB field is available, color the point white
colors[j ] = 255;
colors[j + 1] = 255;
colors[j + 2] = 255;
}
memcpy (&rgb, (reinterpret_cast<const char *> (&cloud_->points[cp])) + rgba_index, sizeof (pcl::RGB));
colors[j ] = rgb.r;
colors[j + 1] = rgb.g;
colors[j + 2] = rgb.b;
}
}
return (true);
Expand Down

0 comments on commit 0f5f3ff

Please sign in to comment.