38 #ifndef PCL_PCL_VISUALIZER_IMPL_H_
39 #define PCL_PCL_VISUALIZER_IMPL_H_
41 #include <vtkVersion.h>
42 #include <vtkSmartPointer.h>
43 #include <vtkCellArray.h>
44 #include <vtkLeaderActor2D.h>
45 #include <vtkVectorText.h>
46 #include <vtkAlgorithmOutput.h>
47 #include <vtkFollower.h>
48 #include <vtkSphereSource.h>
49 #include <vtkProperty2D.h>
50 #include <vtkDataSetSurfaceFilter.h>
51 #include <vtkPointData.h>
52 #include <vtkPolyDataMapper.h>
53 #include <vtkProperty.h>
54 #include <vtkMapper.h>
55 #include <vtkCellData.h>
56 #include <vtkDataSetMapper.h>
57 #include <vtkRenderer.h>
58 #include <vtkRendererCollection.h>
59 #include <vtkAppendPolyData.h>
60 #include <vtkTextProperty.h>
61 #include <vtkLODActor.h>
63 #include <pcl/visualization/common/shapes.h>
66 #ifdef vtkGenericDataArray_h
67 #define SetTupleValue SetTypedTuple
68 #define InsertNextTupleValue InsertNextTypedTuple
69 #define GetTupleValue GetTypedTuple
73 template <
typename Po
intT>
bool
76 const std::string &
id,
int viewport)
80 return (addPointCloud<PointT> (cloud, geometry_handler,
id, viewport));
84 template <
typename Po
intT>
bool
88 const std::string &
id,
int viewport)
91 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
93 if (am_it != cloud_actor_map_->end ())
95 PCL_WARN (
"[addPointCloud] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
105 template <
typename Po
intT>
bool
109 const std::string &
id,
int viewport)
112 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
114 if (am_it != cloud_actor_map_->end ())
118 am_it->second.geometry_handlers.push_back (geometry_handler);
128 template <
typename Po
intT>
bool
132 const std::string &
id,
int viewport)
135 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
137 if (am_it != cloud_actor_map_->end ())
139 PCL_WARN (
"[addPointCloud] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
153 template <
typename Po
intT>
bool
157 const std::string &
id,
int viewport)
160 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
161 if (am_it != cloud_actor_map_->end ())
165 am_it->second.color_handlers.push_back (color_handler);
174 template <
typename Po
intT>
bool
179 const std::string &
id,
int viewport)
182 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
183 if (am_it != cloud_actor_map_->end ())
187 am_it->second.geometry_handlers.push_back (geometry_handler);
188 am_it->second.color_handlers.push_back (color_handler);
195 template <
typename Po
intT>
bool
200 const std::string &
id,
int viewport)
203 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
205 if (am_it != cloud_actor_map_->end ())
207 PCL_WARN (
"[addPointCloud] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
219 template <
typename Po
intT>
void
220 pcl::visualization::PCLVisualizer::convertPointCloudToVTKPolyData (
228 allocVtkPolyData (polydata);
230 polydata->SetVerts (vertices);
234 vertices = polydata->GetVerts ();
238 vtkIdType nr_points = cloud->
points.size ();
244 points->SetDataTypeToFloat ();
245 polydata->SetPoints (points);
247 points->SetNumberOfPoints (nr_points);
250 float *data = (
static_cast<vtkFloatArray*
> (points->GetData ()))->GetPointer (0);
255 for (vtkIdType i = 0; i < nr_points; ++i)
256 memcpy (&data[i * 3], &cloud->
points[i].x, 12);
261 for (vtkIdType i = 0; i < nr_points; ++i)
264 if (!pcl_isfinite (cloud->
points[i].x) ||
265 !pcl_isfinite (cloud->
points[i].y) ||
266 !pcl_isfinite (cloud->
points[i].z))
269 memcpy (&data[j * 3], &cloud->
points[i].x, 12);
273 points->SetNumberOfPoints (nr_points);
277 updateCells (cells, initcells, nr_points);
280 vertices->SetCells (nr_points, cells);
284 template <
typename Po
intT>
void
285 pcl::visualization::PCLVisualizer::convertPointCloudToVTKPolyData (
293 allocVtkPolyData (polydata);
295 polydata->SetVerts (vertices);
301 polydata->SetPoints (points);
303 vtkIdType nr_points = points->GetNumberOfPoints ();
306 vertices = polydata->GetVerts ();
311 updateCells (cells, initcells, nr_points);
313 vertices->SetCells (nr_points, cells);
317 template <
typename Po
intT>
bool
320 double r,
double g,
double b,
const std::string &
id,
int viewport)
327 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
328 if (am_it != shape_actor_map_->end ())
333 #if VTK_MAJOR_VERSION < 6
334 all_data->AddInput (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
336 all_data->AddInputData (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
341 #if VTK_MAJOR_VERSION < 6
342 surface_filter->AddInput (vtkUnstructuredGrid::SafeDownCast (data));
344 surface_filter->AddInputData (vtkUnstructuredGrid::SafeDownCast (data));
347 #if VTK_MAJOR_VERSION < 6
348 all_data->AddInput (poly_data);
350 all_data->AddInputData (poly_data);
355 createActorFromVTKDataSet (all_data->GetOutput (), actor);
356 actor->GetProperty ()->SetRepresentationToWireframe ();
357 actor->GetProperty ()->SetColor (r, g, b);
358 actor->GetMapper ()->ScalarVisibilityOff ();
359 removeActorFromRenderer (am_it->second, viewport);
360 addActorToRenderer (actor, viewport);
363 (*shape_actor_map_)[id] = actor;
369 createActorFromVTKDataSet (data, actor);
370 actor->GetProperty ()->SetRepresentationToWireframe ();
371 actor->GetProperty ()->SetColor (r, g, b);
372 actor->GetMapper ()->ScalarVisibilityOff ();
373 addActorToRenderer (actor, viewport);
376 (*shape_actor_map_)[id] = actor;
383 template <
typename Po
intT>
bool
386 double r,
double g,
double b,
const std::string &
id,
int viewport)
393 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
394 if (am_it != shape_actor_map_->end ())
399 #if VTK_MAJOR_VERSION < 6
400 all_data->AddInput (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
402 all_data->AddInputData (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
407 #if VTK_MAJOR_VERSION < 6
408 surface_filter->SetInput (vtkUnstructuredGrid::SafeDownCast (data));
410 surface_filter->SetInputData (vtkUnstructuredGrid::SafeDownCast (data));
413 #if VTK_MAJOR_VERSION < 6
414 all_data->AddInput (poly_data);
416 all_data->AddInputData (poly_data);
421 createActorFromVTKDataSet (all_data->GetOutput (), actor);
422 actor->GetProperty ()->SetRepresentationToWireframe ();
423 actor->GetProperty ()->SetColor (r, g, b);
424 actor->GetMapper ()->ScalarVisibilityOn ();
425 actor->GetProperty ()->BackfaceCullingOff ();
426 removeActorFromRenderer (am_it->second, viewport);
427 addActorToRenderer (actor, viewport);
430 (*shape_actor_map_)[id] = actor;
436 createActorFromVTKDataSet (data, actor);
437 actor->GetProperty ()->SetRepresentationToWireframe ();
438 actor->GetProperty ()->SetColor (r, g, b);
439 actor->GetMapper ()->ScalarVisibilityOn ();
440 actor->GetProperty ()->BackfaceCullingOff ();
441 addActorToRenderer (actor, viewport);
444 (*shape_actor_map_)[id] = actor;
450 template <
typename Po
intT>
bool
453 const std::string &
id,
int viewport)
455 return (!addPolygon<PointT> (cloud, 0.5, 0.5, 0.5,
id, viewport));
459 template <
typename P1,
typename P2>
bool
463 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
464 if (am_it != shape_actor_map_->end ())
466 PCL_WARN (
"[addLine] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
474 createActorFromVTKDataSet (data, actor);
475 actor->GetProperty ()->SetRepresentationToWireframe ();
476 actor->GetProperty ()->SetColor (r, g, b);
477 actor->GetMapper ()->ScalarVisibilityOff ();
478 addActorToRenderer (actor, viewport);
481 (*shape_actor_map_)[id] = actor;
486 template <
typename P1,
typename P2>
bool
490 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
491 if (am_it != shape_actor_map_->end ())
493 PCL_WARN (
"[addArrow] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
499 leader->GetPositionCoordinate ()->SetCoordinateSystemToWorld ();
500 leader->GetPositionCoordinate ()->SetValue (pt1.x, pt1.y, pt1.z);
501 leader->GetPosition2Coordinate ()->SetCoordinateSystemToWorld ();
502 leader->GetPosition2Coordinate ()->SetValue (pt2.x, pt2.y, pt2.z);
503 leader->SetArrowStyleToFilled ();
504 leader->AutoLabelOn ();
506 leader->GetProperty ()->SetColor (r, g, b);
507 addActorToRenderer (leader, viewport);
510 (*shape_actor_map_)[id] = leader;
515 template <
typename P1,
typename P2>
bool
519 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
520 if (am_it != shape_actor_map_->end ())
522 PCL_WARN (
"[addArrow] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
528 leader->GetPositionCoordinate ()->SetCoordinateSystemToWorld ();
529 leader->GetPositionCoordinate ()->SetValue (pt1.x, pt1.y, pt1.z);
530 leader->GetPosition2Coordinate ()->SetCoordinateSystemToWorld ();
531 leader->GetPosition2Coordinate ()->SetValue (pt2.x, pt2.y, pt2.z);
532 leader->SetArrowStyleToFilled ();
533 leader->SetArrowPlacementToPoint1 ();
535 leader->AutoLabelOn ();
537 leader->AutoLabelOff ();
539 leader->GetProperty ()->SetColor (r, g, b);
540 addActorToRenderer (leader, viewport);
543 (*shape_actor_map_)[id] = leader;
547 template <
typename P1,
typename P2>
bool
549 double r_line,
double g_line,
double b_line,
550 double r_text,
double g_text,
double b_text,
551 const std::string &
id,
int viewport)
554 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
555 if (am_it != shape_actor_map_->end ())
557 PCL_WARN (
"[addArrow] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
563 leader->GetPositionCoordinate ()->SetCoordinateSystemToWorld ();
564 leader->GetPositionCoordinate ()->SetValue (pt1.x, pt1.y, pt1.z);
565 leader->GetPosition2Coordinate ()->SetCoordinateSystemToWorld ();
566 leader->GetPosition2Coordinate ()->SetValue (pt2.x, pt2.y, pt2.z);
567 leader->SetArrowStyleToFilled ();
568 leader->AutoLabelOn ();
570 leader->GetLabelTextProperty()->SetColor(r_text, g_text, b_text);
572 leader->GetProperty ()->SetColor (r_line, g_line, b_line);
573 addActorToRenderer (leader, viewport);
576 (*shape_actor_map_)[id] = leader;
581 template <
typename P1,
typename P2>
bool
584 return (!addLine (pt1, pt2, 0.5, 0.5, 0.5,
id, viewport));
588 template <
typename Po
intT>
bool
592 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
593 if (am_it != shape_actor_map_->end ())
595 PCL_WARN (
"[addSphere] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
600 data->SetRadius (radius);
601 data->SetCenter (
double (center.x), double (center.y), double (center.z));
602 data->SetPhiResolution (10);
603 data->SetThetaResolution (10);
604 data->LatLongTessellationOff ();
609 mapper->SetInputConnection (data->GetOutputPort ());
613 actor->SetMapper (mapper);
615 actor->GetProperty ()->SetRepresentationToSurface ();
616 actor->GetProperty ()->SetInterpolationToFlat ();
617 actor->GetProperty ()->SetColor (r, g, b);
618 actor->GetMapper ()->ImmediateModeRenderingOn ();
619 actor->GetMapper ()->StaticOn ();
620 actor->GetMapper ()->ScalarVisibilityOff ();
621 actor->GetMapper ()->Update ();
622 addActorToRenderer (actor, viewport);
625 (*shape_actor_map_)[id] = actor;
630 template <
typename Po
intT>
bool
633 return (addSphere (center, radius, 0.5, 0.5, 0.5,
id, viewport));
637 template<
typename Po
intT>
bool
641 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
642 if (am_it == shape_actor_map_->end ())
647 vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second);
648 #if VTK_MAJOR_VERSION < 6
649 vtkAlgorithm *algo = actor->GetMapper ()->GetInput ()->GetProducerPort ()->GetProducer ();
651 vtkAlgorithm *algo = actor->GetMapper ()->GetInputAlgorithm ();
653 vtkSphereSource *src = vtkSphereSource::SafeDownCast (algo);
655 src->SetCenter (
double (center.x), double (center.y), double (center.z));
656 src->SetRadius (radius);
658 actor->GetProperty ()->SetColor (r, g, b);
665 template <
typename Po
intT>
bool
667 const std::string &text,
673 const std::string &
id,
683 ShapeActorMap::iterator am_it = shape_actor_map_->find (tid);
684 if (am_it != shape_actor_map_->end ())
686 pcl::console::print_warn (stderr,
"[addText3d] A text with id <%s> already exists! Please choose a different id and retry.\n", tid.c_str ());
691 textSource->SetText (text.c_str());
692 textSource->Update ();
695 textMapper->SetInputConnection (textSource->GetOutputPort ());
698 rens_->InitTraversal ();
699 vtkRenderer* renderer = NULL;
701 while ((renderer = rens_->GetNextItem ()) != NULL)
704 if (viewport == 0 || viewport == i)
707 textActor->SetMapper (textMapper);
708 textActor->SetPosition (position.x, position.y, position.z);
709 textActor->SetScale (textScale);
710 textActor->GetProperty ()->SetColor (r, g, b);
711 textActor->SetCamera (renderer->GetActiveCamera ());
713 renderer->AddActor (textActor);
718 std::string alternate_tid = tid;
719 alternate_tid.append(i,
'*');
721 (*shape_actor_map_)[(viewport == 0) ? tid : alternate_tid] = textActor;
731 template <
typename Po
intNT>
bool
734 int level,
float scale,
const std::string &
id,
int viewport)
736 return (addPointCloudNormals<PointNT, PointNT> (cloud, cloud, level, scale,
id, viewport));
740 template <
typename Po
intT,
typename Po
intNT>
bool
744 int level,
float scale,
745 const std::string &
id,
int viewport)
749 PCL_ERROR (
"[addPointCloudNormals] The number of points differs from the number of normals!\n");
753 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
755 if (am_it != cloud_actor_map_->end ())
757 PCL_WARN (
"[addPointCloudNormals] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
764 points->SetDataTypeToFloat ();
766 data->SetNumberOfComponents (3);
769 vtkIdType nr_normals = 0;
775 vtkIdType point_step =
static_cast<vtkIdType
> (sqrt (
double (level)));
776 nr_normals = (
static_cast<vtkIdType
> ((cloud->
width - 1)/ point_step) + 1) *
777 (static_cast<vtkIdType> ((cloud->
height - 1) / point_step) + 1);
778 pts =
new float[2 * nr_normals * 3];
780 vtkIdType cell_count = 0;
781 for (vtkIdType y = 0; y < normals->
height; y += point_step)
782 for (vtkIdType x = 0; x < normals->
width; x += point_step)
784 PointT p = (*cloud)(x, y);
785 p.x += (*normals)(x, y).normal[0] * scale;
786 p.y += (*normals)(x, y).normal[1] * scale;
787 p.z += (*normals)(x, y).normal[2] * scale;
789 pts[2 * cell_count * 3 + 0] = (*cloud)(x, y).x;
790 pts[2 * cell_count * 3 + 1] = (*cloud)(x, y).y;
791 pts[2 * cell_count * 3 + 2] = (*cloud)(x, y).z;
792 pts[2 * cell_count * 3 + 3] = p.x;
793 pts[2 * cell_count * 3 + 4] = p.y;
794 pts[2 * cell_count * 3 + 5] = p.z;
796 lines->InsertNextCell (2);
797 lines->InsertCellPoint (2 * cell_count);
798 lines->InsertCellPoint (2 * cell_count + 1);
804 nr_normals = (cloud->
points.size () - 1) / level + 1 ;
805 pts =
new float[2 * nr_normals * 3];
807 for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = j * level)
810 p.x += normals->
points[i].normal[0] * scale;
811 p.y += normals->
points[i].normal[1] * scale;
812 p.z += normals->
points[i].normal[2] * scale;
814 pts[2 * j * 3 + 0] = cloud->
points[i].x;
815 pts[2 * j * 3 + 1] = cloud->
points[i].y;
816 pts[2 * j * 3 + 2] = cloud->
points[i].z;
817 pts[2 * j * 3 + 3] = p.x;
818 pts[2 * j * 3 + 4] = p.y;
819 pts[2 * j * 3 + 5] = p.z;
821 lines->InsertNextCell (2);
822 lines->InsertCellPoint (2 * j);
823 lines->InsertCellPoint (2 * j + 1);
827 data->SetArray (&pts[0], 2 * nr_normals * 3, 0);
828 points->SetData (data);
831 polyData->SetPoints (points);
832 polyData->SetLines (lines);
835 #if VTK_MAJOR_VERSION < 6
836 mapper->SetInput (polyData);
838 mapper->SetInputData (polyData);
840 mapper->SetColorModeToMapScalars();
841 mapper->SetScalarModeToUsePointData();
845 actor->SetMapper (mapper);
848 addActorToRenderer (actor, viewport);
851 (*cloud_actor_map_)[id].actor = actor;
856 template <
typename Po
intT,
typename GradientT>
bool
860 int level,
double scale,
861 const std::string &
id,
int viewport)
865 PCL_ERROR (
"[addPointCloudGradients] The number of points differs from the number of gradients!\n");
869 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
871 if (am_it != cloud_actor_map_->end ())
873 PCL_WARN (
"[addPointCloudGradients] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
880 points->SetDataTypeToFloat ();
882 data->SetNumberOfComponents (3);
884 vtkIdType nr_gradients = (cloud->
points.size () - 1) / level + 1 ;
885 float* pts =
new float[2 * nr_gradients * 3];
887 for (vtkIdType i = 0, j = 0; j < nr_gradients; j++, i = j * level)
890 p.x += gradients->
points[i].gradient[0] * scale;
891 p.y += gradients->
points[i].gradient[1] * scale;
892 p.z += gradients->
points[i].gradient[2] * scale;
894 pts[2 * j * 3 + 0] = cloud->
points[i].x;
895 pts[2 * j * 3 + 1] = cloud->
points[i].y;
896 pts[2 * j * 3 + 2] = cloud->
points[i].z;
897 pts[2 * j * 3 + 3] = p.x;
898 pts[2 * j * 3 + 4] = p.y;
899 pts[2 * j * 3 + 5] = p.z;
901 lines->InsertNextCell(2);
902 lines->InsertCellPoint(2*j);
903 lines->InsertCellPoint(2*j+1);
906 data->SetArray (&pts[0], 2 * nr_gradients * 3, 0);
907 points->SetData (data);
910 polyData->SetPoints(points);
911 polyData->SetLines(lines);
914 #if VTK_MAJOR_VERSION < 6
915 mapper->SetInput (polyData);
917 mapper->SetInputData (polyData);
919 mapper->SetColorModeToMapScalars();
920 mapper->SetScalarModeToUsePointData();
924 actor->SetMapper (mapper);
927 addActorToRenderer (actor, viewport);
930 (*cloud_actor_map_)[id].actor = actor;
935 template <
typename Po
intT>
bool
939 const std::vector<int> &correspondences,
940 const std::string &
id,
944 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
945 if (am_it != shape_actor_map_->end ())
947 PCL_WARN (
"[addCorrespondences] A set of correspondences with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
951 int n_corr = int (correspondences.size ());
956 line_colors->SetNumberOfComponents (3);
957 line_colors->SetName (
"Colors");
958 line_colors->SetNumberOfTuples (n_corr);
959 unsigned char* colors = line_colors->GetPointer (0);
960 memset (colors, 0, line_colors->GetNumberOfTuples () * line_colors->GetNumberOfComponents ());
963 rgb.r = 255; rgb.g = rgb.b = 0;
967 line_points->SetNumberOfPoints (2 * n_corr);
970 line_cells_id->SetNumberOfComponents (3);
971 line_cells_id->SetNumberOfTuples (n_corr);
972 vtkIdType *line_cell_id = line_cells_id->GetPointer (0);
976 line_tcoords->SetNumberOfComponents (1);
977 line_tcoords->SetNumberOfTuples (n_corr * 2);
978 line_tcoords->SetName (
"Texture Coordinates");
980 double tc[3] = {0.0, 0.0, 0.0};
984 for (
int i = 0; i < n_corr; ++i)
987 const PointT &p_tgt = target_points->
points[correspondences[i]];
989 int id1 = j * 2 + 0, id2 = j * 2 + 1;
991 line_points->SetPoint (id1, p_src.x, p_src.y, p_src.z);
992 line_points->SetPoint (id2, p_tgt.x, p_tgt.y, p_tgt.z);
995 *line_cell_id++ = id1;
996 *line_cell_id++ = id2;
998 tc[0] = 0.; line_tcoords->SetTuple (id1, tc);
999 tc[0] = 1.; line_tcoords->SetTuple (id2, tc);
1002 colors[idx+0] = rgb.r;
1003 colors[idx+1] = rgb.g;
1004 colors[idx+2] = rgb.b;
1006 line_colors->SetNumberOfTuples (j);
1007 line_cells_id->SetNumberOfTuples (j);
1008 line_cells->SetCells (n_corr, line_cells_id);
1009 line_points->SetNumberOfPoints (j*2);
1010 line_tcoords->SetNumberOfTuples (j*2);
1013 line_data->SetPoints (line_points);
1014 line_data->SetLines (line_cells);
1015 line_data->GetPointData ()->SetTCoords (line_tcoords);
1016 line_data->GetCellData ()->SetScalars (line_colors);
1020 createActorFromVTKDataSet (line_data, actor);
1021 actor->GetProperty ()->SetRepresentationToWireframe ();
1022 actor->GetProperty ()->SetOpacity (0.5);
1023 addActorToRenderer (actor, viewport);
1026 (*shape_actor_map_)[id] = actor;
1032 template <
typename Po
intT>
bool
1038 const std::string &
id,
1041 if (correspondences.empty ())
1043 PCL_DEBUG (
"[addCorrespondences] An empty set of correspondences given! Nothing to display.\n");
1048 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
1049 if (am_it != shape_actor_map_->end ())
1051 PCL_WARN (
"[addCorrespondences] A set of correspondences with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
1055 int n_corr = int (correspondences.size () / nth + 1);
1060 line_colors->SetNumberOfComponents (3);
1061 line_colors->SetName (
"Colors");
1062 line_colors->SetNumberOfTuples (n_corr);
1063 unsigned char* colors = line_colors->GetPointer (0);
1064 memset (colors, 0, line_colors->GetNumberOfTuples () * line_colors->GetNumberOfComponents ());
1067 rgb.r = 255; rgb.g = rgb.b = 0;
1071 line_points->SetNumberOfPoints (2 * n_corr);
1074 line_cells_id->SetNumberOfComponents (3);
1075 line_cells_id->SetNumberOfTuples (n_corr);
1076 vtkIdType *line_cell_id = line_cells_id->GetPointer (0);
1080 line_tcoords->SetNumberOfComponents (1);
1081 line_tcoords->SetNumberOfTuples (n_corr * 2);
1082 line_tcoords->SetName (
"Texture Coordinates");
1084 double tc[3] = {0.0, 0.0, 0.0};
1088 for (
size_t i = 0; i < correspondences.size (); i += nth, idx = j * 3, ++j)
1090 const PointT &p_src = source_points->
points[correspondences[i].index_query];
1091 const PointT &p_tgt = target_points->
points[correspondences[i].index_match];
1093 int id1 = j * 2 + 0, id2 = j * 2 + 1;
1095 line_points->SetPoint (id1, p_src.x, p_src.y, p_src.z);
1096 line_points->SetPoint (id2, p_tgt.x, p_tgt.y, p_tgt.z);
1098 *line_cell_id++ = 2;
1099 *line_cell_id++ = id1;
1100 *line_cell_id++ = id2;
1102 tc[0] = 0.; line_tcoords->SetTuple (id1, tc);
1103 tc[0] = 1.; line_tcoords->SetTuple (id2, tc);
1106 colors[idx+0] = rgb.r;
1107 colors[idx+1] = rgb.g;
1108 colors[idx+2] = rgb.b;
1110 line_colors->SetNumberOfTuples (j);
1111 line_cells_id->SetNumberOfTuples (j);
1112 line_cells->SetCells (n_corr, line_cells_id);
1113 line_points->SetNumberOfPoints (j*2);
1114 line_tcoords->SetNumberOfTuples (j*2);
1117 line_data->SetPoints (line_points);
1118 line_data->SetLines (line_cells);
1119 line_data->GetPointData ()->SetTCoords (line_tcoords);
1120 line_data->GetCellData ()->SetScalars (line_colors);
1124 createActorFromVTKDataSet (line_data, actor);
1125 actor->GetProperty ()->SetRepresentationToWireframe ();
1126 actor->GetProperty ()->SetOpacity (0.5);
1127 addActorToRenderer (actor, viewport);
1130 (*shape_actor_map_)[id] = actor;
1136 template <
typename Po
intT>
bool
1142 const std::string &
id)
1144 if (correspondences.empty ())
1146 PCL_DEBUG (
"[updateCorrespondences] An empty set of correspondences given! Nothing to display.\n");
1151 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
1152 if (am_it == shape_actor_map_->end ())
1158 int n_corr = int (correspondences.size () / nth + 1);
1162 line_colors->SetNumberOfComponents (3);
1163 line_colors->SetName (
"Colors");
1164 line_colors->SetNumberOfTuples (n_corr);
1165 unsigned char* colors = line_colors->GetPointer (0);
1166 memset (colors, 0, line_colors->GetNumberOfTuples () * line_colors->GetNumberOfComponents ());
1169 rgb.r = 255.0; rgb.g = rgb.b = 0.0;
1173 line_points->SetNumberOfPoints (2 * n_corr);
1176 line_cells_id->SetNumberOfComponents (3);
1177 line_cells_id->SetNumberOfTuples (n_corr);
1178 vtkIdType *line_cell_id = line_cells_id->GetPointer (0);
1182 line_tcoords->SetNumberOfComponents (1);
1183 line_tcoords->SetNumberOfTuples (n_corr * 2);
1184 line_tcoords->SetName (
"Texture Coordinates");
1186 double tc[3] = {0.0, 0.0, 0.0};
1190 for (
size_t i = 0; i < correspondences.size (); i += nth, idx = j * 3, ++j)
1192 const PointT &p_src = source_points->
points[correspondences[i].index_query];
1193 const PointT &p_tgt = target_points->
points[correspondences[i].index_match];
1195 int id1 = j * 2 + 0, id2 = j * 2 + 1;
1197 line_points->SetPoint (id1, p_src.x, p_src.y, p_src.z);
1198 line_points->SetPoint (id2, p_tgt.x, p_tgt.y, p_tgt.z);
1200 *line_cell_id++ = 2;
1201 *line_cell_id++ = id1;
1202 *line_cell_id++ = id2;
1204 tc[0] = 0.; line_tcoords->SetTuple (id1, tc);
1205 tc[0] = 1.; line_tcoords->SetTuple (id2, tc);
1208 colors[idx+0] = rgb.r;
1209 colors[idx+1] = rgb.g;
1210 colors[idx+2] = rgb.b;
1212 line_colors->SetNumberOfTuples (j);
1213 line_cells_id->SetNumberOfTuples (j);
1214 line_cells->SetCells (n_corr, line_cells_id);
1215 line_points->SetNumberOfPoints (j*2);
1216 line_tcoords->SetNumberOfTuples (j*2);
1219 line_data->SetPoints (line_points);
1220 line_data->SetLines (line_cells);
1221 line_data->GetPointData ()->SetTCoords (line_tcoords);
1222 line_data->GetCellData ()->SetScalars (line_colors);
1225 #if VTK_MAJOR_VERSION < 6
1226 reinterpret_cast<vtkPolyDataMapper*
>(actor->GetMapper ())->SetInput (line_data);
1228 reinterpret_cast<vtkPolyDataMapper*
> (actor->GetMapper ())->SetInputData (line_data);
1235 template <
typename Po
intT>
bool
1236 pcl::visualization::PCLVisualizer::fromHandlersToScreen (
1239 const std::string &
id,
1241 const Eigen::Vector4f& sensor_origin,
1242 const Eigen::Quaternion<float>& sensor_orientation)
1246 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n",
id.c_str (), geometry_handler.
getName ().c_str ());
1252 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n",
id.c_str (), color_handler.
getName ().c_str ());
1259 convertPointCloudToVTKPolyData<PointT> (geometry_handler, polydata, initcells);
1263 bool has_colors =
false;
1266 if (color_handler.
getColor (scalars))
1268 polydata->GetPointData ()->SetScalars (scalars);
1269 scalars->GetRange (minmax);
1275 createActorFromVTKDataSet (polydata, actor);
1277 actor->GetMapper ()->SetScalarRange (minmax);
1280 addActorToRenderer (actor, viewport);
1283 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
1284 cloud_actor.actor = actor;
1285 cloud_actor.cells = initcells;
1289 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
1290 cloud_actor.viewpoint_transformation_ = transformation;
1291 cloud_actor.actor->SetUserMatrix (transformation);
1292 cloud_actor.actor->Modified ();
1298 template <
typename Po
intT>
bool
1299 pcl::visualization::PCLVisualizer::fromHandlersToScreen (
1300 const PointCloudGeometryHandler<PointT> &geometry_handler,
1301 const ColorHandlerConstPtr &color_handler,
1302 const std::string &
id,
1304 const Eigen::Vector4f& sensor_origin,
1305 const Eigen::Quaternion<float>& sensor_orientation)
1307 if (!geometry_handler.isCapable ())
1309 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n",
id.c_str (), geometry_handler.getName ().c_str ());
1313 if (!color_handler->isCapable ())
1315 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n",
id.c_str (), color_handler->getName ().c_str ());
1322 convertPointCloudToVTKPolyData<PointT> (geometry_handler, polydata, initcells);
1326 bool has_colors =
false;
1329 if (color_handler->getColor (scalars))
1331 polydata->GetPointData ()->SetScalars (scalars);
1332 scalars->GetRange (minmax);
1338 createActorFromVTKDataSet (polydata, actor);
1340 actor->GetMapper ()->SetScalarRange (minmax);
1343 addActorToRenderer (actor, viewport);
1346 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
1347 cloud_actor.actor = actor;
1348 cloud_actor.cells = initcells;
1349 cloud_actor.color_handlers.push_back (color_handler);
1353 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
1354 cloud_actor.viewpoint_transformation_ = transformation;
1355 cloud_actor.actor->SetUserMatrix (transformation);
1356 cloud_actor.actor->Modified ();
1362 template <
typename Po
intT>
bool
1363 pcl::visualization::PCLVisualizer::fromHandlersToScreen (
1364 const GeometryHandlerConstPtr &geometry_handler,
1365 const PointCloudColorHandler<PointT> &color_handler,
1366 const std::string &
id,
1368 const Eigen::Vector4f& sensor_origin,
1369 const Eigen::Quaternion<float>& sensor_orientation)
1371 if (!geometry_handler->isCapable ())
1373 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n",
id.c_str (), geometry_handler->getName ().c_str ());
1377 if (!color_handler.isCapable ())
1379 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n",
id.c_str (), color_handler.getName ().c_str ());
1386 convertPointCloudToVTKPolyData (geometry_handler, polydata, initcells);
1390 bool has_colors =
false;
1393 if (color_handler.getColor (scalars))
1395 polydata->GetPointData ()->SetScalars (scalars);
1396 scalars->GetRange (minmax);
1402 createActorFromVTKDataSet (polydata, actor);
1404 actor->GetMapper ()->SetScalarRange (minmax);
1407 addActorToRenderer (actor, viewport);
1410 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
1411 cloud_actor.actor = actor;
1412 cloud_actor.cells = initcells;
1413 cloud_actor.geometry_handlers.push_back (geometry_handler);
1417 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
1418 cloud_actor.viewpoint_transformation_ = transformation;
1419 cloud_actor.actor->SetUserMatrix (transformation);
1420 cloud_actor.actor->Modified ();
1426 template <
typename Po
intT>
bool
1428 const std::string &
id)
1431 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1433 if (am_it == cloud_actor_map_->end ())
1438 convertPointCloudToVTKPolyData<PointT> (cloud, polydata, am_it->second.cells);
1442 polydata->GetPointData ()->SetScalars (scalars);
1444 minmax[0] = std::numeric_limits<double>::min ();
1445 minmax[1] = std::numeric_limits<double>::max ();
1446 am_it->second.actor->GetMapper ()->ImmediateModeRenderingOff ();
1447 am_it->second.actor->GetMapper ()->SetScalarRange (minmax);
1450 #if VTK_MAJOR_VERSION < 6
1451 reinterpret_cast<vtkPolyDataMapper*
>(am_it->second.actor->GetMapper ())->SetInput (polydata);
1453 reinterpret_cast<vtkPolyDataMapper*
> (am_it->second.actor->GetMapper ())->SetInputData (polydata);
1459 template <
typename Po
intT>
bool
1462 const std::string &
id)
1465 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1467 if (am_it == cloud_actor_map_->end ())
1474 convertPointCloudToVTKPolyData (geometry_handler, polydata, am_it->second.cells);
1478 polydata->GetPointData ()->SetScalars (scalars);
1480 minmax[0] = std::numeric_limits<double>::min ();
1481 minmax[1] = std::numeric_limits<double>::max ();
1482 am_it->second.actor->GetMapper ()->ImmediateModeRenderingOff ();
1483 am_it->second.actor->GetMapper ()->SetScalarRange (minmax);
1486 #if VTK_MAJOR_VERSION < 6
1487 reinterpret_cast<vtkPolyDataMapper*
>(am_it->second.actor->GetMapper ())->SetInput (polydata);
1489 reinterpret_cast<vtkPolyDataMapper*
> (am_it->second.actor->GetMapper ())->SetInputData (polydata);
1496 template <
typename Po
intT>
bool
1499 const std::string &
id)
1502 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1504 if (am_it == cloud_actor_map_->end ())
1514 vtkIdType nr_points = cloud->
points.size ();
1515 points->SetNumberOfPoints (nr_points);
1518 float *data = (
static_cast<vtkFloatArray*
> (points->GetData ()))->GetPointer (0);
1524 for (vtkIdType i = 0; i < nr_points; ++i, pts += 3)
1525 memcpy (&data[pts], &cloud->
points[i].x, 12);
1530 for (vtkIdType i = 0; i < nr_points; ++i)
1536 memcpy (&data[pts], &cloud->
points[i].x, 12);
1541 points->SetNumberOfPoints (nr_points);
1545 updateCells (cells, am_it->second.cells, nr_points);
1548 vertices->SetCells (nr_points, cells);
1554 scalars->GetRange (minmax);
1556 polydata->GetPointData ()->SetScalars (scalars);
1558 am_it->second.actor->GetMapper ()->ImmediateModeRenderingOff ();
1559 am_it->second.actor->GetMapper ()->SetScalarRange (minmax);
1562 #if VTK_MAJOR_VERSION < 6
1563 reinterpret_cast<vtkPolyDataMapper*
>(am_it->second.actor->GetMapper ())->SetInput (polydata);
1565 reinterpret_cast<vtkPolyDataMapper*
> (am_it->second.actor->GetMapper ())->SetInputData (polydata);
1571 template <
typename Po
intT>
bool
1574 const std::vector<pcl::Vertices> &vertices,
1575 const std::string &
id,
1578 if (vertices.empty () || cloud->
points.empty ())
1581 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1582 if (am_it != cloud_actor_map_->end ())
1585 "[addPolygonMesh] A shape with id <%s> already exists! Please choose a different id and retry.\n",
1591 std::vector<pcl::PCLPointField> fields;
1599 colors->SetNumberOfComponents (3);
1600 colors->SetName (
"Colors");
1603 for (
size_t i = 0; i < cloud->
size (); ++i)
1607 memcpy (&rgb_data, reinterpret_cast<const char*> (&cloud->
points[i]) + fields[rgb_idx].offset, sizeof (
pcl::RGB));
1608 unsigned char color[3];
1609 color[0] = rgb_data.r;
1610 color[1] = rgb_data.g;
1611 color[2] = rgb_data.b;
1612 colors->InsertNextTupleValue (color);
1618 vtkIdType nr_points = cloud->
points.size ();
1619 points->SetNumberOfPoints (nr_points);
1623 float *data =
static_cast<vtkFloatArray*
> (points->GetData ())->GetPointer (0);
1626 std::vector<int> lookup;
1630 for (vtkIdType i = 0; i < nr_points; ++i, ptr += 3)
1631 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1635 lookup.resize (nr_points);
1637 for (vtkIdType i = 0; i < nr_points; ++i)
1643 lookup[i] =
static_cast<int> (j);
1644 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1649 points->SetNumberOfPoints (nr_points);
1653 int max_size_of_polygon = -1;
1654 for (
size_t i = 0; i < vertices.size (); ++i)
1655 if (max_size_of_polygon < static_cast<int> (vertices[i].vertices.size ()))
1656 max_size_of_polygon =
static_cast<int> (vertices[i].vertices.size ());
1658 if (vertices.size () > 1)
1662 vtkIdType *cell = cell_array->WritePointer (vertices.size (), vertices.size () * (max_size_of_polygon + 1));
1664 if (lookup.size () > 0)
1666 for (
size_t i = 0; i < vertices.size (); ++i, ++idx)
1668 size_t n_points = vertices[i].vertices.size ();
1671 for (
size_t j = 0; j < n_points; j++, ++idx)
1672 *cell++ = lookup[vertices[i].vertices[j]];
1678 for (
size_t i = 0; i < vertices.size (); ++i, ++idx)
1680 size_t n_points = vertices[i].vertices.size ();
1683 for (
size_t j = 0; j < n_points; j++, ++idx)
1684 *cell++ = vertices[i].vertices[j];
1689 allocVtkPolyData (polydata);
1690 cell_array->GetData ()->SetNumberOfValues (idx);
1691 cell_array->Squeeze ();
1692 polydata->SetPolys (cell_array);
1693 polydata->SetPoints (points);
1696 polydata->GetPointData ()->SetScalars (colors);
1698 createActorFromVTKDataSet (polydata, actor,
false);
1703 size_t n_points = vertices[0].vertices.size ();
1704 polygon->GetPointIds ()->SetNumberOfIds (n_points - 1);
1706 if (lookup.size () > 0)
1708 for (
size_t j = 0; j < (n_points - 1); ++j)
1709 polygon->GetPointIds ()->SetId (j, lookup[vertices[0].vertices[j]]);
1713 for (
size_t j = 0; j < (n_points - 1); ++j)
1714 polygon->GetPointIds ()->SetId (j, vertices[0].vertices[j]);
1718 poly_grid->Allocate (1, 1);
1719 poly_grid->InsertNextCell (polygon->GetCellType (), polygon->GetPointIds ());
1720 poly_grid->SetPoints (points);
1722 poly_grid->GetPointData ()->SetScalars (colors);
1724 createActorFromVTKDataSet (poly_grid, actor,
false);
1726 addActorToRenderer (actor, viewport);
1727 actor->GetProperty ()->SetRepresentationToSurface ();
1729 actor->GetProperty ()->BackfaceCullingOff ();
1730 actor->GetProperty ()->SetInterpolationToFlat ();
1731 actor->GetProperty ()->EdgeVisibilityOff ();
1732 actor->GetProperty ()->ShadingOff ();
1735 (*cloud_actor_map_)[id].actor = actor;
1740 (*cloud_actor_map_)[id].viewpoint_transformation_ = transformation;
1746 template <
typename Po
intT>
bool
1749 const std::vector<pcl::Vertices> &verts,
1750 const std::string &
id)
1759 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1760 if (am_it == cloud_actor_map_->end ())
1772 vtkIdType nr_points = cloud->
points.size ();
1773 points->SetNumberOfPoints (nr_points);
1776 float *data = (
static_cast<vtkFloatArray*
> (points->GetData ()))->GetPointer (0);
1779 std::vector<int> lookup;
1783 for (vtkIdType i = 0; i < nr_points; ++i, ptr += 3)
1784 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1788 lookup.resize (nr_points);
1790 for (vtkIdType i = 0; i < nr_points; ++i)
1796 lookup [i] =
static_cast<int> (j);
1797 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1802 points->SetNumberOfPoints (nr_points);
1806 vtkUnsignedCharArray* colors = vtkUnsignedCharArray::SafeDownCast (polydata->GetPointData ()->GetScalars ());
1808 std::vector<pcl::PCLPointField> fields;
1812 if (rgb_idx != -1 && colors)
1816 for (
size_t i = 0; i < cloud->
size (); ++i)
1821 reinterpret_cast<const char*> (&cloud->
points[i]) + fields[rgb_idx].offset,
1823 unsigned char color[3];
1824 color[0] = rgb_data.r;
1825 color[1] = rgb_data.g;
1826 color[2] = rgb_data.b;
1827 colors->SetTupleValue (j++, color);
1832 int max_size_of_polygon = -1;
1833 for (
size_t i = 0; i < verts.size (); ++i)
1834 if (max_size_of_polygon < static_cast<int> (verts[i].vertices.size ()))
1835 max_size_of_polygon =
static_cast<int> (verts[i].vertices.size ());
1839 vtkIdType *cell = cells->WritePointer (verts.size (), verts.size () * (max_size_of_polygon + 1));
1841 if (lookup.size () > 0)
1843 for (
size_t i = 0; i < verts.size (); ++i, ++idx)
1845 size_t n_points = verts[i].vertices.size ();
1847 for (
size_t j = 0; j < n_points; j++, cell++, ++idx)
1848 *cell = lookup[verts[i].vertices[j]];
1853 for (
size_t i = 0; i < verts.size (); ++i, ++idx)
1855 size_t n_points = verts[i].vertices.size ();
1857 for (
size_t j = 0; j < n_points; j++, cell++, ++idx)
1858 *cell = verts[i].vertices[j];
1861 cells->GetData ()->SetNumberOfValues (idx);
1864 polydata->SetPolys (cells);
1869 #ifdef vtkGenericDataArray_h
1870 #undef SetTupleValue
1871 #undef InsertNextTupleValue
1872 #undef GetTupleValue
bool isCapable() const
Check if this handler is capable of handling the input data or not.
XYZ handler class for PointCloud geometry.
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested.
int getFieldIndex(const pcl::PCLPointCloud2 &cloud, const std::string &field_name)
Get the index of a specified field (i.e., dimension/channel)
bool updateCorrespondences(const typename pcl::PointCloud< PointT >::ConstPtr &source_points, const typename pcl::PointCloud< PointT >::ConstPtr &target_points, const pcl::Correspondences &correspondences, int nth, const std::string &id="correspondences")
Update the specified correspondences to the display.
uint32_t width
The point cloud width (if organized as an image-structure).
ColorHandler::ConstPtr ColorHandlerConstPtr
bool addPointCloud(const typename pcl::PointCloud< PointT >::ConstPtr &cloud, const std::string &id="cloud", int viewport=0)
Add a Point Cloud (templated) to screen.
virtual void getGeometry(vtkSmartPointer< vtkPoints > &points) const =0
Obtain the actual point geometry for the input dataset in VTK format.
bool addPointCloudIntensityGradients(const typename pcl::PointCloud< PointT >::ConstPtr &cloud, const typename pcl::PointCloud< GradientT >::ConstPtr &gradients, int level=100, double scale=1e-6, const std::string &id="cloud", int viewport=0)
Add the estimated surface intensity gradients of a Point Cloud to screen.
bool addPolygon(const typename pcl::PointCloud< PointT >::ConstPtr &cloud, double r, double g, double b, const std::string &id="polygon", int viewport=0)
Add a polygon (polyline) that represents the input point cloud (connects all points in order) ...
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
Base Handler class for PointCloud colors.
bool addSphere(const PointT ¢er, double radius, const std::string &id="sphere", int viewport=0)
Add a sphere shape from a point and a radius.
PCL_EXPORTS void getRandomColors(double &r, double &g, double &b, double min=0.2, double max=2.8)
Get (good) random values for R/G/B.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
bool addCorrespondences(const typename pcl::PointCloud< PointT >::ConstPtr &source_points, const typename pcl::PointCloud< PointT >::ConstPtr &target_points, const std::vector< int > &correspondences, const std::string &id="correspondences", int viewport=0)
Add the specified correspondences to the display.
A structure representing RGB color information.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
Handler for predefined user colors.
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
bool addPolygonMesh(const pcl::PolygonMesh &polymesh, const std::string &id="polygon", int viewport=0)
Add a PolygonMesh object to screen.
bool addArrow(const P1 &pt1, const P2 &pt2, double r, double g, double b, const std::string &id="arrow", int viewport=0)
Add a line arrow segment between two points, and display the distance between them.
uint32_t height
The point cloud height (if organized as an image-structure).
PCL_EXPORTS void allocVtkUnstructuredGrid(vtkSmartPointer< vtkUnstructuredGrid > &polydata)
Allocate a new unstructured grid smartpointer.
PCL_EXPORTS void print_warn(const char *format,...)
Print a warning message on stream with colors.
bool updatePointCloud(const typename pcl::PointCloud< PointT >::ConstPtr &cloud, const std::string &id="cloud")
Updates the XYZ data for an existing cloud object id on screen.
bool isCapable() const
Checl if this handler is capable of handling the input data or not.
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
Base handler class for PointCloud geometry.
virtual std::string getName() const =0
Abstract getName method.
GeometryHandler::ConstPtr GeometryHandlerConstPtr
bool addLine(const P1 &pt1, const P2 &pt2, const std::string &id="line", int viewport=0)
Add a line segment from two points.
bool addText3D(const std::string &text, const PointT &position, double textScale=1.0, double r=1.0, double g=1.0, double b=1.0, const std::string &id="", int viewport=0)
Add a 3d text to the scene.
A point structure representing Euclidean xyz coordinates, and the RGB color.
virtual std::string getName() const =0
Abstract getName method.
bool updateSphere(const PointT ¢er, double radius, double r, double g, double b, const std::string &id="sphere")
Update an existing sphere shape from a point and a radius.
bool addPointCloudNormals(const typename pcl::PointCloud< PointNT >::ConstPtr &cloud, int level=100, float scale=0.02f, const std::string &id="cloud", int viewport=0)
Add the estimated surface normals of a Point Cloud to screen.
virtual bool getColor(vtkSmartPointer< vtkDataArray > &scalars) const =0
Obtain the actual color for the input dataset as vtk scalars.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values).
PCL_EXPORTS vtkSmartPointer< vtkDataSet > createLine(const Eigen::Vector4f &pt1, const Eigen::Vector4f &pt2)
Create a line shape from two points.
bool updatePolygonMesh(const typename pcl::PointCloud< PointT >::ConstPtr &cloud, const std::vector< pcl::Vertices > &vertices, const std::string &id="polygon")
Update a PolygonMesh object on screen.
PCL_EXPORTS void print_error(const char *format,...)
Print an error message on stream with colors.