Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Outputting results from an exact kernel

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Outputting results from an exact kernel


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Outputting results from an exact kernel
  • Date: Mon, 06 Dec 2010 18:41:32 +0100

Hamid G wrote:
Hi

What method would you suggest to use in order to write coordinates of points from an exact kernel to a file on hard disk so that when we read it later on we won't use any precision/information ?

Outputting everything in a file is generally not a good solution (but I understand that for testing purpose this is the fastest way, so the first thing to try is to increase the output precision of your stream using ios_base::precision.)

An alternative solution is to use the Polyhedron_incremental_builder
together with the Cartesian_converter (used on Point_3) to convert a
Polyhedron from one kernel to a Polyhedron from another kernel.

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Class_Cartesian_converter.html
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Polyhedron_ref/Class_Polyhedron_incremental_builder_3.html


This is not hard when you are used to, otherwise this is a good
CGAL exercise.

To use Cartesian_converter from Kernel K1 to Kernel K2, you need to do
something like this:
CGAL::Cartesian_converter<K1,K2> converter;

K1::Point_3 p_k1(1,2,3);
K2::Point_3 p_k2 = converter( p_k1 );

I am using different modules from CGAL that don't support a common kernel. So after using each module I write the results to a .OFF file using provided iostream methods. And then I read that file in the next module.

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
CGAL::Polyhedron_3<Kernel> shell;
ofstream fid("out.off")
fid << shell;


I am getting random assertion failures here and there in the modules I am using, similar to this:

terminate called after throwing an instance of 'CGAL::Precondition_exception'
what(): CGAL ERROR: precondition violation!
Expr: ! k.is_degenerate_3_object()(t)
File: /home/hamid/local/include/CGAL/Triangle_3_Segment_3_do_intersect.h

This doesn't happen all the time for the same input and settings!
So I am guessing assertion failures are somehow related to rounding off the coordinates in file I/O operations.

Can the assertion happen at any step 1,2,3,4 ? or is it happening always at 3 or 4? does this happen while reading Polyhedra?

This is a general view of which modules I am using from CGAL:

1- Surface_mesh with gray scale image as input (not sure which kernel 'Surface_mesh_default_triangulation_3' is using)

2- Then the resulting surface mesh from 1 is used in Nef_3 for a subtraction boolean operation with another surface mesh. (here I use 'Exact_predicates_exact_constructions_kernel')

3- The resulting surface mesh from 2 is refined using Exact_predicates_inexact_constructions_kernel in 'Subdivision_method_3'

4- The resulting surface from 3 is then fed to tetrahedral mesh generator which uses Exact_predicates_inexact_constructions_kernel with 'Robust_intersection_traits_3'

Am I using the right kernel ? Any suggestion about which kernels are better fit for this workflow assuming that I am using file I/O to send the data between these modules.

thanks in advance,
Hamid G






Archive powered by MHonArc 2.6.16.

Top of Page