|
[code]bool
myfunc(AcGeLineSeg3d x, AcGeLineSeg3d y, AcGeTol tol)
{
AcGeVector3d v1 = x.endPoint().asVector() - x.startPoint().asVector() ;
AcGeVector3d v2 = y.endPoint().asVector() - y.startPoint().asVector() ;
AcGeVector3d nulvec = AcGeVector3d::kIdentity;
v1.normalize();
v2.normalize();
AcGeVector3d sum = v1+v2;
AcGeVector3d dif = v1-v2;
AcGeTol zeroTol;
zeroTol.setEqualPoint(0.0);
zeroTol.setEqualVector(0.0);
if ((sum == nulvec) || (dif == nulvec))
return false;
//if(sum.isEqualTo(nulvec,zeroTol) || dif.isEqualTo(nulvec,zeroTol))
// return true;
return ! (v1.isParallelTo(v2, tol));
}
void AcGeLineSeg3dTest::intersection()
{
AcGeTol told;
double dtold=0.1;
told.setEqualPoint(dtold);
//told.setEqualPoint(1.0);
told.setEqualVector(dtold);
//told.setEqualVector(0.01);
AcGePoint3d ptInsd1;
Adesk::Boolean retdx = Adesk::kTrue, retd1= Adesk::kTrue;
double deltad = 1e-5, gap = 0.0;
unsigned long long x=0, NN=100000;
x=NN;
while(x--!=1)
{
AcGePoint3d pt1Adl(0.0,0.0+gap,0.0);
AcGePoint3d pt1Bdl(100.0,0.0,0.0);
AcGePoint3d pt2Adl(0.0,0.0,0.0);
AcGePoint3d pt2Bdl(100.0,0.0,0.0);
AcGeLineSeg3d lSeg1dl(pt1Adl,pt1Bdl);
AcGeLineSeg3d lSeg2dl(pt2Adl,pt2Bdl);
retdx = lSeg1dl.intersectWith(lSeg2dl,ptInsd1,told);
retd1 = myfunc(lSeg1dl, lSeg2dl, told);
if((retd1!=retdx))
break;
gap+=deltad;
//pt1Ad.set(pt1Ad.x+gap,pt1Ad.y,pt1Ad.z);
//lSeg1d.set(pt1Ad,pt1Bd);
}
CPPUNIT_ASSERT ( !x);
x=NN;
while(x--!=1)
{
AcGePoint3d pt1Adl(0.00000000 ,0.00000000+gap,0.00000000);
AcGePoint3d pt1Bdl(100.0000000 ,0.00000000,0.00000000);
AcGePoint3d pt2Adl(300.00000000 ,0.00000000 ,0.00000000);
AcGePoint3d pt2Bdl(100.00000000 ,0.00000000 ,0.00000000);
AcGeLineSeg3d lSeg1dl(pt1Adl,pt1Bdl);
AcGeLineSeg3d lSeg2dl(pt2Adl,pt2Bdl);
retd1 = lSeg1dl.intersectWith(lSeg2dl,ptInsd1,told);
retdx = myfunc(lSeg1dl, lSeg2dl, told);
if(retdx!=retd1)
break;
gap+=deltad;
//pt1Ad.set(pt1Ad.x+gap,pt1Ad.y,pt1Ad.z);
//lSeg1d.set(pt1Ad,pt1Bd);
}
CPPUNIT_ASSERT ( !x);
return;[/code] |
|