The 3D ACIS® Modeler (ACIS) is Spatial’s prominent 3D solid modeling engine. 3D InterOp is a CAD data translation framework (Interoperability)

HOOPS/ACIS Bridge

From DocR20

Jump to: navigation, search


The HOOPS/ACIS Bridge encapsulates the work needed to connect 3D ACIS modeler from Spatial to the HOOPS/3dGS. The bridge provides an API for controlling the manner in which ACIS' geometric tessellation is mapped to HOOPS primitives, and for finding exactly which HOOPS segment corresponds to which ACIS entity and vice versa. The HOOPS/ACIS Bridge is supplied as a dynamic linked library (dll) with an exposed API.

The following section gives technical details on how the integration between ACIS and the HOOPS/3dGS has been designed and includes a reference guide for the routines in the HOOPS/ACIS Bridge API.

The HOOPS/ACIS Reference Application is a MS Windows Application built with the components of the HOOPS 3D Application Framework, ACIS, and MFC GUI toolkit. It includes clear source for the application code and can be used as a prototyping tool or a base architecture for new applications.

Contents

Connecting ACIS to HOOPS/3dGS

Building a two-way connection between ACIS and the HOOPS/3dGS involves accessing the geometric data in ACIS and mapping it the appropriate set of geometric primitives in HOOPS. Furthermore, it involves providing a mechanism for finding out which ACIS entity corresponds to which HOOPS entity and vice versa. A class that implements IEntityConverter performs the conversion of ACIS ENTITYs to HOOPS segments. An example class (hoops_acis_entity_converter) is provided with the HOOPS/ACIS Bridge. If hoops_acis_entity_converter does not suit the application's needs, it can be replaced using HA_Set_Entity_Converter.

Synchronizing ACIS and HOOPS/3dGS

The HOOPS/ACIS Bridge routine HA_Render_Entities will initiate the flow of geometric information from ACIS to the HOOPS/3dGS. The HA_Render_Entities routine accepts a list of ACIS entities and then calls the registered IEntityConverter-derived class to convert the ACIS entities to HOOPS segments.

HOOPS Segment Structure Generated

When ACIS entities are rendered via the HA_Render_Entity routine, the HOOPS/ACIS Bridge uses the passed-in segment pattern or the default segment pattern (set using the "segment pattern" sent to HA_Set_Rendering_Options). The HOOPS/ACIS Bridge then opens the segment the pattern expands to and populates it with geometry corresponding to the rendered ACIS entities.

The HOOPS/ACIS Bridge API provides control over how the ACIS entities are mapped to HOOPS via the routine HA_Set_Rendering_Options. The actual segment structure generated under the open segment depends on which options are chosen.

As the HOOPS/ACIS Bridge uses a segment pattern, the user has maximum flexibility over the structure of the top part of the HOOPS segment tree. For instance, an application working with assemblies of ACIS bodies will create the appropriate assembly structure in the HOOPS segment tree, and then open the appropriate segment in the tree when rendering bodies for the individual parts of the assembly.

Mapping of ACIS Entities to HOOPS Geometry

To give the user maximum flexibility in their implementation, mappings are maintained between HOOPS segments and ACIS entities. This is so someone could, for example, pick on the HOOPS graphics on the screen and perform operations on the corresponding ACIS geometry. The HOOPS/MVO library includes several Operator classes, which make use of the entity mapping between ACIS and HOOPS to implement sophisticated application-level features.

The HOOPS/ACIS Bridge maps the tessellation of all ACIS entities to HOOPS geometric primitives, inserting zero or more new HOOPS geometric primitives into the HOOPS database for each ACIS entity encountered. While each ACIS entity uses a pointer for access, HOOPS entities have "keys" that are long integers, and which are passed to routines when accessing the entity. The HOOPS/ACIS Bridge routines HA_Compute_Entity_Pointer and HA_Compute_Geometry_Keys can be used for converting ACIS pointers to HOOPS keys and vice versa.

