TopExp_Explorer类:用于遍历。
参考官网内容,和整理使用笔记。
官网链接:https://dev.opencascade.org/doc/occt-7.5.0/refman/html/class_top_exp___explorer.html
1、 上实例
//Example to find all the Faces in the Shape S :
//遍历模型 S 中的所有 TopAbs_FACE 类型的对象
for (Ex.Init(S,TopAbs_FACE); Ex.More(); Ex.Next())
{
ProcessFace(Ex.Current());//处理这个face
}
//第二种方法
//遍历模型 S 中的所有 TopAbs_FACE 类型的对象
TopExp_Explorer Ex(S,TopAbs_FACE);
while (Ex.More())
{
ProcessFace(Ex.Current()); //处理这个face
Ex.Next();
}
//To find all the vertices which are not in an edge :
//要查找不在边(edge )中的所有顶点(vertices )
for (Ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ...)
//To find all the faces in a SHELL,
//要查找壳(SHELL)中的所有面(faces ),
TopExp_Explorer Ex1, Ex2;
for (Ex1.Init(S,TopAbs_SHELL),...)
{
// visit all shells 遍历shell
for (Ex2.Init(Ex1.Current(),TopAbs_FACE),...)
{
// visit all the faces of the current shell
//遍历当前shell的face
}
}
//then all the faces not in a SHELL :
//然后查找不在壳(SHELL )中的所有面(faces ):
for (Ex1.Init(S,TopAbs_FACE,TopAbs_SHELL),...) { // visit all faces not in a shell }
//遍历可选择类型
enum TopAbs_ShapeEnum
{
TopAbs_COMPOUND,
TopAbs_COMPSOLID,
TopAbs_SOLID,
TopAbs_SHELL,
TopAbs_FACE,
TopAbs_WIRE,
TopAbs_EDGE,
TopAbs_VERTEX,
TopAbs_SHAPE
};
2、TopExp_Explorer类具体说明
详细描述:(Detailed Description)
TopExp_Explorer类是从TopoDS包中访问拓扑数据结构的工具。
由以下各项组成:
1.要遍历的形状。
2.要查找的形状类型:例如:顶点、边。这种类型不能是形状(TopAbs_SHAPE)。
3.要避免的形状类型。例如:壳,边。默认情况下,这种类型是TopAbs_SHAPE,这意味着对探索没有限制。如果要避免的类型与要查找的类型相同,或要避免的类型比要查找的类型等级更低,则发现该类型没有效果。例如,搜索不在顶点中的边不会产生任何影响。
TopExp_Explorer类会访问所有结构,以查找所请求类型的形状,这些形状不包含在要避免的类型中。
3、常用函数
TopExp_Explorer ()
TopExp_Explorer (const TopoDS_Shape &S, const TopAbs_ShapeEnum ToFind,
const TopAbs_ShapeEnum ToAvoid=TopAbs_SHAPE)
//ToFind查找类型;ToAvoid避免类型;S 待查找类型对象
~TopExp_Explorer ()
void Init (const TopoDS_Shape &S, const TopAbs_ShapeEnum ToFind,
const TopAbs_ShapeEnum ToAvoid=TopAbs_SHAPE)
//同上面构造函数
Standard_Boolean More () const
//如果还有下一个对象就返回true. Returns True if there are more shapes in the exploration.
void Next ()
// iteration移动到下一个。 Moves to the next Shape in the exploration. Exceptions Standard_NoMoreObject if there are no more shapes to explore.
const TopoDS_Shape & Value () const
//返回当前对象 Returns the current shape in the exploration. Exceptions Standard_NoSuchObject if this explorer has no more shapes to explore.
const TopoDS_Shape & Current () const
//获得当前对象 Returns the current shape in the exploration. Exceptions Standard_NoSuchObject if this explorer has no more shapes to explore.
void ReInit ()
//用原始参数重新初始化。 Reinitialize the exploration with the original arguments.
Standard_Integer Depth () const
//返回当前勘探深度。0是探索自身的形状。
// Returns the current depth of the exploration. 0 is the shape to explore itself.
void Clear ()
// Clears the content of the explorer. It will return False on More().
void Destroy ()
//无