38#ifndef PCL_STANDALONE_MARCHING_CUBES_IMPL_HPP_
39#define PCL_STANDALONE_MARCHING_CUBES_IMPL_HPP_
41#include <pcl/gpu/kinfu_large_scale/standalone_marching_cubes.h>
45template <
typename Po
intT>
54 const Eigen::Vector3f volume_size = Eigen::Vector3f::Constant (volume_size_);
58 tsdf_volume_gpu_->setSize (volume_size);
74 std::cout <<
"VOLUME SIZE IS " << volume_size_ << std::endl;
77 tsdf_volume_gpu_->reset ();
80 fill (tsdf_volume_cpu_.begin (), tsdf_volume_cpu_.end (), 0);
83 loadTsdfCloudToGPU (cloud);
86 return ( runMarchingCubes () );
93template <
typename Po
intT>
void
99 PCL_INFO (
"There are %d cubes to be processed \n",
max_iterations);
100 float cell_size = volume_size_ / voxels_x_;
106 PCL_INFO (
"Processing cube number %d\n", i);
132 PCL_INFO (
"This cloud returned no faces, we skip it!\n");
148 std::stringstream name;
162 return (tsdf_volume_gpu_);
167template <
typename Po
intT> std::vector<int>&
170 return (tsdf_volume_cpu_);
175template <
typename Po
intT>
void
179 convertTsdfVectors (cloud, tsdf_volume_cpu_);
183 tsdf_volume_gpu_->data ().upload (tsdf_volume_cpu_,
cubeColumns);
188template <
typename Po
intT>
void
191 constexpr int DIVISOR = std::numeric_limits<short>::max();
194#pragma omp parallel for \
196 shared(cloud, output)
197 for(
int i = 0; i < (
int) cloud.
size (); ++i)
206 int dst_index = x + voxels_x_ * y + voxels_y_ * voxels_x_ * z;
209 elem.x =
static_cast<short> (cloud[i].intensity * DIVISOR);
210 elem.y =
static_cast<short> (1);
220 if (triangles.
empty () )
226 cloud.width = triangles.
size ();
235 for (std::size_t i = 0; i <
mesh_ptr->polygons.
size (); ++i)
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
std::size_t size() const
Returns size in elements.
void download(T *host_ptr) const
Downloads data from internal buffer to CPU memory.
bool empty() const
Returns true if unallocated otherwise false.
MarchingCubes implements MarchingCubes functionality for TSDF volume on GPU.
StandaloneMarchingCubes(int voxels_x=512, int voxels_y=512, int voxels_z=512, float volume_size=3.0f)
Constructor
pcl::PolygonMesh::Ptr MeshPtr
MeshPtr getMeshFromTSDFCloud(const PointCloud &cloud)
Run marching cubes in a TSDF cloud and returns a PolygonMesh.
MeshPtr convertTrianglesToMesh(const pcl::gpu::DeviceArray< pcl::PointXYZ > &triangles)
Converts the triangles buffer device to a PolygonMesh.
void getMeshesFromTSDFVector(const std::vector< PointCloudPtr > &tsdf_clouds, const std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > &tsdf_offsets)
Runs marching cubes on every pointcloud in the vector.
void convertTsdfVectors(const PointCloud &cloud, std::vector< int > &output)
Read the data in the point cloud.
std::vector< int > & tsdfVolumeCPU()
Returns the associated Tsdf Volume buffer in CPU.
void loadTsdfCloudToGPU(const PointCloud &cloud)
Loads a TSDF Cloud to the TSDF Volume in GPU.
MeshPtr runMarchingCubes()
Runs marching cubes on the data that is contained in the TSDF Volume in GPU.
TsdfVolume::Ptr tsdfVolumeGPU()
Returns the associated Tsdf Volume buffer in GPU.
shared_ptr< TsdfVolume > Ptr
void transformPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const Eigen::Matrix< Scalar, 4, 4 > &transform, bool copy_all_fields)
Apply a rigid transform defined by a 4x4 matrix.
int savePLYFile(const std::string &file_name, const pcl::PCLPointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), bool binary_mode=false, bool use_camera=true)
Save point cloud data to a PLY file containing n-D points.
Defines functions, macros and traits for allocating and using memory.
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
shared_ptr< ::pcl::PolygonMesh > Ptr
Describes a set of vertices in a polygon mesh, by basically storing an array of indices.