求三角形交线时候错误
3dface
-1.2251099999999999,-5.8899699999999999,-7.987949999999999
0.40490799999999999,-6.0014500000000002,-3.314319999999999
-1.2251099999999999,-5.8899699999999999,-3.314319999999999
3dface
-0.21243100000000001,-5.7414293000000001,-4.50379500000000
-0.15238699999999999,-6.0416264999999996,-4.51681199999999
-0.56714299999999995,-5.9451375000000004,-4.37800200000000
对以上2个三角形使用CGAL::intersection(triA, triB);,并不能找到交线,实际上是存在交线的,跟入cagl的内部代码查看
1.首先会找到三角形平面的交线
2.判断三角形的3个点在交线的哪一侧
Triangle_Line_Inter inter1 = intersection_coplanar(t1,*line,k);下的
const Orientation pqa = coplanar_orientation(p,q,a);
const Orientation pqb = coplanar_orientation(p,q,b);
const Orientation pqc = coplanar_orientation(p,q,c);
函数coplanar_orientationC3中直接先从x开始判断,然后y,然后z
x的微小容差会导致结果判断失败。
kernel_ftC3.h 194行的函数改为
template < class FT >
CGAL_KERNEL_MEDIUM_INLINE
typename Same_uncertainty_nt<Orientation, FT>::type
coplanar_orientationC3(const FT& px, const FT& py, const FT& pz,
const FT& qx, const FT& qy, const FT& qz,
const FT& rx, const FT& ry, const FT& rz)
{
typedef typename Same_uncertainty_nt<Orientation, FT>::type Ori;
FT num[3] =
{
determinant(qx - px, qy - py, rx - px, ry - py),
determinant(qy - py, qz - pz, ry - py, rz - pz),
determinant(qx - px, qz - pz, rx - px, rz - pz)
};
FT fnum[3];
for (int i = 0; i < 3; ++i)
{
fnum[i] = num[i] > 0 ? num[i] : -num[i];
}
int inx = fnum[1] > fnum[0] ? 1 : 0;
inx = fnum[inx] > fnum[2] ? inx : 2;
return enum_cast<Sign>(CGAL_NTS compare(num[inx], 0));
/* Ori oxy_pqr = orientationC2(px, py, qx, qy, rx, ry);
if (oxy_pqr != COLLINEAR)
return oxy_pqr;
Ori oyz_pqr = orientationC2(py, pz, qy, qz, ry, rz);
if (oyz_pqr != COLLINEAR)
return oyz_pqr;
return orientationC2(px, pz, qx, qz, rx, rz);*/
}后正确