OpenCascade拓扑对象之:拓扑对象方向继承关系


OpenCascade的拓扑对象的方向,存在继承关系。通常来说,下层拓扑对象的最终方向,依赖上层对象的方向。例如:一个Edge的方向,依赖所在Face方向最终确定。

OCCT中,当一个拓扑对象反向时,仅仅需要将方向属性反向,如下面代码所示:

inline void TopoDS_Shape::Reverse()
{
  myOrient = TopAbs::Reverse(myOrient);
}
    子对象的方向将根据父对象的方向属性而进行调整。     例如:如果一个Face反向了,通常裁剪环Wire也需要反向,Wire中的Edge也需要反向,这样才能保证拓扑结构的正确性。而实际上,仅仅需要调用Face的Reverse()方法,反向Face的方向即可。

OCCT中拓扑子对象遍历,有两个工具类:TopoDS_Iterator和TopExp_Explorer,其中TopExp_Explorer是基于TopoDS_Iterator类实现的。我们看看TopoDS_Iterator类:

//! Creates an Iterator on  sub-shapes.
//! Note:
//! - If cumOri is true, the function composes all
//! sub-shapes with the orientation of S.
//! - If cumLoc is true, the function multiplies all
//! sub-shapes by the location of S, i.e. it applies to
//! each sub-shape the transformation that is associated with S.

    TopoDS_Iterator(const TopoDS_Shape& S, const Standard_Boolean cumOri = Standard_True, const Standard_Boolean cumLoc = Standard_True);

注意:cumOri参数,就是遍历是,是否需要考虑父对象的方向。如果要获取最终子对象正确的方向,通常需要设定该参数为true,这里默认也是true。

在一些情况下,可以使用false。例如:Face中当要基于surface进行参数域或裁剪环操作时,通常不考虑Face的方向,基于surface来进行裁剪环的处理,可以省去很多的麻烦。

TopExp_Explorer类的实现总,创建TopExp_Iterator类对象时,传递的cumOri值为默认值,即为true,因此默认是考虑上了父对象的方向的,也因此组合了父对象的方向。