OpenCASCade——presentation与selection模块

1 presentation显示组件

OCC将显示与数据分离,这样改变数据时便不会影响显示的内容。该组件中主要有三种对象:AIS_InteractiveObject(交互对象), viewer(视窗),AIS_InteractiveContext(交互上下文)。

1.1 AIS_InteractiveObject

Standard presentation algorithms [StdPrs\Prs3d提供创建交互显示结构的算法]。
每一个独立显示的个体都需要成为一个AIS_InteractiveObject对象。

1.2 viewer

视图类,视图放缩与变换。

1.3 AIS_InteractiveContext

控制整个交互显示过程,向显示对象请求数据并发送给viewer进行显示。

1.4 主要组件

AIS、PrsMgr、StdPrs、V3d。自定义显示时还需要组件:Prs3d、Graphic3d
AIS—-包含了交互显示对象需要实现的所有类。
PrsMgr—-如果想用自定义的显示对象而不是AIS提供的对象时,需要实现此包中定义的两个抽象类和一个实体类。抽象类:Presentation and PresentableObject 、实体类PresentationManager3d。
StdPrs—-为特殊几何体准备的显示。
Prs3d—-基本的显示算法、属性:影藏、线宽、颜色等。
V3d—-支持3dview的服务。
Graphic3d— 提供创建3D graphic structures所需的资源。
Visual3d—-实现了3D viewer命令的类。
DsgPrs—-用于提供dime nsions, relations以及XYZ trihedrons的显示。

Handle(V3d_Viewer) theViewer; 
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (theViewer);
BRepPrimAPI_MakeWedge aWedgeMaker (theWedgeDX, theWedgeDY, theWedgeDZ, theWedgeLtx); 
TopoDS_Solid aShape = aWedgeMaker.Solid(); 
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape); // creation of the presentable object 
aContext->Display (aShapePrs); // display the presentable object in the 3d viewer

显示Shape的过程

2 selection选中显示组件

2.1 static select 与dynamic select

  • static select 静态选择,鼠标单击选中。
  • dynamic select动态选择,鼠标移动时的选择。

2.2 三种选择手段

  • point点选
  • rectangle selection框选
  • polyline selection 多边形选择

2.3 术语与概念

  • Sensitive entity将一个拓扑结构的实体打散为多个senstive entity以供计算选择
  • Entity owner每一个sensitive entity都链接了一个entity owner,entity owner中具有更多的显示对象的信息,比如高亮显示的颜色、是否被选中、该sensitive entity的类型等。
  • Selection sensitive entitys与其entity owners形成的一个集合,定义了一种显示模式。
  • Selectable object 存储了所有的selection set 与sensitive entity。一个对象只有被删除才会释放掉其中的存储。
  • 选择模式
    • 0 – selection of the entire object∗(AIS_Shape)∗; 整体选择
    • 1 – selection of the vertices;顶点选择
    • 2 – selection of the edges;边选择
    • 3 – selection of the wires;线选择
    • 4 – selection of the faces;面选择
    • 5 – selection of the shells;壳选择
    • 6 – selection of the constituent solids.连续实体
    从sensitive entity到selectable object
    selection object的组织结构
  • Viewers elector选择器,用于判断哪个实体被选择。
  • Selection manager管理所有的选择器,更新状态,结构等。
    viewer选择器与selection manager之间的关系

2.4 算法

OCC的选择主要靠搜索深度为3的一个BVH树来完成。计算从视锥体(frustum)到可选实体(sensititve entity)间的映射关系,主要进行覆盖的计算,来判断哪个实体被选中。
- Selection Frustum
- BVH tree
BVH第一层是各个interactive object的bounding box。这一层是自动计算的。
BVH第二层是各interactive object中的sensitive entities。这一层是模式切换时自动计算且只在首次计算。
BVH第三层是各个sensitive entity中的细节,比如面中线,线中点等。
BVH树结构

2.5 包和类

  • Select Basics
    SelectBasics_SensitiveEntity SensitiveEntity的基本定义
    SelectBasics_EntityOwner entityowner的定义
    SelectBasics_PickResult 选择结果的结构
    SelectBasics_SelectingVolumeManager 与当前选择视锥体的交互接口
    一个SensitiveEntity至少需要继承实现SelectBasics_SensitiveEntity。
  • Select3D
    定义了标准选择实体(SensitiveEntity)。
    • box;
    • circle;
    • curve;
    • face;
    • group;
    • point;
    • segment;
    • triangle;
    • triangulation;
    • wire.
    这里的每个实体都继承自SelectBasics_SensitiveEntity,包中还有两个辅助工具:Select3D_SensitivePolySelect3D_SensitiveSet。前者是一个点集的实体,没有/不提供内部数据的check。后者用于需要计算到第三层SVH树的复杂实体的计算,提供了遍历子实体的接口。
  • SelectMgr
  • 激活和反激活实体选择模式
  • 实体选择模式中的计算接口
  • 选择滤波器类的定义
  • 保持BVH树的更新
  • StdSelect
    继承SelectMgr的类,创建显示结构。

猜你喜欢

转载自blog.csdn.net/u012541187/article/details/81060245
今日推荐