[ ArchWall ] - Part.getSortedCluster, Part.sortEdges(), again

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

[ ArchWall ] - Part.getSortedCluster, Part.sortEdges(), again

Post by paullee »

[EDIT - topic updated - see https://forum.freecadweb.org/viewtopic. ... 89#p651789]

Split from original Thread - How to pad a grid : -
...
( "Further check reveal Part.__sortEdges__() in offsetWire(0 single out the 4 edges in rectangular configuration, leaving out the diagonal edge."
- https://forum.freecadweb.org/viewtopic. ... 25#p650754 )


Roy_043 wrote: Sat Dec 31, 2022 1:32 pm I am not sure which version you use (I do not recognize the version number) but that issue was fixed with this PR:
https://github.com/FreeCAD/FreeCAD/pull/7436
I am sure you had fixed the issue, thanks to your works :D

However, this maybe a cornercase it is not working? Kind of random in the result for different Wall Width... :roll:

FC 0.20.1 AppImage on Fedora 36
Test_ ArchWall_ 01.FCStd
(9.71 KiB) Downloaded 25 times
Screenshot from 2022-12-31 21-41-35.png
Screenshot from 2022-12-31 21-41-35.png (190.05 KiB) Viewed 1687 times
Screenshot from 2022-12-31 21-43-32.png
Screenshot from 2022-12-31 21-43-32.png (197.62 KiB) Viewed 1687 times
Screenshot from 2022-12-31 21-43-41.png
Screenshot from 2022-12-31 21-43-41.png (198.16 KiB) Viewed 1687 times
Screenshot from 2022-12-31 21-44-30.png
Screenshot from 2022-12-31 21-44-30.png (208.15 KiB) Viewed 1687 times
Screenshot from 2022-12-31 21-44-40.png
Screenshot from 2022-12-31 21-44-40.png (203.74 KiB) Viewed 1687 times

Code: Select all

OS: Fedora Linux 36 (Workstation Edition) (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.21.30345 (Git)
Build type: Release
Branch: master
Hash: f42a47aa0fd8c4f34ef63c185d9f29b9b6e84737
Python 3.10.6, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * dodo 1.0.0
  * DynamicData 2.46.0
  * ArchTextures
  * BOLTSFC.backup1666323893.5041647
  * BOLTSFC
  * FreeCAD-BlenderBIM.backup1666328110.015535
  * FreeCAD-BlenderBIM.backup1666737837.420096
  * FreeCAD-BlenderBIM 2022.10.20
  * BIM.backup1670731522.690569
  * BIM 2021.12.0
  * 3rd link to Paul
  * 3rd link to SketchArchPlus
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: How to pad a grid

Post by paullee »

Probably, it is Edge5, which start from Endpoint of Edge 4, but it is also the Startpoint of Edge 1.

EDIT (and Edge 5 Endpoint is EndPoint of Edge2)

EDIT- Detaching it from the Startpoint of Edge 1, AND ITS ENDPOINT, it looks better.


Screenshot from 2022-12-31 22-10-21.png
Screenshot from 2022-12-31 22-10-21.png (212.09 KiB) Viewed 1668 times
Screenshot from 2022-12-31 22-12-10.png
Screenshot from 2022-12-31 22-12-10.png (208.37 KiB) Viewed 1668 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: How to pad a grid

Post by paullee »

With Edge5 Endpoint not detached -


Screenshot from 2022-12-31 22-15-57.png
Screenshot from 2022-12-31 22-15-57.png (190.24 KiB) Viewed 1643 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: How to pad a grid

Post by paullee »

paullee wrote: Sat Dec 31, 2022 1:49 pm
Roy_043 wrote: Sat Dec 31, 2022 1:32 pm I am not sure which version you use (I do not recognize the version number) but that issue was fixed with this PR:
https://github.com/FreeCAD/FreeCAD/pull/7436
I am sure you had fixed the issue, thanks to your works :D

However, this maybe a cornercase it is not working? Kind of random in the result for different Wall Width... :roll:
Quick study of the faces.py, and test of below for reference @Roy_043.

As the edges are sorted by Part.getSortedClusters(skGeomEdges), Edge5 is apparently sorted after Edge4 resulting in a 5 edges wire, resulting in the awkward projection in the lower-left corner. User intervention, e.g. selection and exclusion of the diagonal lines in the Part sorting mechanism, may be required.

Code: Select all

        #return faces[0].fuse(faces[1:]).removeSplitter().Faces[0]
        fused = faces[0].fuse(faces[1:])
        Part.show(fused)
        fused = fused.removeSplitter().Faces[0]
        Part.show(fused)
        return fused
Maybe start another thread to discuss how this could be further fixed.
Test_ ArchWall_ 01_ r.FCStd
(13.67 KiB) Downloaded 22 times
Screenshot from 2023-01-01 17-58-58.png
Screenshot from 2023-01-01 17-58-58.png (154.11 KiB) Viewed 1511 times
Screenshot from 2023-01-01 17-59-05.png
Screenshot from 2023-01-01 17-59-05.png (142.23 KiB) Viewed 1511 times
Screenshot from 2023-01-01 17-59-27.png
Screenshot from 2023-01-01 17-59-27.png (154.46 KiB) Viewed 1511 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: How to pad a grid

Post by paullee »

Further quick test, and Part Check Geometry (last 'segment' - not closed, self-intersecting etc.)

Code: Select all

        for (edge1, edge2) in zip(w1.Edges, w2.Edges):
            face = create_face(edge1, edge2)
            if face is None:
                return None

            ## TODO Paul 2023.1.1
            Part.show(face)

            faces.append(face)
Test_ ArchWall_ 01_ r2.FCStd
(19.24 KiB) Downloaded 21 times
Screenshot from 2023-01-01 18-42-27.png
Screenshot from 2023-01-01 18-42-27.png (171.76 KiB) Viewed 1494 times
Screenshot from 2023-01-01 18-44-35.png
Screenshot from 2023-01-01 18-44-35.png (196.77 KiB) Viewed 1494 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: How to pad a grid

Post by Roy_043 »

I was a little surprised to see that sketches are handled separately (and differently). If you create a PartDesign_SubShapeBinder from the sketch and use that as the base for a wall you get a different result (only the 4 orthogonal edges are then used). Maybe create an issue on GitHub for this?

Another strange and unexpected issue is that the Shape of the Sketch only has a single wire with 6 edges.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

How to pad a grid

Post by paullee »

Oops, the creation of the 2 wires had problem prior to bind() :D

Code: Select all

def bind(w1, w2, per_segment=False):
    """Bind 2 wires by their endpoints and returns a face.
    ...
    """

    ## TODO Paul 2023.1.1
    Part.show(w1)
    Part.show(w2)
A side remarks : These 2 looks like 2 closed profiles, but the last 2 opposite segment, in 'reverse' direction, created the 'self-intersecting' wire and non-closed faces, make the 'per-segment' mechanism not good to tackle this case.


Test_ ArchWall_ 01_ r3.FCStd
(23.17 KiB) Downloaded 24 times
Screenshot from 2023-01-01 18-53-33.png
Screenshot from 2023-01-01 18-53-33.png (166.61 KiB) Viewed 1573 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: How to pad a grid

Post by paullee »

Roy_043 wrote: Sun Jan 01, 2023 10:52 am I was a little surprised to see that sketches are handled separately (and differently). If you create a PartDesign_SubShapeBinder from the sketch and use that as the base for a wall you get a different result (only the 4 orthogonal edges are then used). Maybe create an issue on GitHub for this?

Another strange and unexpected issue is that the Shape of the Sketch only has a single wire with 6 edges.
In ArchWall, Sketch Edges get Part.getSortedClusters(Sketch Edges), which find connected edges - in this cases 2 wires : 5 edges, and 1 edge. This is one way how Yorik make ArchWall works; alternative is just use Sketch.Shape.Wires. Long story behind.


Can you show the workflow of PartDesign_SubShapeBinder ?

EDIT - Indeed, the Sketch has single wire of 6 edges (final edge disconnected ! ) ? See screencapture / File :roll:

Thanks.

Test_ ArchWall_ 01_ r4_ 1-Wire_6-Edges.FCStd
(14.65 KiB) Downloaded 22 times
Screenshot from 2023-01-01 20-26-43.png
Screenshot from 2023-01-01 20-26-43.png (198.19 KiB) Viewed 1537 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

How to pad a grid

Post by paullee »

paullee wrote: Sun Jan 01, 2023 12:20 pm
Roy_043 wrote: Sun Jan 01, 2023 10:52 am ...

Another strange and unexpected issue is that the Shape of the Sketch only has a single wire with 6 edges.
...

EDIT - Indeed, the Sketch has single wire of 6 edges (final edge disconnected ! ) ? See screencapture / File :roll:
@chrisb and/or @abdullah can shed some light ? :)
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ ArchWall ] - Part.getSortedCluster, Part.__sortEdges__(), again

Post by paullee »

Found it is below line in Draft.draftgeoutils.offsets.OffsetWire() which check if the wire is closed return incorrect result in the first place:-

Code: Select all

def offsetWire(wire, dvec, bind=False, occ=False,
    ....
    closed = wire.isClosed()
    # should use Draft isReallyClosed()
It should return 'False' for this wire (4 edges rectangle with diagonal edges), but it return 'True'.


Notwithstanding that, Part.getSortedClusters(Sketch Edges) would group one of the diagonal into 1st wire as they can be understood connected, the algorithm would still result in funny projection on the lower-left corner if without user intervention.


Test_ ArchWall_ 01_ r5.FCStd
(12.26 KiB) Downloaded 22 times
Screenshot from 2023-01-01 22-23-51.png
Screenshot from 2023-01-01 22-23-51.png (194.97 KiB) Viewed 1461 times
Post Reply