vector<Point3d> computerPnt(tag_t edgeTAG, tag_t bodyTAG); //获取曲线上间隔80的点
vector<Point3d> Ufun::computerPnt(tag_t edgeTAG,tag_t bodyTAG) {
vector<Point3d> pnt;
double centerPnt[3] = { 0.0 };
double absStartPnt[3] = { 0.0 };
double absEndPnt[3] = { 0.0 };
Ufun::curveEndAndMidPnt(edgeTAG, absStartPnt, absEndPnt, centerPnt);
//发射射线找面
double identity_mtx[16] = { 0.0 };
UF_MTX4_identity(identity_mtx);
double direction[3] = { 0,0,1 };
int num_desired = 0;
int num_results = 0;
UF_MODL_ray_hit_point_info_t* hit_list;
UF_MODL_trace_a_ray(1, &bodyTAG, centerPnt, direction, identity_mtx, num_desired, &num_results, &hit_list);
tag_t faceTAG = hit_list[0].hit_face;
//获取面中点
int type = 0;
double absCentPnt[3] = { 0.0 };
double dir[3] = { 0.0 };
double box[6] = { 0.0 };
double radius = 0.0;
double rad_data = 0.0;
int norm_dir = 0;
UF_MODL_ask_face_data(faceTAG, &type, absCentPnt, dir, box, &radius, &rad_data, &norm_dir);
//根据面uv及线端点创建CSYS
double param[2] = { 0.0 };
double face_pnt[3] = { 0,0,0 };
UF_MODL_ask_face_parm(faceTAG, absCentPnt, param, face_pnt);
double point[3] = { 0.0 };
double u1[3] = { 0.0 };
double v1[3] = { 0.0 };
double u2[3] = { 0.0 };
double v2[3] = { 0.0 };
double unit_norm[3] = { 0.0 };
double radii[2] = { 0.0 };
UF_MODL_ask_face_props(faceTAG, param, point, u1, v1, u2, v2, unit_norm, radii);
double mtxValue[9] = { 0.0 };
UF_MTX3_initialize(u1, v1, mtxValue);
tag_t matrix_id = NULL_TAG;
UF_CSYS_create_matrix(mtxValue, &matrix_id);
tag_t csys_id = NULL_TAG;
UF_CSYS_create_csys(absStartPnt, matrix_id, &csys_id);
//---------------绝对坐标->CSYS
double tgStartPnt[3] = { 0 };
UF_VEC3_sub(absStartPnt, absStartPnt, tgStartPnt);
UF_MTX3_vec_multiply(tgStartPnt, mtxValue, tgStartPnt);
double tgEndPnt[3] = { 0 };
UF_VEC3_sub(absEndPnt, absStartPnt, tgEndPnt);
UF_MTX3_vec_multiply(tgEndPnt, mtxValue, tgEndPnt);
double tgCentPnt[3] = { 0 };
UF_VEC3_sub(absCentPnt, absStartPnt, tgCentPnt);
UF_MTX3_vec_multiply(tgCentPnt, mtxValue, tgCentPnt);
//获取偏移4mm的坐标
if ((int)tgStartPnt[0] == (int)tgEndPnt[0]) //X值相同,X轴偏移
{
if ((int)tgCentPnt[0] > 0)
{
tgStartPnt[0] = tgStartPnt[0] + 4;
tgEndPnt[0] = tgEndPnt[0] + 4;
}
else if ((int)tgCentPnt[0] < 0)
{
tgStartPnt[0] = tgStartPnt[0] - 4;
tgEndPnt[0] = tgEndPnt[0] - 4;
}
}
else if ((int)tgStartPnt[1] == (int)tgEndPnt[1]) //Y值相同,Y轴偏移
{
if ((int)tgCentPnt[1] > 0)
{
tgStartPnt[1] = tgStartPnt[1] + 4;
tgEndPnt[1] = tgEndPnt[1] + 4;
}
else if ((int)tgCentPnt[1] < 0)
{
tgStartPnt[1] = tgStartPnt[1] - 4;
tgEndPnt[1] = tgEndPnt[1] - 4;
}
}
//----------------线端点、面中点:CSYS->绝对坐标
double absTgStPnt[3] = { 0 };
UF_MTX3_vec_multiply_t(tgStartPnt, mtxValue, absTgStPnt);
UF_VEC3_add(absTgStPnt, absStartPnt, absTgStPnt);
double absTgEndPnt[3] = { 0 };
UF_MTX3_vec_multiply_t(tgEndPnt, mtxValue, absTgEndPnt);
UF_VEC3_add(absTgEndPnt, absStartPnt, absTgEndPnt);
double absStCentPnt[3] = { 0 };
UF_MTX3_vec_multiply_t(tgCentPnt, mtxValue, absStCentPnt);
UF_VEC3_add(absStCentPnt, absStartPnt, absStCentPnt);
//求曲线长度(绝对
double thimDist = 0;
UF_VEC3_distance(absTgStPnt, absTgEndPnt, &thimDist);
//求曲线中点(绝对
double absCurMidPnt[3] = { 0 };
UF_VEC3_midpt(absTgStPnt, absTgEndPnt, absCurMidPnt);
//-------------曲线中点:绝对->CSYS
double csCurMIdPnt[3] = { 0.0 };
UF_VEC3_sub(absCurMidPnt, absStartPnt, csCurMIdPnt);
UF_MTX3_vec_multiply(csCurMIdPnt, mtxValue, csCurMIdPnt);
//间隔80添加
int thimInter = 80;
if ((int)thimDist < 99)
{
/* tag_t pointTAG = NULL_TAG;
UF_CURVE_create_point(absCurMidPnt, &pointTAG);*/
Point3d temple;
temple.X = absCurMidPnt[0];
temple.Y = absCurMidPnt[1];
temple.Z = absCurMidPnt[2];
// temple = { absCurMidPnt[0],absCurMidPnt[1],absCurMidPnt[2] };
pnt.push_back(temple);
}
if ((int)thimDist >= 99 && (int)thimDist < 179)
{
double tempPnt1[3] = { 0.0 };
double tempPnt2[3] = { 0.0 };
if (fabs(tgStartPnt[0] - tgEndPnt[0]) < 0.01)
{ //坐标系X同,Y加减40
tempPnt1[0] = csCurMIdPnt[0];
tempPnt1[1] = csCurMIdPnt[1] - thimInter / 2;
tempPnt1[2] = csCurMIdPnt[2];
tempPnt2[0] = csCurMIdPnt[0];
tempPnt2[1] = csCurMIdPnt[1] + thimInter / 2;
tempPnt2[2] = csCurMIdPnt[2];
}
else if (fabs(tgStartPnt[1] - tgEndPnt[1]) < 0.01)
{
tempPnt1[0] = csCurMIdPnt[0] - thimInter / 2;
tempPnt1[1] = csCurMIdPnt[1];
tempPnt1[2] = csCurMIdPnt[2];
tempPnt2[0] = csCurMIdPnt[0] + (thimInter / 2);
tempPnt2[1] = csCurMIdPnt[1];
tempPnt2[2] = csCurMIdPnt[2];
}
//将CSYS得到的两点转回绝对坐标系
double absTempPnt1[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt1, mtxValue, absTempPnt1);
UF_VEC3_add(absTempPnt1, absStartPnt, absTempPnt1);
double absTempPnt2[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt2, mtxValue, absTempPnt2);
UF_VEC3_add(absTempPnt2, absStartPnt, absTempPnt2);
Point3d temple1;
temple1.X = absTempPnt1[0];
temple1.Y = absTempPnt1[1];
temple1.Z = absTempPnt1[2];
// temple1 = { absTempPnt1[0],absTempPnt1[1],absTempPnt1[2] };
pnt.push_back(temple1);
Point3d temple2;
temple2.X = absTempPnt2[0];
temple2.Y = absTempPnt2[1];
temple2.Z = absTempPnt2[2];
// temple2 = { absTempPnt2[0],absTempPnt2[1],absTempPnt2[2] };
pnt.push_back(temple2);
//tag_t pointTag1 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt1, &pointTag1);
//tag_t pointTag2 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt2, &pointTag2);
}
if ((int)thimDist >= 179 && (int)thimDist < 259)
{
/* tag_t midPntTag = NULL_TAG;
UF_CURVE_create_point(absCurMidPnt, &midPntTag);*/
double tempPnt1[3] = { 0.0 };
double tempPnt2[3] = { 0.0 };
if (fabs(tgStartPnt[0] - tgEndPnt[0]) < 0.01)//坐标系X同,Y加减40
{
tempPnt1[0] = csCurMIdPnt[0];
tempPnt1[1] = csCurMIdPnt[1] - thimInter;
tempPnt1[2] = csCurMIdPnt[2];
tempPnt2[0] = csCurMIdPnt[0];
tempPnt2[1] = csCurMIdPnt[1] + thimInter;
tempPnt2[2] = csCurMIdPnt[2];
}
else if (fabs(tgStartPnt[1] - tgEndPnt[1]) < 0.01)
{
tempPnt1[0] = csCurMIdPnt[0] - thimInter;
tempPnt1[1] = csCurMIdPnt[1];
tempPnt1[2] = csCurMIdPnt[2];
tempPnt2[0] = csCurMIdPnt[0] + thimInter;
tempPnt2[1] = csCurMIdPnt[1];
tempPnt2[2] = csCurMIdPnt[2];
}
//将CSYS得到的两点转回绝对坐标系
double absTempPnt1[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt1, mtxValue, absTempPnt1);
UF_VEC3_add(absTempPnt1, absStartPnt, absTempPnt1);
double absTempPnt2[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt2, mtxValue, absTempPnt2);
UF_VEC3_add(absTempPnt2, absStartPnt, absTempPnt2);
Point3d temple;
temple.X = absCurMidPnt[0];
temple.Y = absCurMidPnt[1];
temple.Z = absCurMidPnt[2];
// temple = { absCurMidPnt[0],absCurMidPnt[1],absCurMidPnt[2] };
pnt.push_back(temple);
Point3d temple1;
temple1.X = absTempPnt1[0];
temple1.Y = absTempPnt1[1];
temple1.Z = absTempPnt1[2];
// temple1 = { absTempPnt1[0],absTempPnt1[1],absTempPnt1[2] };
pnt.push_back(temple1);
Point3d temple2;
temple2.X = absTempPnt2[0];
temple2.Y = absTempPnt2[1];
temple2.Z = absTempPnt2[2];
// temple2 = { absTempPnt2[0],absTempPnt2[1],absTempPnt2[2] };
pnt.push_back(temple2);
创建点
//tag_t pointTag1 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt1, &pointTag1);
//tag_t pointTag2 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt2, &pointTag2);
}
if ((int)thimDist >= 259 && (int)thimDist < 339)
{
double tempPnt1[3] = { 0.0 };
double tempPnt2[3] = { 0.0 };
double tempPnt3[3] = { 0.0 };
double tempPnt4[3] = { 0.0 };
//判断线在那个轴上,决定X或者Y加减40/80
if (fabs(tgStartPnt[0] - tgEndPnt[0]) < 0.01)
{
tempPnt1[0] = csCurMIdPnt[0];
tempPnt1[1] = csCurMIdPnt[1] - thimInter / 2;
tempPnt1[2] = csCurMIdPnt[2];
tempPnt2[0] = csCurMIdPnt[0];
tempPnt2[1] = csCurMIdPnt[1] + thimInter / 2;
tempPnt2[2] = csCurMIdPnt[2];
tempPnt3[0] = csCurMIdPnt[0];
tempPnt3[1] = csCurMIdPnt[1] - thimInter / 2 - thimInter;
tempPnt3[2] = csCurMIdPnt[2];
tempPnt4[0] = csCurMIdPnt[0];
tempPnt4[1] = csCurMIdPnt[1] + thimInter / 2 + thimInter;
tempPnt4[2] = csCurMIdPnt[2];
}
else if (fabs(tgStartPnt[1] - tgEndPnt[1]) < 0.01)
{
tempPnt1[0] = csCurMIdPnt[0] - thimInter / 2;
tempPnt1[1] = csCurMIdPnt[1];
tempPnt1[2] = csCurMIdPnt[2];
tempPnt2[0] = csCurMIdPnt[0] + (thimInter / 2);
tempPnt2[1] = csCurMIdPnt[1];
tempPnt2[2] = csCurMIdPnt[2];
tempPnt3[0] = csCurMIdPnt[0] - thimInter / 2 - thimInter;
tempPnt3[1] = csCurMIdPnt[1];
tempPnt3[2] = csCurMIdPnt[2];
tempPnt4[0] = csCurMIdPnt[0] + thimInter / 2 + thimInter;
tempPnt4[1] = csCurMIdPnt[1];
tempPnt4[2] = csCurMIdPnt[2];
}
//将CSYS得到的四点转回绝对坐标系
double absTempPnt1[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt1, mtxValue, absTempPnt1);
UF_VEC3_add(absTempPnt1, absStartPnt, absTempPnt1);
double absTempPnt2[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt2, mtxValue, absTempPnt2);
UF_VEC3_add(absTempPnt2, absStartPnt, absTempPnt2);
double absTempPnt3[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt3, mtxValue, absTempPnt3);
UF_VEC3_add(absTempPnt3, absStartPnt, absTempPnt3);
double absTempPnt4[3] = { 0.0 };
UF_MTX3_vec_multiply_t(tempPnt4, mtxValue, absTempPnt4);
UF_VEC3_add(absTempPnt4, absStartPnt, absTempPnt4);
Point3d temple1;
temple1.X = absTempPnt1[0];
temple1.Y = absTempPnt1[1];
temple1.Z = absTempPnt1[2];
// temple1 = { absTempPnt1[0],absTempPnt1[1],absTempPnt1[2] };
pnt.push_back(temple1);
Point3d temple2;
temple2.X = absTempPnt2[0];
temple2.Y = absTempPnt2[1];
temple2.Z = absTempPnt2[2];
// temple2 = { absTempPnt2[0],absTempPnt2[1],absTempPnt2[2] };
pnt.push_back(temple2);
Point3d temple3;
temple3.X = absTempPnt3[0];
temple3.Y = absTempPnt3[1];
temple3.Z = absTempPnt3[2];
// temple3 = { absTempPnt3[0],absTempPnt3[1],absTempPnt3[2] };
pnt.push_back(temple3);
Point3d temple4;
temple4.X = absTempPnt4[0];
temple4.Y = absTempPnt4[1];
temple4.Z = absTempPnt4[2];
pnt.push_back(temple4);
};
//tag_t pointTag1 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt1, &pointTag1);
//tag_t pointTag2 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt2, &pointTag2);
//tag_t pointTag3 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt3, &pointTag3);
//tag_t pointTag4 = NULL_TAG;
//UF_CURVE_create_point(absTempPnt4, &pointTag4);
return pnt;
}