Skip to content

Commit

Permalink
Merge pull request #2142 from frozar/get_point_cloud_rendering_proper…
Browse files Browse the repository at this point in the history
…ties

[VISU] Add another method 'getPointCloudRenderingProperties()'
  • Loading branch information
SergioRAgostinho authored Dec 15, 2017
2 parents 2f31e7e + 7fa84d7 commit c1e395b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
39 changes: 38 additions & 1 deletion test/visualization/test_visualization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,45 @@ TEST (PCL, PCLVisualizer_camera)
// cerr << "reset camera viewer pose:" << endl << viewer_pose << endl;
}

////////////////////////////////////////////////////////////////////////////////
TEST (PCL, PCLVisualizer_getPointCloudRenderingProperties)
{
PCLVisualizer visualizer;


std::string cloud_id = "input_cloud";
visualizer.addPointCloud (cloud, cloud_id);
ASSERT_TRUE (visualizer.setPointCloudRenderingProperties (PCL_VISUALIZER_COLOR,
1., 0., 0., cloud_id));
double r, g, b;
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_POINT_SIZE,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_OPACITY,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_LINE_WIDTH,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_FONT_SIZE,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_REPRESENTATION,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_IMMEDIATE_RENDERING,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_SHADING,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_LUT,
r, g, b, cloud_id));
EXPECT_FALSE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_LUT_RANGE,
r, g, b, cloud_id));

r = 666.;
g = 666.;
b = 666.;
EXPECT_TRUE (visualizer.getPointCloudRenderingProperties (PCL_VISUALIZER_COLOR,
r, g, b, cloud_id));

EXPECT_EQ (r, 1.);
EXPECT_EQ (g, 0.);
EXPECT_EQ (b, 0.);
}

/* ---[ */
int
Expand Down
13 changes: 13 additions & 0 deletions visualization/include/pcl/visualization/pcl_visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,19 @@ namespace pcl
getPointCloudRenderingProperties (int property, double &value,
const std::string &id = "cloud");

/** \brief Get the rendering properties of a PointCloud
* \param[in] property the property type
* \param[out] val1 the resultant property value
* \param[out] val2 the resultant property value
* \param[out] val3 the resultant property value
* \param[in] id the point cloud object id (default: cloud)
* \return True if the property is effectively retrieved.
* \note The list of properties can be found in \ref pcl::visualization::LookUpTableRepresentationProperties.
*/
bool
getPointCloudRenderingProperties (RenderingProperties property, double &val1, double &val2, double &val3,
const std::string &id = "cloud");

/** \brief Set whether the point cloud is selected or not
* \param[in] selected whether the cloud is selected or not (true = selected)
* \param[in] id the point cloud object id (default: cloud)
Expand Down
40 changes: 40 additions & 0 deletions visualization/src/pcl_visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,46 @@ pcl::visualization::PCLVisualizer::getPointCloudRenderingProperties (int propert
}
return (true);
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool
pcl::visualization::PCLVisualizer::getPointCloudRenderingProperties (RenderingProperties property,
double &val1,
double &val2,
double &val3,
const std::string &id)
{
// Check to see if this ID entry already exists (has it been already added to the visualizer?)
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);

if (am_it == cloud_actor_map_->end ())
return (false);
// Get the actor pointer
vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second.actor);
if (!actor)
return (false);

switch (property)
{
case PCL_VISUALIZER_COLOR:
{
double rgb[3];
actor->GetProperty ()->GetColor (rgb);
val1 = rgb[0];
val2 = rgb[1];
val3 = rgb[2];
break;
}
default:
{
pcl::console::print_error ("[getPointCloudRenderingProperties] "
"Property (%d) is either unknown or it requires a different "
"number of variables to retrieve its contents.\n",
property);
return (false);
}
}
return (true);
}

/////////////////////////////////////////////////////////////////////////////////////////////
bool
Expand Down

0 comments on commit c1e395b

Please sign in to comment.