Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tools/pcd_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ isOnly2DImage (const pcl::PCLPointField &field)
return (true);
return (false);
}

void
printHelp (int, char **argv)
{
Expand Down Expand Up @@ -219,7 +219,7 @@ pp_callback (const pcl::visualization::PointPickingEvent& event, void* cookie)
event.getPoint (pos.x, pos.y, pos.z);
p->addText3D<pcl::PointXYZ> (idx_string, pos, 0.0005, 1.0, 1.0, 1.0, idx_string);
}

}

/* ---[ */
Expand Down Expand Up @@ -286,7 +286,7 @@ main (int argc, char** argv)

bool use_vbos = false;
pcl::console::parse_argument (argc, argv, "-vbo_rendering", use_vbos);
if (use_vbos)
if (use_vbos)
print_highlight ("Vertex Buffer Object (VBO) visualization enabled.\n");

bool useEDLRendering = false;
Expand All @@ -295,7 +295,7 @@ main (int argc, char** argv)
print_highlight("EDL visualization enabled.\n");

bool use_pp = pcl::console::find_switch (argc, argv, "-use_point_picking");
if (use_pp)
if (use_pp)
print_highlight ("Point picking enabled.\n");

bool use_ap = pcl::console::find_switch(argc, argv, "-use_area_picking");
Expand All @@ -311,7 +311,7 @@ main (int argc, char** argv)
if (!use_vbos)
{
pcl::console::parse_argument (argc, argv, "-immediate_rendering", use_immediate_rendering);
if (use_immediate_rendering)
if (use_immediate_rendering)
print_highlight ("Using immediate mode rendering.\n");
}

Expand Down Expand Up @@ -486,7 +486,7 @@ main (int argc, char** argv)
{
print_info ("[done, "); print_value ("%g", tt.toc ()); print_info (" ms : "); print_value ("%u", cloud->width * cloud->height); print_info (" points]\n");
print_info ("Available dimensions: "); print_value ("%s\n", pcl::getFieldsList (*cloud).c_str ());

std::string name = "PCD Viewer :: " + std::string(argv[p_file_indices.at (i)]);
pcl::visualization::ImageViewer::Ptr img (new pcl::visualization::ImageViewer (name));
pcl::PointCloud<pcl::RGB> rgb_cloud;
Expand Down Expand Up @@ -719,7 +719,7 @@ main (int argc, char** argv)
float ax_x = 0.0, ax_y = 0.0, ax_z = 0.0;
pcl::console::parse_3x_arguments (argc, argv, "-ax_pos", ax_x, ax_y, ax_z);
// Draw XYZ axes if command-line enabled
p->addCoordinateSystem (axes, ax_x, ax_y, ax_z, "global");
p->addCoordinateSystem (axes, ax_x, ax_y, ax_z, "global", 0, false);
}

// Clean up the memory used by the binary blob
Expand Down Expand Up @@ -747,7 +747,7 @@ main (int argc, char** argv)
}
img->spinOnce ();
}

if (p)
{
if (p->wasStopped ())
Expand Down
15 changes: 12 additions & 3 deletions visualization/include/pcl/visualization/pcl_visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,10 @@ namespace pcl
* \param[in] scale the scale of the axes (default: 1)
* \param[in] id the coordinate system object id (default: reference)
* \param[in] viewport the view port where the 3D axes should be added (default: all)
* \param[in] pickable Whether the resulting vtk actors are pickable, i.e. they may attract the view when using 'f' for fly-to-point
*/
void
addCoordinateSystem (double scale = 1.0, const std::string& id = "reference", int viewport = 0);
addCoordinateSystem (double scale = 1.0, const std::string& id = "reference", int viewport = 0, bool pickable = true);

/** \brief Adds 3D axes describing a coordinate system to screen at x, y, z
* \param[in] scale the scale of the axes (default: 1)
Expand All @@ -319,9 +320,10 @@ namespace pcl
* \param[in] z the Z position of the axes
* \param[in] id the coordinate system object id (default: reference)
* \param[in] viewport the view port where the 3D axes should be added (default: all)
* \param[in] pickable Whether the resulting vtk actors are pickable, i.e. they may attract the view when using 'f' for fly-to-point
*/
void
addCoordinateSystem (double scale, float x, float y, float z, const std::string &id = "reference", int viewport = 0);
addCoordinateSystem (double scale, float x, float y, float z, const std::string &id = "reference", int viewport = 0, bool pickable = true);

/** \brief Adds 3D axes describing a coordinate system to screen at x, y, z, Roll,Pitch,Yaw
*
Expand Down Expand Up @@ -1714,7 +1716,7 @@ namespace pcl
* @brief Eye-Dome Lighting makes dark areas to improve depth perception
* See https://www.kitware.com/eye-dome-lighting-a-non-photorealistic-shading-technique/
* It is applied to all actors, including texts.
* @param viewport
* @param viewport
*/
void
enableEDLRendering(int viewport = 0);
Expand Down Expand Up @@ -1942,6 +1944,13 @@ namespace pcl
return (shape_actor_map_);
}

/** \brief Return a pointer to the CoordinateActorMap this visualizer uses. */
CoordinateActorMapPtr
getCoordinateActorMap ()
{
return (coordinate_actor_map_);
}

