Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] CGAL difference on Nef_polyhedron produces shape with duplicate vertices

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] CGAL difference on Nef_polyhedron produces shape with duplicate vertices


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] CGAL difference on Nef_polyhedron produces shape with duplicate vertices
  • Date: Mon, 01 Sep 2014 08:34:04 +0200
  • Organization: GeometryFactory

What kernel are you using internally to do the computation?
I guess you export the result into double/float which result in rounding
of the exact output, which result in points having the same coordinates
in your case.

Sebastien.


On 08/31/2014 02:51 AM, crobar wrote:
Hi,

I'm working on a computational solid geometry package for the Matlab/Octave
programming language. This interface is based on the project pyPolyCSG,
which makes use of CGAL to perform it's operations. I have forked and
modified this project to make a more generally useful library that is a
wrapper for CGAL. In testing, I have found that CGAL appears to make meshes
with duplicate nodes under certain conditions which then lead to errors in
subsequent operations.

The particular shape that causes the problem for me is constructed from the
difference between a sphere and a cube.
<http://cgal-discuss.949826.n4.nabble.com/file/n4659760/fillet.png>

This was constructed by subtracting this sphere:

<http://cgal-discuss.949826.n4.nabble.com/file/n4659760/sphere_unrotated.png>

from this cube:

<http://cgal-discuss.949826.n4.nabble.com/file/n4659760/cube.png>

The resulting shape has a duplicate node at the point (273.4741e-003,
0.0000e+000, 418.5832e-003) i.e. on a point on the z-y plane. Neither shape
has duplicate nodels before the difference operation. And when I try to the
difference this object with another cube, I get:

Error !!!!!!!!!!!!!!!!!!!!!!!
Error !!!!!!!!!!!!!!!!!!!!!!!

from CGAL

However, the problem goes away if I first rotate the sphere by 90 degrees
around the y-axis. I suspect this is because one of the lines making up the
sphere (which has 20 x 20 segments in these examples) is no longer lying in
the same plane as the edge of the cube.

is there a possibility of a bug here?

To reproduce the issue, you can find my modified pyPolyCSG project here:

https://github.com/crobarcro/pyPolyCSG

however, you don't need the whole project, only the "libpolyhcsg"
subproject, which does not use python or matlab. It is a cmake project and
can be built and installed with:

cmake .
make
sudo make install

The main files of relevance are polyhedron.h/cpp, ane
polyhedron_binary_op.h/cpp

The actual issue is reproduced in a test program, which you can find in the
"test/cornerrd" subdirectory here:

https://github.com/crobarcro/pyPolyCSG/tree/master/libpolyhcsg/test/cornerrad

This is not a cmake project, but is only a single file, main.cpp. A
code::blocks project is provided.

If I run this I get the following exception thrown when trying to difference
the polyhedron with the duplicate vertices with a cube:

Debugger name and version: GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
In __cxa_throw () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6)
#1 0x00007ffff799dea8 in CGAL::Uncertain<bool>::make_certain
(this=0x7fffffffd8f0) at /usr/local/include/CGAL/Uncertain.h:125
/usr/local/include/CGAL/Uncertain.h:125:2852:beg:0x7ffff799dea8
At /usr/local/include/CGAL/Uncertain.h:125

The backtrace:

