Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Error in CGAL bool operation to the OFF files

Subject: CGAL users discussion list

List archive

[cgal-discuss] Error in CGAL bool operation to the OFF files


Chronological Thread 
  • From: tang <>
  • To:
  • Subject: [cgal-discuss] Error in CGAL bool operation to the OFF files
  • Date: Fri, 14 Sep 2012 00:02:58 -0700 (PDT)

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 "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


http://cgal-discuss.949826.n4.nabble.com/file/n4655853/off.zip off.zip




--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Error-in-CGAL-bool-operation-to-the-OFF-files-tp4655853.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page