点击查看详细介绍

中心线工具,三种找中心方式,没有整理的,好像面过滤没有设对,8.5的不能用,平面过滤

WW_TT_TOOLS 2年前 1424 0

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


void TT_CREATE_CenterLine_TOOL::setdlgSHOW_cb()
{
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
std::vector<Selection::MaskTriple> maskArray1(1),maskArray2(1),maskArray3(1);
maskArray1[0] = Selection::MaskTriple( UF_face_type,0 , 0 ); // 面
maskArray2[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype ,UF_UI_SEL_FEATURE_SOLID_BODY); //实体
maskArray3[0] = Selection::MaskTriple( 0, 0 , UF_UI_SEL_FEATURE_PLANAR_FACE ); // Plane
//maskArray3[0] = Selection::MaskTriple( UF_solid_type, UF_solid_body_subtype ,0); //实体和片体
if (enumCLASS->GetProperties()->GetEnum("Value")==0)
{
if (enumFACE->GetProperties()->GetEnum("Value")==0)
{
selectionCLASS->GetProperties()->SetSelectionFilter("SelectionFilter", action, maskArray3);
}
else
{
selectionCLASS->GetProperties()->SetSelectionFilter("SelectionFilter", action, maskArray1);
}

selectionCLASS->SetSelectModeAsString("Single");
buttonFACE->SetBitmap("$UGII_USER_DIR\\application\\Bitmaps\\TT_FaceCenterLine_OK.bmp");
buttonBODY->SetBitmap("$UGII_USER_DIR\\application\\Bitmaps\\TT_BodyCenterLine.bmp");
selectionCLASS->SetBitmap("select_face");enumFACE->SetShow(true);enumBODY->SetShow(false);
}
else
{
selectionCLASS->GetProperties()->SetSelectionFilter("SelectionFilter", action, maskArray2);
selectionCLASS->SetSelectModeAsString("Multiple");
buttonFACE->SetBitmap("$UGII_USER_DIR\\application\\Bitmaps\\TT_FaceCenterLine.bmp");
buttonBODY->SetBitmap("$UGII_USER_DIR\\application\\Bitmaps\\TT_BodyCenterLine_OK.bmp");
selectionCLASS->SetBitmap("select_body");enumFACE->SetShow(false);enumBODY->SetShow(true);
}
}