#0 0x00007ffff71a3a30 in __cxa_throw () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007ffff799dea8 in CGAL::Uncertain<bool>::make_certain
(this=0x7fffffffd8f0) at /usr/local/include/CGAL/Uncertain.h:125
#2 0x00007ffff7979636 in CGAL::Uncertain<bool>::operator bool
(this=0x7fffffffd8f0) at /usr/local/include/CGAL/Uncertain.h:133
#3 0x00007ffff799d927 in
CGAL::operator==<CGAL::Simple_cartesian&lt;CGAL::Interval_nt&lt;false> > >
(v=..., w=...) at /usr/local/include/CGAL/Cartesian/Vector_3.h:143
#4 0x00007ffff7978e09 in
CGAL::CommonKernelFunctors::Equal_3<CGAL::Simple_cartesian&lt;CGAL::Interval_nt&lt;false>
::operator() (this=0x7fffffffda11, v1=..., v2=...) at
/usr/local/include/CGAL/Kernel/function_objects.h:2229
#5 0x00007ffff795aa09 in
CGAL::Filtered_predicate<CGAL::CommonKernelFunctors::Equal_3&lt;CGAL::Simple_cartesian&lt;CGAL::Gmpq>
,
CGAL::CommonKernelFunctors::Equal_3<CGAL::Simple_cartesian&lt;CGAL::Interval_nt&lt;false>
, CGAL::Exact_converter<CGAL::Epeck,
CGAL::Simple_cartesian&lt;CGAL::Gmpq> >, CGAL::Approx_converter<CGAL::Epeck,
CGAL::Simple_cartesian&lt;CGAL::Interval_nt&lt;false> > >,
true>::operator()<CGAL::Vector_3&lt;CGAL::Epeck>,
CGAL::Vector_3<CGAL::Epeck> > (this=0x7fffffffda10, a1=..., a2=...) at
/usr/local/include/CGAL/Filtered_predicate.h:214
#6 0x00007ffff7941af0 in CGAL::operator==<CGAL::Epeck> (p=..., q=...) at
/usr/local/include/CGAL/Kernel/global_functions_3.h:784
#7 0x00007ffff792e540 in
CGAL::Facet_plane_3::operator()<CGAL::HalfedgeDS_in_place_list_face&lt;CGAL::I_Polyhedron_facet&lt;CGAL::HalfedgeDS_face_base&lt;CGAL::HalfedgeDS_list_types&lt;CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3&lt;CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Epeck> >
(this=0x7fffffffdb60, f=...) at
/usr/local/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h:105
#8 0x00007ffff791fd2c in
std::transform<CGAL::internal::In_place_list_iterator&lt;CGAL::HalfedgeDS_in_place_list_face&lt;CGAL::I_Polyhedron_facet&lt;CGAL::HalfedgeDS_face_base&lt;CGAL::HalfedgeDS_list_types&lt;CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3&lt;CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Epeck> >
,
std::allocator<CGAL::HalfedgeDS_in_place_list_face&lt;CGAL::I_Polyhedron_facet&lt;CGAL::HalfedgeDS_face_base&lt;CGAL::HalfedgeDS_list_types&lt;CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3&lt;CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Epeck> >
,
CGAL::Iterator_project<CGAL::internal::In_place_list_iterator&lt;CGAL::HalfedgeDS_in_place_list_face&lt;CGAL::I_Polyhedron_facet&lt;CGAL::HalfedgeDS_face_base&lt;CGAL::HalfedgeDS_list_types&lt;CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3&lt;CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Epeck> >
,
std::allocator<CGAL::HalfedgeDS_in_place_list_face&lt;CGAL::I_Polyhedron_facet&lt;CGAL::HalfedgeDS_face_base&lt;CGAL::HalfedgeDS_list_types&lt;CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3&lt;CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Epeck> >
,
CGAL::Project_plane<CGAL::HalfedgeDS_in_place_list_face&lt;CGAL::I_Polyhedron_facet&lt;CGAL::HalfedgeDS_face_base&lt;CGAL::HalfedgeDS_list_types&lt;CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3&lt;CGAL::Polyhedron_items_3>,
std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Epeck> >
, int, int, int, int>, CGAL::Facet_plane_3> (__first=..., __last=...,
__result=..., __unary_op=...) at /usr/include/c++/4.8/bits/stl_algo.h:4926
#9 0x00007ffff791a764 in
CGAL::polyhedron_3_to_nef_3<CGAL::Polyhedron_3&lt;CGAL::Epeck,
CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator&lt;int>
, CGAL::SNC_structure<CGAL::Epeck, CGAL::SNC_indexed_items, bool> > (P=...,
S=...) at /usr/local/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h:198
#10 0x00007ffff7917d2c in CGAL::Nef_polyhedron_3<CGAL::Epeck,
CGAL::SNC_indexed_items, bool>::Nef_polyhedron_3<CGAL::Epeck,
CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator&lt;int> >
(this=0x7fffffffe270, P=...) at
/usr/local/include/CGAL/Nef_polyhedron_3.h:566
#11 0x00007ffff79112b8 in polyhcsg::polyhedron_to_cgal (p=...) at
/home/rcrozier/src/pyPolyCSG-crobarcro/libpolyhcsg/source/polyhedron_binary_op.cpp:86
#12 0x00007ffff7911bb4 in polyhcsg::polyhedron_difference::operator()
(this=0x7fffffffe300, A=..., B=...) at
/home/rcrozier/src/pyPolyCSG-crobarcro/libpolyhcsg/source/polyhedron_binary_op.cpp:140
#13 0x00007ffff7acbe29 in polyhcsg::polyhedron::operator-
(this=0x7fffffffe340, in=...) at
/home/rcrozier/src/pyPolyCSG-crobarcro/libpolyhcsg/source/polyhedron.cpp:758
#14 0x00000000004013e6 in main (argc=1, argv=0x7fffffffe5c8) at
/home/rcrozier/src/pyPolyCSG-crobarcro/libpolyhcsg/test/cornerrad/main.cpp:16


If you are interested in the matlab.Octave interface, it can be found here:

https://github.com/crobarcro/mpolycsg

It is quite functional, but not yet documented.



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/CGAL-difference-on-Nef-polyhedron-produces-shape-with-duplicate-vertices-tp4659760.html
Sent from the cgal-discuss mailing list archive at Nabble.com.





Archive powered by MHonArc 2.6.18.

Top of Page