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
Posts: 9830
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Part.Wire misses some Edges

Postby bernd » Wed May 24, 2017 8:27 pm

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
Posts: 7600
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Part.Wire misses some Edges

Postby DeepSOIC » 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.

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
Posts: 9830
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Part.Wire misses some Edges

Postby bernd » Sat May 27, 2017 9:20 am

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
Posts: 9830
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Part.Wire misses some Edges

Postby bernd » Sat May 27, 2017 5:03 pm

: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 7 times
booleanfragments_shell.fcstd
(247.57 KiB) Downloaded 6 times
screen.jpg
screen.jpg (135.13 KiB) Viewed 646 times
screen1.jpg
screen1.jpg (105.46 KiB) Viewed 646 times
User avatar
tanderson69
Posts: 1531
Joined: Thu Feb 18, 2010 1:07 am

Re: Part.Wire misses some Edges

Postby tanderson69 » 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?
User avatar
bernd
Posts: 9830
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Part.Wire misses some Edges

Postby bernd » Sat May 27, 2017 9:55 pm

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
Posts: 1531
Joined: Thu Feb 18, 2010 1:07 am

Re: Part.Wire misses some Edges

Postby tanderson69 » 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'?
User avatar
bernd
Posts: 9830
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Part.Wire misses some Edges

Postby bernd » Sat May 27, 2017 10:15 pm

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
Posts: 9830
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Part.Wire misses some Edges

Postby bernd » Sat May 27, 2017 10:16 pm

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 6 times

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

Re: Part.Wire misses some Edges

Postby tanderson69 » Sat May 27, 2017 10:32 pm

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.