/* Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved. */ #ifndef lint static char UtilMfgWcell_h [] = "@(#)UtilMfgWcell.c 1.4 11/26/96"; #endif /*--------------------------------------------------------------------*\ System includes \*--------------------------------------------------------------------*/ #include <math.h> /*--------------------------------------------------------------------*\ Pro/Toolkit includes \*--------------------------------------------------------------------*/ #include "ProToolkit.h" #include "ProNcseq.h" #include "ProElement.h" #include "ProModelitem.h" #include "ProNcseqElem.h" #include "ProFeature.h" #include "ProSelection.h" #include "ProMdl.h" #include "ProParamval.h" #include "ProToolElem.h" #include "ProWcell.h" #include "ProElement.h" #include "ProElemId.h" #include "ProElempath.h" #include "ProFeature.h" #include "ProFeatType.h" #include "ProSolid.h" #include "ProCsys.h" #include <ProTKRunTime.h> /*--------------------------------------------------------------------*\ Application includes \*--------------------------------------------------------------------*/ #include "TestConsts.h" #include "UtilString.h" #include "UtilGeom.h" #include "TestError.h" #include "UtilTree.h" #include "MfgMenu.h" #include "TestMfgNew.h" /*--------------------------------------------------------------------*\ Application macros \*--------------------------------------------------------------------*/ #define PARAM_FIELD_WIDTH 21 /*--------------------------------------------------------------------*\ Application data types \*--------------------------------------------------------------------*/ /*====================================================================*\ Function: ProTempCreateWkcell Purpose : Create Workcell \*====================================================================*/ ProError ProTempCreateWkcell( Workcell wcell, ProFeature *p_wc_feature) { ProElement wc_elem_tree = (ProElement)NULL; /* Workcell element tree. */ ProElement wc_elem = (ProElement)NULL; /* Individual element. */ ProValue value = (ProValue)NULL; ProValueData value_data; ProSelection selection; ProErrorlist errors; ProError status = PRO_TK_NO_ERROR; char name[PRO_LINE_SIZE]; int i = 0; ProFeatureCreateOptions *opts = 0; /* Set up the top level element values and sizes. */ static ElemTable workcell_elem_table[] = { { PRO_E_FEATURE_TYPE, PRO_VALUE_TYPE_INT }, { PRO_E_WCELL_TYPE, PRO_VALUE_TYPE_INT }, { PRO_E_NUM_AXES, PRO_VALUE_TYPE_INT }, { PRO_E_FEAT_NAME, PRO_VALUE_TYPE_WSTRING}}; int wc_elem_type_size = sizeof(workcell_elem_table)/ sizeof(ElemTable); /*--------------------------------------------------------------------*\ Allocate space for workcell element tree \*--------------------------------------------------------------------*/ if (status == PRO_TK_NO_ERROR) { status = ProElementAlloc ( PRO_E_FEATURE_TREE, &wc_elem_tree ); TEST_CALL_REPORT("ProElementAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } ProTKFprintf(stderr, (char*)"wcell.type: %d\n", wcell.type); ProTKFprintf(stderr, (char*)"wcell.n_axis: %d\n", wcell.n_axis); ProTKFprintf(stderr, (char*)"wcell.wname: %s\n", pro_wstr_to_str(name, wcell.wname)); /*--------------------------------------------------------------------*\ Set all of the top level elements \*--------------------------------------------------------------------*/ for (i =0; i < wc_elem_type_size; i++) { if (status == PRO_TK_NO_ERROR) { status = ProElementAlloc(workcell_elem_table[i].elem_type,&wc_elem); TEST_CALL_REPORT("ProElementAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } switch (workcell_elem_table[i].elem_type) { case PRO_E_FEATURE_TYPE: value_data.v.i = PRO_FEAT_WORKCELL; status = ProElementIntegerSet(wc_elem, PRO_FEAT_WORKCELL); TEST_CALL_REPORT("ProElementIntegerSet()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); break; case PRO_E_WCELL_TYPE: value_data.v.i = wcell.type; status = ProElementIntegerSet(wc_elem, wcell.type); TEST_CALL_REPORT("ProElementIntegerSet()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); break; case PRO_E_NUM_AXES: value_data.v.i = wcell.n_axis; status = ProElementIntegerSet(wc_elem, wcell.n_axis); TEST_CALL_REPORT("ProElementIntegerSet()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); break; case PRO_E_FEAT_NAME: status=ProElementWstringSet(wc_elem, wcell.wname); TEST_CALL_REPORT("ProElementWstringSet()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); break; default: ProTKFprintf(stderr, (char*)"Error setting element type\n"); return (PRO_TK_GENERAL_ERROR); } if ( status == PRO_TK_NO_ERROR ) { status = ProElemtreeElementAdd (wc_elem_tree, NULL, wc_elem ); TEST_CALL_REPORT("ProElemtreeElementAdd()","ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); } } status = ProUtilElementtreePrint(wc_elem_tree, PRO_TEST_INFO_WINDOW, NULL); /* status = ProElementAlloc( PRO_E_TOOLING, &wc_elem ); TEST_CALL_REPORT("ProElementAlloc()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); status = ProTestCreateTools( tool_id_default, p_param_file, bitmask, tool_type, wc_elem ); status = ProFeatinputElemAdd((ProFeatinputPtr) wc_input, wc_elem); TEST_CALL_REPORT("ProFeatinputElemAdd()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); */ status = ProTestCreateSelection(PRO_TK_NOT_USED, PRO_TYPE_UNUSED, &selection); if (status == PRO_TK_NO_ERROR) { status = ProArrayAlloc(1,sizeof(ProFeatureCreateOptions), 1, (ProArray*)&opts); opts[0]= PRO_FEAT_CR_NO_OPTS; status = ProFeatureWithoptionsCreate( selection, wc_elem_tree, opts, PRO_REGEN_NO_FLAGS, p_wc_feature, &errors); TEST_CALL_REPORT("ProFeatureWithoptionsCreate()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); status = ProArrayFree((ProArray*)&opts); } status = ProElementFree(&wc_elem_tree); TEST_CALL_REPORT("ProElementFree()", "ProTestCreateWkcell()", status, (status != PRO_TK_NO_ERROR)); return(status); }