/*====================================================================*\ FILE : TestSmtlSurf.c PURPOSE : Test functions for Pro/TOOLKIT Sheetmetal surface type. HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 24-Mar-97 H-03-04 Bojan $$1 Created sheetmetal surface evaluation. 15-Sep-97 H-03-22 Pavel $$2 Replace Pro/D on Pro/E 17-Oct-97 H-03-27 Pavel $$3 Replaced Visit functions by UtilCollect 11-May-98 I-01-07 CHI $$4 fix include \*====================================================================*/ /*--------------------------------------------------------------------*\ Pro/TOOLKIT includes \*--------------------------------------------------------------------*/ #include "ProToolkit.h" #include "ProMdl.h" #include "ProSolid.h" #include "ProSurface.h" #include "ProSheetmetal.h" #include "ProMode.h" /*--------------------------------------------------------------------*\ C System includes \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include #include #include #include #include #include #include /*--------------------------------------------------------------------*\ Application macros \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Application data types \*--------------------------------------------------------------------*/ typedef struct testsmtlsurf { ProMdl *model; FILE *fp; } ProTestSmtlSurf; /*--------------------------------------------------------------------*\ Application prototypes \*--------------------------------------------------------------------*/ ProError ProTestCurveCompAct( ProCurve , ProCurve , int, ProBoolean, ProError, ProAppData); ProError ProTestCurveAct( ProModelitem* , ProError, ProAppData); int ProTestGeomTraverse(ProMdl *, int); /*====================================================================*\ FUNCTION : ProTestSheetmetalTraverse() PURPOSE : Traverse all sheetmetal surfaces. \*====================================================================*/ int ProTestSheetmetalTraverse( ProMdl *model) { ProUtilCname fname; ProTestSmtlSurf app_data; ProError status; FILE *fp; ProSurface *surfaces; int surfaces_num, i; ProError ProTestShtmtlSurfAct(ProSurface surface, ProError instatus, ProAppData tmp_app_data); /*--------------------------------------------------------------------*\ Get the name of the output file \*--------------------------------------------------------------------*/ ProTestQcrName(model, TRAVERSAL, fname); fp = fopen(fname,"w"); if (fp == NULL) return(-1); /*--------------------------------------------------------------------*\ Set up the general data with the model and the file \*--------------------------------------------------------------------*/ app_data.fp = fp; app_data.model = model; /*--------------------------------------------------------------------*\ Set up a header for the output file \*--------------------------------------------------------------------*/ fprintf(fp,"SHEETMETAL SURFACES:\n\n"); fprintf(fp," Id Surface Type \n"); /*--------------------------------------------------------------------*\ Visit all the solid surfaces \*--------------------------------------------------------------------*/ status = ProUtilCollectSolidSurfaces ((ProSolid) *model, &surfaces); if (status == PRO_TK_NO_ERROR) { status = ProArraySizeGet ((ProArray)surfaces, &surfaces_num); TEST_CALL_REPORT( "ProArraySizeGet()", "ProTestShtmtlSurfAct()", status, status != PRO_TK_NO_ERROR ); for (i = 0; i < surfaces_num; i++) { status = ProTestShtmtlSurfAct (surfaces[i], PRO_TK_NO_ERROR, (ProAppData)&app_data); } status = ProArrayFree ((ProArray*)&surfaces); TEST_CALL_REPORT( "ProArrayFree()", "ProTestShtmtlSurfAct()", status, status != PRO_TK_NO_ERROR ); } if (status == PRO_TK_E_NOT_FOUND) fprintf(fp, " -- (No surfaces found) --\n"); fclose(fp); return(0); } /*====================================================================*\ FUNCTION : ProTestShtmtlSurfAct() PURPOSE : General action function for a surface \*====================================================================*/ ProError ProTestShtmtlSurfAct( ProSurface surface, ProError instatus, ProAppData tmp_app_data) { ProTestSmtlSurf *app_data = (ProTestSmtlSurf *) tmp_app_data; ProSmtSurfType smt_surf_type; ProMdl *model; int surf_id; ProError status; FILE *fp; fp = app_data->fp; model = app_data->model; /*--------------------------------------------------------------------*\ Get the surface id. \*--------------------------------------------------------------------*/ status = ProSurfaceIdGet(surface, &surf_id); TEST_CALL_REPORT("ProSurfaceIdGet()", "ProTestShtmtlSurfAct()", status, status != PRO_TK_NO_ERROR); /*--------------------------------------------------------------------*\ Get the sheetmetal surface type. \*--------------------------------------------------------------------*/ status = ProSmtSurfaceTypeGet ((ProPart)(*model), surface, &smt_surf_type); TEST_CALL_REPORT("ProSmtSurfaceTypeGet()", "ProTestShtmtlSurfAct()", status, status != PRO_TK_NO_ERROR); /*--------------------------------------------------------------------*\ Print the id and type of the sheetmetal surface. \*--------------------------------------------------------------------*/ switch (smt_surf_type) { case PRO_SMT_SURF_NON_SMT : fprintf(fp," %d \t %s\n", surf_id, "PRO_SMT_SURF_NON_SMT - surface created by solid feature."); break; case PRO_SMT_SURF_SIDE : fprintf(fp," %d \t %s\n", surf_id, "PRO_SMT_SURF_SIDE - side surface."); break; case PRO_SMT_SURF_FACE : fprintf(fp," %d \t %s\n", surf_id, "PRO_SMT_SURF_FACE - face (green) surface."); break; case PRO_SMT_SURF_OFFSET : fprintf(fp," %d \t %s\n", surf_id, "PRO_SMT_SURF_OFFSET - offset (white) surface."); break; default :; } return(PRO_TK_NO_ERROR); } /*====================================================================*\ FUNCTION : ProTestSheetmetalSurfs() PURPOSE : Command Traversal for listing of all surfaces in a sheetmetal model and evaluation of surface types. \*====================================================================*/ int ProTestSheetmetalSurfs( ProMdl *model, int action) { ProError status; ProMdldata mdata; ProMode curr_mode; ProUtilCname type; /*--------------------------------------------------------------------*\ Find out the current mode (works only in the sheetmetal mode) \*--------------------------------------------------------------------*/ status = ProModeCurrentGet(&curr_mode); TEST_CALL_REPORT("ProModeCurrentGet()", "ProTestSheetmetalSurfs()", status, status != PRO_TK_NO_ERROR); if (curr_mode != PRO_MODE_SHEET_METAL) return(-1); /*--------------------------------------------------------------------*\ Find out the model type \*--------------------------------------------------------------------*/ status = ProMdlDataGet(*model, &mdata); TEST_CALL_REPORT("ProMdlDataGet()", "ProTestSheetmetalSurfs()", status, status != PRO_TK_NO_ERROR); ProWstringToString(type, mdata.type); /*--------------------------------------------------------------------*\ Visit all surfaces in the sheetmetal model. \*--------------------------------------------------------------------*/ if(!ProUtilStrcmp(type, "PRT")) ProTestSheetmetalTraverse(model); return(0); }