discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: WTF ? ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron.

AM
Adrian Mariano
Sat, Sep 25, 2021 12:52 AM

When you render an object by itself, CGAL doesn't get invoked and
bogus objects generate no error.  Introducing a second object forces
CGAL to run and reveals the error in the first object.

In this case the "thrown together" view mode reveals that half the
faces are reversed (purple).  I would say that a library that supplied
that face set is useless...unless you want to do some serious
debugging to flip all the reversed faces.

You might consider instead BOSL2 which includes a polyhedra library

https://github.com/revarbat/BOSL2/wiki/polyhedra.scad

which implements a range of polyhedra, including the icosahedron.  And
it actually works.  See also:

https://github.com/revarbat/BOSL2/wiki/shapes3d.scad#functionmodule-spheroid

On Fri, Sep 24, 2021 at 8:31 PM Dan White via Discuss
discuss@lists.openscad.org wrote:

---------- Forwarded message ----------
From: Dan White d_e_white@icloud.com
To: discuss@lists.openscad.org
Cc:
Bcc:
Date: Sat, 25 Sep 2021 00:30:58 -0000
Subject: [OpenSCAD] WTF ? ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron.
Trying something with code from Geodesic Maths for OpenScad - Thingiverse

Preview is fine.

Trying to render coughs out
Rendering Polygon Mesh using CGAL...
ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron.

If I take out the cylinder, no error.

I even extracted code from maths_geodesic.scad so I might isolate any problem, but no joy.
OpenSCAD 2021.01
running on a MacBookPro running Big Sur (macOS 11.6)

------------------- BEGIN CODE -------------------

//include <maths_geodesic.scad>

//--------------------------------------------
//WITHOUT  <maths_geodesic.scad>
Cepsilon = 0.00000001;

function sph(long, lat, rad=1) = [long, lat, rad];

// Clean: Corrected
function clean(n) = (n < 0) ? ((n < -Cepsilon) ? n : 0) : (n < Cepsilon) ? 0 : n;

// Convert spherical to cartesian
function sph_to_cart(s) = [
clean(s[2]*sin(s[1])*cos(s[0])),
clean(s[2]*sin(s[1])*sin(s[0])),
clean(s[2]*cos(s[1]))
];
//--------------------------------------------

module icosahedron ( radius = 1 ) {
foo = atan ( 0.500 ) ;

polyhedron(
points = [
sph_to_cart ( sph(  0,  0,      rad = radius ) ) , //  0
sph_to_cart ( sph(  36,  90 - foo, rad = radius ) ) , //  1
sph_to_cart ( sph( 108,  90 - foo, rad = radius ) ) , //  2
sph_to_cart ( sph( 180,  90 - foo, rad = radius ) ) , //  3
sph_to_cart ( sph( 252,  90 - foo, rad = radius ) ) , //  4
sph_to_cart ( sph( 324,  90 - foo, rad = radius ) ) , //  5
sph_to_cart ( sph(  72,  90 + foo, rad = radius ) ) , //  6
sph_to_cart ( sph( 144,  90 + foo, rad = radius ) ) , //  7
sph_to_cart ( sph( 216,  90 + foo, rad = radius ) ) , //  8
sph_to_cart ( sph( 288,  90 + foo, rad = radius ) ) , //  9
sph_to_cart ( sph( 360,  90 + foo, rad = radius ) ) , // 10
sph_to_cart ( sph(  0, 180,      rad = radius ) )  // 11
],
faces = [
[ 0, 1, 2],
[ 0, 2, 3 ],
[ 0, 3, 4 ],
[ 0, 4, 5 ],
[ 0, 5, 1 ],
[ 1, 6, 10 ],
[ 2, 6, 1 ],
[ 2, 6, 7 ],
[ 2, 3, 7 ],
[ 3, 7, 8 ],
[ 3, 8, 4 ],
[ 4, 8, 9 ],
[ 4, 9, 5 ],
[ 5, 9, 10 ],
[ 5,10, 1 ],
[ 11, 6, 7 ],
[ 11, 7, 8 ],
[ 11, 8, 9 ],
[ 11, 9, 10 ],
[ 11, 10, 6 ]
],
convexity = 1
) ;
}

icosahedron ( ) ;
cylinder ( h = 0.01, r = 1, $fn = 25 ) ;

------------------- END CODE -------------------

Dan White | d_e_white@icloud.com ------------------------------------------------ “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” (Bill Waterson: Calvin & Hobbes)

---------- Forwarded message ----------
From: Dan White via Discuss discuss@lists.openscad.org
To: discuss@lists.openscad.org
Cc: Dan White d_e_white@icloud.com
Bcc:
Date: Sat, 25 Sep 2021 00:30:58 -0000
Subject: [OpenSCAD] WTF ? ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

