9.7 Integrating Visualize with Parasolid and HOOPS Exchange
Exchange-Parasolid Sprocket
9.7.1 Prerequisites9.7.2 File Loading
9.7.3 Importing Multiple Models
9.7.4 Accessing Parasolid and Exchange Data
9.7.5 Updating the Model After Parasolid Modeling Operations
9.7.6 Creating Geometry in Memory Using Parasolid and Adding it to the Scene
9.7.7 Limitations
9.7.8 Miscellaneous
9.7.9 Table: Synchronizing Visualize and the Native Parasolid API
9.7.10 Boolean Operations
Designed to facilitate CAD conversion and geometric modeling in a single interface, the Exchange-Parasolid Sprocket is useful for developers who wish to load files using HOOPS Exchange and then interact with the geometry in the scene using the Parasolid modeling kernel.
The Exchange-Parasolid Sprocket is available on Windows, Linux, and MacOS platforms, and you must have a license for both Exchange and Parasolid in order to use the sprocket.
Visualize, Exchange, and Parasolid interact with each other in the following manner:
- Visualize displays the model on screen, builds a Component structure, provides the user access to Parasolid and Exchange data, and keeps the Parasolid data, Exchange data, Component structure, and visual rendition synchronized.
- Exchange loads and translates the model and manages Views, PMI, and the assembly structure.
- Parasolid tessellates the model and performs modeling operations.
Throughout this guide, we sometimes refer to "PRC" – this refers to the intermediate CAD data format used by Exchange during file conversion. In Visualize, PRC also forms the basis of the Component structure used in the Exchange-Parasolid Sprocket. For more information on PRC, see the HOOPS Exchange documentation or the PRC specification itself.
9.7.1 Prerequisites
To satisfy the prerequisites, users should complete the prerequisite steps for both the Exchange and the Parasolid sprockets, which are found in section 9.5 and section 9.6 of the Programming Guide.
9.7.2 File Loading and Translation
When using the Exchange-Parasolid Sprocket, the contents of each Exchange Representation Item is translated to Parasolid. The translation process takes place automatically as part of the import and is configurable by the user. Since the geometry being inserted into the scene will be tessellated by Parasolid, Parasolid tessellation settings also need to be provided.
Since Visualize's Parasolid integration supports convergent modeling, even files without B-rep can be loaded and translated to Parasolid, if the format is supported by Exchange.
Here's a basic example of loading and translating a file with default options:
The usual caveats described in the other Sprocket guides still apply here:
- The user can call HPS::IONotifier::Wait() on the notifier to wait until after the import has completed. The import happens on a separate thread, and it is not guaranteed to be completed until after HPS::IONotifier::Wait() returns or until the HPS::IONotifier::Status() call returns something other than HPS::Event::Status::InProgress.
- The import can be canceled by calling HPS::IONotifier::Cancel() on the notifier.
- The import status can be queried while the import is in progress.
Options for File Loading
The Options for File Loading section in the Exchange Sprocket programming guide applies to the Exchange-Parasolid Sprocket, too. As the sample above shows there are several options kit which need to be passed to the HPS::ExchangeParasolid::File::Import() function call:
- An HPS::Exchange::ImportOptionsKit. This kit determines how the file is read by Exchange. The options specified in the Exchange Sprocket sections still apply (for example, calling SetPMI(false) on this kit will result in PMIs not being imported).
- An HPS::Exchange::TranslationOptionsKit. This kit determines how the file is translated into Parasolid, and optionally performs some functions such as sewing and healing. It's worth noting that one of the options allows users to use multiple processes to translate the data, speeding up the process. See the function HPS::Exchange::TranslationOptionsKit::SetMultiProcessCount for more information.
-
A HPS::Parasolid::FacetTessellationKit and a HPS::Parasolid::LineTessellationKit. These kits determine how Parasolid will tessellate facets and lines respectively. The description of these kits is the same as the one found in the Import Options section of the Parasolid programming guide. It is worth noting that if you don't need to fine tune all the tessellation options, you can just call the HPS::Parasolid::FacetTessellationKit::SetTessellationLevel() function from the HPS::Parasolid::FacetTessellationKit, and use the default HPS::Parasolid::LineTessellationKit. This way the two are guaranteed to be compatible.
(When these kits are not compatible, it can result in lines that do not exactly lie on faces or lines that are tessellated more coarsely than the faces they belong to.)
9.7.3 Importing Multiple Models
Multiple models can be imported into the same scene using the same functionality described in Importing multiple models in the Exchange Programming Guide.
Note: When importing multiple models, the Parasolid entities from all models in the same scene are placed in the same Parasolid partition.
Component Structure of Exchange-Parasolid Files
- The top of the component structure for Exchange-Parasolid files will be an HPS::Exchange::CADModel.
- From there the component structure will continue as expected for an Exchange file: the CADModel will contain Product Occurrence components, which will in turn contain either other Product Occurrence components or a Part Definition component. Part Definition components will contain Representation Item components.
- When importing a model through Exchange-Parasolid, components under the Representation Item level will all be Parasolid components. For example, Representation Item components will contain Parasolid Topological Body components.
- The component structure will still contain Views and Filters if the original CAD file contained them.
Sample Component Structure of an Exchange-Parasolid File
The following graphic demonstrates a hypothetical Component structure for an Exchange-Parasolid file:

