mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024988: Wrong result done by projection algorithm
Wrong border 1.0e-9 jump has deleted. Added periodicity information when projecting to surface. Period "jump" bug fixes. AppCont_LeastSquare conversion to non cdl class. AppCont_Function + AppCont_FunctionTool combined in one class providing the same functionality and converted to non cdl. Testcase modification. Test cases for issue CR24988 Fixed incorrect comparison.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <AppCont_Function2d.hxx>
|
||||
#include <AppCont_Function.hxx>
|
||||
#include <Convert_CompBezierCurves2dToBSplineCurve2d.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
@@ -120,7 +120,9 @@ static gp_Pnt2d Function_Value(const Standard_Real U,
|
||||
|
||||
if ( UCouture) {
|
||||
if(S < U1 || S > U2)
|
||||
S = ElCLib::InPeriod(S, U1, U2);
|
||||
{
|
||||
S = ElCLib::InPeriod(S, U1, U2);
|
||||
}
|
||||
}
|
||||
|
||||
if ( VCouture) {
|
||||
@@ -755,39 +757,86 @@ static void Function_SetUVBounds(Standard_Real& myU1,
|
||||
//classn : ProjLib_Function
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
class ProjLib_Function : public AppCont_Function2d
|
||||
class ProjLib_Function : public AppCont_Function
|
||||
{
|
||||
Handle(Adaptor3d_HCurve) myCurve;
|
||||
Handle(Adaptor3d_HSurface) mySurface;
|
||||
|
||||
Standard_Boolean myIsPeriodic[2];
|
||||
Standard_Real myPeriod[2];
|
||||
public :
|
||||
|
||||
Standard_Real myU1,myU2,myV1,myV2;
|
||||
Standard_Boolean UCouture,VCouture;
|
||||
|
||||
|
||||
ProjLib_Function(const Handle(Adaptor3d_HCurve)& C,
|
||||
const Handle(Adaptor3d_HSurface)& S) :
|
||||
myCurve(C), mySurface(S),
|
||||
const Handle(Adaptor3d_HSurface)& S)
|
||||
: myCurve(C),
|
||||
mySurface(S),
|
||||
myU1(0.0),
|
||||
myU2(0.0),
|
||||
myV1(0.0),
|
||||
myV2(0.0),
|
||||
UCouture(Standard_False),
|
||||
VCouture(Standard_False)
|
||||
{Function_SetUVBounds(myU1,myU2,myV1,myV2,UCouture,VCouture,myCurve,mySurface);}
|
||||
|
||||
{
|
||||
myNbPnt = 0;
|
||||
myNbPnt2d = 1;
|
||||
Function_SetUVBounds(myU1,myU2,myV1,myV2,UCouture,VCouture,myCurve,mySurface);
|
||||
myIsPeriodic[0] = mySurface->IsUPeriodic();
|
||||
myIsPeriodic[1] = mySurface->IsVPeriodic();
|
||||
|
||||
if (myIsPeriodic[0])
|
||||
myPeriod[0] = mySurface->UPeriod();
|
||||
else
|
||||
myPeriod[0] = 0.0;
|
||||
|
||||
if (myIsPeriodic[1])
|
||||
myPeriod[1] = mySurface->VPeriod();
|
||||
else
|
||||
myPeriod[1] = 0.0;
|
||||
}
|
||||
|
||||
void PeriodInformation(const Standard_Integer theDimIdx,
|
||||
Standard_Boolean& IsPeriodic,
|
||||
Standard_Real& thePeriod) const
|
||||
{
|
||||
IsPeriodic = myIsPeriodic[theDimIdx - 1];
|
||||
thePeriod = myPeriod[theDimIdx - 1];
|
||||
}
|
||||
|
||||
Standard_Real FirstParameter() const
|
||||
{return (myCurve->FirstParameter() + 1.e-9);}
|
||||
|
||||
{
|
||||
return (myCurve->FirstParameter());
|
||||
}
|
||||
|
||||
Standard_Real LastParameter() const
|
||||
{return (myCurve->LastParameter() -1.e-9);}
|
||||
|
||||
|
||||
gp_Pnt2d Value(const Standard_Real t) const
|
||||
{return Function_Value(t,myCurve,mySurface,myU1,myU2,myV1,myV2,UCouture,VCouture);}
|
||||
|
||||
Standard_Boolean D1(const Standard_Real t, gp_Pnt2d& P, gp_Vec2d& V) const
|
||||
{return Function_D1(t,P,V,myCurve,mySurface,myU1,myU2,myV1,myV2,UCouture,VCouture);}
|
||||
{
|
||||
return (myCurve->LastParameter());
|
||||
}
|
||||
|
||||
Standard_Boolean Value(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Pnt2d>& thePnt2d,
|
||||
NCollection_Array1<gp_Pnt>& /*thePnt*/) const
|
||||
{
|
||||
thePnt2d(1) = Function_Value(theT, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
gp_Pnt2d Value(const Standard_Real theT) const
|
||||
{
|
||||
return Function_Value(theT, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture);
|
||||
}
|
||||
|
||||
Standard_Boolean D1(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Vec2d>& theVec2d,
|
||||
NCollection_Array1<gp_Vec>& /*theVec*/) const
|
||||
{
|
||||
gp_Pnt2d aPnt2d;
|
||||
gp_Vec2d aVec2d;
|
||||
Standard_Boolean isOk = Function_D1(theT, aPnt2d,aVec2d, myCurve, mySurface, myU1, myU2, myV1, myV2, UCouture, VCouture);
|
||||
theVec2d(1) = aVec2d;
|
||||
return isOk;
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
@@ -947,65 +996,44 @@ ProjLib_ComputeApprox::ProjLib_ComputeApprox
|
||||
|
||||
Conv.AddCurve(Poles2d);
|
||||
}
|
||||
|
||||
//mise a jour des fields de ProjLib_Approx
|
||||
|
||||
//mise a jour des fields de ProjLib_Approx
|
||||
Conv.Perform();
|
||||
|
||||
NbPoles = Conv.NbPoles();
|
||||
NbKnots = Conv.NbKnots();
|
||||
|
||||
//7626
|
||||
if(NbPoles <= 0 || NbPoles > 100000)
|
||||
return;
|
||||
return;
|
||||
if(NbKnots <= 0 || NbKnots > 100000)
|
||||
return;
|
||||
return;
|
||||
|
||||
TColgp_Array1OfPnt2d NewPoles(1,NbPoles);
|
||||
TColStd_Array1OfReal NewKnots(1,NbKnots);
|
||||
TColStd_Array1OfInteger NewMults(1,NbKnots);
|
||||
|
||||
|
||||
Conv.KnotsAndMults(NewKnots,NewMults);
|
||||
Conv.Poles(NewPoles);
|
||||
|
||||
|
||||
BSplCLib::Reparametrize(C->FirstParameter(),
|
||||
C->LastParameter(),
|
||||
NewKnots);
|
||||
|
||||
C->LastParameter(),
|
||||
NewKnots);
|
||||
|
||||
/*cout << endl;
|
||||
for (int i = 1; i <= NbPoles; i++)
|
||||
{
|
||||
cout << NewPoles.Value(i).X() << " " << NewPoles.Value(i).Y() << endl;
|
||||
}
|
||||
cout << endl; */
|
||||
|
||||
// il faut recadrer les poles de debut et de fin:
|
||||
// ( Car pour les problemes de couture, on a du ouvrir l`intervalle
|
||||
// de definition de la courbe.)
|
||||
// On choisit de calculer ces poles par prolongement de la courbe
|
||||
// approximee.
|
||||
|
||||
gp_Pnt2d P;
|
||||
Standard_Real U;
|
||||
|
||||
U = C->FirstParameter() - 1.e-9;
|
||||
BSplCLib::D0(U,
|
||||
0,
|
||||
Conv.Degree(),
|
||||
Standard_False,
|
||||
NewPoles,
|
||||
BSplCLib::NoWeights(),
|
||||
NewKnots,
|
||||
NewMults,
|
||||
P);
|
||||
NewPoles.SetValue(1,P);
|
||||
U = C->LastParameter() + 1.e-9;
|
||||
BSplCLib::D0(U,
|
||||
0,
|
||||
Conv.Degree(),
|
||||
Standard_False,
|
||||
NewPoles,
|
||||
BSplCLib::NoWeights(),
|
||||
NewKnots,
|
||||
NewMults,
|
||||
P);
|
||||
NewPoles.SetValue(NbPoles,P);
|
||||
myBSpline = new Geom2d_BSplineCurve (NewPoles,
|
||||
NewKnots,
|
||||
NewMults,
|
||||
Conv.Degree());
|
||||
NewKnots,
|
||||
NewMults,
|
||||
Conv.Degree());
|
||||
}
|
||||
else {
|
||||
Standard_Integer NbCurves = Fit.NbMultiCurves();
|
||||
|
@@ -14,7 +14,7 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ProjLib_ComputeApproxOnPolarSurface.hxx>
|
||||
#include <AppCont_Function2d.hxx>
|
||||
#include <AppCont_Function.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <BSplCLib.hxx>
|
||||
@@ -288,49 +288,54 @@ static gp_Pnt2d Function_Value(const Standard_Real U,
|
||||
//purpose : (OCC217 - apo)- This class produce interface to call "gp_Pnt2d Function_Value(...)"
|
||||
//=======================================================================
|
||||
|
||||
class ProjLib_PolarFunction : public AppCont_Function2d
|
||||
class ProjLib_PolarFunction : public AppCont_Function
|
||||
{
|
||||
Handle(Adaptor3d_HCurve) myCurve;
|
||||
Handle(Adaptor2d_HCurve2d) myInitialCurve2d ;
|
||||
Handle(Adaptor3d_HSurface) mySurface ;
|
||||
//OCC217
|
||||
Standard_Real myTolU, myTolV;
|
||||
Standard_Real myDistTol3d;
|
||||
//Standard_Real myTolerance ;
|
||||
|
||||
Handle(Adaptor2d_HCurve2d) myInitialCurve2d;
|
||||
Handle(Adaptor3d_HSurface) mySurface;
|
||||
Standard_Real myTolU, myTolV;
|
||||
Standard_Real myDistTol3d;
|
||||
|
||||
public :
|
||||
|
||||
|
||||
ProjLib_PolarFunction(const Handle(Adaptor3d_HCurve) & C,
|
||||
const Handle(Adaptor3d_HSurface)& Surf,
|
||||
const Handle(Adaptor2d_HCurve2d)& InitialCurve2d,
|
||||
//OCC217
|
||||
const Standard_Real Tol3d) :
|
||||
//const Standard_Real Tolerance) :
|
||||
myCurve(C),
|
||||
const Handle(Adaptor3d_HSurface)& Surf,
|
||||
const Handle(Adaptor2d_HCurve2d)& InitialCurve2d,
|
||||
const Standard_Real Tol3d)
|
||||
: myCurve(C),
|
||||
myInitialCurve2d(InitialCurve2d),
|
||||
mySurface(Surf),
|
||||
//OCC217
|
||||
myTolU(Surf->UResolution(Tol3d)),
|
||||
myTolV(Surf->VResolution(Tol3d)),
|
||||
myDistTol3d(100.0*Tol3d){} ;
|
||||
//myTolerance(Tolerance){} ;
|
||||
|
||||
~ProjLib_PolarFunction() {}
|
||||
|
||||
Standard_Real FirstParameter() const
|
||||
{return (myCurve->FirstParameter()/*+1.e-9*/);}
|
||||
|
||||
Standard_Real LastParameter() const
|
||||
{return (myCurve->LastParameter()/*-1.e-9*/);}
|
||||
|
||||
gp_Pnt2d Value(const Standard_Real t) const {
|
||||
return Function_Value
|
||||
(t,mySurface,myCurve,myInitialCurve2d,myDistTol3d,myTolU,myTolV) ; //OCC217
|
||||
//(t,mySurface,myCurve,myInitialCurve2d,myTolerance) ;
|
||||
myDistTol3d(100.0*Tol3d)
|
||||
{
|
||||
myNbPnt = 0;
|
||||
myNbPnt2d = 1;
|
||||
}
|
||||
|
||||
// Standard_Boolean D1(const Standard_Real t, gp_Pnt2d& P, gp_Vec2d& V) const
|
||||
Standard_Boolean D1(const Standard_Real , gp_Pnt2d& , gp_Vec2d& ) const
|
||||
|
||||
~ProjLib_PolarFunction() {}
|
||||
|
||||
Standard_Real FirstParameter() const
|
||||
{
|
||||
return myCurve->FirstParameter();
|
||||
}
|
||||
|
||||
Standard_Real LastParameter() const
|
||||
{
|
||||
return myCurve->LastParameter();
|
||||
}
|
||||
|
||||
Standard_Boolean Value(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Pnt2d>& thePnt2d,
|
||||
NCollection_Array1<gp_Pnt>& /*thePnt*/) const
|
||||
{
|
||||
thePnt2d(1) = Function_Value(theT, mySurface, myCurve, myInitialCurve2d, myDistTol3d, myTolU, myTolV);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean D1(const Standard_Real /*theT*/,
|
||||
NCollection_Array1<gp_Vec2d>& /*theVec2d*/,
|
||||
NCollection_Array1<gp_Vec>& /*theVec*/) const
|
||||
{return Standard_False;}
|
||||
};
|
||||
|
||||
@@ -1695,12 +1700,7 @@ Handle(Geom2d_BSplineCurve)
|
||||
|
||||
//update of fields of ProjLib_Approx
|
||||
Standard_Integer NbKnots = NbCurves + 1;
|
||||
|
||||
// The start and end nodes are not correct : Cf: opening of the interval
|
||||
//Knots( 1) -= 1.e-9;
|
||||
//Knots(NbKnots) += 1.e-9;
|
||||
|
||||
|
||||
|
||||
TColStd_Array1OfInteger Mults( 1, NbKnots);
|
||||
Mults.Init(MaxDeg);
|
||||
Mults.SetValue( 1, MaxDeg + 1);
|
||||
|
@@ -251,14 +251,19 @@ class ProjLib_OnPlane : public AppCont_Function
|
||||
Handle(Adaptor3d_HCurve) myCurve;
|
||||
gp_Ax3 myPlane;
|
||||
gp_Dir myDirection;
|
||||
|
||||
public :
|
||||
|
||||
|
||||
public :
|
||||
|
||||
ProjLib_OnPlane(const Handle(Adaptor3d_HCurve)& C,
|
||||
const gp_Ax3& Pl,
|
||||
const gp_Dir& D)
|
||||
: myCurve(C), myPlane(Pl), myDirection(D)
|
||||
{}
|
||||
const gp_Ax3& Pl,
|
||||
const gp_Dir& D)
|
||||
: myCurve(C),
|
||||
myPlane(Pl),
|
||||
myDirection(D)
|
||||
{
|
||||
myNbPnt = 1;
|
||||
myNbPnt2d = 0;
|
||||
}
|
||||
|
||||
Standard_Real FirstParameter() const
|
||||
{return myCurve->FirstParameter();}
|
||||
@@ -266,11 +271,21 @@ class ProjLib_OnPlane : public AppCont_Function
|
||||
Standard_Real LastParameter() const
|
||||
{return myCurve->LastParameter();}
|
||||
|
||||
gp_Pnt Value( const Standard_Real t) const
|
||||
{return OnPlane_Value(t,myCurve,myPlane,myDirection);}
|
||||
Standard_Boolean Value(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Pnt2d>& /*thePnt2d*/,
|
||||
NCollection_Array1<gp_Pnt>& thePnt) const
|
||||
{
|
||||
thePnt(1) = OnPlane_Value(theT, myCurve, myPlane, myDirection);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean D1(const Standard_Real t, gp_Pnt& P, gp_Vec& V) const
|
||||
{return OnPlane_D1(t,P,V,myCurve,myPlane,myDirection);}
|
||||
Standard_Boolean D1(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Vec2d>& /*theVec2d*/,
|
||||
NCollection_Array1<gp_Vec>& theVec) const
|
||||
{
|
||||
gp_Pnt aDummyPnt;
|
||||
return OnPlane_D1(theT, aDummyPnt, theVec(1),myCurve,myPlane,myDirection);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@@ -91,29 +91,41 @@ class ProjLib_OnSurface : public AppCont_Function
|
||||
public :
|
||||
|
||||
ProjLib_OnSurface(const Handle(Adaptor3d_HCurve) & C,
|
||||
const Handle(Adaptor3d_HSurface) & S)
|
||||
: myCurve(C)
|
||||
{Standard_Real U = myCurve->FirstParameter();
|
||||
gp_Pnt P = myCurve->Value(U);
|
||||
Standard_Real Tol = Precision::PConfusion();
|
||||
myExtPS = new Extrema_ExtPS(P,S->Surface(),Tol,Tol);}
|
||||
const Handle(Adaptor3d_HSurface) & S)
|
||||
: myCurve(C)
|
||||
{
|
||||
myNbPnt = 1;
|
||||
myNbPnt2d = 0;
|
||||
Standard_Real U = myCurve->FirstParameter();
|
||||
gp_Pnt P = myCurve->Value(U);
|
||||
Standard_Real Tol = Precision::PConfusion();
|
||||
myExtPS = new Extrema_ExtPS(P,S->Surface(),Tol,Tol);
|
||||
}
|
||||
|
||||
~ProjLib_OnSurface() { delete myExtPS; }
|
||||
|
||||
Standard_Real FirstParameter() const
|
||||
{return myCurve->FirstParameter();}
|
||||
|
||||
|
||||
Standard_Real LastParameter() const
|
||||
{return myCurve->LastParameter();}
|
||||
|
||||
gp_Pnt Value( const Standard_Real t) const
|
||||
{return OnSurface_Value(t,myCurve,myExtPS);}
|
||||
Standard_Boolean Value(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Pnt2d>& /*thePnt2d*/,
|
||||
NCollection_Array1<gp_Pnt>& thePnt) const
|
||||
{
|
||||
thePnt(1) = OnSurface_Value(theT, myCurve, myExtPS);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean D1(const Standard_Real t, gp_Pnt& P, gp_Vec& V) const
|
||||
{return OnSurface_D1(t,P,V,myCurve,myExtPS);}
|
||||
Standard_Boolean D1(const Standard_Real theT,
|
||||
NCollection_Array1<gp_Vec2d>& /*theVec2d*/,
|
||||
NCollection_Array1<gp_Vec>& theVec) const
|
||||
{
|
||||
gp_Pnt aPnt;
|
||||
return OnSurface_D1(theT, aPnt, theVec(1), myCurve, myExtPS);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//=====================================================================//
|
||||
|
Reference in New Issue
Block a user