MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / getGeometry

Method getGeometry

visualization/src/point_cloud_handlers.cpp:682–744  ·  view source on GitHub ↗

//////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

680
681///////////////////////////////////////////////////////////////////////////////////////////
682void
683pcl::visualization::PointCloudGeometryHandler<pcl::PCLPointCloud2>::getGeometry (vtkSmartPointer<vtkPoints> &points) const
684{
685 if (!capable_)
686 return;
687
688 if (!points)
689 points = vtkSmartPointer<vtkPoints>::New ();
690 points->SetDataTypeToFloat ();
691
692 vtkSmartPointer<vtkFloatArray> data = vtkSmartPointer<vtkFloatArray>::New ();
693 data->SetNumberOfComponents (3);
694
695 vtkIdType nr_points = cloud_->width * cloud_->height;
696
697 if (!data->Resize(nr_points))
698 {
699 PCL_ERROR("[point_cloud_handlers::getGeometry] Failed to allocate space for points in VTK array.\n");
700 throw std::bad_alloc();
701 }
702
703
704 // Add all points
705 int point_offset = 0;
706
707 // If the dataset has no invalid values, just copy all of them
708 if (cloud_->is_dense)
709 {
710 for (vtkIdType i = 0; i < nr_points; ++i, point_offset+=cloud_->point_step)
711 {
712 const float* ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_x_idx_].offset]);
713 data->InsertNextValue(*ptr);
714
715 ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_y_idx_].offset]);
716 data->InsertNextValue(*ptr);
717
718 ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_z_idx_].offset]);
719 data->InsertNextValue(*ptr);
720 }
721 points->SetData (data);
722 }
723 else
724 {
725 for (vtkIdType i = 0; i < nr_points; ++i, point_offset+=cloud_->point_step)
726 {
727 const float* ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_x_idx_].offset]);
728 if (!std::isfinite (*ptr))
729 continue;
730 data->InsertNextValue(*ptr);
731
732 ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_y_idx_].offset]);
733 if (!std::isfinite (*ptr))
734 continue;
735 data->InsertNextValue(*ptr);
736
737 ptr = reinterpret_cast<const float*>(&cloud_->data[point_offset + cloud_->fields[field_z_idx_].offset]);
738 if (!std::isfinite (*ptr))
739 continue;

Callers 2

OnKeyDownMethod · 0.45

Calls 2

NewFunction · 0.85
ResizeMethod · 0.45

Tested by

no test coverage detected