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 template <
typename Po
intT>
bool
69 const std::string &
id,
int viewport)
73 return (addPointCloud<PointT> (cloud, geometry_handler,
id, viewport));
77 template <
typename Po
intT>
bool
81 const std::string &
id,
int viewport)
84 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
86 if (am_it != cloud_actor_map_->end ())
88 PCL_WARN (
"[addPointCloud] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
98 template <
typename Po
intT>
bool
102 const std::string &
id,
int viewport)
105 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
107 if (am_it != cloud_actor_map_->end ())
111 am_it->second.geometry_handlers.push_back (geometry_handler);
121 template <
typename Po
intT>
bool
125 const std::string &
id,
int viewport)
128 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
130 if (am_it != cloud_actor_map_->end ())
132 PCL_WARN (
"[addPointCloud] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
146 template <
typename Po
intT>
bool
150 const std::string &
id,
int viewport)
153 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
154 if (am_it != cloud_actor_map_->end ())
158 am_it->second.color_handlers.push_back (color_handler);
167 template <
typename Po
intT>
bool
172 const std::string &
id,
int viewport)
175 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
176 if (am_it != cloud_actor_map_->end ())
180 am_it->second.geometry_handlers.push_back (geometry_handler);
181 am_it->second.color_handlers.push_back (color_handler);
188 template <
typename Po
intT>
bool
193 const std::string &
id,
int viewport)
196 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
198 if (am_it != cloud_actor_map_->end ())
200 PCL_WARN (
"[addPointCloud] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
212 template <
typename Po
intT>
void
213 pcl::visualization::PCLVisualizer::convertPointCloudToVTKPolyData (
221 allocVtkPolyData (polydata);
223 polydata->SetVerts (vertices);
227 vertices = polydata->GetVerts ();
231 vtkIdType nr_points = cloud->
points.size ();
237 points->SetDataTypeToFloat ();
238 polydata->SetPoints (points);
240 points->SetNumberOfPoints (nr_points);
243 float *data = (
static_cast<vtkFloatArray*
> (points->GetData ()))->GetPointer (0);
248 for (vtkIdType i = 0; i < nr_points; ++i)
249 memcpy (&data[i * 3], &cloud->
points[i].x, 12);
254 for (vtkIdType i = 0; i < nr_points; ++i)
257 if (!pcl_isfinite (cloud->
points[i].x) ||
258 !pcl_isfinite (cloud->
points[i].y) ||
259 !pcl_isfinite (cloud->
points[i].z))
262 memcpy (&data[j * 3], &cloud->
points[i].x, 12);
266 points->SetNumberOfPoints (nr_points);
270 updateCells (cells, initcells, nr_points);
273 vertices->SetCells (nr_points, cells);
277 template <
typename Po
intT>
void
278 pcl::visualization::PCLVisualizer::convertPointCloudToVTKPolyData (
286 allocVtkPolyData (polydata);
288 polydata->SetVerts (vertices);
294 polydata->SetPoints (points);
296 vtkIdType nr_points = points->GetNumberOfPoints ();
299 vertices = polydata->GetVerts ();
304 updateCells (cells, initcells, nr_points);
306 vertices->SetCells (nr_points, cells);
310 template <
typename Po
intT>
bool
313 double r,
double g,
double b,
const std::string &
id,
int viewport)
320 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
321 if (am_it != shape_actor_map_->end ())
326 #if VTK_MAJOR_VERSION < 6
327 all_data->AddInput (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
329 all_data->AddInputData (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
334 #if VTK_MAJOR_VERSION < 6
335 surface_filter->AddInput (vtkUnstructuredGrid::SafeDownCast (data));
337 surface_filter->AddInputData (vtkUnstructuredGrid::SafeDownCast (data));
340 #if VTK_MAJOR_VERSION < 6
341 all_data->AddInput (poly_data);
343 all_data->AddInputData (poly_data);
348 createActorFromVTKDataSet (all_data->GetOutput (), actor);
349 actor->GetProperty ()->SetRepresentationToWireframe ();
350 actor->GetProperty ()->SetColor (r, g, b);
351 actor->GetMapper ()->ScalarVisibilityOff ();
352 removeActorFromRenderer (am_it->second, viewport);
353 addActorToRenderer (actor, viewport);
356 (*shape_actor_map_)[id] = actor;
362 createActorFromVTKDataSet (data, actor);
363 actor->GetProperty ()->SetRepresentationToWireframe ();
364 actor->GetProperty ()->SetColor (r, g, b);
365 actor->GetMapper ()->ScalarVisibilityOff ();
366 addActorToRenderer (actor, viewport);
369 (*shape_actor_map_)[id] = actor;
376 template <
typename Po
intT>
bool
379 double r,
double g,
double b,
const std::string &
id,
int viewport)
386 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
387 if (am_it != shape_actor_map_->end ())
392 #if VTK_MAJOR_VERSION < 6
393 all_data->AddInput (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
395 all_data->AddInputData (reinterpret_cast<vtkPolyDataMapper*> ((vtkActor::SafeDownCast (am_it->second))->GetMapper ())->GetInput ());
400 #if VTK_MAJOR_VERSION < 6
401 surface_filter->SetInput (vtkUnstructuredGrid::SafeDownCast (data));
403 surface_filter->SetInputData (vtkUnstructuredGrid::SafeDownCast (data));
406 #if VTK_MAJOR_VERSION < 6
407 all_data->AddInput (poly_data);
409 all_data->AddInputData (poly_data);
414 createActorFromVTKDataSet (all_data->GetOutput (), actor);
415 actor->GetProperty ()->SetRepresentationToWireframe ();
416 actor->GetProperty ()->SetColor (r, g, b);
417 actor->GetMapper ()->ScalarVisibilityOn ();
418 actor->GetProperty ()->BackfaceCullingOff ();
419 removeActorFromRenderer (am_it->second, viewport);
420 addActorToRenderer (actor, viewport);
423 (*shape_actor_map_)[id] = actor;
429 createActorFromVTKDataSet (data, actor);
430 actor->GetProperty ()->SetRepresentationToWireframe ();
431 actor->GetProperty ()->SetColor (r, g, b);
432 actor->GetMapper ()->ScalarVisibilityOn ();
433 actor->GetProperty ()->BackfaceCullingOff ();
434 addActorToRenderer (actor, viewport);
437 (*shape_actor_map_)[id] = actor;
443 template <
typename Po
intT>
bool
446 const std::string &
id,
int viewport)
448 return (!addPolygon<PointT> (cloud, 0.5, 0.5, 0.5,
id, viewport));
452 template <
typename P1,
typename P2>
bool
456 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
457 if (am_it != shape_actor_map_->end ())
459 PCL_WARN (
"[addLine] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
467 createActorFromVTKDataSet (data, actor);
468 actor->GetProperty ()->SetRepresentationToWireframe ();
469 actor->GetProperty ()->SetColor (r, g, b);
470 actor->GetMapper ()->ScalarVisibilityOff ();
471 addActorToRenderer (actor, viewport);
474 (*shape_actor_map_)[id] = actor;
479 template <
typename P1,
typename P2>
bool
483 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
484 if (am_it != shape_actor_map_->end ())
486 PCL_WARN (
"[addArrow] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
492 leader->GetPositionCoordinate ()->SetCoordinateSystemToWorld ();
493 leader->GetPositionCoordinate ()->SetValue (pt1.x, pt1.y, pt1.z);
494 leader->GetPosition2Coordinate ()->SetCoordinateSystemToWorld ();
495 leader->GetPosition2Coordinate ()->SetValue (pt2.x, pt2.y, pt2.z);
496 leader->SetArrowStyleToFilled ();
497 leader->AutoLabelOn ();
499 leader->GetProperty ()->SetColor (r, g, b);
500 addActorToRenderer (leader, viewport);
503 (*shape_actor_map_)[id] = leader;
508 template <
typename P1,
typename P2>
bool
512 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
513 if (am_it != shape_actor_map_->end ())
515 PCL_WARN (
"[addArrow] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
521 leader->GetPositionCoordinate ()->SetCoordinateSystemToWorld ();
522 leader->GetPositionCoordinate ()->SetValue (pt1.x, pt1.y, pt1.z);
523 leader->GetPosition2Coordinate ()->SetCoordinateSystemToWorld ();
524 leader->GetPosition2Coordinate ()->SetValue (pt2.x, pt2.y, pt2.z);
525 leader->SetArrowStyleToFilled ();
526 leader->SetArrowPlacementToPoint1 ();
528 leader->AutoLabelOn ();
530 leader->AutoLabelOff ();
532 leader->GetProperty ()->SetColor (r, g, b);
533 addActorToRenderer (leader, viewport);
536 (*shape_actor_map_)[id] = leader;
540 template <
typename P1,
typename P2>
bool
542 double r_line,
double g_line,
double b_line,
543 double r_text,
double g_text,
double b_text,
544 const std::string &
id,
int viewport)
547 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
548 if (am_it != shape_actor_map_->end ())
550 PCL_WARN (
"[addArrow] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
556 leader->GetPositionCoordinate ()->SetCoordinateSystemToWorld ();
557 leader->GetPositionCoordinate ()->SetValue (pt1.x, pt1.y, pt1.z);
558 leader->GetPosition2Coordinate ()->SetCoordinateSystemToWorld ();
559 leader->GetPosition2Coordinate ()->SetValue (pt2.x, pt2.y, pt2.z);
560 leader->SetArrowStyleToFilled ();
561 leader->AutoLabelOn ();
563 leader->GetLabelTextProperty()->SetColor(r_text, g_text, b_text);
565 leader->GetProperty ()->SetColor (r_line, g_line, b_line);
566 addActorToRenderer (leader, viewport);
569 (*shape_actor_map_)[id] = leader;
574 template <
typename P1,
typename P2>
bool
577 return (!addLine (pt1, pt2, 0.5, 0.5, 0.5,
id, viewport));
581 template <
typename Po
intT>
bool
585 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
586 if (am_it != shape_actor_map_->end ())
588 PCL_WARN (
"[addSphere] A shape with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
593 data->SetRadius (radius);
594 data->SetCenter (
double (center.x), double (center.y), double (center.z));
595 data->SetPhiResolution (10);
596 data->SetThetaResolution (10);
597 data->LatLongTessellationOff ();
602 mapper->SetInputConnection (data->GetOutputPort ());
606 actor->SetMapper (mapper);
608 actor->GetProperty ()->SetRepresentationToSurface ();
609 actor->GetProperty ()->SetInterpolationToFlat ();
610 actor->GetProperty ()->SetColor (r, g, b);
611 actor->GetMapper ()->ImmediateModeRenderingOn ();
612 actor->GetMapper ()->StaticOn ();
613 actor->GetMapper ()->ScalarVisibilityOff ();
614 actor->GetMapper ()->Update ();
615 addActorToRenderer (actor, viewport);
618 (*shape_actor_map_)[id] = actor;
623 template <
typename Po
intT>
bool
626 return (addSphere (center, radius, 0.5, 0.5, 0.5,
id, viewport));
630 template<
typename Po
intT>
bool
634 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
635 if (am_it == shape_actor_map_->end ())
640 vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second);
641 #if VTK_MAJOR_VERSION < 6
642 vtkAlgorithm *algo = actor->GetMapper ()->GetInput ()->GetProducerPort ()->GetProducer ();
644 vtkAlgorithm *algo = actor->GetMapper ()->GetInputAlgorithm ();
646 vtkSphereSource *src = vtkSphereSource::SafeDownCast (algo);
648 src->SetCenter (
double (center.x), double (center.y), double (center.z));
649 src->SetRadius (radius);
651 actor->GetProperty ()->SetColor (r, g, b);
658 template <
typename Po
intT>
bool
660 const std::string &text,
666 const std::string &
id,
676 ShapeActorMap::iterator am_it = shape_actor_map_->find (tid);
677 if (am_it != shape_actor_map_->end ())
679 pcl::console::print_warn (stderr,
"[addText3d] A text with id <%s> already exists! Please choose a different id and retry.\n", tid.c_str ());
684 textSource->SetText (text.c_str());
685 textSource->Update ();
688 textMapper->SetInputConnection (textSource->GetOutputPort ());
691 rens_->InitTraversal ();
692 vtkRenderer* renderer = NULL;
694 while ((renderer = rens_->GetNextItem ()) != NULL)
697 if (viewport == 0 || viewport == i)
700 textActor->SetMapper (textMapper);
701 textActor->SetPosition (position.x, position.y, position.z);
702 textActor->SetScale (textScale);
703 textActor->GetProperty ()->SetColor (r, g, b);
704 textActor->SetCamera (renderer->GetActiveCamera ());
706 renderer->AddActor (textActor);
711 std::string alternate_tid = tid;
712 alternate_tid.append(i,
'*');
714 (*shape_actor_map_)[(viewport == 0) ? tid : alternate_tid] = textActor;
724 template <
typename Po
intNT>
bool
727 int level,
float scale,
const std::string &
id,
int viewport)
729 return (addPointCloudNormals<PointNT, PointNT> (cloud, cloud, level, scale,
id, viewport));
733 template <
typename Po
intT,
typename Po
intNT>
bool
737 int level,
float scale,
738 const std::string &
id,
int viewport)
742 PCL_ERROR (
"[addPointCloudNormals] The number of points differs from the number of normals!\n");
746 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
748 if (am_it != cloud_actor_map_->end ())
750 PCL_WARN (
"[addPointCloudNormals] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
757 points->SetDataTypeToFloat ();
759 data->SetNumberOfComponents (3);
762 vtkIdType nr_normals = 0;
768 vtkIdType point_step =
static_cast<vtkIdType
> (sqrt (
double (level)));
769 nr_normals = (
static_cast<vtkIdType
> ((cloud->
width - 1)/ point_step) + 1) *
770 (static_cast<vtkIdType> ((cloud->
height - 1) / point_step) + 1);
771 pts =
new float[2 * nr_normals * 3];
773 vtkIdType cell_count = 0;
774 for (vtkIdType y = 0; y < normals->
height; y += point_step)
775 for (vtkIdType x = 0; x < normals->
width; x += point_step)
777 PointT p = (*cloud)(x, y);
778 p.x += (*normals)(x, y).normal[0] * scale;
779 p.y += (*normals)(x, y).normal[1] * scale;
780 p.z += (*normals)(x, y).normal[2] * scale;
782 pts[2 * cell_count * 3 + 0] = (*cloud)(x, y).x;
783 pts[2 * cell_count * 3 + 1] = (*cloud)(x, y).y;
784 pts[2 * cell_count * 3 + 2] = (*cloud)(x, y).z;
785 pts[2 * cell_count * 3 + 3] = p.x;
786 pts[2 * cell_count * 3 + 4] = p.y;
787 pts[2 * cell_count * 3 + 5] = p.z;
789 lines->InsertNextCell (2);
790 lines->InsertCellPoint (2 * cell_count);
791 lines->InsertCellPoint (2 * cell_count + 1);
797 nr_normals = (cloud->
points.size () - 1) / level + 1 ;
798 pts =
new float[2 * nr_normals * 3];
800 for (vtkIdType i = 0, j = 0; j < nr_normals; j++, i = j * level)
803 p.x += normals->
points[i].normal[0] * scale;
804 p.y += normals->
points[i].normal[1] * scale;
805 p.z += normals->
points[i].normal[2] * scale;
807 pts[2 * j * 3 + 0] = cloud->
points[i].x;
808 pts[2 * j * 3 + 1] = cloud->
points[i].y;
809 pts[2 * j * 3 + 2] = cloud->
points[i].z;
810 pts[2 * j * 3 + 3] = p.x;
811 pts[2 * j * 3 + 4] = p.y;
812 pts[2 * j * 3 + 5] = p.z;
814 lines->InsertNextCell (2);
815 lines->InsertCellPoint (2 * j);
816 lines->InsertCellPoint (2 * j + 1);
820 data->SetArray (&pts[0], 2 * nr_normals * 3, 0);
821 points->SetData (data);
824 polyData->SetPoints (points);
825 polyData->SetLines (lines);
828 #if VTK_MAJOR_VERSION < 6
829 mapper->SetInput (polyData);
831 mapper->SetInputData (polyData);
833 mapper->SetColorModeToMapScalars();
834 mapper->SetScalarModeToUsePointData();
838 actor->SetMapper (mapper);
841 addActorToRenderer (actor, viewport);
844 (*cloud_actor_map_)[id].actor = actor;
849 template <
typename Po
intT,
typename GradientT>
bool
853 int level,
double scale,
854 const std::string &
id,
int viewport)
858 PCL_ERROR (
"[addPointCloudGradients] The number of points differs from the number of gradients!\n");
862 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
864 if (am_it != cloud_actor_map_->end ())
866 PCL_WARN (
"[addPointCloudGradients] A PointCloud with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
873 points->SetDataTypeToFloat ();
875 data->SetNumberOfComponents (3);
877 vtkIdType nr_gradients = (cloud->
points.size () - 1) / level + 1 ;
878 float* pts =
new float[2 * nr_gradients * 3];
880 for (vtkIdType i = 0, j = 0; j < nr_gradients; j++, i = j * level)
883 p.x += gradients->
points[i].gradient[0] * scale;
884 p.y += gradients->
points[i].gradient[1] * scale;
885 p.z += gradients->
points[i].gradient[2] * scale;
887 pts[2 * j * 3 + 0] = cloud->
points[i].x;
888 pts[2 * j * 3 + 1] = cloud->
points[i].y;
889 pts[2 * j * 3 + 2] = cloud->
points[i].z;
890 pts[2 * j * 3 + 3] = p.x;
891 pts[2 * j * 3 + 4] = p.y;
892 pts[2 * j * 3 + 5] = p.z;
894 lines->InsertNextCell(2);
895 lines->InsertCellPoint(2*j);
896 lines->InsertCellPoint(2*j+1);
899 data->SetArray (&pts[0], 2 * nr_gradients * 3, 0);
900 points->SetData (data);
903 polyData->SetPoints(points);
904 polyData->SetLines(lines);
907 #if VTK_MAJOR_VERSION < 6
908 mapper->SetInput (polyData);
910 mapper->SetInputData (polyData);
912 mapper->SetColorModeToMapScalars();
913 mapper->SetScalarModeToUsePointData();
917 actor->SetMapper (mapper);
920 addActorToRenderer (actor, viewport);
923 (*cloud_actor_map_)[id].actor = actor;
928 template <
typename Po
intT>
bool
932 const std::vector<int> &correspondences,
933 const std::string &
id,
937 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
938 if (am_it != shape_actor_map_->end ())
940 PCL_WARN (
"[addCorrespondences] A set of correspondences with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
944 int n_corr = int (correspondences.size ());
949 line_colors->SetNumberOfComponents (3);
950 line_colors->SetName (
"Colors");
951 line_colors->SetNumberOfTuples (n_corr);
952 unsigned char* colors = line_colors->GetPointer (0);
953 memset (colors, 0, line_colors->GetNumberOfTuples () * line_colors->GetNumberOfComponents ());
956 rgb.r = 255; rgb.g = rgb.b = 0;
960 line_points->SetNumberOfPoints (2 * n_corr);
963 line_cells_id->SetNumberOfComponents (3);
964 line_cells_id->SetNumberOfTuples (n_corr);
965 vtkIdType *line_cell_id = line_cells_id->GetPointer (0);
969 line_tcoords->SetNumberOfComponents (1);
970 line_tcoords->SetNumberOfTuples (n_corr * 2);
971 line_tcoords->SetName (
"Texture Coordinates");
973 double tc[3] = {0.0, 0.0, 0.0};
977 for (
int i = 0; i < n_corr; ++i)
980 const PointT &p_tgt = target_points->
points[correspondences[i]];
982 int id1 = j * 2 + 0, id2 = j * 2 + 1;
984 line_points->SetPoint (id1, p_src.x, p_src.y, p_src.z);
985 line_points->SetPoint (id2, p_tgt.x, p_tgt.y, p_tgt.z);
988 *line_cell_id++ = id1;
989 *line_cell_id++ = id2;
991 tc[0] = 0.; line_tcoords->SetTuple (id1, tc);
992 tc[0] = 1.; line_tcoords->SetTuple (id2, tc);
995 colors[idx+0] = rgb.r;
996 colors[idx+1] = rgb.g;
997 colors[idx+2] = rgb.b;
999 line_colors->SetNumberOfTuples (j);
1000 line_cells_id->SetNumberOfTuples (j);
1001 line_cells->SetCells (n_corr, line_cells_id);
1002 line_points->SetNumberOfPoints (j*2);
1003 line_tcoords->SetNumberOfTuples (j*2);
1006 line_data->SetPoints (line_points);
1007 line_data->SetLines (line_cells);
1008 line_data->GetPointData ()->SetTCoords (line_tcoords);
1009 line_data->GetCellData ()->SetScalars (line_colors);
1013 createActorFromVTKDataSet (line_data, actor);
1014 actor->GetProperty ()->SetRepresentationToWireframe ();
1015 actor->GetProperty ()->SetOpacity (0.5);
1016 addActorToRenderer (actor, viewport);
1019 (*shape_actor_map_)[id] = actor;
1025 template <
typename Po
intT>
bool
1031 const std::string &
id,
1034 if (correspondences.empty ())
1036 PCL_DEBUG (
"[addCorrespondences] An empty set of correspondences given! Nothing to display.\n");
1041 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
1042 if (am_it != shape_actor_map_->end ())
1044 PCL_WARN (
"[addCorrespondences] A set of correspondences with id <%s> already exists! Please choose a different id and retry.\n",
id.c_str ());
1048 int n_corr = int (correspondences.size () / nth + 1);
1053 line_colors->SetNumberOfComponents (3);
1054 line_colors->SetName (
"Colors");
1055 line_colors->SetNumberOfTuples (n_corr);
1056 unsigned char* colors = line_colors->GetPointer (0);
1057 memset (colors, 0, line_colors->GetNumberOfTuples () * line_colors->GetNumberOfComponents ());
1060 rgb.r = 255; rgb.g = rgb.b = 0;
1064 line_points->SetNumberOfPoints (2 * n_corr);
1067 line_cells_id->SetNumberOfComponents (3);
1068 line_cells_id->SetNumberOfTuples (n_corr);
1069 vtkIdType *line_cell_id = line_cells_id->GetPointer (0);
1073 line_tcoords->SetNumberOfComponents (1);
1074 line_tcoords->SetNumberOfTuples (n_corr * 2);
1075 line_tcoords->SetName (
"Texture Coordinates");
1077 double tc[3] = {0.0, 0.0, 0.0};
1081 for (
size_t i = 0; i < correspondences.size (); i += nth, idx = j * 3, ++j)
1083 const PointT &p_src = source_points->
points[correspondences[i].index_query];
1084 const PointT &p_tgt = target_points->
points[correspondences[i].index_match];
1086 int id1 = j * 2 + 0, id2 = j * 2 + 1;
1088 line_points->SetPoint (id1, p_src.x, p_src.y, p_src.z);
1089 line_points->SetPoint (id2, p_tgt.x, p_tgt.y, p_tgt.z);
1091 *line_cell_id++ = 2;
1092 *line_cell_id++ = id1;
1093 *line_cell_id++ = id2;
1095 tc[0] = 0.; line_tcoords->SetTuple (id1, tc);
1096 tc[0] = 1.; line_tcoords->SetTuple (id2, tc);
1099 colors[idx+0] = rgb.r;
1100 colors[idx+1] = rgb.g;
1101 colors[idx+2] = rgb.b;
1103 line_colors->SetNumberOfTuples (j);
1104 line_cells_id->SetNumberOfTuples (j);
1105 line_cells->SetCells (n_corr, line_cells_id);
1106 line_points->SetNumberOfPoints (j*2);
1107 line_tcoords->SetNumberOfTuples (j*2);
1110 line_data->SetPoints (line_points);
1111 line_data->SetLines (line_cells);
1112 line_data->GetPointData ()->SetTCoords (line_tcoords);
1113 line_data->GetCellData ()->SetScalars (line_colors);
1117 createActorFromVTKDataSet (line_data, actor);
1118 actor->GetProperty ()->SetRepresentationToWireframe ();
1119 actor->GetProperty ()->SetOpacity (0.5);
1120 addActorToRenderer (actor, viewport);
1123 (*shape_actor_map_)[id] = actor;
1129 template <
typename Po
intT>
bool
1135 const std::string &
id)
1137 if (correspondences.empty ())
1139 PCL_DEBUG (
"[updateCorrespondences] An empty set of correspondences given! Nothing to display.\n");
1144 ShapeActorMap::iterator am_it = shape_actor_map_->find (
id);
1145 if (am_it == shape_actor_map_->end ())
1151 int n_corr = int (correspondences.size () / nth + 1);
1155 line_colors->SetNumberOfComponents (3);
1156 line_colors->SetName (
"Colors");
1157 line_colors->SetNumberOfTuples (n_corr);
1158 unsigned char* colors = line_colors->GetPointer (0);
1159 memset (colors, 0, line_colors->GetNumberOfTuples () * line_colors->GetNumberOfComponents ());
1162 rgb.r = 255.0; rgb.g = rgb.b = 0.0;
1166 line_points->SetNumberOfPoints (2 * n_corr);
1169 line_cells_id->SetNumberOfComponents (3);
1170 line_cells_id->SetNumberOfTuples (n_corr);
1171 vtkIdType *line_cell_id = line_cells_id->GetPointer (0);
1175 line_tcoords->SetNumberOfComponents (1);
1176 line_tcoords->SetNumberOfTuples (n_corr * 2);
1177 line_tcoords->SetName (
"Texture Coordinates");
1179 double tc[3] = {0.0, 0.0, 0.0};
1183 for (
size_t i = 0; i < correspondences.size (); i += nth, idx = j * 3, ++j)
1185 const PointT &p_src = source_points->
points[correspondences[i].index_query];
1186 const PointT &p_tgt = target_points->
points[correspondences[i].index_match];
1188 int id1 = j * 2 + 0, id2 = j * 2 + 1;
1190 line_points->SetPoint (id1, p_src.x, p_src.y, p_src.z);
1191 line_points->SetPoint (id2, p_tgt.x, p_tgt.y, p_tgt.z);
1193 *line_cell_id++ = 2;
1194 *line_cell_id++ = id1;
1195 *line_cell_id++ = id2;
1197 tc[0] = 0.; line_tcoords->SetTuple (id1, tc);
1198 tc[0] = 1.; line_tcoords->SetTuple (id2, tc);
1201 colors[idx+0] = rgb.r;
1202 colors[idx+1] = rgb.g;
1203 colors[idx+2] = rgb.b;
1205 line_colors->SetNumberOfTuples (j);
1206 line_cells_id->SetNumberOfTuples (j);
1207 line_cells->SetCells (n_corr, line_cells_id);
1208 line_points->SetNumberOfPoints (j*2);
1209 line_tcoords->SetNumberOfTuples (j*2);
1212 line_data->SetPoints (line_points);
1213 line_data->SetLines (line_cells);
1214 line_data->GetPointData ()->SetTCoords (line_tcoords);
1215 line_data->GetCellData ()->SetScalars (line_colors);
1218 #if VTK_MAJOR_VERSION < 6
1219 reinterpret_cast<vtkPolyDataMapper*
>(actor->GetMapper ())->SetInput (line_data);
1221 reinterpret_cast<vtkPolyDataMapper*
> (actor->GetMapper ())->SetInputData (line_data);
1228 template <
typename Po
intT>
bool
1229 pcl::visualization::PCLVisualizer::fromHandlersToScreen (
1232 const std::string &
id,
1234 const Eigen::Vector4f& sensor_origin,
1235 const Eigen::Quaternion<float>& sensor_orientation)
1239 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n",
id.c_str (), geometry_handler.
getName ().c_str ());
1245 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n",
id.c_str (), color_handler.
getName ().c_str ());
1252 convertPointCloudToVTKPolyData<PointT> (geometry_handler, polydata, initcells);
1256 bool has_colors =
false;
1259 if (color_handler.
getColor (scalars))
1261 polydata->GetPointData ()->SetScalars (scalars);
1262 scalars->GetRange (minmax);
1268 createActorFromVTKDataSet (polydata, actor);
1270 actor->GetMapper ()->SetScalarRange (minmax);
1273 addActorToRenderer (actor, viewport);
1276 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
1277 cloud_actor.actor = actor;
1278 cloud_actor.cells = initcells;
1282 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
1283 cloud_actor.viewpoint_transformation_ = transformation;
1284 cloud_actor.actor->SetUserMatrix (transformation);
1285 cloud_actor.actor->Modified ();
1291 template <
typename Po
intT>
bool
1292 pcl::visualization::PCLVisualizer::fromHandlersToScreen (
1293 const PointCloudGeometryHandler<PointT> &geometry_handler,
1294 const ColorHandlerConstPtr &color_handler,
1295 const std::string &
id,
1297 const Eigen::Vector4f& sensor_origin,
1298 const Eigen::Quaternion<float>& sensor_orientation)
1300 if (!geometry_handler.isCapable ())
1302 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n",
id.c_str (), geometry_handler.getName ().c_str ());
1306 if (!color_handler->isCapable ())
1308 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n",
id.c_str (), color_handler->getName ().c_str ());
1315 convertPointCloudToVTKPolyData<PointT> (geometry_handler, polydata, initcells);
1319 bool has_colors =
false;
1322 if (color_handler->getColor (scalars))
1324 polydata->GetPointData ()->SetScalars (scalars);
1325 scalars->GetRange (minmax);
1331 createActorFromVTKDataSet (polydata, actor);
1333 actor->GetMapper ()->SetScalarRange (minmax);
1336 addActorToRenderer (actor, viewport);
1339 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
1340 cloud_actor.actor = actor;
1341 cloud_actor.cells = initcells;
1342 cloud_actor.color_handlers.push_back (color_handler);
1346 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
1347 cloud_actor.viewpoint_transformation_ = transformation;
1348 cloud_actor.actor->SetUserMatrix (transformation);
1349 cloud_actor.actor->Modified ();
1355 template <
typename Po
intT>
bool
1356 pcl::visualization::PCLVisualizer::fromHandlersToScreen (
1357 const GeometryHandlerConstPtr &geometry_handler,
1358 const PointCloudColorHandler<PointT> &color_handler,
1359 const std::string &
id,
1361 const Eigen::Vector4f& sensor_origin,
1362 const Eigen::Quaternion<float>& sensor_orientation)
1364 if (!geometry_handler->isCapable ())
1366 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid geometry handler (%s)!\n",
id.c_str (), geometry_handler->getName ().c_str ());
1370 if (!color_handler.isCapable ())
1372 PCL_WARN (
"[fromHandlersToScreen] PointCloud <%s> requested with an invalid color handler (%s)!\n",
id.c_str (), color_handler.getName ().c_str ());
1379 convertPointCloudToVTKPolyData (geometry_handler, polydata, initcells);
1383 bool has_colors =
false;
1386 if (color_handler.getColor (scalars))
1388 polydata->GetPointData ()->SetScalars (scalars);
1389 scalars->GetRange (minmax);
1395 createActorFromVTKDataSet (polydata, actor);
1397 actor->GetMapper ()->SetScalarRange (minmax);
1400 addActorToRenderer (actor, viewport);
1403 CloudActor& cloud_actor = (*cloud_actor_map_)[id];
1404 cloud_actor.actor = actor;
1405 cloud_actor.cells = initcells;
1406 cloud_actor.geometry_handlers.push_back (geometry_handler);
1410 convertToVtkMatrix (sensor_origin, sensor_orientation, transformation);
1411 cloud_actor.viewpoint_transformation_ = transformation;
1412 cloud_actor.actor->SetUserMatrix (transformation);
1413 cloud_actor.actor->Modified ();
1419 template <
typename Po
intT>
bool
1421 const std::string &
id)
1424 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1426 if (am_it == cloud_actor_map_->end ())
1431 convertPointCloudToVTKPolyData<PointT> (cloud, polydata, am_it->second.cells);
1435 polydata->GetPointData ()->SetScalars (scalars);
1437 minmax[0] = std::numeric_limits<double>::min ();
1438 minmax[1] = std::numeric_limits<double>::max ();
1439 am_it->second.actor->GetMapper ()->ImmediateModeRenderingOff ();
1440 am_it->second.actor->GetMapper ()->SetScalarRange (minmax);
1443 #if VTK_MAJOR_VERSION < 6
1444 reinterpret_cast<vtkPolyDataMapper*
>(am_it->second.actor->GetMapper ())->SetInput (polydata);
1446 reinterpret_cast<vtkPolyDataMapper*
> (am_it->second.actor->GetMapper ())->SetInputData (polydata);
1452 template <
typename Po
intT>
bool
1455 const std::string &
id)
1458 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1460 if (am_it == cloud_actor_map_->end ())
1467 convertPointCloudToVTKPolyData (geometry_handler, polydata, am_it->second.cells);
1471 polydata->GetPointData ()->SetScalars (scalars);
1473 minmax[0] = std::numeric_limits<double>::min ();
1474 minmax[1] = std::numeric_limits<double>::max ();
1475 am_it->second.actor->GetMapper ()->ImmediateModeRenderingOff ();
1476 am_it->second.actor->GetMapper ()->SetScalarRange (minmax);
1479 #if VTK_MAJOR_VERSION < 6
1480 reinterpret_cast<vtkPolyDataMapper*
>(am_it->second.actor->GetMapper ())->SetInput (polydata);
1482 reinterpret_cast<vtkPolyDataMapper*
> (am_it->second.actor->GetMapper ())->SetInputData (polydata);
1489 template <
typename Po
intT>
bool
1492 const std::string &
id)
1495 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1497 if (am_it == cloud_actor_map_->end ())
1507 vtkIdType nr_points = cloud->
points.size ();
1508 points->SetNumberOfPoints (nr_points);
1511 float *data = (
static_cast<vtkFloatArray*
> (points->GetData ()))->GetPointer (0);
1517 for (vtkIdType i = 0; i < nr_points; ++i, pts += 3)
1518 memcpy (&data[pts], &cloud->
points[i].x, 12);
1523 for (vtkIdType i = 0; i < nr_points; ++i)
1529 memcpy (&data[pts], &cloud->
points[i].x, 12);
1534 points->SetNumberOfPoints (nr_points);
1538 updateCells (cells, am_it->second.cells, nr_points);
1541 vertices->SetCells (nr_points, cells);
1547 scalars->GetRange (minmax);
1549 polydata->GetPointData ()->SetScalars (scalars);
1551 am_it->second.actor->GetMapper ()->ImmediateModeRenderingOff ();
1552 am_it->second.actor->GetMapper ()->SetScalarRange (minmax);
1555 #if VTK_MAJOR_VERSION < 6
1556 reinterpret_cast<vtkPolyDataMapper*
>(am_it->second.actor->GetMapper ())->SetInput (polydata);
1558 reinterpret_cast<vtkPolyDataMapper*
> (am_it->second.actor->GetMapper ())->SetInputData (polydata);
1564 template <
typename Po
intT>
bool
1567 const std::vector<pcl::Vertices> &vertices,
1568 const std::string &
id,
1571 if (vertices.empty () || cloud->
points.empty ())
1574 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1575 if (am_it != cloud_actor_map_->end ())
1578 "[addPolygonMesh] A shape with id <%s> already exists! Please choose a different id and retry.\n",
1584 std::vector<pcl::PCLPointField> fields;
1592 colors->SetNumberOfComponents (3);
1593 colors->SetName (
"Colors");
1596 for (
size_t i = 0; i < cloud->
size (); ++i)
1600 memcpy (&rgb_data, reinterpret_cast<const char*> (&cloud->
points[i]) + fields[rgb_idx].offset, sizeof (
pcl::RGB));
1601 unsigned char color[3];
1602 color[0] = rgb_data.r;
1603 color[1] = rgb_data.g;
1604 color[2] = rgb_data.b;
1605 colors->InsertNextTupleValue (color);
1611 vtkIdType nr_points = cloud->
points.size ();
1612 points->SetNumberOfPoints (nr_points);
1616 float *data =
static_cast<vtkFloatArray*
> (points->GetData ())->GetPointer (0);
1619 std::vector<int> lookup;
1623 for (vtkIdType i = 0; i < nr_points; ++i, ptr += 3)
1624 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1628 lookup.resize (nr_points);
1630 for (vtkIdType i = 0; i < nr_points; ++i)
1636 lookup[i] =
static_cast<int> (j);
1637 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1642 points->SetNumberOfPoints (nr_points);
1646 int max_size_of_polygon = -1;
1647 for (
size_t i = 0; i < vertices.size (); ++i)
1648 if (max_size_of_polygon < static_cast<int> (vertices[i].vertices.size ()))
1649 max_size_of_polygon =
static_cast<int> (vertices[i].vertices.size ());
1651 if (vertices.size () > 1)
1655 vtkIdType *cell = cell_array->WritePointer (vertices.size (), vertices.size () * (max_size_of_polygon + 1));
1657 if (lookup.size () > 0)
1659 for (
size_t i = 0; i < vertices.size (); ++i, ++idx)
1661 size_t n_points = vertices[i].vertices.size ();
1664 for (
size_t j = 0; j < n_points; j++, ++idx)
1665 *cell++ = lookup[vertices[i].vertices[j]];
1671 for (
size_t i = 0; i < vertices.size (); ++i, ++idx)
1673 size_t n_points = vertices[i].vertices.size ();
1676 for (
size_t j = 0; j < n_points; j++, ++idx)
1677 *cell++ = vertices[i].vertices[j];
1682 allocVtkPolyData (polydata);
1683 cell_array->GetData ()->SetNumberOfValues (idx);
1684 cell_array->Squeeze ();
1685 polydata->SetPolys (cell_array);
1686 polydata->SetPoints (points);
1689 polydata->GetPointData ()->SetScalars (colors);
1691 createActorFromVTKDataSet (polydata, actor,
false);
1696 size_t n_points = vertices[0].vertices.size ();
1697 polygon->GetPointIds ()->SetNumberOfIds (n_points - 1);
1699 if (lookup.size () > 0)
1701 for (
size_t j = 0; j < (n_points - 1); ++j)
1702 polygon->GetPointIds ()->SetId (j, lookup[vertices[0].vertices[j]]);
1706 for (
size_t j = 0; j < (n_points - 1); ++j)
1707 polygon->GetPointIds ()->SetId (j, vertices[0].vertices[j]);
1711 poly_grid->Allocate (1, 1);
1712 poly_grid->InsertNextCell (polygon->GetCellType (), polygon->GetPointIds ());
1713 poly_grid->SetPoints (points);
1715 poly_grid->GetPointData ()->SetScalars (colors);
1717 createActorFromVTKDataSet (poly_grid, actor,
false);
1719 addActorToRenderer (actor, viewport);
1720 actor->GetProperty ()->SetRepresentationToSurface ();
1722 actor->GetProperty ()->BackfaceCullingOff ();
1723 actor->GetProperty ()->SetInterpolationToFlat ();
1724 actor->GetProperty ()->EdgeVisibilityOff ();
1725 actor->GetProperty ()->ShadingOff ();
1728 (*cloud_actor_map_)[id].actor = actor;
1733 (*cloud_actor_map_)[id].viewpoint_transformation_ = transformation;
1739 template <
typename Po
intT>
bool
1742 const std::vector<pcl::Vertices> &verts,
1743 const std::string &
id)
1752 CloudActorMap::iterator am_it = cloud_actor_map_->find (
id);
1753 if (am_it == cloud_actor_map_->end ())
1765 vtkIdType nr_points = cloud->
points.size ();
1766 points->SetNumberOfPoints (nr_points);
1769 float *data = (
static_cast<vtkFloatArray*
> (points->GetData ()))->GetPointer (0);
1772 std::vector<int> lookup;
1776 for (vtkIdType i = 0; i < nr_points; ++i, ptr += 3)
1777 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1781 lookup.resize (nr_points);
1783 for (vtkIdType i = 0; i < nr_points; ++i)
1789 lookup [i] =
static_cast<int> (j);
1790 memcpy (&data[ptr], &cloud->
points[i].x, sizeof (
float) * 3);
1795 points->SetNumberOfPoints (nr_points);
1799 vtkUnsignedCharArray* colors = vtkUnsignedCharArray::SafeDownCast (polydata->GetPointData ()->GetScalars ());
1801 std::vector<pcl::PCLPointField> fields;
1805 if (rgb_idx != -1 && colors)
1809 for (
size_t i = 0; i < cloud->
size (); ++i)
1814 reinterpret_cast<const char*> (&cloud->
points[i]) + fields[rgb_idx].offset,
1816 unsigned char color[3];
1817 color[0] = rgb_data.r;
1818 color[1] = rgb_data.g;
1819 color[2] = rgb_data.b;
1820 colors->SetTupleValue (j++, color);
1825 int max_size_of_polygon = -1;
1826 for (
size_t i = 0; i < verts.size (); ++i)
1827 if (max_size_of_polygon < static_cast<int> (verts[i].vertices.size ()))
1828 max_size_of_polygon =
static_cast<int> (verts[i].vertices.size ());
1832 vtkIdType *cell = cells->WritePointer (verts.size (), verts.size () * (max_size_of_polygon + 1));
1834 if (lookup.size () > 0)
1836 for (
size_t i = 0; i < verts.size (); ++i, ++idx)
1838 size_t n_points = verts[i].vertices.size ();
1840 for (
size_t j = 0; j < n_points; j++, cell++, ++idx)
1841 *cell = lookup[verts[i].vertices[j]];
1846 for (
size_t i = 0; i < verts.size (); ++i, ++idx)
1848 size_t n_points = verts[i].vertices.size ();
1850 for (
size_t j = 0; j < n_points; j++, cell++, ++idx)
1851 *cell = verts[i].vertices[j];
1854 cells->GetData ()->SetNumberOfValues (idx);
1857 polydata->SetPolys (cells);
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.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
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.
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.
uint32_t width
The point cloud width (if organized as an image-structure).
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) ...
Base Handler class for PointCloud colors.
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
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.
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.
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.
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 isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
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.
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.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values).
uint32_t height
The point cloud height (if organized as an image-structure).