quilt-cut

////////////////////////////////////////////////////////////////////////////////////////////////// // // QuiltCutTest.cpp : Defines the initialization routines for the DLL. // #include "stdafx.h" #include "QuiltCutTest.h" #include "TKCheckInterference.h" #include "TKQuiltCut.h" #include #include #include #include #include #include #ifdef _DEBUG #define new DEBUG_NEW #endif // //TODO: If this DLL is dynamically linked against the MFC DLLs, // any functions exported from this DLL which call into // MFC must have the AFX_MANAGE_STATE macro added at the // very beginning of the function. // // For example: // // extern "C" BOOL PASCAL EXPORT ExportedFunction() // { // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // // normal function body here // } // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that // it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. // // Please see MFC Technical Notes 33 and 58 for additional // details. // // CQuiltCutTestApp BEGIN_MESSAGE_MAP(CQuiltCutTestApp, CWinApp) END_MESSAGE_MAP() // CQuiltCutTestApp construction CQuiltCutTestApp::CQuiltCutTestApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } // The one and only CQuiltCutTestApp object CQuiltCutTestApp theApp; // CQuiltCutTestApp initialization BOOL CQuiltCutTestApp::InitInstance() { CWinApp::InitInstance(); return TRUE; } static uiCmdAccessState TestFunAccessFn(uiCmdAccessMode access_mode) { return (ACCESS_AVAILABLE); } ProError QuiltCutTestMenuFn() { ProError status; ProSelection *quiltSels; int selCount; status = ProSelect("dtmqlt", 1, NULL, NULL, NULL, NULL, &quiltSels, &selCount); if (status != PRO_TK_NO_ERROR || selCount <= 0) { return PRO_TK_NO_ERROR; } ProMdl currMdl; status = ProMdlCurrentGet(&currMdl); if (status != PRO_TK_NO_ERROR) { return status; } InterferenceFindStruct cutpartData(currMdl); ProSelectionCopy(quiltSels[0], &cutpartData.check_sel); ProAsmcomppath tempComppath; status = ProSelectionAsmcomppathGet(quiltSels[0], &tempComppath); status = ProAsmcomppathMdlGet(&tempComppath, &cutpartData.comp_model); cutpartData.mdl_sel_arr = NULL; status = ProArrayAlloc(0, sizeof(ProSelection), 1, (ProArray*)&cutpartData.mdl_sel_arr); status = ProSolidFeatVisit((ProSolid)currMdl, CheckQuiltInterference, NULL, (ProAppData)&cutpartData); if (status != PRO_TK_NO_ERROR) { return status; } status = ProWindowRepaint(-1); int cuppartCount(0); status = ProArraySizeGet((ProArray)cutpartData.mdl_sel_arr,&cuppartCount); for (int i = 0; i < cuppartCount; i++) { AfxMessageBox("good job!"); ProFeature cutFeat; status = TKSolidifyCreate(cutpartData.mdl_sel_arr[i], quiltSels[0], PRO_FEAT_CUT, &cutFeat); } return PRO_TK_NO_ERROR; } // Toolkit extern "C" int user_initialize( int argc, char *argv[], char *version, char *build, wchar_t errbuf[80]) { ProError status; ProFileName MsgFile; ProStringToWstring(MsgFile, "QuiltCutTest.txt"); uiCmdCmdId TestFunMenuId; status = ProCmdActionAdd("QuiltCutTest", (uiCmdCmdActFn)QuiltCutTestMenuFn, uiProeImmediate, TestFunAccessFn, PRO_B_TRUE, PRO_B_TRUE,&TestFunMenuId); status = ProMenubarmenuPushbuttonAdd ("Help", "QuiltCutTest", "QuiltCutTest", "QuiltCutTest_Help", NULL, PRO_B_TRUE, TestFunMenuId, MsgFile); return (PRO_TK_NO_ERROR); } extern "C" void user_terminate() { return; } ////////////////////////////////////////////////////////////////////////////////////////////// // // QuiltCutTest.h : main header file for the QuiltCutTest DLL // #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols // CQuiltCutTestApp // See QuiltCutTest.cpp for the implementation of this class // class CQuiltCutTestApp : public CWinApp { public: CQuiltCutTestApp(); // Overrides public: virtual BOOL InitInstance(); DECLARE_MESSAGE_MAP() }; ================================================================== ////////////////////////////////////////////////////////////////////////////////////////////// // // TKCheckInterference.cpp // 干涉判斷 // #include "stdafx.h" #include "TKCheckInterference.h" #include "TKSelection.h" #include #include #include #include #include #include #include #include #include #include ProError CheckQuiltInterference(ProFeature *p_feature,ProError err,ProAppData app_data) { ProError status; ProFeatStatus feat_status; ProFeattype feat_type; ProMdl comp_model; InterferenceFindStruct *p_quilt_data = (InterferenceFindStruct*)app_data; // check only active features status = ProFeatureStatusGet(p_feature,&feat_status); if (status!=PRO_TK_NO_ERROR || feat_status != PRO_FEAT_ACTIVE) { return PRO_TK_NO_ERROR; } status = ProFeatureTypeGet(p_feature,&feat_type); if (feat_type == PRO_FEAT_COMPONENT) { status = ProAsmcompMdlGet(p_feature,&comp_model); if(status!=PRO_TK_NO_ERROR) { return PRO_TK_NO_ERROR; } // dont compare model itself if(comp_model==p_quilt_data->comp_model) { return PRO_TK_NO_ERROR; } // build selection of this component ProSelection comp_sel; status = ProSelectionAlloc(&p_quilt_data->asmcomppath, p_feature, &comp_sel); if(status==PRO_TK_NO_ERROR) { // check interference between 'p_quilt_data->check_sel' and 'akt_quilt_sel' Select3d sel_recs[2]; Prohandle *interf_vol_surfs; int n_surfs=0; ProselectionToSelect3d(p_quilt_data->check_sel,&(sel_recs[1])); sel_recs[1].part_ptr=(Prohandle)p_quilt_data->comp_model; ProselectionToSelect3d(comp_sel,&(sel_recs[0])); sel_recs[0].part_ptr=(Prohandle)comp_model; int status = pro_compute_interference(sel_recs,PROINTERF_ALL_VIS_GEOM,&interf_vol_surfs,&n_surfs); if (n_surfs > 0 && status == PRODEV_NO_ERROR) { p_quilt_data->asmcomppath.comp_id_table[p_quilt_data->asmcomppath.table_num] = p_feature->id; p_quilt_data->asmcomppath.table_num++; ProModelitem mi; ProMdlToModelitem(comp_model, &mi); status = ProSelectionAlloc(&p_quilt_data->asmcomppath, &mi, &comp_sel); p_quilt_data->asmcomppath.table_num--; p_quilt_data->asmcomppath.comp_id_table[p_quilt_data->asmcomppath.table_num] = -1; status = ProArrayObjectAdd((ProArray*)&(p_quilt_data->mdl_sel_arr), -1, 1, (void*)&comp_sel); pro_display_interf_volume(interf_vol_surfs,n_surfs,HIGHLITE_COLOR); pro_interference_volume_release(interf_vol_surfs,n_surfs); } } // handle acp for components p_quilt_data->asmcomppath.comp_id_table[p_quilt_data->asmcomppath.table_num] = p_feature->id; p_quilt_data->asmcomppath.table_num++; // search recursively status = ProSolidFeatVisit((ProSolid)comp_model,CheckQuiltInterference,NULL,(ProAppData)p_quilt_data); // handle acp for components p_quilt_data->asmcomppath.table_num--; p_quilt_data->asmcomppath.comp_id_table[p_quilt_data->asmcomppath.table_num] = -1; } return PRO_TK_NO_ERROR; } ////////////////////////////////////////////////////////////////////////////////////////////// // // TKCheckInterference.h // 干涉判斷 // #include #include typedef struct InterferenceFindStruct { ProAsmcomppath asmcomppath; ProSelection check_sel; ProMdl comp_model; ProSelection *mdl_sel_arr; InterferenceFindStruct(ProMdl asmMdl) { ProIdTable comp_id_tab; comp_id_tab[0] = -1; ProAsmcomppathInit((ProSolid)asmMdl, comp_id_tab, 0, &asmcomppath); } } InterferenceFindStruct; ProError CheckQuiltInterference(ProFeature *p_feature,ProError status,ProAppData app_data); ================================================================== ////////////////////////////////////////////////////////////////////////////////////////////// // // TKQuiltCut.cpp // 曲面Solidfy // #include "stdafx.h" #include "TKQuiltCut.h" #include #include #include #include #include #include #include // // 使用Quilt實體化,通過參數feat_type確定是CUTOUT還是拉伸特徵 // 輸入參數: // model_sel:目標檔案 // p_quilt_sel:Quilt // feat_type:PRO_FEAT_CUT/PRO_FEAT_PROTRUSION // 輸出參數: // feature:新增特徵 // ProError TKSolidifyCreate(ProSelection model_sel, ProSelection p_qiult_sel, int feat_type, ProFeature *feature) { ProElement pro_e_feature_tree; ProElement pro_e_feature_type; ProElement pro_e_feature_form; ProElement pro_e_patch_quilt; ProElement pro_e_patch_type; ProElement pro_e_patch_material_side; ProElement pro_e_std_feature_name; ProError status; // ProName wide_string; ProValue value; ProValueData value_data; ProBoolean is_interactive = PRO_B_TRUE; //Populating root element PRO_E_FEATURE_TREE status = ProElementAlloc ( PRO_E_FEATURE_TREE, &pro_e_feature_tree ); //Populating element PRO_E_FEATURE_TYPE status = ProElementAlloc ( PRO_E_FEATURE_TYPE, &pro_e_feature_type ); value_data.type = PRO_VALUE_TYPE_INT; value_data.v.i = feat_type; //PRO_FEAT_CUT status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_feature_type, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_type ); //Populating element PRO_E_FEATURE_FORM status = ProElementAlloc ( PRO_E_FEATURE_FORM, &pro_e_feature_form ); value_data.type = PRO_VALUE_TYPE_INT; value_data.v.i = PRO_USE_SURFS; status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_feature_form, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_feature_form ); //Populating element PRO_E_PATCH_QUILT status = ProElementAlloc ( PRO_E_PATCH_QUILT, &pro_e_patch_quilt ); value_data.type = PRO_VALUE_TYPE_SELECTION; value_data.v.r = p_qiult_sel; status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_patch_quilt, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_patch_quilt ); //Populating element PRO_E_PATCH_TYPE status = ProElementAlloc ( PRO_E_PATCH_TYPE, &pro_e_patch_type ); value_data.type = PRO_VALUE_TYPE_INT; value_data.v.i = feat_type; //PRO_FEAT_CUT status = ProValueAlloc ( &value ); status = ProValueDataSet ( value, &value_data ); status = ProElementValueSet ( pro_e_patch_type, value ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_patch_type ); //Populating element PRO_E_PATCH_MATERIAL_SIDE status = ProElementAlloc ( PRO_E_PATCH_MATERIAL_SIDE, &pro_e_patch_material_side ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_patch_material_side ); //Populating element PRO_E_STD_FEATURE_NAME status = ProElementAlloc ( PRO_E_STD_FEATURE_NAME, &pro_e_std_feature_name ); status = ProElemtreeElementAdd ( pro_e_feature_tree, NULL, pro_e_std_feature_name); // ³Ð«ØSOLIDIFY¯S©º ProErrorlist errors; ProFeatureCreateOptions opts[1]; opts[0] = PRO_FEAT_CR_INCOMPLETE_FEAT; status = ProFeatureCreate (model_sel, pro_e_feature_tree, opts, 1, feature, &errors); if (status != PRO_TK_NO_ERROR) { ProElementFree(&pro_e_feature_tree); return status; } status = ProElementFree (&pro_e_feature_tree ); return PRO_TK_NO_ERROR; } ////////////////////////////////////////////////////////////////////////////////////////////// // // TKQuiltCut.h // 曲面Solidfy // #include #include // // 使用Quilt實體化,通過參數feat_type確定是CUTOUT還是拉伸特徵 // 輸入參數: // model_sel:目標檔案 // p_quilt_sel:Quilt // feat_type:PRO_FEAT_CUT/PRO_FEAT_PROTRUSION // 輸出參數: // feature:新增特徵 // ProError TKSolidifyCreate(ProSelection model_sel, ProSelection p_qiult_sel, int feat_type, ProFeature *feature); ================================================================== ////////////////////////////////////////////////////////////////////////////////////////////// // // TKSelection.cpp // 選擇WF2和WF3轉換 // #include "stdafx.h" #include "TKSelection.h" #include #include //////////////////////// // Pro/TOOLKIT includes #include #include #include #include #include #include #include #include #include #include #include //////////////////////////////////////////////////////////////////// // convert Proselection to old select3d int ProselectionToSelect3d(ProSelection in_selection, Select3d *out_select3d) { int i, n_refs; Object_element subject, *ref; ProError err; ProModelitem mdl_item; ProAsmcomppath asm_comppath; ProFeature feature; asm_comppath.table_num=-1; err = ProSelectionModelitemGet(in_selection, &mdl_item); err = ProSelectionAsmcomppathGet(in_selection, &asm_comppath); if(asm_comppath.table_num>0) { out_select3d->assembly_ptr = (Prohandle)(asm_comppath.owner); } else { out_select3d->assembly_ptr = (Prohandle)(mdl_item.owner); } out_select3d->memb_num = asm_comppath.table_num; if (asm_comppath.table_num == 0) out_select3d->memb_id_tab[0] = -1; { for(i=0;imemb_id_tab[i] = asm_comppath.comp_id_table[i]; out_select3d->memb_id_tab[asm_comppath.table_num] = -1; } out_select3d->part_ptr = (Prohandle)mdl_item.owner; if (mdl_item.type == PRO_SURFACE) { out_select3d->selected_id = mdl_item.id; out_select3d->sel_type = SEL_3D_SRF; subject.type = SEL_3D_SRF; subject.id = mdl_item.id; n_refs = pro_element_info(out_select3d->part_ptr,&subject, PRO_IDENTIFY, -1, &ref); out_select3d->selected_ptr = ref[0].ptr; out_select3d->sel_elem_id = -1; } else if (mdl_item.type == PRO_CURVE) { out_select3d->selected_id = mdl_item.id; out_select3d->sel_type = SEL_3D_CURVE; subject.type = SEL_3D_CURVE; subject.id = mdl_item.id; n_refs = pro_element_info(out_select3d->part_ptr,&subject, PRO_IDENTIFY, -1, &ref); out_select3d->selected_ptr = ref[0].ptr; } else if (mdl_item.type == PRO_AXIS) { out_select3d->selected_id = mdl_item.id; out_select3d->sel_type = SEL_3D_AXIS; subject.type = SEL_3D_AXIS; subject.id = mdl_item.id; n_refs = pro_element_info(out_select3d->part_ptr,&subject, PRO_IDENTIFY, -1, &ref); out_select3d->selected_ptr = ref[0].ptr; } else if (mdl_item.type == PRO_CSYS) { out_select3d->selected_id = mdl_item.id; out_select3d->sel_type = SEL_3D_CSYS; err = ProGeomitemToCsys(&mdl_item,(ProCsys*)&(out_select3d->selected_ptr)); } else if (mdl_item.type == PRO_POINT) { out_select3d->sel_type = SEL_3D_PNT; out_select3d->sel_elem_id = mdl_item.id; err = ProGeomitemFeatureGet(&mdl_item,&feature); out_select3d->selected_id = feature.id; subject.type = SEL_3D_PNT; subject.id = mdl_item.id; n_refs = pro_element_info(out_select3d->part_ptr,&subject, PRO_IDENTIFY, -1, &ref); out_select3d->selected_ptr = ref[0].ptr; } else if (mdl_item.type == PRO_PART) { out_select3d->sel_type = SEL_3D_PART; } return 1; } //////////////////////////////////////////////////////////////////// // convert old select3d to Proselection int Select3dToProselection(Select3d in_select_3d, ProSelection* p_out_selection) { ProError err; ProModelitem sel_modelitem; ProAsmcomppath sel_acp; // Modelitem Initialisieren // ------------------------ if (in_select_3d.sel_type == SEL_3D_SRF) err = ProModelitemInit((ProSolid)in_select_3d.part_ptr,in_select_3d.selected_id,PRO_SURFACE,&sel_modelitem); else if (in_select_3d.sel_type == SEL_3D_CURVE) err = ProModelitemInit((ProSolid)in_select_3d.part_ptr,in_select_3d.selected_id,PRO_CURVE,&sel_modelitem); else if (in_select_3d.sel_type == SEL_3D_AXIS) err = ProModelitemInit((ProSolid)in_select_3d.part_ptr,in_select_3d.selected_id,PRO_AXIS,&sel_modelitem); else if (in_select_3d.sel_type == SEL_3D_CSYS) err = ProModelitemInit((ProSolid)in_select_3d.part_ptr,in_select_3d.selected_id,PRO_CSYS,&sel_modelitem); else if (in_select_3d.sel_type == SEL_3D_PNT) err = ProModelitemInit((ProSolid)in_select_3d.part_ptr,in_select_3d.sel_elem_id,PRO_POINT,&sel_modelitem); if (err!=PRO_TK_NO_ERROR) { return FALSE; } // Asmcpmppath Initialisieren if (in_select_3d.memb_num >= 0) { err = ProAsmcomppathInit((ProSolid)in_select_3d.assembly_ptr,in_select_3d.memb_id_tab,in_select_3d.memb_num,&sel_acp); if (err!=PRO_TK_NO_ERROR) { return FALSE; } err = ProSelectionAlloc(&sel_acp,&sel_modelitem,p_out_selection); if (err!=PRO_TK_NO_ERROR) { return FALSE; } } else { err = ProSelectionAlloc(NULL,&sel_modelitem,p_out_selection); if (err!=PRO_TK_NO_ERROR) { return FALSE; } } return TRUE; } ////////////////////////////////////////////////////////////////////////////////////////////// // // TKSelection.cpp // 選擇WF2和WF3轉換 // #include #include //////////////////////////////////////////////////////////////////// // convert Proselection to old select3d int ProselectionToSelect3d(ProSelection in_selection, Select3d *out_select3d) ; //////////////////////////////////////////////////////////////////// // convert old select3d to Proselection int Select3dToProselection(Select3d in_select_3d, ProSelection* p_out_selection);

你可能感兴趣的:(patch,tree,null,initialization,assembly,construction)