Part.Wire misses some Edges

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Part.Wire misses some Edges

Post by bernd »

It works without BooleanFragments too. Just only add the missing Edges to the Part.Wire works ...

Load nonmanifold_wire.fcstd from first topic post

Code: Select all

edges = App.ActiveDocument.Compound.Shape.Edges
w = Part.Wire(edges)
for ed in edges:
    missing_edge = True
    for ew in w.Edges:
        if ed.CenterOfMass == ew.CenterOfMass:
            missing_edge = False
            break
    if missing_edge:
        w.add(ed)

Part.show(w)

@DeepSOIC:
Why is it possible to add all Edges to the BooleanFragments and the BooleanFragments behaves like a magician and deletes the doubeled ones?

bernd
Last edited by bernd on Sat May 27, 2017 9:12 am, edited 1 time in total.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part.Wire misses some Edges

Post by DeepSOIC »

bernd wrote:Why is it possible to add all Edges to the BooleanFragments and the BooleanFragments behaves like a magician and deletes the doubeled ones?
I don't quite understand shat you are asking. I'll try to explain why did I do what I suggested.

In OCC, the connectivity of things is usually defined by sharing. For example, a compsolid. Compsolid is merely a list of solids, and the connectivity is defined by face sharing.Same with shells, and wires. I'm not sure if that's the only information about wire connectivity, but vertex sharing is at least required.

Part.Wire(edges) assembles wires. If the edges have coincident but not shared vertices, the vertices are made shared. As consequence, new edges are created. However if you feed edges where vertexes are pre-shared, Part.Wire will use the very edges you supply, and you can then test if the edge is in wire by looping through wire edges and comparing with isSame() method.

That's what booleanfragments was for. I used it as a way to establish vertex sharing, before building the wire.

I think the final bit of the puzzle is suggested by microelly2. That is why we have to add edges twice. I think, OCC adds edges one by one, and will silently reject an edge if it doesn't connect to the rest of the wire. Adding all edges the second time is a hacky workaround, which assumes that most of the wire was built by the very first call, and that adding an edge that already is in the wire will be ignored.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Part.Wire misses some Edges

Post by bernd »

thanks for the explanation.

DeepSOIC wrote: Thu May 25, 2017 3:00 pm
bernd wrote:Why is it possible to add all Edges to the BooleanFragments and the BooleanFragments behaves like a magician and deletes the doubeled ones?
I don't quite understand shat you are asking. I'll try to explain why did I do what I suggested.
If all edges are added twice to a Part.Wire lots of edges are added twice and it results an an invalid shape. If all edges are added to to a BooleanFragment of a Part.Wire all edges which are already in the wire are ignored and it results in a valid shape. I would like to know why are they ignored in the BooleanFragment?

bernd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Part.Wire misses some Edges

Post by bernd »

:shock: :o :mrgreen: :D

it is much more simpler ... Just pass the BooleanFragment of Edges to GMSH and it will connect the Edges. These BooleanFragments are magical ... This would mean in the brep passed to GMSH there is written that it is not a Compound but a BooleanFragment containing a Compound. But Part --> Check Geometry does not show any difference ?!?

Mhh I really do need to know more detailed what really these BooleanFragments are ... Is there some resources ?

I tested with faces and BooleanFragments too, same magical. Pass a BooleanFragment of faces to GMSH and the Mesh of faces (which would form a nonmanifold shell) is connected.

booleanfragments_edges.fcstd
(75.3 KiB) Downloaded 21 times
booleanfragments_shell.fcstd
(247.57 KiB) Downloaded 25 times
screen.jpg
screen.jpg (135.13 KiB) Viewed 1555 times
screen1.jpg
screen1.jpg (105.46 KiB) Viewed 1555 times
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Part.Wire misses some Edges

Post by tanderson69 »

