0% found this document useful (0 votes)
23 views

api_intro_1

Uploaded by

Linda Fu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

api_intro_1

Uploaded by

Linda Fu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Part 1: Parasolid Fundamentals

© 2020 Siemens Industry Software Inc.


Main areas of Parasolid
functionality:
 Model representation
 Model creation and editing
 Model enquiry and analysis
 Rendering and selection
 Application support
 Calling Parasolid
 Model Representation
 Geometry
 Inquiries
 The PK
 Tags, tokens and error codes
 Commonly used structures
 Dynamic memory allocation
 Initialising and terminating
 Further information
User Application ▪ Parasolid is accessed via
the PK interface
Graphical User Interface
▪ Parasolid communicates
Application Functionality with the operating system
via the frustrum and the
Public API - PK Interface
graphical interfaces
▪ Your application supplies
Parasolid the frustrum and graphical
interfaces
Frustrum Graphical
Interface Interface

File/Memory Management Graphics Subsystem


(databases) (device drivers)
 The PK is the main interface to Parasolid
▪ Suite of functions used to make calls to Parasolid
 Designed to be C callable
▪ Utilizes ANSI C features
 Object-oriented style reflects class hierarchy
inherent in Parasolid
 Consistent naming convention
 PK_<CLASS>_<verb>_<noun>
▪ e.g. PK_BODY_ask_faces
 PK functions use standard arrays
Parasolid Classes
 Entities
▪ Topology
▪ Bodies, faces, edges, Parasolid Class Hierarchy (Top Level)
vertices etc.
 CLASS • PARTITION
▪ Geometry  SESSION • PMARK
▪ Surface, curves, points  ERROR • MARK
▪ Associated data  MEMORY • DELTA
▪ Attributes, groups,  ENTITY
transforms etc.  VECTOR, • BB

▪ Session management BOX, ...


objects
▪ Partitions, deltas etc.
ENTITY

ATTRIB ATTDEF TOPOL GROUP TRANSF GEOM

PART REGION SHELL FACE LOOP EDGE FIN VERTEX

BODY ASSEMBLY SURF CURVE POINT

CIRCLE BCURVE
CYL CONE PLANE SPHERE TORUS
ELLIPSE SPCURVE
BSURF BLENDSF OFFSET SWEPT SPUN
LINE PLINE

MESH ICURVE
Tags
 Every entity has a unique tag
 Used for input and return arguments to/from
the PK functions
 Integer variables
 Created and assigned only by Parasolid
 Not reused - unique within a session
 Special tags: PK_ENTITY_null
Tokens
 Used by Parasolid and the application to communicate
information
▪ E.g. to specify optional behaviour during modeling operations
 Positive integer values
 Declared as constants in the ‘.h include’ file
 Should be referred to by their enumerator not their
integer value
 Special Tokens: PK_LOGICAL_true, PK_LOGICAL_false
Error codes
 Communicates success or failure of a routine
 Return value of a PK function
 Should not be referred to by their value
 Used by the application to specify the behavior of a PK function
 Of the form PK_***_o_t
 Must be initialized before use to default values
▪ Macros of the form PK_***_o_m provided for this purpose
 Fields can subsequently be set to non-default values using dotted
pairs.
 First field is the version number (o_t_version)
▪ Should never be set/altered by the application

PK_SESSION_start_o_t sessionOpts;

PK_SESSION_start_o_m(sessionOpts);
sessionOpts.journal_file = “journal”;

PK_SESSION_start(&sessionOpts);
PK_CYL_t cylinder;
PK_CYL_sf_t cyl_sf;
 Used by the application &
Parasolid to store the cyl_sf.basis_set.location.coord[0] = 1.0;
standard definition of cyl_sf.basis_set.location.coord[1] = 2.0;
Parasolid entities cyl_sf.basis_set.location.coord[2] = 3.0;
 Contain the definition of cyl_sf.basis_set.axis.coord[0] = 1.0;