The most important aspect of this structure is that the Exchange representation item will always contain a single Parasolid topological body (and not a Parasolid assembly or other data). In the next section, we'll look at a sample that shows how to use the function HPS::Component::GetSubcomponents() to retrieve these elements.
9.7.4 Accessing Parasolid and Exchange Data
By using the the Visualize Component structure, it's possible to gain access to Exchange or Parasolid entities directly. You can then operate on these entities using the native Exchange and Parasolid APIs.
The first step in this process is to find the component we are interested in. Each component can query its parent and children component through its HPS::Component::GetOwners() and HPS::Component::GetSubcomponents() functions. It can also query all its descendants of a particular type by calling HPS::Component::GetAllSubcomponents().
The type of a component can be found using the HPS::Component::GetComponentType() function, and the result can be checked against the HPS::Component::ComponentType enumeration. The HPS::Component class also contains the HPS::Component::HasComponentType() function, which allows us to check against a bitmask. For example, the function can be used to determine whether a component is an Exchange or a Parasolid component, or whether the component represents any of the topological items supported by Exchange or Parasolid.
Once an interesting component has been located, we can access its underlying data. For Exchange components, we create an HPS::Exchange::Component from the Component object, and call HPS::Exchange::Component::GetExchangeEntity(). For Parasolid components, we create an HPS::Parasolid::Component from the component object, and call HPS::Parasolid::Component::GetParasolidEntity().
9.7.5 Updating the Model After Parasolid Modeling Operations
After a modelling operation takes place in Parasolid, Visualize will have to be notified about which Parasolid bodies have changed, so that they can be retessellated and have their component structure updated to reflect their new status.
This can be done through the HPS::ExchangeParasolid::File::Tessellate() function or the HPS::Parasolid::Component::Tessellate() function.
Note: Currently the HPS::Parasolid::Component::Tessellate() and HPS::ExchangeParasolid::File::Tessellate() functions update Visualize to reflect the changes made in Parasolid. This function does NOT however update the PRC representation of the model held by Exchange. Therefore, after calling either of these Tessellate functions, in order to export an accurate representation of the model, use the Parasolid API (e.g., PK_PART_transmit) and reload the model into Visualize from disk.
The following code sample demonstrates how to add a fillet to an edge of a model and retessellate it using the native Parasolid API:
Here is the output when applying this code to a simple cube; the edge on the left is where the fillet has been applied:

9.7.6 Creating Geometry in Memory Using Parasolid and Adding it to the Scene
Note: This is the Exchange-Parasolid equivalent of the Entity Creation section of the Parasolid programming guide.
Sometimes you may want to create a model from scratch instead of loading one, or other times you may want to create some geometry from scratch and then add it to an existing model you've already loaded. In either case, you'll need a way to take what you've created in memory using Parasolid and add it to the scene.
The HPS::ExchangeParasolid::File::AddEntity() function allows you to not only update the Visualize component structure but also to create new PRC data to update the Exchange structure. (Please see the API Reference for details about the limitations of the HPS::ExchangeParasolid::File::AddEntity() function.)
Below is a sample of how to add a new Parasolid body to the model PartWithPMI.CATPart, located in the samples/data directory. Here's the model before adding the new body:

This code snippet demonstrates loading a model via Exchange, creating a Parasolid body in memory (a red cube), and using the HPS::ExchangeParasolid::File::AddEntity() function to add the Parasolid body to the Exchange CAD model:
And here's the final output, with the red cube inserted into the CAD model:

9.7.7 Limitations
- When importing files that do not contain B-rep information, colors will not be imported.
- Currently the HPS::Parasolid::Component::Tessellate() and HPS::ExchangeParasolid::File::Tessellate() functions update Visualize to reflect the changes made in Parasolid. This function does NOT however update the PRC representation of the model held by Exchange. Therefore, after calling either of these Tessellate functions, in order to export an accurate representation of the model, use the Parasolid API (e.g., PK_PART_transmit) and reload the model into Visualize from disk.
9.7.8 Miscellaneous
- The HOOPS Parasolid Demo Viewer uses Exchange-Parasolid and can be used to sample basic modeling operations.
9.7.9 Synchronizing Visualize and the Native Parasolid API
This chart shows which Visualize functions must be called after a specific native Parasolid operation:
Native Parasolid Operation | Related Visualize Call | Updates PRC? |
---|---|---|
Adds new Body to the Parasolid partition | HPS::ExchangeParasolid::File::AddEntity() | YES |
Modifies existing Body | HPS::ExchangeParasolid::File::Tessellate() | NO |
Deletes Body | HPS::Component::Delete() | YES |