40 #ifndef PCL_SURFACE_IMPL_POISSON_H_
41 #define PCL_SURFACE_IMPL_POISSON_H_
48 #include <pcl/surface/poisson/octree_poisson.h>
49 #include <pcl/surface/poisson/sparse_matrix.h>
50 #include <pcl/surface/poisson/function_data.h>
51 #include <pcl/surface/poisson/ppolynomial.h>
52 #include <pcl/surface/poisson/multi_grid_octree_data.h>
54 #define MEMORY_ALLOCATOR_BLOCK_SIZE 1<<12
62 template <
typename Po
intNT>
65 no_reset_samples_ (false),
66 no_clip_tree_ (false),
69 output_polygons_ (false),
76 samples_per_node_ (1.0),
82 template <
typename Po
intNT>
88 template <
typename Po
intNT>
template <
int Degree>
void
90 poisson::Point3D<float> ¢er,
93 float isoValue = 0.0f;
96 poisson::TreeNodeData::UseIndex = 1;
98 poisson::Octree<Degree> tree;
99 poisson::PPolynomial<Degree> ReconstructionFunction = poisson::PPolynomial<Degree>::GaussianApproximation ();
101 center.coords[0] = center.coords[1] = center.coords[2] = 0.0f;
105 kernel_depth_ = depth_ - 2;
108 tree.setFunctionData (ReconstructionFunction, depth_, 0, poisson::Real (1.0f) / poisson::Real (1 << depth_));
115 tree.setTree (input_, depth_, kernel_depth_,
float (samples_per_node_), scale_, center, scale, !no_reset_samples_, confidence_);
117 printf (
"scale after settree %f\n", scale);
124 tree.finalize1 (refine_);
126 tree.maxMemoryUsage = 0;
127 tree.SetLaplacianWeights ();
129 tree.finalize2 (refine_);
131 tree.maxMemoryUsage = 0;
132 tree.LaplacianMatrixIteration (solver_divide_);
134 tree.maxMemoryUsage = 0;
135 isoValue = tree.GetIsoValue ();
138 tree.GetMCIsoTriangles (isoValue, iso_divide_, &mesh, 0, 1, manifold_, output_polygons_);
140 tree.GetMCIsoTriangles (isoValue, &mesh, 0, 1, manifold_, output_polygons_);
145 template <
typename Po
intNT>
void
148 poisson::CoredVectorMeshData mesh;
149 poisson::Point3D<float> center;
156 execute<1> (mesh, center, scale);
161 execute<2> (mesh, center, scale);
166 execute<3> (mesh, center, scale);
171 execute<4> (mesh, center, scale);
176 execute<5> (mesh, center, scale);
181 PCL_ERROR (stderr,
"Degree %d not supported\n", degree_);
188 cloud.
points.resize (
int (mesh.outOfCorePointCount () + mesh.inCorePoints.size ()));
189 poisson::Point3D<float> p;
190 for (
int i = 0; i < int (mesh.inCorePoints.size ()); i++)
192 p = mesh.inCorePoints[i];
193 cloud.
points[i].x = p.coords[0]*scale+center.coords[0];
194 cloud.
points[i].y = p.coords[1]*scale+center.coords[1];
195 cloud.
points[i].z = p.coords[2]*scale+center.coords[2];
197 for (
int i =
int (mesh.inCorePoints.size ()); i < int (mesh.outOfCorePointCount () + mesh.inCorePoints.size ()); i++)
199 mesh.nextOutOfCorePoint (p);
200 cloud.
points[i].x = p.coords[0]*scale+center.coords[0];
201 cloud.
points[i].y = p.coords[1]*scale+center.coords[1];
202 cloud.
points[i].z = p.coords[2]*scale+center.coords[2];
205 output.
polygons.resize (mesh.polygonCount ());
208 std::vector<poisson::CoredVertexIndex> polygon;
209 for (
int p_i = 0; p_i < mesh.polygonCount (); p_i++)
212 mesh.nextPolygon (polygon);
213 v.
vertices.resize (polygon.size ());
215 for (
int i = 0; i < static_cast<int> (polygon.size ()); ++i)
216 if (polygon[i].inCore )
219 v.
vertices[i] = polygon[i].idx + int (mesh.inCorePoints.size ());
226 template <
typename Po
intNT>
void
228 std::vector<pcl::Vertices> &polygons)
230 poisson::CoredVectorMeshData mesh;
231 poisson::Point3D<float> center;
238 execute<1> (mesh, center, scale);
243 execute<2> (mesh, center, scale);
248 execute<3> (mesh, center, scale);
253 execute<4> (mesh, center, scale);
258 execute<5> (mesh, center, scale);
263 PCL_ERROR (stderr,
"Degree %d not supported\n", degree_);
269 points.
points.resize (
int (mesh.outOfCorePointCount () + mesh.inCorePoints.size ()));
270 poisson::Point3D<float> p;
271 for (
int i = 0; i < int(mesh.inCorePoints.size ()); i++)
273 p = mesh.inCorePoints[i];
274 points.
points[i].x = p.coords[0]*scale+center.coords[0];
275 points.
points[i].y = p.coords[1]*scale+center.coords[1];
276 points.
points[i].z = p.coords[2]*scale+center.coords[2];
278 for (
int i =
int(mesh.inCorePoints.size()); i < int (mesh.outOfCorePointCount() + mesh.inCorePoints.size ()); i++)
280 mesh.nextOutOfCorePoint (p);
281 points.
points[i].x = p.coords[0]*scale+center.coords[0];
282 points.
points[i].y = p.coords[1]*scale+center.coords[1];
283 points.
points[i].z = p.coords[2]*scale+center.coords[2];
288 polygons.resize (mesh.polygonCount ());
291 std::vector<poisson::CoredVertexIndex> polygon;
292 for (
int p_i = 0; p_i < mesh.polygonCount (); p_i++)
295 mesh.nextPolygon (polygon);
296 v.
vertices.resize (polygon.size ());
298 for (
int i = 0; i < static_cast<int> (polygon.size ()); ++i)
299 if (polygon[i].inCore )
302 v.
vertices[i] = polygon[i].idx + int (mesh.inCorePoints.size ());
309 #define PCL_INSTANTIATE_Poisson(T) template class PCL_EXPORTS pcl::Poisson<T>;
311 #endif // PCL_SURFACE_IMPL_POISSON_H_