Example #1
0
// Returns the chord line as a wire
TopoDS_Wire CCPACSWingProfile::GetChordLineWire() 
{
    // convert 2d chordline to 3d
    Handle(Geom2d_TrimmedCurve) chordLine = GetChordLine();
    gp_Pnt origin;
    gp_Dir yDir(0.0, 1.0, 0.0);
    gp_Pln xzPlane(origin, yDir);
    Handle(Geom_Curve) chordLine3d = GeomAPI::To3d(chordLine, xzPlane);
    TopoDS_Edge chordEdge = BRepBuilderAPI_MakeEdge(chordLine3d);
    TopoDS_Wire chordWire = BRepBuilderAPI_MakeWire(chordEdge);
    return chordWire;
}
Example #2
0
void DoRayTest()
{
    Vector3 origin(0.0f, 0.0f, 0.0f);
    BoundingSphere sphere(origin, 10.0f);

    // Test 1: Ray hits a bounding sphere that the ray is inside of.
    {
        Ray ray(origin, Vector3(0.0f, 0.0f, 1.0f));

        if (!ray.hasIntersected(sphere))
            throw std::runtime_error("DoRayTest() : Test 1 failed");
    }

    // Test 2: Ray hits a bounding sphere.
    {
        Ray ray(Vector3(0.0f, 0.0f, 100.0f), Vector3(0.0f, 0.0f, -1.0f));

        if (!ray.hasIntersected(sphere))
            throw std::runtime_error("DoRayTest() : Test 2 failed");
    }

    // Test 3: Ray misses a bounding sphere.
    {
        Ray ray(Vector3(0.0f, 0.0f, 100.0f), Vector3(0.0f, 0.0f, 1.0f));

        if (ray.hasIntersected(sphere))
            throw std::runtime_error("DoRayTest() : Test 3 failed");
    }

    BoundingBox box(Vector3(-10.0f, -10.0f, -10.0f), Vector3(10.0f, 10.0f, 10.0f));

    // Test 4: Ray hits a bounding box that the ray is inside of.
    {
        Ray ray(origin, Vector3(0.0f, 0.0f, 1.0f));

        if (!ray.hasIntersected(box))
            throw std::runtime_error("DoRayTest() : Test 4 failed");
    }

    // Test 5: Ray hits a bounding box.
    {
        Ray ray(Vector3(0.0f, 0.0f, 100.0f), Vector3(0.0f, 0.0f, -1.0f));

        if (!ray.hasIntersected(box))
            throw std::runtime_error("DoRayTest() : Test 5 failed");
    }

    // Test 6: Ray misses a bounding box.
    {
        Ray ray(Vector3(0.0f, 0.0f, 100.0f), Vector3(0.0f, 0.0f, 1.0f));

        if (ray.hasIntersected(box))
            throw std::runtime_error("DoRayTest() : Test 6 failed");
    }

    Plane xzPlane(origin, Vector3(0.0f, 1.0f, 0.0f));

    // Test 7: Ray intersects a plane.
    {
        Ray ray(Vector3(0.0f, 10.0f, 0.0f), Vector3(0.0f, -1.0f, 0.0f));

        if (!ray.hasIntersected(xzPlane))
            throw std::runtime_error("DoRayTest() : Test 7 failed");
    }

    // Test 8: Ray misses a plane.
    {
        Ray ray(Vector3(0.0f, 10.0f, 0.0f), Vector3(0.0f, 1.0f, 0.0f));

        if (ray.hasIntersected(xzPlane))
            throw std::runtime_error("DoRayTest() : Test 8 failed");
    }

    // Test 9: Line segment intersects a plane.
    {
        Vector3 pt1(0.0f, -10.0f, 0.0f);
        Vector3 pt2(0.0f, 10.0f, 0.0f);
        Ray ray(pt1, pt2 - pt1);

        if (!ray.hasIntersected(xzPlane))
            throw std::runtime_error("DoRayTest() : Test 9 failed");
    }

    // Test 10: Line segment misses a plane.
    {
        Vector3 pt1(0.0f, 10.0f, 0.0f);
        Vector3 pt2(0.0f, 20.0f, 0.0f);
        Ray ray(pt1, pt2 - pt1);

        if (ray.hasIntersected(xzPlane))
            throw std::runtime_error("DoRayTest() : Test 10 failed");
    }
}