⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcollect.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
📖 第 1 页 / 共 5 页
字号:
/*===========================================================================*\    FILE:	TestCollect.c    PURPOSE:	HISTORY:15-May-97   H-03-11  Alexey  $$1  Created06-Oct-97   H-03-25  Pavel   $$2  More includes17-Oct-97   H-03-27  Pavel   $$3  Used ProUtilElemtreeElementArrayFree20-Jan-98   H-03-37  aab     $$4  type casting for c++ compiler01-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 <stdio.h>#include <string.h>#include <malloc.h>#include <math.h>#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_frame<FRAME_NUM; i_frame++ )    {	/* Create an animation frame */	status = ProAnimframeCreate( m_frame_view, &anim_frame );    	TEST_CALL_REPORT( "ProAnimframeCreate()", "ProTestCollectAnimation()",                                status, status != PRO_TK_NO_ERROR);	if( status != PRO_TK_NO_ERROR )	    break;	/* Add rotation to the transformation matrix */	angle += add_angle;	ProUtilXRot( angle, m_transform );	for( i_obj=0; i_obj<n_selected; i_obj++ )	{	    /* Create an animation object... */	    status = ProAnimobjectCreate( p_selection[i_obj], m_transform, 		&anim_object );    	    TEST_CALL_REPORT( "ProAnimobjectCreate()", 		"ProTestCollectAnimation()",		status, status != PRO_TK_NO_ERROR);	    if( status == PRO_TK_NO_ERROR )	    {		/* ...and add it to the frame */		status = ProAnimframeObjAdd( anim_frame, anim_object );    	    	TEST_CALL_REPORT( "ProAnimframeObjAdd()", 			"ProTestCollectAnimation()",			status, status != PRO_TK_NO_ERROR);	    }	}	status = ProAnimmovieFrameAdd( animation_movie, anim_frame );	TEST_CALL_REPORT( "ProAnimmovieFrameAdd()", "ProTestCollectAnimation()",		status, status != PRO_TK_NO_ERROR);    }    /* Start a batch animation process */    status = ProBatchAnimationStart( animation_movie, NULL, NULL );    TEST_CALL_REPORT( "ProBatchAnimationStart()", "ProTestCollectAnimation()",	status, status != PRO_TK_NO_ERROR);    n_frames = 0;    p_frames = NULL;    status = ProUtilCollectAnimFrames( animation_movie, &p_frames );    if( status == PRO_TK_NO_ERROR )    {	status = ProArraySizeGet( p_frames, &n_frames );    	TEST_CALL_REPORT( "ProArraySizeGet()", "ProTestCollectAnimation()",		status, status != PRO_TK_NO_ERROR);    }    fprintf( fp_out, "Number of anim frames: %d\n", n_frames );    fprintf( fp_out, "Frame #\tNumber of objs in frame\n" );    /* Delete frames */    for( i_frame=0; i_frame<n_frames; i_frame++ )    {	n_objs = 0;	p_objs = NULL;	status = ProUtilCollectAnimObjects( p_frames[i_frame], &p_objs );	if( status == PRO_TK_NO_ERROR )	{	    status = ProArraySizeGet( p_objs, &n_objs );    	    TEST_CALL_REPORT( "ProArraySizeGet()", "ProTestCollectAnimation()",		status, status != PRO_TK_NO_ERROR);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -