Skip to Content.
Sympa Menu

cgal-discuss - RE: [cgal-discuss] bug in boolean operations

Subject: CGAL users discussion list

List archive

RE: [cgal-discuss] bug in boolean operations


Chronological Thread 
  • From: Peter Hachenberger <>
  • To:
  • Subject: RE: [cgal-discuss] bug in boolean operations
  • Date: Mon, 30 Jul 2007 15:05:08 +0200

Hi Isabel,

sorry that it took me some time.

Unfortunately, you run into most of the i/o problems of Nef polyhedra.
There are some problems with conversions between Off-files and Nef
polyhedra. What happens in your case, is that some of the facets in the
difference of cube and cylinder are not only triangles, but larger
facets. The output function does not include a triangulation of such
facets, yet. This means, that you still have these large facets in the
off-file, but since the coordinates are now floating-point, the points
are not in the same plane any more. This also means, that the off-file
is not readable any more by Nef_polyhedron_3. This means, you should not
use OFF as an intermediate file format and OFF only as your input format
and ouput-format at the end of all operations with Nef_polyhedron_3. Use
nef_3 file-I/O as follows:

Nef_polyhedron_3 N1, N2;
ofstream out("file1.nef3");
out << N1;
ifstream in("file1.nef3");
in >> N2;


About the two files that you sent (cubmincyl.off and
cubemincylinder.off). First, I had some problem displaying the latter
one with geomview and found out, that geomview does not like it when you
have a file with integer and floating-point coordinates. In
cubemincylinder.off the coordiantes are floating-point, but some are
exactly on integer coordinates and were output without ".0" at the end.
The file was displayable by geomview after I added ".0" to those
coordinates. This is a new phenomenon for me, I hope you did not run
into it.

Second, looking at both files in geomview, they look the same to me.
What viewer are you using and is there a distinctive difference that you
see in the viewer? It would be interesting to know whether any viewers
have problems with our output

Peter

On Mon, 2007-07-23 at 15:54 +0200, Isabel wrote:
> Hi Peter,
> I have a problem. I use
>
> Polyhedron_3 P;
> std::cin >> P;
> Nef_polyhedron N(P);
>
> I can't create the Nef_polyhedron. Why? I need a precondition? There isn't
> any error message but my program fail.
>
> About the boolean difference, I think that the correct difference is
> 'cubmincyl.off' (I make this with rhino 4.0), where the cube has a correct
> hole, and not the other file.
> Thanks, Isabel.
>
>
> De: Peter Hachenberger
> [mailto:]
>
> Enviado el: viernes, 20 de julio de 2007 14:26
> Asunto: Re: [cgal-discuss] bug in boolean operations
>
> Hi Isabel,
>
> the operation takes a lot of time since you use the OFF_to_nef_3 function,
> which tries to convert every OFF file no matter how problematic it is. This
> function is not designed for efficiency but for robustness (I improved the
> efficiency of the function recently and will put it in CGAL-3.3.1). Try to
> use
>
> Polyhedron_3 P;
> std::cin >> P;
> Nef_polyhedron N(P);
>
> This function is much faster, but has some restrictions on the input. If you
> have problems with these restrictions, I might can help you get around these
> problems.
>
> I looked at cubeminclyinder.off in my viewer. It looks fine to me. Can you
> be more specific about what you think is wrong with it?
>
> Peter
>
> On Fri, 2007-07-20 at 11:20 +0200, Isabel wrote:
> > Hi all.
> > I think that I find a bug in boolean operation, the difference of a
> > cube and a cylinder is not correct. There are
> > facets in holes. See 'cubemincylinder.off'
> > I convert to Nef_Polyhedron_3 my two polyhedrons, a cube and a
> > cylinder. This operation spend a lot of time.
> >
> > this is the code:
> > typedef CGAL::Homogeneous<CGAL::Gmpz> Kernel;
> >
> > typedef CGAL::Nef_polyhedron_3<Kernel> Nef_3;
> >
> > typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
> >
> > typedef Kernel::Point_3 Point;
> >
> > typedef Kernel::Vector_3 Vector;
> >
> > typedef Polyhedron::Vertex_iterator Vertex_iterator;
> >
> > typedef Polyhedron::Facet_iterator Facet_iterator;
> >
> > typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
> >
> >
> >
> > int main( int argc, char **argv) {
> >
> > Polyhedron P1, P2, P;
> >
> > const char* name = "cin";
> >
> > istream* p_in1 = &cin;
> >
> > istream* p_in2 = &cin;
> >
> > ifstream in1, in2;
> >
> > in1.open( ".\\cube.off");
> >
> > p_in1 = &in1;
> >
> > Nef_3 N1;
> >
> > std::size_t discarded = CGAL::OFF_to_nef_3 ( *p_in1, N1, true);
> >
> > in2.open( ".\\cylinder.off");
> >
> > p_in2 = &in2;
> >
> > Nef_3 N2;
> >
> > discarded = CGAL::OFF_to_nef_3 ( *p_in2, N2, true);
> >
> > Nef_3 N3;
> >
> > std::cout << "boolean operation in NEF3..." << std::endl;
> >
> > N3 = N1 - N2;
> >
> > std::cout << "Convert to polyhedron..." << std::endl;
> >
> > if(N3.is_simple()) {
> >
> > N3.convert_to_Polyhedron(P);
> >
> > std::cout << N3;
> >
> > const char* oname = "cout";
> >
> > ostream* p_out = &cout;
> >
> > ofstream out;
> >
> > out.open( "cubemincylinder.off");
> >
> > p_out = &out;
> >
> > CGAL::set_ascii_mode( *p_out);
> >
> > (*p_out) << P;
> >
> > }
> >
> > else {
> >
> > std::cout << N3;
> >
> > }
> >
> > return 0;
> >
> > }
> >
> > Thanks Isabel
> >
> >
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss



Archive powered by MHonArc 2.6.16.

Top of Page