For a 2d curve whose image lies in the surface’s domain, how to create a 3D curve from it? In other words, how to create a 3D curve from the following p2DCurve and srf?

When creating a ON_Brep, does it require the corresponding 3D edge for each 2D curve? In other words, is it possible to use the following API to create the ON_BrepTrim (without the corresponding edge)?

1.) To compute a 3d curve that is the composite of a 2d curve and the surface map, use ON_Surface::Pushup.

2.)

Yes. However, if your Brep has no edge curves and you call the above member function, then it’s assumed this is the only trim using this edge and ON trim.m_type will be set to ON_BrepTrim::boundary. This type will be changed to ON_BrepTrim::seam or ON_BrepTrim::mated when another trim is added that uses this edge.

Sorry to resurrect this old topic months later from the answer. I am trying to do the same thing with OpenNURBS but I don’t think ON_Surface::Pushup method exists in the latest release of OpenNURBS. I am aware that this post is under Rhino Developer but it seemed that this is the most related topic to ask about it.

I was wondering if you could provide an example to create 3D curves from 2D trim curves for OpenNURBS users.

@dale, thank you so much for your reply. I am all good with all the missing features and actually I don’t need most of them at all. I am only trying to read and write .3dm files with OpenNURBS. I was able to read all types of geometrical data and parametric trimming curves for surfaces. There are even examples for these in the GH repo. On the other hand, I got stuck with writing .3dm files.

I was able to create a BRep from a ON_NurbsSurface instance using ON_Brep::Create. This method generates the outer BRep loop automatically. However, I was unable to add surface trimming curves to the BRep structure. My trimming curves are instances of ON_NurbsCurve and ON_Brep::NewTrim seems to require a 3-dimensional edge. I couldn’t find a way to generate that edge which feels like the 3-dimensional mapping of the surface trimming curve.

I am not exactly looking for ON_Surface::Pushup or even not asking for porting that function to OpenNURBS. I am only seeking a way to add surface trimming curves of ON_NurbsCurve instance to the BRep structure. I would be glad if you could point me to the right way to achieve this.

Here are a couple of samples that demonstrate how to “roll your own” Brep. The samples are based from the Rhino SDK samples. But the code will works in just openNURBS:

I remember some of these examples from OpenNURBS GitHub repository. From what I remember, those trimming curves are using line-based curve classes for representing 3-dimensional edge curves and the 2-dimensional surface trimming curves are actually lines (hopefully, I am remembering correctly). The trimming curves that I am using are freeform 2-dimensional splines (some of them are quadratic, some of them are cubic and some of them are rational splines) but not lines.These examples help up to some point but they don’t solve the problem of 3-dimensional edge curve generation for the freeform surface trimming curves.

I have the NURBS surface and I can generate the BRep face. I have the 2-dimensional surface trimming curve as a NURBS curve but I am not sure how to generate an edge from that trimming curve. Appending the trim to ON_Brep::m_c2 array and creating a inner BRep loop don’t seem to change the final model when I load it to Rhino 5.

Sorry, I don’t know how to help. Have you considered writing a file import plug-in for Rhino (rather than trying to write 3dm file from your application)? Here, you’d have full access to the Rhino API.

Thank you for the suggestion. I also think writing a Rhino plugin would be the best and probably the easiest option to go. On the other hand, knowing that ON_Surface::Pushup method will not be available for the free version of OpenNURBS, I have implemented my own 2-D trim curve to 3-D edge mapping function by simply evaluating the trim curve points (i.e. u and v parameters) on the surface.

I have used On_PolylineCurve class for storing the evaluated surface points and therefore, representing the 3-D edge, and then using On_PolylineCurve:::NurbsCurve method, I was able to get the spline representation of the 3-D edge.

I am still trying to solve other issues regarding to BRep generation with OpenNURBS but I was able to solve 3-D edge generation problem.

Thank you so much for all the support and suggestions.