View Issue Details

IDProjectCategoryView StatusLast Update
0030316CommunityOCCT:Modeling Algorithmspublic2018-10-28 09:50
Reporterabdullah Assigned Tomsv 
PrioritynormalSeveritymajor 
Status newResolutionopen 
PlatformUbuntu 18.04.1 LTS 64-bit 
Product Version7.3.0 
Summary0030316: GeomAPI_ExtremaCurveCurve fails to detect intersection
Description
All the intersections of two offset curves, each of the offset curves having a basis curve being an arc of ellipse, are not detected by the GeomAPI_ExtremaCurveCurve algorithm.

In the attached pictures you can see the two original arcs and the two offset curves on those arcs. This report is about the two intersections of the offset curves, so the intersection is not at the endpoint like in ticket 0030217.

The algorithm only detects the bottom intersection, but not the one at the top (around [-7.1,-0.5]).

More information about what is being tried to accomplish in here:
https://forum.freecadweb.org/viewtopic.php?f=10&t=31700&p=265165#p265038
Steps To Reproduce


///// c++ code
# include <Geom_Ellipse.hxx>
# include <Geom_Curve.hxx>
# include <Geom_TrimmedCurve.hxx>
# include <Geom_OffsetCurve.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>


# include <GC_MakeEllipse.hxx>
# include <GC_MakeSegment.hxx>
# include <GC_MakeArcOfEllipse.hxx>

# include <gp.hxx>
# include <gp_Ax2.hxx>
# include <gp_Pnt.hxx>
# include <gp_Dir.hxx>
# include <gp_Pln.hxx>
# include <gp_Elips.hxx>

# include <GeomAPI.hxx>
# include <Geom2d_Curve.hxx>
# include <Geom2dAPI_InterCurveCurve.hxx>
# include <GeomAPI_ExtremaCurveCurve.hxx>

int main()
{

    double precision = 1.0e-8;

    // A first arc of ellipse
    // ArcOfEllipse (MajorRadius : 3.28231, MinorRadius : 3.22419, AngleXU : 3.05018,
    // Position : (-10.1267, -3.83438, 0), Direction : (0, 0, 1), Parameter : (3.74954, 8.81587))
    gp_Pnt p1(-10.1267,-3.83438,0);
    gp_Dir norm(0,0,1);

    gp_Ax1 normaxis(p1,norm);

    gp_Ax2 xdir(p1, norm);

    xdir.Rotate(normaxis,3.05018);

    GC_MakeEllipse mc(xdir, 3.28231, 3.22419);

    if (!mc.IsDone()) {
    printf("First ellipse not done");
    return -1;
    }

    GC_MakeArcOfEllipse ma(mc.Value()->Elips(), 3.74954, 8.81587, 1);

    if (!ma.IsDone()) {
        printf("First arc of ellipse not done");
    return -1;
    }

    Handle(Geom_TrimmedCurve) aoe1 = ma.Value();

    // A second arc of ellipse
    // ArcOfEllipse (MajorRadius : 3.7124, MinorRadius : 3.54058, AngleXU : 0.179513,
    // Position : (-4.28788, -4.29777, 0), Direction : (0, -0, 1), Parameter : (3.42763, 8.6199))

    gp_Pnt p2(-4.28788, -4.29777, 0);
    gp_Dir norm2(0,0,1);

    gp_Ax1 normaxis2(p2,norm2);

    gp_Ax2 xdir2(p2, norm2);

    xdir2.Rotate(normaxis2, 0.179513);

    GC_MakeEllipse mc2(xdir2, 3.7124, 3.54058);

    if (!mc2.IsDone()){
        printf("Second ellipse not done");
    return -1;
    }

    GC_MakeArcOfEllipse ma2(mc2.Value()->Elips(), 3.42763, 8.6199, 1);

    if (!ma2.IsDone()){
        printf("Second arc of ellipse not done");
    return -1;
    }

    Handle(Geom_TrimmedCurve) aoe2 = ma2.Value();

    // TEST SETUP: OUTPUT CURVES

    printf("\nOUTPUT VALUES OF THE CURVES:\n");

    auto printcurve = [](Handle(Geom_Curve) c, char const* title) {
    printf("\n%s :\n",title);
        for(double param = c->FirstParameter(); param < c->LastParameter(); param = param + (c->LastParameter()-c->FirstParameter())/10)
            printf("%f: (%f,%f,0)\n", param, c->Value(param).X(),c->Value(param).Y());

          printf("%f: (%f,%f,0)\n", c->LastParameter(), c->Value(c->LastParameter()).X(),c->Value(c->LastParameter()).Y());

    };

    printcurve(aoe1,"Arc of Ellipse 1");
    printcurve(aoe2,"Arc of Ellipse 2");

    // Construct Offset curves from the Arc of Ellipses
    double offset = 1.358370;
    gp_Dir norm3(0,0,1);

    Handle(Geom_OffsetCurve) oaoe1 = new Geom_OffsetCurve(aoe1, offset, norm3);
    Handle(Geom_OffsetCurve) oaoe2 = new Geom_OffsetCurve(aoe2, offset, norm3);

    printcurve(oaoe1,"Offset Arc of Ellipse 1");
    printcurve(oaoe2,"Offset Arc of Ellipse 2");

    // From the output, there are two intersections:
    //Offset Arc of Ellipse 1 :
    //3.749540: (-6.100171,-1.565646,0) <= Cross 1 of offset curves
    //4.256173: (-7.723394,0.080638,0) <= Cross 1 of offset curves
    //4.762806: (-9.940595,0.744547,0)
    //5.269439: (-12.205122,0.267937,0)
    //5.776072: (-13.957389,-1.239283,0)
    //6.282705: (-14.747802,-3.408550,0)
    //6.789338: (-14.367174,-5.685738,0)
    //7.295971: (-12.919871,-7.487803,0)
    //7.802604: (-10.780575,-8.370205,0)
    //8.309237: (-8.479384,-8.122642,0) <= Cross 2 of offset curves
    //8.815870: (-6.582633,-6.800723,0) <= Cross 2 of offset curves

    //Offset Arc of Ellipse 2 :
    //3.427630: (-8.819565,-6.542242,0) <= Cross 2 of offset curves
    //3.946857: (-7.087416,-8.418028,0) <= Cross 2 of offset curves
    //4.466084: (-4.641189,-9.194190,0)
    //4.985311: (-2.115470,-8.702613,0)
    //5.504538: (-0.140323,-7.064943,0)
    //6.023765: (0.757442,-4.675394,0)
    //6.542992: (0.302230,-2.169759,0)
    //7.062219: (-1.378655,-0.248668,0)
    //7.581446: (-3.803608,0.589678,0)
    //8.100673: (-6.340850,0.161532,0) <= Cross 1 of offset curves
    //8.619900: (-8.357785,-1.425408,0) <= Cross 1 of offset curves

    // Calculate intersection of offset curves

    printf("\nCalculate intersection of offset curves\n");

    GeomAPI_ExtremaCurveCurve intersector(oaoe1, oaoe2);

    if (intersector.NbExtrema() == 0 || intersector.LowerDistance() > precision) {
        // No intersection
    printf("\nNo intersection between offset curves\n");
        return -1;
    }
    printf("\nGeomAPI_ExtremaCurveCurve NbExtrema = %d\n",intersector.NbExtrema());

    for (int i = 1; i <= intersector.NbExtrema(); i++) {
        if (intersector.Distance(i) > precision)
            continue;

        gp_Pnt p1, p2;
        intersector.Points(i, p1, p2);

    printf("\tExtrema nr %d: (%f,%f,%f),(%f,%f,%f)\n",i,p1.X(),p1.Y(),p1.Z(),p2.X(),p2.Y(),p2.Z());
    }

    return 0;
}

