Degenerate meshes on newly created cones and imported IGES surfaces

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
nshea
Posts: 5
Joined: Mon Feb 17, 2020 9:48 pm

Degenerate mesh around the seams of objects

Post by nshea »

I am puzzled by FreeCAD's mesh generation, particularly around the seams of objects. I have noticed several degenerate artefacts that become visible when viewing objects with the "Hidden Line" option. This is most noticeable with a cone, and becomes worse after exporting the said cone to IGES and then re-importing the IGES file; specifically, the mesh becomes a random net, as if generated by a convex hull algorithm that has no knowledge of the underling surface geometry. I would expect a surface of revolution to be regenerated as such. I do not see these artefacts when importing into AutoCAD's online viewer, and wonder if this is a bug or feature/setting in FreeCAD that I have yet to discover. I am using FreeCAD 0.18 on Windows 10.

Nicholas Shea.
nshea
Posts: 5
Joined: Mon Feb 17, 2020 9:48 pm

Degenerate meshes on newly created cones and imported IGES surfaces

Post by nshea »

I am puzzled by FreeCAD's mesh generation, particularly around the seams of objects. I have noticed several degenerate artefacts that become visible when viewing objects with the "Hidden Line" option. This is most noticeable with a cone, and becomes worse after exporting the said cone to IGES and then re-importing the IGES file; specifically, the mesh becomes a random net, as if generated by a convex hull algorithm that has no knowledge of the underling surface geometry. I would expect a surface of revolution to be regenerated as such. I do not see these artefacts when importing into AutoCAD's online viewer, and wonder if this is a bug or feature/setting in FreeCAD that I have yet to discover. The following Google Photos link shows two screenshots of the problem:

https://photos.app.goo.gl/qahRVCDWsPFFpsn77

1). "FreeCAD_cone_mesh_degenerate.png" which shows a newly created cone in FreeCAD with a degenerate seam.

2). "FreeCAD_custom_cone_igs_import_mesh_degenerate" which shows an IGES surface of revolution created in another application imported into FreeCAD.

I am using FreeCAD 0.18 on Windows 10.

Nicholas Shea

P.S. This is the second attempt to get this problem solved in the Open Discussion; my first post never appeared or was lost in the system.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Degenerate meshes on newly created cones and imported IGES surfaces

Post by microelly2 »

The converting of a brep shape to a mesh approximations is not unique.
If you use different ways you will get different results.
A mesh is always only an approimation. That means that the points of the mesh are near to the real points of the shape within
a defined tollerance.
nshea
Posts: 5
Joined: Mon Feb 17, 2020 9:48 pm

Re: Degenerate meshes on newly created cones and imported IGES surfaces

Post by nshea »

microelly2 wrote: Wed Feb 19, 2020 10:57 am The converting of a brep shape to a mesh approximations is not unique. If you use different ways you will get different results. A mesh is always only an approimation. That means that the points of the mesh are near to the real points of the shape within a defined tollerance.
I appreciate you taking the time to reply to my problem.
Unfortunately the answer is not specific enough to be of any help.
Of course I know that a mesh is only an approximation, but your explanation
"different ways - different results" is rather ambiguous to say the least.

It appears that the defined tolerance to approximate the B-Rep shape
is too large - and the algorithm that generates the mesh is not very efficient.
The surface of revolution B-Rep _is_ precisely defined in the IGES file - by an
axis of revolution and a generatrix B-Spline curve. In the following example,
a straight line BSpline was used as the generatrix to create a simple cylinder
of revolution:

https://photos.app.goo.gl/jHrGeaXmi2DePczg8

But again, there are mesh artefacts around the cylinder edges
(circled red). What I do not understand is why; further, much of the trimesh
geometry that represents the object is wasted on the planar surfaces rather
than being used to acurately depict the curved surfaces. Is there some setting
in FreeCAD equivalent to the QHull option 'An' that might be used to tweak the
precision of the mesh?

The peculiar thing is, I do not see any of these artefacts in the FreeCAD screen
shots (they are not in the Splash screen image, for example); so I was wondering
if there is a bug in the OpenCascade kernel or whatever part of FreeCAD that is
used to generate mesh geometry.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Degenerate meshes on newly created cones and imported IGES surfaces

