The collection of PMI classes provided by HOOPS is meant to simplify managing PMI or GD&T data in a HOOPS scene graph. Classes are provided for inserting, modifying and querying datums, dimensions, feature control frames, notes and roughness features. There is also a facility for dealing with generic PMI, meant to allow managing GD&T which doesn't conform to the any of the other types provided. Additionally the PMI classes provide a means of creating views associated with PMI entities created via the classes.
The PMI classes for the various entity types all work in fundamentally the same way. As a canonical example, we will demonstrate using the classes to create a datum identifier. All PMI entities require a segment key which will be used to hold the associated geometry and metadata associated with that entity. The default constructors all use an INVALID_KEY as the segment key, and if an actual key is not provided during construction then the classes will ignore any values set on them, since there is no place to store the data. When constructed with a valid segment key, the DatumEntity (or any other PMI entity) will create some or all of the following segment structure, depending on what values the user decides to set:
Once constructed, the user can proceed to call the appropriate functions to set up the DatumEntity for their dataset. To make this instance a datum identifier, they would need to call the SetDatumType function, construct a Frame and pass it to SetFrame, create a Polyline array and pass it to SetLeaderLines and create a String array and pass it to SetLabels. For example, this could be done like this:
The above code will create a datum identifier that looks like this:
A majority of the other PMI entity classes (i.e., DimensionEntity, GenericEntity, NoteEntity and RoughnessEntity) work in an analogous manner to the DatumEntity example above. The primary manner in which they differ is in allowing the user to set and get metadata specific to their particular entity type.
The FeatureControlFrameEntity works in basically the same way as the other entity classes, however due to the well-defined nature of feature control frame specification, the functions for creating a FCF are slightly different.
For example, a feature control frame could be create like this:
The above code will create a feature control frame which looks like this:
This example demonstrates using all of the various components of the FeatureControlFrameEntity class, however the user can elect to only set those portions of the feature control frame which are needed for their application.
For example, if you wanted to create a view associated with the DatumEntity and FeatureControlFrameEntity created in the previous sections, you could do something like this:
The above code will create a view that looks like this:
Since the PMI classes store all geometry and metadata in the HOOPS scene graph, if you want to re-create an entity instance from an existing segment (for instance, after the original instance fell out of scope, or on importing a scene graph which contains PMI entities), you need to look for the presence of a user option in the segment originally passed in when creating a piece of PMI. Using this, you can determine the type of PMI entity originally created and create an appropriate object which will then allow you to set or get the relevant data for that piece of PMI.
For example, the logic for making this determination might look like this:
In the event you want to delete portions of an existing PMI entity, this is done by setting those components with the appropriate unknown or empty values.
For example, if we wanted to unset the tolerance type, projected magnitude and datum references for the feature control frame created earlier, we would do this:
The above code would result in a feature control frame which looks like this:
In the event you want to delete the entire piece of PMI, in addition to deleting the entity instance (or having it fall out of scope) you should delete the segment used to create the entity. Once this segment is deleted, any entity which references that segment key will no longer function, and result in errors getting generated by HOOPS if you do try to set any values on it. If you don't delete the segment, even if the instance gets destructed, the geometry will remain in the scene graph.