Trying to get the middle of a trimmed surface - on the surface, not outside of it

Hi I’m trying to get the center of a stack of surfaces so they can be laser engraved with a number on them. I don’t want the geometric center or centroid because that often falls outside of the actual surface.
It’s for a topo model where many of the surfaces are trimmed and cannot be untrimmed.

As a work-around, I’ve offset the outside edge of the curve and used it as a way to get a point on the surface far enough from the edge that the text is visible.

Is there a more direct or better way of doing this with GH? (41.4 KB)

you just want to share your workaround or you need help ?

what about a practical solution:
use the highest point of your topo-model - if there are local peaks it is more then one of this points.
just place them manual.
as long as you do not have overhangs - from top view, all labels are at same position.

if you search for an algorithmic approach: “place a rectangle inside a non convex closed curve” -… you should define more conditions like - maximum size, given size, top most, left most… but i think you 'll end up in a clever way to try several solutions until one position fits quite well.

definitely wanted help, just shared the workaround for context. some of my topos are massive so doing it manually kinda defeats the purpose of all this algorithmic work with OpenNest.

sounds like there isn’t an “easy” way to get the middle of bunch of trimmed surfaces, and still stay within the geometry of the surface. thanks for the tips though, I’ll search for those additional phrases.

Maybe you could use a simple technique on how trims are getting their render mesh.

If a point is inside a closed polycurve can be determined if a ray/line in one direction and its opposite direction intersects odd times each. (intersectionCount % 2 == 1)

If its inside, you can measure the closest point to the polycurve to determine the ‘depth’ inside the polygon. The greater, the better.

In order to create some points , take the bounding rectangle and create a point grid, say 11x11 points. This prevents you in doing something recursive which requires writing code (if this is a problem).


1 Like

What you are after is called curve “visual” center.

Done with recursion as follows: For a given crv in some List start getting a QTree from the flat BoundingBox, get the centers and pick as candidate - for the next loop - the rectangle who’s center is the furthest from the crv … then go to the next loop and do a QTree for that rectangle etc etc. Stop either due to some max loop value of some min distance achieved.

BTW: The core of the matter (the Recursive Method) has as follows:


@TomTom and @PeterFotiadis these are epic suggestions…QTree lesson was great!

Thanks, I had a hard time describing the problem. Wish I could mark both of these as solutions, I’ll use them both based on how complicated the curves are.

In fact (general case: crv contains crv(s)) you’ll need a containment clustering first pass in order to work with BrepFaces.

1 Like

Could you give some hint on how to get that sardines?

Now it’s time to study!

If you are really brave … it’s time to walk on the wild side:

Mastermind some way to do HAC Containment Clustering (Nested stuff, that is).

If/when you do it: you’ll get 10 cans of the finest sardines known to man.