The HOOPS/ACIS Bridge maps the geometric tessellation of all ACIS entities to HOOPS, inserting a new HOOPS geometric primitive into the HOOPS database for each ACIS Entity. The following section gives details on how each of the ACIS Entities is mapped to HOOPS geometric primitives.

ACIS Faces and Bodies

In applications that provide highly interactive functionality such as model creation, view and markup, and dimensioning, the modeler operations have to create, delete, and modify ACIS faces frequently, and therefore the amount of data flowing from ACIS to HOOPS should be minimized. This is accomplished by mapping all the tessellated geometry associated with one ACIS face to one HOOPS shell. An additional optimization step ensures the minimum number of vertices is used and the longest triangle strips possible are computed internally by HOOPS for optimal rendering.

Conversely, for applications only viewing ACIS models, all the tessellated geometry associated with all the ACIS Faces in one ACIS body can be mapped to one HOOPS shell. This results in a reduction in the number of vertices for complex ACIS bodies, and can increase rendering through-put. It is anticipated this mode will be useful to applications focused primarily on viewing and querying model or assembly data, that is, the Virtual Prototyping and View/Markup sectors.

ACIS Edges/Wires

ACIS edges/wires map to HOOPS polylines.

ACIS Vertices

ACIS vertices map to HOOPS marker symbols. To display the vertices, you must set the marker visibility of model segment on.

Initialization

A typical application will need to perform the following:

  • start the ACIS modeler,
  • initialize the used ACIS components, and
  • call api_initialize_hoops_acis_bridge to initialize all the ACIS components required for rendering/faceting purposes.

Setting Rendering Options (HA_Set_Rendering_Options)

Table. Rendering Options
Option Type Description
RenderVerticesMode [= on,off] Controls whether or not to render ACIS vertices and map them to HOOPS primitives.
RenderEdgesMode [= on,off] Controls whether or not to tessellate the ACIS edges and map them to HOOPS primitives.
RenderFacesMode [= on,off] Controls whether or not to render ACIS faces and map them to HOOPS primitives.
RenderTCoedges [= on,off] Controls whether or not to render ACIS tcoedges and map them to HOOPS primitives.
RenderCoedges [= on,off] Controls whether or not to render ACIS coedges and map them to HOOPS primitives.
RenderAPOINTs [= on,off] Controls whether or not to render ACIS points and map them to HOOPS primitives.
RenderWCSs [= on,off] Controls whether or not to render ACIS WCS's and map them to HOOPS primitives.
RenderText [= on,off] Controls whether or not to render ACIS text entities and map them to HOOPS primitives.
segment pattern [string] Specifies the global segment pattern. (See Segment Patterns, below.)

Converting ACIS Entities to HOOPS Segments

ENTITYs are converted to HOOPS segments using HA_Render_Entity or HA_Render_Entities. These functions take, respectively, an ENTITY or an ENTITY_LIST and an optional segment pattern.

Segment Pattern

