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

📄 testcollect.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
📖 第 1 页 / 共 5 页
字号:
    File:	TestCollect.c    Function:   ProTestCollectFeatureGeomitems()    Purpose:    On button function. Test feature geometry items collection.    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestCollectFeatureGeomitems(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProSelection    *p_selection;    int		    n_selected = 0;    ProFeature	    feature;    ProGeomitem	    *p_geomitems;    ProGeomitemdata *p_geomitem_data;    ProName	    w_name;    ProCharName	    name;    int		    n;    int		    i;    /* Print the header */    fprintf( fp_out, "\n# Feature geomitems\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()", "ProTestCollectFeatureGeomitems()",	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;    /* Get solid geomitems */    status = ProUtilCollectFeatureGeomitems( &feature, PRO_TYPE_UNUSED, 	&p_geomitems );    /* Print out obtained geomitems */    if( status == PRO_TK_NO_ERROR )    {	/* Get the array size */	n = 0;	status = ProArraySizeGet( p_geomitems, &n );	TEST_CALL_REPORT( "ProArraySizeGet()", 		"ProTestCollectFeatureGeomitems()",		status, status != PRO_TK_NO_ERROR);	/* Print out the geomitems array */	fprintf( fp_out, "Number of geomitems:\t%d\n", n );	for( i=0; i<n; i++ )	{	    status = ProGeomitemdataGet( p_geomitems+i, &p_geomitem_data );	    TEST_CALL_REPORT( "ProGeomitemdataGet()", 	    	"ProTestCollectFeatureGeomitems()",		status, status != PRO_TK_NO_ERROR);	    status = ProModelitemNameGet( p_geomitems+i, w_name );	    TEST_CALL_REPORT( "ProModelitemNameGet()", 	    	"ProTestCollectFeatureGeomitems()",		status, status != PRO_TK_NO_ERROR);	    ProWstringToString( name, w_name );	    fprintf( fp_out, "%s\t%s\n", name, 		ProUtilGeomitemTypeToString( p_geomitem_data->obj_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<n; i++ )	{	    /* Get element ID */	    status = ProElementIdGet( p_elements[i].p_element, &element_id );	    TEST_CALL_REPORT( "ProElementIdGet()", 		"ProTestCollectElemtreeElements()",		status, status != PRO_TK_NO_ERROR);	    /* Get element value */	    status = ProElementValueGet( p_elements[i].p_element, &p_value );	    TEST_CALL_REPORT( "ProElementValueGet()", 		"ProTestCollectElemtreeElements()",		status, status != PRO_TK_NO_ERROR);	    /* Print out element ID and value */	    fprintf( fp_out, "ID: %d\t- %s\n", element_id, 		ProUtilValueToString( p_value ) );	}	status = ProUtilElemtreeElementArrayFree( &p_elements );    }    return status;}/*=========================================================================*\    File:	TestCollect.c    Function:   ProUtilValueToString()    Purpose:    Convert ProValue to string    Returns:	String with value. It is redefined on subsequent 		calls to this function.\*=========================================================================*/char *ProUtilValueToString( ProValue p_value ){    ProError		status;    ProValueData	value_data;    static ProCharName	value_data_str;    status = ProValueDataGet( p_value, &value_data );    TEST_CALL_REPORT( "ProValueDataGet)", "ProUtilValueToString()",	status, status != PRO_TK_NO_ERROR);    switch( value_data.type )    {      case PRO_VALUE_TYPE_INT:	sprintf( value_data_str, "%d", value_data.v.i );	break;      case PRO_VALUE_TYPE_DOUBLE:	sprintf( value_data_str, "%f", value_data.v.d );	break;      case PRO_VALUE_TYPE_POINTER:	sprintf( value_data_str, "pointer" );	break;      case PRO_VALUE_TYPE_STRING:	sprintf( value_data_str, "%s", value_data.v.s );	break;      case PRO_VALUE_TYPE_WSTRING:	ProWstringToString( value_data_str, value_data.v.w );	break;      case PRO_VALUE_TYPE_SELECTION:	sprintf( value_data_str, "Selection" );	break;      default:	sprintf( value_data_str, "unknown" );    }    return (value_data_str);}/*=========================================================================*\    File:	TestCollect.c    Function:   ProTestCollectCurveComponents()    Purpose:    On button function. Test curve components collection.    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestCollectCurveComponents(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProSelection    *p_selection;    int		    n_selected = 0;    ProCurve	    p_curve;    ProEnttype	    curve_type;    CurveComponent  *p_components;    int		    n;    int		    i;    /* Print the header */    fprintf( fp_out, "\n# Curve components\n" );    /* Select model */    ProMessageDisplay( w_msg_file, "TEST %0s", "Select the composite curve" );    status = ProSelect( "curve", 1, NULL, NULL, NULL, NULL, 	&p_selection, &n_selected );    TEST_CALL_REPORT( "ProSelect()", "ProTestCollectCurveComponents()",	status, status != PRO_TK_NO_ERROR);    if( (status != PRO_TK_NO_ERROR) || (n_selected != 1) )	return -1;    /* Get selected model */    if( ProUtilSelectedCurveGet( p_selection[0], &p_curve ) != PRO_TK_NO_ERROR )	return -1;    /* Selected curve must be composite */    curve_type = (ProEnttype)-1;    status = ProCurveTypeGet( p_curve, &curve_type );    TEST_CALL_REPORT( "ProCurveTypeGet()", "ProTestCollectCurveComponents()",	status, status != PRO_TK_NO_ERROR);    if( curve_type != PRO_ENT_CMP_CRV )	return -1;    /* Get curve components */    status = ProUtilCollectCurveComponents( p_curve, &p_components );    /* Print out obtained components */    if( status == PRO_TK_NO_ERROR )    {	/* Get the array size */	n = 0;	status = ProArraySizeGet( p_components, &n );	TEST_CALL_REPORT( "ProArraySizeGet()", "ProTestCollectCurveComponents()",		status, status != PRO_TK_NO_ERROR);	/* Print out the components array */	fprintf( fp_out, "Number of curve components:\t%d\n", n );	for( i=0; i<n; i++ )	{	    fprintf( fp_out, "Index %d%s\n", 		p_components[i].index, 		(p_components[i].flip == PRO_B_TRUE ? ", flipped" : "") );	}	status = ProArrayFree( (ProArray*)&p_components );	TEST_CALL_REPORT( "ProArrayFree()", "ProTestCollectCurveComponents()",		status, status != PRO_TK_NO_ERROR);    }    return status;}/*=========================================================================*\    File:	TestCollect.c    Function:   ProTestCollectContours()    Purpose:    On button function. Test surface contours collection		and contour edges collection    Returns:	0 if successful, non-zero otherwise.\*=========================================================================*/int ProTestCollectContours(     ProAppData p_appdata,    int int_dummy ){    ProError	    status;    ProSelection    *p_selection;    int		    n_selected = 0;    ProSurface	    p_surface;    ProContour	    *p_contours;    ProEdge	    *p_edges;    char	    *p_trav_str;    ProContourTraversal	traversal;    int		    edge_id;    double	    edge_len;    ProEnttype	    edge_type;    int		    n_contours;    int		    n_edges;    int		    i;    int		    j;    /* Print the header */    fprintf( fp_out, "\n# Contours\n" );    /* Select model */    ProMessageDisplay( w_msg_file, "TEST %0s", "Select the surface" );    status = ProSelect( "surface", 1, NULL, NULL, NULL, NULL, 	&p_selection, &n_selected );    TEST_CALL_REPORT( "ProSelect()", "ProTestCollectContours()",	status, status != PRO_TK_NO_ERROR);    if( (status != PRO_TK_NO_ERROR) || (n_selected != 1) )	return -1;    /* Get selected model */    if( ProUtilSelectedSurfaceGet( p_selection[0], &p_surface ) 	!= PRO_TK_NO_ERROR )	return -1;    /* Get surface contours */    status = ProUtilCollectSurfaceContours( p_surface, &p_contours );    if( status != PRO_TK_NO_ERROR )	return -1;    /* Print out contours */    if( status == PRO_TK_NO_ERROR )    {	/* Get the contours array size */	n_contours = 0;	status = ProArraySizeGet( p_contours, &n_contours );	TEST_CALL_REPORT( "ProArraySizeGet()", 		"ProTestCollectContours()",		status, status != PRO_TK_NO_ERROR);	/* Print out the contours array */	fprintf( fp_out, "Number of contours:\t%d\n", n_contours );	for( i=0; i<n_contours; i++ )	{	    /* Internal or external contour */	    status = ProContourTraversalGet( p_contours[i], &traversal );	    TEST_CALL_REPORT( "ProContourTraversalGet()", 		"ProTestCollectContours()",		status, status != PRO_TK_NO_ERROR);	    switch( traversal )	    {	      case PRO_CONTOUR_TRAV_INTERNAL: 		p_trav_str = "Internal"; 		break;	      case PRO_CONTOUR_TRAV_NONE: 		p_trav_str = "Erroneous"; 		break;	      case PRO_CONTOUR_TRAV_EXTERNAL: 

⌨️ 快捷键说明

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