under ubuntu can be compiled as:

g++ intersector3.cpp -I/usr/include/occt -L/usr/lib/x86_64-linux-gnu -lTKG3d -lTKernel -lTKMath -lTKGeomBase -lTKGeomAlgo -o intersector3
Additional information
and documentation updates
May be related to ticket 30217

Output of the binary:
OUTPUT VALUES OF THE CURVES:

Arc of Ellipse 1 :
3.749540: (-7.275644,-2.246404,0)
4.256173: (-8.422482,-1.084028,0)
4.762806: (-9.997476,-0.612632,0)
5.269439: (-11.604936,-0.950647,0)
5.776072: (-12.841013,-2.013152,0)
6.282705: (-13.395164,-3.533211,0)
6.789338: (-13.128167,-5.128934,0)
7.295971: (-12.107101,-6.399421,0)
7.802604: (-10.588492,-7.025484,0)
8.309237: (-8.953866,-6.849835,0)
8.815870: (-7.613894,-5.916603,0)

Arc of Ellipse 2 :
3.427630: (-7.613843,-5.916620,0)
3.946857: (-6.363137,-7.268858,0)
4.466084: (-4.565407,-7.837935,0)
4.985311: (-2.694522,-7.473846,0)
5.504538: (-1.243637,-6.272562,0)
6.023765: (-0.595196,-4.550735,0)
6.542992: (-0.920124,-2.762228,0)
7.062219: (-2.132772,-1.378480,0)
7.581446: (-3.913494,-0.764240,0)
8.100673: (-5.792902,-1.081417,0)
8.619900: (-7.275595,-2.246405,0)

Offset Arc of Ellipse 1 :
3.749540: (-6.100171,-1.565646,0)
4.256173: (-7.723394,0.080638,0)
4.762806: (-9.940595,0.744547,0)
5.269439: (-12.205122,0.267937,0)
5.776072: (-13.957389,-1.239283,0)
6.282705: (-14.747802,-3.408550,0)
6.789338: (-14.367174,-5.685738,0)
7.295971: (-12.919871,-7.487803,0)
7.802604: (-10.780575,-8.370205,0)
8.309237: (-8.479384,-8.122642,0)
8.815870: (-6.582633,-6.800723,0)

Offset Arc of Ellipse 2 :
3.427630: (-8.819565,-6.542242,0)
3.946857: (-7.087416,-8.418028,0)
4.466084: (-4.641189,-9.194190,0)
4.985311: (-2.115470,-8.702613,0)
5.504538: (-0.140323,-7.064943,0)
6.023765: (0.757442,-4.675394,0)
6.542992: (0.302230,-2.169759,0)
7.062219: (-1.378655,-0.248668,0)
7.581446: (-3.803608,0.589678,0)
8.100673: (-6.340850,0.161532,0)
8.619900: (-8.357785,-1.425408,0)

Calculate intersection of offset curves

GeomAPI_ExtremaCurveCurve NbExtrema = 1
        Extrema nr 1: (-7.845691,-7.830647,0.000000),(-7.845691,-7.830647,0.000000)
TagsNo tags attached.
Test case number

Attached Files

  • sage0.png (35,765 bytes)

Activities

abdullah

2018-10-28 09:50

reporter  

sage0.png (35,765 bytes)

Issue History

Date Modified Username Field Change
2018-10-28 09:50 abdullah New Issue
2018-10-28 09:50 abdullah Assigned To => msv
2018-10-28 09:50 abdullah File Added: sage0.png