Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

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


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

Dear all,

The code should be 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 "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");
}


Thanks,
Zhanghong Tang





Archive powered by MHonArc 2.6.18.

Top of Page