HA_Render_Entity/HA_Render_Entities takes an optional segment pattern parameter. The segment pattern specifies the segment that will contain the ENTITY's rendering data. The pattern can contain keywords that will be automatically expanded by calling HA_Build_Segment_String with a given ENTITY and pattern. The current keywords are:

  • "history" (this is replaced with entity->history())
  • "entity" (this is replaced with the ENTITY's pointer value)
  • "type" (this is replaced with entity->type_name())

A global segment pattern can also be set by calling HA_Set_Rendering_Options with "segment pattern = some_segment_pattern". For example:

// Set the global segment pattern
HA_Set_Rendering_Options("segment pattern = ?Include Library/history/entity");

When HA_Build_Segment_String expands this, all ENTITYs with the same history stream will be grouped together, with each ENTITY in its own segment, since "entity" will be replaced by the ENTITY's address.

char inbuffer[1024];
HA_Build_Segment_String(entity, inbuffer,"?Include Library/history/entity");
// inbuffer becomes "?Include Library/0x12345678/0x11112222" if entity->history() == 0x12345678
// and entity == 0x11112222

Writing a Custom Converter

The HOOPS/ACIS bridge comes with a default ENTITY converter. If the default converter is not sufficient for an application's needs, a custom converter can be registered with the bridge, which will then be used instead of the default one. To implement a custom converter, derive from IEntityConverter or hoops_acis_entity_converter and register it with the Bridge.

For example, the Scheme application has a scheme_entity_converter, and it is registered as follows:

// Delete the current converter, and...
IEntityConverter* cvrt = HA_Get_Entity_Converter();
 
if (cvrt)
{
    ACIS_DELETE cvrt;
    cvrt = 0;
}
 
// ...use the Scheme entity converter instead.
HA_Set_Entity_Converter(ACIS_NEW scheme_entity_converter);

Note: On termination, the Bridge will automatically delete the converter that is currently active.

Mapping

Mapping from an ACIS entity to a HOOPS segment, or vice versa, is accomplished using the following two functions:

// From entity to key(s)
HA_Compute_Geometry_Keys(ENTITY* entity, unsigned long count, HC_KEY* keys);
// From key to entity
HA_Compute_Entity_Pointer(HC_KEY key, int acisClass);

Deleting Rendering Data

The function HA_Delete_Entity_Geometry deletes the rendering data for a specified list of ENTITYs.

History and Rollback

Inside api_initialize_hoops_acis_bridge, HA_History_Callbacks is registered with the history callback list. HA_History_Callbacks is derived from history_callbacks and receives the following notifications:

Callback method Description
virtual void 
history_callbacks::After_Roll_Bulletin_Board ( 
                 BULLETIN_BOARD*,  // bulletin board 
                 logical discard  // discard
                 );
Callback method, called after rolling a bulletin board. If discard is TRUE, the roll is due to error processing, and the BULLETIN_BOARD will be deleted along with all of its bulletins.
virtual void 
history_callbacks::After_Roll_State ( 
 DELTA_STATE*  // delta state 
 );
Callback method, called after rolling one state.
virtual void 
history_callbacks::After_Roll_States ();
Callback method, called after rolling all states.
virtual void 
history_callbacks::Before_Roll_Bulletin_Board ( 
 BULLETIN_BOARD*,  // bulletin board 
 logical discard  // discard 
 );
Callback method, called before rolling a bulletin board. If discard is TRUE, the roll is due to error processing, and the BULLETIN_BOARD will be deleted along with all of its BULLETINs.
virtual void 
history_callbacks::Before_Roll_State ( 
 DELTA_STATE*  // delta state 
 );
Callback method, called before rolling one state.
virtual void 
history_callbacks::Before_Roll_States ();
Callback method, called before rolling all states.

HA_History_Callbacks overrides these methods to keep the HOOPS segment structure up-to-date during rollback operations.

Part Management (HA_Part)

HA_Part is a helper class that wraps PART for use with the HOOPS/ACIS bridge. It provides the following methods:

HA_Part Operation Consequent PART Operation
On construction, it calls api_part_create(0,m_pPart). The constructor then registers HA_EntityCallback (see below) with the created PART.
On destruction, it calls api_part_delete(m_pPart).
HA_Part::LoadFile PART::load.
HA_Part::AddEntities PART::add for each ENTITY.
HA_Part::AddEntity PART::add.
HA_Part::RemoveEntity PART::remove.
HA_Part::UpdateEntity PART::modified and then PART::update.
HA_Part::RollBack api_part_roll_n_states(-1).
HA_Part::RollForward api_part_roll_n_states(1).

HA_EntityCallback (ha_callback.h) provides Part Management support for HOOPS/ACIS Bridge applications that want to use the PART Management Component. HA_EntityCallback derives from entity_callback and listens for the following message:

Calls
pm_Create_Entity calls HA_Render_Entity
pm_Delete_Entity calls HA_Delete_Entity_Geometry
pm_Remove_Entity calls HA_Delete_Entity_Geometry
pm_Part_Delete_Delete_Entity calls HA_Delete_Entity_Geometry
pm_Update_Entity calls HA_Render_Entity

Termination

api_terminate_hoops_acis_bridge calls ACIS termination functions for the components initialized during initialization.

See Also

Personal tools