surfaces, curves etc. cyl_sf.basis_set.axis.coord[1] = 0.0;
 Input & output functions cyl_sf.basis_set.axis.coord[2] = 0.0;
take the same standard cyl_sf.basis_set.ref_direction.coord[0] = 0.0;
forms. cyl_sf.basis_set.ref_direction.coord[1] = 1.0;
▪ e.g. PK_CYL_sf_t is used by cyl_sf.basis_set.ref_direction.coord[2] = 0.0;
both PK_CYL_create and cyl_sf.radius = 5;
PK_CYL_ask.
PK_CYL_create(&cyl_sf, &cylinder);
 Some PK functions pass information back to
application using return structures.
▪ Indicated by PK…_r_t in declaration
▪ e.g. PK_TOPOL_track_r_t
 Most have equivalent functions to free
memory allocated to structure
▪ Indicated by PK_…_r_f
▪ e.g. PK_TOPOL_track_r_f
 Used if the length of a returned array is unknown at run-time
 The application can register functions to manage this memory
 Denoted in the documentation by at least two levels of indirection,
e.g. PK_FACE_t**
▪ two levels may be split
 Where indicated the argument is optional
▪ Application can pass NULL
 Such memory can be freed using PK_MEMORY_free
PK_BODY_t body;
int n_faces;
PK_FACE_t* faces;

PK_BODY_ask_faces(body, &n_face, &faces);


….
….
PK_MEMORY_free(faces);
 Before the modeler is started we must:
▪ Register the frustrum
▪ PK_SESSION_register_frustrum
▪ Register the delta frustrum (if applicable)
▪ PK_DELTA_register_callbacks
 Starting the modeler
▪ PK_SESSION_start
▪ Initializes memory, session parameters, system defined
attributes
▪ Takes a number of options to control:
▪ Journalling, User fields
 Stopping the modeler
▪ PK_SESSION_stop
 The PK
▪ Functional Description chapter 10 “PK Interface
Programming Concepts”
 Frustrum and Graphical Interface
▪ Downward Interfaces manual
▪ Functional Description chapter 7 “Supplying A Frustrum”
▪ C++ Example Application files Session.cpp, frustrum.cpp,
frustrum_delta.cpp for the Frustrum
▪ C++ Example Application files Example AppDoc.cpp,
GO.cpp for the GO
▪ C++ code examples “Frustrum” and “GO”
 Initialising and terminating
▪ Example Application file Session.cpp
 The PK
 Tags, tokens and error codes
 Commonly used structures
 Dynamic memory allocation
 Initialising and terminating
 Further information
 Model entities
 Tolerant modeling
 Manifold bodies
 Further information
Body Any
Geom
Attribs
Region

Shell
Face
Face Surface
Groups Edge
Loop
Face
Loop normal
Edge
Curve Vertex
Transform Fin Fins

Vertex Point

Associated Topology Geometry


Data
What is tolerant modeling?
 Parasolid session precision is 1.0e-08
 Local precision can be set on edges and vertices
Why use tolerant modeling?
 Representing model data created in different CAD
systems
 Reliability and performance
▪ There are cases where it is better for algorithms to create
an approximate solution rather than a complex, high
order accurate solution
▪ Intersection between two surfaces that meet ‘nearly smoothly’
▪ Approximate solution in these cases is faster and more
stable
Accurate Model

Curve
Fin1 Face1
Edge

Edge Face2
Fin2 Face1
Face2 Fin1 Fin2

Tolerant Model
Tolerant edge

Face1 Face2

Fin1 Fin2

SP-curve1 SP-curve2
A part refers to a body or an assembly
Minimal body Wire
 ‘Zero dimensional’  ‘One dimensional’
 A point in space  One or more sets of simply-
 One void region, shell, loop, vertex connected edges
 Created from a point using  No more than two edges at
PK_POINT_make_minumum_body any vertex
Acorn  One void region, one shell
 The same as Minimal bodies except
they can have multiple vertices

Valid Valid Not


