Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Error in CGAL bool operation

Subject: CGAL users discussion list

List archive

[cgal-discuss] Error in CGAL bool operation


Chronological Thread 
  • From: Zhanghong Tang <>
  • To: <>
  • Subject: [cgal-discuss] Error in CGAL bool operation
  • Date: Fri, 14 Sep 2012 16:21:10 +1200
  • Importance: Normal

Dear all,

I am trying to do bool operation by CGAL basing on the OFF files. The code is as follows:

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <iostream>
#include <istream>
#include <fstream> 
#include <CGAL/IO/Polyhedron_iostream.h> 
#include <CGAL/IO/Nef_polyhedron_iostream_3.h> 
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Nef_polyhedron_3.h>
#include "CSGlib.h"
#include "math.h"

using namespace std; 
typedef CGAL::Exact_predicates_exact_constructions_kernel        Kernel;
typedef CGAL::Simple_cartesian<double>                                            sKernel;
typedef Kernel::Point_3                                                                            Point_3;
typedef CGAL::Nef_polyhedron_3<Kernel>                                            Nef_polyhedron;
typedef CGAL::Polyhedron_3<Kernel>                                                    Polyhedron;
typedef Polyhedron::HalfedgeDS                                                            HalfedgeDS;
typedef Kernel::Plane_3                                                                            Plane_3;
typedef Polyhedron::Vertex_iterator                                                    Vertex_iterator;
typedef Polyhedron::Facet_iterator                                                    Facet_iterator;
typedef Polyhedron::Halfedge_around_facet_circulator                Halfedge_facet_circulator;
typedef Nef_polyhedron::Aff_transformation_3                                Aff_transformation_3;
typedef Nef_polyhedron::Vector_3                                                        Vector_3;

void readoff(Polyhedron *P,char *filename)
{
  std::ifstream stream(filename);
  stream >> *P;
}

void BoolObject3(char *op, char *file1,char *file2,char *outfile)
{
    Polyhedron P1, P2;
    readoff(&P1,file1);
    readoff(&P2,file1);
    Nef_polyhedron NP1(P1);
    Nef_polyhedron NP2(P2);
    switch(*op)
    {
        case '+': NP1 = NP1 + NP2;break;
        case '-': NP1 = NP1 - NP2;break;
        case '*': NP1 = NP1 * NP2;break;
        case '^': NP1 = NP1 ^ NP2;break;
        default:break;
    }
    NP1.convert_to_polyhedron(P1);
    // output the polyhedron to OFF file
    std::ofstream log(outfile);
  std::streambuf * oldbuf = std::cout.rdbuf(log.rdbuf());

  std::cout << P1;
    std::cout.rdbuf( oldbuf);
}

int main()
{
    BoolObject3("+", "a1.off","a2.off","a3.off");
}


The off files are attached.

Now the code crash when running.
Could anyone help me to solve this problem?


Thanks,
Zhanghong Tang

Attachment: off.zip
Description: Zip compressed data




Archive powered by MHonArc 2.6.18.

Top of Page