示例#1
0
void testIntersection3D()
{
    Mesh3D mesh;
    AxisAlignedBox3d box(Vector3dd(-100, -100, -100), Vector3dd(100, 100, 100));
    ConvexPolyhedron poly(box);

    mesh.switchColor();
    mesh.currentColor = RGBColor::Blue();
    mesh.addAOB(box, false);
    Ray3d ray(Vector3dd(-120, -90, -80), Vector3dd(2.0,1.1,1.5));

    mesh.currentColor = RGBColor::White();
    mesh.addLine(ray.getPoint(0), ray.getPoint(5.0));


    double t1, t2;
    bool result = ray.clip<ConvexPolyhedron> (poly, t1, t2);

    mesh.currentColor = result ? RGBColor::Green() : RGBColor::Red();
    mesh.addLine(ray.getPoint(t1), ray.getPoint(t2));

    ofstream file("test.ply", std::ios::out);
    mesh.dumpPLY(file);
    file.close();

}
TEST(OrientedBox, testOrientedBoxFromAligned)
{
    cout << "Starting test <orientedbox>" << endl;
    AxisAlignedBox3d A(Vector3dd(-1, -2, -3), Vector3dd(1, 2, 3));
    OrientedBox box(A);

    Mesh3D mesh;
    mesh.switchColor();
    dumpToMesh(box, mesh);

    box.transform(Matrix44::Shift(10,10,10) * Matrix44::RotationZ(degToRad(45)));

    dumpToMesh(box, mesh);
    mesh.dumpPLY("oob.ply");

    cout << "Test <orientedbox> PASSED" << endl;
}