Valid
Sheet Solid
 ‘Two dimensional’  ‘Three dimensional’
 One or more sets of (simply)  Each component occupies a
connected faces – each set is continuous, finite volume
called a component  At least two regions
 Zero thickness ▪ one void region is infinite
 No more than 2 faces at any ▪ each component has one solid
edge region
 Can be ‘open’ or ‘closed ▪ each component has any number
of void regions
 Each component has one or
two void regions and one or
two shells
 Model entities
▪ Code example “Model Structure”
 Manifold Bodies
▪ Code example “Primitive Forms”
 Model entities
 Tolerant modeling
 Manifold bodies
 Further information
 Geometry types
 Primitive creation
 Facet geometry for Convergent Modelling
 B-Geometry
 Geometric connections
 Dependent geometry
 Further information
Curves Surface
 Analytics  Analytics
▪ Line ▪ Plane
▪ Circular cylinder
▪ Circle
▪ Circular cone
▪ Ellipse
▪ Sphere
 Freeform ▪ Torus
▪ NURBS curve  Facet geometry
 Facet geometry ▪ Mesh
▪ Pline  Freefrom
 Generated ▪ NURBS surface
▪ Parameter-space (SP) curve  Generated
▪ Isoparametric curve ▪ Surface of revolution
▪ Intersection curve ▪ Swept surface
▪ Offset surface
▪ Rolling ball blend surface
Creation
 There are primitive creation routines for curves:
▪ PK_LINE_create
▪ PK_CIRCLE_create
▪ PK_ELLIPSE_create
 These routines all take a standard form structure
▪ Parameters for size
▪ Basis set for position and orientation
Inquiry
 All APIs of the form PK_XXX_create have an
equivalent enquiry function:
▪ Of the form PK_XXX_ask, e.g. PK_LINE_ask
▪ Returns the same standard form structure
Creation and Inquiry Routines
 There are primitive creation routines for
surfaces that take a standard form structure:
▪ PK_CONE_create
▪ PK_CYL_create
▪ PK_PLANE_create
▪ PK_SPHERE_create
▪ PK_TORUS_create
 All primitive surface creation APIs of the form
PK_XXX_create have an equivalent enquiry
function
▪ Enquiry function returns the standard form structure
▪ E.g. PK_CONE_ask
 A polyline (PK_CLASS_pline) is a curve consisting of a series of line
segments
▪ This is the curve type used in facet bodies, or at the boundary of meshes in
mixed bodies
Creation
 PK_PLINE_create
 Supply a polyline standard form
▪ Position vectors
▪ Whether the curve is closed
▪ Parameter at first position vector
Inquiry
 PK_PLINE_ask
 Returns the standard form of a polyline
Polyline positions Line segments
 The surface type used in facet
bodies is the mesh
(PK_CLASS_mesh)
▪ Meshes may also be used in
mixed bodies, i.e. a face with
facet geometry in a mixed model
has a mesh attached
 Meshes are defined by:
▪ Mesh facets (mfacets)
▪ Only triangular facets are supported
▪ Mesh fins (mfins)
▪ Fin on the boundary of a mesh facet
▪ Mfins do not necessarily bound the
mesh; only laminar mfins do
▪ Mesh vertices (mvertices)
▪ Vertex on a mesh facet, not a vertex
in Parasolid’s body topology
 Mesh topology (mtopols) is the collective term for
mfacets, mfins and mvertices
 Each has a unique index for a given mesh.
▪ The mtopols are defined by their mesh tag and index
 There are numerous inquiry functions to find the
relationships between mtopols – for example:
▪ PK_MESH_ask_n_mfacets
▪ PK_MFACET_ask_fin
▪ PK_MFIN_ask_mvertex
 B-geometry is fully incorporated in Parasolid
 Generated explicitly
▪ From B-spline control points - NURBS curves and surfaces
▪ From piecewise data (Bezier, Hermite, polynomial, Taylor
series)
▪ By splining or meshing a set of points
 Generated automatically
