Creating and Rendering ACIS Entities
Defining ACIS Geometry
A sphere, along with many other predefined ACIS objects, is represented by a BODY entity, and is created via the routine:
<outcome>= api_make_sphere(<radius>, <sphere_body>);
|
The following code demonstrates how to create an ACIS sphere. Note that it calls HA_Render_Entity.
// create an acis sphere and return the sphere's body id
BODY* HOpCreateSolidSphere::CreateSolidSphere(HPoint & center, float radius)
{
BODY* sphere_body;
vector translate_vector;
transf delta_transf;
outcome o;
translate_vector.set_x(center.x);
translate_vector.set_y(center.y);
translate_vector.set_z(center.z);
delta_transf = translate_transf(translate_vector);
o = api_make_sphere(radius, sphere_body);
o = api_transform_entity(sphere_body, delta_transf);
assert(o.ok());
// before rendering bodies, check if this view is in 'merge faces'
// mode or not, and ensure that the rendering option is set
// accordingly. This is necessary because the HOOPS/GM Rendering
// Options are procedural; they set the current state of the bridge,
// and we need to make sure that all parts in each view object are
// rendered in a consistent mode
if (((HSolidView*)GetView())->GetOptimizations())
HA_Set_Rendering_Options("merge faces");
else
HA_Set_Rendering_Options("no merge faces");
// now put it in the HOOPS database
HA_Render_Entity((ENTITY*)sphere_body);
((HSolidModel*)m_pView->GetModel())->AddAcisEntity(sphere_body);
return sphere_body;
}
Inserting ACIS Geometry into the HOOPS database:
//Read Sat file
// strPartFilePath为sat文件路径名
ENTITY_LIST entList;
CFile SatFile = fopen (strPartFilePath, "rt");
outcome oRes = api_restore_entity_list(satFile, TRUE, entList);
//将多余的边去除,以达到使圆柱侧面为一个完整周期曲面的目的
entList.init();
ENTITY* entity = entList.next();
while(entity != NULL)
{
oRes = api_clean_entity(entity);
entity = entList.next();
}
entList.init();
// ACIS entity map to HOOPS segment
HC_Open_Segment_By_Key(key);
entList ->init();
ENTITY* ent =pList->next();
while(ent != NULL)
{
HA_Render_Entity(ent);
ent = pList->next();
}
HC_Close_Segment();
//HA_Render_Entity()函数内部调用上面提到的IEntityConverter接口:
HC_KEY HA_Render_Entity(ENTITY* entity, const char* pattern)
{
extern IEntityConverter *s_pIEntityConverter;
ENTITY *owner = NULL;
。。。。。。
api_get_owner( entity, owner );
pattern = s_RenderingOptions.GetPattern();
key=s_pIEntityConverter->ConvertEntity(owner,s_RenderingOptions,map,pattern)
。。。。。。
};
// delete the ACIS body
void HSolidModel::DeleteAcisEntity( ENTITY* entity)
{
ENTITY_LIST elist;
elist.add(entity);
HA_Delete_Entity_Geometry(elist);
api_del_entity(entity);
}
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 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.
Operating on ACIS Entities
When performing operations that modify ACIS entities, it is necessary to keep the HOOPS representation of the model synchronized with its ACIS representation. Because such operations are typically initiated by selecting (hit testing) HOOPS geometric objects, it is necessary to determine which ACIS entity(s) correspond with the selected HOOPS entities, and vice versa. The HOOPS/ACIS Integration includes routines that support this requirement.
HOOPS geometric entities are identified by a HOOPS 'key'. Recall that ACIS entities are referred to by an ACIS pointer. Given a HOOPS key, the HA_Compute_Entity_Pointer function will return the ACIS pointer for the ACIS entity associated with that key. Conversely, given an ACIS pointer, the HA_Compute_Geometry_Keys function will return all the HOOPS keys for the tessellated geometry or the HOOPS segment associated with the ACIS entity. (Recall that an ACIS entity might be represented by more than one HOOPS geometric entity.)
Accessing an ACIS Entity
Selection on the HOOPS scene returns the key(s) of HOOPS geometry, requiring us to find the ACIS entity that is associated with the selected HOOPS geometry. If we wanted to access the ACIS 'body' entity given the key of a selected HOOPS geometric primitive, we would call:
BODY* entity = (BODY*)HA_Compute_Entity_Pointer(key, BODY_TYPE);
|
We can now use the pointer of the ACIS entity to perform ACIS operations, or to access the HOOPS geometric primitives that represent the ACIS entity.
4.HOOPS/MVO (Model/View/Operator)
Model : Application data
View : Representations of the application data
Operator : Algorithms that operate on the application data
The user of the application operates on the model via the views of the model. Views are designed specifically to facilitate a given model interaction such as data creation or editing. Views can "look at" multiple models and models can "be seen" by multiple views (a many to many mapping). Operators are associated with views.
In HOOPS, 3D objects are organized into segments containing geometry, attributes and sub-segments. For each application, the 3D model maps to some section of the HOOPS segment tree, typically in the Include Library. Views are mapped to HOOPS driver instance segments with camera and window attributes. The model is either directly built under the driver instance segment or included from another spot in the segment tree. This relationship of HOOPS model to HOOPS views is generic and applicable to most applications built with HOOPS.
Operators consist of the application code that manipulates the application data. When building HOOPS-MVO applications, the operators use the HOOPS API, along with other component or application-specific APIs, to manipulate the data stored in both HOOPS and application-specific data structures.
The HOOPS/MVO Classes provide a HOOPS-specific implementation of the model/view/operator paradigm, which may be directly incorporated into an application and extended.
The class library builds higher level objects for the model and view out of HOOPS segment structures. The HBaseModel object is built out of the include library and the HBaseView object is built out of HOOPS driver segment instances. View objects also build an initial segment structure for managing the inclusion of model objects, interacting with user input, lighting of the scene, etc...
5.HOOPS/3dGS(3D Graphics System )
HOOPS/3dGS provides the algorithms for creating, editing, manipulating, and querying the graphics information stored in the database
The HOOPS/3dGS Graphics System, illustrated in Figure 1, consists of 2 major subcomponents: a graphical object database called the HOOPS/3dGS Segment Tree, and a rendering pipeline called the HOOPS/3dGS Structured Device Interface.
The HOOPS/3dGS database stores graphical data in objects called "segments". Think of a segment as a container for geometry and attributes that describe how the geometry is to be drawn..
The HOOPS/3dGS graphics database stores graphics scenes as a hierarchy of segments, which lends itself naturally to organizing graphics information. In terms of object-oriented programming, think of a segment as an object.
6.HOOPS/Stream
HOOPS/Stream is a set of platform and GUI-independent C++ classes that provide support for creating and reading HOOPS Stream Files (HSF's) or data streams containing 2D & 3D scene-graph objects, attributes, and any kind of specialized application-specific data.
HOOPS/Stream's open architecture allows developers to create and read custom, stream-enabled HSF files that are tailored to a particular application's needs. Its flexibility of design enables the creation of an endless variety of streaming formats, file extensions, file interaction strategies (including client/server interaction), data transfer techniques, and more...all with advanced data compression and full object and attribute support.
HOOPS/Stream is independent from other HOOPS modules, in that its usage does not require the application's architecture to be based on HOOPS/3dAF. Any application using a proprietary scene graph, as well as those that use HOOPS/3dAF, can implement HOOPS/Stream.