diff --git a/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx b/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx index ada816c70a..6f624b5774 100644 --- a/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx +++ b/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx @@ -72,6 +72,7 @@ #include #include #include +#include #include // pour la verif G2 @@ -455,7 +456,7 @@ void GeomPlate_BuildPlateSurface:: //fonction : Perform // Calcul la surface de remplissage avec les contraintes chargees //--------------------------------------------------------- -void GeomPlate_BuildPlateSurface::Perform() +void GeomPlate_BuildPlateSurface::Perform(const Handle(Message_ProgressIndicator) & aProgress) { #ifdef OCCT_DEBUG // Chronmetrage @@ -488,7 +489,7 @@ void GeomPlate_BuildPlateSurface::Perform() // Surface Initiale //====================================================================== if (!mySurfInitIsGive) - ComputeSurfInit(); + ComputeSurfInit(aProgress); else { if (NTLinCont>=2) @@ -658,13 +659,19 @@ void GeomPlate_BuildPlateSurface::Perform() //==================================================================== //Resolution de la surface //==================================================================== - myPlate.SolveTI(myDegree, ComputeAnisotropie()); + + myPlate.SolveTI(myDegree, ComputeAnisotropie(), aProgress); + + if (!aProgress.IsNull() && aProgress->UserBreak()) + { + return; + } + if (!myPlate.IsDone()) { #ifdef OCCT_DEBUG cout << "WARNING : GeomPlate : abort calcul of Plate." << endl; #endif - return; } @@ -692,7 +699,13 @@ void GeomPlate_BuildPlateSurface::Perform() //==================================================================== //Resolution de la surface //==================================================================== - myPlate.SolveTI(myDegree, ComputeAnisotropie()); + myPlate.SolveTI(myDegree, ComputeAnisotropie(), aProgress); + + if (!aProgress.IsNull() && aProgress->UserBreak()) + { + return; + } + if (!myPlate.IsDone()) { #ifdef OCCT_DEBUG @@ -1354,7 +1367,7 @@ Standard_Boolean GeomPlate_BuildPlateSurface:: // il y a des contraintes ponctuelles //------------------------------------------------------------------------- -void GeomPlate_BuildPlateSurface::ComputeSurfInit() +void GeomPlate_BuildPlateSurface::ComputeSurfInit(const Handle(Message_ProgressIndicator) & aProgress) { Standard_Integer nopt=2, popt=2, Np=1; Standard_Boolean isHalfSpace = Standard_True; @@ -1719,7 +1732,12 @@ void GeomPlate_BuildPlateSurface::ComputeSurfInit() //==================================================================== //Resolution de la surface //==================================================================== - myPlate.SolveTI(2, ComputeAnisotropie()); + myPlate.SolveTI(2, ComputeAnisotropie(), aProgress); + if (!aProgress.IsNull() && aProgress->UserBreak()) + { + return; + } + if (!myPlate.IsDone()) { #ifdef OCCT_DEBUG diff --git a/src/GeomPlate/GeomPlate_BuildPlateSurface.hxx b/src/GeomPlate/GeomPlate_BuildPlateSurface.hxx index 372b67ac88..4f7288d70e 100644 --- a/src/GeomPlate/GeomPlate_BuildPlateSurface.hxx +++ b/src/GeomPlate/GeomPlate_BuildPlateSurface.hxx @@ -46,6 +46,7 @@ class gp_Pnt; class Geom2d_Curve; class Adaptor3d_HCurve; class Adaptor2d_HCurve2d; +class Message_ProgressIndicator; @@ -130,7 +131,7 @@ public: //! Exceptions //! Standard_RangeError if the value of the constraint is //! null or if plate is not done. - Standard_EXPORT void Perform(); + Standard_EXPORT void Perform(const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)()); //! returns the CurveConstraints of order order Standard_EXPORT Handle(GeomPlate_CurveConstraint) CurveConstraint (const Standard_Integer order) const; @@ -217,7 +218,7 @@ private: Standard_EXPORT Handle(Adaptor2d_HCurve2d) ProjectedCurve (Handle(Adaptor3d_HCurve)& Curv); - Standard_EXPORT void ComputeSurfInit(); + Standard_EXPORT void ComputeSurfInit(const Handle(Message_ProgressIndicator) & aProgress); Standard_EXPORT void Intersect (Handle(GeomPlate_HArray1OfSequenceOfReal)& PntInter, Handle(GeomPlate_HArray1OfSequenceOfReal)& PntG1G1); diff --git a/src/Plate/Plate_Plate.cxx b/src/Plate/Plate_Plate.cxx index 838577b8cb..963c657187 100644 --- a/src/Plate/Plate_Plate.cxx +++ b/src/Plate/Plate_Plate.cxx @@ -37,6 +37,7 @@ #include #include #include +#include //======================================================================= //function : Plate_Plate @@ -249,7 +250,8 @@ void Plate_Plate::Load(const Plate_GlobalTranslationConstraint& GTConst) //======================================================================= void Plate_Plate::SolveTI(const Standard_Integer ord, - const Standard_Real anisotropie) + const Standard_Real anisotropie, + const Handle(Message_ProgressIndicator) & aProgress) { Standard_Integer IterationNumber=0; OK = Standard_False; @@ -277,16 +279,15 @@ void Plate_Plate::SolveTI(const Standard_Integer ord, ddv[0] = 1; for(i=1;i<=9;i++) ddv[i] = ddv[i-1] / dv; - if(myLScalarConstraints.IsEmpty()) { if(myLXYZConstraints.IsEmpty()) - SolveTI1(IterationNumber); + SolveTI1(IterationNumber, aProgress); else - SolveTI2(IterationNumber); + SolveTI2(IterationNumber, aProgress); } else - SolveTI3(IterationNumber); + SolveTI3(IterationNumber, aProgress); } @@ -296,7 +297,7 @@ void Plate_Plate::SolveTI(const Standard_Integer ord, // only PinPointConstraints are loaded //======================================================================= -void Plate_Plate::SolveTI1(const Standard_Integer IterationNumber) +void Plate_Plate::SolveTI1(const Standard_Integer IterationNumber, const Handle(Message_ProgressIndicator) & aProgress) { // computation of square matrix members @@ -349,14 +350,21 @@ void Plate_Plate::SolveTI1(const Standard_Integer IterationNumber) Standard_Real pivot_max = 1.e-12; OK = Standard_True; - math_Gauss algo_gauss(mat,pivot_max); + math_Gauss algo_gauss(mat,pivot_max, aProgress); + + if (!aProgress.IsNull() && aProgress->UserBreak()) + { + OK = Standard_False; + return; + } + if(!algo_gauss.IsDone()) { Standard_Integer nbm = order*(order+1)/2; for(i=n_el;iUserBreak ()) + { + OK = Standard_False; + return; + } + if(!algo_gauss.IsDone()) { for(i=nCC1+nCC2;iUserBreak ()) + { + OK = Standard_False; + return; + } + if(!algo_gauss.IsDone()) { for(i=nCC1+nCC2;i #include #include + class Plate_PinpointConstraint; class Plate_LinearXYZConstraint; class Plate_LinearScalarConstraint; @@ -42,6 +43,7 @@ class Plate_FreeGtoCConstraint; class gp_XYZ; class gp_XY; class math_Matrix; +class Message_ProgressIndicator; //! This class implement a variationnal spline algorithm able @@ -82,7 +84,9 @@ Plate_Plate& operator= (const Plate_Plate& Ref) Standard_EXPORT void Load (const Plate_FreeGtoCConstraint& FGtoCConst); - Standard_EXPORT void SolveTI (const Standard_Integer ord = 4, const Standard_Real anisotropie = 1.0); + Standard_EXPORT void SolveTI (const Standard_Integer ord = 4, + const Standard_Real anisotropie = 1.0, + const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)()); //! returns True if all has been correctly done. Standard_EXPORT Standard_Boolean IsDone() const; @@ -135,11 +139,11 @@ private: gp_XY& Points (const Standard_Integer index) const; - Standard_EXPORT void SolveTI1 (const Standard_Integer IterationNumber); + Standard_EXPORT void SolveTI1 (const Standard_Integer IterationNumber, const Handle(Message_ProgressIndicator) & aProgress = NULL); - Standard_EXPORT void SolveTI2 (const Standard_Integer IterationNumber); + Standard_EXPORT void SolveTI2 (const Standard_Integer IterationNumber, const Handle(Message_ProgressIndicator) & aProgress = NULL); - Standard_EXPORT void SolveTI3 (const Standard_Integer IterationNumber); + Standard_EXPORT void SolveTI3 (const Standard_Integer IterationNumber, const Handle(Message_ProgressIndicator) & aProgress = NULL); Standard_EXPORT void fillXYZmatrix (math_Matrix& mat, const Standard_Integer i0, const Standard_Integer j0, const Standard_Integer ncc1, const Standard_Integer ncc2) const; diff --git a/src/math/math_Gauss.cxx b/src/math/math_Gauss.cxx index 7f864bc211..aab379af6c 100644 --- a/src/math/math_Gauss.cxx +++ b/src/math/math_Gauss.cxx @@ -28,7 +28,8 @@ #include math_Gauss::math_Gauss(const math_Matrix& A, - const Standard_Real MinPivot) + const Standard_Real MinPivot, + const Handle(Message_ProgressIndicator) & aProgress) : LU (1, A.RowNumber(), 1, A.ColNumber()), Index(1, A.RowNumber()) { @@ -37,7 +38,8 @@ math_Gauss::math_Gauss(const math_Matrix& A, Standard_Integer Error = LU_Decompose(LU, Index, D, - MinPivot); + MinPivot, + aProgress); if(!Error) { Done = Standard_True; } diff --git a/src/math/math_Gauss.hxx b/src/math/math_Gauss.hxx index 76657fdff2..53ee630870 100644 --- a/src/math/math_Gauss.hxx +++ b/src/math/math_Gauss.hxx @@ -27,10 +27,12 @@ #include #include #include + class math_NotSquare; class Standard_DimensionError; class StdFail_NotDone; class math_Matrix; +class Message_ProgressIndicator; @@ -55,7 +57,9 @@ public: //! If the largest pivot found is less than MinPivot the matrix A is //! considered as singular. //! Exception NotSquare is raised if A is not a square matrix. - Standard_EXPORT math_Gauss(const math_Matrix& A, const Standard_Real MinPivot = 1.0e-20); + Standard_EXPORT math_Gauss(const math_Matrix& A, + const Standard_Real MinPivot = 1.0e-20, + const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)()); //! Returns true if the computations are successful, otherwise returns false Standard_Boolean IsDone() const; diff --git a/src/math/math_Recipes.cxx b/src/math/math_Recipes.cxx index 1df7b88432..02654975ed 100644 --- a/src/math/math_Recipes.cxx +++ b/src/math/math_Recipes.cxx @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -175,7 +176,8 @@ Standard_Integer LU_Decompose(math_Matrix& a, math_IntegerVector& indx, Standard_Real& d, math_Vector& vv, - Standard_Real TINY) { + Standard_Real TINY, + const Handle(Message_ProgressIndicator) & aProgress) { Standard_Integer i, imax=0, j, k; Standard_Real big, dum, sum, temp; @@ -183,6 +185,8 @@ Standard_Integer LU_Decompose(math_Matrix& a, Standard_Integer n = a.RowNumber(); d = 1.0; + Message_ProgressSentry aPSentry(aProgress, "", 0, n, 1); + for(i = 1; i <= n; i++) { big = 0.0; for (j = 1; j <= n; j++) @@ -192,7 +196,8 @@ Standard_Integer LU_Decompose(math_Matrix& a, } vv(i) = 1.0 / big; } - for(j = 1; j <= n; j++) { + + for(j = 1; j <= n && aPSentry.More(); j++, aPSentry.Next()) { for(i = 1; i < j; i++) { sum = a(i,j); for(k = 1; k < i; k++) @@ -232,16 +237,23 @@ Standard_Integer LU_Decompose(math_Matrix& a, a(i,j) *= dum; } } + + if (j <= n) + { + return math_Status_UserAborted; + } + return math_Status_OK; } Standard_Integer LU_Decompose(math_Matrix& a, math_IntegerVector& indx, Standard_Real& d, - Standard_Real TINY) { + Standard_Real TINY, + const Handle(Message_ProgressIndicator) & aProgress) { math_Vector vv(1, a.RowNumber()); - return LU_Decompose(a, indx, d, vv, TINY); + return LU_Decompose(a, indx, d, vv, TINY, aProgress); } void LU_Solve(const math_Matrix& a, diff --git a/src/math/math_Recipes.hxx b/src/math/math_Recipes.hxx index 33d0727b11..55cbc27c67 100644 --- a/src/math/math_Recipes.hxx +++ b/src/math/math_Recipes.hxx @@ -18,12 +18,14 @@ #include #include #include +#include class math_IntegerVector; class math_Vector; class math_Matrix; +class Message_ProgressIndicator; - +const Standard_Integer math_Status_UserAborted = -1; const Standard_Integer math_Status_OK = 0; const Standard_Integer math_Status_SingularMatrix = 1; const Standard_Integer math_Status_ArgumentError = 2; @@ -32,7 +34,8 @@ const Standard_Integer math_Status_NoConvergence = 3; Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a, math_IntegerVector& indx, Standard_Real& d, - Standard_Real TINY = 1.0e-20); + Standard_Real TINY = 1.0e-20, + const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)()); // Given a matrix a(1..n, 1..n), this routine computes its LU decomposition, // The matrix a is replaced by this LU decomposition and the vector indx(1..n) @@ -44,7 +47,8 @@ Standard_EXPORT Standard_Integer LU_Decompose(math_Matrix& a, math_IntegerVector& indx, Standard_Real& d, math_Vector& vv, - Standard_Real TINY = 1.0e-30); + Standard_Real TINY = 1.0e-30, + const Handle(Message_ProgressIndicator) & aProgress = Handle(Message_ProgressIndicator)()); // Idem to the previous LU_Decompose function. But the input Vector vv(1..n) is // used internally as a scratch area.