MantisBT
Mantis Bug Tracker Workflow

View Revisions: Issue #26930 All Revisions ] Back to Issue ]
Summary 0026930: ShapeConstruct_ProjectCurveOnSurface returns a B-Spline instead of line (again)
Revision 2016-01-29 18:51 by ika
Steps To Reproduce test cases:
bugs heal bug26930_1 bug26930_2

Handle(Geom2d_Curve) MakeCurve2d (const Handle(Geom_Curve)& theCurve,
                                  const Standard_Real theFirst,
                                  const Standard_Real theLast,
                                  const Handle(Geom_Surface)& theSurface,
                                  const Standard_Real theTol)
{
    Handle (Geom2d_Curve) aPCurve;

    ShapeConstruct_ProjectCurveOnSurface aProj;
    aProj.Init (theSurface, theTol);
    {
    try {
        Handle (Geom_Curve) aCurve = theCurve; //to use reference in Perform()
        aProj.Perform (aCurve, theFirst, theLast, aPCurve);
    } catch (const Standard_Failure&) {
    }
    }

    if (!aPCurve.IsNull()) {
        //ShapeConstruct_ProjectCurveOnSurface has 2 peculiarities:
        //1. curves projected on planes lose a range (looks like a bug)
        //2. curves projected as iso-lines are constructed as trims on lines (range differs from original)
        if (theSurface->IsKind (STANDARD_TYPE (Geom_Plane))) {
            Handle(Geom2d_Curve) aNewPCurve = Trim (aPCurve, theFirst, theLast, Standard_True);
            aPCurve = aNewPCurve;
        } else if (aPCurve->IsKind (STANDARD_TYPE (Geom2d_Line))) {
            aPCurve = new Geom2d_TrimmedCurve(aPCurve, theFirst, theLast);
        } else if (aPCurve->IsKind (STANDARD_TYPE (Geom2d_TrimmedCurve))) {
            assert (Handle(Geom2d_TrimmedCurve)::DownCast (aPCurve)->BasisCurve()->
                IsKind (STANDARD_TYPE (Geom2d_Line)));
            //convert to B-Spline and reparametrize
            Handle(Geom2d_BSplineCurve) aBs = Geom2dConvert::CurveToBSplineCurve (aPCurve);
            //Standard_Boolean aRes = Reparametrize (aBs, theFirst, theLast);
            aPCurve = aBs;
        }
    }

    return aPCurve;
}


void Algo_CurveTest::Project2d_data()
{
    QTest::addColumn<QString>("dir");
    QTest::addColumn<QString>("curve");
    QTest::addColumn<double>("first");
    QTest::addColumn<double>("last");
    QTest::addColumn<QString>("surface");
    QTest::addColumn<QString>("result");

    QString aPref (TestLib::ModelsDir() + "ut/misc/project/");

    QTest::newRow("ElipConvx3.33.sat") << aPref << "projc6" << 0.0 << 14.3316 << "projs6" <<
#if OCC_VERSION_HEX >= 0x070000
    "projresc6_700";
#elif OCC_VERSION_HEX >= 0x060900
    "projresc6_690";
#elif OCC_VERSION_HEX >= 0x060701
    "projresc6_671";
#else
    "projresc6_670";
#endif
}

void Algo_CurveTest::Project2d()
{
    QFETCH(QString, dir);
    QFETCH(QString, curve);
    QFETCH(double, first);
    QFETCH(double, last);
    QFETCH(QString, surface);
    QFETCH(QString, result);

    //curve
    Handle(Geom_Curve) aC;
    QVERIFY (Read (dir + curve, aC));
    QVERIFY (!aC.IsNull());

    //surface
    Handle(Geom_Surface) aS;
    QVERIFY (Read (dir + surface, aS));
    QVERIFY (!aS.IsNull());

    //algorithm
    Handle(Geom2d_Curve) aPCurve = MakeCurve2d (aC, first, last, aS, Precision::Confusion());
    QVERIFY (!aPCurve.IsNull());

    //compare with expected result...
}

