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