<<< Application Design | Chapters | The Example Application >>> |
As described in Chapter 2, "Application Design", you need to supply frustrum code to Parasolid in order to perform the following tasks:
This section gives you an overview of what you need to supply in order to accomplish these tasks.
This section outlines the frustrum functions that you need to supply in order to build a working frustrum. Some functions are optional; what you need to supply depends on the requred functionality of your application.
The use of the frustrum functions is explained in more detail in Section 3.4, "File handling", Section 3.5, "Memory management", and Section 3.6, "Graphical output" later on in this chapter.
You must provide the following frustrum functions:
File (part data) handling (see Section 3.4, "File handling") |
|
---|---|
Memory handling (see Section 3.5, "Memory management") |
|
---|---|
You can choose whether to implement the following frustrum functions. If you do not, they should be left as NULL. When you initialize the frustrum, all available functions are set to NULL, so you can effectively ignore any functions listed here that you don't require.
returns sample name keys (used for testing FFOPRD and FFOPWR) |
Graphical output (see Section 3.6, "Graphical output") |
|
---|---|
Before you can start the modeler and make PK calls, you need to register the frustrum functions with Parasolid. To do this, use the PK function PK_SESSION_register_frustrum, which takes a list of pointers to the frustrum functions you have supplied.
You declare and initialize the frustrum in the same way that you set up any option structure in the PK. The following code extract shows how this might be done. For more details, refer to Appendix B, "Using the PK Interface".
PK_SESSION_frustrum_t fru; /* Declare fru as the frustrum */ PK_SESSION_frustrum_o_m( fru ); /* Initialize the frustrum functions */ /* Point to each of the frustrum functions you are supplying */ fru.fstart = MyAppStartFrustrum; fru.fabort = MyAppAbortFrustrum; fru.goopsg = MyAppOpenSeg; /* Note: Many functions missing from the list above */ /* Register the frustrum with Parasolid */ PK_SESSION_register_frustrum( &fru ); |
In the code above, note that MyAppStartFrustrum represents a function that you have actually supplied a definition for, and fstart represents a field required by PK_SESSION_register_frustrum.
A specific example showing how the frustrum is registered in the Parasolid Example Application is described in Section 4.3, "The frustrum".
The files that Parasolid uses for storing part data are referred to as 'transmit' or 'XT' files. In order to transfer data through the frustrum, you need to write to and read from these files. Parasolid can also use several other file types, as described in Section 3.4.2, "File types and file extensions". You need to decide the format and location of these files in order to write your frustrum functions.
You can configure Parasolid to handle many different kinds of archiving systems, such as:
Your application should provide the following functionality for managing the files generated and required by Parasolid.
The frustrum is passed a key (a text string) that identifies the part. This key can be used as a filename or as an index into the database, depending on the archiving system you have chosen.
Parasolid uses several file types, each of which can be written in one of the following formats:
At a minimum, your application must support Transmit files. Depending on its functionality, it may also need to deal with some of the other file types described here.
Each file type has a recommended file extension that is also dependent on the file system you are writing to or reading from, as shown in the table below. Note that file extensions ending in
_t
or
_txt
denote text-based formats, and extensions ending in
_b
or
_bin
denote binary-based formats.
.xmt_txt .xmt_bin |
.x_t .x_b |
Transmit (or XT) files are used to store part or assembly data and are often used for transferring data between Parasolid-powered systems. |
|
.sch_txt .sch_bin |
.s_t .s_b |
Parasolid uses schema files to read and write data from and to previous versions of Parasolid. |
|
.jnl_txt .jnl_bin |
.j_t .j_b |
Journal files are used to keep a record of all of the commands issued to Parasolid within a session. Journal files can be used for debugging. |
|
.snp_txt .snp_bin |
.n_t .n_b |
A snapshot file is a memory dump of a Parasolid session. These files are very rarely used, but are sometimes useful for reproducing faults. |
|
.xmp_txt .xmp_bin |
.p_t .p_b |
Partitions enable related parts to be archived as a single item. Rollback information allows your application to return a Parasolid session to an earlier state. If your application uses either of these mechanisms, the relevant data is written to a partition file. See Chapter A, "Further Implementation Decisions" for more information. |
|
.xmd_txt .xmd_bin |
.d_t .d_b |
Delta files are used within the rollback mechanism and are controlled by a separate suite of functions called the delta frustrum. Delta transmit files are an aggregate of all existing delta files, and their creation is controlled by the frustrum. See Chapter A, "Further Implementation Decisions" for more information. |
The file handling functions in your frustrum must handle all the file types that you decide to support, adding the appropriate extensions. These functions may also test whether a file resides on a DOS style FAT device or a long filename NTFS type device before adding the extension, unless you decide to support only the FAT extensions, regardless of the filesystem. If you support both FAT and NTFS extensions, files can simply be renamed when transferring between the different systems. An example that shows how extensions can be added to filenames is described in Section 4.4.2, "File extensions" in Chapter 4, "The Example Application".
Section 4.4, "File handling" gives details about how to implement file handling in the frustrum.
You need to supply two memory management functions in the frustrum that allow Parasolid to allocate and free memory for its use. These functions control the way that memory is allocated to and freed for use in:
The memory management functions are FMALLO (allocate virtual memory) and FMFREE (free virtual memory).These functions map closely to the C functions malloc and free, and any function definitions you supply should be type-compatible with malloc and free.
You could consider implementing some buffering in order to improve performance compared to the standard functions. For example, with suitable definitions for FMALLO and FMFREE:
The memory management functions are registered when registering the frustrum.
A specific example showing how memory management functions are used in the Parasolid Example Application is described in Section 4.5, "Memory management".
If your application needs to display parts - whether by rendering them on screen, or printing them to a plotter or laser printer - you need to do three things:
When a call is made to one of the PK rendering functions, the graphical data output by Parasolid is passed to the GO functions, which catch and interpret the data, filter it, and use the functionality of the graphics library to render the parts on the appropriate device.
In order to render part data, your application needs to call a PK rendering function. There are three such functions available:
Renders a geometric entity as a wire frame drawing that is independent of the view required. |
|
Each of these functions uses the supplied GO functions to pass graphical data to the appropriate graphics library.
The PK outputs graphical information in the form of segments. These correspond to identifiable portions of the model being rendered, and can be curves or facets (depending on the PK function used). There are two types of segments:
Note: It is possible to generate faceted information without using the GO, by using the function PK_TOPOL_facet. This approach may be useful, for instance, if your application needs to perform many calculations on a faceted representation of the model. |
Parasolid passes segment data to the GO functions. These functions use the supplied graphics libraries and may generate, for example, screen pictures, plot files and laser print files.
There are three GO functions in the frustrum. They all take the same arguments, but interpret them in different ways.
GO functions are registered together with the other frustrum functions. See the Section 3.3, "Registering the frustrum" for details.
A specific example showing how GO functions are defined in the Parasolid Example Application is described in Section 4.6, "Graphics".
Parasolid's graphical data output can be used in conjunction with many different graphical libraries. You must supply a graphics library for every device you want to use for rendering output. If your application renders to several different devices (for instance, it might render to the screen, and print paper copy), then you may need to supply several different libraries. You can write your own graphics libraries if you wish, or you can use third party libraries. The GOSGMT function calls the appropriate libraries in order to perform the necessary rendering.
Parasolid can raise errors in a number of circumstances. For example, if your application passes incorrect data to a PK function, or a PK function fails in some way, then Parasolid raises an error. Your application needs to be able to handle these sorts of errors. This section describes how you go about doing this.
There are two approaches to handling errors from Parasolid.
The strategy you choose probably depends on how errors are handled by the rest of your application. You are strongly recommended not to mix the two strategies, if this is possible.
Whichever strategy you choose, the same action needs to be taken. This action depends on the severity of the error, as supplied in the error call. See Section 3.7.3, "What to do when an error occurs" for more details.
You use PK_ERROR_register_callbacks to register an error handler with Parasolid. When a PK function is about to return an error, the error handler is passed a standard structure (PK_ERROR_sf_t) containing:
This data is always stored, and can be retrieved again if necessary using PK_ERROR_ask_last. The data for the last error can be cleared using PK_ERROR_clear_last.
You can see how an error handler is registered in the Parasolid Example Application in Section 4.7, "Error handling" in Chapter 4, "The Example Application".
Every PK function returns an error code that indicates the result of the operation. If this value is zero - PK_ERROR_no_errors - the operation has completed successfully and your application can proceed.
However, if this value is non-zero, then the operation has failed to complete. Each numerical value indicates a predictable error, and your application must handle it appropriately:
Whether you register an error handler or decide to handle each error explicitly in your application code, the action that needs to be taken when an error occurs is much the same.
The three error severity levels that your application has to manage are:
You use the function PK_SESSION_start to start the Parasolid modeler. This takes an options structure that you can use to specify session specific options, as described in Section A.4, "Session parameters".
You use the function PK_SESSION_stop to stop the Parasolid modeler.
Warning: You
must register the frustrum before attempting to start a Parasolid session. |
<<< Application Design | Chapters | The Example Application >>> |