mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0030435: Improving performance of Approx_ComputeCLine
1. Approx_ComputeCLine.gxx, Approx_FitAndDivide.hxx, Approx_FitAndDivide2d.hxx, BRepFill_ComputeCLine.hxx It is base modification, which allows improve performance of approximation with help of Approx_ComputeCLine. The main idea of improvement is using degree selection by inverse order - from maxdegree to mindegree. If tolerance for maxdegree is not reached, there is no sense to make approximation for current number of knots with lower degree, it is necessary to cut parametric interval. 2. ProjLib_ComputeApprox, ProjLib_ComputeApproxOnPolarSurface, ProjLib_ComputeApproxOnPolarSurface, ProjLib_ProjectOnPlane It is additional modification of methods using Approx_ComputeCLine. Mainly, modifications concern to more optimal choosing parameters for approximation algorithm. 3. BRepCheck_Face Small improvement of method Intersect(...), which intersects two wires on face. 4. BRepTopAdaptor_FClass2d Impovement of treatment infinitely narrow faces. 5. ChFi3d/ChFi3d_Builder_6.cxx Small improvement, which forbids extension of singular boundary of surface. It was TODO problem in tests/bugs/modalg_7/bug27711_3 6. IntTools_EdgeEdge.cxx Improvement of performance for cases of searching common parts between line and analytical curve 7. GeomliteTest_CurveCommands.cxx Adding Draw command fitcurve. This command is analog of approxcurve, but uses Approx_FitAndDivide algorithm. Mainly to have direct draw command for testing Approx_ComputeCLine. 8. Extrema_ExtElC.cxx Treatment of case "infinite solutions" for extrema line-ellipse 9. Modification of some tests according to new behavior of algorithm. 10. tests/perf/moddata/bug30435 Test for new improved algorithm. 11. Implementation QAcommand OCC30435 in QABugs_20.cxx used in test bug30435
This commit is contained in:
@@ -1011,6 +1011,15 @@ void ProjLib_ComputeApprox::Perform
|
||||
(CType != GeomAbs_OtherCurve) ;
|
||||
|
||||
Standard_Boolean simplecase = SurfIsAnal && CurvIsAnal;
|
||||
if (CType == GeomAbs_BSplineCurve || CType == GeomAbs_BezierCurve)
|
||||
{
|
||||
Standard_Integer aNbKnots = 1;
|
||||
if (CType == GeomAbs_BSplineCurve)
|
||||
{
|
||||
aNbKnots = C->NbKnots();
|
||||
}
|
||||
simplecase = simplecase && C->Degree() <= 2 && aNbKnots <= 2;
|
||||
}
|
||||
|
||||
if (CType == GeomAbs_BSplineCurve &&
|
||||
SType == GeomAbs_Plane ) {
|
||||
@@ -1111,12 +1120,12 @@ void ProjLib_ComputeApprox::Perform
|
||||
#endif
|
||||
|
||||
//-----------
|
||||
Standard_Integer Deg1 = 8, Deg2;
|
||||
if(simplecase) {
|
||||
Deg2 = 10;
|
||||
Standard_Integer Deg1 = 5, Deg2;
|
||||
if (simplecase) {
|
||||
Deg2 = 8;
|
||||
}
|
||||
else {
|
||||
Deg2 = 12;
|
||||
Deg2 = 10;
|
||||
}
|
||||
if(myDegMin > 0)
|
||||
{
|
||||
@@ -1188,6 +1197,10 @@ void ProjLib_ComputeApprox::Perform
|
||||
C->LastParameter(),
|
||||
NewKnots);
|
||||
|
||||
// Set NewKnots(NbKnots) exactly C->LastParameter()
|
||||
// to avoid problems if trim is used.
|
||||
NewKnots(NbKnots) = C->LastParameter();
|
||||
|
||||
// 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.)
|
||||
|
@@ -482,7 +482,8 @@ ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface()
|
||||
myDegMin(-1), myDegMax(-1),
|
||||
myMaxSegments(-1),
|
||||
myMaxDist(-1.),
|
||||
myBndPnt(AppParCurves_TangencyPoint)
|
||||
myBndPnt(AppParCurves_TangencyPoint),
|
||||
myDist(0.)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -502,7 +503,8 @@ ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
|
||||
myDegMin(-1), myDegMax(-1),
|
||||
myMaxSegments(-1),
|
||||
myMaxDist(-1.),
|
||||
myBndPnt(AppParCurves_TangencyPoint)
|
||||
myBndPnt(AppParCurves_TangencyPoint),
|
||||
myDist(0.)
|
||||
{
|
||||
myBSpline = Perform(theInitialCurve2d, theCurve, theSurface);
|
||||
}
|
||||
@@ -522,7 +524,8 @@ ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
|
||||
myDegMin(-1), myDegMax(-1),
|
||||
myMaxSegments(-1),
|
||||
myMaxDist(-1.),
|
||||
myBndPnt(AppParCurves_TangencyPoint)
|
||||
myBndPnt(AppParCurves_TangencyPoint),
|
||||
myDist(0.)
|
||||
{
|
||||
const Handle(Adaptor2d_HCurve2d) anInitCurve2d;
|
||||
myBSpline = Perform(anInitCurve2d, theCurve, theSurface);
|
||||
@@ -545,7 +548,8 @@ ProjLib_ComputeApproxOnPolarSurface::ProjLib_ComputeApproxOnPolarSurface
|
||||
myDegMin(-1), myDegMax(-1),
|
||||
myMaxSegments(-1),
|
||||
myMaxDist(-1.),
|
||||
myBndPnt(AppParCurves_TangencyPoint)
|
||||
myBndPnt(AppParCurves_TangencyPoint),
|
||||
myDist(0.)
|
||||
{
|
||||
// InitialCurve2d and InitialCurve2dBis are two pcurves of the sewing
|
||||
Handle(Geom2d_BSplineCurve) bsc =
|
||||
@@ -1079,6 +1083,7 @@ Handle(Adaptor2d_HCurve2d)
|
||||
else {
|
||||
myProjIsDone = Standard_False;
|
||||
Standard_Real Dist2Min = 1.e+200, u = 0., v = 0.;
|
||||
myDist = 0.;
|
||||
gp_Pnt pntproj;
|
||||
|
||||
TColgp_SequenceOfPnt2d Sols;
|
||||
@@ -1253,7 +1258,7 @@ Handle(Adaptor2d_HCurve2d)
|
||||
// U0 and V0 are the points in the initialized period
|
||||
// (period with u and v),
|
||||
// U1 and V1 are the points for construction of poles
|
||||
|
||||
myDist = Dist2Min;
|
||||
for ( i = 2 ; i <= NbOfPnts ; i++)
|
||||
if(myProjIsDone) {
|
||||
myProjIsDone = Standard_False;
|
||||
@@ -1267,6 +1272,10 @@ Handle(Adaptor2d_HCurve2d)
|
||||
if (aLocateExtPS.SquareDistance() < DistTol3d2)
|
||||
{ //OCC217
|
||||
//if (aLocateExtPS.SquareDistance() < Tol3d * Tol3d) {
|
||||
if (aLocateExtPS.SquareDistance() > myDist)
|
||||
{
|
||||
myDist = aLocateExtPS.SquareDistance();
|
||||
}
|
||||
(aLocateExtPS.Point()).Parameter(U0,V0);
|
||||
U1 = U0 + usens*uperiod;
|
||||
V1 = V0 + vsens*vperiod;
|
||||
@@ -1291,6 +1300,10 @@ Handle(Adaptor2d_HCurve2d)
|
||||
}
|
||||
if (LocalMinSqDist < DistTol3d2)
|
||||
{
|
||||
if (LocalMinSqDist > myDist)
|
||||
{
|
||||
myDist = LocalMinSqDist;
|
||||
}
|
||||
Standard_Real LocalU, LocalV;
|
||||
aGlobalExtr.Point(imin).Parameter(LocalU, LocalV);
|
||||
if (uperiod > 0. && Abs(U0 - LocalU) >= uperiod/2.)
|
||||
@@ -1363,6 +1376,10 @@ Handle(Adaptor2d_HCurve2d)
|
||||
if (locext.IsDone())
|
||||
if (locext.SquareDistance() < DistTol3d2) { //OCC217
|
||||
//if (locext.SquareDistance() < Tol3d * Tol3d) {
|
||||
if (locext.SquareDistance() > myDist)
|
||||
{
|
||||
myDist = locext.SquareDistance();
|
||||
}
|
||||
(locext.Point()).Parameter(u,v);
|
||||
if((aUsup - U0) > (U0 - aUinf))
|
||||
usens--;
|
||||
@@ -1390,7 +1407,11 @@ Handle(Adaptor2d_HCurve2d)
|
||||
if (locext.IsDone())
|
||||
if (locext.SquareDistance() < DistTol3d2) { //OCC217
|
||||
//if (locext.SquareDistance() < Tol3d * Tol3d) {
|
||||
(locext.Point()).Parameter(u,v);
|
||||
if (locext.SquareDistance() > myDist)
|
||||
{
|
||||
myDist = locext.SquareDistance();
|
||||
}
|
||||
(locext.Point()).Parameter(u, v);
|
||||
if((aVsup - V0) > (V0 - aVinf))
|
||||
vsens--;
|
||||
else
|
||||
@@ -1419,7 +1440,11 @@ Handle(Adaptor2d_HCurve2d)
|
||||
if (locext.IsDone())
|
||||
if (locext.SquareDistance() < DistTol3d2) {
|
||||
//if (locext.SquareDistance() < Tol3d * Tol3d) {
|
||||
(locext.Point()).Parameter(u,v);
|
||||
if (locext.SquareDistance() > myDist)
|
||||
{
|
||||
myDist = locext.SquareDistance();
|
||||
}
|
||||
(locext.Point()).Parameter(u, v);
|
||||
if((Usup - U0) > (U0 - Uinf))
|
||||
usens--;
|
||||
else
|
||||
@@ -1447,7 +1472,11 @@ Handle(Adaptor2d_HCurve2d)
|
||||
}
|
||||
if (Dist2Min < DistTol3d2) {
|
||||
//if (Dist2Min < Tol3d * Tol3d) {
|
||||
(ext.Point(aGoodValue)).Parameter(u,v);
|
||||
if (Dist2Min > myDist)
|
||||
{
|
||||
myDist = Dist2Min;
|
||||
}
|
||||
(ext.Point(aGoodValue)).Parameter(u, v);
|
||||
if(uperiod) {
|
||||
if((U0 - u) > (2*uperiod/3)) {
|
||||
usens++;
|
||||
@@ -1862,8 +1891,18 @@ Handle(Geom2d_BSplineCurve)
|
||||
aLastC = myBndPnt;
|
||||
}
|
||||
|
||||
if (myDist > 10.*Tol3d)
|
||||
{
|
||||
aFistC = AppParCurves_PassPoint;
|
||||
aLastC = AppParCurves_PassPoint;
|
||||
}
|
||||
|
||||
Approx_FitAndDivide2d Fit(Deg1, Deg2, Tol3d, Tol2d, Standard_True, aFistC, aLastC);
|
||||
Fit.SetMaxSegments(aMaxSegments);
|
||||
if (InitCurve2d->GetType() == GeomAbs_Line)
|
||||
{
|
||||
Fit.SetInvOrder(Standard_False);
|
||||
}
|
||||
Fit.Perform(F);
|
||||
|
||||
Standard_Real anOldTol2d = Tol2d;
|
||||
@@ -1936,6 +1975,10 @@ Handle(Geom2d_BSplineCurve)
|
||||
|
||||
Standard_Boolean OK = Standard_True;
|
||||
Standard_Real aSmoothTol = Max(Precision::Confusion(), aNewTol2d);
|
||||
if (myBndPnt == AppParCurves_PassPoint)
|
||||
{
|
||||
aSmoothTol *= 10.;
|
||||
}
|
||||
for (Standard_Integer ij = 2; ij < NbKnots; ij++) {
|
||||
OK = OK && Dummy->RemoveKnot(ij,MaxDeg-1, aSmoothTol);
|
||||
}
|
||||
|
@@ -142,7 +142,7 @@ private:
|
||||
Standard_Integer myMaxSegments;
|
||||
Standard_Real myMaxDist;
|
||||
AppParCurves_Constraint myBndPnt;
|
||||
|
||||
Standard_Real myDist;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -317,8 +317,14 @@ static void PerformApprox (const Handle(Adaptor3d_HCurve)& C,
|
||||
Standard_Integer Deg1, Deg2;
|
||||
Deg1 = 8; Deg2 = 8;
|
||||
|
||||
Approx_FitAndDivide Fit(F,Deg1,Deg2,Precision::Approximation(),
|
||||
Approx_FitAndDivide Fit(Deg1,Deg2,Precision::Approximation(),
|
||||
Precision::PApproximation(),Standard_True);
|
||||
Fit.SetMaxSegments(100);
|
||||
Fit.Perform(F);
|
||||
if (!Fit.IsAllApproximated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Standard_Integer i;
|
||||
Standard_Integer NbCurves = Fit.NbMultiCurves();
|
||||
Standard_Integer MaxDeg = 0;
|
||||
@@ -347,9 +353,8 @@ static void PerformApprox (const Handle(Adaptor3d_HCurve)& C,
|
||||
MC.Curve(1, LocalPoles);
|
||||
|
||||
//Augmentation eventuelle du degre
|
||||
Standard_Integer Inc = MaxDeg - MC.Degree();
|
||||
if ( Inc > 0) {
|
||||
BSplCLib::IncreaseDegree(Inc, Poles, BSplCLib::NoWeights(),
|
||||
if (MaxDeg > MC.Degree() ) {
|
||||
BSplCLib::IncreaseDegree(MaxDeg, LocalPoles, BSplCLib::NoWeights(),
|
||||
TempPoles, BSplCLib::NoWeights());
|
||||
//mise a jour des poles de la PCurve
|
||||
for (Standard_Integer j = 1 ; j <= MaxDeg + 1; j++) {
|
||||
|
Reference in New Issue
Block a user