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

📄 utilcollect.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
📖 第 1 页 / 共 5 页
字号:
/*================================================================*\    FILE:	UtilCollect.c    PURPOSE:	Collection functions implementation    HISTORY:21-Mar-97   H-01-30   Alexey  $$1   Created16-May-97   H-03-11   Alexey  $$2   added functionality28-May-97   H-03-13   Pavel   $$3   added ProUtilCollectMdlLayers13-Jul-97   H-03-17   Pavel   $$4   Added ProUtilCollectProcstep17-Sep-97   H-03-23   Pavel   $$5   Added ProUtilCollectWindowids05-Oct-97   H-03-25   Alexey  $$6   Write callback names to log 16-Oct-97   H-03-27   Pavel   $$7   More collect & filter functions24-Oct-97   H-03-27   Pavel   $$8   Fixed bug27-Oct-97   H-03-28   Pavel   $$9   Corrected params in TEST_CALL_REPORT20-Jan-98   H-03-37   aab     $$10  Fixed some bugs for c++ compiler02-Feb-98   H-03-38   Pavel   $$11  Fixed bug in ProUtilCollectProcstep13-Feb-98   H-03-39   Pavel   $$12  More FindByName funcs11-Jun-98   I-01-12   Akkur   $$13  Add TEST_CALL_REPORT                                         to ProElemtreeVisitFilter().18-Sep-98   I-01-20   Pavel   $$14  Added ProUtilCollectCollectionInstrs,					  ProUtilCollectCollectinstrRefs  21-Oct-98   I-01-23   Alexey  $$15  Remove ProUtilDefaultFilter() arguments 17-Nov-98   I-01-27   Pavel   $$16  Added ProUtilCollectSolidXsec()11-Dec-98   I-01-28   Alexey  $$17  Remove ProUtilCollectCollectinstrRefs(),					ProUtilCollectCollectionInstrs()06-May-99   I-03-10   aab     $$18  Added ProUtilCollectSolidAnalysis()\*=================================================================*//*----------------------------------------------------------*\    Headers\*----------------------------------------------------------*/#include "ProToolkit.h"#include "ProArray.h"#include "ProAxis.h"#include "ProFeatType.h"#include "ProGeomitem.h"#include "ProProcstep.h"#include "ProExpldstate.h"#include "prodevelop.h"#include "pd_prototype.h"#include "TestError.h"#include "UtilString.h"#include "UtilMath.h"#include "UtilCollect.h"#include "UtilVisit.h"/*----------------------------------------------------------*\    Macros\*----------------------------------------------------------*/#define ACTION_TYPE( v, f )	\    p_visit_action_type=v;	\    p_filter_action_type=f;/*----------------------------------------------------------*\    Data types\*----------------------------------------------------------*//*--------------------------------------------------------------------*\Application data\*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*\   These are variables for testing purposes. Since for visiting several   different objects we can use only one callback function we will check   this variable for type of the object we visit.   For example, if we are going to use callbacks of type   ProAxisFilterAction/ProAxisVisitAction we have to set     ACTION_TYPE("ProAxisVisitAction", "ProAxisVisitAction")   before calling visit function.\*--------------------------------------------------------------------*/static char             *p_visit_action_type = "";static char             *p_filter_action_type = "";/*----------------------------------------------------------*\    Functions declaration (internal)\*----------------------------------------------------------*/ProError ProUtilCollect2ParamOpaqueVisitAction(void *, ProAppData);ProError ProUtilCollect3ParamOpaqueVisitAction(void *, ProError, ProAppData);ProError ProUtilCollect2ParamDBVisitAction(void *, ProAppData);ProError ProUtilCollect3ParamDBVisitAction(void *, ProError ,ProAppData);ProError ProUtilCollect2ParamIdVisitAction(int, ProAppData);ProError ProUtilDefaultFilter();ProError ProUtilCollectExtobjReferencesVisitAction( ProExtobj *p_extobj,    ProWExtobjRef p_extobj_ref, ProError filter_status,     ProExtobjrefStatus ref_status, ProAppData app_data );ProError ProUtilCollectElemtreeElementVisitAction( ProElement p_elemtree,     ProElement p_element, ProElempath p_elempath, ProAppData app_data );ProError ProUtilCollectCurveComponentVisitAction( ProCurve p_curve,     ProCurve p_comp, int comp_idx, ProBoolean comp_flip, ProError filter_status,     ProAppData app_data );/*=========================================================================*\    Function:	ProUtilCollect2ParamDBVisitAction()    Purpose:	Add any object given by pointer to the Collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollect2ParamDBVisitAction(    void	    *p_object,	/* In:	The pointer to the object 					being visited */    ProAppData	    app_data)	/* In:	In fact it's ProArray** */{    ProError status;     ProArray *p_array;        p_array = (ProArray*)((void**)app_data)[0];    TEST_CALL_REPORT( p_visit_action_type, "ProUtilCollect2ParamDBVisitAction",	PRO_TK_NO_ERROR, 0 );    status = ProArrayObjectAdd(p_array, PRO_VALUE_UNUSED, 1, p_object );    return (status);}/*=========================================================================*\    Function:	ProUtilCollect3ParamDBVisitAction()    Purpose:	Add any object given by pointer to the Collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollect3ParamDBVisitAction(    void	    *p_object,	/* In:	The pointer to the object 					being visited */    ProError	    status,	/* In:  The status returned by filter func */    ProAppData	    app_data)	/* In:	In fact it's ProArray** */{    return (ProUtilCollect2ParamDBVisitAction(p_object, app_data));}/*=========================================================================*\    Function:	ProUtilCollect2ParamOpaqueVisitAction()    Purpose:	Add any opaque handle to the Collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollect2ParamOpaqueVisitAction(    void	    *p_object,	/* In:	The opaque handle being visited */    ProAppData	    app_data)	/* In:	In fact it's ProArray** */{    return (ProUtilCollect2ParamDBVisitAction((void*)&p_object, app_data));}/*=========================================================================*\    Function:	ProUtilCollect3ParamOpaqueVisitAction()    Purpose:	Add any opaque handle to the Collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollect3ParamOpaqueVisitAction(    void	    *p_object,	/* In:	The opaque handle being visited */    ProError	    status,	/* In:  The status returned by filter func */    ProAppData	    app_data)	/* In:	In fact it's ProArray** */{    return (ProUtilCollect2ParamDBVisitAction((void*)&p_object, app_data));}/*=========================================================================*\    Function:	ProUtilCollect2ParamIdVisitAction()    Purpose:	Add any Id to the Collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollect2ParamIdVisitAction(    int id,     ProAppData app_data){    return (ProUtilCollect2ParamDBVisitAction((void*)&id, app_data));}/*=========================================================================*\    Function:	ProUtilDefaultFilter()    Purpose:	filter function, just write TEST_CALL_REPORT for debug purposes    Returns:	PRO_TK_NO_ERROR - allow visit all objects;\*=========================================================================*/ProError ProUtilDefaultFilter(){    TEST_CALL_REPORT( p_filter_action_type, "ProUtilDefaultFilter",         PRO_TK_NO_ERROR, 0 );    return (PRO_TK_NO_ERROR);}/*=========================================================================*\    Function:	ProUtilCollectExtobjReferencesVisitAction()    Purpose:	Add passed ext objects reference to the collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollectExtobjReferencesVisitAction(     ProExtobj		*p_extobj,	/* In:  The handle to the extobj */    ProWExtobjRef	p_extobj_ref,	/* In:	The reference */    ProError		filter_status,	/* In:	The status */    ProExtobjrefStatus	ref_status,	/* In:	Reference status */    ProAppData		app_data)	/* In:	In fact it's ProArray** */{    ExtobjReference    extobj_ref;    /* Fill in the structure fields */    extobj_ref.extobj = p_extobj[0];    extobj_ref.p_extobj_ref = p_extobj_ref;    extobj_ref.ref_status = ref_status;    return (ProUtilCollect2ParamDBVisitAction((void*)&extobj_ref, app_data));}/*=========================================================================*\    Function:	ProUtilCollectElemtreeElementVisitAction()    Purpose:	Add passed element tree element to the collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollectElemtreeElementVisitAction(     ProElement	    p_elemtree,	/* In:	The handle to the element tree */    ProElement	    p_element,	/* In:	The handle to the element */    ProElempath	    p_elempath,	/* In:	The handle to the elem_path */    ProAppData	    app_data)	/* In:	In fact it's ElemtreeElement**  */{    ElemtreeElement elemtree_element;    ProError status;        /* Fill in the structure fields */    elemtree_element.p_element = p_element;    status = ProElempathAlloc (&(elemtree_element.p_elempath));    TEST_CALL_REPORT ("ProElempathAlloc()",         "ProUtilCollectElemtreeElementVisitAction()",         status, status != PRO_TK_NO_ERROR);    status = ProElempathCopy (p_elempath, elemtree_element.p_elempath);    TEST_CALL_REPORT ("ProElempathCopy()",         "ProUtilCollectElemtreeElementVisitAction()",         status, status != PRO_TK_NO_ERROR);    /* Add the structure to the array */    return (ProUtilCollect2ParamDBVisitAction((void*)&elemtree_element, 	app_data));}/*=========================================================================*\    Function:	ProUtilCollectCurveComponentVisitAction()    Purpose:	Add passed curve component parameters to the collection    Returns:	PRO_TK_NO_ERROR - success;\*=========================================================================*/ProError ProUtilCollectCurveComponentVisitAction(     ProCurve     p_curve,   /* In:  The composite curve being processed */    ProCurve     p_comp,    /* In:  The current component being visited */    int          comp_idx,  /* In:  The index of the current component in the 				    curve */    ProBoolean   comp_flip, /* In:  This is PRO_TK_TRUE if the current component 				    is flipped */    ProError     filter_status,	/* In:  The status returned by the filter */    ProAppData   app_data)  /* In:  In fact it's CurveComponent**  */{    CurveComponent  curve_comp;    /* Fill in the structure fields */    curve_comp.p_owner = p_curve;    curve_comp.p_curve = p_comp;    curve_comp.index = comp_idx;    curve_comp.flip = comp_flip;    /* Add the structure to the array */    return (ProUtilCollect2ParamDBVisitAction((void*)&curve_comp, app_data));}/*=========================================================================*\    Function:	ProUtilFindModelitemVisitAction()    Purpose:	Copy first visited modelitem to user's memory    Returns:	PRO_TK_USER_ABORT to stop visiting\*=========================================================================*/ProError ProUtilFindModelitemVisitAction(    ProModelitem *p_modelitem,	    /* In : The modelitem */    ProError	 status,	    /* In : the status */    ProModelitem **pp_modelitem)    /* In : The find structure */{    TEST_CALL_REPORT( p_visit_action_type, "ProUtilFindModelitemVisitAction()",         PRO_TK_NO_ERROR, 0 );    pp_modelitem[0][0] = p_modelitem[0];    return (PRO_TK_USER_ABORT);}/*=========================================================================*\    Function:	ProUtilFindGeomitemVisitAction()    Purpose:	Convert entity to geomitem and call		ProUtilFindModelitemVisitAction    Returns:	PRO_TK_USER_ABORT\*=========================================================================*/ProError ProUtilFindGeomitemVisitAction(    ProAppData geomitem,	    /* In : The geomitem */    ProError	status,		    /* the filter func status */    FindByName   *p_findbyname)	    /* In : The find structure */{    ProModelitem modelitem = p_findbyname->p_modelitem[0];    switch (modelitem.type)    {	case PRO_CSYS:	    status = ProCsysToGeomitem((ProSolid)modelitem.owner, 		(ProCsys)geomitem, &modelitem);	    TEST_CALL_REPORT("ProCsysToGeomitem()", 		"ProUtilGeomitemByNameFilterAction()", 		status, status != PRO_TK_NO_ERROR);	    break;	case PRO_AXIS:	    status = ProAxisToGeomitem((ProSolid)modelitem.owner, 		(ProAxis)geomitem, &modelitem);	    TEST_CALL_REPORT("ProAxisToGeomitem()", 		"ProUtilGeomitemByNameFilterAction()", 		status, status != PRO_TK_NO_ERROR);	    break;	case PRO_SURFACE:	    status = ProSurfaceToGeomitem((ProSolid)modelitem.owner, 		(ProSurface)geomitem, &modelitem);	    TEST_CALL_REPORT("ProSurfaceToGeomitem()", 		"ProUtilGeomitemByNameFilterAction()", 		status, status != PRO_TK_NO_ERROR);	    break;	default:	    status = PRO_TK_GENERAL_ERROR;    }    if (status == PRO_TK_NO_ERROR)	status = ProUtilFindModelitemVisitAction(&modelitem, PRO_TK_NO_ERROR,	    (ProModelitem**)p_findbyname);    return(status);	    }/*=========================================================================*\    Function:	ProUtilCollectExplstate()    Purpose:	Return a list of exploded in assembly    Returns:	PRO_TK_NO_ERROR - success;		PRO_TK_BAD_INPUTS - invalid parameters\*=========================================================================*/ProError ProUtilCollectExplstate(     ProAssembly     p_assembly,    /* In:  The assembly */    ProGeomitem     **p_geomitems   /* Out: ProArray with collected geomitems.					    The function allocates 					    memory for this argument, but 					    you must free it. To free 					    the memory, call the function 					    ProArrayFree() */){    ProError	    status;    if( p_geomitems != NULL )    {	status=ProArrayAlloc(0,sizeof(ProGeomitem),1,(ProArray*)p_geomitems);	TEST_CALL_REPORT("ProArrayAlloc()", "ProUtilCollectExplstate()",					    status, status != PRO_TK_NO_ERROR);	if( status == PRO_TK_NO_ERROR )	{	    ACTION_TYPE( "ProGeomitemAction", "ProGeomitemFilter" )	    status = ProSolidExpldstateVisit( p_assembly,                 (ProGeomitemAction)ProUtilCollect3ParamDBVisitAction,		(ProGeomitemFilter)ProUtilDefaultFilter,                (ProAppData)&p_geomitems );	    TEST_CALL_REPORT("ProSolidExpldstateVisit()", 		"ProUtilCollectExplstate()", status, 		status != PRO_TK_NO_ERROR && status != PRO_TK_E_NOT_FOUND);	    if( status != PRO_TK_NO_ERROR )	    {		ProArrayFree( (ProArray*)p_geomitems );

⌨️ 快捷键说明

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