Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Crash with Nef_polyhedron_3

Subject: CGAL users discussion list

List archive

[cgal-discuss] Crash with Nef_polyhedron_3


Chronological Thread 
  • From: James Gregson <(005b7a4cd6%hidden_head%005b7a4cd6)james.gregson(005b7a4cd6%hidden_at%005b7a4cd6)gmail.com(005b7a4cd6%hidden_end%005b7a4cd6)>
  • To: (005b7a4cd6%hidden_head%005b7a4cd6)cgal-discuss(005b7a4cd6%hidden_at%005b7a4cd6)lists-sop.inria.fr(005b7a4cd6%hidden_end%005b7a4cd6)
  • Subject: [cgal-discuss] Crash with Nef_polyhedron_3
  • Date: Mon, 28 May 2012 09:39:04 -0700

Hello,

First of all, thanks for developing and maintaining CGAL, it's been very helpful to me over the past few years.

Now my problem:  I'm trying use Nef_polyhedron_3s for performing boolean operations on solid models.  I've started from sample code (see below) posted in an online forum by Sebastien Loriot some time ago.  I slightly modified the code to use only two polyhedrons rather than 3 and to apply an affine transformation to one of them.

The code frequently crashes with a segmentation fault at the "N1+=N2;" line and it seems to be model dependent. From the polyhedron demo data directory, cube.off works properly but pinion.off fails as does icosahedron.off.   I am running OS-X 10.7, CGAL-4.0 and the default Apple franken-compiler which seems to be a just a wrapper for LLVM.  The makefiles were generated from 'cgal_create_cmake_script'.

Is there a bug for this machine configuration?  Since I get correct results sometimes, it leads me to believe that the source is not terribly wrong...failure on the icosahedron model is particularly surprising since this should be a 'nice' model. 

Thanks for your help,

James Gregson

Here is the code:

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/IO/Nef_polyhedron_iostream_3.h>
#include <iostream>
#include <fstream>

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> > Polyhedron_d;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
typedef Kernel::Vector_3 Vector_3;
typedef Kernel::Aff_transformation_3 Aff_transformation_3;

int main(int argc, char** argv) {
    Polyhedron P1;
    Polyhedron P2;
    Polyhedron P3;
   
    std::ifstream f1("icosahedron.off");
    f1 >> P1;
    std::ifstream f2("icosahedron.off");
    f2 >> P2;
    Nef_polyhedron N1(P1);
    Nef_polyhedron N2(P2);

    Aff_transformation_3 aff(CGAL::TRANSLATION, Vector_3(1,1,0,1));
    N2.transform(aff);
   
    std::cout << N1.number_of_volumes() << std::endl;
    std::cout << N2.number_of_volumes() << std::endl;
   
    N1+=N2;  // model-dependent crash here
   
    std::cout << N1.number_of_volumes() << std::endl;   
    N1.closure().convert_to_polyhedron(P3);
   
    std::ofstream result("results.off");
    result << P3;
    result.close();
   
    return 0;
}



Archive powered by MHonArc 2.6.18.

Top of Page