algorithmic modeling for Rhino
Hi, Can anybody tell me the differences between these classes? brep, brepFace, NurbsSurface, GeometryBase and Surface.
My problem is I load a surface(a polygon with a hole on it) as brep in GH, then I want to get this surface in GeometryBase type. It seems I can only get a solid polygon, the hole is missing.
I have tried to get a surface first by x.Faces, it is a brepFace, displayed as something like a plane
then I tried x.Faces.toNurbsSurface(), it display the polygon without hole,
(Surface)x.Faces display the same
I get confused what are the differences between these classes?
Thanks in advance.
GeometryBase is an abstract class that unifies as many functions and properties as makes sense that apply to all geometry everywhere. Curves, Points, Surfaces, Meshes, you name it. This is useful because now all geometry can derive from GeometryBase making the things they have in common a matter of definition. I.e. it's not just the case that both Meshes and Surfaces happen to have a function that computes the bounding box of the shape, it is the same function because it was inherited from GeometryBase.
Surface is another abstract class that unifies as many functions and properties as it can that apply to all surfaces. All surfaces have an area for example. And they all have U and V domains. Rhino supports a number of different surface definitions, among which are PlaneSurfaces (filled rectangles, basically), RevSurfaces (revolutions of a curve about an axis), SumSurfaces (one curve is moved along another) and NurbsSurfaces.
NurbsSurface is a non-abstract class that derives from Surface (and therefore also from GeometryBase) which implements the mathematics of Nurbs surfaces. So every NurbsSurface has control-points, knot-vectors and so on and so forth in addition to whatever Surface already defines.
Brep is a non-abstract class that allows you to create a shape consisting of multiple and/or trimmed surfaces. For example a Box would need to be a Brep because it contains 6 surfaces that are joined at their edges. The filled letter O would also need to be a Brep since it has trim curves that remove portions of a surface. A Brep maintains many lists of geometric entities, including faces, edges, trims, loops and vertices. All of these are associated with each other via topological relationships. Brep is a very complicated class so don't worry if you don't understand how it works.
BrepFace represents a single surface in a Brep. BrepFaces never exist on their own, they are always part of a Brep object. Basically, a BrepFace represents the underlying Surface including the trimming curves. A box contains 6 BrepFaces, all of which represent 6 untrimmed planar surfaces. A cylinder contains 3 BrepFaces, two of which (the caps) represent trimmed planar surfaces.
In Grasshopper, what I call a Surface is actually a single-face brep. I chose to break away from the Rhino SDK terminology because I wanted surfaces to be able to have trimmed portions. When you convert a BrepFace to a Surface, you lose all the trimming information.
Thank you for your answer. It helps a lot. I cast a brep contains a single surface to GeometrBase, and it could display as it should be: a polygon with a hole! Actually I still have a problem, when I try to use RayShoot with this GeometryBase(a polygon with a hole), a ray still reflected at the hole, could you tell me why this happened and what I should do to let the ray pass through the hole? Thank you very much.
I actually thing RayShoot can't handle trims. I seem to remember it being important we add this feature to the Rhino5 SDK, but I don't know whether it has been done yet. Have you tried to run your script in a recent Rhino5?
I haven't tried Rhino 5, have Rhino 4 only. I guess I need to switch to Rhino 5 or use intersect.CurveBrep and write a new Rayshoot. Thank you.
Mesh Ray intersect may be faster, you could try that as well.
© 2023 Created by Scott Davidson. Powered by