algorithmic modeling for Rhino
What's the inner mechanism to test validity?
I input an "invalid" sphere to a c# component to check its validity.
The direct output is an "invalid surface".
Sphere.IsValid returns "True".
Then I used Sphere.ToNurbsSurface() to convert it to NurbsSurface. NurbsSurface.IsValid returns "True".
Then I used that "List technique" to convert that NurbsSurface to Surface, Surface.Isvalid returns "True".
Finally, I used Sphere.ToBrep() to convert it to Brep, Brep.IsValid returns "False".
Could anyone what's happening under the hood? What is a proper way to check geometry like sphere or torus in grasshopper?
Thanks!
I attached the definition here.
Tags:
Validity detection can be very complicated business. Especially in the case of Breps. As far as I know, more cases are added to the Brep.IsValid method all the time as we come across funky geometry that really shouldn't have been made.
Breps have Surfaces, Faces, Edges, Trims, Vertices, Loops, Shading meshes and so on and so forth. If there's a mismatch or tolerance issue between these components it may well result in an invalid Brep.
Can you run your brep through the Null item component? It should output text with additional information if the object is invalid.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks, David.
I tried your suggestion of trying that Null item. The output from the Description variable seems to be hard to understand, but this doesn't matter. What I know now is always convert everything into brep to test its validity, right?
Thanks,
-Jerome
What does it say? I might be able to find some clues in the validity description.
Also note that an invalid shape will sometimes still work, depending on what you want to do with it.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
The sphere is generated by the Surface.TryGetSphere. What I want to do is to get an approximate sphere of that test surface and then, project the borders of that surface to the sphere. Unluckily, the sphere turned out to be invalid, so I can't do anything further. I attached the file below, you could visualize that invalid sphere in the viewport.
Thanks,
-Jerome
Hi Jerome,
that surface isn't actually a sphere, it doesn't have any curvature in the vertical direction. It's more like a piece of cylinder. When you convert this into a sphere you end up with huge numbers. Both the sphere plane and the radius will suffer massively from this.
It is in fact always a problem to represent very shallow circles, arcs and spheres, because the radii must be enormous.
I've attached a modified version of your surface and gh file, using a different method to convert freeform surfaces into spheres. But it requires the surfaces have at least some curvature in both directions.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks, David.
Your way of using FitSphereToPoints is really cool, I tried on other surfaces and they all worked fine.
But one thing seems to be out of control is the tolerance. TryGetSphere has a tolerance parameter which helps me to know about or control the deviation from the surface to the sphere. Is there a way to test deviations between the surface and sphere after I used that FitSphereToPoints method?
Thanks!
-Jerome
Sure, after you fit the sphere, compute the distances from all the input points to the sphere center. You can find the highest and lowest numbers in this range to tell you the maximum absolute deviation, or compute the statistical standard deviation from this set.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by