Pro/E特徵訪問之二:訪問由孔貫入的表面

typedef struct uappdata
{
	int    feature_id;
	ProMdl solid;
} UsrAppData;
/*================================================================*\
FUNCTION: UserHoleSrfDisp()
PURPOSE:  Display the surfaces adjacent to the selected hole.
\*================================================================*/
int UserHoleSrfDisp()
{
	int            n, sel_count, feat_id;
	ProFeattype    feat_type;
	ProError       status;
	ProFeature     feat;
	ProFileName    msgfile;
	ProSelection  *psels = NULL;
	ProMdl         p_solid;
	ProModelitem   p_surf, p_edge, p_mdl_item;
	UsrAppData       appdata;

	/*-------------------------------------------------------*\
	Prompt the user to select a hole.
	\*--------------------------------------------------------*/
	ProStringToWstring (msgfile, "Message.txt");
	ProMessageDisplay (msgfile, "UG9 Select Hole Feature:");
	if ((ProSelect ("feature", 1, NULL, NULL, NULL, NULL, &psels,
		&sel_count) != PRO_TK_NO_ERROR) || (sel_count < 1))
		return ((int) PRO_TK_GENERAL_ERROR);

	status = ProSelectionModelitemGet (psels[0], &p_mdl_item);
	/*--------------------------------------------------*\
	Verify the selection of a hole feature.
	\*-----------------------------------------------------*/
	status = ProFeatureTypeGet (&p_mdl_item, &feat_type);
	if (feat_type != PRO_FEAT_HOLE)
	{
		ProMessageDisplay (msgfile, "UG9 Feature is not a hole");
		return ((int) PRO_TK_GENERAL_ERROR);
	}
	/*--------------------------------------------------------*\
	Use the UappData structure (cast to ProAppData type)
	to pass data between the visit function and here.
	\*--------------------------------------------------------*/
	appdata.feature_id = p_mdl_item.id;
	status = ProMdlCurrentGet (&(appdata.solid));
	status = ProFeatureGeomitemVisit (&p_mdl_item, PRO_EDGE, 
		(ProGeomitemAction)UserEdgeNeighborsEval, NULL, (ProAppData)&appdata);
	return ((int)PRO_TK_NO_ERROR);
}
/*================================================================*\
FUNCTION: UserEdgeNeighborsEval()
PURPOSE:  Evaluate the surfaces adjacent to the edges by
comparing the feature identifier to the feature
identifier of the hole.
\*================================================================*/
ProError UserEdgeNeighborsEval (
								ProGeomitem   *p_edge,   /* input from the visit function */
								ProError       status,   /* output from filter function */
								ProAppData     p_inp     /* user application data - input in
														 this case */
														 )
{
	int           n;
	UsrAppData     *ud = (UsrAppData *)p_inp;
	ProEdge       this_edge, next1, next2;
	ProSurface    surf[2];
	ProGeomitem   geom_item;
	ProSelection  selection;
	ProFeature    feat;

	/*-----------------------------------------------------------*\
	Look at both surfaces attached to this edge and highlight
	whichever does not belong to this feature.
	\*--------------------------------------------------------*/
	status = ProGeomitemToEdge (p_edge, &this_edge);
	status = ProEdgeNeighborsGet (this_edge, &next1, &next2, &surf[0], 
		&surf[1]);
	for (n = 0; n < 2; n++)
	{
		status = ProSurfaceToGeomitem ((ProSolid)ud->solid, surf[n], &geom_item);
		status = ProGeomitemFeatureGet (&geom_item, &feat);
		if (feat.id != ud->feature_id)
		{
			status = ProSelectionAlloc (NULL, &geom_item, &selection);
			status = ProSelectionHighlight (selection,
				PRO_COLOR_HIGHLITE);
			status = ProSelectionFree (&selection);
		}
	}
	return (PRO_TK_NO_ERROR);
}

转载于:https://www.cnblogs.com/samyangvs05/archive/2010/04/07/1706743.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值