Revision 2015-11-26 10:18 by Roman Lygin
Steps To Reproduce Handle(Geom2d_Curve) MakeCurve2d (const Handle(Geom_Curve)& theCurve,
                                  const Standard_Real theFirst,
                                  const Standard_Real theLast,
                                  const Handle(Geom_Surface)& theSurface,
                                  const Standard_Real theTol)
{
    Handle (Geom2d_Curve) aPCurve;

    ShapeConstruct_ProjectCurveOnSurface aProj;
    aProj.Init (theSurface, theTol);
    {
    try {
        Handle (Geom_Curve) aCurve = theCurve; //to use reference in Perform()
        aProj.Perform (aCurve, theFirst, theLast, aPCurve);
    } catch (const Standard_Failure&) {
    }
    }

    if (!aPCurve.IsNull()) {
        //ShapeConstruct_ProjectCurveOnSurface has 2 peculiarities:
        //1. curves projected on planes lose a range (looks like a bug)
        //2. curves projected as iso-lines are constructed as trims on lines (range differs from original)
        if (theSurface->IsKind (STANDARD_TYPE (Geom_Plane))) {
            Handle(Geom2d_Curve) aNewPCurve = Trim (aPCurve, theFirst, theLast, Standard_True);
            aPCurve = aNewPCurve;
        } else if (aPCurve->IsKind (STANDARD_TYPE (Geom2d_Line))) {
            aPCurve = new Geom2d_TrimmedCurve(aPCurve, theFirst, theLast);
        } else if (aPCurve->IsKind (STANDARD_TYPE (Geom2d_TrimmedCurve))) {
            assert (Handle(Geom2d_TrimmedCurve)::DownCast (aPCurve)->BasisCurve()->
                IsKind (STANDARD_TYPE (Geom2d_Line)));
            //convert to B-Spline and reparametrize
            Handle(Geom2d_BSplineCurve) aBs = Geom2dConvert::CurveToBSplineCurve (aPCurve);
            //Standard_Boolean aRes = Reparametrize (aBs, theFirst, theLast);
            aPCurve = aBs;
        }
    }

    return aPCurve;
}


void Algo_CurveTest::Project2d_data()
{
    QTest::addColumn<QString>("dir");
    QTest::addColumn<QString>("curve");
    QTest::addColumn<double>("first");
    QTest::addColumn<double>("last");
    QTest::addColumn<QString>("surface");
    QTest::addColumn<QString>("result");

    QString aPref (TestLib::ModelsDir() + "ut/misc/project/");

    QTest::newRow("ElipConvx3.33.sat") << aPref << "projc6" << 0.0 << 14.3316 << "projs6" <<
#if OCC_VERSION_HEX >= 0x070000
    "projresc6_700";
#elif OCC_VERSION_HEX >= 0x060900
    "projresc6_690";
#elif OCC_VERSION_HEX >= 0x060701
    "projresc6_671";
#else
    "projresc6_670";
#endif
}

void Algo_CurveTest::Project2d()
{
    QFETCH(QString, dir);
    QFETCH(QString, curve);
    QFETCH(double, first);
    QFETCH(double, last);
    QFETCH(QString, surface);
    QFETCH(QString, result);

    //curve
    Handle(Geom_Curve) aC;
    QVERIFY (Read (dir + curve, aC));
    QVERIFY (!aC.IsNull());

    //surface
    Handle(Geom_Surface) aS;
    QVERIFY (Read (dir + surface, aS));
    QVERIFY (!aS.IsNull());

    //algorithm
    Handle(Geom2d_Curve) aPCurve = MakeCurve2d (aC, first, last, aS, Precision::Confusion());
    QVERIFY (!aPCurve.IsNull());

    //compare with expected result...
}



Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker