Select tangent faces of a Brep?

Is it possible to edit that script so that it outputs a structured tree when there are multiple Breps as input ?
Multiple solids.gh (699.0 KB)

sure:

CheckForTangent2.gh (19.7 KB)

maybe these paths are more natural:

CheckForTangent3.gh (20.1 KB)

Hmm… it doesn’t seem to work with my data set.
Something is wrong.gh (694.4 KB)

By using “Brep Join” on the output, I should get a single Brep in each branch, right ?

"I should get a single Brep in each branch, right " not necessary. well, doesn’t work then. :slightly_frowning_face:

Well, if each branch represents a set of tangent surfaces, they should become a single Brep after “Join”.

as I said, haven‘t tested it fully. I spend less then 60 minutes which is a lot for free help in a forum. I believe its more about the idea rather then providing full functionality. Basically you can use this script and devellop it further.I fully commented so even if you dont understand c# you will get the idea from my notes. I also would like to help you further, but I do have a full time job so I cant simply spend 60 hours to it, which is a realistic timeframe for a well engineered functionality like this.:wink::slightly_smiling_face:

1 Like

Hi TomTom,

Thanks for your efforts ! Editing C# is out of my league, but at least I know what I’m missing.
That a small script could replace such a messy and convoluted part of my definition is an indication that I should look into scripting indeed !

For now, I guess I’ll have to make do with this.

Hi TomTom,
I think that the issue comes from the fact that you put in the same branch faces which are not tangentially connected to any other.
If they were dispatched in separate branches, this script would be a little jewel :slight_smile:

i’ll have a look later on, not sure if I can solve it though

I’m looking into graph theory to solve this problem.
Here is a tree (for Brep N°38) giving, for each face which has tangent neighbours, the list of those neighbours (including itself).
For example, list {38;13} says that face 13 is tangent to face 20 and 18.
If you plot a graph of all the faces (13, and 17 to 25), the two “chains” of tangentially connected faces appear as graph paths of a disjoint graph.

I was wondering if there was a graph plugin for GH, or how I could turn this in to an adjacency matrix and extract the two paths from there.

OK folks, I worked out my own solution to this problem.
Using the “BREP topology”, and a but of comparing normals, it is easy to get a tree with, for each face of the BREP, the list of neighboring faces which are tangentially connected.
But then, to get concatenated lists, or “chains” of faces, and despite all the tools in the “Sets” tab,

Sets

there didn’t seem to be an easy way to do that.
So, inspired by graph theory, I mapped the faces and the “tangency” condition as a set of nodes connected by links.
Then I got rid of the duplicate lines, made polylines, and reverse-engineered my way back to the face lists.
I guess that this could be useful in other circumstances.

GEOMETRIC SOLUTION TO LIST CONCATENATION.gh (102.1 KB)

And this is what the graphs look for other BREPS :

1 Like

Good work @osuire ,

in case you still need my one:

FindTangentFaces_Update.gh (2.0 MB)

3 Likes

TomTom,

Your component works flawlessly, and replaces a convoluted part of my definition quite elegantly and efficiently !

Thank you so much for this !

Just for fun I tried solving it using mostly native components, the logic is basically the same as @TomTom’s script but hopefully a little more transparent of what’s going on:
tangency-grouping.gh (51.6 KB)

A little scripting magic happens in that Python component on the right which merges overlapping sets together.

from ghpythonlib.treehelpers import list_to_tree

sets = map(set, sets.Branches) # Tree Access 

def folder(acc, x):
    s = acc.pop()
    if s.intersection(x):
        return acc + [s.union(x)]
    else:
        return acc + [x, s]

result = []

for s in sets:
    if not s: continue
    result = reduce(folder, result, [s])

joined = list_to_tree(result)
1 Like

:+1:

yeah should have commented my one. I didn‘t even used a real graph, just simple recursion and a simple boolean mask to filter out visited faces. My first approach was about iterating over the edges, but this actually made it difficult to map the faces into the right groups. Thats the error occuring in the first scripts.Thats why i redesigned the algorithm to iterate over faces from beginning on.
It just became complicated to write, because when iterating over the face from beginning on, you need to find the corresponding edges from two adjacent faces beforehand, which results in this cryptic algorithm. I‘ll might comment it later on and do some testing and optimisation. Seems to work this way.

yes that should be a grasshopper stock node, with option for any face, developable faces or planar faces as David remarked.

but there is no easy select chain in curves either in grasshopper, is there???

Unfortunately, it fails to work with multiple inputs (when there is another level of branching)

Yep.
And I still struggle with these issues today