Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors
Chronological Thread
- From: Manuel Bourgault <>
- To:
- Subject: Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors
- Date: Tue, 9 Sep 2014 23:24:58 -0700
Thank you for your answer, i will post the points.
Before that, can you tell me what this error mean ? I juste dont understand
Le 2014-09-10 01:19, "Sebastien Loriot (GeometryFactory)" <> a écrit :
Posting the point set would indeed help.
Sebastien
On 09/09/2014 10:33 PM, manuelB wrote:
Hello everybody,
I discovered CGAL a couple of weeks ago, very great library !
I needed something that can build mesh from a set of points (also heard
about the normal things..). So, i installed it on my Ubuntu machine.
I succeed compiling the "poisson reconstruction example" using the
kitten.xyz file, works really great !
My problem appears when I try to use my own custom .xyz file..
Basically, this is what i have done:
- I wrote an STL file importer ( i get face list with normals )
- I wrote a simple algorythm that creates a set of points
from those faces and compute their normals from the
corresponding faces wich touches that point in the stl file.
- OK, now I have a set of points with normals..
-- Here comes CGAL --
- I ran the simple example for poisson processing ( the same
I tried with the kitten.xyz file... and voila:
terminate called after throwing an instance of
'CGAL::Precondition_excpetion'
what(): CGAL_ERROR: precondition violation!
Expr: dimesion() == 3
File: /usr/include/CGAL/Triangulation_3.h
Line: 463
The first thing i was thinking was that my set of point was probably wrong,
so i started thinking.. The output file of the kitten.xyz (kitten.off) was
really small
and maybe thats because my points were representing a mesh that was too big
!
No luck... Same error.
After that, I tried writing a .xyz file to see if the
CGAL::read_xyz_points_and_normals()
does something I wasnt doing when I was copying the points.
Same error..
The code above is the same as the example:
/* CGAL INCLUDES */
#include <CGAL/trace.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Surface_mesh_default_triangulation_3.h>
#include <CGAL/make_surface_mesh.h>
#include <CGAL/Implicit_surface_3.h>
#include <CGAL/IO/output_surface_facets_to_polyhedron.h>
#include <CGAL/Poisson_reconstruction_function.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/compute_average_spacing.h>
#include <CGAL/Vector_3.h>
#include <CGAL/pca_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_xyz_points.h>
/* standard C++ includes */
#include <utility> // defines std::pair
#include <vector>
#include <fstream>
// usefull types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal;
typedef Kernel::Sphere_3 Sphere;
typedef std::vector<Point_with_normal> PointList;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Poisson_reconstruction_function<Kernel>
Poisson_reconstruction_function;
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
typedef CGAL::Implicit_surface_3<Kernel,Poisson_reconstruction_function>
Surface_3;
// Point with normal vector stored in a std::pair.
typedef std::pair<Point, Vector> PointVectorPair;
int main()
{
FT sm_angle = 20.0; // Min triangle angle in degrees.
FT sm_radius = 30; // Max triangle size w.r.t. point set average
spacing.
FT sm_distance = 0.375; // Surface Approximation error w.r.t. point set
average spacing.
PointList points;
std::ifstream stream("/home/manuel/Desktop/points.xyz");
if (!stream ||
!CGAL::read_xyz_points_and_normals(
stream,
std::back_inserter(points),
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points))))
{
std::cerr << "Error: cannot read file points.xyz" << std::endl;
return -1;
}
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(points));
Poisson_reconstruction_function function(points.begin(), points.end(),
CGAL::make_normal_of_point_with_normal_pmap(points.begin()));
**** ERROR HAPPEN HERE ****
if (!function.compute_implicit_function()) *** <----- ***
{
return -1;
}
// Computes average spacing
FT average_spacing = CGAL::compute_average_spacing(points.begin(),
points.end(), 6 /* knn = 1 ring */);
Point inner_point = function.get_inner_point();
Sphere bsphere = function.bounding_sphere();
FT radius = std::sqrt(bsphere.squared_radius());
FT sm_sphere_radius = 5.0 * radius;
FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy
error must be << sm_distance
Surface_3 surface(function,
Sphere(inner_point,sm_sphere_radius*sm_sphere_radius),
sm_dichotomy_error/sm_sphere_radius);
CGAL::Surface_mesh_default_criteria_3<STr> criteria(sm_angle, // Min
triangle angle (degrees)
sm_radius*average_spacing, // Max triangle size
sm_distance*average_spacing); // Approximation error
STr tr; // 3D Delaunay triangulation for surface mesh generation
C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation
CGAL::make_surface_mesh(c2t3, // reconstructed mesh
surface, // implicit surface
criteria, // meshing criteria
CGAL::Manifold_with_boundary_tag());
if(tr.number_of_vertices() == 0)
return -1;
std::ofstream out("/home/manuel/Desktop/points.off");
Polyhedron output_mesh;
CGAL::output_surface_facets_to_polyhedron(c2t3, output_mesh);
out << output_mesh;
return 0;
}
--------------------------------------------------------------------------------------------------
I dont know was i am doing wrong, and tobe honnest I have
absolutly no idea about the meaning of this error. Thank you
for your time.
PS: i can post the points.xyz file if wanted.
--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/using-custom-xyz-file-for-poisson-reconstruction-cause-errors-tp4659812.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
- [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors, manuelB, 09/09/2014
- Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors, Sebastien Loriot (GeometryFactory), 09/10/2014
- Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors, Manuel Bourgault, 09/10/2014
- Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors, Sebastien Loriot (GeometryFactory), 09/10/2014
- Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors, Manuel Bourgault, 09/10/2014
- Re: [cgal-discuss] using custom .xyz file for poisson reconstruction cause errors, Sebastien Loriot (GeometryFactory), 09/10/2014
Archive powered by MHonArc 2.6.18.