Finding parallel planes (faces) and grouping them

Hi!
I´m trying to find a good method for finding parallel planes (or faces) in a box and then group them in pairs.
I attach my grasshopper definition so far. I managed to find the parallels but I struggle to get just a tree with three branches (one for each pair of parallel planes) with the indices of the faces composing the pair as item on such list. Instead I have a tree composed of 6 branches (one per each face) with the pairs duplicated. Also, I have the feeling that the definition is a little bit dirty. There must be a simpler way to accomplish the same goal with less.

grouping parallel faces.gh (18.3 KB)

Hello,

If Brep is a Box, it could be done like this.


grouping parallel faces Box.gh (19.1 KB)

Another possibility, also assuming a box:
grouping parallel faces-b.gh (32.2 KB)

I prefer to do this with the dot product. The indices in the text panel are the faces which are parallel.

parallel_faces.gh (25.8 KB)

Just out of interest, I thought I would give it a go in Python:

import rhinoscriptsyntax as rs
import itertools as it
import ghpythonlib.treehelpers as th

bfaces = rs.ExplodePolysurfaces(x)

pfaces = []

for i in it.combinations(bfaces,2):
    nmls = []
    for j in i:
        cpnt = rs.SurfaceAreaCentroid(j)[0]
        param = rs.SurfaceClosestPoint(j, cpnt)
        nmls.append(rs.SurfaceNormal(j, param))
    if rs.IsVectorParallelTo(nmls[0], nmls[1]):
        pfaces.append(i)

a = th.list_to_tree(pfaces)

3 Likes

Get the general case (impossible without code): an elementary Hard Flat Clustering task (if you can read C# … see the classic/standard HFC Method used + the related BINFO Class).

Clusters_BrepFaceAngle_V1.gh (158.3 KB)

You can compare Z axis

grouping parallel faces.gh|attachment (10.9 KB)

Hey @Adam_M. Really clean, fast and good solution. Thanks for your interest and the script!

Hey @martinsiegrist. Thanks so much for the quick answer. It saved my b***. Sorry for not having come back before. I had no time, so I basically took your def and inserted it into mine. Everything worked like a charm.

1 Like

Hey there @PeterFotiadis. I checked your solution the first. It was impressively complete. But although I could detect and group parallel faces among several BREPs, I could do that in the same BREP. I must have done something wrong. Anyway, thanks soo much for the quick hand.

Hey @11159. Thanks so much for your help. Quite an interesting method. I definitely need to sit down and study it. Specially the use of crossref and the filtering you did before. Thanks so much!

Well … I do hope that I haven’t skipped some line (you never know) in the Clustering Method (or in the Class definition and/or the sampling phase - but that is more or less highly unlikely since each Face from each Brep is sampled in the bInfo List).

When time permits I’ll give it a go.

1 Like

Hey @anon39580149, I used that method before. It seems the way to go at the beginning. I do not know how but I found the case where I had values in y that were exactly as in z and then it could not separate them in pairs. Maybe I just did something else wrong. Thanks anyway. I really appreciate your effort.

Well … after checking the thing … it works 100% OK. See Clusters on Faces of the same Brep (using another test collection).


BTW: using the 3 dim paths (Cluster idx, Brep idx, Face idx) … you can filter anything you like .

Update: did a small video on that:

1 Like

Hey @PeterFotiadis, thanks for taking the time. Check the image below.

The faces marked in red are parallel to the clustered ones too.

No they are NOT.

The Clustering algo stores (in some given Cluster [of bInfo Type]) each Face that has a Normal angle (to any other Normal) LESS that delta. So the above Faces have Normals heading North/South (they are anti papallel).

But obvioulsy I could add an option for that: a 2nd delta => delta2 = Math.Abs(Math.PI*2 - delta).

ok then… antiparallel is it. Antiparallel is what I´m looking for.

Less than 3 minutes job.

Clusters_BrepFaceAngle_V1A.gh (241.6 KB)


1 Like

beautiful!! I´ll take a look at it later. But so far, excellent!

BTW: If you can read C# see the rather primitive filter used on Faces. So there maybe I could add an option or two (say: take only faces that have 2 holes or are pig ugly or are smaller than this or greater than that or are adjacent to 666 others … etc etc)…