void TT_CREATE_CenterLine_TOOL::dosthCLASS_cb()
{
UF_initialize();
std::vector<TaggedObject *>theselectCLASSPros=selectionCLASS->GetProperties()->GetTaggedObjectVector("SelectedObjects");
tag_t classTAG=selectionCLASS->Tag();
if (enumCLASS->GetProperties()->GetEnum("Value")==0)
{
if (enumFACE->GetProperties()->GetEnum("Value")==0)
{
tag_t classTAG=theselectCLASSPros[0]->Tag();
double uv_min_max[4];
UF_MODL_ask_face_uv_minmax(classTAG, uv_min_max);
double parameter1[2],parameter2[2],parameter3[2],parameter4[2];
double point1[3],point2[3],point3[3],point4[3];
double U1[3];
double V1[3];
double U2[3];
double V2[3];
double unit_norm[3];
double radii[2];
parameter1[0]=uv_min_max[0];
parameter1[1]=(uv_min_max[2]+uv_min_max[3])/2;
UF_MODL_ask_face_props (classTAG,parameter1,point1,U1,V1,U2,V2,unit_norm,radii);
parameter2[0]=uv_min_max[1];
parameter2[1]=(uv_min_max[2]+uv_min_max[3])/2;
UF_MODL_ask_face_props (classTAG,parameter2,point2,U1,V1,U2,V2,unit_norm,radii);
parameter3[0]=(uv_min_max[0]+uv_min_max[1])/2;
parameter3[1]=uv_min_max[2];
UF_MODL_ask_face_props (classTAG,parameter3,point3,U1,V1,U2,V2,unit_norm,radii);
parameter4[0]=(uv_min_max[0]+uv_min_max[1])/2;
parameter4[1]=uv_min_max[3];
UF_MODL_ask_face_props (classTAG,parameter4,point4,U1,V1,U2,V2,unit_norm,radii);
UF_CURVE_line_t Line_coords1[2];
Line_coords1[0].start_point[0] =point1[0];
Line_coords1[0].start_point[1] =point1[1];
Line_coords1[0].start_point[2] =point1[2];
Line_coords1[0].end_point[0] =point2[0];
Line_coords1[0].end_point[1] =point2[1];
Line_coords1[0].end_point[2] =point2[2];
Line_coords1[1].start_point[0] =point3[0];
Line_coords1[1].start_point[1] =point3[1];
Line_coords1[1].start_point[2] =point3[2];
Line_coords1[1].end_point[0] = point4[0];
Line_coords1[1].end_point[1] = point4[1];
Line_coords1[1].end_point[2] =point4[2];
tag_t Line1[2];
UF_CURVE_create_line(&Line_coords1[0], &Line1[0]);
UF_CURVE_create_line(&Line_coords1[1], &Line1[1]);
UF_OBJ_set_color(Line1[0],186);UF_OBJ_set_color(Line1[1],186);UF_OBJ_set_color(Line1[2],186);
UF_OBJ_set_font(Line1[0],UF_OBJ_FONT_CENTERLINE);
UF_OBJ_set_font(Line1[1],UF_OBJ_FONT_CENTERLINE);
UF_OBJ_set_font(Line1[2],UF_OBJ_FONT_CENTERLINE);
}
else
{
tag_t classTAG=theselectCLASSPros[0]->Tag();
int face_type = 0;
UF_MODL_ask_face_type(classTAG,&face_type);
//分析曲面的u,v参数最大值和最小值
double uv_min_max[4];
UF_MODL_ask_face_uv_minmax(classTAG, uv_min_max);
//在面上创建等参数曲线
int uv_flag[2];
uv_flag[0]=1;
uv_flag[1]=2;
double parameter[2];
parameter[0] = (uv_min_max[1] + uv_min_max[0])/2;
parameter[1] = (uv_min_max[3] + uv_min_max[2])/2;
double dist_tol = 0.01;
tag_t* isocurve_id[2];
int isocurve_cnt = 0;
if (enumFACE->GetProperties()->GetEnum("Value")==1)
{
UF_MODL_create_isocurve(classTAG, uv_flag[0], parameter[0], dist_tol, &isocurve_id[0], &isocurve_cnt);
UF_MODL_create_isocurve(classTAG, uv_flag[1], parameter[1], dist_tol, &isocurve_id[1], &isocurve_cnt);
}
else if (enumFACE->GetProperties()->GetEnum("Value")==2)
{
UF_MODL_create_isocurve(classTAG, uv_flag[0], parameter[0], dist_tol, &isocurve_id[0], &isocurve_cnt);
}
else
{
UF_MODL_create_isocurve(classTAG, uv_flag[1], parameter[1], dist_tol, &isocurve_id[1], &isocurve_cnt);
}
}
}
else
{

if (enumBODY->GetProperties()->GetEnum("Value")==0)
{
for (int i = 0; i < theselectCLASSPros.size(); i++)
{
tag_t classTAG=theselectCLASSPros[i]->Tag();
double Box[6];
UF_MODL_ask_bounding_box(classTAG,Box);
UF_CURVE_line_t Line_coords1[3];
Line_coords1[0].start_point[0] = (Box[0] + Box[3])/2;
Line_coords1[0].start_point[1] = (Box[1] + Box[4])/2;
Line_coords1[0].start_point[2] = (Box[2]);
Line_coords1[0].end_point[0] = (Box[0] + Box[3])/2;
Line_coords1[0].end_point[1] = (Box[1] + Box[4])/2;
Line_coords1[0].end_point[2] = Box[5];
Line_coords1[1].start_point[0] = (Box[0] + Box[3])/2;
Line_coords1[1].start_point[1] = Box[1];
Line_coords1[1].start_point[2] = (Box[2] + Box[5])/2;
Line_coords1[1].end_point[0] = (Box[0] + Box[3])/2;
Line_coords1[1].end_point[1] = Box[4];
Line_coords1[1].end_point[2] = (Box[2] + Box[5])/2;
Line_coords1[2].start_point[0] = Box[0];
Line_coords1[2].start_point[1] = (Box[1] + Box[4])/2;
Line_coords1[2].start_point[2] = (Box[2] + Box[5])/2;
Line_coords1[2].end_point[0] = Box[3];
Line_coords1[2].end_point[1] = (Box[1] + Box[4])/2;
Line_coords1[2].end_point[2] = (Box[2] + Box[5])/2;
tag_t Line1[3];
UF_CURVE_create_line(&Line_coords1[0], &Line1[0]);
UF_CURVE_create_line(&Line_coords1[1], &Line1[1]);
UF_CURVE_create_line(&Line_coords1[2], &Line1[2]);
UF_OBJ_set_color(Line1[0],186);UF_OBJ_set_color(Line1[1],186);UF_OBJ_set_color(Line1[2],186);
UF_OBJ_set_font(Line1[0],UF_OBJ_FONT_CENTERLINE);
UF_OBJ_set_font(Line1[1],UF_OBJ_FONT_CENTERLINE);
UF_OBJ_set_font(Line1[2],UF_OBJ_FONT_CENTERLINE);
}
}
else
{
double MaxBox[6] = {10000, 10000, 10000, -10000, -10000, -10000};
for (int i = 0;i < theselectCLASSPros.size(); i++)
{
tag_t classTAG=theselectCLASSPros[0]->Tag();
double Box[6];
UF_MODL_ask_bounding_box(theselectCLASSPros[i]->Tag(),Box);
MaxBox[0] = MaxBox[0] < Box[0]? MaxBox[0]:Box[0];
MaxBox[1] = MaxBox[1] < Box[1]? MaxBox[1]:Box[1];
MaxBox[2] = MaxBox[2] < Box[2]? MaxBox[2]:Box[2];
MaxBox[3] = MaxBox[3] > Box[3]? MaxBox[3]:Box[3];
MaxBox[4] = MaxBox[4] > Box[4]? MaxBox[4]:Box[4];
MaxBox[5] = MaxBox[5] > Box[5]? MaxBox[5]:Box[5];
}
UF_CURVE_line_t Line_coords1[3];
Line_coords1[0].start_point[0] = (MaxBox[0] + MaxBox[3])/2;
Line_coords1[0].start_point[1] = (MaxBox[1] + MaxBox[4])/2;
Line_coords1[0].start_point[2] = (MaxBox[2]);
Line_coords1[0].end_point[0] = (MaxBox[0] + MaxBox[3])/2;
Line_coords1[0].end_point[1] = (MaxBox[1] + MaxBox[4])/2;
Line_coords1[0].end_point[2] = MaxBox[5];
Line_coords1[1].start_point[0] = (MaxBox[0] + MaxBox[3])/2;
Line_coords1[1].start_point[1] = MaxBox[1];
Line_coords1[1].start_point[2] = (MaxBox[2] + MaxBox[5])/2;
Line_coords1[1].end_point[0] = (MaxBox[0] + MaxBox[3])/2;
Line_coords1[1].end_point[1] = MaxBox[4];
Line_coords1[1].end_point[2] = (MaxBox[2] + MaxBox[5])/2;
Line_coords1[2].start_point[0] = MaxBox[0];
Line_coords1[2].start_point[1] = (MaxBox[1] + MaxBox[4])/2;
Line_coords1[2].start_point[2] = (MaxBox[2] + MaxBox[5])/2;
Line_coords1[2].end_point[0] = MaxBox[3];
Line_coords1[2].end_point[1] = (MaxBox[1] + MaxBox[4])/2;
Line_coords1[2].end_point[2] = (MaxBox[2] + MaxBox[5])/2;
tag_t Line1[3];
UF_CURVE_create_line(&Line_coords1[0], &Line1[0]);
UF_CURVE_create_line(&Line_coords1[1], &Line1[1]);
UF_CURVE_create_line(&Line_coords1[2], &Line1[2]);
UF_OBJ_set_color(Line1[0],186);UF_OBJ_set_color(Line1[1],186);UF_OBJ_set_color(Line1[2],186);
UF_OBJ_set_font(Line1[0],UF_OBJ_FONT_CENTERLINE);
UF_OBJ_set_font(Line1[1],UF_OBJ_FONT_CENTERLINE);
UF_OBJ_set_font(Line1[2],UF_OBJ_FONT_CENTERLINE);
}
}
UF_terminate();
}

0

最新回复 (0)
请登录后发表新帖