/*================================================================*\ FILE: UtilCollectDtmpnt.c PURPOSE: Util functions for collection datum points in the solid HISTORY: 18-Sep-98 I-01-20 Pavel $$1 Created 19-Oct-98 I-01-23 AKH $$2 Move ProUtilCollectDtmPointFeatFilter into UtilVisit.c \*=================================================================*/ #include #include #include #include #include #include #include #include #include #include /*====================================================================*\ FUNCTION : ProUtilCollectOneLevelAsmcomppath() PURPOSE : Collect Asmcomppathes on one level only. Util function to be call from ProUtilCollectAsmcomppath NOTE : Do not call it directly \*====================================================================*/ static ProError ProUtilCollectOneLevelAsmcomppath( ProAssembly assy, ProAsmcomppath *p_path, int level, ProAsmcomppath **pp_path) { ProError err; ProAsmcomp *p_comps; int i, n_comps; ProMdl mdl; ProMdlType mdl_type; err = ProUtilCollectAsmcomp(assy, &p_comps); if (err != PRO_TK_NO_ERROR) return (err); err = ProArraySizeGet((ProArray)p_comps, &n_comps); for (i=0; icomp_id_table[level] = p_comps[i].id; p_path->comp_id_table[level + 1] = -1; p_path->table_num = level + 1; /* Add Asmcomppath to the array */ ProArrayObjectAdd((ProArray*)pp_path, PRO_VALUE_UNUSED, 1, p_path); /* Check if components is assembly for recursive checking */ err = ProAsmcompMdlGet(p_comps+i, &mdl); err = ProMdlTypeGet(mdl, &mdl_type); if (mdl_type == PRO_MDL_ASSEMBLY) { err = ProUtilCollectOneLevelAsmcomppath((ProAssembly)mdl, p_path, level+1, pp_path); } } err = ProArrayFree((ProArray*)&p_comps); return (PRO_TK_NO_ERROR); } /*====================================================================*\ FUNCTION : ProUtilCollectAsmcomppath() PURPOSE : Collect asmcomppathes for all levels of assembly, including parts and subassemblies \*====================================================================*/ ProError ProUtilCollectAsmcomppath( ProAssembly assy, /* In : Assembly */ ProAsmcomppath **pp_path, /* Out: The ProArray of collected pathes. The function allocates memory for this argument, but you must free it. To free the memory, call the function ProArrayFree() */ int *p_n_pathes) /* Out: The number of pathes in the array */ { ProError err; ProAsmcomppath path; int n_pathes; if((assy == (ProAssembly)NULL) || pp_path == NULL ) return (PRO_TK_BAD_INPUTS); err = ProArrayAlloc(0, sizeof(ProAsmcomppath), 10, (ProArray*)pp_path); path.owner = (ProSolid)assy; err = ProUtilCollectOneLevelAsmcomppath(assy, &path, 0, pp_path); err = ProArraySizeGet((ProArray)*pp_path, &n_pathes); if (n_pathes<=0) { err = ProArrayFree((ProArray*)pp_path); return (PRO_TK_E_NOT_FOUND); } p_n_pathes[0] = n_pathes; return (PRO_TK_NO_ERROR); } /*====================================================================*\ FUNCTION : ProUtilCollectOneLevelDtmPnts() PURPOSE : Collect Datum points in top level solid only. Util function to be call from ProUtilCollectSolidDtmPnts NOTE : Do not call it directly \*====================================================================*/ static ProError ProUtilCollectOneLevelDtmPnts( ProSolid solid, ProAsmcomppath *p_path, ProSelection **p_sel) { ProError err; ProFeature *p_features; ProModelitem *p_points; int i, j, n_points, n_feats; ProSelection sel; err = ProUtilCollectSolidFeaturesWithFilter (solid, ProUtilCollectDtmPointFeatFilter, &p_features); if (err != PRO_TK_NO_ERROR) return (err); err = ProArraySizeGet((ProArray)p_features, &n_feats); for (i=0; i