When you render an object by itself, CGAL doesn't get invoked and bogus objects generate no error. Introducing a second object forces CGAL to run and reveals the error in the first object. In this case the "thrown together" view mode reveals that half the faces are reversed (purple). I would say that a library that supplied that face set is useless...unless you want to do some serious debugging to flip all the reversed faces. You might consider instead BOSL2 which includes a polyhedra library https://github.com/revarbat/BOSL2/wiki/polyhedra.scad which implements a range of polyhedra, including the icosahedron. And it actually works. See also: https://github.com/revarbat/BOSL2/wiki/shapes3d.scad#functionmodule-spheroid On Fri, Sep 24, 2021 at 8:31 PM Dan White via Discuss <discuss@lists.openscad.org> wrote: > > > > > ---------- Forwarded message ---------- > From: Dan White <d_e_white@icloud.com> > To: discuss@lists.openscad.org > Cc: > Bcc: > Date: Sat, 25 Sep 2021 00:30:58 -0000 > Subject: [OpenSCAD] WTF ? ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. > Trying something with code from Geodesic Maths for OpenScad - Thingiverse > > Preview is fine. > > Trying to render coughs out > Rendering Polygon Mesh using CGAL... > ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. > > If I take out the cylinder, no error. > > I even extracted code from maths_geodesic.scad so I might isolate any problem, but no joy. > OpenSCAD 2021.01 > running on a MacBookPro running Big Sur (macOS 11.6) > # ------------------- BEGIN CODE ------------------- > //include <maths_geodesic.scad> > > //-------------------------------------------- > //WITHOUT <maths_geodesic.scad> > Cepsilon = 0.00000001; > > function sph(long, lat, rad=1) = [long, lat, rad]; > > // Clean: Corrected > function clean(n) = (n < 0) ? ((n < -Cepsilon) ? n : 0) : (n < Cepsilon) ? 0 : n; > > > // Convert spherical to cartesian > function sph_to_cart(s) = [ > clean(s[2]*sin(s[1])*cos(s[0])), > clean(s[2]*sin(s[1])*sin(s[0])), > clean(s[2]*cos(s[1])) > ]; > //-------------------------------------------- > > > module icosahedron ( radius = 1 ) { > foo = atan ( 0.500 ) ; > > polyhedron( > points = [ > sph_to_cart ( sph( 0, 0, rad = radius ) ) , // 0 > sph_to_cart ( sph( 36, 90 - foo, rad = radius ) ) , // 1 > sph_to_cart ( sph( 108, 90 - foo, rad = radius ) ) , // 2 > sph_to_cart ( sph( 180, 90 - foo, rad = radius ) ) , // 3 > sph_to_cart ( sph( 252, 90 - foo, rad = radius ) ) , // 4 > sph_to_cart ( sph( 324, 90 - foo, rad = radius ) ) , // 5 > sph_to_cart ( sph( 72, 90 + foo, rad = radius ) ) , // 6 > sph_to_cart ( sph( 144, 90 + foo, rad = radius ) ) , // 7 > sph_to_cart ( sph( 216, 90 + foo, rad = radius ) ) , // 8 > sph_to_cart ( sph( 288, 90 + foo, rad = radius ) ) , // 9 > sph_to_cart ( sph( 360, 90 + foo, rad = radius ) ) , // 10 > sph_to_cart ( sph( 0, 180, rad = radius ) ) // 11 > ], > faces = [ > [ 0, 1, 2], > [ 0, 2, 3 ], > [ 0, 3, 4 ], > [ 0, 4, 5 ], > [ 0, 5, 1 ], > [ 1, 6, 10 ], > [ 2, 6, 1 ], > [ 2, 6, 7 ], > [ 2, 3, 7 ], > [ 3, 7, 8 ], > [ 3, 8, 4 ], > [ 4, 8, 9 ], > [ 4, 9, 5 ], > [ 5, 9, 10 ], > [ 5,10, 1 ], > [ 11, 6, 7 ], > [ 11, 7, 8 ], > [ 11, 8, 9 ], > [ 11, 9, 10 ], > [ 11, 10, 6 ] > ], > convexity = 1 > ) ; > } > > icosahedron ( ) ; > cylinder ( h = 0.01, r = 1, $fn = 25 ) ; > # ------------------- END CODE ------------------- > > Dan White | d_e_white@icloud.com ------------------------------------------------ “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” (Bill Waterson: Calvin & Hobbes) > > > > > > ---------- Forwarded message ---------- > From: Dan White via Discuss <discuss@lists.openscad.org> > To: discuss@lists.openscad.org > Cc: Dan White <d_e_white@icloud.com> > Bcc: > Date: Sat, 25 Sep 2021 00:30:58 -0000 > Subject: [OpenSCAD] WTF ? ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org