|
|
@ -145,25 +145,26 @@ inline double distan(P A, P B, int inOut1, int inOut2) |
|
|
|
double len = distan1(A, B); |
|
|
|
|
|
|
|
// 求交判断并赋值惩罚参数
|
|
|
|
if (intersection_model == 1) |
|
|
|
// if (0)
|
|
|
|
{ |
|
|
|
LineSegment lineSegment(Vec3f(A.x, A.y, A.z), Vec3f(B.x, B.y, B.z)); |
|
|
|
static BVH_intersection bvh(mesh); |
|
|
|
bool hit = bvh.intersectWithLineSegment(lineSegment); |
|
|
|
if (hit == 0) |
|
|
|
penalty_par_intersection = 1; |
|
|
|
else |
|
|
|
penalty_par_intersection = 100; //*原400
|
|
|
|
// cout << "out: len:" << len << " intersection_distance" << intersection_distance << endl;
|
|
|
|
//----------------------mark-----------------------//
|
|
|
|
// 注释下面效果可能好
|
|
|
|
// if (len > intersection_distance)
|
|
|
|
// penalty_par_distance = 8;
|
|
|
|
// else
|
|
|
|
// penalty_par_distance = 1;
|
|
|
|
} |
|
|
|
|
|
|
|
// if (intersection_model == 1)
|
|
|
|
// {
|
|
|
|
// LineSegment lineSegment(Vec3f(A.x, A.y, A.z), Vec3f(B.x, B.y, B.z));
|
|
|
|
// static BVH_intersection bvh(mesh);
|
|
|
|
// bool hit = bvh.intersectWithLineSegment(lineSegment);
|
|
|
|
// if (hit == 0)
|
|
|
|
// penalty_par_intersection = 1;
|
|
|
|
// else
|
|
|
|
// penalty_par_intersection = 100; //*原400
|
|
|
|
// // cout << "out: len:" << len << " intersection_distance" << intersection_distance << endl;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//----------------------mark-----------------------
|
|
|
|
//注释以支持多线缆,这里惩罚参数不够精细,会导致多线缆失败
|
|
|
|
// if (len > intersection_distance)
|
|
|
|
// penalty_par_distance = 8;
|
|
|
|
// else
|
|
|
|
// penalty_par_distance = 1;
|
|
|
|
|
|
|
|
|
|
|
|
double len1 = sqrt((A.y - Ycenter) * (A.y - Ycenter) + (A.z - Zcenter) * (A.z - Zcenter)); |
|
|
|
double len2 = sqrt((B.y - Ycenter) * (B.y - Ycenter) + (B.z - Zcenter) * (B.z - Zcenter)); |
|
|
|
if (len1 < R || len2 < R) |
|
|
@ -227,22 +228,24 @@ inline double distan(P A, P B) |
|
|
|
angel = min(angel, pi / 2 - angel); |
|
|
|
double len = distan1(A, B); |
|
|
|
|
|
|
|
if (intersection_model == 1) |
|
|
|
// if(0)
|
|
|
|
{ |
|
|
|
LineSegment lineSegment(Vec3f(A.x, A.y, A.z), Vec3f(B.x, B.y, B.z)); |
|
|
|
static BVH_intersection bvh(mesh); |
|
|
|
bool hit = bvh.intersectWithLineSegment(lineSegment); |
|
|
|
if (hit == 0) |
|
|
|
penalty_par_intersection = 1; |
|
|
|
else |
|
|
|
penalty_par_intersection = 100; //*原400
|
|
|
|
// cout << "no_out: len:" << len << " intersection_distance" << intersection_distance << endl;
|
|
|
|
if (len > intersection_distance) |
|
|
|
penalty_par_distance = 8; |
|
|
|
else |
|
|
|
penalty_par_distance = 1; |
|
|
|
} |
|
|
|
// if (intersection_model == 1)
|
|
|
|
// {
|
|
|
|
// LineSegment lineSegment(Vec3f(A.x, A.y, A.z), Vec3f(B.x, B.y, B.z));
|
|
|
|
// static BVH_intersection bvh(mesh);
|
|
|
|
// bool hit = bvh.intersectWithLineSegment(lineSegment);
|
|
|
|
// if (hit == 0)
|
|
|
|
// penalty_par_intersection = 1;
|
|
|
|
// else
|
|
|
|
// penalty_par_intersection = 100; //*原400
|
|
|
|
// // cout << "no_out: len:" << len << " intersection_distance" << intersection_distance << endl;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//----------------------mark-----------------------
|
|
|
|
//注释以支持多线缆,这里惩罚参数不够精细,会导致多线缆失败
|
|
|
|
// if (len > intersection_distance)
|
|
|
|
// penalty_par_distance = 8;
|
|
|
|
// else
|
|
|
|
// penalty_par_distance = 1;
|
|
|
|
|
|
|
|
double len1 = sqrt((A.y - Ycenter) * (A.y - Ycenter) + (A.z - Zcenter) * (A.z - Zcenter)); |
|
|
|
double len2 = sqrt((B.y - Ycenter) * (B.y - Ycenter) + (B.z - Zcenter) * (B.z - Zcenter)); |
|
|
|