/*====================================================================*\ FILE : TestImportfeat.c PURPOSE : Test functions for Pro/TOOLKIT ProImportfeat HISTORY.. DATE BUILD AUTHOR MODIFICATIONS h-01-14 Pavel $$1 Created 22-Jun-97 H-03-15 Pavel $$2 Updated 1-Jul-97 H-03-16 Pavel $$3 Fixed TEST_CALL_REPORT 10-Jul-97 H-03-16 Pavel $$4 Modified option in ProPartToIntfData 11-Jul-97 H-03-17 Pavel $$5 Fixed param in ProImportfeatRedefSourceInit 14-Aug-97 H-03-18 Alexey $$6 Arguments of ProImportfeatItemIdToUserId() are changed in ProImportfeat.h 06-Oct-97 H-03-25 Pavel $$7 Fix warnings 20-Aug-97 H-03-27 Pavel $$8 Added datum support 02-Dec-97 H-03-35 Pavel $$9 added edge creation type 09-Mar-98 H-03-40 Pavel $$10 Updated 20-Mar-98 H-03-41+ AEY $$11 Set option values for curve_representation and surface_representation in ProTestImportfeat(). 01-Jul-98 I-01-13 AKH $$12 Added support for PT/Products Toolkit 13-AUg-98 h-03-52 Rodi $$13 Used ProSurfacedataMemoryFree ProQuiltdataMemoryFree ProEdgedataMemoryFree 12-Oct-98 I-01-21 AEY $$14 Fixed call ProImportfeatRedefSourceInit(). 09-Nov-98 I-01-26 Pavel $$15 Add menu Surface & curve convertions options. Replaced some ProMenu functions by ProUtilMenu 07-Dec-98 I-01-27 Alexey $$16 Corrected TEST_CALL_REPORT, fixed calls to ProDatumdataFree(). 14-Dec-98 I-01-28 mka $$17 Corrected TEST_CALL_REPORT, fixed calls to ProImportfeatRedefine() 14-Jul-99 I-03-11 Alexey $$18 For ProTestRedefImpfeat declare impfeatattr as ProImportfeatAttr instead of int 30-Jul-99 I-03-12 Alexey $$19 To use Add Solid option cut_or_add should be set to 0. \*====================================================================*/ /*--------------------------------------------------------------------*\ Pro/TOOLKIT includes \*--------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include #include #include /*--------------------------------------------------------------------*\ C System includes \*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include "TestError.h" #include "UtilMenu.h" #include "UtilMessage.h" #define NEW_PART_NAME "new_impfeat_part" #define UV_POINTS 1 #define UV_CURVES 2 #define XYZ_CURVE 4 #define JOIN_SURFACES 1 #define MAKE_SOLID 2 #define ADD_SOLID 4 static int cr_type = UV_POINTS | UV_CURVES | XYZ_CURVE; static ProImportfeatAttr impfeatattr = { 1, 1, 0 }; static ProPartConversionOptions opt = { {1, 1, 1}, PRO_PART_CURVES_AS_DEFAULT, PRO_PART_SURFACES_AS_DEFAULT }; /*====================================================================*\ FUNCTION : ProUtilIntfTypeToStr() PURPOSE : convert ProIntfType to str \*====================================================================*/ char * ProUtilIntfTypeToStr(ProIntfType type) { int i; static struct intf_type_str { ProIntfType type; char *str; } tab[] = { {PRO_INTF_NONE, "PRO_INTF_NONE"}, {PRO_INTF_NEUTRAL, "PRO_INTF_NEUTRAL"}, {PRO_INTF_NEUTRAL_FILE, "PRO_INTF_NEUTRAL_FILE"}, {PRO_INTF_IGES, "PRO_INTF_IGES"}, {PRO_INTF_STEP, "PRO_INTF_STEP"}, {PRO_INTF_VDA, "PRO_INTF_VDA"}, {PRO_INTF_SET, "PRO_INTF_SET"}, {PRO_INTF_PDGS, "PRO_INTF_PDGS"}, {PRO_INTF_CATIA, "PRO_INTF_CATIA"}, {PRO_INTF_NONE, "UNKNOWN"} }; for (i=0; iIId " "IId->UId\n"); for (i=0; isurface_representation, PRO_PART_SURFACES_AS_DEFAULT ); ProMenubuttonActionSet( "TkSurfCreat", "Spl as BSpl", (ProMenubuttonAction)ProUtilSurfaceMenuAction, (ProAppData)&p_opts->surface_representation, PRO_PART_SPL_SURFACES_AS_BSPL_SURFACES ); ProMenubuttonActionSet( "TkSurfCreat", "Srf as BSpl", (ProMenubuttonAction)ProUtilSurfaceMenuAction, (ProAppData)&p_opts->surface_representation, PRO_PART_SURFACES_AS_BSPL_SURFACES ); ProMenubuttonActionSet( "TkSurfCreat", "TkSurfCreat", (ProMenubuttonAction)ProMenuHold, NULL, 0 ); status = ProMenuFileRegister( "TkCurvCreat", "tkcurvcreat.mnu", &menu_id ); ProMenubuttonActionSet( "TkCurvCreat", "Default Curve", (ProMenubuttonAction)ProUtilSurfaceMenuAction, (ProAppData)&p_opts->curve_representation, PRO_PART_CURVES_AS_DEFAULT ); ProMenubuttonActionSet( "TkCurvCreat", "Spl as BSpl", (ProMenubuttonAction)ProUtilSurfaceMenuAction, (ProAppData)&p_opts->curve_representation, PRO_PART_SPLINES_AS_BSPLINES ); ProMenubuttonActionSet( "TkCurvCreat", "Curve as BSpl", (ProMenubuttonAction)ProUtilSurfaceMenuAction, (ProAppData)&p_opts->curve_representation, PRO_PART_CURVES_AS_BSPLINES ); ProMenubuttonActionSet( "TkCurvCreat", "TkCurvCreat", (ProMenubuttonAction)ProMenuHold, NULL, 0 ); status = ProMenuModeSet ("TkEdgeCreat", PROMENUMODE_DATA); TEST_CALL_REPORT( "ProMenuModeSet()", "ProTestSelectEdgeCreationType()", status, status != PRO_TK_NO_ERROR ); status = ProMenuDatamodeSet ("TkEdgeCreat", PRO_B_TRUE); TEST_CALL_REPORT( "ProMenuDatamodeSet()", "ProTestSelectEdgeCreationType()", status, status != PRO_TK_NO_ERROR ); status = ProMenuFileRegister("DONE","tketdone.mnu", &menu_id); TEST_CALL_REPORT("ProMenuFileRegister()", "ProTestSelectEdgeCreationType()", status , status != PRO_TK_NO_ERROR); status = ProMenubuttonActionSet("DONE","-Done", (ProMenubuttonAction)ProUtilMenuKill, NULL, 4); status = ProMenubuttonActionSet("DONE","DONE", (ProMenubuttonAction)ProMenuHold,NULL,0); status = ProCompoundmenuCreate(cmpnd_menu, &menu_id); TEST_CALL_REPORT("ProCompoundmenuCreate()", "ProTestSelectEdgeCreationType()", status , status != PRO_TK_NO_ERROR); cr_type = 0; if (opt.edge_representation.uv_points) cr_type |= UV_POINTS; if (opt.edge_representation.uv_curves) cr_type |= UV_CURVES; if (opt.edge_representation.xyz_curve) cr_type |= XYZ_CURVE; ProUtilMenubuttonHighlight ("TkEdgeCreat", "UV points", cr_type& UV_POINTS); ProUtilMenubuttonHighlight ("TkEdgeCreat", "UV curves", cr_type& UV_CURVES); ProUtilMenubuttonHighlight ("TkEdgeCreat", "XYZ curve", cr_type& XYZ_CURVE); ProUtilMenubuttonHighlight ("TkSurfCreat", "Default Surf", 1); ProUtilMenubuttonHighlight ("TkCurvCreat", "Default Curve", 1); if( status == PRO_TK_NO_ERROR ) { status = ProMenuProcess( "TkEdgeCreat", &action ); TEST_CALL_REPORT( "ProMenuProcess()", "ProTestSelectEdgeCreationType()", status, status != PRO_TK_NO_ERROR ); } opt.edge_representation.uv_points = (cr_type & UV_POINTS) && 1; opt.edge_representation.uv_curves = (cr_type & UV_CURVES) && 1; opt.edge_representation.xyz_curve = (cr_type & XYZ_CURVE) && 1; } /*====================================================================*\ FUNCTION : ProTestImportfeat() PURPOSE : Commands for testing import feature in Pro/TOOLKIT \*====================================================================*/ void ProTestSelectIntfType( ProIntfType *type) { ProError err; int action; static ProUtilMenuButtons intf_type[] = { {"TkIntfType", 0, TEST_CALL_PRO_MENU_DELETE}, {"Neutral", PRO_INTF_NEUTRAL, 0}, {"Neutral File", PRO_INTF_NEUTRAL_FILE, 0}, {"Iges File", PRO_INTF_IGES, 0}, {"Step File", PRO_INTF_STEP, 0}, {"Vda File", PRO_INTF_VDA, 0}, {"Set File", PRO_INTF_SET, 0}, {"PDGS File", PRO_INTF_PDGS, 0}, {"CATIA File",PRO_INTF_CATIA , 0}, {"",0,0} }; err = ProUtilMenuIntValueSelect(intf_type, &action); if (err != PRO_TK_NO_ERROR) *type = PRO_INTF_NONE; else *type = (ProIntfType)action; } /*====================================================================*\ FUNCTION : ProTestImportfeat() PURPOSE : Commands for testing import feature in Pro/TOOLKIT \*====================================================================*/ int ProTestImportfeat(ProMdl *mdl) { ProError err; ProIntfType intf_type; ProIntfDataSourceType intfdatasrc_type; ProPart part = *mdl, new_part; ProIntfDataSource id_source; ProIntfData *id_data = NULL; int cont = 1, w_id; ProName w_name, w_file_name; ProFeature feat; ProImportfeatRedefSource redef_source; ProImportfeatRedefSourceType redefsourcetype; char part_name[PRO_NAME_SIZE]; void *vp; ProTestSelectIntfType(&intf_type); if (intf_type == PRO_INTF_NONE) return (0); if (intf_type == PRO_INTF_NEUTRAL) { ProTestSelectEdgeCreationType (&opt); } ProUtilMsgPrint("gen", "TEST %0s", "Enter new part name."); ProStringToWstring(w_name, NEW_PART_NAME); ProUtilStringGet(w_name, w_name, PRO_NAME_SIZE); err = ProSolidCreate(w_name, PRO_PART, &new_part); TEST_CALL_REPORT("ProSolidCreate()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); do { intfdatasrc_type = ProIntfTypeToIntfDataSourceType(intf_type); TEST_CALL_REPORT(" ProIntfTypeToIntfDataSourceType()", "ProTestImportfeat()", 0, 0); if (intfdatasrc_type == PRO_INTF_DATA_SOURCE_NONE) break; if (intfdatasrc_type == PRO_INTF_DATA_SOURCE_FILE) { ProUtilMsgPrint("gen", "TEST %0s", "Enter the import file name."); if (ProUtilStringGet(w_file_name, NULL, PRO_NAME_SIZE) == 0) break; vp = (void*)w_file_name; } else { err = ProIntfDataAlloc(&id_data); TEST_CALL_REPORT("ProIntfDataAlloc()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); err = ProPartToProIntfData(part, &opt, id_data); TEST_CALL_REPORT("ProPartToProIntfData()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) break; err = ProUtilIntfDataCopy(&id_data); if (err != PRO_TK_NO_ERROR) break; vp = (void*)id_data; } err = ProIntfDataSourceInit( intf_type, vp, &id_source); TEST_CALL_REPORT("ProIntfDataSourceInit()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) break; err = ProImportfeatCreate(new_part, &id_source, NULL, NULL, &feat); TEST_CALL_REPORT("ProImportfeatCreate()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); if (err != PRO_TK_NO_ERROR) break; #ifndef PT_PRODUCTS_BUILD err = ProObjectwindowCreate(w_name, PRO_PART, &w_id); TEST_CALL_REPORT("ProObjectwindowCreate()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); err = ProMdlDisplay((ProMdl)new_part); TEST_CALL_REPORT("ProMdlDisplay()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); err = ProWindowActivate(w_id); TEST_CALL_REPORT("ProWindowActivate()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); #endif if (id_data != NULL) { err = ProImportfeatRedefSourceInit(PRO_IMPORT_FEAT_REDEF_SUBSTITUTE, (void*)&id_source, &redef_source); TEST_CALL_REPORT("ProImportfeatRedefSourceInit()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); redefsourcetype = ProImportfeatRedefSourceTypeGet( PRO_IMPORT_FEAT_REDEF_SUBSTITUTE); TEST_CALL_REPORT("ProImportfeatRedefSourceTypeGet()", "ProTestImportfeat()", 0, 0); err = ProImportfeatRedefine(&feat, &redef_source); TEST_CALL_REPORT("ProImportfeatRedefine()", "ProTestImportfeat()", err, (err != PRO_TK_NO_ERROR)&& (err != PRO_TK_NOT_IMPLEMENTED)); } ProUtilImportfeatInfoPrint(&feat); } while (!cont); if (id_data != NULL) { err = ProIntfDataFree(id_data); TEST_CALL_REPORT("ProIntfDataFree()", "ProTestImportfeat()", err, err != PRO_TK_NO_ERROR); } return (0); } /*====================================================================*\ FUNCTION : ProUtilImportfeatFilter() PURPOSE : Allows to collect only import features \*====================================================================*/ ProError ProUtilImportfeatFilter( ProFeature *p_feature) { ProError err; ProFeattype feattype; err = ProFeatureTypeGet(p_feature, &feattype); TEST_CALL_REPORT( " ProFeatureTypeGet()", " ProUtilImportfeatFilter()", err, err != PRO_TK_NO_ERROR ); return (err == PRO_TK_NO_ERROR && feattype == PRO_FEAT_IMPORT ? PRO_TK_NO_ERROR : PRO_TK_CONTINUE); } int ProTestImpfeatAttrMenuAction( ProAppData data, int action ) { ProImportfeatAttr *p_attrs = (ProImportfeatAttr*)data; switch( action ) { case JOIN_SURFACES: p_attrs->join_surfaces = p_attrs->join_surfaces ? 0 : 1; break; case MAKE_SOLID: p_attrs->attempt_make_solid = p_attrs->attempt_make_solid ? 0 : 1; break; case ADD_SOLID: p_attrs->cut_or_add = p_attrs->cut_or_add ? 0 : 1; break; } return 0; } /*====================================================================*\ FUNCTION : ProTestRedefImpfeat() PURPOSE : Commands for testing import feature in Pro/TOOLKIT \*====================================================================*/ int ProTestRedefImpfeat(ProMdl *mdl) { ProError err; ProFeature *p_feats; ProImportfeatRedefSource redef_source; int menu_id, action; static char *cmpnd_menu[] = {"TkImpfeatAttr","DONE",""}; err = ProUtilCollectSolidFeaturesWithFilter((ProSolid)*mdl, (ProFeatureFilterAction)ProUtilImportfeatFilter, &p_feats); if (err != PRO_TK_NO_ERROR) { ProUtilMsgPrint("gen", "TEST %0s", "No Import feats found."); return (0); } err = ProMenuFileRegister( "TkImpfeatAttr", "tkimpfeatattr.mnu", &menu_id ); TEST_CALL_REPORT( "ProMenuFileRegister()", "ProTestRedefImpfeate()", err, err != PRO_TK_NO_ERROR ); ProMenubuttonActionSet( "TkImpfeatAttr", "TkImpfeatAttr", (ProMenubuttonAction)ProMenuDelete, NULL, 0); ProMenubuttonActionSet( "TkImpfeatAttr", "Join Surfaces", (ProMenubuttonAction)ProTestImpfeatAttrMenuAction, (ProAppData)&impfeatattr, JOIN_SURFACES ); ProMenubuttonActionSet( "TkImpfeatAttr", "Make Solid", (ProMenubuttonAction)ProTestImpfeatAttrMenuAction, (ProAppData)&impfeatattr, MAKE_SOLID); ProMenubuttonActionSet( "TkImpfeatAttr", "Add Solid", (ProMenubuttonAction)ProTestImpfeatAttrMenuAction, (ProAppData)&impfeatattr, ADD_SOLID); err = ProMenuModeSet ("TkImpfeatAttr", PROMENUMODE_DATA); TEST_CALL_REPORT( "ProMenuModeSet()", "ProTestRedefImpfeate()", err, err != PRO_TK_NO_ERROR ); err = ProMenuDatamodeSet ("TkImpfeatAttr", PRO_B_TRUE); TEST_CALL_REPORT( "ProMenuDatamodeSet()", "ProTestRedefImpfeat()", err, err != PRO_TK_NO_ERROR ); err = ProMenuFileRegister("DONE","tketdone.mnu", &menu_id); err = ProMenubuttonActionSet("DONE","-Done", (ProMenubuttonAction)ProUtilMenuKill, NULL, 2); err = ProMenubuttonActionSet("DONE","DONE", (ProMenubuttonAction)ProMenuHold,NULL,0); err = ProCompoundmenuCreate(cmpnd_menu, &menu_id); TEST_CALL_REPORT("ProCompoundmenuCreate()", "ProTestRedefImpfeat()", err, err != PRO_TK_NO_ERROR ); ProUtilMenubuttonHighlight ("TkImpfeatAttr", "Join Surfaces", impfeatattr.join_surfaces); ProUtilMenubuttonHighlight ("TkImpfeatAttr", "Make Solid", impfeatattr.attempt_make_solid); ProUtilMenubuttonHighlight ("TkImpfeatAttr", "Add Solid", impfeatattr.cut_or_add); err = ProMenuProcess( "TkImpfeatAttr", &action ); TEST_CALL_REPORT( "ProMenuProcess()", "ProTestRedefImpfeat()", err, err != PRO_TK_NO_ERROR ); err = ProImportfeatRedefSourceInit(PRO_IMPORT_FEAT_REDEF_CHANGE_ATTR, (void*)&impfeatattr, &redef_source); TEST_CALL_REPORT("ProImportfeatRedefSourceInit()", "ProTestRedefImpfeat()", err, err != PRO_TK_NO_ERROR ); err = ProImportfeatRedefine(p_feats, &redef_source); TEST_CALL_REPORT("ProImportfeatRedefine()", "ProTestRedefImpfeat()", err, (err != PRO_TK_NO_ERROR)&& (err !=PRO_TK_NOT_IMPLEMENTED)); err = ProArrayFree((ProArray*)&p_feats); TEST_CALL_REPORT("ProArrayFree()", "ProTestRedefImpfeat()", err, err != PRO_TK_NO_ERROR ); return (0); }