bernd wrote: Sun May 21, 2017 7:18 pm
tanderson69 wrote:Curious, what does gmsh do with a compound of 'connected' edges?
Same what GMSH meshes if you pass a Compound of "connected" Solids instead of one CompSolid or if you pass a Compound of "connected" Faces instead of one Shell or a Compound of "connected" Edges instead of one Wire. GMSH will mesh them in one big mesh but will not connect them means for the connected Edges in the mesh there will be at a vertex where 3 Edges meat there will be three nodes. Each Edge will have his own node, thus the Edges are not connected. If you pass one wire GMSH will make one Vertex at the point where the three edges are connected. GMSH just meshes what it gets. Means you need to pass the wire as brep.

bernd
so do you still think this?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Part.Wire misses some Edges

Post by bernd »

tanderson69 wrote: Sat May 27, 2017 7:46 pm
bernd wrote: Sun May 21, 2017 7:18 pm
tanderson69 wrote:Curious, what does gmsh do with a compound of 'connected' edges?
Same what GMSH meshes if you pass a Compound of "connected" Solids instead of one CompSolid or if you pass a Compound of "connected" Faces instead of one Shell or a Compound of "connected" Edges instead of one Wire. GMSH will mesh them in one big mesh but will not connect them means for the connected Edges in the mesh there will be at a vertex where 3 Edges meat there will be three nodes. Each Edge will have his own node, thus the Edges are not connected. If you pass one wire GMSH will make one Vertex at the point where the three edges are connected. GMSH just meshes what it gets. Means you need to pass the wire as brep.

bernd
so do you still think this?
Yes ! if it is passed as a Compound (a bound of connected not glued edges) they are not Connected (glued) in the mesh. If it is passed as a BooleanFragment Compound (a bound of connected not glued (I don't know may be there are glued already in a BooleanFragment but that is what I have to learn)) they are connected (glued) in the mesh ! Example will follow ...
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Part.Wire misses some Edges

Post by tanderson69 »

bernd wrote: Sat May 27, 2017 5:03 pm it is much more simpler ... Just pass the BooleanFragment of Edges to GMSH and it will connect the Edges.
Does this mean you didn't need to run the booleanFragment edges through 'Part.Wire'?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Part.Wire misses some Edges

Post by bernd »

tanderson69 wrote: Sat May 27, 2017 10:11 pm
bernd wrote: Sat May 27, 2017 5:03 pm it is much more simpler ... Just pass the BooleanFragment of Edges to GMSH and it will connect the Edges.
Does this mean you didn't need to run the booleanFragment edges through 'Part.Wire'?
Exactly ! Thats the magical thing and it works on nonmanifold shells too. Just pass a bound of faces as a BooleanFragmentsCompound to gmsh and the faces in the mesh will be glued !
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Part.Wire misses some Edges

Post by bernd »

as promised the example

BooleanFragments compound mesh has 5 nodes
Compound mesh has 6 nodes

>>> App.ActiveDocument.BooleanFragments001_Mesh.FemMesh.Nodes
{1L: Vector (0.0, 0.0, 0.0), 2L: Vector (100.0, 0.0, 0.0), 3L: Vector (200.0, 0.0, 0.0), 4L: Vector (50.0, 0.0, 0.0), 5L: Vector (150.0, 0.0, 0.0)}
>>> App.ActiveDocument.Compound_Mesh.FemMesh.Nodes
{1L: Vector (0.0, -100.0, 0.0), 2L: Vector (100.0, -100.0, 0.0), 3L: Vector (100.0, -100.0, 0.0), 4L: Vector (200.0, -100.0, 0.0), 5L: Vector (50.0, -100.0, 0.0), 6L: Vector (150.0, -100.0, 0.0)}

node 2L and 3L are at the same place, one belongs to the first edge and the other to the other edge. The edges are not glued together in the mesh.

or select the mesh right mouse button mesh info

compound_vs_booleanfragmentcompound.fcstd
(9.26 KiB) Downloaded 22 times

EDIT: the forum code tags have line ending problems I deleted them for now
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Part.Wire misses some Edges

Post by tanderson69 »

bernd wrote: Sat May 27, 2017 10:15 pm Exactly ! Thats the magical thing and it works on nonmanifold shells too. Just pass a bound of faces as a BooleanFragmentsCompound to gmsh and the faces in the mesh will be glued !
That is what I thought, and that is what my first question was about. Thanks.
Post Reply