From e57b83896c3ad5a322a589c0770e4fd589cc988a Mon Sep 17 00:00:00 2001 From: asuraven Date: Fri, 27 Aug 2021 13:06:02 +0300 Subject: [PATCH] 0032539: using std::vector --- .../BRepExtrema_DistShapeShape.cxx | 143 +++++++++--------- .../BRepExtrema_DistShapeShape.hxx | 14 +- src/BRepExtrema/BRepExtrema_DistanceSS.cxx | 130 ++++++++-------- src/BRepExtrema/BRepExtrema_DistanceSS.hxx | 10 +- src/BRepTest/BRepTest_ExtremaCommands.cxx | 6 +- 5 files changed, 154 insertions(+), 149 deletions(-) diff --git a/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx b/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx index 3d30c83c27..cf032def3e 100644 --- a/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx +++ b/src/BRepExtrema/BRepExtrema_DistShapeShape.cxx @@ -113,8 +113,8 @@ struct VertexTask { VertexTask(Standard_Integer theFirtsIndex, Standard_Integer theLastIndex, - BRepExtrema_SeqOfSolution* theSolutionsShape1, - BRepExtrema_SeqOfSolution* theSolutionsShape2, + std::vector* theSolutionsShape1, + std::vector* theSolutionsShape2, const TopTools_IndexedMapOfShape* theMap1, const TopTools_IndexedMapOfShape* theMap2, const std::vector* theLBox1, @@ -176,8 +176,8 @@ struct VertexTask Standard_Integer myFirtsIndex; Standard_Integer myLastIndex; - BRepExtrema_SeqOfSolution* mySolutionsShape1; - BRepExtrema_SeqOfSolution* mySolutionsShape2; + std::vector* mySolutionsShape1; + std::vector* mySolutionsShape2; const TopTools_IndexedMapOfShape* myMap1; const TopTools_IndexedMapOfShape* myMap2; const std::vector* myLBox1; @@ -237,24 +237,24 @@ struct VertexFunctor Standard_Mutex::Sentry aLock(theTask.myMutex.get()); if (aDistTool.DistValue() < *theTask.myDistRef - theTask.myEps) { - theTask.mySolutionsShape1->Clear(); - theTask.mySolutionsShape2->Clear(); + theTask.mySolutionsShape1->clear(); + theTask.mySolutionsShape2->clear(); - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - theTask.mySolutionsShape1->Append(aSeq1); - theTask.mySolutionsShape2->Append(aSeq2); + theTask.mySolutionsShape1->insert(theTask.mySolutionsShape1->end(), aSeq1.begin(), aSeq1.end()); + theTask.mySolutionsShape2->insert(theTask.mySolutionsShape2->end(), aSeq2.begin(), aSeq2.end()); *theTask.myDistRef = aDistTool.DistValue(); } else if (fabs(aDistTool.DistValue() - *theTask.myDistRef) < theTask.myEps) { - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - theTask.mySolutionsShape1->Append(aSeq1); - theTask.mySolutionsShape2->Append(aSeq2); + theTask.mySolutionsShape1->insert(theTask.mySolutionsShape1->end(), aSeq1.begin(), aSeq1.end()); + theTask.mySolutionsShape2->insert(theTask.mySolutionsShape2->end(), aSeq2.begin(), aSeq2.end()); if (*theTask.myDistRef > aDistTool.DistValue()) { @@ -308,24 +308,24 @@ void BRepExtrema_DistShapeShape::DistanceVertVert(const TopTools_IndexedMapOfSha { if (aDistTool.DistValue() < myDistRef - myEps) { - mySolutionsShape1.Clear(); - mySolutionsShape2.Clear(); + mySolutionsShape1.clear(); + mySolutionsShape2.clear(); - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - mySolutionsShape1.Append(aSeq1); - mySolutionsShape2.Append(aSeq2); + mySolutionsShape1.insert(mySolutionsShape1.end(), aSeq1.begin(), aSeq1.end()); + mySolutionsShape2.insert(mySolutionsShape2.end(), aSeq2.begin(), aSeq2.end()); myDistRef = aDistTool.DistValue(); } else if (fabs(aDistTool.DistValue() - myDistRef) < myEps) { - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - mySolutionsShape1.Append(aSeq1); - mySolutionsShape2.Append(aSeq2); + mySolutionsShape1.insert(mySolutionsShape1.end(), aSeq1.begin(), aSeq1.end()); + mySolutionsShape2.insert(mySolutionsShape2.end(), aSeq2.begin(), aSeq2.end()); if (myDistRef > aDistTool.DistValue()) { @@ -378,8 +378,8 @@ void BRepExtrema_DistShapeShape::DistanceVertVert(const TopTools_IndexedMapOfSha struct DistanceTask { DistanceTask(const NCollection_Array1* theArray, - BRepExtrema_SeqOfSolution* theSolutionsShape1, - BRepExtrema_SeqOfSolution* theSolutionsShape2, + std::vector* theSolutionsShape1, + std::vector* theSolutionsShape2, const TopTools_IndexedMapOfShape* theMap1, const TopTools_IndexedMapOfShape* theMap2, const std::vector* theLBox1, @@ -440,8 +440,8 @@ struct DistanceTask return *this; } - BRepExtrema_SeqOfSolution* mySolutionsShape1; - BRepExtrema_SeqOfSolution* mySolutionsShape2; + std::vector* mySolutionsShape1; + std::vector* mySolutionsShape2; const NCollection_Array1* myArray; const TopTools_IndexedMapOfShape* myMap1; const TopTools_IndexedMapOfShape* myMap2; @@ -499,24 +499,24 @@ struct DistanceFunctor Standard_Mutex::Sentry aLock(theTask.myMutex.get()); if (aDistTool.DistValue() < *theTask.myDistRef - anEps) { - theTask.mySolutionsShape1->Clear(); - theTask.mySolutionsShape2->Clear(); + theTask.mySolutionsShape1->clear(); + theTask.mySolutionsShape2->clear(); - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - theTask.mySolutionsShape1->Append(aSeq1); - theTask.mySolutionsShape2->Append(aSeq2); + theTask.mySolutionsShape1->insert(theTask.mySolutionsShape1->end(), aSeq1.begin(), aSeq1.end()); + theTask.mySolutionsShape2->insert(theTask.mySolutionsShape2->end(), aSeq2.begin(), aSeq2.end()); *theTask.myDistRef = aDistTool.DistValue(); } else if (fabs(aDistTool.DistValue() - *theTask.myDistRef) < anEps) { - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - theTask.mySolutionsShape1->Append(aSeq1); - theTask.mySolutionsShape2->Append(aSeq2); + theTask.mySolutionsShape1->insert(theTask.mySolutionsShape1->end(), aSeq1.begin(), aSeq1.end()); + theTask.mySolutionsShape2->insert(theTask.mySolutionsShape2->end(), aSeq2.begin(), aSeq2.end()); if (*theTask.myDistRef > aDistTool.DistValue()) { @@ -601,24 +601,24 @@ void BRepExtrema_DistShapeShape::DistanceMapMap (const TopTools_IndexedMapOfShap { if (aDistTool.DistValue() < myDistRef - myEps) { - mySolutionsShape1.Clear(); - mySolutionsShape2.Clear(); + mySolutionsShape1.clear(); + mySolutionsShape2.clear(); - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - mySolutionsShape1.Append(aSeq1); - mySolutionsShape2.Append(aSeq2); + mySolutionsShape1.insert(mySolutionsShape1.end(), aSeq1.begin(), aSeq1.end()); + mySolutionsShape2.insert(mySolutionsShape2.end(), aSeq2.begin(), aSeq2.end()); myDistRef = aDistTool.DistValue(); } else if (fabs(aDistTool.DistValue() - myDistRef) < myEps) { - BRepExtrema_SeqOfSolution aSeq1 = aDistTool.Seq1Value(); - BRepExtrema_SeqOfSolution aSeq2 = aDistTool.Seq2Value(); + const std::vector& aSeq1 = aDistTool.Seq1Value(); + const std::vector& aSeq2 = aDistTool.Seq2Value(); - mySolutionsShape1.Append(aSeq1); - mySolutionsShape2.Append(aSeq2); + mySolutionsShape1.insert(mySolutionsShape1.end(), aSeq1.begin(), aSeq1.end()); + mySolutionsShape2.insert(mySolutionsShape2.end(), aSeq2.begin(), aSeq2.end()); if (myDistRef > aDistTool.DistValue()) { @@ -807,8 +807,8 @@ void BRepExtrema_DistShapeShape::SolidTreatmentOne(const TopoDS_Shape& theShape, myDistRef = 0.; myIsDone = Standard_True; BRepExtrema_SolutionElem Sol(0, aPnt, BRepExtrema_IsVertex, aVertex); - mySolutionsShape1.Append(Sol); - mySolutionsShape2.Append(Sol); + mySolutionsShape1.push_back(Sol); + mySolutionsShape2.push_back(Sol); break; } } @@ -855,7 +855,7 @@ struct TreatmentTask return *this; } - BRepExtrema_SeqOfSolution mySolutionsShape; + std::vector mySolutionsShape; const TopoDS_Shape* myShape; const NCollection_Array1* myArray; Message_ProgressRange myRange; @@ -896,7 +896,7 @@ struct TreatmentFunctor Standard_Atomic_CompareAndSwap((int*) *theTask.myInnerSol, Standard_False, Standard_True); Standard_Atomic_CompareAndSwap((int*) *theTask.myIsDone, Standard_False, Standard_True); BRepExtrema_SolutionElem aSolElem(0, aPnt, BRepExtrema_IsVertex, aVertex); - theTask.mySolutionsShape.Append(aSolElem); + theTask.mySolutionsShape.push_back(aSolElem); break; } } @@ -961,8 +961,8 @@ void BRepExtrema_DistShapeShape::SolidTreatmentMulty(const TopoDS_Shape& theShap myDistRef = 0.; if (aTaskArray.Size()) { - mySolutionsShape1.Append(aTaskArray[0].mySolutionsShape); - mySolutionsShape2.Append(aTaskArray[0].mySolutionsShape); + mySolutionsShape1.push_back(aTaskArray[0].mySolutionsShape[0]); + mySolutionsShape2.push_back(aTaskArray[0].mySolutionsShape[0]); } } @@ -1001,8 +1001,8 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform(const Message_ProgressRange myIsDone = Standard_False; myInnerSol = Standard_False; myIsBreak = Standard_False; - mySolutionsShape1.Clear(); - mySolutionsShape2.Clear(); + mySolutionsShape1.clear(); + mySolutionsShape2.clear(); if ( myShape1.IsNull() || myShape2.IsNull() ) return Standard_False; @@ -1079,16 +1079,19 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform(const Message_ProgressRange DistanceMapMap (myMapF1, myMapF2, myBF1, myBF2, aRootScope.Next()); } - // Modified by Sergey KHROMOV - Tue Mar 6 11:55:03 2001 Begin - Standard_Integer i = 1; - for (; i <= mySolutionsShape1.Length(); i++) - if (mySolutionsShape1.Value(i).Dist() > myDistRef + myEps) + for (std::vector::iterator it = mySolutionsShape1.begin(); + it != mySolutionsShape1.end(); ) + { + if ((*it).Dist() > myDistRef + myEps) + { + it = mySolutionsShape1.erase(it); + } + else { - mySolutionsShape1.Remove(i); - mySolutionsShape2.Remove(i); + ++it; } - // Modified by Sergey KHROMOV - Tue Mar 6 11:55:04 2001 End - myIsDone = ( mySolutionsShape1.Length() > 0 ); + } + myIsDone = ( mySolutionsShape1.size() > 0 ); } } catch (StdFail_NotDone) @@ -1122,7 +1125,7 @@ TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const Standard_Integer if (!myIsDone) throw StdFail_NotDone("BRepExtrema_DistShapeShape::SupportOnShape1: There's no solution "); - const BRepExtrema_SolutionElem &sol = mySolutionsShape1.Value(N); + const BRepExtrema_SolutionElem &sol = mySolutionsShape1[N]; switch (sol.SupportKind()) { case BRepExtrema_IsVertex : return sol.Vertex(); @@ -1142,7 +1145,7 @@ TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape2(const Standard_Integer if (!myIsDone) throw StdFail_NotDone("BRepExtrema_DistShapeShape::SupportOnShape2: There's no solution "); - const BRepExtrema_SolutionElem &sol = mySolutionsShape2.Value(N); + const BRepExtrema_SolutionElem &sol = mySolutionsShape2[N]; switch (sol.SupportKind()) { case BRepExtrema_IsVertex : return sol.Vertex(); @@ -1162,7 +1165,7 @@ void BRepExtrema_DistShapeShape::ParOnEdgeS1(const Standard_Integer N, Standard_ if (!myIsDone) throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnEdgeS1: There's no solution"); - const BRepExtrema_SolutionElem &sol = mySolutionsShape1.Value(N); + const BRepExtrema_SolutionElem &sol = mySolutionsShape1[N]; if (sol.SupportKind() != BRepExtrema_IsOnEdge) throw BRepExtrema_UnCompatibleShape("BRepExtrema_DistShapeShape::ParOnEdgeS1: ParOnEdgeS1 is impossible without EDGE"); @@ -1179,7 +1182,7 @@ void BRepExtrema_DistShapeShape::ParOnEdgeS2(const Standard_Integer N, Standard if (!myIsDone) throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnEdgeS2: There's no solution"); - const BRepExtrema_SolutionElem &sol = mySolutionsShape2.Value(N); + const BRepExtrema_SolutionElem &sol = mySolutionsShape2[N]; if (sol.SupportKind() != BRepExtrema_IsOnEdge) throw BRepExtrema_UnCompatibleShape("BRepExtrema_DistShapeShape::ParOnEdgeS2: ParOnEdgeS2 is impossible without EDGE"); @@ -1196,7 +1199,7 @@ void BRepExtrema_DistShapeShape::ParOnFaceS1(const Standard_Integer N, Standard if (!myIsDone) throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnFaceS1: There's no solution"); - const BRepExtrema_SolutionElem &sol = mySolutionsShape1.Value(N); + const BRepExtrema_SolutionElem &sol = mySolutionsShape1[N]; if (sol.SupportKind() != BRepExtrema_IsInFace) throw BRepExtrema_UnCompatibleShape("BRepExtrema_DistShapeShape::ParOnFaceS1: ParOnFaceS1 is impossible without FACE"); @@ -1213,7 +1216,7 @@ void BRepExtrema_DistShapeShape::ParOnFaceS2(const Standard_Integer N, Standard if (!myIsDone) throw StdFail_NotDone("BRepExtrema_DistShapeShape::ParOnFaceS2: There's no solution"); - const BRepExtrema_SolutionElem &sol = mySolutionsShape2.Value(N); + const BRepExtrema_SolutionElem &sol = mySolutionsShape2[N]; if (sol.SupportKind() != BRepExtrema_IsInFace) throw BRepExtrema_UnCompatibleShape("BRepExtrema_DistShapeShape::ParOnFaceS2:ParOnFaceS2 is impossible without FACE "); diff --git a/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx b/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx index 1c3ef06bb9..6ea8f39f5b 100644 --- a/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx +++ b/src/BRepExtrema/BRepExtrema_DistShapeShape.hxx @@ -82,7 +82,7 @@ class BRepExtrema_DistShapeShape //! Returns the number of solutions satisfying the minimum distance.
Standard_Integer NbSolution() const { - return mySolutionsShape1.Length(); + return (Standard_Integer) mySolutionsShape1.size(); } //! Returns the value of the minimum distance.
Standard_EXPORT Standard_Real Value() const; @@ -95,12 +95,12 @@ class BRepExtrema_DistShapeShape //! Returns the Point corresponding to the th solution on the first Shape
const gp_Pnt & PointOnShape1(const Standard_Integer N) const { - return mySolutionsShape1.Value(N).Point(); + return mySolutionsShape1[N].Point(); } //! Returns the Point corresponding to the th solution on the second Shape
const gp_Pnt & PointOnShape2(const Standard_Integer N) const { - return mySolutionsShape2.Value(N).Point(); + return mySolutionsShape2[N].Point(); } //! gives the type of the support where the Nth solution on the first shape is situated:
//! IsVertex => the Nth solution on the first shape is a Vertex
@@ -109,7 +109,7 @@ class BRepExtrema_DistShapeShape //! the corresponding support is obtained by the method SupportOnShape1
BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const { - return mySolutionsShape1.Value(N).SupportKind(); + return mySolutionsShape1[N].SupportKind(); } //! gives the type of the support where the Nth solution on the second shape is situated:
//! IsVertex => the Nth solution on the second shape is a Vertex
@@ -118,7 +118,7 @@ class BRepExtrema_DistShapeShape //! the corresponding support is obtained by the method SupportOnShape2
BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const { - return mySolutionsShape2.Value(N).SupportKind(); + return mySolutionsShape2[N].SupportKind(); } //! gives the support where the Nth solution on the first shape is situated.
//! This support can be a Vertex, an Edge or a Face.
@@ -185,8 +185,8 @@ private: Standard_Real myDistRef; Standard_Boolean myIsDone; - BRepExtrema_SeqOfSolution mySolutionsShape1; - BRepExtrema_SeqOfSolution mySolutionsShape2; + std::vector mySolutionsShape1; + std::vector mySolutionsShape2; Standard_Boolean myInnerSol; Standard_Real myEps; TopoDS_Shape myShape1; diff --git a/src/BRepExtrema/BRepExtrema_DistanceSS.cxx b/src/BRepExtrema/BRepExtrema_DistanceSS.cxx index 61773dd806..01808b3f23 100644 --- a/src/BRepExtrema/BRepExtrema_DistanceSS.cxx +++ b/src/BRepExtrema/BRepExtrema_DistanceSS.cxx @@ -62,12 +62,12 @@ //------------------------------------------------------------------------------ // function: TRI_SOLUTION //------------------------------------------------------------------------------ -static Standard_Boolean TRI_SOLUTION (const BRepExtrema_SeqOfSolution& SeqSol, const gp_Pnt& Pt) +static Standard_Boolean TRI_SOLUTION (std::vector& SeqSol, const gp_Pnt& Pt) { - const Standard_Integer Nbsol = SeqSol.Length(); + const Standard_Integer Nbsol = SeqSol.size(); for (Standard_Integer i = 1; i <= Nbsol; i++) { - const Standard_Real dst = SeqSol.Value(i).Point().Distance(Pt); + const Standard_Real dst = SeqSol[i].Point().Distance(Pt); if (dst <= Precision::Confusion()) return Standard_False; } return Standard_True; @@ -76,21 +76,21 @@ static Standard_Boolean TRI_SOLUTION (const BRepExtrema_SeqOfSolution& SeqSol, c //------------------------------------------------------------------------------ // function: MIN_SOLUTION //------------------------------------------------------------------------------ -static void MIN_SOLUTION (const BRepExtrema_SeqOfSolution& SeqSol1, - const BRepExtrema_SeqOfSolution& SeqSol2, +static void MIN_SOLUTION (const std::vector& SeqSol1, + const std::vector& SeqSol2, const Standard_Real DstRef, const Standard_Real Eps, - BRepExtrema_SeqOfSolution& seqSol1, - BRepExtrema_SeqOfSolution& seqSol2) + std::vector& seqSol1, + std::vector& seqSol2) { - const Standard_Integer nbSol = SeqSol1.Length(); + const Standard_Integer nbSol = SeqSol1.size(); for (Standard_Integer i = 1; i <= nbSol; i++) { - const Standard_Real dst1 = SeqSol1.Value(i).Dist(); + const Standard_Real dst1 = SeqSol1[i].Dist(); if (fabs(dst1 - DstRef) < Eps) { - seqSol1.Append(SeqSol1.Value(i)); - seqSol2.Append(SeqSol2.Value(i)); + seqSol1.push_back(SeqSol1[i]); + seqSol2.push_back(SeqSol2[i]); } } } @@ -392,8 +392,8 @@ static void TRIM_INFINIT_FACE(const TopoDS_Shape& S1, const TopoDS_Shape& S2, // static function: PERFORM_C0 //------------------------------------------------------------------------------ static void PERFORM_C0(const TopoDS_Edge &S1, const TopoDS_Edge &S2, - BRepExtrema_SeqOfSolution& SeqSol1, - BRepExtrema_SeqOfSolution& SeqSol2, + std::vector& SeqSol1, + std::vector& SeqSol2, const Standard_Real DstRef, Standard_Real& mDstRef, const Standard_Real Eps) @@ -479,8 +479,8 @@ static void PERFORM_C0(const TopoDS_Edge &S1, const TopoDS_Edge &S2, mDstRef=Dstmin; const BRepExtrema_SolutionElem Sol1(Dstmin,aPnt,BRepExtrema_IsOnEdge,E,aParameter); const BRepExtrema_SolutionElem Sol2(Dstmin,Pt,BRepExtrema_IsOnEdge,Eother,t); - SeqSol1.Append(iE == 0 ? Sol1 : Sol2); - SeqSol2.Append(iE == 0 ? Sol2 : Sol1); + SeqSol1.push_back(iE == 0 ? Sol1 : Sol2); + SeqSol2.push_back(iE == 0 ? Sol2 : Sol1); } } } @@ -497,8 +497,8 @@ static void PERFORM_C0(const TopoDS_Edge &S1, const TopoDS_Edge &S2, mDstRef=Dst; const BRepExtrema_SolutionElem Sol1(Dst,aPnt,BRepExtrema_IsOnEdge,E,aParameter); const BRepExtrema_SolutionElem Sol2(Dst,aPntOther,BRepExtrema_IsOnEdge,Eother,aParameterOther); - SeqSol1.Append(iE == 0 ? Sol1 : Sol2); - SeqSol2.Append(iE == 0 ? Sol2 : Sol1); + SeqSol1.push_back(iE == 0 ? Sol1 : Sol2); + SeqSol2.push_back(iE == 0 ? Sol2 : Sol1); } } } @@ -511,8 +511,8 @@ static void PERFORM_C0(const TopoDS_Edge &S1, const TopoDS_Edge &S2, void BRepExtrema_DistanceSS::Perform(const TopoDS_Shape& S1, const TopoDS_Shape& S2, const Bnd_Box& B1, const Bnd_Box& B2) { - SeqSolShape1.Clear(); - SeqSolShape2.Clear(); + SeqSolShape1.clear(); + SeqSolShape2.clear(); myModif=Standard_False; switch (S1.ShapeType()) @@ -641,8 +641,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Vertex& S1, const TopoDS_Verte myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dst,P1,BRepExtrema_IsVertex,S1); const BRepExtrema_SolutionElem Sol2(Dst,P2,BRepExtrema_IsVertex,S2); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } @@ -695,8 +695,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Vertex& S1, const TopoDS_Edge& myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,P1,BRepExtrema_IsVertex,S1); const BRepExtrema_SolutionElem Sol2(Dstmin,Pt,BRepExtrema_IsOnEdge,S2,t); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -753,8 +753,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1,const TopoDS_Vertex& myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,Pt,BRepExtrema_IsOnEdge,S1,t); const BRepExtrema_SolutionElem Sol2(Dstmin,P2,BRepExtrema_IsVertex,S2); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -811,8 +811,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Vertex& S1, const TopoDS_Face& myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,P1,BRepExtrema_IsVertex,S1); const BRepExtrema_SolutionElem Sol2(Dstmin,Pt,BRepExtrema_IsInFace,S2,U,V); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -867,8 +867,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Vertex& myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,Pt,BRepExtrema_IsInFace,S1,U,V); const BRepExtrema_SolutionElem Sol2(Dstmin,P2,BRepExtrema_IsVertex,S2); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -932,8 +932,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Edge& S myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,Pt1,BRepExtrema_IsOnEdge,S1,t1); const BRepExtrema_SolutionElem Sol2(Dstmin,Pt2,BRepExtrema_IsOnEdge,S2,t2); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -941,21 +941,21 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Edge& S } } - BRepExtrema_SeqOfSolution SeqSolution1; - BRepExtrema_SeqOfSolution SeqSolution2; + std::vector SeqSolution1; + std::vector SeqSolution2; PERFORM_C0(S1, S2, SeqSolution1, SeqSolution2, DstRef, myDstRef, myEps); - BRepExtrema_SeqOfSolution seqSol1; - BRepExtrema_SeqOfSolution seqSol2; + std::vector seqSol1; + std::vector seqSol2; - if (SeqSolution1.Length() > 0 && SeqSolution2.Length() > 0) + if (SeqSolution1.size() > 0 && SeqSolution2.size() > 0) MIN_SOLUTION(SeqSolution1, SeqSolution2, myDstRef, myEps, seqSol1, seqSol2); - if (!seqSol1.IsEmpty() && !seqSol2.IsEmpty()) + if (!seqSol1.empty() && !seqSol2.empty()) { - SeqSolShape1.Append(seqSol1); - SeqSolShape2.Append(seqSol2); + SeqSolShape1.insert(SeqSolShape1.end(), seqSol1.begin(), seqSol1.end()); + SeqSolShape2.insert(SeqSolShape2.end(), seqSol2.begin(), seqSol2.end()); myModif = Standard_True; } } @@ -1019,8 +1019,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Face& S myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,Pt1,BRepExtrema_IsOnEdge,S1,t1); const BRepExtrema_SolutionElem Sol2(Dstmin,Pt2,BRepExtrema_IsInFace,S2,U,V); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -1033,8 +1033,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Face& S Handle(Geom_Curve) pCurv = BRep_Tool::Curve(S1, aFirst, aLast); if (pCurv->Continuity() == GeomAbs_C0) { - BRepExtrema_SeqOfSolution SeqSolution1; - BRepExtrema_SeqOfSolution SeqSolution2; + std::vector SeqSolution1; + std::vector SeqSolution2; GeomAdaptor_Curve aAdaptorCurve(pCurv, aFirst, aLast); const Standard_Integer nbIntervals = aAdaptorCurve.NbIntervals(GeomAbs_C1); @@ -1085,8 +1085,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Face& S myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,aPnt,BRepExtrema_IsOnEdge,S1,aParameter); const BRepExtrema_SolutionElem Sol2(Dstmin,ExtPF.Point(ii),BRepExtrema_IsInFace,S2,U,V); - SeqSolution1.Append(Sol1); - SeqSolution2.Append(Sol2); + SeqSolution1.push_back(Sol1); + SeqSolution2.push_back(Sol2); } } } @@ -1094,15 +1094,15 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Edge& S1, const TopoDS_Face& S } } - BRepExtrema_SeqOfSolution seqSol1; - BRepExtrema_SeqOfSolution seqSol2; - if (SeqSolution1.Length() > 0 && SeqSolution2.Length() > 0) + std::vector seqSol1; + std::vector seqSol2; + if (SeqSolution1.size() > 0 && SeqSolution2.size() > 0) MIN_SOLUTION(SeqSolution1, SeqSolution2, myDstRef, myEps, seqSol1, seqSol2); - if (!seqSol1.IsEmpty() && !seqSol2.IsEmpty()) + if (!seqSol1.empty() && !seqSol2.empty()) { - SeqSolShape1.Append(seqSol1); - SeqSolShape2.Append(seqSol2); + SeqSolShape1.insert(SeqSolShape1.end(), seqSol1.begin(), seqSol1.end()); + SeqSolShape2.insert(SeqSolShape2.end(), seqSol2.begin(), seqSol2.end()); } } } @@ -1164,8 +1164,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Edge& S myModif=Standard_True; const BRepExtrema_SolutionElem Sol2(Dstmin,Pt1,BRepExtrema_IsOnEdge,S2,t1); const BRepExtrema_SolutionElem Sol1(Dstmin,Pt2,BRepExtrema_IsInFace,S1,U,V); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } @@ -1178,8 +1178,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Edge& S Handle(Geom_Curve) pCurv = BRep_Tool::Curve(S2, aFirst, aLast); if (pCurv->Continuity() == GeomAbs_C0) { - BRepExtrema_SeqOfSolution SeqSolution1; - BRepExtrema_SeqOfSolution SeqSolution2; + std::vector SeqSolution1; + std::vector SeqSolution2; GeomAdaptor_Curve aAdaptorCurve(pCurv, aFirst, aLast); const Standard_Integer nbIntervals = aAdaptorCurve.NbIntervals(GeomAbs_C1); @@ -1230,8 +1230,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Edge& S myModif=Standard_True; const BRepExtrema_SolutionElem Sol2(Dstmin,aPnt,BRepExtrema_IsOnEdge,S2,aParameter); const BRepExtrema_SolutionElem Sol1(Dstmin,ExtPF.Point(ii),BRepExtrema_IsInFace,S1,U,V); - SeqSolution1.Append(Sol1); - SeqSolution2.Append(Sol2); + SeqSolution1.push_back(Sol1); + SeqSolution2.push_back(Sol2); } } } @@ -1239,15 +1239,15 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Edge& S } } - BRepExtrema_SeqOfSolution seqSol1; - BRepExtrema_SeqOfSolution seqSol2; - if (SeqSolution1.Length() > 0 && SeqSolution2.Length() > 0) + std::vector seqSol1; + std::vector seqSol2; + if (SeqSolution1.size() > 0 && SeqSolution2.size() > 0) MIN_SOLUTION(SeqSolution1, SeqSolution2, myDstRef, myEps, seqSol1, seqSol2); - if (!seqSol1.IsEmpty() && !seqSol2.IsEmpty()) + if (!seqSol1.empty() && !seqSol2.empty()) { - SeqSolShape1.Append(seqSol1); - SeqSolShape2.Append(seqSol2); + SeqSolShape1.insert(SeqSolShape1.end(), seqSol1.begin(), seqSol1.end()); + SeqSolShape2.insert(SeqSolShape2.end(), seqSol2.begin(), seqSol2.end()); } } } @@ -1309,8 +1309,8 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Face& S1, const TopoDS_Face& S myModif=Standard_True; const BRepExtrema_SolutionElem Sol1(Dstmin,Pt1,BRepExtrema_IsInFace,S1,U1,V1); const BRepExtrema_SolutionElem Sol2(Dstmin,Pt2,BRepExtrema_IsInFace,S2,U2,V2); - SeqSolShape1.Append(Sol1); - SeqSolShape2.Append(Sol2); + SeqSolShape1.push_back(Sol1); + SeqSolShape2.push_back(Sol2); } } } diff --git a/src/BRepExtrema/BRepExtrema_DistanceSS.hxx b/src/BRepExtrema/BRepExtrema_DistanceSS.hxx index 1f7e6fc9e4..2b96597f92 100644 --- a/src/BRepExtrema/BRepExtrema_DistanceSS.hxx +++ b/src/BRepExtrema/BRepExtrema_DistanceSS.hxx @@ -20,6 +20,8 @@ #include #include +#include + class TopoDS_Shape; class Bnd_Box; class TopoDS_Vertex; @@ -69,12 +71,12 @@ class BRepExtrema_DistanceSS return myDstRef; } //! returns the list of solutions on the first shape
- const BRepExtrema_SeqOfSolution& Seq1Value() const + const std::vector& Seq1Value() const { return SeqSolShape1; } //! returns the list of solutions on the second shape
- const BRepExtrema_SeqOfSolution& Seq2Value() const + const std::vector& Seq2Value() const { return SeqSolShape2; } @@ -124,8 +126,8 @@ class BRepExtrema_DistanceSS //! computes the minimum distance between two faces
void Perform(const TopoDS_Face& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2); - BRepExtrema_SeqOfSolution SeqSolShape1; - BRepExtrema_SeqOfSolution SeqSolShape2; + std::vector SeqSolShape1; + std::vector SeqSolShape2; Standard_Real myDstRef; Standard_Boolean myModif; Standard_Real myEps; diff --git a/src/BRepTest/BRepTest_ExtremaCommands.cxx b/src/BRepTest/BRepTest_ExtremaCommands.cxx index 9673bf0255..7309769fab 100644 --- a/src/BRepTest/BRepTest_ExtremaCommands.cxx +++ b/src/BRepTest/BRepTest_ExtremaCommands.cxx @@ -117,7 +117,7 @@ static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const Draw::Set(tempd,dst.Value()); di << named << " "; - for (Standard_Integer i1 = 1; i1<= dst.NbSolution(); i1++) + for (Standard_Integer i1 = 0; i1 < dst.NbSolution(); i1++) { gp_Pnt P1,P2; P1 = (dst.PointOnShape1(i1)); @@ -126,7 +126,7 @@ static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const { TopoDS_Vertex V =BRepLib_MakeVertex(P1); char namev[100]; - if (i1==1) + if (i1==0) Sprintf(namev, "%s" ,ns0); else Sprintf(namev, "%s%d" ,ns0,i1); @@ -138,7 +138,7 @@ static Standard_Integer distmini(Draw_Interpretor& di, Standard_Integer n, const { char name[100]; TopoDS_Edge E = BRepLib_MakeEdge (P1, P2); - if (i1==1) + if (i1==0) { Sprintf(name,"%s",ns0); } -- 2.39.5