/*===========================================================================*\ FILE: TestCollect.c PURPOSE: HISTORY: 15-May-97 H-03-11 Alexey $$1 Created 06-Oct-97 H-03-25 Pavel $$2 More includes 17-Oct-97 H-03-27 Pavel $$3 Used ProUtilElemtreeElementArrayFree 20-Jan-98 H-03-37 aab $$4 type casting for c++ compiler 01-Jul-98 I-01-13 akh $$5 Fix for PT/Modeler \*===========================================================================*/ /*---------------------------------------------------------------------------*\ Headers \*---------------------------------------------------------------------------*/ #include "ProToolkit.h" #include "ProEdge.h" #include "ProTool.h" #include "prodevelop.h" #include "prodevdim.h" #include #include #include #include #include "ProMenu.h" #include "TestError.h" #include "ProMessage.h" #include "ProUtil.h" #include "UtilCollect.h" #include "TestCollect.h" /*---------------------------------------------------------------------------*\ Macros \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ Data types \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ Global variables \*---------------------------------------------------------------------------*/ static wchar_t w_msg_file[ PRO_PATH_SIZE ]; static FILE *fp_out = NULL; static struct object_type_name { char *p_name; /*ProType*/int type; } object_type_name[] = { { "PRO_TYPE_UNUSED", PRO_TYPE_UNUSED }, { "PRO_ASSEMBLY", PRO_ASSEMBLY }, { "PRO_PART", PRO_PART }, { "PRO_FEATURE", PRO_FEATURE }, { "PRO_DRAWING", PRO_DRAWING }, { "PRO_SURFACE", PRO_SURFACE }, { "PRO_EDGE", PRO_EDGE }, { "PRO_3DSECTION", PRO_3DSECTION }, { "PRO_DIMENSION", PRO_DIMENSION }, { "PRO_2DSECTION", PRO_2DSECTION }, { "PRO_LAYOUT", PRO_LAYOUT }, { "PRO_AXIS", PRO_AXIS }, { "PRO_CSYS", PRO_CSYS }, { "PRO_REF_DIMENSION", PRO_REF_DIMENSION }, { "PRO_GTOL", PRO_GTOL }, { "PRO_DWGFORM", PRO_DWGFORM }, { "PRO_SUB_ASSEMBLY", PRO_SUB_ASSEMBLY }, { "PRO_MFG", PRO_MFG }, { "PRO_QUILT", PRO_QUILT }, { "PRO_CURVE", PRO_CURVE }, { "PRO_POINT", PRO_POINT }, { "PRO_NOTE", PRO_NOTE }, { "PRO_IPAR_NOTE", PRO_IPAR_NOTE }, { "PRO_EDGE_START", PRO_EDGE_START }, { "PRO_EDGE_END", PRO_EDGE_END }, { "PRO_CRV_START", PRO_CRV_START }, { "PRO_CRV_END", PRO_CRV_END }, { "PRO_SYMBOL_INSTANCE", PRO_SYMBOL_INSTANCE }, { "PRO_DRAFT_ENTITY", PRO_DRAFT_ENTITY }, { "PRO_REPORT", PRO_REPORT }, { "PRO_MARKUP", PRO_MARKUP }, { "PRO_SKETCH_ENTITY", PRO_SKETCH_ENTITY }, { "PRO_COMP_CRV", PRO_COMP_CRV }, { "PRO_PARAMETER", PRO_PARAMETER }, { "PRO_DIAGRAM_WIRE", PRO_DIAGRAM_WIRE }, { "PRO_SIMP_REP", PRO_SIMP_REP }, { "PRO_EXTOBJ", PRO_EXTOBJ }, { "PRO_CONTOUR", PRO_CONTOUR }, { "PRO_GROUP", PRO_GROUP }, { "PRO_FAMILY_TABLE", PRO_FAMILY_TABLE }, { NULL, 0 } }; static struct surface_type_name { char *p_name; /*ProSrftype*/int type; } surface_type_name[] = { { "PRO_SRF_NONE", PRO_SRF_NONE }, { "PRO_SRF_PLANE", PRO_SRF_PLANE }, { "PRO_SRF_CYL", PRO_SRF_CYL }, { "PRO_SRF_CONE", PRO_SRF_CONE }, { "PRO_SRF_TORUS", PRO_SRF_TORUS }, { "PRO_SRF_COONS", PRO_SRF_COONS }, { "PRO_SRF_SPL", PRO_SRF_SPL }, { "PRO_SRF_FIL", PRO_SRF_FIL }, { "PRO_SRF_RUL", PRO_SRF_RUL }, { "PRO_SRF_REV", PRO_SRF_REV }, { "PRO_SRF_TABCYL", PRO_SRF_TABCYL }, { "PRO_SRF_B_SPL", PRO_SRF_B_SPL }, { "PRO_SRF_FOREIGN",PRO_SRF_FOREIGN }, { "PRO_SRF_CYL_SPL",PRO_SRF_CYL_SPL }, { NULL, 0 } }; static struct feature_status_name { char *p_name; /*ProFeatStatus*/int type; } feature_status_name[] = { { "PRO_FEAT_INVALID", PRO_FEAT_INVALID }, { "PRO_FEAT_ACTIVE", PRO_FEAT_ACTIVE }, { "PRO_FEAT_INACTIVE", PRO_FEAT_INACTIVE }, { "PRO_FEAT_FAMTAB_SUPPRESSED", PRO_FEAT_FAMTAB_SUPPRESSED }, { "PRO_FEAT_SIMP_REP_SUPPRESSED", PRO_FEAT_SIMP_REP_SUPPRESSED }, { "PRO_FEAT_PROG_SUPPRESSED", PRO_FEAT_PROG_SUPPRESSED }, { "PRO_FEAT_SUPPRESSED", PRO_FEAT_SUPPRESSED }, { "PRO_FEAT_UNREGENERATED", PRO_FEAT_UNREGENERATED }, { NULL, 0 } }; static struct edge_type_name { char *p_name; /*ProEnttype*/int type; } edge_type_name[] = { { "PRO_ENT_NONE", PRO_ENT_NONE }, { "PRO_ENT_POINT", PRO_ENT_POINT }, { "PRO_ENT_LINE", PRO_ENT_LINE }, { "PRO_ENT_ARC", PRO_ENT_ARC }, { "PRO_ENT_TXT", PRO_ENT_TXT }, { "PRO_ENT_ARROW", PRO_ENT_ARROW }, { "PRO_ENT_CIRCLE", PRO_ENT_CIRCLE }, { "PRO_ENT_SPLINE", PRO_ENT_SPLINE }, { "PRO_ENT_B_SPLINE", PRO_ENT_B_SPLINE }, { "PRO_ENT_ELLIPSE", PRO_ENT_ELLIPSE }, { "PRO_ENT_POLYGON", PRO_ENT_POLYGON }, { "PRO_ENT_CMP_CRV", PRO_ENT_CMP_CRV }, { NULL, 0 } }; static struct tool_type_name { char *p_name; /*ProToolType*/int type; } tool_type_name[] = { { "PRO_TOOL_NONE" , PRO_TOOL_NONE }, { "PRO_TOOL_DRILL", PRO_TOOL_DRILL }, { "PRO_TOOL_TURN", PRO_TOOL_TURN }, { "PRO_TOOL_SAW" , PRO_TOOL_SAW }, { "PRO_TOOL_MILL" , PRO_TOOL_MILL }, { "PRO_TOOL_GROOVE" , PRO_TOOL_GROOVE }, { "PRO_TOOL_NIBBLE" , PRO_TOOL_NIBBLE }, { "PRO_TOOL_PUNCH", PRO_TOOL_PUNCH }, { "PRO_TOOL_AUXILIARY" , PRO_TOOL_AUXILIARY }, { "PRO_TOOL_FORM" , PRO_TOOL_FORM }, { "PRO_TOOL_PUNPNT" , PRO_TOOL_PUNPNT }, { "PRO_TOOL_AREA_NIB" , PRO_TOOL_AREA_NIB }, { "PRO_TOOL_MFG_REFINE" , PRO_TOOL_MFG_REFINE }, { "PRO_TOOL_BORE" , PRO_TOOL_BORE }, { "PRO_TOOL_TAP" , PRO_TOOL_TAP }, { "PRO_TOOL_CSINK" , PRO_TOOL_CSINK }, { "PRO_TOOL_REAM", PRO_TOOL_REAM }, { "PRO_TOOL_CENTER_DRL" , PRO_TOOL_CENTER_DRL }, { "PRO_TOOL_TURN_GRV" , PRO_TOOL_TURN_GRV }, { "PRO_TOOL_MILL_THREAD", PRO_TOOL_MILL_THREAD }, { "PRO_TOOL_TURN_THREAD" , PRO_TOOL_TURN_THREAD }, { "PRO_TOOL_SHEAR" , PRO_TOOL_SHEAR }, { "PRO_TOOL_SIDE_MILL" , PRO_TOOL_SIDE_MILL }, { "PRO_TOOL_CMM_FIXED" , PRO_TOOL_CMM_FIXED }, { "PRO_TOOL_CMM_ROTATED" , PRO_TOOL_CMM_ROTATED }, { "PRO_TOOL_BACK", PRO_TOOL_BACK }, { NULL, 0 } }; /*=========================================================================*\ File: TestCollect.c Function: ProTestCollection() Purpose: On button function. Returns: 0 if successful, non-zero otherwise. \*=========================================================================*/ int ProTestCollection( ProAppData p_appdata, int int_dummy) { ProError status; int dummy; ProStringToWstring( w_msg_file, "gen_msg.txt" ); fp_out = fopen( DAT_FILE_NAME, "a" ); if( fp_out == NULL ) fp_out = stderr; status = ProMenuFileRegister( "COLLECTION", "collection.mnu", &dummy ); if( status != PRO_TK_NO_ERROR ) return -1; ProMenubuttonActionSet( "COLLECTION", "Animation", (ProMenubuttonAction)ProTestCollectAnimation, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Solid Csys", (ProMenubuttonAction)ProTestCollectSolidCsys, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Solid Axis", (ProMenubuttonAction)ProTestCollectSolidAxis, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Solid Quilts", (ProMenubuttonAction)ProTestCollectSolidQuilts, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Solid Surfaces", (ProMenubuttonAction)ProTestCollectSolidSurfaces, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Simp Reps", (ProMenubuttonAction)ProTestCollectSolidSimpreps, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Solid Features", (ProMenubuttonAction)ProTestCollectSolidFeatures, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Model Notes", (ProMenubuttonAction)ProTestCollectModelNotes, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Mfg Tools", (ProMenubuttonAction)ProTestCollectMfgTools, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Feature Geomitems", (ProMenubuttonAction)ProTestCollectFeatureGeomitems, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Elements", (ProMenubuttonAction)ProTestCollectElemtreeElements, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Curve Comps", (ProMenubuttonAction)ProTestCollectCurveComponents, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Contours", (ProMenubuttonAction)ProTestCollectContours, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Extobj", (ProMenubuttonAction)ProTestCollectExtobj, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Find By Name", (ProMenubuttonAction)ProTestFindByName, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Axis By Plane", (ProMenubuttonAction)ProTestCollectSolidAxisByPlane, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Dimensions", (ProMenubuttonAction)ProTestCollectDimensions, p_appdata, 0 ); ProMenubuttonActionSet( "COLLECTION", "Done Collect", (ProMenubuttonAction)ProMenuDelete, NULL, 0 ); ProMenubuttonActionSet( "COLLECTION", "COLLECTION", (ProMenubuttonAction)ProMenuDelete, NULL, 0 ); ProMenuCreate( PROMENUTYPE_MAIN, "COLLECTION", &dummy ); ProMenuProcess( "COLLECTION", &dummy ); fclose( fp_out ); return (0); } /*=========================================================================*\ File: TestCollect.c Function: ProTestCollectAnimation() Purpose: On button function. Returns: 0 if successful, non-zero otherwise. \*=========================================================================*/ int ProTestCollectAnimation( ProAppData p_appdata, int int_dummy ) { ProError status; ProMatrix m_frame_view; ProMatrix m_transform; ProAnimFrame anim_frame; ProAnimObj anim_object; ProSelection *p_selection; int n_selected = 0; ProMdl model; ProModelitem model_item; int i_frame; int i_obj; double add_angle, angle; ProAnimMovie animation_movie; ProAnimFrame *p_frames; int n_frames; ProAnimObj *p_objs; int n_objs; int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { if (i == j) { m_frame_view[i][j] = 1.0; m_transform[i][j] = 1.0; } else { m_frame_view[i][j] = 0.0; m_transform[i][j] = 0.0; } } } /* Print the header */ fprintf( fp_out, "\n# Animation frames & objects\n" ); /* Select objects to animate */ ProMessageDisplay( w_msg_file, "TEST %0s", "Select objects to animate" ); status = ProSelect( "part", -1, NULL, NULL, NULL, NULL, &p_selection, &n_selected ); if( (status != PRO_TK_NO_ERROR) || (n_selected < 1) ) return -1; /* Get the model item from a selection object. */ status = ProSelectionModelitemGet( p_selection[0], &model_item ); TEST_CALL_REPORT( "ProSelectionModelitemGet()", "ProTestCollectAnimation()", status, status != PRO_TK_NO_ERROR); if( status == PRO_TK_NO_ERROR ) { /* Retrieve the model the owns the specified item. */ status = ProModelitemMdlGet( &model_item, &model ); TEST_CALL_REPORT( "ProModelitemMdlGet()", "ProTestCollectAnimation()", status, status != PRO_TK_NO_ERROR); } if( status != PRO_TK_NO_ERROR ) return -1; /* Create the anim movie */ status = ProAnimmovieCreate( model, &animation_movie ); TEST_CALL_REPORT( "ProAnimmovieCreate()", "ProTestCollectAnimation()", status, status != PRO_TK_NO_ERROR); if( status != PRO_TK_NO_ERROR ) return -1; /* Init rotate angle */ angle = 0.0; add_angle = 360.0; add_angle /= (double)FRAME_NUM; /* Create animation objects and add it to the frames, add frames to movie*/ for( i_frame=0; i_frameobj_type ) ); status = ProGeomitemdataFree( &p_geomitem_data ); TEST_CALL_REPORT( "ProGeomitemdataFree()", "ProTestCollectFeatureGeomitems()", status, status != PRO_TK_NO_ERROR); } status = ProArrayFree( (ProArray*)&p_geomitems ); TEST_CALL_REPORT( "ProArrayFree()", "ProTestCollectFeatureGeomitems()", status, status != PRO_TK_NO_ERROR); } return status; } /*=========================================================================*\ File: TestCollect.c Function: ProUtilGeomitemTypeToString() Purpose: Return the string with geometry item type Returns: Geometry item type name \*=========================================================================*/ char *ProUtilGeomitemTypeToString( ProType item_type ) { int i; for( i=0; object_type_name[i].p_name != NULL; i++ ) if( object_type_name[i].type == item_type ) return object_type_name[i].p_name; return "unknown"; } /*=========================================================================*\ File: TestCollect.c Function: ProTestCollectElemtreeElements() Purpose: On button function. Test element tree elements collection. Returns: 0 if successful, non-zero otherwise. \*=========================================================================*/ int ProTestCollectElemtreeElements( ProAppData p_appdata, int int_dummy ) { ProError status; ProSelection *p_selection; int n_selected = 0; ProFeature feature; ProElement p_elem_tree; ElemtreeElement *p_elements; ProElemId element_id; ProValue p_value; int n; int i; /* Print the header */ fprintf( fp_out, "\n# Elements\n" ); /* Select model */ ProMessageDisplay( w_msg_file, "TEST %0s", "Select the feature" ); status = ProSelect( "feature", 1, NULL, NULL, NULL, NULL, &p_selection, &n_selected ); TEST_CALL_REPORT( "ProSelect()", "ProTestCollectElemtreeElements()", status, status != PRO_TK_NO_ERROR); if( (status != PRO_TK_NO_ERROR) || (n_selected != 1) ) return -1; /* Get selected feature */ if( ProSelectionModelitemGet( p_selection[0], &feature ) != PRO_TK_NO_ERROR ) return -1; status = ProFeatureElemtreeCreate( &feature, &p_elem_tree ); TEST_CALL_REPORT( "ProFeatureElemtreeCreate()", "ProTestCollectElemtreeElements()", status, status != PRO_TK_NO_ERROR); if( status == PRO_TK_NO_ERROR ) /* Get feature elements */ status = ProUtilCollectElemtreeElements( p_elem_tree, NULL, &p_elements ); /* Print out obtained elements */ if( status == PRO_TK_NO_ERROR ) { /* Get the array size */ n = 0; status = ProArraySizeGet( p_elements, &n ); TEST_CALL_REPORT( "ProArraySizeGet()", "ProTestCollectElemtreeElements()", status, status != PRO_TK_NO_ERROR); /* Print out the elements array */ fprintf( fp_out, "Number of elements:\t%d\n", n ); for( i=0; i