Mesh creation loses triangles.

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Mesh creation loses triangles.

Post by microelly2 »

Mesh.Mesh((pts,triangles)) does not produce all faces when I have large triangles.
My workaround at the moment is the creation af mutliple meshes and then
bigMesh.addMesh(addonMesh)
Are there some limitations on these commands Ishould know or can this be a bug?
can I get diagnostic information why some triangles are not created?
wmayer
Founder
Posts: 20308
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Mesh creation loses triangles.

Post by wmayer »

The method addFacets (also used inside Mesh.Mesh()) checks for non-manifolds edge and filter out the affected triangles while addMesh doesn't do this check because it expects that the two meshes don't overlap.

The field of application the mesh data structure was designed for it is important to avoid non-manifolds, self-intersections, ... Now when creating a mesh from CAD shapes it pretty often happens that the data structure has non-manifolds.

If your input data is a shape then you can use

Code: Select all

mesh=MeshPart.meshFromShape(shape, deviation)
We can also think about adding a further parameter to addFacets to switch off the error checking.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Mesh creation loses triangles.

Post by microelly2 »

wmayer wrote: The field of application the mesh data structure was designed for it is important to avoid non-manifolds, self-intersections, ... Now when creating a mesh from CAD shapes it pretty often happens that the data structure has non-manifolds.
Thank you, my error diet only occur when I merged horzontal and vertical faces, so there will be the error and I can look for it.


We can also think about adding a further parameter to addFacets to switch off the error checking.
This is a nice idea because I need the mesh only for fast rendering.
wmayer
Founder
Posts: 20308
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Mesh creation loses triangles.

Post by wmayer »

This now switches off the manifold check. git commit f560398

Code: Select all

from FreeCAD import Vector


m=([Vector (0.0, 10.0, 10.0), Vector (0.0, 10.0, 0.0), Vector (0.0, 0.0, 10.0),
  Vector (0.0, 0.0, 0.0), Vector (10.0, 0.0, 10.0), Vector (10.0, 10.0, 0.0),
  Vector (10.0, 10.0, 10.0), Vector (10.0, 0.0, 0.0), Vector (10.0, 20.0, 10.0),
  Vector (10.0, 20.0, 0.0), Vector (20.0, 10.0, 10.0), Vector (20.0, 20.0, 0.0),
  Vector (20.0, 20.0, 10.0), Vector (20.0, 10.0, 0.0)],
 [(0, 1, 2), (1, 3, 2), (4, 5, 6), (4, 7, 5), (3, 7, 4), (2, 3, 4),
  (6, 5, 1), (6, 1, 0), (3, 1, 5), (7, 3, 5), (6, 0, 2), (6, 2, 4),
  (8, 9, 6), (9, 5, 6), (10, 11, 12), (10, 13, 11), (5, 13, 10), (6, 5, 10),
  (12, 11, 9), (12, 9, 8), (5, 9, 11), (13, 5, 11), (12, 8, 6), (12, 6, 10)])

import Mesh
mesh=Mesh.Mesh()
mesh.addFacets(m, False)
Mesh.show(mesh)
Post Reply