现在的位置: 首页 > 综合 > 正文

基于ACIS/HOOPS的3D应用开发简介

2013年10月31日 ⁄ 综合 ⁄ 共 10113字 ⁄ 字号 评论关闭

 

造型引擎——ACIS

显示引擎——Direct3D/OpenGL/GDI

应用框架——HOOPS

ACIS——造型引擎

ACIS是美国Spatial Technology公司推出的三维几何造型引擎,它集线框、曲面和实体造型于一体,并允许这三种表示共存于统一的数据结构中,为各种3D造型应用的开发提供了几何造型平台.Spatial Technology公司在1986年成立,目前ACIS 3D Toolkit在世界上已有380多个基于它的开发商,许多著名的大型系统都是以ACIS作为造型内核,如AutoCAD,CADKEY,Mechanical Desktop,Bravo,TriSpectives,TurboCAD,Solid Modeler,Vellum
Solid等。

ACIS 核心功能

3D 造型

Ø         将2D曲线经拉伸、旋转、扫掠等操作生成复杂的3D曲面或实体

Ø         高级倒角和圆角操作

Ø         网格曲面生成

Ø         阵列操作

Ø         实体抽壳和曲面加厚

Ø         曲线、曲面和实体的交互式弯曲、扭曲、延展、变形

Ø         曲线、曲面、实体的交、并、差运算

Ø         放样操作

Ø         模型中拔模面生成、曲面等距和移动

3D 模型管理

Ø         在模型的任何级别关联用户自定义的数据

Ø         跟踪几何和拓扑改变

Ø         计算质量和体积

Ø         使用单元拓扑表示实体模型子域

Ø         独立于历史流的无穷次的撤销(undo)和恢复(redo)操作

3D 模型显示

Ø         将曲面几何离散成多边形网格表示

Ø         利用可选可变形造型组件创建高级曲面

Ø         利用可选PHL V5 组件生成带隐藏线消除的精确2D工程图

Ø         利用Spatial提供的Tech Soft America的HOOPS/3dAF以及HOOPS/ACIS Bridge等产品搭建图形交互应用程序

ACIS是一个完整的modeling的内核,说白了就是一套用C++写的modeling类库,只要你掌握了这个库就可以完成所有的建模工作(基本上所有3D造型软件的功能他都有),但是这个库的易用性不够,所以在其上又开发了一些API进一步对底层的acis类库进行封装,而最上层则是现在非常流行的一中类lisp的解释器平台,应用scheme语言作为上层的开发语言,经过这么多步骤的封装,你只需要输入(block(0,0,0),(10,10,10))这个命令就能建立一个立方体,其他相似的简单命令就能完成很复杂的操作,已经相当于AutoCAD里面的命令行模式了。

建立一个模型后不能只存为一个数据文件就完了,我们需要把这个模型显示在计算机屏幕上,并实时对他进行操作,这就需要一个图形显示引擎来干这个事儿了。

HOOPS是一个在底层图形驱动基础上开发的显示类库,他不是一个单独的图形显示引擎,而是对OpenGL、DirectX这些图形引擎进行封装和扩展的结果。他的最大优势是对大模型操作和显示的优化以及一种压缩比高,适合网络传输的stream模式。这两者都可以理解为对原有图形引擎的优化,使文件更小,运行更快。当然,灵活的对OpenGL和directX的支持也是其卖点,HOOPS保证自己能同步跟上OpenGL和DirectX的发展步伐并在其上做有益的改进。

ACIS是一个B-rep建模引擎,它是通过定义几何对象的边界来表达一个实物。边界是可组成一个闭合区域的一系列面的集合。

Body   模型对象的根结点,是块的集合,能描述线体、板体、实体,也能是几个彼此分离的体的集合,包含0个或多个Lumps。

Lump   空间有界的连通的区域。用Shell约束的点的集合,一个实体上附加一个悬挂面也称为Lump。

Shell   一系列连通的Face / Wire 的集合。线、面的集合,能位于实体外,也能在内部形成空洞。一个体含一个悬挂面,一个体内嵌许多和外表面相连的面都称为shell

Face   广义的面。ACIS能定义无限薄的双面或单面(这种情况下,单面法向量指向面的一侧,实体材料存在于另一侧)。

Loop        a connected series of coedges, Closed

Wire         not attached to faces

Coedge    Edge被多个Face引用。ACIS中允许边是一个、两个或多个面的交线,因此它能描述二流形体和非流形体。一条边由两条共边(有时也是单条共边)组成。

Edge             one or more vertices。边是多个面的交线时(形成非流形体),半边保存顺序非常重要,用它来决定面的发散方向。

Vertice

Body处于最上层,它可以由任意的拓扑元素组成。几个不共点的Body可看作一个Body。Body可以有任何数目的Lumps。Lumps代表空间中一个约束的连接的区域。一个Lumps是一系列整个相连点集,而不论它们是三维、二维、一维或是它们的混合。因此一个实体带有一个悬挂面的是一个Lumps,而两个不相连的薄面则代表两个Lumps。Shell是一系列整个相连的面。一个实体带有一个悬挂面的是一个Shell,而一个实体带有一个不相连的面则是两个Shell。Subshells 不能够通过API来访问,它基本上不直间使用。一个FACE是空间一个几何表面,Face的边界是由Loops构成的。Loops是由一系列相连的Coedge所组成。Coedge记录的是一个面Loops的中的一条边。引入是Coedge为了表示多个面共边,这就使得流体和非流体的造形成为可能。对于Coedge很重要的一点是要理解它的方向性。在Coedge类中有很多指针,可指向它的相邻,前一个,后一个等等,这就使得在进行模型的遍历时是很方便的。拓扑模型的遍历就是一个从上到下的循环查找的过程

HOOPS和ACIS、InterOp、Direct3D/OpenGL之间的关系

   HOOPS组件不但可以单独用于3D模型的可视化,而且可以和其他造型内核(如ACIS)和数据接口组件(如InterOP)结合使用。下图所示非常直观地说明了HOOPS和ACIS、InterOp之间的关系以及如何使用这三个组件来构建3D应用程序的基本框架。

    3D应用程序通过HOOPS/GUI和ACIS、HOOPS组件建立连接,从而实现利用ACIS内核进行造型,并利用HOOPS组件进行可视化和人机交互。ACIS和HOOPS之间通过HOOPS/ACIS bridge来进行通信,从而实现文档和视图分开;InterOp组件用于读写实现ACIS模型和其他格式3D模型之间的相互转换;HOOPS/Stream组件则可用于读写3D场景图数据。

Creating and Rendering ACIS Entities

Rendering ACIS entities is performed by calling HA_Render_Entity or HA_Render_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

// strPartFilePathsat文件路径名

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 andHA_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.

抱歉!评论已关闭.