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

📄 testcollect.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
📖 第 1 页 / 共 5 页
字号:
		p_trav_str = "External"; 		break;	      default: 		p_trav_str = "Undefined"; 		break;	    }	    /* Print out contour data */	    fprintf( fp_out, "Contour: %s\n", p_trav_str );	    /* Get the contour edges */	    status = ProUtilCollectContourEdges( p_surface, p_contours[i], 		&p_edges );	    /* Print out obtained edges */	    if( status == PRO_TK_NO_ERROR )	    {		/* Get the edges array size */		n_edges = 0;		status = ProArraySizeGet( p_edges, &n_edges );		TEST_CALL_REPORT( "ProArraySizeGet()", 			"ProTestCollectContours()",			status, status != PRO_TK_NO_ERROR);		/* Print out the edges array */		fprintf( fp_out, "\t%d edges: \n", n_edges );		for( j=0; j<n_edges; j++ )		{		    /* Get edge ID */		    edge_id = -1;		    ProEdgeIdGet( p_edges[j], &edge_id );		    /* Get edge length */		    edge_len = 0.0;		    status = ProEdgeLengthEval( p_edges[j], &edge_len );		    TEST_CALL_REPORT( "ProEdgeLengthEval()", 			"ProTestCollectContours()",			status, status != PRO_TK_NO_ERROR);		    /* Get edge type */		    edge_type = (ProEnttype)-1;		    status = ProEdgeTypeGet( p_edges[j], &edge_type );		    TEST_CALL_REPORT( "ProEdgeTypeGet()", 			"ProTestCollectContours()",			status, status != PRO_TK_NO_ERROR);		    /* Print out edge data */		    fprintf( fp_out, "\tID: %d,\tType: %s, \tLen: %f\n", 			edge_id, 			ProUtilEdgeTypeToString( edge_type ),			edge_len );		}		status = ProArrayFree( (ProArray*)&p_edges );		TEST_CALL_REPORT( "ProArrayFree()", 			"ProTestCollectContours()",			status, status != PRO_TK_NO_ERROR);	    }	}	status = ProArrayFree( (ProArray*)&p_contours );	TEST_CALL_REPORT( "ProArrayFree()", 		"ProTestCollectContours()", 		status, status != PRO_TK_NO_ERROR);    }    return status;}/*=========================================================================*\    File:	TestCollect.c    Function:   ProUtilEdgeTypeToString()    Purpose:    Return the string with edge type    Returns:	Edge type name\*=========================================================================*/char *ProUtilEdgeTypeToString(     ProEnttype edge_type    /* In:  Edge type to convert to string */){    int		i;    for( i=0; edge_type_name[i].p_name != NULL; i++ )	if( edge_type_name[i].type == edge_type )	    return edge_type_name[i].p_name;    return "unknown";}/*=========================================================================*\    File:	TestCollect.c    Function:   ProTestCollectExtobj()    Purpose:    On button function. Test extobj collection.    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestCollectExtobj(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProMdl	    p_model;    ProExtobj	    *p_extobjs;    ExtobjReference *p_extobj_refs;    ProExtobjClass  extobj_class;    int		    extobj_ref_type;    int		    n_extobjs;    int		    n_extobj_refs;    int		    i;    int		    j;    /* Print the header */    fprintf( fp_out, "\n# External objects\n" );    p_model = *((ProMdl*)p_appdata);    if( p_model == NULL )    	return -1;    /* Init external object class */    ProStringToWstring( extobj_class.name, "Mechanica" );    extobj_class.type = 0;    /* Get extobj */    status = ProUtilCollectExtobj( p_model, &extobj_class,  &p_extobjs );    /* Print out obtained extobjs */    if( status == PRO_TK_NO_ERROR )    {	/* Get the array size */	n_extobjs = 0;	status = ProArraySizeGet( p_extobjs, &n_extobjs );	TEST_CALL_REPORT( "ProArraySizeGet()", 		"ProTestCollectExtobj()", 		status, status != PRO_TK_NO_ERROR);	/* Print out the extobj array */	fprintf( fp_out, "Number of external objects:\t%d\n", n_extobjs );	for( i=0; i<n_extobjs; i++ )	{	    status = ProUtilCollectExtobjReferences( p_extobjs+i, 		&p_extobj_refs );	    if( status == PRO_TK_NO_ERROR )	    {		/* Get the array size */		n_extobj_refs = 0;		status = ProArraySizeGet( p_extobj_refs, &n_extobj_refs );		TEST_CALL_REPORT( "ProArraySizeGet()", 			"ProTestCollectExtobj()", 			status, status != PRO_TK_NO_ERROR);		/* Print out the extobj refs array */		fprintf( fp_out, "\t%d external object references:\n", 		    n_extobj_refs );		for( j=0; j<n_extobj_refs; j++ )		{		    if( ProExtobjReftypeGet( p_extobj_refs[j].p_extobj_ref,			&extobj_ref_type ) == PRO_TK_NO_ERROR )		    fprintf( fp_out, "\tref type: %d\n", extobj_ref_type );		}		status = ProArrayFree( (ProArray*)&p_extobj_refs );		TEST_CALL_REPORT( "ProArrayFree()", 			"ProTestCollectExtobj()", 			status, status != PRO_TK_NO_ERROR);	    }	}	status = ProArrayFree( (ProArray*)&p_extobjs );	TEST_CALL_REPORT( "ProArrayFree()", 		"ProTestCollectExtobj()", 		status, status != PRO_TK_NO_ERROR);    }    return status;}/*=========================================================================*\    File:	TestCollect.c    Function:   ProTestFindByName()    Purpose:    On button function. Test extobj collection.    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestFindByName(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProSelection    *p_selection;    int		    n_selected = 0;    ProMdl	    p_model;    ProName	    name;    ProModelitem    feature, geomitem;    char	    c_name[PRO_NAME_SIZE];    /* Print the header */    fprintf( fp_out, "\n# Features by name\n" );    p_model = *((ProMdl*)p_appdata);    if( p_model == NULL )    	return -1;    ProMessageDisplay( w_msg_file, "TEST %0s", "Enter feature name" );    if (ProMessageStringRead(PRO_NAME_SIZE, name)!= PRO_TK_NO_ERROR)	return (-1);    /* Find the feature */    status = ProUtilFindFeatvisByName((ProSolid)p_model, name, &feature);    if (status == PRO_TK_NO_ERROR)    {	status = ProModelitemNameGet(&feature, name);	TEST_CALL_REPORT( "ProModelitemNameGet()", 		"ProTestFindByName()", 		status, status != PRO_TK_NO_ERROR);	ProWstringToString(c_name, name);	fprintf(fp_out, "Visible feature found:\t%s\n", c_name);    }    else         fprintf(fp_out, "Feature is not found\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()", 	"ProTestFindByName()", 	status, status != PRO_TK_NO_ERROR);    if( (status != PRO_TK_NO_ERROR) || (n_selected != 1) )	return -1;    ProMessageDisplay( w_msg_file, "TEST %0s", "Enter edge name" );    if (ProMessageStringRead(PRO_NAME_SIZE, name)!= PRO_TK_NO_ERROR)	return (-1);    /* Get selected feature */    status = ProSelectionModelitemGet(p_selection[0], &feature);    TEST_CALL_REPORT( "ProSelectionModelitemGet()", 	"ProTestFindByName()", 	status, status != PRO_TK_NO_ERROR);    /* Find the edge */    status = ProUtilFindFeatureGeomitemByName(&feature,PRO_EDGE,name,&geomitem);    if (status == PRO_TK_NO_ERROR)    {	status = ProModelitemNameGet(&geomitem, name);	TEST_CALL_REPORT( "ProModelitemNameGet()", 		"ProTestFindByName()", 		status, status != PRO_TK_NO_ERROR);	ProWstringToString(c_name, name);	fprintf(fp_out, "Edge found:\t%s\n", c_name);    }    else         fprintf(fp_out, "Edge is not found\n");    return status;}/*=========================================================================*\    File:	TestCollect.c    Function:   ProTestCollectDimensions()    Purpose:    On button function. Test extobj collection.    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestCollectDimensions(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProMdl	    p_model;    int		    *p_dims, n_dims=0;    int		    i;    PRODIMENSION    dimension;    char	    name[PRO_LINE_SIZE];    /* Print the header */    fprintf( fp_out, "\n# Dimensions\n" );    p_model = *((ProMdl*)p_appdata);    if( p_model == NULL )    	return -1;        status = ProUtilCollectDimension(p_model, PRO_DIM_PARAM, -1, &p_dims);    if (status == PRO_TK_NO_ERROR)    {	/* Get the array size */	status = ProArraySizeGet( p_dims, &n_dims );	TEST_CALL_REPORT( "ProArraySizeGet()", "ProTestCollectDimensions()", 		status, status != PRO_TK_NO_ERROR);	/* Print out the dimension array */	fprintf( fp_out, "Number of dimensions:\t%d\n", n_dims );	for( i=0; i<n_dims; i++ )	{	    prodim_get_dimension((char*)p_model, p_dims[i], PRO_DIM_PARAM,		&dimension);	    ProWstringToString(name, dimension.symbol);	    fprintf(fp_out, "Dim %10s %20s %8.2f\n", name, dimension.type, 		dimension.value);	}	status = ProArrayFree( (ProArray*)&p_dims );	TEST_CALL_REPORT( "ProArrayFree()", "ProTestCollectDimensions()", 		status, status != PRO_TK_NO_ERROR);    }    return (PRO_TK_NO_ERROR);}/*=========================================================================*\    File:	TestCollect.c    Function:   ProTestCollectSolidAxisByPlane()    Purpose:    On button function. Test axis collection.    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestCollectSolidAxisByPlane(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProSelection    *p_selection;    int		    n_selected = 0;    ProAxis	    *p_axis;    ProSolid	    p_model;    ProSurface	    surface;    ProGeomitem	    geom_item, modelitem;    ProName	    w_name;    ProCharName	    name;    int		    n;    int		    i;    /* Print the header */    fprintf( fp_out, "\n# Solid axis by plane\n" );    /* Select model */    ProMessageDisplay( w_msg_file, "TEST %0s", "Select the plane" );    status = ProSelect( "surface", 1, NULL, NULL, NULL, NULL, 	&p_selection, &n_selected );    TEST_CALL_REPORT( "ProSelect()", "ProTestCollectSolidAxisByPlane()", 	status, status != PRO_TK_NO_ERROR);    if( (status != PRO_TK_NO_ERROR) || (n_selected != 1) )	return -1;    /* Get selected surface */    status = ProSelectionModelitemGet(p_selection[0], &modelitem);    TEST_CALL_REPORT( "ProSelectionModelitemGet()",     	"ProTestCollectSolidAxisByPlane()", 	status, status != PRO_TK_NO_ERROR );    status = ProGeomitemToSurface(&modelitem, &surface);    TEST_CALL_REPORT( "ProGeomitemToSurface()",     	"ProTestCollectSolidAxisByPlane()", 	status, status != PRO_TK_NO_ERROR );    /* Get solid axis */    p_model = (ProSolid)modelitem.owner;    status = ProUtilCollectSolidAxisByPlane(p_model, surface, 	USER_PARALLEL,  &p_axis);    /* Print out obtained axis */    if( status == PRO_TK_NO_ERROR )    {	/* Get the array size */	n = 0;	status = ProArraySizeGet( p_axis, &n );	TEST_CALL_REPORT( "ProArraySizeGet()",     		"ProTestCollectSolidAxisByPlane()", 		status, status != PRO_TK_NO_ERROR );	/* Print out the axis array */	fprintf( fp_out, "Number solid axis parallel to selected plane:\t%d\n", 		n );	for( i=0; i<n; i++ )	{	    /* Get the axis name */	    ProAxisToGeomitem( p_model, p_axis[i], &geom_item );	    ProModelitemNameGet( &geom_item, w_name );	    ProWstringToString( name, w_name );	    fprintf( fp_out, "%s\n", name );	}	status = ProArrayFree( (ProArray*)&p_axis );	TEST_CALL_REPORT( "ProArrayFree()",     		"ProTestCollectSolidAxisByPlane()", 		status, status != PRO_TK_NO_ERROR );    }    return status;}

⌨️ 快捷键说明

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