From: Roman Lygin Date: Fri, 12 Jul 2013 08:27:30 +0000 (+0400) Subject: 0024043: Performance improvements: Modeling Algorithms X-Git-Tag: V6_7_0_beta~211 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=96a85238fb36402aa3c926a049a67c21cd2f6f28;p=occt.git 0024043: Performance improvements: Modeling Algorithms Performance improvements: Modeling Algorithms (added Shape Healing) Added TODO to unstable test cases --- diff --git a/src/Extrema/Extrema_POnSurf.cdl b/src/Extrema/Extrema_POnSurf.cdl index df1e444fa4..c7ad0418c3 100755 --- a/src/Extrema/Extrema_POnSurf.cdl +++ b/src/Extrema/Extrema_POnSurf.cdl @@ -20,7 +20,7 @@ -class POnSurf from Extrema inherits Storable from Standard +class POnSurf from Extrema ---Purpose: Definition of a point on surface. uses Pnt from gp @@ -28,10 +28,12 @@ uses Pnt from gp is Create returns POnSurf; ---Purpose: Creation of an indefinite point on surface. + ---C++: inline Create (U,V: Real; P: Pnt) returns POnSurf; ---Purpose: Creation of a point on surface with parameter -- values on the surface and a Pnt from gp. + ---C++: inline Value (me) returns Pnt ---Purpose: Returns the 3d point. diff --git a/src/Extrema/Extrema_POnSurf.cxx b/src/Extrema/Extrema_POnSurf.cxx index 14a65adf55..dae8ad86e0 100755 --- a/src/Extrema/Extrema_POnSurf.cxx +++ b/src/Extrema/Extrema_POnSurf.cxx @@ -17,13 +17,3 @@ // and conditions governing the rights and limitations under the License. #include - -Extrema_POnSurf::Extrema_POnSurf () {} - -Extrema_POnSurf::Extrema_POnSurf ( const Standard_Real U, const Standard_Real V, const gp_Pnt& P) -{ - myU = U; - myV = V; - myP = P; -} - diff --git a/src/Extrema/Extrema_POnSurf.lxx b/src/Extrema/Extrema_POnSurf.lxx index 3d786887bc..4d8333ed78 100755 --- a/src/Extrema/Extrema_POnSurf.lxx +++ b/src/Extrema/Extrema_POnSurf.lxx @@ -17,6 +17,15 @@ // and conditions governing the rights and limitations under the License. +inline Extrema_POnSurf::Extrema_POnSurf () {} + +inline Extrema_POnSurf::Extrema_POnSurf (const Standard_Real U, + const Standard_Real V, + const gp_Pnt& P) : + myU (U), myV (V), myP (P) +{ +} + inline void Extrema_POnSurf::Parameter ( Standard_Real& U, Standard_Real& V) const { U = myU; diff --git a/src/GeomInt/GeomInt_IntSS_1.cxx b/src/GeomInt/GeomInt_IntSS_1.cxx index 0869da1f99..684fb91cfd 100755 --- a/src/GeomInt/GeomInt_IntSS_1.cxx +++ b/src/GeomInt/GeomInt_IntSS_1.cxx @@ -42,6 +42,11 @@ #include #include #include +#include +#include +#include +#include +#include #include @@ -1260,10 +1265,24 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, const GeomInt_LineConstructor& theLConstructor, IntPatch_SequenceOfLine& theNewLines) { + typedef NCollection_List ListOfInteger; + //have to use std::vector, not NCollection_Vector in order to use copy constructor of + //ListOfInteger which will be created with specific allocator instance + typedef std::vector > ArrayOfListOfInteger; + Standard_Boolean bIsPrevPointOnBoundary, bIsCurrentPointOnBoundary; Standard_Integer nblines, aNbPnts, aNbParts, pit, i, j, aNbListOfPointIndex; Standard_Real aTol, umin, umax, vmin, vmax; - TColStd_ListOfInteger aListOfPointIndex; + + //an inc allocator, it will contain wasted space (upon list's Clear()) but it should + //still be faster than the standard allocator, and wasted memory should not be + //significant and will be limited by time span of this function; + //this is a separate allocator from the anIncAlloc below what provides better data + //locality in the latter (by avoiding wastes which will only be in anIdxAlloc) + Handle(NCollection_IncAllocator) anIdxAlloc = new NCollection_IncAllocator(); + ListOfInteger aListOfPointIndex (anIdxAlloc); + //GeomAPI_ProjectPointOnSurf aPrj1, aPrj2; ProjectPointOnSurf aPrj1, aPrj2; Handle(Geom_Surface) aSurf1, aSurf2; @@ -1275,8 +1294,13 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, return Standard_False; } // - TColStd_Array1OfListOfInteger anArrayOfLines(1, aNbPnts); - TColStd_Array1OfInteger anArrayOfLineType(1, aNbPnts); + Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator(); + NCollection_StdAllocator anAlloc (anIncAlloc); + const ListOfInteger aDummy (anIncAlloc); //empty list to be copy constructed from + ArrayOfListOfInteger anArrayOfLines (aNbPnts + 1, aDummy, anAlloc); + + NCollection_LocalArray anArrayOfLineTypeArr (aNbPnts + 1); + Standard_Integer* anArrayOfLineType = anArrayOfLineTypeArr; // nblines = 0; aTol = Precision::Confusion(); @@ -1350,8 +1374,8 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, if(!aListOfPointIndex.IsEmpty()) { nblines++; - anArrayOfLines.SetValue(nblines, aListOfPointIndex); - anArrayOfLineType.SetValue(nblines, bIsPrevPointOnBoundary); + anArrayOfLines[nblines] = aListOfPointIndex; + anArrayOfLineType[nblines] = bIsPrevPointOnBoundary; aListOfPointIndex.Clear(); } bIsPrevPointOnBoundary = bIsCurrentPointOnBoundary; @@ -1362,8 +1386,8 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, aNbListOfPointIndex=aListOfPointIndex.Extent(); if(aNbListOfPointIndex) { nblines++; - anArrayOfLines.SetValue(nblines, aListOfPointIndex); - anArrayOfLineType.SetValue(nblines, bIsPrevPointOnBoundary); + anArrayOfLines[nblines] = aListOfPointIndex; + anArrayOfLineType[nblines] = bIsPrevPointOnBoundary; aListOfPointIndex.Clear(); } // @@ -1374,15 +1398,15 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, // Correct wlines.begin Standard_Integer aLineType; TColStd_Array1OfListOfInteger anArrayOfLineEnds(1, nblines); - Handle(IntSurf_LineOn2S) aSeqOfPntOn2S = new IntSurf_LineOn2S(); + Handle(IntSurf_LineOn2S) aSeqOfPntOn2S = new IntSurf_LineOn2S (new NCollection_IncAllocator()); // for(i = 1; i <= nblines; i++) { - aLineType=anArrayOfLineType.Value(i); + aLineType=anArrayOfLineType[i]; if(aLineType) { continue; } // - const TColStd_ListOfInteger& aListOfIndex = anArrayOfLines.Value(i); + const ListOfInteger& aListOfIndex = anArrayOfLines[i]; if(aListOfIndex.Extent() < 2) { continue; } @@ -1396,12 +1420,12 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, continue; } // - aLineTypeNeib=anArrayOfLineType.Value(aneighbourindex); + aLineTypeNeib=anArrayOfLineType[aneighbourindex]; if(!aLineTypeNeib){ continue; } // - const TColStd_ListOfInteger& aNeighbour = anArrayOfLines.Value(aneighbourindex); + const ListOfInteger& aNeighbour = anArrayOfLines[aneighbourindex]; Standard_Integer anIndex = (!j) ? aNeighbour.Last() : aNeighbour.First(); const IntSurf_PntOn2S& aPoint = theWLine->Point(anIndex); // check if need use derivative.begin .end [absence] @@ -1637,10 +1661,10 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, Handle(IntSurf_LineOn2S) aLineOn2S = new IntSurf_LineOn2S(); // for(i = 1; i <= nblines; i++) { - if(anArrayOfLineType.Value(i) != 0) { + if(anArrayOfLineType[i] != 0) { continue; } - const TColStd_ListOfInteger& aListOfIndex = anArrayOfLines.Value(i); + const ListOfInteger& aListOfIndex = anArrayOfLines[i]; if(aListOfIndex.Extent() < 2) { continue; @@ -1666,7 +1690,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.First()); aLineOn2S->Add(aP); } - TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex); + ListOfInteger::Iterator anIt(aListOfIndex); for(; anIt.More(); anIt.Next()) { const IntSurf_PntOn2S& aP = theWLine->Point(anIt.Value()); @@ -1683,9 +1707,9 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, Standard_Boolean bIsEndOfLine = Standard_True; if(aneighbour <= nblines) { - const TColStd_ListOfInteger& aListOfNeighbourIndex = anArrayOfLines.Value(aneighbour); + const ListOfInteger& aListOfNeighbourIndex = anArrayOfLines[aneighbour]; - if((anArrayOfLineType.Value(aneighbour) != 0) && + if((anArrayOfLineType[aneighbour] != 0) && (aListOfNeighbourIndex.IsEmpty())) { bIsEndOfLine = Standard_False; } @@ -1706,7 +1730,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, if(bIsFirstInside && bIsLastInside) { // append inside points between ifprm and ilprm - TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex); + ListOfInteger::Iterator anIt(aListOfIndex); for(; anIt.More(); anIt.Next()) { if((anIt.Value() < ifprm) || (anIt.Value() > ilprm)) @@ -1719,7 +1743,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, if(bIsFirstInside) { // append points from ifprm to last point + boundary point - TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex); + ListOfInteger::Iterator anIt(aListOfIndex); for(; anIt.More(); anIt.Next()) { if(anIt.Value() < ifprm) @@ -1737,9 +1761,9 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, Standard_Boolean bIsEndOfLine = Standard_True; if(aneighbour <= nblines) { - const TColStd_ListOfInteger& aListOfNeighbourIndex = anArrayOfLines.Value(aneighbour); + const ListOfInteger& aListOfNeighbourIndex = anArrayOfLines[aneighbour]; - if((anArrayOfLineType.Value(aneighbour) != 0) && + if((anArrayOfLineType[aneighbour] != 0) && (aListOfNeighbourIndex.IsEmpty())) { bIsEndOfLine = Standard_False; } @@ -1762,7 +1786,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, const IntSurf_PntOn2S& aP = aSeqOfPntOn2S->Value(aListOfFLIndex.First()); aLineOn2S->Add(aP); } - TColStd_ListIteratorOfListOfInteger anIt(aListOfIndex); + ListOfInteger::Iterator anIt(aListOfIndex); for(; anIt.More(); anIt.Next()) { if(anIt.Value() > ilprm) @@ -1796,12 +1820,12 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, // if ((ilprm-ifprm)==1) { for(i = 1; i <= nblines; i++) { - aLineType=anArrayOfLineType.Value(i); + aLineType=anArrayOfLineType[i]; if(aLineType) { continue; } // - const TColStd_ListOfInteger& aListOfIndex = anArrayOfLines.Value(i); + const ListOfInteger& aListOfIndex = anArrayOfLines[i]; aNbPoints=aListOfIndex.Extent(); if(aNbPoints==1) { aIndex=aListOfIndex.First(); diff --git a/src/IntPatch/IntPatch_PolyLine.cxx b/src/IntPatch/IntPatch_PolyLine.cxx index cceb3c9fc1..4103005ee8 100755 --- a/src/IntPatch/IntPatch_PolyLine.cxx +++ b/src/IntPatch/IntPatch_PolyLine.cxx @@ -82,7 +82,7 @@ void IntPatch_PolyLine::Prepare() Standard_Integer i; myBox.SetVoid(); Standard_Integer n=NbPoints(); - Standard_Real eps = myError; + const Standard_Real eps_2 = myError * myError; gp_Pnt2d P1, P2; if (n >= 3) { @@ -93,12 +93,12 @@ void IntPatch_PolyLine::Prepare() if (i >= 3) { gp_XY V13 = P3.XY() - P1.XY(); gp_XY V12 = P2.XY() - P1.XY(); - Standard_Real d13 = V13.Modulus(), d; - if (d13 > eps) - d = V13.CrossMagnitude(V12) / d13; + Standard_Real d13_2 = V13.SquareModulus(), d_2; + if (d13_2 > eps_2) + d_2 = V13.CrossSquareMagnitude(V12) / d13_2; else - d = eps; - if (d > myError) { + d_2 = eps_2; + if (d_2 > myError * myError) { // try to compute deflection more precisely using parabola interpolation gp_XY V23 = P3.XY() - P2.XY(); Standard_Real d12 = V12.Modulus(), d23 = V23.Modulus(); @@ -133,9 +133,9 @@ void IntPatch_PolyLine::Prepare() Standard_Real d2 = Abs (A2*xt2 + B2*yt2 + C2); if (d2 > d1) d1 = d2; // select min deflection from linear and parabolic ones - if (d1 < d) d = d1; + if (d1 * d1 < d_2) d_2 = d1 * d1; } - if (d > myError) myError=d; + if (d_2 > myError * myError) myError=Sqrt(d_2); } P1 = P2; P2 = P3; } diff --git a/src/IntSurf/FILES b/src/IntSurf/FILES new file mode 100644 index 0000000000..5b3ce6c0df --- /dev/null +++ b/src/IntSurf/FILES @@ -0,0 +1,2 @@ +IntSurf_Allocator.hxx +IntSurf_SequenceOfPntOn2S.hxx diff --git a/src/IntSurf/IntSurf.cdl b/src/IntSurf/IntSurf.cdl index 6a1c32c418..8b8c41388b 100755 --- a/src/IntSurf/IntSurf.cdl +++ b/src/IntSurf/IntSurf.cdl @@ -38,9 +38,10 @@ is class PntOn2S; - class SequenceOfPntOn2S instantiates Sequence from TCollection - (PntOn2S from IntSurf); - + imported Allocator; + + imported SequenceOfPntOn2S; + class Couple; class SequenceOfCouple instantiates Sequence from TCollection diff --git a/src/IntSurf/IntSurf_Allocator.hxx b/src/IntSurf/IntSurf_Allocator.hxx new file mode 100644 index 0000000000..174a057d47 --- /dev/null +++ b/src/IntSurf/IntSurf_Allocator.hxx @@ -0,0 +1,26 @@ +// Copyright (c) 2013-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef IntSurf_Allocator_HeaderFile +#define IntSurf_Allocator_HeaderFile + +#include + +typedef Handle_NCollection_BaseAllocator IntSurf_Allocator; + +#endif diff --git a/src/IntSurf/IntSurf_LineOn2S.cdl b/src/IntSurf/IntSurf_LineOn2S.cdl index 5f274396e2..fa99220eb9 100755 --- a/src/IntSurf/IntSurf_LineOn2S.cdl +++ b/src/IntSurf/IntSurf_LineOn2S.cdl @@ -27,14 +27,15 @@ class LineOn2S from IntSurf inherits TShared from MMgt -uses PntOn2S from IntSurf, +uses Allocator from IntSurf, + PntOn2S from IntSurf, SequenceOfPntOn2S from IntSurf raises OutOfRange from Standard is - Create + Create (theAllocator: Allocator from IntSurf = 0) returns mutable LineOn2S from IntSurf; diff --git a/src/IntSurf/IntSurf_LineOn2S.cxx b/src/IntSurf/IntSurf_LineOn2S.cxx index 2c1eff165c..56da7831e4 100755 --- a/src/IntSurf/IntSurf_LineOn2S.cxx +++ b/src/IntSurf/IntSurf_LineOn2S.cxx @@ -19,7 +19,8 @@ #include -IntSurf_LineOn2S::IntSurf_LineOn2S () +IntSurf_LineOn2S::IntSurf_LineOn2S (const IntSurf_Allocator& theAllocator) : + mySeq (theAllocator) {} diff --git a/src/IntSurf/IntSurf_SequenceOfPntOn2S.hxx b/src/IntSurf/IntSurf_SequenceOfPntOn2S.hxx new file mode 100644 index 0000000000..c057ee20a3 --- /dev/null +++ b/src/IntSurf/IntSurf_SequenceOfPntOn2S.hxx @@ -0,0 +1,27 @@ +// Copyright (c) 2013-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef IntSurf_SequenceOfPntOn2S_HeaderFile +#define IntSurf_SequenceOfPntOn2S_HeaderFile + +#include +#include + +typedef NCollection_Sequence IntSurf_SequenceOfPntOn2S; + +#endif diff --git a/src/IntWalk/FILES b/src/IntWalk/FILES index d0cc02743f..0c13b99b58 100755 --- a/src/IntWalk/FILES +++ b/src/IntWalk/FILES @@ -8,3 +8,5 @@ IntWalk_PWalking_1.gxx IntWalk_PWalking_2.gxx IntWalk_PWalking_3.gxx IntWalk_PWalking_4.gxx +IntWalk_VectorOfInteger.hxx +IntWalk_VectorOfWalkingData.hxx diff --git a/src/IntWalk/IntWalk.cdl b/src/IntWalk/IntWalk.cdl index b80d447206..87bbb368ad 100755 --- a/src/IntWalk/IntWalk.cdl +++ b/src/IntWalk/IntWalk.cdl @@ -68,6 +68,12 @@ is --algorithme cheminement/resolution generic class IWalking, TheIWLine, SequenceOfIWLine; + + imported VectorOfWalkingData; + ---Purpose: Defines a dynamic vector of work data. + + imported VectorOfInteger; + ---Purpose: Defines a dynamic vector of integer. --algorithme/resolution pour un cheminement sur intersection entre diff --git a/src/IntWalk/IntWalk_IWLine.cdl b/src/IntWalk/IntWalk_IWLine.cdl index fbc92316bb..f36754f403 100755 --- a/src/IntWalk/IntWalk_IWLine.cdl +++ b/src/IntWalk/IntWalk_IWLine.cdl @@ -41,7 +41,8 @@ inherits TShared from MMgt -- because no marching points where found to stop -- beware : the directions are not oriented. -uses Couple from IntSurf, +uses Allocator from IntSurf, + Couple from IntSurf, SequenceOfCouple from IntSurf, PntOn2S from IntSurf, LineOn2S from IntSurf, @@ -54,7 +55,7 @@ raises OutOfRange from Standard, is - Create + Create (theAllocator: Allocator from IntSurf = 0) returns mutable IWLine; diff --git a/src/IntWalk/IntWalk_IWLine.gxx b/src/IntWalk/IntWalk_IWLine.gxx index 12e3107d18..74cbdad80b 100755 --- a/src/IntWalk/IntWalk_IWLine.gxx +++ b/src/IntWalk/IntWalk_IWLine.gxx @@ -18,11 +18,14 @@ #include -IntWalk_IWLine::IntWalk_IWLine() +IntWalk_IWLine::IntWalk_IWLine (const IntSurf_Allocator& theAllocator) : + line (new IntSurf_LineOn2S (theAllocator)), + closed (Standard_False), + hasFirst (Standard_False), hasLast (Standard_False), + firstIndex (-1), lastIndex (-1), + indextg (-1), + istgtbeg (Standard_False), istgtend (Standard_False) { - line = new IntSurf_LineOn2S (); - closed=hasFirst=hasLast=istgtbeg=istgtend=Standard_False; - indextg=-1; } void IntWalk_IWLine::Reverse() diff --git a/src/IntWalk/IntWalk_IWalking.cdl b/src/IntWalk/IntWalk_IWalking.cdl index 748f1919b6..7831423391 100755 --- a/src/IntWalk/IntWalk_IWalking.cdl +++ b/src/IntWalk/IntWalk_IWalking.cdl @@ -44,6 +44,8 @@ uses Vector from math, SequenceOfInteger from TColStd, SequenceOfReal from TColStd, StatusDeflection from IntWalk, + VectorOfInteger from IntWalk, + VectorOfWalkingData from IntWalk, Vec from gp, Dir2d from gp, PntOn2S from IntSurf @@ -269,6 +271,9 @@ is Psol : in out PntOn2S from IntSurf) is static protected; + + Clear (me: in out) is static protected; + ---Purpose: Clears up internal containers fields @@ -281,13 +286,9 @@ fields epsilon : Real from Standard; reversed : Boolean from Standard; - ustart1 : SequenceOfReal from TColStd; - vstart1 : SequenceOfReal from TColStd; - nbMultiplicities : SequenceOfInteger from TColStd; - etat1 : SequenceOfInteger from TColStd; - ustart2 : SequenceOfReal from TColStd; - vstart2 : SequenceOfReal from TColStd; - etat2 : SequenceOfInteger from TColStd; + wd1 : VectorOfWalkingData from IntWalk; + wd2 : VectorOfWalkingData from IntWalk; + nbMultiplicities : VectorOfInteger from IntWalk; Um : Real from Standard; -- Min U de la surf UM : Real from Standard; -- Max U de la surf Vm : Real from Standard; -- Min V de la surf diff --git a/src/IntWalk/IntWalk_IWalking_1.gxx b/src/IntWalk/IntWalk_IWalking_1.gxx index 503d1b2ce5..4a9e21092a 100755 --- a/src/IntWalk/IntWalk_IWalking_1.gxx +++ b/src/IntWalk/IntWalk_IWalking_1.gxx @@ -22,6 +22,7 @@ OSD_Chronometer Chronrsnld; #endif +#include #include IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon, @@ -32,11 +33,39 @@ IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon, pas(Increment), tolerance(1,2), epsilon(Epsilon*Epsilon), + wd1 (IntWalk_VectorOfWalkingData::allocator_type (new NCollection_IncAllocator)), + wd2 (wd1.get_allocator()), + nbMultiplicities (wd1.get_allocator()), NbPointsConfondusConsecutifs(0), EpsilonSembleTropGrand(0) { } + +//======================================================================= +//function : Reset +//purpose : Clears NCollection_Vector-based containers and adds +// dummy data to maintain start index of 1 and consistent with +// previous TCollection_Sequence-based implementation and other +// used TCollection-based containers +//======================================================================= + +void IntWalk_IWalking::Clear() +{ + wd1.clear(); + wd2.clear(); + IntWalk_WalkingData aDummy; + aDummy.etat = -10; + aDummy.ustart = aDummy.vstart = 0.; + wd1.push_back (aDummy); + wd2.push_back (aDummy); + nbMultiplicities.clear(); + nbMultiplicities.push_back (-1); + + done = Standard_False; + seqAjout.Clear(); + lines.Clear(); +} // *************************************************************************** // etat1=12 pas tangent,pas passant @@ -64,23 +93,12 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, { Standard_Integer I; - ThePointOfPath PathPnt; Standard_Boolean Rajout = Standard_False; Standard_Integer nbPnts1 = Pnts1.Length(); Standard_Integer nbPnts2 = Pnts2.Length(); Standard_Real U,V; - done = Standard_False; - - ustart1.Clear(); - vstart1.Clear(); - etat1.Clear(); - nbMultiplicities.Clear(); - ustart2.Clear(); - vstart2.Clear(); - etat2.Clear(); - seqAjout.Clear(); - lines.Clear(); + Clear(); reversed = Reversed; @@ -90,51 +108,39 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, TColStd_SequenceOfReal Vmult; Standard_Integer decal=0; + wd1.reserve (nbPnts1+decal); + nbMultiplicities.reserve (nbPnts1+decal); for (I=1;I <= nbPnts1+decal; I++) { - PathPnt = Pnts1.Value(I-decal); - etat1.Append(1); + const ThePointOfPath& PathPnt = Pnts1.Value(I-decal); + IntWalk_WalkingData aWD1; + aWD1.etat = 1; if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) - etat1(I) = 11; + aWD1.etat = 11; if (!ThePointOfPathTool::IsTangent(PathPnt)) - etat1(I) = etat1(I) + 1; - - Standard_Integer etat1I=etat1(I); - //-- cout<<" \n Etat1("<0) seqSingle.Append(Pnts1(I)); + if (wd1[I].etat >0) seqSingle.Append(Pnts1(I)); } done = Standard_True; } @@ -181,22 +187,10 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, { Standard_Integer I; - ThePointOfPath PathPnt; Standard_Boolean Rajout = Standard_False; Standard_Integer nbPnts1 = Pnts1.Length(); Standard_Real U,V; - done = Standard_False; - - ustart1.Clear(); - vstart1.Clear(); - etat1.Clear(); - nbMultiplicities.Clear(); - ustart2.Clear(); - vstart2.Clear(); - etat2.Clear(); - seqAjout.Clear(); - lines.Clear(); reversed = Reversed; @@ -205,18 +199,20 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, TColStd_SequenceOfReal Umult; TColStd_SequenceOfReal Vmult; + wd1.reserve (nbPnts1); for (I=1;I <= nbPnts1; I++) { - PathPnt = Pnts1.Value(I); - etat1.Append(1); - if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) etat1(I) = 11; - if (!ThePointOfPathTool::IsTangent(PathPnt)) etat1(I) = etat1(I) + 1; - ThePointOfPathTool::Value2d(PathPnt, U,V); - ustart1.Append(U); - vstart1.Append(V); - nbMultiplicities.Append(ThePointOfPathTool::Multiplicity(PathPnt)); - - for (Standard_Integer J = 1; J <= nbMultiplicities(I); J++) { - ThePointOfPathTool::Parameters(PathPnt, J, U , V); + const ThePointOfPath& PathPnt = Pnts1.Value(I); + IntWalk_WalkingData aWD1; + aWD1.etat = 1; + if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) aWD1.etat = 11; + if (!ThePointOfPathTool::IsTangent(PathPnt)) ++aWD1.etat; + ThePointOfPathTool::Value2d(PathPnt, aWD1.ustart, aWD1.vstart); + wd1.push_back (aWD1); + Standard_Integer aNbMult = ThePointOfPathTool::Multiplicity(PathPnt); + nbMultiplicities.push_back(aNbMult); + + for (Standard_Integer J = 1; J <= aNbMult; J++) { + ThePointOfPathTool::Parameters(PathPnt, J, U, V); Umult.Append(U); Vmult.Append(V); } @@ -247,7 +243,7 @@ void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1, if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout); for (I = 1; I <= nbPnts1; I++) { - if (etat1(I) >0) seqSingle.Append(Pnts1(I)); + if (wd1[I].etat >0) seqSingle.Append(Pnts1(I)); } done = Standard_True; } diff --git a/src/IntWalk/IntWalk_IWalking_2.gxx b/src/IntWalk/IntWalk_IWalking_2.gxx index 5d48b1f08d..6126c81284 100755 --- a/src/IntWalk/IntWalk_IWalking_2.gxx +++ b/src/IntWalk/IntWalk_IWalking_2.gxx @@ -203,7 +203,7 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage // l espace UV. { Standard_Real Up, Vp, Du, Dv, Dup, Dvp, Utest,Vtest; - Standard_Integer i, j, k, N, ind; + Standard_Integer j, N, ind; Standard_Real tolu = tolerance(1); Standard_Real tolv = tolerance(2); Standard_Real tolu2 = 10.*tolerance(1); @@ -221,14 +221,14 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage previousPoint.ParametersOnS1(Up,Vp); } - for (i = 1; i <= etat2.Length(); i++) { - if (etat2(i) > 0) { + for (size_t i = 1; i < wd2.size(); i++) { + if (wd2[i].etat > 0) { // debug jag 05.04.94 -// if ((Up-ustart2(i))*(UV(1)-ustart2(i)) + -// (Vp-vstart2(i))*(UV(2)-vstart2(i)) <= 0) - Utest = ustart2(i); - Vtest = vstart2(i); +// if ((Up-wd2[i].ustart)*(UV(1)-wd2[i].ustart) + +// (Vp-wd2[i].vstart)*(UV(2)-wd2[i].vstart) <= 0) + Utest = wd2[i].ustart; + Vtest = wd2[i].vstart; Du = UV(1)-Utest; Dv = UV(2)-Vtest; @@ -242,7 +242,7 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage if ((Abs(Du) < tolu2 && Abs(Dv) < tolv2) || (Abs(Dup) < tolu2 && Abs(Dvp) < tolv2)) { - etat2(i) = -etat2(i); + wd2[i].etat = -wd2[i].etat; } else { Standard_Real DDu = (UV(1)-Up); @@ -252,7 +252,7 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage if(DD1<=DDD) { Standard_Real DD2 = Dup*Dup+Dvp*Dvp; if(DD2<=DDD && ((Du*Dup) + (Dv*Dvp*tolu/tolv) <= 0.)) { - etat2(i) = -etat2(i); + wd2[i].etat = -wd2[i].etat; } } } @@ -279,19 +279,19 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage for (l = 1; l <= 2 && !Arrive; l++) { Standard_Boolean isToCheck; - for (i = 1; i <= etat1.Length(); i++) { + for (size_t i = 1; i < wd1.size(); i++) { if (l == 1) - isToCheck = (etat1(i) > 0); + isToCheck = (wd1[i].etat > 0); else - isToCheck = (etat1(i) < 0); + isToCheck = (wd1[i].etat < 0); if (isToCheck) { // Modified by Sergey KHROMOV - Tue Nov 20 11:03:16 2001 End // debug jag voir avec isg - Utest = ustart1(i); - Vtest = vstart1(i); + Utest = wd1[i].ustart; + Vtest = wd1[i].vstart; Dup = Up - Utest; Dvp = Vp - Vtest; if (Abs(Dup) >= tolu || Abs(Dvp) >= tolv) { @@ -309,12 +309,12 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage UV(2) = Vtest; */ } - else if (nbMultiplicities(i) > 0 && i_candidates.IsEmpty()) { + else if (nbMultiplicities[i] > 0 && i_candidates.IsEmpty()) { N=0; - for (k = 1; k < i; k++) { - N+=nbMultiplicities(k); + for (size_t k = 1; k < i; k++) { + N+=nbMultiplicities[k]; } - for (j = N + 1; j <= N + nbMultiplicities(i); j++) { + for (j = N + 1; j <= N + nbMultiplicities[i]; j++) { if (((Up-Umult(j))*(UV(1)-Umult(j)) + (Vp-Vmult(j))*(UV(2)-Vmult(j)) < 0) || (Abs(UV(1)-Umult(j)) < tolu && @@ -336,7 +336,7 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage } } } - } //end of for (i = 1; i <= etat1.Length(); i++) + } //end of for (i = 1; i < wd1.size(); i++) if (!i_candidates.IsEmpty()) { Standard_Real MinSqDist = RealLast(); @@ -347,8 +347,8 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage Irang = i_candidates(ind); } Arrive = Standard_True; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; } } //end of for (l = 1; l <= 2 && !Arrive; l++) return Arrive; @@ -412,10 +412,10 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage Standard_Real dPreviousCurrent = (Up-UV1)*(Up-UV1)+(Vp-UV2)*(Vp-UV2); - for (k = 1; k <= etat2.Length(); k++) { - if (etat2(k) > 0) { - Utest = ustart2(k); - Vtest = vstart2(k); + for (k = 1; k < (int)wd2.size(); k++) { + if (wd2[k].etat > 0) { + Utest = wd2[k].ustart; + Vtest = wd2[k].vstart; Utest/=deltau; Vtest/=deltav; @@ -426,7 +426,7 @@ Standard_Boolean IntWalk_IWalking::TestArretPassage && (UV2mVtest-tolv2)) { if(Index!=k) { //-- cout<<"* etat2 : ("< 0 && etat1(i) < 11) { //test des points passant - Utest = ustart1(i); - Vtest = vstart1(i); + for (i = 1; i < (int)wd1.size(); i++) { + if (wd1[i].etat > 0 && wd1[i].etat < 11) { //test des points passant + Utest = wd1[i].ustart; + Vtest = wd1[i].vstart; Utest/=deltau; Vtest/=deltav; if (((Up-Utest) * (UV1-Utest) + (Vp-Vtest) * (UV2-Vtest) < 0) || (Abs(UV1-Utest) < tolu && Abs(UV2-Vtest) < tolv)) Irang = i; - else if (nbMultiplicities(i) > 0) { + else if (nbMultiplicities[i] > 0) { N=0; - for (k = 1; k < i; k++) N = N + nbMultiplicities(k); - for (Standard_Integer j = N + 1; j <= N + nbMultiplicities(i); j++) { + for (k = 1; k < i; k++) N = N + nbMultiplicities[k]; + for (Standard_Integer j = N + 1; j <= N + nbMultiplicities[i]; j++) { Standard_Real Umultj = Umult(j)/deltau; Standard_Real Vmultj = Vmult(j)/deltav; if (((Up-Umultj)*(UV1-Umultj) + @@ -605,12 +605,12 @@ void IntWalk_IWalking::TestArretCadre Irang =0; - for (Standard_Integer i = 1; i <= etat1.Length(); i++) { - if (etat1(i) < 0) { + for (Standard_Integer i = 1; i < (int)wd1.size(); i++) { + if (wd1[i].etat < 0) { N=0; // rang dans UVMult. - if (nbMultiplicities(i) > 0) { + if (nbMultiplicities[i] > 0) { for (Standard_Integer k = 1; k < i; k++) - N+=nbMultiplicities(k); + N+=nbMultiplicities[k]; } if (!reversed) { Line->Value(1).ParametersOnS2(Up,Vp); @@ -627,33 +627,33 @@ void IntWalk_IWalking::TestArretCadre Line->Value(j).ParametersOnS1(Uc,Vc); } - Scal = (Up-ustart1(i)) * (Uc-ustart1(i)) + - (Vp-vstart1(i)) * (Vc-vstart1(i)); + Scal = (Up-wd1[i].ustart) * (Uc-wd1[i].ustart) + + (Vp-wd1[i].vstart) * (Vc-wd1[i].vstart); // si on a trouve un point d arret : on arrete la ligne sur ce point. if (Scal < 0) { Line->Cut(j); nbp= Line->NbPoints(); Irang = i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; } - else if (Abs(Uc-ustart1(i)) < tolerance(1) && - Abs(Vc-vstart1(i)) < tolerance(2) ) { + else if (Abs(Uc-wd1[i].ustart) < tolerance(1) && + Abs(Vc-wd1[i].vstart) < tolerance(2) ) { Line->Cut(j); nbp= Line->NbPoints(); Irang=i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; } - else if (nbMultiplicities(i) > 0) { - for (Standard_Integer k = N+1; k <= N + nbMultiplicities(i); k++) { + else if (nbMultiplicities[i] > 0) { + for (Standard_Integer k = N+1; k <= N + nbMultiplicities[i]; k++) { Scal = (Up-Umult(k)) * (Uc-Umult(k)) + (Vp-Vmult(k)) * (Vc-Vmult(k)); if (Scal < 0) { Line->Cut(j); nbp= Line->NbPoints(); Irang=i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; break; } @@ -661,8 +661,8 @@ void IntWalk_IWalking::TestArretCadre Abs(Vc-Vmult(k)) < tolerance(2)) { Line->Cut(j); nbp= Line->NbPoints(); Irang=i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; break; } @@ -704,40 +704,40 @@ void IntWalk_IWalking::TestArretCadre // point calcule. // il n y aura pas besoin de "Cuter" - Scal = (Up-ustart1(i)) * (UV(1)-ustart1(i)) + - // (Vp-ustart1(i)) * (UV(2)-vstart1(i)); + Scal = (Up-wd1[i].ustart) * (UV(1)-wd1[i].ustart) + + // (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart); // modified by NIZHNY-MKK Fri Oct 27 12:29:41 2000 - (Vp-vstart1(i)) * (UV(2)-vstart1(i)); + (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart); if (Scal < 0) { Irang = i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; } - else if (Abs(UV(1)-ustart1(i)) < tolerance(1) && - Abs(UV(2)-vstart1(i)) < tolerance(2)) { + else if (Abs(UV(1)-wd1[i].ustart) < tolerance(1) && + Abs(UV(2)-wd1[i].vstart) < tolerance(2)) { Irang=i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; } - else if (nbMultiplicities(i) > 0) { - for (Standard_Integer j = N+1; j <= N+nbMultiplicities(i); j++) { + else if (nbMultiplicities[i] > 0) { + for (Standard_Integer j = N+1; j <= N+nbMultiplicities[i]; j++) { Scal = (Up-Umult(j)) * (UV(1)-Umult(j)) + (Vp-Vmult(j)) * (UV(2)-Vmult(j)); if (Scal < 0) { Irang=i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; break; } else if (Abs(UV(1)-Umult(j)) < tolerance(1) && Abs(UV(2)-Vmult(j)) < tolerance(2)) { Irang=i; - UV(1) = ustart1(Irang); - UV(2) = vstart1(Irang); + UV(1) = wd1[Irang].ustart; + UV(2) = wd1[Irang].vstart; Found = Standard_True; break; } diff --git a/src/IntWalk/IntWalk_IWalking_3.gxx b/src/IntWalk/IntWalk_IWalking_3.gxx index 9fe626d6b6..396fca1fb1 100755 --- a/src/IntWalk/IntWalk_IWalking_3.gxx +++ b/src/IntWalk/IntWalk_IWalking_3.gxx @@ -18,20 +18,17 @@ -#ifndef DEB -#define No_Standard_RangeError -#define No_Standard_OutOfRange -#endif +#include +#include + // modified by NIZHNY-MKK Thu Nov 2 15:07:26 2000.BEGIN -static Standard_Boolean TestPassedSolutionWithNegativeState(const TColStd_SequenceOfInteger& etat, +static Standard_Boolean TestPassedSolutionWithNegativeState(const IntWalk_VectorOfWalkingData& wd, const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, - const TColStd_SequenceOfReal& ustart, - const TColStd_SequenceOfReal& vstart, const Standard_Real& prevUp, const Standard_Real& prevVp, - const TColStd_SequenceOfInteger& nbMultiplicities, + const IntWalk_VectorOfInteger& nbMultiplicities, const math_Vector& tolerance, TheIWFunction& sp, math_Vector& UV, @@ -101,32 +98,33 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, Standard_Integer nbPath = Pnts1.Length(); // modified by NIZHNY-MKK Fri Oct 27 12:32:34 2000.BEGIN - TColStd_SequenceOfInteger movementdirectioninfo; - for (I = 1; I <= nbPath; I++) { - movementdirectioninfo.Append(0); + NCollection_LocalArray movementdirectioninfoarr (nbPath + 1); + Standard_Integer* movementdirectioninfo = movementdirectioninfoarr; + for (I = 0; I <= nbPath; I++) { + movementdirectioninfo[I] = 0; } // modified by NIZHNY-MKK Fri Oct 27 12:32:38 2000.END for (I = 1; I <= nbPath; I++) { //start point of the progression - // if (etat1(I) > 11) { + // if (wd1[I].etat > 11) { // modified by NIZHNY-MKK Fri Oct 27 12:33:37 2000.BEGIN - if ((etat1(I) > 11) || ((etat1(I) < -11) && (movementdirectioninfo(I)!=0))) { + if ((wd1[I].etat > 11) || ((wd1[I].etat < -11) && (movementdirectioninfo[I]!=0))) { // modified by NIZHNY-MKK Fri Oct 27 12:33:43 2000.END PathPnt = Pnts1.Value(I); - CurrentLine = new IntWalk_TheIWLine (); + CurrentLine = new IntWalk_TheIWLine (new NCollection_IncAllocator()); CurrentLine->SetTangencyAtBegining(Standard_False); Tgtend = Standard_False; CurrentLine->AddStatusFirst(Standard_False, Standard_True, I, PathPnt); - UVap(1) = ustart1(I); - UVap(2) = vstart1(I); + UVap(1) = wd1[I].ustart; + UVap(2) = wd1[I].vstart; MakeWalkingPoint(11, UVap(1), UVap(2), Func, previousPoint); previousd3d = Func.Direction3d(); previousd2d = Func.Direction2d(); CurrentLine->AddPoint(previousPoint); // modified by NIZHNY-MKK Fri Oct 27 12:34:32 2000.BEGIN - if(movementdirectioninfo(I) !=0) { - if(movementdirectioninfo(I) < 0) { + if(movementdirectioninfo[I] !=0) { + if(movementdirectioninfo[I] < 0) { StepSign = -1; CurrentLine->SetTangentVector(previousd3d.Reversed(),1); } else { @@ -147,8 +145,8 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, // modified by NIZHNY-MKK Fri Oct 27 12:34:37 2000.END // Modified by Sergey KHROMOV - Tue Nov 20 10:41:45 2001 Begin - etat1(I) = - abs(etat1(I)); - movementdirectioninfo(I) = (movementdirectioninfo(I)==0) ? StepSign : 0; + wd1[I].etat = - abs(wd1[I].etat); + movementdirectioninfo[I] = (movementdirectioninfo[I]==0) ? StepSign : 0; // Modified by Sergey KHROMOV - Tue Nov 20 10:41:56 2001 End // first step of advancement Standard_Real d2dx = Abs(previousd2d.X()); @@ -227,7 +225,7 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, else { previousPoint.ParametersOnS1(prevUp, prevVp); } - Arrive = TestPassedSolutionWithNegativeState(etat1, Umult, Vmult, ustart1, vstart1, prevUp, prevVp, + Arrive = TestPassedSolutionWithNegativeState(wd1, Umult, Vmult, prevUp, prevVp, nbMultiplicities, tolerance, Func, UVap, N); if(Arrive) { Cadre = Standard_False; @@ -294,7 +292,7 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, // point of stop given at input PathPnt = Pnts1.Value(N); - Standard_Integer etat1N=etat1(N); + Standard_Integer etat1N=wd1[N].etat; // modified by NIZHNY-MKK Thu Nov 2 15:09:51 2000.BEGIN // if (etat1N < 11) { // passing point that is a stop if (Abs(etat1N) < 11) { // passing point that is a stop @@ -317,10 +315,10 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, AddPointInCurrentLine(N,PathPnt,CurrentLine); if ((etat1N != 1 && etat1N != 11)) { // modified by NIZHNY-MKK Fri Oct 27 12:43:05 2000.BEGIN - // etat1(N)= - etat1N; - etat1(N)= - Abs(etat1N); - movementdirectioninfo(N) = (movementdirectioninfo(N)==0) ? StepSign : 0; - if(Arrive && movementdirectioninfo(N)!=0) { + // wd1[N].etat= - wd1[N].etat; + wd1[N].etat = - Abs(etat1N); + movementdirectioninfo[N] = (movementdirectioninfo[N]==0) ? StepSign : 0; + if(Arrive && movementdirectioninfo[N]!=0) { IndexOfPathPointDoNotCheck = N; } @@ -367,23 +365,23 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, CurrentLine->SetTangencyAtEnd(Tgtend); lines.Append(CurrentLine); // modified by NIZHNY-MKK Fri Oct 27 12:59:29 2000.BEGIN - movementdirectioninfo(I)=0; - if(etat1(I) > 0) + movementdirectioninfo[I]=0; + if(wd1[I].etat > 0) // modified by NIZHNY-MKK Fri Oct 27 12:59:42 2000.END - etat1(I)=-etat1(I); + wd1[I].etat=-wd1[I].etat; //-- lbr le 5 juin 97 (Pb ds Contap) for(Standard_Integer av=1; av<=nbPath; av++) { // modified by NIZHNY-MKK Fri Oct 27 13:00:22 2000.BEGIN - // if (etat1(av) > 11) { - if ((etat1(av) > 11) || + // if (wd1[av].etat > 11) { + if ((wd1[av].etat > 11) || ((av!=I) && (av!=IndexOfPathPointDoNotCheck) && - (etat1(av) < -11) && - (movementdirectioninfo(av)!=0))) { + (wd1[av].etat < -11) && + (movementdirectioninfo[av]!=0))) { // modified by NIZHNY-MKK Fri Oct 27 13:00:26 2000.END - Standard_Real Uav=ustart1(av); - Standard_Real Vav=vstart1(av); + Standard_Real Uav=wd1[av].ustart; + Standard_Real Vav=wd1[av].vstart; Standard_Real Uavp,Vavp; const IntSurf_PntOn2S &avP=CurrentLine->Value(CurrentLine->NbPoints()); if (!reversed) { @@ -397,12 +395,12 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, Uav*=0.001; Vav*=0.001; if(Abs(Uav)AddStatusLast(Standard_True, av, Pnts1.Value(av)); @@ -416,19 +414,19 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, else { avPP.ParametersOnS1(Uavp,Vavp); } - Uav=ustart1(av); - Vav=vstart1(av); + Uav=wd1[av].ustart; + Vav=wd1[av].vstart; Uav-=Uavp; Vav-=Vavp; Uav*=0.001; Vav*=0.001; if(Abs(Uav)= tolu || Abs(Dvp) >= tolv) { @@ -480,12 +476,12 @@ static Standard_Boolean TestPassedSolutionWithNegativeState(const TColStd_Sequen UV(1) = Utest; UV(2) = Vtest; } - else if (nbMultiplicities(i) > 0) { + else if (nbMultiplicities[i] > 0) { N=0; for (k = 1; k < i; k++) { - N+=nbMultiplicities(k); + N+=nbMultiplicities[k]; } - for (j = N + 1; j <= N + nbMultiplicities(i); j++) { + for (j = N + 1; j <= N + nbMultiplicities[i]; j++) { if (((prevUp-Umult(j))*(UV(1)-Umult(j)) + (prevVp-Vmult(j))*(UV(2)-Vmult(j)) < 0) || (Abs(UV(1)-Umult(j)) < tolu && diff --git a/src/IntWalk/IntWalk_IWalking_4.gxx b/src/IntWalk/IntWalk_IWalking_4.gxx index 94595bab69..a87fd9a8e5 100755 --- a/src/IntWalk/IntWalk_IWalking_4.gxx +++ b/src/IntWalk/IntWalk_IWalking_4.gxx @@ -17,11 +17,7 @@ // and conditions governing the rights and limitations under the License. - -#ifndef DEB -#define No_Standard_RangeError -#define No_Standard_OutOfRange -#endif +#include void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, @@ -88,21 +84,21 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, Standard_Integer nbLoop = Pnts2.Length(); for (I = 1;I<=nbLoop;I++) { - if (etat2(I) > 12) { // start point of closed line + if (wd2[I].etat > 12) { // start point of closed line LoopPnt = Pnts2.Value(I); previousPoint.SetValue(ThePointOfLoopTool::Value3d(LoopPnt),reversed, - ustart2(I),vstart2(I)); + wd2[I].ustart,wd2[I].vstart); previousd3d = ThePointOfLoopTool::Direction3d(LoopPnt); previousd2d = ThePointOfLoopTool::Direction2d(LoopPnt); - CurrentLine = new IntWalk_TheIWLine (); + CurrentLine = new IntWalk_TheIWLine (new NCollection_IncAllocator()); CurrentLine->AddPoint(previousPoint); CurrentLine->SetTangentVector(previousd3d,1); Tgtbeg = Standard_False; Tgtend = Standard_False; - Uvap(1) = ustart2(I); - Uvap(2) = vstart2(I); + Uvap(1) = wd2[I].ustart; + Uvap(2) = wd2[I].vstart; StepSign = 1; @@ -183,7 +179,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, else { Tgtend = lines.Value(-N)->IsTangentAtBegining(); } - Arrive = (etat2(I) == 12); + Arrive = (wd2[I].etat == 12); } } @@ -196,7 +192,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, Tgtend = Func.IsTangent(); // jag 940616 N = -N; } - Arrive = (etat2(I) == 12); // the line is open + Arrive = (wd2[I].etat == 12); // the line is open } } Status = TestDeflection(Func, Arrive,Uvap,StatusPrecedent, @@ -227,7 +223,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, } else { // open - etat2(I) = 12; // declare it open + wd2[I].etat = 12; // declare it open Tgtbeg = Tgtend; Tgtend = Standard_False; ArretAjout = Standard_False; @@ -252,8 +248,8 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, Arrive = Standard_False; break; } - if (etat2(I) >12) { //the line should become open - etat2(I) = 12; //declare it open + if (wd2[I].etat >12) { //the line should become open + wd2[I].etat = 12; //declare it open ArretAjout = Standard_False; OpenLine(0,Psol,Pnts1,Func,CurrentLine); StepSign = -1; @@ -271,7 +267,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, } } else if (Arrive) { - if (etat2(I) > 12) { //line closed good case + if (wd2[I].etat > 12) { //line closed good case CurrentLine->AddStatusFirstLast(Standard_True, Standard_False,Standard_False); CurrentLine->AddPoint(CurrentLine->Value(1)); @@ -283,8 +279,8 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, } } else if (Status == IntWalk_ArretSurPoint) { - if (etat2(I) >12) { //line should become open - etat2(I) = 12; //declare it open + if (wd2[I].etat >12) { //line should become open + wd2[I].etat = 12; //declare it open Tgtbeg = Standard_True; Tgtend = Standard_False; N= -lines.Length()-1; @@ -344,7 +340,7 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult, CurrentLine->SetTangencyAtEnd(Tgtend); lines.Append(CurrentLine); - etat2(I)=-etat2(I); //mark point as processed + wd2[I].etat=-wd2[I].etat; //mark point as processed } } //end of processing of start point } //end of all start points diff --git a/src/IntWalk/IntWalk_IWalking_6.gxx b/src/IntWalk/IntWalk_IWalking_6.gxx index 4d78dfe80d..e8166ba3c7 100755 --- a/src/IntWalk/IntWalk_IWalking_6.gxx +++ b/src/IntWalk/IntWalk_IWalking_6.gxx @@ -31,7 +31,7 @@ void IntWalk_IWalking::AddPointInCurrentLine IntSurf_PntOn2S Psol; Psol.SetValue(ThePointOfPathTool::Value3d(PathPnt), - reversed,ustart1(N),vstart1(N)); + reversed,wd1[N].ustart,wd1[N].vstart); CurrentLine->AddPoint(Psol); } diff --git a/src/IntWalk/IntWalk_VectorOfInteger.hxx b/src/IntWalk/IntWalk_VectorOfInteger.hxx new file mode 100644 index 0000000000..09d89aa970 --- /dev/null +++ b/src/IntWalk/IntWalk_VectorOfInteger.hxx @@ -0,0 +1,30 @@ +// Created on: 2013-0603 +// Created by: Roman LYGIN +// Copyright (c) 2013-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef IntWalk_VectorOfInteger_HeaderFile +#define IntWalk_VectorOfInteger_HeaderFile + +#include +#include + +typedef std::vector > + IntWalk_VectorOfInteger; + +#endif diff --git a/src/IntWalk/IntWalk_VectorOfWalkingData.hxx b/src/IntWalk/IntWalk_VectorOfWalkingData.hxx new file mode 100644 index 0000000000..2486b113fd --- /dev/null +++ b/src/IntWalk/IntWalk_VectorOfWalkingData.hxx @@ -0,0 +1,37 @@ +// Created on: 2013-0603 +// Created by: Roman LYGIN +// Copyright (c) 2013-2013 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +#ifndef IntWalk_VectorOfWalkingData_HeaderFile +#define IntWalk_VectorOfWalkingData_HeaderFile + +#include +#include + +struct IntWalk_WalkingData +{ + Standard_Real ustart; + Standard_Real vstart; + Standard_Integer etat; +}; + +typedef std::vector > + IntWalk_VectorOfWalkingData; + +#endif diff --git a/src/Intf/Intf_InterferencePolygon2d.cxx b/src/Intf/Intf_InterferencePolygon2d.cxx index d5f68f8062..f12007509c 100644 --- a/src/Intf/Intf_InterferencePolygon2d.cxx +++ b/src/Intf/Intf_InterferencePolygon2d.cxx @@ -162,23 +162,25 @@ void Intf_InterferencePolygon2d::Interference Bnd_Box2d bSO; Bnd_Box2d bST; - Standard_Integer iObje1, iObje2; + Standard_Integer iObje1, iObje2, n1 = nbso, n2 = Obje2.NbSegments(); + Standard_Real d1 = Obje1.DeflectionOverEstimation(), + d2 = Obje2.DeflectionOverEstimation(); gp_Pnt2d p1b, p1e, p2b, p2e; - for (iObje1=1; iObje1<=Obje1.NbSegments(); iObje1++) + for (iObje1=1; iObje1<=n1; iObje1++) { bSO.SetVoid(); Obje1.Segment(iObje1,p1b,p1e); bSO.Add(p1b); bSO.Add(p1e); - bSO.Enlarge(Obje1.DeflectionOverEstimation()); + bSO.Enlarge(d1); if (!Obje2.Bounding().IsOut(bSO)) { - for (iObje2=1; iObje2<=Obje2.NbSegments(); iObje2++) { + for (iObje2=1; iObje2<=n2; iObje2++) { bST.SetVoid(); Obje2.Segment(iObje2,p2b,p2e); bST.Add(p2b); bST.Add(p2e); - bST.Enlarge(Obje2.DeflectionOverEstimation()); + bST.Enlarge(d2); if (!bSO.IsOut(bST)) Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e); } @@ -197,22 +199,23 @@ void Intf_InterferencePolygon2d::Interference Bnd_Box2d bSO; Bnd_Box2d bST; - Standard_Integer iObje1, iObje2; + Standard_Integer iObje1, iObje2, n = Obje.NbSegments(); + Standard_Real d = Obje.DeflectionOverEstimation(); gp_Pnt2d p1b, p1e, p2b, p2e; - for (iObje1=1; iObje1<=Obje.NbSegments(); iObje1++) { + for (iObje1=1; iObje1<=n; iObje1++) { bSO.SetVoid(); Obje.Segment(iObje1,p1b,p1e); bSO.Add(p1b); bSO.Add(p1e); - bSO.Enlarge(Obje.DeflectionOverEstimation()); + bSO.Enlarge(d); if (!Obje.Bounding().IsOut(bSO)) { - for (iObje2=iObje1+1;iObje2<=Obje.NbSegments();iObje2++){ + for (iObje2=iObje1+1;iObje2<=n;iObje2++){ bST.SetVoid(); Obje.Segment(iObje2,p2b,p2e); bST.Add(p2b); bST.Add(p2e); - bST.Enlarge(Obje.DeflectionOverEstimation()); + bST.Enlarge(d); if (!bSO.IsOut(bST)) Intersect(iObje1, iObje2, p1b, p1e, p2b, p2e); } diff --git a/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx b/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx index cb99ace78d..9ec8432646 100755 --- a/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx @@ -70,14 +70,17 @@ static void ProjectOnSegments (const Adaptor3d_Curve& AC, const gp_Pnt& P3D, // On considere points sur [uMin,uMax] // Quel est le plus proche. Et quel est le nouvel intervalle // (il ne peut pas deborder l ancien) - Standard_Real u, dist, delta = (nbseg == 0)? 0 : (uMax-uMin)/nbseg; //szv#4:S4163:12Mar99 anti-exception + Standard_Real u, dist2, delta = (nbseg == 0)? 0 : (uMax-uMin)/nbseg; //szv#4:S4163:12Mar99 anti-exception + Standard_Real distmin2 = distmin * distmin; + Standard_Boolean aHasChanged = Standard_False; for (Standard_Integer i = 0; i <= nbseg; i ++) { u = uMin + (delta * i); gp_Pnt PU = AC.Value (u); - dist = PU.Distance (P3D); - if (dist < distmin) { distmin = dist; proj = PU; param = u; } + dist2 = PU.SquareDistance (P3D); + if (dist2 < distmin2) { distmin2 = dist2; proj = PU; param = u; aHasChanged = Standard_True; } } - + if (aHasChanged) + distmin = Sqrt (distmin2); #ifdef DEBUG cout<<"ShapeAnalysis_Geom:Project, param="< distmin="<