Rhino to Parasolid CAD Data translation: The Entity Map Bible!

There are different CAD modelers available which traverse and read the CAD model data and then make it visible in the viewer or modelers . Different CAD modelers have different steps/ways or file formats to traverse and read the CAD model and write the model geometry.

If the user wants to open a CAD model (let’s say in Rhino 3dm file) in another CAD modelers that supports Parasolid then the you have to traverse the 3dm file data and export it in corresponding file format of Parasolid (i.e x_t). After traversing the CAD model, to write the geometries or attributes in the resultant file format one need to map the geometries and attributes of the CAD model (eg .3dm Rhino file) with the corresponding geometry and attributes of the resultant file format (eg. Parasolid x_t).

The blog mainly focuses on how we can do the mapping of Rhino (3dm) files in the Parasolid (x_t) file format.

Below are the few Rhino entities and their corresponding  Parasolid entity types:

1. Point geometry: To create point geometry in Parasolid you can take the 3d point (ON_3dPoint) and pass it to the standard form of the ‘PK_POINT_create’ API of Parasolid. After the point creation you need to create a minimum body whose single vertex is located at the given  ‘point’.

2. Point Set geometry: In Parasolid there is no point set geometry as such. If you get point set geometry in the Rhino 3dm model then you can loop through the number of point counts in the point set and create points as mentioned above.

3. Line curves: Line curves can be created in Parasolid using an API ‘PK_LINE_create’, you need to provide the location and axis direction to the standard form of the API. OpenNURBS has an ‘ON_LineCurve’ class which has line curves geometry data. You can use the line end point as the location and create a vector using the line direction that you get from the Rhino model geometry.

4. Polyline curve: To create a polyline geometry you can use an API ‘PK_PLINE_create’ in Parasolid. OpenNURBS has an ‘ON_PolylineCurve’ class which has polyline curves geometry data. This API takes a standard form which basically takes the position and the base parameter. While reading the Rhino model polyline data you need to check if the polyline is closed or open (OpenNURBS  provides an API ‘IsClosed()’ for deciding this). If the polyline is closed then the start and end points will be the same so you need to pass the number of positions one less than the total. While creating a polyline curve you need to keep the facet geometry enabled in the session.

5. Arc curve: In OpenNURBS ‘ON_ArcCurve’ class represents the arc curve in openNURBS. To create an arc curve in Parasolid, if it is a circular arc then you can use a Parasolid API ‘PK_CIRCLE_create’. The API takes standard form as input and the circle standard form takes radius of circle and basic set. You can provide the standard form inputs using the object of ‘ON_ArcCurve’ class.  If the arc curve is not a circle then you need to use the NURBS form of Rhino arc curve to create the curve in Parasolid.

6. B-curve: To create a b-curve in Parasolid you have ‘PK_BCURVE_create’ API available. OpenNURBS has an ‘ON_NurbsCurve’ class which has NURBS data. You can directly read the data of NURBS from Rhino and set it to Parasolid standard form as input. In Rhino the number of knots is “m = n + p – 2” but in Parasolid the number of knots are “m = n + p” where n is number of control points and p is the order of curve, so in Parasolid there are two additional knots required to draw a NURBS curve.

7. Plane surface: To create planar surfaces in Parasolid you have ‘PK_PLANE_create’ API. OpenNURBS has an ‘ON_PlaneSurface’ class to handle Planer surface. To create planar surfaces using Parasolid you need to provide the standard from inputs to the API which you can access from the corresponding openNURBS class object.

8. NURBS surface: To create NURBS surfaces in Parasolid you can use the ‘PK_BSURF_create’ API in Parasolid. The corresponding class provided in openNURBS for NURBS surface is ‘ON_NurbsSurface’. The Parasolid API takes standard form which basically needs the data for the knots and ‘u’ and ‘v’ parametric directions. The standard form also checks whether the surface is self intersecting and convexity of surface. You can take all this required data from the object of class ‘ON_NurbsSurface’ and pass it to Parasolid API.

9. Revolution surface: To create Revolution surfaces in Parasolid you can use ‘PK_BCURVE_spin’ API in Parasolid. The corresponding class provided by openNURBS for revolution surface is ‘ON_RevSurface’. The Parasolid API ‘PK_BCURVE_spin’ takes the curve, spin axis and angle to spin. You will get all the required data for mapping from the object of  ‘ON_RevSurface’ class. 

10. Sum surface: In the Rhino Sum surface are created using two curves, first curve is a base curve which will get extruded and second one gives the path of extrusion. You can create Sum Surface in Rhino using sweep API but the curve location we get from Rhino is incorrect. To create Sum surface at correct location you can either create Sum surface using NURBs data or you can use boundary curves from an ON_SumSurface object, it is best to get them using ON_SumSurface::IsoCurve(), rather than accessing the ON_SumSurface::m_curve.

11. B-Rep: B-Rep geometry creation can be done in Parasolid using Topology or Trim surface approach (Sewing a surface to form solid or sheet geometry). For converting Rhino B-Rep geometry to Parasolid it is better suggested to use the Trim surface approach because it is very difficult to create Topology for complex Rhino models.

12. Trimmed and Untrimmed surface: In Rhino you can get the trimmed surface geometry in the model. To decide whether the surface is trimmed or untrimmed (planer) openNURBS provides a function ‘FaceIsSurface’ flag. If the ‘FaceIsSurface’ flag is true then you need to create the surface using the Parasolid API ‘PK_SURF_make_sheet_trimmed’. While using this API you need to provide the correct trim loop and sets as trim data to the API. You need to reorder the curve order data using vertex connectivity to form a loop. And then pass the loop to the API. If the ‘FaceIsSurface’ returns false then you need to create the surface using the Parasolid API ‘PK_SURF_make_sheet_body’ which takes the ‘UV’ box as input. 

13. Extrude geometry: For creating extruded geometry in Parasolid it is better to use B-Rep data as it is easy to handle cases where extrude bodies have slant surfaces or have cut (trim) with some angle. openNURBS provides an ‘ON_Extrusion’ class to handle the extruded geometry. You need to create the extruded geometry in Parasolid by using the B-Rep form of it.

14. Mesh geometry: You can use the index facet method to create mesh geometry in Parasolid by using API ‘PK_MESH_create_from_facets’ in Parasolid. The corresponding class provided by openNURBS for mesh geometry  is ‘ON_Mesh’. Rhino mesh objects have facets in the form of both triangles and quadrilaterals. But Parasolid accepts the mesh facets in triangular form. You need to do the tessellation and provide the facets in triangular form only. Rhino mesh geometry data matches exactly what is needed for the index facet method. In Parasolid it is advisable to use index facet method for mesh geometry creation.
After creating the mesh you need to create the body from the mesh using the Parasolid API ‘PK_MESH_make_bodies’. You need to provide the preferred body type of the mesh  body to decide this openNURBS has a flag ‘IsSolid’. If the flag is true then create the mesh in solid format else create the mesh in sheet body form.

Note: 

  • In Rhino every geometry type is derived from the ON_Geometry base class.
  • Every Rhino curve and surface has NURBS form data. As per the requirement you can create curves and surfaces using it’s NURBS form. 

Author: Somesh P.
Contact us:
info@prototechsolutions.com
ProtoTech Solutions and Services Pvt. Ltd.

ProtoTechSolutions
ProtoTechSolutions

Leave a Reply

Your email address will not be published. Required fields are marked *