/** \brief Set the position in screen coordinates.
* \param[in] x where to move the window to (X)
* \param[in] y where to move the window to (Y)
Expand Down
42 changes: 26 additions & 16 deletions visualization/src/pcl_visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ pcl::visualization::PCLVisualizer::removeOrientationMarkerWidgetAxes ()

/////////////////////////////////////////////////////////////////////////////////////////////
void
pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const std::string &id, int viewport)
pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const std::string &id, int viewport, bool pickable)
{
if (scale <= 0.0)
scale = 1.0;
Expand Down Expand Up @@ -691,6 +691,11 @@ pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const std:
vtkSmartPointer<vtkLODActor> axes_actor = vtkSmartPointer<vtkLODActor>::New ();
axes_actor->SetMapper (axes_mapper);

if (!pickable)
{
axes_actor->SetPickable(false);
}

// Save the ID and actor pair to the global actor map
(*coordinate_actor_map_) [id] = axes_actor;

Expand All @@ -699,7 +704,7 @@ pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const std:

/////////////////////////////////////////////////////////////////////////////////////////////
void
pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, float x, float y, float z, const std::string& id, int viewport)
pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, float x, float y, float z, const std::string& id, int viewport, bool pickable)
{
if (scale <= 0.0)
scale = 1.0;
Expand Down Expand Up @@ -733,6 +738,11 @@ pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, float x, f
axes_actor->SetMapper (axes_mapper);
axes_actor->SetPosition (x, y, z);

if (!pickable)
{
axes_actor->SetPickable(false);
}

// Save the ID and actor pair to the global actor map
(*coordinate_actor_map_) [id] = axes_actor;

Expand Down Expand Up @@ -1400,7 +1410,7 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
// Check if the mapper has scalars
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
break;

// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
break;
Expand All @@ -1411,7 +1421,7 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
PCL_WARN ("[setPointCloudRenderingProperties] Range max must be greater than range min!\n");
return (false);
}

// Update LUT
actor->GetMapper ()->GetLookupTable ()->SetRange (val1, val2);
actor->GetMapper()->UseLookupTableScalarRangeOn ();
Expand Down Expand Up @@ -1563,15 +1573,15 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
// Check if the mapper has scalars
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
break;

// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
break;

// Get range limits from existing LUT
double *range;
range = actor->GetMapper ()->GetLookupTable ()->GetRange ();

actor->GetMapper ()->ScalarVisibilityOn ();
actor->GetMapper ()->SetScalarRange (range[0], range[1]);
vtkSmartPointer<vtkLookupTable> table;
Expand All @@ -1587,7 +1597,7 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
// Check if the mapper has scalars
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
break;

// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
break;
Expand Down Expand Up @@ -1717,7 +1727,7 @@ pcl::visualization::PCLVisualizer::setShapeRenderingProperties (
// Check if the mapper has scalars
if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
break;

// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
break;
Expand All @@ -1728,7 +1738,7 @@ pcl::visualization::PCLVisualizer::setShapeRenderingProperties (
PCL_WARN ("[setShapeRenderingProperties] Range max must be greater than range min!\n");
return (false);
}

// Update LUT
actor->GetMapper ()->GetLookupTable ()->SetRange (val1, val2);
actor->GetMapper()->UseLookupTableScalarRangeOn ();
Expand Down Expand Up @@ -1861,11 +1871,11 @@ pcl::visualization::PCLVisualizer::setShapeRenderingProperties (
// Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->IsA ("vtkUnsignedCharArray"))
break;

// Get range limits from existing LUT
double *range;
range = actor->GetMapper ()->GetLookupTable ()->GetRange ();

actor->GetMapper ()->ScalarVisibilityOn ();
actor->GetMapper ()->SetScalarRange (range[0], range[1]);
vtkSmartPointer<vtkLookupTable> table;
Expand Down Expand Up @@ -3005,7 +3015,7 @@ pcl::visualization::PCLVisualizer::addPolygonMesh (const pcl::PolygonMesh &poly_
pcl::fromPCLPointCloud2 (poly_mesh.cloud, *point_cloud);
poly_points->SetNumberOfPoints (point_cloud->size ());

for (std::size_t i = 0; i < point_cloud->size (); ++i)
for (std::size_t i = 0; i < point_cloud->size (); ++i)
{
const pcl::PointXYZ& p = (*point_cloud)[i];
poly_points->InsertPoint (i, p.x, p.y, p.z);
Expand Down Expand Up @@ -3175,7 +3185,7 @@ pcl::visualization::PCLVisualizer::updatePolygonMesh (

// Update the cells
cells = vtkSmartPointer<vtkCellArray>::New ();

const auto idx = details::fillCells(lookup, verts, cells, max_size_of_polygon);

cells->GetData ()->SetNumberOfValues (idx);
Expand Down Expand Up @@ -3419,7 +3429,7 @@ pcl::visualization::PCLVisualizer::addTextureMesh (const pcl::TextureMesh &mesh,
mapper->MapDataArrayToMultiTextureAttribute(tu,
this_coordinates_name.c_str(),
vtkDataObject::FIELD_ASSOCIATION_POINTS);

polydata->GetPointData ()->AddArray (coordinates);
actor->GetProperty ()->SetTexture (tu, texture);
++tex_id;
Expand Down Expand Up @@ -4338,7 +4348,7 @@ pcl::visualization::PCLVisualizer::close ()
void
pcl::visualization::PCLVisualizer::removeCorrespondences (
const std::string &id, int viewport)
{
{
removeShape (id, viewport);
}

Expand Down Expand Up @@ -4571,7 +4581,7 @@ pcl::visualization::PCLVisualizer::getUniqueCameraFile (int argc, char **argv)
p_file_indices = pcl::console::parse_file_extension_argument (argc, argv, ".pcd");
if (!p_file_indices.empty ())
{
boost::uuids::detail::sha1 sha1;
boost::uuids::detail::sha1 sha1;
bool valid = false;

// Calculate sha1 using canonical paths
Expand Down