📄 utilvisit.c
字号:
/*====================================================================*\FILE : UtilVisit.cPURPOSE : Utility functions for visitingHISTORY..DATE BUILD AUTHOR MODIFICATIONS06-Dec-96 H-01-21 mgs $$1 Stripped some functions from UtilGeom.c28-Mar-97 H-01-30 Pavel $$2 Added more visit fcns16-May-97 H-03-11 Alexey $$3 Added more visit fcns15-Sep-97 H-03-22 Pavel $$4 Fixed bug in ProUtilAxisByVectorFilterAction05-Sep-97 H-03-25 Pavel $$5 More includes and type cast17-Oct-97 H-03-27 Pavel $$6 More filters20-Jan-98 H-03-37 aab $$7 Fixed some bugs for c++ compiler13-Feb-98 H-03-39 Pavel $$8 Added ProUtilGeomitemByNameFilterAction23-Feb-98 H-03-40 Philippe $$9 Added ProUtilAsmFeatsTraverse18-Sep-98 I-01-23 Pavel $$10 Added ProUtilCollectDtmCurveFeatFilter01-Jun-99 I-03-12 mka $$11 More includes\*====================================================================*//*--------------------------------------------------------------------*\Pro/TOOLKIT includes\*--------------------------------------------------------------------*/#include <ProToolkit.h>#include <ProObjects.h>#include <ProSurface.h>#include <ProFeature.h>#include <ProFeatType.h>#include <ProSelection.h>#include <ProSolid.h>#include <ProAsmcomp.h>#include <ProEdge.h>#include <ProAxis.h>#include <ProCsys.h>#include <ProCurve.h>#include <ProPoint.h>#include <ProGeomitem.h>#include <ProNcseq.h>/*--------------------------------------------------------------------*\Application includes\*--------------------------------------------------------------------*/#include "TestError.h"#include "UtilMath.h"#include "UtilVisit.h"#include "UtilCollect.h"/*--------------------------------------------------------------------*\Application data\*--------------------------------------------------------------------*/typedef struct { ProAppData app_data; /* The caller's app_data */ ProFunction action; /* The caller's action function */} AsmComp_data_t ;/*--------------------------------------------------------------------*\ We need our own app_data to pass to ProUtilAsmCompVisit() which contains both the app_data and the action function pointer input to this function, plus our own context data so that OUR action function has all it needs to call the user's action function.\*--------------------------------------------------------------------*/typedef ProError (*ProTestAsmTravAction) (ProAsmcomppath*, ProAppData);typedef struct { ProAppData app_data; /* The caller's app_data */ ProTestAsmTravAction action; /* The caller's action function */ ProAsmcomppath comp_path; /* The current component path */} AsmTrav_data_t ;/*====================================================================*\ FUNCTION : ProUtilAsmcompVisit() PURPOSE : Visit function for components of an assembly\*====================================================================*/ProError ProUtilAsmcompVisit( ProAssembly assembly, ProFunction action, ProAppData app_data ){ ProError status;/*--------------------------------------------------------------------*\ Visit all the features, using a filter to see only assembly components\*--------------------------------------------------------------------*/ status = ProSolidFeatVisit(assembly, (ProFeatureVisitAction)action, (ProFeatureFilterAction)ProUtilAsmcompFilterAction, app_data); TEST_CALL_REPORT("ProSolidFeatVisit()", "ProUtilAsmcompVisit()", status, status != PRO_TK_NO_ERROR); return(status);}/*====================================================================*\ FUNCTION : ProUtilFeatvisVisit() PURPOSE : Visit function for visible features\*====================================================================*/ProError ProUtilFeatvisVisit( ProSolid solid, ProFunction action, ProAppData app_data ){ ProError status;/*--------------------------------------------------------------------*\ Visit all the features, using a filter to see only assembly components\*--------------------------------------------------------------------*/ status = ProSolidFeatVisit(solid, (ProFeatureVisitAction)action, ProUtilFeatvisFilterAction, app_data); TEST_CALL_REPORT("ProSolidFeatVisit()", "ProUtilFeatvisVisit()", status, status != PRO_TK_NO_ERROR); return(status);}/*====================================================================*\ FUNCTION : ProUtilGeomitemactiveVisit() PURPOSE : Visit function for active geomitems\*====================================================================*/ProError ProUtilGeomitemactiveVisit( ProFeature *p_feature, ProType item_type, ProFunction action, ProAppData app_data){ ProError status;/*--------------------------------------------------------------------*\ Visit all the features, using a filter to see only assembly components\*--------------------------------------------------------------------*/ status = ProFeatureGeomitemVisit(p_feature, item_type, (ProGeomitemAction)action, ProUtilGeomitemactiveFilterAction, app_data); TEST_CALL_REPORT("ProFeatureGeomitemVisit()", "ProUtilGeomitemactiveVisit()", status, status != PRO_TK_NO_ERROR); return status; }/*====================================================================*\ FUNCTION : ProUtilAsmTravAction() PURPOSE : Action function to be called for features inside ProUtilAsmTraverse() to recursively visit features which are assemblt components.\*====================================================================*/ProError ProUtilAsmTravAction( ProFeature *component, ProError instatus, ProAppData app_data ){ ProError status; ProSolid model; AsmTrav_data_t *asm_data = (AsmTrav_data_t*)app_data; ProMdlType model_type;/*--------------------------------------------------------------------*\ Increment the component path\*--------------------------------------------------------------------*/ asm_data->comp_path.comp_id_table[asm_data->comp_path.table_num++] = component->id; asm_data->comp_path.comp_id_table[asm_data->comp_path.table_num] = -1; /*--------------------------------------------------------------------*\ Get the ProMdl for this assembly component\*--------------------------------------------------------------------*/ status = ProAsmcompMdlGet(component, (ProMdl *) &model); TEST_CALL_REPORT("ProAsmcompMdlGet()", "ProUtilAsmTravAction()", status, status != PRO_TK_NO_ERROR);/*--------------------------------------------------------------------*\ Call the action function for this component, with the user's app_data\*--------------------------------------------------------------------*/ status = (*asm_data->action) (&asm_data->comp_path, asm_data->app_data);/*--------------------------------------------------------------------*\ If the model is an assembly, visit its components recursively\*--------------------------------------------------------------------*/ ProMdlTypeGet(model, &model_type); TEST_CALL_REPORT("ProMdlTypeGet()", "ProUtilAsmTravAction()", status, status != PRO_TK_NO_ERROR); if(model_type == PRO_MDL_ASSEMBLY) ProUtilAsmcompVisit((ProAssembly)model, (ProFunction)ProUtilAsmTravAction,app_data);/*--------------------------------------------------------------------*\ Decrement the component path\*--------------------------------------------------------------------*/ asm_data->comp_path.comp_id_table[asm_data->comp_path.table_num--] = -1; return(PRO_TK_NO_ERROR);}/*====================================================================*\ FUNCTION : ProUtilAsmTraverse() PURPOSE : Visit function for components of an assembly at ALL levels\*====================================================================*/ProError ProUtilAsmTraverse( ProAssembly assembly, ProFunction action, ProAppData app_data){ ProError status; AsmTrav_data_t asm_data; ProIdTable comp_id_table;/*--------------------------------------------------------------------*\ Initialize our asm_data\*--------------------------------------------------------------------*/ asm_data.app_data = app_data; asm_data.action = (ProTestAsmTravAction)action; comp_id_table[0] = -1; status = ProAsmcomppathInit(assembly, comp_id_table, 0, &asm_data.comp_path); TEST_CALL_REPORT("ProAsmcomppathInit()", "ProUtilAsmTraverse()", status, status != PRO_TK_NO_ERROR);/*--------------------------------------------------------------------*\ Visit the components are this level\*--------------------------------------------------------------------*/ ProUtilAsmcompVisit(assembly, (ProFunction)ProUtilAsmTravAction, (ProAppData)&asm_data); return(PRO_TK_NO_ERROR);}/*====================================================================*\ FUNCTION : ProUtilAsmFeatsTraverse() PURPOSE : Visit function for features of an assembly at *ALL* levels\*====================================================================*/ProError ProUtilAsmFeatsTraverse( ProAssembly assembly, ProFunction action, ProAppData app_data){ ProError status; AsmTrav_data_t asm_data; ProIdTable comp_id_table; /*--------------------------------------------------------------------*\ Initialize our asm_data\*--------------------------------------------------------------------*/ asm_data.app_data = app_data; asm_data.action = (ProTestAsmTravAction) action; comp_id_table[0] = -1; status = ProAsmcomppathInit(assembly, comp_id_table, 0, &asm_data.comp_path); TEST_CALL_REPORT("ProAsmcomppathInit()", "ProUtilAsmTraverse()", status, status != PRO_TK_NO_ERROR); /*--------------------------------------------------------------------*\ Visit the components are this level\*--------------------------------------------------------------------*/ ProUtilAsmcompVisit(assembly, (ProFunction) ProUtilAsmTravAction, (ProAppData)&asm_data); return(PRO_TK_NO_ERROR);}/*====================================================================*\ FUNCTION : ProUtilAsmcompFilterAction() PURPOSE : A filter used by ProUtilAsmCompVisit() to visit features which are assembly components\*====================================================================*/ProError ProUtilAsmcompFilterAction( ProFeature *feature, ProAppData app_data){ ProError status; ProFeattype ftype;/*--------------------------------------------------------------------*\ Get the feature type\*--------------------------------------------------------------------*/ status = ProFeatureTypeGet(feature, &ftype);/*--------------------------------------------------------------------*\ If the feature is an assembly component,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -