遍历模型中的face、edge等——TopExp_Explorer类

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 ()
//无
  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值