Component
-
class HPS::Component : public HPS::Sprocket
The Component class is a smart pointer. It represents an arbitrary component of a structured file.
Subclassed by HPS::CADModel, HPS::Capture, HPS::DWG::Component, HPS::Exchange::Component, HPS::Filter, HPS::Parasolid::Component
Public Types
-
enum ComponentType
Enumerates the format-dependent types a Component can represent.
Values:
-
enumerator None
-
enumerator GenericMask
-
enumerator ExchangeModelFile
Represents an A3DAsmModelFile in Exchange. This will be represented by an Exchange::CADModel.
-
enumerator ExchangeProductOccurrence
Represents an A3DAsmProductOccurrence in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePartDefinition
Represents an A3DAsmPartDefinition in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeView
Represents an A3DMkpView in Exchange. This will be represented by an Exchange::Capture component.
-
enumerator ExchangeFilter
Represents an A3DMkpFilter in Exchange. This will be represented by an Exchange::Filter component.
-
enumerator ExchangeRIBRepModel
Represents an A3DRiBrepModel in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRICurve
Represents an A3DRiCurve in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRIDirection
Represents an A3DRiDirection in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRIPlane
Represents an A3DRiPlane in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRIPointSet
Represents an A3DRiPointSet in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRIPolyBRepModel
Represents an A3DRiPolyBrepModel in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRIPolyWire
Represents an A3DRiPolyWire in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRISet
Represents an A3DRiSet in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeRICoordinateSystem
Represents an A3DRiCoordinateSystem in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoBody
Represents an A3DTopoBody in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoConnex
Represents an A3DTopoConnex in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoShell
Represents an A3DTopoShell in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoFace
Represents an A3DTopoFace in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoLoop
Represents an A3DTopoLoop in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoCoEdge
Represents an A3DTopoCoEdge in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoEdge
Represents an A3DTopoEdge in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoVertex
Represents an A3DTopoVertex in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoSingleWireBody
Represents an A3DTopoSingleWireBody in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeTopoWireEdge
Represents an A3DTopoWireEdge in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangeDrawingModel
Represents an A3DDrawingModel in Exchange. This is the starting point of a drawing. It is found under a product occurrence. Generally there is only one Drawing Model per file, but it is possible to have more than one. This will be represented by an Exchange::Component.
-
enumerator ExchangeDrawingView
Represents an A3DDrawingView in Exchange. A Drawing Sheet can contain views. Views are basically snapshot of the model from a particular angle. Each view has a name and a type, for example, front view, side view, section, etc. This will be represented by an Exchange::Component.
-
enumerator ExchangeDrawingSheet
Represents an A3DDrawingSheet in Exchange. A DrawingModel contains one or more sheets. Each sheet represents a physical sheet of paper. Generally a sheet defines the frame of the drawing, contains the name of the paper format it reproduces, and contains a transform. One of the sheets is classified as the “active sheet” by the model, and this one will be what you see when you first load a drawing. There can only be one active sheet at the time, with all the inactive ones being hidden. Drawing sheets have metadata associated with them called ‘IsDefaultSheet’. This is a BooleanMetadata. It will return true if the sheet is the active sheet, and false otherwise. This will be represented by an Exchange::Component.
-
enumerator ExchangeBasicDrawingBlock
Represents an A3DDrawingBlockBasic in Exchange. Sheets and views contain blocks. Blocks can be of two types: basic or operator blocks. Operator blocks are blocks which reference a particular view. These two types are internally treated as the same thing. Blocks contain the actual representation items which will be tessellated and drawn on the screen. This will be represented by an Exchange::Component.
-
enumerator ExchangeOperatorDrawingBlock
Represents an A3DDrawingBlockOperator in Exchange. Sheets and views contain blocks. Blocks can be of two types: basic or operator blocks. Operator blocks are blocks which reference a particular view. These two types are internally treated as the same thing. Blocks contain the actual representation items which will be tessellated and drawn on the screen. This will be represented by an Exchange::Component.
-
enumerator ExchangePMI
Represents a generic A3DMkpMarkup in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIText
Represents an A3DMarkupText in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIRichText
Represents an A3DMarkupRichText in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIRoughness
Represents an A3DMarkupRoughness in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIGDT
Represents an A3DMarkupGDT in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIDatum
Represents an A3DMarkupDatum in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMILineWelding
Represents an A3DMarkupLineWelding in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMISpotWelding
Represents an A3DMarkupSpotWelding in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIDimension
Represents an A3DMarkupDimension in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIBalloon
Represents an A3DMarkupBalloon in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMICoordinate
Represents an A3DMarkupCoordinate in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIFastener
Represents an A3DMarkupFastener in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMILocator
Represents an A3DMarkupLocator in Exchange. This will be represented by an Exchange::Component.
-
enumerator ExchangePMIMeasurementPoint
Represents an A3DMarkupMeasurementPoint in Exchange. This will be represented by an Exchange::Component.
-
enumerator ParasolidModelFile
Abstract component representing the root of a Parasolid file. Does not map to any Parasolid element.
-
enumerator ParasolidAssembly
Represents a PK_ASSEMBLY in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidInstance
Represents a PK_INSTANCE in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoBody
Represents a PK_BODY in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoRegion
Represents a PK_REGION in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoShell
Represents a PK_SHELL in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoFace
Represents a PK_FACE in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoLoop
Represents a PK_LOOP in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoFin
Represents a PK_FIN in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoEdge
Represents a PK_EDGE in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator ParasolidTopoVertex
Represents a PK_VERTEX in Parasolid. This will be represented by a Parasolid::Component.
-
enumerator DWGModelFile
Represents an AcDbDatabase in RealDWG. This will be represented by a DWG::CADModel.
-
enumerator DWGLayout
Represents an AcDbLayout in RealDWG.
-
enumerator DWGBlockTable
Represents an AcDbBlockTable in RealDWG.
-
enumerator DWGBlockTableRecord
Represents an AcDbBlockTableRecord in RealDWG.
-
enumerator DWGEntity
Represents an AcDbEntity in RealDWG.
-
enumerator DWGLayerTable
Represents an AcDbLayerTable in RealDWG.
-
enumerator DWGLayer
Represents an AcDbLayer in RealDWG.
-
enumerator UserComponent
Represents a user created component.
-
enumerator None
-
enum DeleteMode
Enumerates whether the delete operation will use the mode Standard, Full or StandardAndExchange.
Values:
-
enumerator Standard
Subcomponents will be deleted if they don’t have multiple owners, otherwise their reference count will be decremented
-
enumerator Full
Subcomponents will always be deleted, even if they are shared.
-
enumerator Standard
Public Functions
-
void AddKey(Key const &in_key)
Adds a key to be associated with this Component. This will additionally ensure this key can be used to find this Component via CADModel::GetComponentFromKey on the owning CADModel. In general, this will either be a SegmentKey or a GeometryKey (or a subclass thereof), but it may also be an IncludeKey, which is necessary for an instanced Component. If an IncludeKey is associated with this Component, the underlying target of the include will be associated with this Component, though the include will be stored as well to determine things like the associated KeyPath correctly.
- Parameters
in_key – The key to associate with this Component.
-
void AddOwner(Component &in_owner, IncludeKey const &in_include = IncludeKey())
Adds an owner to this Component. This is intended to facilitate adding additional owners to an instanced Component, and allows specifying the associated IncludeKey for the additional owner. It is possible to add an owner without adding an IncludeKey, and, if desired, add the IncludeKey separately via AddKey.
- Parameters
in_owner – The Component to act as an additional owner for this Component.
in_include – The IncludeKey for this Component for this new owner. This defaults to an uninitialized IncludeKey.
-
bool AddTransform(MatrixKit const &in_transform)
Appends a transform to the underlying PRC or Parasolid data associated with this component.
Warning
For Parasolid components, only transformations which are rigid motions can be applied. Calling SetTransform from a Parasolid component with a transform which is not a rigid motion, such as a shear, will cause the function to fail.
Warning
For Exchange components, only components of type ExchangeProductOccurrence, or components that have the type ExchangeRepresentationItemMask can have transforms applied to them. Additionally, SetTransform does not work on Exchange models which have a Drawing structure to them. This would include CATDrawing files and 2D DWG files loaded through Exchange. Any attempt to use this function on those models will produce a warning.
- Parameters
in_transform – The transform to apply to this component.
- Returns
true if transform was applied correctly, false otherwise.
-
virtual void Assign(Component const &in_that)
Share the underlying smart-pointer of the Component source.
-
Component()
The default constructor creates an uninitialized Component object. The Type() function will return Type::None.
-
Component(Component &&in_that)
The move constructor creates a Component by transferring the underlying object of the rvalue reference to this Component.
- Parameters
in_that – An rvalue reference to a Component to take the underlying object from.
-
Component(Component const &in_that)
The copy constructor creates a Component object that shares the underlying smart-pointer of the source Component.
- Parameters
in_that – The source Component to copy.
-
Component CopyTo(HPS::Component const &in_new_owner)
Creates a deep copy of this component under another component. Please note how entity copying is handled for each type of entity:
Copying a RepresentationItem to a ProductOccurrence: The copy of the representation item will be inserted under the Part Definition under the target Product Occurrence
Copying a RepresentationItem to a PartDefinition: supported
Copying a RepresentationItem to a RepresentationItemSet: supported
Copying a PartDefinition to a ProductOccurrence: The function will create a new ProductOccurrence object, insert the copy into the children of this product occurrence and then insert this product occurrence under the target product occurrence. This is to avoid rewrite on the original PartDefinition of the target ProductOccurrence (if one exists)
Copying a ProductOccurrence to a ProductOccurrence: The newly created copy will be inserted under the target Product Occurrence. However we need to note that if the target ProductOccurrence already has a prototype, the prototype will not be visualized by HPS but only the newly created copy will be. In the case of ExternalData, both will be rendered by HPS.
Copying a ProductOccurrence to a Exchange ModelFile: The A3DAsmModelFile under the target component will be deleted, and a new one will be created. This new model is identical with the old model except that the copy of the source ProductOccurrence will be inserted under this new model. In this case, since we create a new CADModel, the reload process may take more time since we need to re-render the whole new model.
In any case, if the function fails, it will return an empty Component, so checking if the type of the returned component is None or not can be considered a way to test if the function succeeded or failed.
Additional notes about the deep copy process: The deep copy process for ProductOccurrence and RepresentationItem uses two functions of Exchange: A3DAsmProductOccurrenceDeepCopy and A3DRiRepresentationItemDeepCopy. These functions can make changes to the structure of the entity, so we may not have a copy that is an exact replica of the source entity. More on this can be found here: https://docs.techsoft3d.com/exchange/latest/api/group__a3d__productoccurrence.html#_CPPv431A3DAsmProductOccurrenceDeepCopyPK23A3DAsmProductOccurrencePP23A3DAsmProductOccurrence and https://docs.techsoft3d.com/exchange/latest/api/group__a3d__ricontent.html#_CPPv431A3DRiRepresentationItemDeepCopyPK23A3DRiRepresentationItemPP23A3DRiRepresentationItem
For PartDefinition and RepresentationItemSet, which lack a deep copy function in Exchange, the PartDefinition is only shallow copied, so its children pointers are shared between the source and the target. The deep copy process copies all the attributes of the source entity, thus, if the modelling matrix of the source entity if relative to its parents, the location of the copied entity will also be relative to its new parents.
\param in_new_owner The component which will be the owner of the newly created component. \return The newly created component. \note This will currently only work for derived Exchange components.
-
void Delete(HPS::Component::DeleteMode mode = HPS::Component::DeleteMode::Standard)
The behavior of the Delete function varies according to the type of object it’s being called on.
HPS:
Removes this component from memory and invalidates any component objects referring to it. All owners of this component will no longer have it as a subcomponent, all components that reference this component will no longer have it as a reference, and the keys underlying this component will be deleted. Any subcomponents of this component that have multiple owners will have this component removed as an owner. Any subcomponents of this component that have only this component as an owner will be recursively deleted via this function.
Invoking this function on an instance of an object derived from Component will perform some additional cleanup relevant to the derived type. For example, performing a delete on a CADModel will delete the default capture associated with the CADModel, delete its associated Model, and delete the mapping information between keys and components, in addition to performing all the operations for a generic component. See below for the behavior of derived types in the integrations that create component trees.
Lastly, note that it is not necessary to construct or cast a component to its specific type to ensure the appropriate delete logic is used. The appropriate logic will always be invoked even if using a base Component object handle to a derived type.
Invoking delete on these types will not modify the associated Exchange data. It will remove the associated A3DEntity pointer and component from the mapping data accessible via Exchange::CADModel::GetComponentFromEntity, and then it will invoke the base Component delete logic. When invoking Delete on the last root HPS::Exchange::Component, the whole subtree is deleted, but a new root HPS::Exchange::Component will be associated to the CADModel in order to be consistent with HOOPS Exchange behavior. In this case, it has an empty product occurrence data structure with no child at the HPS::Exchange::Component level.
Invoking delete on an Exchange::CADModel will delete the underlying A3DAsmModelFile via A3DAsmModelFileDelete if Exchange::CADModel::GetEntityOwnership is true. It will additionally clean up the associated A3DRWParamsPrcReadHelper if one was created during import (see Exchange::ImportOptionsKit::SetPRCReadHelper). The mapping data between A3DEntity pointers and components will also be deleted, and lastly it will invoke the delete logic for the base CADModel.
Invoking delete on this type will invoke PK_ENTITY_delete on the underlying Parasolid entity if the entity has class PK_CLASS_assembly or PK_CLASS_body. It will remove this Parasolid entity and component from the mapping data accessible via Parasolid::CADModel::GetComponentFromEntity, and then it will invoke the base Component delete logic.
The mapping data between Parasolid entities and components will be deleted, and then it will invoke the base CADModel delete logic.
DWG:
Invoking delete on these types will not modify the associated DWG database. It will simply invoke the base Component delete logic.
Invoking delete on a DWG::CADModel will release the underlying AcDbDatabase via acdbReleaseHostDwg, and then it will invoke the base CADModel delete logic.
- Parameters
mode – The DeleteMode that we will use.
-
bool Equals(Component const &in_that) const
Check if the source Component points to the same underlying impl as this Component.
-
void Flush()
Removes all references to the underlying subcomponents, but leaves this Component around. If a subcomponent of the component being flushed has multiple owners, the flush will simply remove the reference to that subcomponent. If a subcomponent of the component being flushed has only one owner (the component being flushed), that subcomponent will be deleted. Any handles to the deleted components will become invalid.
-
MetadataArray GetAllMetadata() const
-
ComponentArray GetAllSubcomponents(ComponentType in_type) const
Gets all components under this Component that have the specified ComponentType mask. This will examine this subcomponents of this Component, the subcomponents of the subcomponents, and so on.
-
ComponentType GetComponentType() const
Gets the specific format-dependent type this Component represents.
- Returns
The specific format-dependent type this Component represents.
-
KeyArray GetKeys() const
Get the underlying keys (if any) which represent this Component. Generally this will either be a segment or geometry key.
- Returns
The underlying keys (if any) which represent this Component.
-
Metadata GetMetadata(char const *in_name) const
Get the single Metadata object with the given name associated with this Component (if present).
-
UTF8 GetName() const
Gets the name for this Component. This is a convenience function equivalent to getting the “Name” metadata for this Component. If a Component does not have a name, an empty UTF8 object will be returned.
- Returns
The name (if any) for this Component.
-
ComponentArray GetOwners() const
Get the Component objects (if any) which “own” this Component. Generally this will be a single element or no elements for a root component. It is possible for there to be multiple owners of a Component if it is instanced (i.e., it may have both a prototype and a containing Component).
-
ComponentArray GetReferences() const
Get the Component objects (if any) which are referenced by this Component. These are Component objects which are associated with this Component, but not “owned” by this Component, and would not be deleted if this Component is deleted (though the reference relationship will be removed).
-
ComponentArray GetReferrers() const
Gets the Component objects which refer to this Component
(if any). These relationships are defined in the original CAD file and can be arbitrarily assigned between Components.
For the
Exchange implementation of the Component hierarchy, Referrers will typically indicate which PMI elements refer to the Component being inspected.- See
-
ComponentArray GetSubcomponents() const
Get the subcomponent objects (if any) owned or referenced by this Component. These Component objects would be deleted if this Component is deleted.
- Returns
The subcomponent objects (if any) owned or referenced by this Component.
-
bool HasComponentType(ComponentType in_mask) const
This function indicates whether this Component has the given ComponentType mask.
-
inline virtual HPS::Type ObjectType() const
This function returns the type the object, as declared (if the object is derived, this does not give the true type of the derived object).
- Returns
The declared type of the object in question, which may differ from the true, underlying type.
-
bool operator!=(Component const &in_that) const
Check if the source Component points to a different impl than this Component.
-
Component &operator=(Component &&in_that)
The move assignment operator transfers the underlying object of the rvalue reference to this Component.
-
Component &operator=(Component const &in_that)
Share the underlying smart-pointer of the Component source.
-
bool operator==(Component const &in_that) const
Check if the source Component points to the same underlying impl as this Component.
-
bool SetName(char const *in_new_name)
Sets the name for this component.
Note
This will currently only work for derived Exchange components.
- Parameters
in_name – The new name for this component.
- Returns
true if the name was set successfully, false otherwise.
-
bool SetTransform(MatrixKit const &in_transform)
Applies a transform to the underlying PRC or Parasolid data associated with this component, replacing any transforms currently set on it.
Warning
For Parasolid components, only transformations which are rigid motions can be applied. Calling SetTransform from a Parasolid component with a transform which is not a rigid motion, such as a shear, will cause the function to fail.
Warning
For Exchange components, only components of type ExchangeProductOccurrence, or components that have the type ExchangeRepresentationItemMask can have transforms applied to them. Additionally, SetTransform does not work on Exchange models which have a Drawing structure to them. This would include CATDrawing files and 2D DWG files loaded through Exchange. Any attempt to use this function on those models will produce a warning.
- Parameters
in_transform – The transform to apply to this component.
- Returns
true if transform was applied correctly, false otherwise.
Public Static Functions
-
static KeyPathArray GetKeyPath(Component const &in_component)
Gets the list of KeyPath objects that correspond to the given Component. There will be at least one KeyPath, and possibly more than one if a particular Component is instanced, e.g., if the Component corresponds to the wheel of a car, a KeyPath would be returned for each wheel (driver side front and rear, and passenger side front and rear). Each KeyPath in the list will also include the portion of the path above the Model (associated with the root CADModel) for each View, Layout layer, and Canvas permutation which includes the Model. This function will not take into account any includes or paths which do not come from the Component hierarchy or the View, Layout, and Canvas permutations which include the Model.
-
static KeyPathArray GetKeyPath(ComponentArray const &in_components)
Gets the list of KeyPath objects that correspond to the given ComponentPath. This function can be used to get the KeyPath for a particular instance of an instanced Component. For a non-instanced Component, since the ComponentPath can be determined unambiguously, the KeyPath returned will be the same as if only the leaf non-instanced Component was given to this function. There will be at least one KeyPath returned, and possibly more than one for each View, Layout layer, and Canvas which include the Model associated with the root CADModel. This function will not take into account any includes or paths which do not come from the Component hierarchy or the View, Layout, and Canvas permutations which include the Model.
- Parameters
in_components – The ComponentPath for which to compute the corresponding KeyPath objects. The path should be defined such that the first element is the leaf Component, and the last element is the root CADModel. Each element in the path should be an owner of the preceding Component, otherwise an exception will be thrown.
- Returns
A list of all KeyPath objects which refer to the given Component.
-
static KeyPathArray GetKeyPath(size_t in_count, Component const in_components[])
Gets the list of KeyPath objects that correspond to the given ComponentPath. This function can be used to get the KeyPath for a particular instance of an instanced Component. For a non-instanced Component, since the ComponentPath can be determined unambiguously, the KeyPath returned will be the same as if only the leaf non-instanced Component was given to this function. There will be at least one KeyPath returned, and possibly more than one for each View, Layout layer, and Canvas which include the Model associated with the root CADModel. This function will not take into account any includes or paths which do not come from the Component hierarchy or the View, Layout, and Canvas permutations which include the Model.
- Parameters
in_count – Size of the following array.
in_components – The ComponentPath for which to compute the corresponding KeyPath objects. The path should be defined such that the first element is the leaf Component, and the last element is the root CADModel. Each element in the path should be an owner of the preceding Component, otherwise an exception will be thrown.
- Returns
A list of all KeyPath objects which refer to the given Component.
Public Static Attributes
-
static const HPS::Type staticType = HPS::Type::Component
-
enum ComponentType