▪ By sweeping or swinging B-curves
▪ By lofting a set of B-curves
▪ By converting curves and surfaces to B-curves and B-
surfaces
▪ Within other more general modeling operations
Explicit Creation
 All routines take a standard form structure
 From B-spline data to form NURBS curves and surfaces
▪ PK_BCURVE_create, PK_BSURF_create
▪ knot vector(s), control points, periodicity, rational/non-rational
 From piecewise data
▪ PK_BCURVE_create_piecewise, PK_BSURF_create_piecewise
▪ Data for each segment or patch
▪ Form: Bezier, Hermite, Taylor or Polynomial
 Splining
▪ PK_BCURVE_create_spline_2 and
PK_BSURF_create_splinewise
▪ Set of points and end conditions
Geometry Categories
 Geometry may be:
▪ Connected
▪ Attached directly to topology, can be one of the
following:
▪ Principle
 connected to a face, edge, fin or vertex
▪ Construction
 connected directly to a part

▪ Orphan
▪ Not incorporated in a part
▪ Associated with the partition
Connected geometry
 Inquiring principle geometry
▪ PK_EDGE_ask_geometry
▪ PK_FIN_ask_geometry
 Inquiring construction geometry
▪ PK_PART_ask_construction_<geoms>
▪ Can be surfaces, curves or points
 Defining and removing connections
▪ PK_PART_add_geoms
▪ PK_PART_remove_geoms
Orphan geometry
 PK_PARTITION_ask_geoms
▪ Enquire orphan geometry
General
 Definition depends on other geometry
 Examples include intersection curves and SP-
curves
 May be incorporated in a part or orphan
 Created implicitly as a result of another
modeling operation
Inquiry
 PK_GEOM_ask_dependents
▪ Returns geometry referenced by input geometry
 PK_GEOM_ask_geom_owners
▪ Returns geometry that references input geometry
 Primitive Creation
▪ Code Example “Primitive Forms”
 B-Geometry
▪ Code example “BGeometry”, “BGeometry
Creation”, “Create BCurve From Piecewise
Standard Form”
 Geometry types
 Primitive creation
 B-geometry
 Geometric connections
 Dependent geometry
 Further information
 Class structure
 Data connections
 Data relationships
 Topological
 Geometric
 Model analysis
▪ Validity
 Further Information
Class Structure
 PK_ENTITY_is, PK_ENTITY_is_<object> - is the given argument
an entity? Is it an entity of class <object>?
 PK_ENTITY_ask_class - which class does entity belong to?
 PK_<OBJECT>_ask_<object> - e.g. PK_FACE_ask_surf
Data Connections
 Topological Relationships - PK_BODY_ask_edges,
PK_BODY_ask_vertices
 Topological/Geometric Relationships - PK_FACE_ask_surf,
PK_EDGE_ask_curve
 Session management relationships - PK_PARTITION_ask_pmarks
Data Relationships
 PK_FACE_ask_oriented_surf/ PK_EDGE_ask_oriented_curve
▪ Returns surface/curve and logical flag
Regions Loops
 PK_REGION_is_solid  PK_LOOP_ask_type
Shells Fins
 PK_SHELL_find_sign  PK_FIN_ask_type
 PK_SHELL_ask_type Vertices
Bodies  PK_VERTEX_ask_type
 PK_BODY_ask_type
Edges
 PK_EDGE_ask_type
▪ Returns information about
vertex, enclosure and fins
Parameter space to 3D vector
 PK_CURVE_eval, PK_SURF_eval
▪ Supply curve\surface parameter(s), returns point and
derivatives
 PK_CURVE_eval_with_tangent
 PK_SURF_eval_with_normal
▪ Additionally return curve tangent/surface normal
 PK_CURVE_eval_handed,
PK_CURVE_eval_with_tan_handed..etc…
▪ Additionally takes ‘hand’ direction
3D vector to parameter space
 PK_CURVE_parameterise_vector,
PK_SURF_parameterise_vector
Parameterisation
 PK_CURVE_ask_interval, PK_SURF_ask_params