Post by sgrogan »

nshea wrote: Thu Feb 20, 2020 9:22 pm Unfortunately the answer is not specific enough to be of any help.
Of course I know that a mesh is only an approximation, but your explanation
"different ways - different results" is rather ambiguous to say the least.
Different ways refers to the underlying mesh algorithm. FreeCAD offers 3 by default. Mesh_FromPartShape
It looks like you are using standard. The advantage of this is small file size. The disadvantage is that it allows large aspect ratio triangles. This is not a problem for non-precision 3D-printing.

There is no real rule of thumb which mesher to use. It depends what you want to do with the result. Also do to the underlying libraries used to implement the different meshers, different options are available.

If can can explain what you want to do with the mesh object maybe we can help you choose the most appropriate mesher and the corresponding settings for that mesher.
"fight the good fight"
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: Degenerate meshes on newly created cones and imported IGES surfaces

Post by chrisb »

Moved topic and merged with similar question from OP.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
nshea
Posts: 5
Joined: Mon Feb 17, 2020 9:48 pm

Re: Degenerate meshes on newly created cones and imported IGES surfaces

Post by nshea »

Thank you, sgrogan, for your help. I very much appreciate this information;
the mesh generators certainly seem to offer more of the control I was
originally seeking. Alas, after several attempts with various IGES input files,
I am still ending up with a corrupt mesh...

The Mephisto mesh generator somehow ignores the B-Spline weights and gives
the cylinder a slight cushion effect - it also moves a single vertex at the seam.
This is shown in the first gif animation (circled red).

https://photos.app.goo.gl/y89SHEaZs9Afv45r8

The Netgen mesh generator simply ignored the surface of revolution altogether
and produced the corrupt mesh shown in the second gif animation.

Clearly I am doing something wrong, or surely this problem would have been
reported long before now - unless it is specifically related to the IGES
surface of revolution entity # 120.
nshea
Posts: 5
Joined: Mon Feb 17, 2020 9:48 pm

Re: Degenerate meshes on newly created cones and imported IGES surfaces

Post by nshea »

After looking into the problem further I have determined that this is an issue
with the OpenCascade kernel. The correct surface of revolution (entity 120) for
a perfect cylinder is only formed when defining the generatrix as a compound
curve (entity 102) of straight line segments (entity 110). FreeCAD will then
corectly import the IGES file; (AutoCAD fails to import the geometry in this
instance - I suspect that the connected lines are not given a parameterization).
Either way, the mesh formed in FreeCAD by the following IGES snip does not
suffer the aforementioned artefacts that occur when using a BSline as the
generatrix:

Code: Select all

     402       1       0       0       0       0       0       000000000D0000001
     402       0       0       1       1                               0D0000002
     102       2       0       0       0       0       0       000020000D0000003
     102       0       0       1       0                               0D0000004
     110       3       0       0       0       0       0       000010000D0000005
     110       0       0       1       0                               0D0000006
     110       4       0       0       0       0       0       000010000D0000007
     110       0       0       1       0                               0D0000008
     110       5       0       0       0       0       0       000010000D0000009
     110       0       0       1       0                               0D0000010
     110       6       0       0       0       0       0       000010000D0000011
     110       0       0       1       0                               0D0000012
     120       7       0       0       0       0       0       000010000D0000013
     120       1       1       1       0                               0D0000008
402,1,3;                                                         0000001P0000001
102,3,5,7,9;                                                     0000003P0000002
110,0.,30.,0.,-60.,30.,0.;                                       0000005P0000003
110,-60.,30.,0.,-60.,0.,0.;                                      0000007P0000004
110,-60.,0.,0.,0.,0.,0.;                                         0000009P0000005
110,0.,0.,0.,0.,30.,0.;                                          0000011P0000006
120,11,3,0.0,6.2831853072;                                       0000012P0000007
I have been warned by various reports on the web to stay away from IGES files;
I think the warning is unfair as the format is excellent and very extensive; the
problem, rather, is with the inconsistent manner in which various CAD programs
implement their IGES pre/post processors. As I have discovered to my cost, this
leaves developers in a rather awkward situation whereby they must account for
such inconsistencies in their IGES import/export options.
Post Reply