Curvature on brep at a point?

There is probably an obvious answer to this, but so far my searches have not uncovered it in a way I understand. My apologies if I have missed finding an existing explanation!

I can find the curvature at a point on a surface by first finding the closest point to get u v parameters and then calling (in the C# case) surface.CurvatureAt(u, v).

Is there a way to work with a polysurface/brep similarly? Do I have to divide the polysurface up somehow first? Is there a plugin where someone has already tackled this? I see that peacock has surface curvature analysis, but I don’t think I understand what the colored geometry output there means.

Any and all suggestions would be most welcome! Thanks!

Deconstruct the Brep, find the face closest to your point, then run the usual curvature test on that face.

This Method (shown the R5 SDK) gets your component index and if is BrepFace … the rest are history Notify if you want a full C# example (but your tag is after P and you can’t auto translate C# to P).

Thanks, Michael! I think in C# the way I would do that is to use brep.Faces?


To find the face index @PeterFotiadis showed you above. Once you have it you can use can call out that face like yourBrep.Faces[index];

Thanks, PeterFotiadis!

I regret to say I am still confused,though. I think I’m not quite sure how to use the ComponentIndex I get back. I think I want to check if its type is ComponentIndex.BrepFace, but I’m somehow not seeing how to check the type that way. I see there’s an Index, but I’m also not actually sure what to index into with this Index. I’ve been poking around at examples I’ve found online and in the forum, but I’m still not uncovering this. It is probably obvious to everyone else, so I apologize for my confusion. If you have further guidance, I’d love to hear it…

Thanks again,


I do hope that you are after the correct/proper language (C#). If so … here comes the pain (but no pain == no gain):

Brep_Curvature_EntryLevel_V1.3dm (1.1 MB) (128.1 KB)

This has the entry level moniker because it lacks the usual Vis parafernalia : text dots, inquiring things/results on a brep basis and the likes.

Plus … requires an “extension” (as a challenge for you): read my comments inside the Method used. The reason is obvious: what if the Method returns a BrepEdge instead of a BrepFace? In plain English (so to speak):

Feel free to ask anything related with that C# . Most notably with regard the positiveInfinity for the OscCircles radii (but why this freaky thingy is used? and why Kappa and not Gauss or Mean as a filter? you tell me).

Demos ARE NOT internalized (I never do that if Breps are on duty) meaning: load R file first. If there’s no input ( !bList.Any() is true) then the C# stops playing.


If you’re interested in a Pythonic solution, here’s a script similar to what Peter has done above:

# Input B: Item Access; Type Hint: Brep
# Input P: Item Access; Type Hint: Point3d

import Rhino.Geometry as rg

# Get the closest distance between the test point and the brep
closest_pt = B.ClosestPoint(P)
closest_dist = closest_pt.DistanceTo(P)

normal = None

# Get the closest parameters s, t 
rc, pt, ci, s, t, vec = B.ClosestPoint(P, closest_dist+0.01)

if rc:
    print "Closest Point results:\n- Type: {0}\n- Index: {1}".format(ci.ComponentIndexType, ci.Index)
    # The closest object is of type BrepFace
    if (ci.ComponentIndexType == rg.ComponentIndexType.BrepFace):
        face = B.Faces[ci.Index]
        sc = face.CurvatureAt(s, t) # SurfaceCurvature (cf.
        normal = sc.Normal
        print "Gaussian cuvature: {}".format(sc.Gaussian)
        print "Mean cuvature: {}".format(sc.Mean)
    # The closest object is of type BrepEdge
    elif (ci.ComponentIndexType == rg.ComponentIndexType.BrepEdge):
        edge = B.Edges[ci.Index]
        cv = edge.CurvatureAt(s) # curvature vector
        normal = cv

# Output 
a = closest_pt
b = normal
1 Like

Thank you so much PeterFotiadis! This clarifies several things, including the fact that I had a very basic misunderstanding of what was going on. Now it is all working, and I’m very grateful!

Thank you P1r4t3b0y! This is super helpful, as indeed I usually use Python and not C#. By the time I’m done with this project, I’ll certainly have learned more about both :slight_smile:

I very much appreciate the generosity of time and effort folks here have shown me.

1 Like

You’re welcome, Mary!

PS1: If at some future point you need way more elaborated ways (like: recursive BrepFaces subdivision(s) and other freaky things) to deal with curvatures (and the Vis part as well: colors, histograms, text dots, cats and dogs) notify.

PS2: If you are in the broad AEC market sector I would strongly suggest to stick to C#.