Core: 3D Geometry
This section deals with the objects and actions used to extract the geometry of a Creo Parametric solid. Because the geometry objects are closely related to each other and they have a number of generic action types in common, this section is organized not by object, but by type of action needed in Creo TOOLKIT.
Some of the objects and actions in this also apply to assemblies. See Assembly: Basic Assembly Access section for information on objects and actions specific to assemblies.
Geometry Objects
The generic object for geometry is called ProGeomitem, or “geometry item”. It is a DHandle that shares the declaration of ProModelitem. Its own instances are the specific types of geometrical item familiar to users of Creo Parametric. Each of these is declared as an OHandle, or opaque handle.
The ProGeomitem types are as follows:
•  ProSurface—Surface, datum surface, or datum plane
•  ProEdge—Edge
•  ProCurve—Datum curve
•  ProCompcrv—Composite datum curve
•  ProQuilt—Quilt
•  ProAxis—Axis
•  ProPoint—Datum point
•  ProCsys—Datum coordinate system
Every ProGeomitem is contained in a feature, and each feature is contained in a solid, as shown in the following figure.
ProGeomItem in Feature In Solid
Image
Some geometrical items in a part are also contained in another hierarchy, which shows how they connect together geometrically, rather than to which features they belong. This type of hierarchy is shown in the following figure.
Hierarchy of Geometrical Items in a Part
Image
The Creo TOOLKIT object ProContour is also an OHandle, but has no corresponding integer identifier, and therefore is not an instance of ProGeomitem.
There are a number of actions applicable to many of these types, whose corresponding functions begin with “ProGeomitem”. These include functions such as ProGeomitemdataGet(), for which there are also specific functions for the subtypes (where appropriate), and some functions for generic measurement operations. These functions are described under the context of their action type.
To read and modify the name of a ProGeomitem, use the functions ProModelitemNameGet() and ProModelitemNameSet(), described in the section Core: Models and Model Items.
Visiting Geometry Objects
Visiting geometry objects means acquiring the object handles to all the geometry objects in a solid model, either in the form of a ProGeomitem, or in the form of the various specific opaque handles.
The term “solid” is used in Creo TOOLKIT to distinguish models that contain three-dimensional geometry—parts and assemblies—from other model types, such as drawings. However, to the Creo Parametric user, the term “solid” is used in parts and assemblies to distinguish features that represent the geometry of the design object from features used in construction only—the various types of “datum.” Within this section, therefore, the terms “solid geometry” and “datums” are used in that sense.
The most general way to visit geometrical items is through their features. Visiting Feature Geometry describes this in detail, and includes an illustration of the hierarchy used.
You can also traverse solid geometry items through the hierarchy of surfaces, contours, and edges in a part. This is described in Visiting Solid Geometry.
The following sections describe the traversal of the various datums. Some of these datums have their own visit functions, whereas others are visited through the feature hierarchy.
Note
Although the Creo Parametric user can create solid features in Assembly mode, the geometrical items that result from them are stored only within the component parts whose geometry is modified—not in the assembly features themselves. Therefore, although traversal of datums is applicable to assemblies exactly as to parts, no solid geometry items are found in assemblies.
Datum planes, datum surfaces, and solid surfaces are all represented by the ProSurface object because they share the same types of mathematical description.
Visiting Feature Geometry
Functions Introduced:
All geometry in Creo Parametric is created as a result of features, so each geometry object in Creo TOOLKIT belongs to a feature. Therefore, the most general way to traverse geometry of all types is to traverse the features, then traverse the geometry each one contains.
The function ProSolidFeatVisit() visits every feature in a solid. The function ProFeatureTypeGet() reports the type of a feature in terms of the enumerated type ProFeattype (described in the include file ProFeattype.h).
Note that ProSolidFeatVisit() is designed partly for internal use within Creo Parametric. It visits not only the features seen by the Creo Parametric users, but also the features created internally to help in the construction of geometry. These internal features are rarely of interest to Creo TOOLKIT users. To distinguish the visible features from the internal, or invisible, features, call the function ProFeatureVisibilityGet(). Internal features are invisible features used internally for construction purposes.
Note
The function ProFeatureVisibilityGet() is primarily used in the action and filter callbacks of the function ProSolidFeatVisit().
The function ProFeatureStatusGet() reports whether a feature is suppressed or inactive for some reason—only active features contain active geometry.
The function ProFeatureGeomitemVisit() visits the geometry items within a feature. It can visit all the geometry items, or one of these specific types:
SURFACE, PRO_EDGE, or PRO_CURVE. Like ProSolidFeatVisit(), this function visits not only the visible items, but also items used internally to aid in regeneration. Use the function ProGeomitemIsInactive() to skip over the internal, or inactive, geometry items. For features with solid geometry, ProFeatureGeomitemVisit() visits not only the surfaces, but also the edges. Contrast this with the visit functions specific to those items, described in the next section, that show the hierarchical relationships between surfaces, contours, and edges.
If you want the function ProFeatureGeomitemVisit() to visit annotation elements only , use the feature type PRO_ANNOTATION_ELEM.
Active geometry objects for datums will usually be found in features created for them, and therefore have the corresponding type. For example, a ProGeomitem object of type PRO_CSYS is usually contained in a feature of type PRO_FEAT_CSYS. However, this is not always true; a geomitem of type PRO_AXIS can exist in a feature of type PRO_FEAT_HOLE, for example. A feature of type PRO_FEAT_MERGE, which may arise from a Mirror operation in Part mode, or from a Merge in Assembly mode, contains geometry objects corresponding to all those in the referenced features, whatever their type. In general, it is it best to make no assumptions about what kinds of feature in which you should look for datums.
Remember to distinguish the feature object from the geometry object it contains, even when they have a one-to-one relationship. For example, a feature of type PRO_FEAT_DATUM_AXIS contains a single geometry item of type PRO_AXIS, and each of these can be represented as a ProModelitem object. However, they are still distinct items with their own identifiers and types.
To extract the type and shape of each geometry item, use the function ProGeomitemdataGet(), described in detail in the section Geometry Equations.
Note
Some of the following sections about traversing specific geometry items introduce new functions specific to those types. PTC recommends that you use the more specific functions rather than the general method described in this section, because they are easier to use and usually have better performance.
All the functions in this section specific to features are described in detail in Core: Features.
Visiting Solid Geometry
Functions Introduced:
Superseded Functions:
In Creo Parametric 7.0.0.0 and later, the function ProSolidSurfaceVisit() has been deprecated. The function ProSolidSurfaceVisit() visits the surfaces of the model only if the model has a single body else returns the error PRO_TK_MULTIBODY_UNSUPPORTED.
The method ProSolidBodySurfaceVisit() visits all the surfaces in the specified body.
In a Creo Parametric solid, each surface contains a list of contours, and each contour contains a list of edges. The edges in a contour form a closed loop, and are ordered such that following the edges keeps the surface on the right. External contours go clockwise, and internal contours go counterclockwise.
The functions ProSolidBodySurfaceVisit(), ProSurfaceContourVisit(), and ProContourEdgeVisit() traverse all the objects in this three-level hierarchy. If you visit all the surfaces, the contours of each surface, and the edges of each contour, the resulting code visits each surface and contour one time, and each edge twice. This is true because each edge forms the intersection between two surfaces, and is therefore listed in one contour of each of the two surfaces.
The function ProEdgeContourGet() returns a pointer to the contour, which is associated with the specified edge. The input arguments are:
•  surface—Specifies the surface of the contour.
•  edge—Specifies the handle of the edge.
The function ProContourTraversalGet() tells you whether the specified contour is internal or external. The function ProContainingContourFind() finds the innermost contour that closes the specified contour. If the specified contour is internal, the returned contour will be external, and vice versa. If the specified contour is the outermost contour for the surface, ProContainingContourFind() outputs NULL.
Each contour has a natural direction in terms of the order in which ProContourEdgeVisit() visits its edges. Each edge also has its own direction, in terms of its parameterization—the parameter, t, moves from 0 to 1 along the edge. The function ProEdgeDirGet() tells you whether an edge is parameterized along or against the direction of the specified contour. Note that each edge belongs to two contours, and will be in the same direction as one contour, and in the opposite direction of the other.
The function ProEdgeNeighborsGet() returns the two surfaces that intersect at the specified edge, and which edges on each of those surfaces is the next one following the specified edge when traversing its contour.
The function ProEdgeVertexdataGet() returns the list of surfaces and edges that meet at the specified vertex.
Note
The functions in this section visit active geometry items only, so you do not need to call the function ProGeomitemIsInactive().
Example 1: Finding the Surfaces Penetrated by a Hole
The sample code in UgGeomHoleSrfDisp.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_geometry uses the techniques of feature traversal and solid geometry traversal to find the surfaces that neighbor the surfaces of the selected hole.
Visiting Axis Datums
Functions Introduced:
An axis is represented by the object ProAxis, which is declared as an opaque handle. The function ProSolidAxisVisit() visits all the axes in a part or assembly. An axis created explicitly using the Creo Parametric command Model  Axis will be contained in a feature of type PRO_FEAT_DATUM_AXIS, but axes can also exist in features of other types, such as PRO_FEAT_HOLE.
To find the feature that an axis belongs to, describe the axis in terms of a ProGeomitem object using the functions ProAxisIdGet() and ProModelitemInit(), then call ProGeomitemFeatureGet().
You could also traverse axes using the functions ProSolidFeatVisit() and ProFeatureGeomitemVisit(), described in the section Visiting Feature Geometry. As input to ProFeatureGeomitemVisit(), use the type PRO_AXIS. You would have to visit features of any type that could contain axes.
Always remember to use the function ProGeomitemIsInactive() to skip over axes used internally only.
The function ProAxisSurfaceGet() provides the ProSurface object that identifies the surface used to define the axis position.
Visiting Coordinate System Datums
Functions Introduced:
A coordinate system datum is represented by the object ProCsys, which is declared as an opaque handle. The function ProSolidCsysVisit() visits all the coordinate system datums in a part or an assembly.
You could also traverse the coordinate system datums using the ProSolidFeatVisit() and ProFeatureGeomitemVisit() functions, described in the section Visiting Feature Geometry. The coordinate system datums are usually found in features of type PRO_FEAT_CSYS, although they can appear in others, and have the geomitem type PRO_CSYS.
Always remember to use the function ProGeomitemIsInactive() to skip over coordinate system datums used internally only.
The function ProCsysIdGet() provides the persistent integer identifier of the coordinate system, which is used if you need to make a ProGeomitem representation of the coordinate system. The function ProCsysInit() creates a ProCsys object from the integer identifier.
Visiting Datum Planes
Functions Introduced:
A datum plane is represented by the object ProSurface, which is declared as an opaque handle and is also used to represent solid surfaces and datum surfaces.
To visit all the datum planes, use the functions ProSolidFeatVisit() and ProFeatureGeomitemVisit(), described in the section Visiting Feature Geometry. The datum planes are contained in features of type PRO_FEAT_DATUM, each of which contains a single active ProGeomitem object whose type field is PRO_SURFACE.
Always remember to use the function ProGeomitemIsInactive() to skip over datum planes used internally only. (Active datum planes occur in features of type PRO_FEAT_DATUM only; datum planes created on-the-fly during creation of other features are inactive.)
To convert the ProGeomitem to a ProSurface, use the id field in the ProGeomitem as input to the function ProSurfaceInit().
The function ProSurfaceIdGet() gives the integer identifier of a ProSurface, so you can convert back to a ProGeomitem using the function ProModelitemInit().
Note
Although a datum plane has a nominal outline used to visualize the datum in the Creo Parametric display, this is not part of the geometry because a datum plane is an infinite, unbounded plane. Therefore, if you try to use the function ProSurfaceContourVisit() on a datum plane, it will not find any contours.
Visiting Quilts and Datum Surfaces
Functions Introduced:
A datum surface is represented by the object ProSurface, which is declared as an opaque handle and is also used to represent solid surfaces and datum planes.
From the viewpoint of Creo TOOLKIT, every datum surface belongs to a quilt, even if no explicit quilt feature has been made in Creo Parametric. If the user creates a single datum surface, it belongs to an internal quilt created for that purpose.
A quilt is represented by the object ProQuilt, which is declared as an opaque handle.
To visit datum surfaces, you must therefore first visit all the quilts, using ProSolidQuiltVisit(), then visit each surface in the quilt using ProQuiltSurfaceVisit().
The function ProSolidQuiltVisit() takes the filter function ProQuiltFilterAction() and the visit function ProQuiltVisitAction() as its input arguments. The function ProQuiltFilterAction() is a generic action function for filtering quilts from a solid model. It returns the filter status of the quilts. This status is used as an input argument by the visit action function ProQuiltVisitAction().
The function ProQuiltSurfaceVisit() takes the filter function ProQuiltSurfaceFilterAction() and the visit function ProQuiltSurfaceVisitAction() as its input arguments. The function ProQuiltSurfaceFilterAction() is a generic action function for filtering datum surfaces in a quilt. It returns the filter status of the datum surfaces. This status is used as an input argument by the visit function ProQuiltSurfaceVisitAction()
Always remember to use the function ProGeomitemIsInactive() to skip over quilts and datum surfaces used internally only.
To convert a ProQuilt object to a ProGeomitem, use the functions ProQuiltIdGet() and ProModelitemInit().
To create a ProQuilt object from the integer identifier, use ProQuiltInit().
To find the contours and edges of a datum surface, use the visit functions ProSurfaceContourVisit() and ProContourEdgeVisit(), described in the section Visiting Solid Geometry.
Visiting Datum Curves
Functions Introduced:
A datum curve is represented by the object ProCurve, which is declared as an opaque handle.
To visit all the datum curves, use the functions ProSolidFeatVisit() and ProFeatureGeomitemVisit(), described in the section Visiting Feature Geometry. The datum curves are contained in features of many different types, each of which contains one or more active ProGeomitem objects whose type field is PRO_CURVE.
Always remember to use the function ProGeomitemIsInactive() to skip over datum curves used internally only.
To convert a ProCurve object to a ProGeomitem, use the functions ProCurveIdGet() and ProModelitemInit().
To create a ProCurve object from the integer identifier, use ProCurveInit().
Use the functions ProCurvePersistentColorGet() and ProCurvePersistentColorSet() to obtain and set the color of a specified curve. In order to view the color changes, use the function ProDisplistInvalidate() on the owner model.
Use the functions ProCurvePersistentLinestyleGet() and ProCurvePersistentLinestyleSet(). In order to view the linestyle changes, use the function ProDisplistInvalidate() on the owner model.
Visiting Composite Datum Curves
Function Introduced:
A composite datum curve is also represented by the object ProCurve. To distinguish a composite curve from an ordinary curve when dealing with a ProCurve object, use the function ProCurveTypeGet(). This function outputs the value PRO_ENT_CMP_CRV for a composite curve.
To visit all the composite datum curves, use the functions ProSolidFeatVisit() andProFeatureGeomitemVisit(), described in the section Visiting Feature Geometry.
The composite curves are contained in features of many different types, each of which contains one or more active ProGeomitem objects whose type field is PRO_CURVE.
To visit the datum curves in a composite curve, use the function ProCurveCompVisit().
Remember that each curve in a composite may be a composite itself, so you may need to make recursive calls. However, you can find all non-composite curves, including those contained in composites, using the method described in the previous section. It is therefore unnecessary to traverse all the composite curves to find all the non-composite curves.
Visiting Datum Points
Functions Introduced:
A datum point is represented by the object ProPoint, which is declared as an opaque handle.
To visit all the datum points, use the functions ProSolidFeatVisit() and ProFeatureGeomitemVisit(), described in the section Visiting Feature Geometry. The datum points are usually contained in features of type PRO_FEAT_DATUM_POINT, although they can also occur in others, such as PRO_FEAT_MERGE. Datum points are represented by geometry items of type PRO_POINT.
Always remember to use the function ProGeomitemIsInactive() to skip over datum points used internally only.
To convert a ProPoint object to a ProGeomitem, use the functions ProPointIdGet() and ProModelitemInit().
To create a ProPoint object from the integer identifier, use ProPointInit().
Tessellation
You can calculate tessellation for different types of Creo Parametric geometry. The tessellation is made up of small lines (for edges and curves), or triangles (for surfaces and solid models).
Curve and Edge Tessellation
Functions Introduced:
The function ProEdgeTessellationGet() enables you to invoke the algorithm that generates a sequence of lines from an arbitrary curved edge. This function provides the following outputs:
•  An array of the XYZ coordinates of the vertices between the tessellations
•  The two surfaces that neighbor the edge (as also provided by ProEdgeNeighborsGet()). If the edge is a single-sided edge, then the output argument returns only one surface.
•  An array of uv pairs for the tessellation vertices in the first neighboring surface
•  An array of uv pairs for the second neighboring surface
•  The number of tessellation vertices
The function ProCurveTessellationGet() retrieves the curve tessellation for a datum curve. It returns the number of tessellation points and a list of them.
Surface Tessellation
Functions Introduced:
The function ProSurfaceTessellationGet() calculates the tessellation data given by the ProTessellation object for a specified surface. Use the function ProTessellationFree() to release the memory used by this data object.
The function ProTessellationVerticesGet() obtains the vertices for the tessellation for a specified surface.
The function ProTessellationFacetsGet() obtains the indices indicating the vertices used for each facet of the tessellated item.
The function ProTessellationNormalsGet() obtains the normal vectors for each of the tessellation vertices.
The function ProTessellationParamsGet() obtains the UV parameters for each of the tessellation vertices.
The function ProSurfacetessellationinputAlloc() allocates the ProSurfaceTessellationInput data object containing the options for surface tessellation. Use the function ProSurfacetessellationinputFree() to release the memory allocated to this data object.
The function ProSurfacetessellationinputChordheightSet() assigns the chord height used for surface tessellation.
The function ProSurfacetessellationinputAnglecontrolSet() assigns the value of the angle control used for surface tessellation.
The function ProSurfacetessellationinputStepsizeSet() assigns the maximum value for the step size used for surface tessellation.
The function ProSurfacetessellationinputUvprojectionSet() assigns the parameters used to calculate the UV projection for the texture mapping to the tessellation inputs. The types of UV projection are given by the enumerated type ProSurfaceTessellationProjection, and are as follows:
•  PRO_SRFTESS_DEFAULT_PROJECTION—Provides the UV parameters for the tessellation points that map to a plane whose U and V extents are [0,1] each. This is the default projection.
•  PRO_SRFTESS_PLANAR_PROJECTION—Projects the UV parameters using a planar transform, where u=x, v=y, and z is ignored.
•  PRO_SRFTESS_CYLINDRICAL_PROJECTION—Projects the UV parameters using a cylindrical transform, where x=r*cos(theta), y=r*sin(theta), u=theta, v=z, and r is ignored.
•  PRO_SRFTESS_SPHERICAL_PROJECTION—Projects the UV parameters onto a sphere, where x=r*cos(theta)*sin(phi), y=r*sin(theta)*sin(phi), z=r*cos(phi), u=theta, v=phi, and r is ignored.
•  PRO_SRFTESS_NO_PROJECTION—Provides the unmodified UV parameters for the tessellation points. This is similar to using the function ProSurfaceParamEval().
•  PRO_SRFTESS_BOX_PROJECTION—Projects the UV parameters using the box transform. The box transformation uses planar projection to project a point from the face of the box onto the model or surface, which is opposite to the face of the box, where u = x, v = y, and z is ignored.
Note
•  If the function ProSurfacetessellationinputUvprojectionSet() is not used, the output tessellation will not contain any UV parameters and the function ProTessellationParamsGet() will not return any values.
•  Specify the unmodified UV parameters obtained using PRO_SRFTESS_NO_PROJECTION as the input u and v values for the functions ProSurfaceXyzdataEval(), ProSurfaceUvpntVerify(), ProSurfaceDiameterEval(), and ProSurfacePrincipalCrvtEval().
Part and Assembly Tessellation
Functions Introduced:
The function ProPartTessellate() tessellates all surfaces of the specified part or assembly in one operation. On parts, ProPartTessellate() acts on all surfaces. On assemblies, this function acts only on surfaces that belong to the assembly, that is, it does not tessellate surfaces of the assembly components. ProPartTessellate() returns an array of ProSurfaceTessellationData data objects. Use the function ProPartTessellationFree() to release the memory assigned to these data objects.
Evaluating Geometry
The geometry of each edge or curve in Creo Parametric is described as a set of three parametric equations that represent the values of X, Y, and Z as functions of the independent parameter, t. For a surface, the three equations are functions of the two independent parameters u and v.
The Creo TOOLKIT functions described in this section provide the ability to evaluate the parametric edge and surface functions—that is, find the values and derivatives of X, Y and Z for the specified values of t, or u and v. They also provide for reverse evaluation.
Evaluating Surfaces, Edges, and Curves
Functions Introduced:
The function ProSurfaceXyzdataEval() evaluates the parametric equations for a surface at a point specified by its u and v values. The inputs to the function are the ProSurface object and the u and v values. The u and v values are obtained by specifying the projection type as PRO_SRFTESS_NO_PROJECTION for the function ProSurfacetessellationinputUvprojectionSet().
The function outputs are as follows:
•  The X, Y, and Z coordinates of the point, with respect to the model coordinates
•  The first partial derivatives of X, Y, and Z, with respect to u and v
•  The second partial derivatives of X, Y, and Z, with respect to u and v
•  A unit vector in the direction of the outward normal to the surface at that point
The function ProEdgeXyzdataEval() performs a similar role for an edge. Its inputs are the ProEdge object and the value of t at the required point. The function outputs are as follows:
•  The X, Y, and Z coordinates of the point, with respect to the model coordinates
•  The first partial derivatives of X, Y, and Z, with respect to t
•  The second partial derivatives of X, Y, and Z, with respect to t
•  A unit vector in the direction of the edge
You must allocate a memory location for each of the output arguments of these two functions. Pass a NULL pointer if you do not want to use an output argument. You cannot pass a null for both the output arguments.
The function ProCurveXyzdataEval() is equivalent to ProEdgeXyzdataEval(), but works for datum curves.
The ProEdgeUvdataEval() function relates the geometry of a point on an edge to the surfaces that meet at that point.
The function ProSurfaceUvpntVerify() verifies whether a surface point, specified by its u and v values, lies inside, outside, or very close to the boundary of the surface. The u and v values are obtained by specifying the projection type as PRO_SRFTESS_NO_PROJECTION for the function ProSurfacetessellationinputUvprojectionSet().
Function ProContourUvpntVerify() does the same for points on a given contour.
Inverse Evaluation and Minimum Distances
Functions Introduced:
These functions provide the parameters of a point on a surface, edge, or datum curve nearest to the specified XYZ coordinate point.
You can use the function ProEdgeParamEval() only for the points that are either on the edge or very close to the edge.
The function ProSurfaceParamEval() returns the closest approximation to the unmodified u and v values obtained by specifying the projection type as PRO_SRFTESS_NO_PROJECTION for the function ProSurfacetessellationinputUvprojectionSet().
Use the function ProGeomitemBodyGet() to retrieve the body that is associated with the specified geometry item.
Geometry at Points
Functions Introduced:
The function ProGeometryAtPointFind() locates the geometry items that lie on a given point. This function supports solid geometry only.
The function ProPoint3dOnsurfaceFind() determines if the distance between the specified point and the specified surface is less than the Creo Parametric model accuracy as set in the current Creo Parametric session. Accuracy can also be set with function ProSolidAccuracySet(). This function is applicable to solid and datum surfaces.
The function ProPoint3dIntoleranceFind() determines if two specified points are co-incident, that is, if the distance between the two points is within the Creo Parametric tolerance set in ProSolidToleranceGet().
The function ProSolidProjectPoint() projects a point along the shortest possible line normal to a surface, finds the point where that line hits the solid, and returns that point. Note that this function works on parts only.
Geometry Equations
Functions Introduced:
The parametric equations that describe surfaces, edges, and datum curves in Creo Parametric are documented in the Geometry Representations section. (Datum curves are geometrically equivalent to edges, but because they play a different role in Creo Parametric, they need a parallel set of functions to access them. The word curve is used as a generic word for the shape of either an edge or a datum curve.)
To know the form of a particular geometry item, you need to know not only which type of equation is being used, but also the values of the various coefficients and constants used in that equation for that item.Geometry Representations documents the equations using the same names for these coefficients and constants used to store them in the Creo Parametric data structures. The functions in this section enable you to get copies of the data structures containing those coefficients and constants. Therefore, you can perform your own evaluations.
The data structures for ProSurfacedata are defined in the include file ProSurfacedata.h, and those for ProCurvedata are defined in ProCurvedata.h.
The function ProGeomitemdataGet() allocates and fills a data structure that describes the geometry of the item. The structure ProGeomitemdata is declared in the file ProGeomitemdata.h, and looks like this:
typedef struct geom_item_data_struct
{
  ProType              obj_type;
  union
  {
     ProCurvedata     *p_curve_data;
     ProSurfacedata   *p_surface_data;
     ProCsysdata      *p_csys_data;
  }  data;
} ProGeomitemdata;
The type field has the same value as the type field in the ProGeomitem object.
The three fields in the union contain data structures for the geometry of curves (including solid edges and axes), surfaces, and coordinate system datums. These three data structures are described in detail in Geometry of Solid Edges, Geometry of Surfaces, and Geometry of Coordinate System Datums, respectively.
The memory for the data structure is allocated by the function, but is never freed. To free the memory when you have finished with it, call ProGeomitemdataFree().
Use the function ProLogObjectitemdataGet() to retrieve the geometric representation data for the specified log object type item. The input argument p_item is the handle to the ProGeomitem object. The function supports the PRO_LOG_OBJECT item type only. The output argument p_surf_arr is the item data specified using the ProSurface object.
Geometry of Solid Edges
Functions Introduced:
Function ProEdgeTypeGet() provides the equation used to describe the edge. Function ProEdgeDataGet() returns the data structure associated with the specified edge.
Use function ProEdgedataMemoryFree() to free the top-level memory associated with the edge data structure. Function ProEdgedataFree() frees the underlying memory of the data structure.
Follow these steps to get the description of an edge:
1. Get the type of equation used to describe the edge using the function ProEdgeTypeGet(). The possible types for a solid edge are as follows:
•  PRO_ENT_LINE—A straight line
•  PRO_ENT_ARC—An arc
•  PRO_ENT_ELLIPSE—An ellipse
•  PRO_ENT_SPLINE—A nonuniform cubic spline
•  PRO_ENT_B_SPLINE—A nonuniform rational B-spline (NURBS)
2. Get the data structure for the geometry using the function ProEdgeDataGet(). For an edge, the type field is set to PRO_EDGE, and the relevant field from the union is p_curve_data. The type for that field, ProCurvedata, is itself a union that contains a field for each type of edge equation. For example, if the edge type is PRO_ENT_ARC, the relevant field in the ProCurvedata structure is the one called arc, of type ProArcdata. Each such structure contains fields for the coefficients and constants in the relevant equations (described in the Geometry Representations section), and share the same names.
3. When you have read the information you need from the ProGeomitemdata structure, free the memory using ProGeomitemdataFree().
Example 2: Extracting the Diameter of an Arc Edge
The sample code in UgGeomArcDiaDisp.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_geometry shows how to extract the geometry equation of a solid edge.
Geometry of Surfaces
Functions Introduced:
The method for getting the description of surface geometry is analogous to that described in the previous section for solid edges. Function ProSurfaceTypeGet() provides the equation used to describe the surface. Function ProSurfaceDataGet() returns the data structure associated with the specified surface.
Use function ProSurfacedataMemoryFree() to free the top-level memory associated with the surface data structure. Function ProSurfacedataFree() frees the underlying memory of the data structure.
The possible types of surface are as follows:
•  PRO_SRF_PLANE—A plane
•  PRO_SRF_CYL—A cylinder
•  PRO_SRF_CONE—A cone
•  PRO_SRF_TORUS—A torus
•  PRO_SRF_COONS—A Coons patch
•  PRO_SRF_SPL—A spline surface
•  PRO_SRF_FIL—A fillet surface
•  PRO_SRF_RUL—A ruled surface
•  PRO_SRF_REV—A surface of revolution
•  PRO_SRF_TABCYL—A tabulated cylinder
•  PRO_SRF_B_SPL—A nonuniform rational B-spline (NURBS)
•  PRO_SRF_CYL_SPL—A cylindrical spline surface
The relevant field in the ProGeomitemdata structure is p_surface_data, of type ProSurfacedata.
The structure ProSurfacedata contains information applicable to surfaces of all types, such as the maximum and minimum values of u and v, and of X, Y, and Z for the surface, and a union that contains a field for each type of surface geometry.
As with edges, these structures contain fields for the coefficients and constants in the relevant equations, described in Geometry Representations .
These functions are also applicable to datum surfaces, and to datum planes (in which the surface type will always be PRO_SRF_PLANE).
The function ProSurfaceIsDatumPlane() identifies if the given surface is a datum plane.
The function ProSurfaceSameSrfsFind() finds and returns an array of surfaces that are the same as the input surface. For example, in case of a cylinder, Creo Parametric creates two half cylindrical surfaces. If you obtain one half, the other half is returned by this function.
The function ProSldsurfaceVolumesFind() analyzes and returns the number of connect volumes of a part and the surfaces that bound them.
The function ProSurfacePeriodicityGet() gets information about the periodicity of a surface. The output arguments are:
•  periodic_in_u—Specifies if the surface is periodic in U-direction.
•  period_in_u—Specifies the value of period in U-direction.
•  periodic_in_v—Specifies if the surface is periodic in V-direction.
•  period_in_v—Specifies the value of period in V-direction.
The function ProSurfaceNextGet() returns the next surface in the surface list or returns NULL if there is no next surface. The input argument this_surface is the surface for which the next surface is queried and can be NULL. The output argument p_next_surface is a non-Null pointer for returning the next surface. If the surface passed through the input argument this_surface is the last surface in the list, then the returned surface is NULL.
Note
For a solid body part with multiple bodies, this function does not return a surface that is outside the body.
Example 3: Getting the Angle of a Conical Surface
The sample code in UgGeomConeAngDisp.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_geometry shows how to read the geometry equation of a surface.
Geometry of Axes
Function Introduced:
An axis is treated in the same way as a solid edge. The function ProAxisDataGet() allocates and fills a ProGeomitemdata structure for a ProAxis object. The relevant field in the union is p_curve_data, but the type of the contained edge is always a line.
Geometry of Coordinate System Datums
Function Introduced:
The function ProCsysDataGet() provides a ProGeomitemdata structure in which the field p_csys_data is set. This is a pointer to a structure called ProCsysdata, declared in ProCsysdata.h, that contains the location of the origin, and the directions of the three axes, of the coordinate system datum.
Geometry of Datum Planes
Datum planes are treated exactly like surfaces, so you can use ProSurfaceDataGet().
Their type is always PRO_SRF_PLANE.
Geometry of Quilts
Functions Introduced:
A quilt represents a "patchwork" of connected nonsolid surfaces. A quilt may consist of a single surface or a collection of surfaces. A quilt contains information describing the geometry of all the surfaces that compose a quilt and information on how quilt surfaces are "stitched" (joined or intersected). A part can contain several quilts. You can create or manipulate quilts using a surface feature.
To find the surfaces it contains, use ProQuiltSurfaceVisit() and analyze the geometry of each surface.
The function ProQuiltdataGet() retrieves information from the quilt data structure. The helper functions ProQuiltdataSurfArrayGet() and ProQuiltdataSurfArraySet() return or define, respectively, an array of pointers to the datum surfaces in the quilt data structure.
The function ProQuiltdataMemoryFree() releases the top-level memory associated with the quilt data structure. The function ProQuiltdataFree() releases the underlying memory of the data structure.
The function ProQuiltdataTypeGet() returns the type of quilt data. If the type of quilt data is a body, the output argument p_body_or_quilt returns PRO_BODY and returns PRO_QUILT if the type is quilt.
Use the function ProQuiltdataTypeSet() to set the type of quilt data as PRO_BODY or PRO_QUILT. The input arguments follow:
•  p_quilt_data—The quilt data.
•  body_or_quilt—Type of quilt data as PRO_BODY or PRO_QUILT.
The function ProQuiltVolumeEval() calculates the volume of a closed quilt.
The function ProQuiltIsBackupgeometry() identifies if the specified quilt belongs to the invisible Copy Geometry backup feature. Its input argument is a pointer to the quilt’s handle of the type ProQuilt. If the quilt belongs to the invisible Copy Geometry backup feature, the function returns a ProBoolean with the value PRO_B_TRUE; otherwise, the value is PRO_B_FALSE.
The function ProQuiltIsInternal() checks whether a quilt is created for internal use only. If the quilt is created for internal use only, the function returns a ProBoolean with the value PRO_B_TRUE; otherwise, the value is PRO_B_FALSE.
Geometry of Datum Surfaces
Because the system treats datum surfaces exactly like surfaces, you can use ProSurfaceDataGet().
They can have any type of geometry.
Geometry of Datum Points
Functions Introduced:
The function ProPointCoordGet() provides the X, Y, and Z coordinates of the specified ProPoint object.
Geometry of Datum Curves
Functions Introduced:
Datum curves use the same data structure as edges, with the same possible types of geometry. Because they are stored in a different location in the Creo Parametric database, they need their own functions:
•  ProCurveTypeGet() is analogous to ProEdgeTypeGet().
•  ProCurveDataGet() is analogous to ProEdgeDataGet().
The enumerated type ProEnttype is used to get the type of curve.
•  The value PRO_ENT_CMP_CRV specifies a composite curve.
•  The value PRO_ENT_PARAM_CRV specifies a parametrized curve (x(t), y(t), z(t)), where x, y, and z are user-defined functions.
•  The value PRO_ENT_SRF_CRV specifies a parameterized curve (u(t), v(t)) that exists on a surface, where u and v are user-defined functions.
Use the function ProComponentCurvedataAlloc() to allocate memory for a component of a composite curve. The output argument pp_component is the component of a composite curve.
Use the function ProComponentCurvedataFree() to free the memory of a component of a composite curve. The input argument p_component is the component of a composite curve.
The function ProComponentCurvedataGet() gets information from a component of a composite curve.
Note
The function ignores the output arguments with null pointers.
The input argument p_component is the component of the composite curve.
The output arguments are:
•  p_curve—The component curve.
•  p_direction—The direction of the component.
The function ProComponentCurvedataInit() initializes a component of a composite curve data structure.
The input arguments are:
•  p_curve—The component curve data structure is defined by the ProCurvedata.
•  direction—The direction of the component is defined by the ProCurveDir.
The output argument p_component is the component of the composite curve and is defined by the ProComponentCurvedata.
The function ProCompositeCurvedataGet() gets information from the composite curve data structure.
The function ProCompositeCurvedataInit() initializes a composite curve data structure.
Use function ProCurvedataMemoryFree() to free the top-level memory associated with the curve data structure. Function ProCurvedataFree() frees the underlying memory of the data structure.
Geometry of Composite Curves
A composite curve does not have geometry of its own. Find the member curves using ProCurveCompVisit() and analyze their geometry in the usual way.
Ray Tracing
Functions Introduced:
The function ProSolidRayIntersectionCompute() finds the intersections between a ray and a solid.
The ray is defined in terms of a start location and direction vector. The intersections are described in terms of an array of ProSelection objects to show their context in an assembly.
The function finds intersections in both directions from the start point of the ray, and assigns each intersection a depth—the distance from the ray start point in the direction defined (intersections in the reverse direction have a negative depth). You can extract the depth of each intersection using the function ProSelectionDepthGet(). The intersections are ordered from the most negative depth to the most positive.
The function processes all solid surfaces and datum surfaces, but not datum planes. It also includes edges that lie within a certain critical distance, called the aperture radius, of the ray. Such an edge is shown as intersected, even if a neighboring surface is also intersected. This implies that several entries in the array may represent a single “piercing,” in geometrical terms.
The aperture radius is an optional input to the function, defined in terms of pixels. If you supply a value less than –1.0, the value is taken from the Creo Parametric configuration file option pick_aperture_radius. If that option is not set, the function uses the default value of 7.0.
In an assembly, each component is processed separately, so if two coincident mating faces are hit, the function records two separate intersections.
Surfaces and edges that are not displayed because they are assigned to a blanked layer are not intersected.
This function is most often used in optical analysis, when calculating the path of a ray of light through an assembly whose parts represent lenses or mirrors. In this case, you want to find the closest intersecting surface in the positive direction, then calculate the normal to the surface at that point, in assembly coordinates.
Measurement
Functions Introduced:
The function ProSurfaceAreaEval() evaluates the surface areas of a specified surface. It is not valid for datum planes.
Function ProContourAreaEval() outputs the inside surface area of a specified outer contour. Note it takes into account internal voids.
The function ProSurfaceExtremesEval() finds the coordinates of the face edges at the extremes in the specified direction. The accuracy of the result is limited to the accuracy of edge tessellation.
Function ProSurfacePrincipalCrvtEval() outputs the curvatures and directions of the specified surface at a given UV point. The u and v values are obtained by specifying the projection type as PRO_SRFTESS_NO_PROJECTION for the function ProSurfacetessellationinputUvprojectionSet().
The function ProEdgeLengthEval() evaluates the length of a solid edge, and ProCurveLengthEval() does the same for a datum curve.
Function ProEdgeLengthT1T2Eval() finds the length of a specified edge between two parameters. Use function ProCurveLengthT1T2Eval() to do the same for a curve.
ProEdgeParamByLengthEval() finds the parameter value of the point located a given length from the specified start parameter. Use function ProCurveParamByLengthEval() to do the same for a curve.
The function ProGeomitemDistanceEval() measures the distance between two geometry items. The geometry items are expressed as ProSelection objects, so you can specify any two objects in an assembly. Each object can be an axis, plane surface, or datum point.
The function ProGeomitemAngleEval() measures the angle between two geometry items expressed as ProSelection objects. Both objects must be straight, solid edges.
The function ProSurfaceDiameterEval() measures the diameter of a surface, expressed as a ProSelection object. The surface type must be one of the following:
•  Cylinder—The cylinder radius
•  Torus—The distance from the axis to the generating arc
•  Cone—The distance of the point specified from the axis
•  Surface of revolution—The distance of the point specified from the axis
The u and v values are obtained by specifying the projection type as PRO_SRFTESS_NO_PROJECTION for the function ProSurfacetessellationinputUvprojectionSet().
Note
In the case of a sphere made by revolving an arc, the Creo Parametric command Analysis  Diameter gives the real spherical diameter, whereas ProGeomitemDiameterEval() gives the distance of the specified point from the axis of revolution.
The functions ProContourBoundbox2dCompute() and ProContourBoundbox3dCompute() output a bounding box for the inside surface of the specified outer contour.
Note
•  Only the ProContourBoundbox3dCompute() function takes into account internal voids.
•  The outline returned by the function ProContourBoundbox3dCompute() represents the outline box used by Creo Parametric embedded algorithms, and hence it can be slightly bigger than the outline computed directly from the surface parameters.
The function ProSelectionWithOptionsDistanceEval() evaluates the distance between two items. You can evaluate distance between surfaces, edges, entities, vertices, curves, datums, and so on. The initial selection of the item is used to guess the type of geometry. In case of error types PRO_TK_BAD_INPUTS or PRO_TK_BAD_CONTEXT, the output argument p_result is set to -1.0 and all parameters are set to 0.0.
The input arguments option1 and option2 are analogous to Options in the Measure dialog box in Creo Parametric user interface. You can specify PRO_B_TRUE if you want to turn on the following options for the selected items:
•  If the selected item is a cylindrical surface, measures the distance from the central axis of the cylindrical surface. Specify PRO_B_FALSE to measure from the surface instead of the axis.
•  If the selected item is an arc, measures the distance from the center of a circle or an arc-shaped curve or edge. Specify PRO_B_FALSE to measure from the edge instead of the center.
•  If the selected item is a planar surface or a plane, extends the selected surface or plane to infinity in both directions only for the purpose of measuring distance. You can now measure the distance normal to the reference entity.
•  If the selected item is linear, extends the selected straight edge or curve to infinity in both directions only for the purpose of measuring distance. You can now measure the distance normal to the reference entity.
The output arguments return the following values:
•  p_result—Distance between the two items
•  pnt_1 and pnt_2—Critical point for the first and second selected items. Critical point is the actual point used for measurement.
•  param_1 and param_2—UV parameter of the critical point for the first and second selected items
Geometry as NURBS
Functions Introduced:
A common reason for extracting the solid geometry of a Creo Parametric model is to pass it to another MCAE tool for some kind of engineering analysis. Not all of the other MCAE tools share the rich variety of geometry equation types supported by Creo Parametric, and therefore may not be able to import all the surface descriptions directly. Because many MCAE systems use nonuniform rational B-splines (NURBS) to model surfaces and edges, you frequently need to convert many or all of the Creo Parametric surface descriptions to NURB splines.
The function ProSurfaceToNURBS() operates on a surface of any type. The function makes an accurate approximation of the shape of the surface using a NURBS, and outputs a pointer to the structure ProSurfacedata. This structure contains the surface type PTC_B_SPLSRF, which describes the form of the NURBS.
The function ProEdgeToNURBS() finds a one-dimensional NURBS that approximates a Creo Parametric solid edge. The function outputs a pointer to the ProCurvedata union whose b_spline field contains the NURBS description.
The function ProCurveToNURBS() provides the same functionality as ProEdgeToNURBS(), but for a datum curve.
Both ProSurfacedata and ProCurvedata are declared in the Creo TOOLKIT header file ProGeomitem.h.
Interference
Functions Introduced:
The function ProFitClearanceCompute() computes the clearance between two objects. When the function computes clearance between two parts, it also tries to determine if there is interference between them.
Use the function ProFitGlobalinterferenceCompute() to compute the interference in the specified assembly. If the assembly is regenerated, the interference must be recalculated. The enumerated data type ProFitComputeSetup specifies the set up to compute the interference for parts or subassemblies. The valid values are:
•  PRO_FIT_PART—Computes interference between the pairs of parts in an assembly. The interference is computed only for those pairs whose volume can be calculated. The pairs whose volume could not be calculated are removed.
•  PRO_FIT_SUB_ASSEMBLY—Computes interference between the pairs of subassemblies in an assembly, that is, computes interference between parts of different subassemblies. The interference is computed only for pairs whose volume can be calculated. The pairs whose volume could not be calculated are removed.
•  PRO_FIT_PART_DETAILED—Computes interference between the pairs of parts in an assembly. The interference is computed for all the pairs irrespective of whether the volume can be calculated.
•  PRO_FIT_SUB_ASSEMBLY_DETAILED—Computes interference between the pairs of subassemblies in an assembly, that is, computes interference between parts of different subassemblies. The interference is computed for all the pairs irrespective of whether the volume can be calculated.
The function ProFitInterferenceCompute() returns the interference information specified between two items. In assembly mode, each item is either a component part or a solid body of a part. In Part mode, each item is a solid body of the current part. If the items are regenerated, the interferences must be recalculated. The input arguments follow:
•  sel_1—The first part or solid body.
•  sel_2—The second part or solid body.
•  set_facets—The option to include facets for parts.
•  set_quilts—The option to include quilts for parts.
Note
Set the ProBoolean arguments set_facets and set_quilts to PRO_B_TRUE to include facets or quilts in the model, respectively.
Note
The interference data obtained from the functions ProFitGlobalinterferenceCompute() and ProFitInterferenceCompute() must be passed as input to the functions ProFitInterferencevolumeCompute() and ProFitInterferencevolumeDisplay(). The interference data must not include facets or quilts. They must include information about only interfering solids.
The function ProFitInterferenceCompute() returns an error PRO_TK_NOT_EXIST if one or more items specified by either of the input arguments sel_1 and sel_2 could not be found or does not contain any geometry with which to compute interference.
The function returns the error PRO_TK_GENERAL_ERROR if the interference could not be computed. The function returns the error PRO_TK_NOT_VALID if the value of the interference volume is invalid.
The function ProFitInterferencevolumeCompute() calculates volume of interference between two specified components. Use the function ProFitInterferencevolumeDisplay() to display the volume of interference between the two specified components.
Use the functions ProInterferenceDataFree() and ProInterferenceInfoProarrayFree() to free the interference data obtained from the functions ProFitInterferenceCompute() and ProFitGlobalinterferenceCompute() respectively.
The function ProVolumeInterferenceCompute() calculates the volume interference between the selected closed quilt and an assembly. The output argument p_intf_infos is a pointer to the ProArray, where the interference results are stored. The interference data is returned as a ProVolumeInterferenceInfo structure.
Use the function ProVolumeInterferenceInfoArrayFree() to free the interference data obtained from the function ProVolumeInterferenceCompute(). The function is supported only in DLL mode.
The function ProVolumeInterferenceDisplay() displays the curves and surfaces that interfere with the selected quilt in the specified color or hides them. This function must be called after the interference data is computed. The input arguments are:
•  inetrf_data — Specifies a pointer to the interference data.
•  color— Specifies the color to use for highlighting the interference.
•  hilite— Specifies if the curves and surfaces that interfere with the selected quilt must be displayed or hidden. Specify PRO_B_TRUE for displaying the interfering component and PRO_B_FALSE for hiding it.
Use the function ProVolumeInterferenceBodiesGet() to obtain the solid bodies of the specified component that participate in the interference with the selected closed quilt. The input argument interf_data specified through the structure ProVolumeInterferenceData is the pointer to the interference data for the corresponding component that interferes with the quilt. The output argument r_bodies returns an array of the bodies through the structure ProSolidBody which is allocated by the function.
Call the function ProVolumeInterferenceCompute() before using ProVolumeInterferenceBodiesGet().
The function ProVolumeInterferenceBodiesGet() returns an error PRO_TK_E_NOT_FOUND if there are no solid bodies in the interference data.
The function ProVolumeInterferenceDisplayForBody() displays or hides the curves and surfaces of the specified solid body that interfere with the quilt that is selected. The input arguments follow:
•  interf_data— Pointer to the interference data for the corresponding component that interferes with the quilt.
•  p_body—Pointer to the solid body in the specified component.
•  color— Specifies the color to be used for highlighting the interference and is defined by the enumerated data type ProColortype.
•  hilite— Specifies if the curves and surfaces that interfere with the selected quilt must be displayed or hidden. Specify PRO_B_TRUE for displaying the interference geometry of the specified body and PRO_B_FALSE for hiding it.
The function ProVolumeInterferenceDisplayForBody() returns an error PRO_TK_E_NOT_FOUND if the given body does not interfere with the quilt.
Call the function ProVolumeInterferenceInfoArrayFree() to remove the interference highlighted by the function ProVolumeInterferenceDisplay() or partially highlighted by the function ProVolumeInterferenceDisplayForBody().
Faceted Geometry
Creo Parametric allows you to build a surface CAD model on top of faceted or triangular data. Each facet is uniquely identified by a face normal and three vertices.
A facet is represented by the opaque handle ProFacet, while a set of facets is represented by the DHandle ProFacetSet. ProFacetSet has the same structure as the object ProModelitem and is defined as follows:
typedef struct pro_model_item
{
  ProType  type;
  int      id;
  ProMdl owner;
} ProFacetSet;
Visiting Facets and Facet Sets
The functions described below enable you to find all the facet sets in a model and visit the facets stored in those sets.
Functions Introduced:
The function ProSolidFacetsetVisit() visits each of the facet sets in a given model. This function takes the filter function ProFacetsetFilterAction() and the visit function ProFacetsetVisitAction() as its input arguments. The function ProFacetsetFilterAction() is a generic action function for filtering the facet sets from a model. It returns the filter status of the facet sets. This status is used as an input argument by the visit action function ProFacetsetVisitAction().
The function ProFacetsetFacetVisit() visits the facets in the faceted geometry set. This function takes the filter function ProFacetFilterAction() and the visit function ProFacetVisitAction() as its input arguments. The function ProFacetFilterAction() is a generic action function for filtering a facet from the faceted geometry set. It returns the filter status of the facet. This status is used as the input argument by the visit action function ProFacetVisitAction().
Accessing Facet Properties
The functions described below allow you to access the face normal and three vertices or corners of a facet. A facet vertex is given by the object ProFacetVertex.
Functions Introduced:
The function ProFacetVerticesGet() obtains the vertices of a specified facet.
Use the function ProFacetverticesFree() to release the memory allocated for the vertices of a facet.
The function ProFacetvertexPointGet() returns the location of the facet vertex in the model coordinate system.
The function ProFacetNormalGet() returns the normal vector of a facet in the model coordinate system.