Curvature
 Curves
▪ PK_CURVE_eval_curvature
▪ Supply curve and curve parameter
▪ Returns
▪ tangent direction, normal direction, binormal direction
▪ curvature
 Surfaces
▪ PK_SURF_eval_curvature
▪ Supply surface and surface parameters
▪ Returns
▪ surface normal, principal directions
▪ principal curvatures
Containment
 PK_CURVE_find_non_aligned_box,
PK_SURF_find_non_aligned_box
▪ Returns non-axis aligned boxes in the form:
▪ Box centre
▪ Box axis
▪ Box width in each axis direction
▪ Box dimension Equivalence
Equivalence
 PK_GEOM_is_coincident
▪ Not guaranteed to detect equivalence, does not
incorrectly claim equivalence
Discrete representation of a
curve
 PK_CURVE_output_vectors Angular Tolerance
▪ Enable discrete
representation of curve
▪ Outputs coordinates and
optionally parameterisation
of points on curve Chordal Tolerance
▪ Accuracy of sample points
can be controlled using curve
tolerances
Step Length Tolerance
Topology Containment
 PK_TOPOL_find_box
▪ Used on assemblies, bodies, faces,
edges
▪ Box limits defined by two position
vectors
▪ Box is aligned with the axes
▪ Box is guaranteed to contain the entity
Point Containment
 PK_BODY_contains_vector/ Inside
PK_FACE_contains_vectors
▪ Determines whether the point lies
▪ Inside/outside/on entity boundary
▪ Point may be vector or parameters
▪ Loops may be specified for faces
▪ Topology is returned
Outside
Closest Approach
Received
 PK_TOPOL_range***, PK_GEOM_range*** position
▪ Finds the closest distance between two entities
▪ Can optionally supply
▪ Upper and lower bound, estimate Global Minimum
▪ Returns
▪ Entity and position vector on the entity
▪ Single (global) or all local solutions
▪ Minimum distance(s)
Tolerant Coincidence Received surface

 PK_FACE_is_coincident
▪ Receives two faces and tolerance
▪ Returns details on the coincidence, a point where
the faces are not coincident
 Clash Detection
 PK_TOPOL_clash - Clash topologies
▪ Detects every clash between target and tool lists
▪ Entities can be clashed with their owning bodies
▪ Can find only first or all clashes
▪ The clash can be further classified into :
▪ Containment, contact, interference
 Intersections
 Can calculate intersections between pairs of
▪ Curves, surfaces, faces or any combination
▪ Of the form PK_XXX_intersect_xxx
 Functions can be optimised with options for:
▪ Parametric Box, 3D box, Common surface (curves
only)
Mass Properties - PK_TOPOL_eval_mass_props

Edge Length
Face Perimeter, Area, CofG
Wire Body Length, Mass
Sheet Body Circumference, Surface area, Mass, CofG
Solid Body Surface Area, Mass, CofG, Moments of
Assembly Inertia
 General
▪ In general, operations on valid models either produce a valid
model or return a sensible failure code
▪ A part can become invalid:
▪ As a result of a local operation when local checking has been turned off
▪ As a direct result of the inputs to the calling operation
▪ At an intermediate stage of a two step process
▪ After importing data
 PK_BODY_check - sequentially checks a body for:
▪ Corrupt data-structure, invalid geometry, consistency between
topology and geometry, invalid topology
 Other functions:
▪ PK_FACE_check, PK_EDGE_check, PK_GEOM_check,
PK_TRANSF_check
 Topological
▪ Code example “Model Structure”
 Geometric
▪ Code example “Evaluation”
 Model analysis
▪ Code examples:
▪ “Clashing”
▪ “Mass Props”
▪ “Picking”
▪ “Validity”
 Class structure
 Data connections
 Data relationships
 Topological
 Geometric
 Model analysis
▪ Validity
 Further Information
 Calling Parasolid
 Model Representation
 Geometry
 Inquiries

You might also like