1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0024859: Replace SortTools by STL equivalents

Package SortTools and its derived classes are removed; STL sort algorithms are used instead.
Comparator objects are mostly reimplemented as local classes.
This commit is contained in:
abv
2015-06-30 10:47:45 +03:00
parent b7c077b9ee
commit e35db4162b
47 changed files with 150 additions and 1374 deletions

View File

@@ -25,7 +25,6 @@ uses
TColStd,
BRepAdaptor,
BRepTopAdaptor,
SortTools,
TopTools,
math,
gp,
@@ -54,8 +53,6 @@ is
class Range;
class CommonPrt;
class Root;
class Compare;
class CompareRange;
class EdgeEdge;
@@ -115,18 +112,9 @@ is
imported Array1OfRange;
class QuickSort instantiates
QuickSort from SortTools (Root from IntTools,
Array1OfRoots from IntTools,
Compare from IntTools);
class QuickSortRange instantiates
QuickSort from SortTools (Range from IntTools,
Array1OfRange from IntTools,
CompareRange from IntTools);
imported SequenceOfCommonPrts;
imported IndexedDataMapOfTransientAddress;
imported SequenceOfCommonPrts;
imported IndexedDataMapOfTransientAddress;
imported ListOfCurveRangeSample;

View File

@@ -19,8 +19,6 @@
#include <BRep_Tool.hxx>
#include <IntTools_Root.hxx>
#include <IntTools_Array1OfRoots.hxx>
#include <IntTools_Compare.hxx>
#include <IntTools_QuickSort.hxx>
#include <IntTools_Root.hxx>
#include <gce_MakeCirc.hxx>
@@ -32,9 +30,8 @@
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <gce_ErrorType.hxx>
#ifdef WNT
#pragma warning ( disable : 4101 )
#endif
#include <algorithm>
//=======================================================================
//function : IntTools::GetRadius
//purpose :
@@ -200,26 +197,33 @@
}
}
//=======================================================================
namespace {
// Auxiliary: comparator function for sorting roots
bool IntTools_RootComparator (const IntTools_Root& theLeft, const IntTools_Root& theRight)
{
return theLeft.Root() < theRight.Root();
}
};
//=======================================================================
//function : SortRoots
//purpose :
//=======================================================================
void IntTools::SortRoots(IntTools_SequenceOfRoots& mySequenceOfRoots,
const Standard_Real myEpsT)
const Standard_Real /*myEpsT*/)
{
Standard_Integer j, aNbRoots;
aNbRoots=mySequenceOfRoots.Length();
IntTools_Array1OfRoots anArray1OfRoots(1, aNbRoots);
IntTools_Compare aComparator(myEpsT);
IntTools_Array1OfRoots anArray1OfRoots(1, aNbRoots);
for (j=1; j<=aNbRoots; j++) {
anArray1OfRoots(j)=mySequenceOfRoots(j);
}
IntTools_QuickSort aQS;
aQS.Sort(anArray1OfRoots, aComparator);
std::sort (anArray1OfRoots.begin(), anArray1OfRoots.end(), IntTools_RootComparator);
mySequenceOfRoots.Clear();
for (j=1; j<=aNbRoots; j++) {

View File

@@ -1,60 +0,0 @@
-- Created on: 2000-05-22
-- Created by: Peter KURNEV
-- Copyright (c) 2000-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Compare from IntTools
---Purpose: Auxiliary class to provide a sorting Roots.
uses
Root from IntTools
is
Create
returns Compare from IntTools;
---Purpose:
--- Empty constructor
---
Create (aTol:Real from Standard)
returns Compare from IntTools;
---Purpose:
--- Initializes me by tolerance
---
IsLower (me; Left, Right: Root from IntTools)
---Purpose:
--- Returns True if <Left> is lower than <Right>.
---
returns Boolean from Standard;
IsGreater (me; Left, Right: Root from IntTools)
---Level: Public
---Purpose:
--- Returns True if <Left> is greater than <Right>.
---
returns Boolean from Standard;
IsEqual(me; Left, Right: Root from IntTools)
---Level: Public
---Purpose:
--- Returns True when <Right> and <Left> are equal.
---
returns Boolean from Standard ;
fields
myTol: Real from Standard;
end Compare;

View File

@@ -1,69 +0,0 @@
// Created on: 2000-05-22
// Created by: Peter KURNEV
// Copyright (c) 2000-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IntTools_Compare.ixx>
//=======================================================================
//function :IntTools_Compare::IntTools_Compare
//purpose :
//=======================================================================
IntTools_Compare::IntTools_Compare() :myTol(1.e-12) {}
//=======================================================================
//function :IntTools_Compare::IntTools_Compare
//purpose :
//=======================================================================
IntTools_Compare::IntTools_Compare(const Standard_Real aTol)
{
myTol=aTol;
}
//=======================================================================
//function :IsLower
//purpose :
//=======================================================================
Standard_Boolean IntTools_Compare::IsLower(const IntTools_Root& aLeft,
const IntTools_Root& aRight)const
{
return aLeft.Root()<aRight.Root();
}
//=======================================================================
//function :IsGreater
//purpose :
//=======================================================================
Standard_Boolean IntTools_Compare::IsGreater(const IntTools_Root& aLeft,
const IntTools_Root& aRight)const
{
return !IsLower(aLeft,aRight);
}
//=======================================================================
//function :IsEqual
//purpose :
//=======================================================================
Standard_Boolean IntTools_Compare::IsEqual(const IntTools_Root& aLeft,
const IntTools_Root& aRight)const
{
Standard_Real a, b;
a=aLeft.Root();
b=aRight.Root();
return fabs(a-b) < myTol;
}

View File

@@ -1,61 +0,0 @@
-- Created on: 2000-10-24
-- Created by: Peter KURNEV
-- Copyright (c) 2000-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class CompareRange from IntTools
---Purpose: Auxiliary class to provide a sorting Ranges,
-- taking into account a value of Left .
uses
Range from IntTools
--raises
is
Create
returns CompareRange from IntTools;
---Purpose:
--- Empty constructor
---
Create (aTol:Real from Standard)
returns CompareRange from IntTools;
---Purpose:
--- Initializes me by tolerance
---
IsLower (me; Left, Right: Range from IntTools)
---Purpose:
--- Returns True if <Left> is lower than <Right>.
---
returns Boolean from Standard;
IsGreater (me; Left, Right: Range from IntTools)
---Level: Public
---Purpose:
--- Returns True if <Left> is greater than <Right>.
---
returns Boolean from Standard;
IsEqual(me; Left, Right: Range from IntTools)
---Level: Public
---Purpose:
--- Returns True when <Right> and <Left> are equal.
---
returns Boolean from Standard ;
fields
myTol: Real from Standard;
end CompareRange;

View File

@@ -1,66 +0,0 @@
// Created on: 2000-10-24
// Created by: Peter KURNEV
// Copyright (c) 2000-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IntTools_CompareRange.ixx>
//=======================================================================
//function :IntTools_CompareRange::IntTools_CompareRange
//purpose :
//=======================================================================
IntTools_CompareRange::IntTools_CompareRange() :myTol(1.e-12) {}
//=======================================================================
//function :IntTools_CompareRange::IntTools_CompareRange
//purpose :
//=======================================================================
IntTools_CompareRange::IntTools_CompareRange(const Standard_Real aTol)
{
myTol=aTol;
}
//=======================================================================
//function :IsLower
//purpose :
//=======================================================================
Standard_Boolean IntTools_CompareRange::IsLower(const IntTools_Range& aLeft,
const IntTools_Range& aRight)const
{
return aLeft.First()<aRight.First();
}
//=======================================================================
//function :IsGreater
//purpose :
//=======================================================================
Standard_Boolean IntTools_CompareRange::IsGreater(const IntTools_Range& aLeft,
const IntTools_Range& aRight)const
{
return !IsLower(aLeft,aRight);
}
//=======================================================================
//function :IsEqual
//purpose :
//=======================================================================
Standard_Boolean IntTools_CompareRange::IsEqual(const IntTools_Range& aLeft,
const IntTools_Range& aRight)const
{
Standard_Real a, b;
a=aLeft.First();
b=aRight.First();
return fabs(a-b) < myTol;
}

View File

@@ -23,8 +23,6 @@
#include <IntTools_Range.hxx>
#include <IntTools_Tools.hxx>
#include <IntTools_Array1OfRange.hxx>
#include <IntTools_QuickSortRange.hxx>
#include <IntTools_CompareRange.hxx>
#include <IntTools_CommonPrt.hxx>
#include <IntTools_Root.hxx>
#include <IntTools_BeanFaceIntersector.hxx>
@@ -64,9 +62,7 @@
#include <GeomAdaptor_HSurface.hxx>
#include <IntCurveSurface_IntersectionPoint.hxx>
#ifdef WNT
#pragma warning ( disable : 4101 )
#endif
#include <algorithm>
static
Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& ,
@@ -604,6 +600,17 @@ void IntTools_EdgeFace::PrepareArgsFuncArrays(const Standard_Real ta,
AddDerivativePoints(anArgs, aFunc);
}
//=======================================================================
namespace {
// Auxiliary: comparator function for sorting ranges
bool IntTools_RangeComparator (const IntTools_Range& theLeft, const IntTools_Range& theRight)
{
return theLeft.First() < theRight.First();
}
}
//=======================================================================
//function : AddDerivativePoints
//purpose :
@@ -719,9 +726,7 @@ void IntTools_EdgeFace::AddDerivativePoints
anArray1OfRange(n+i).SetLast (aFSeq(i));
}
IntTools_QuickSortRange aQuickSortRange;
IntTools_CompareRange aComparator;
aQuickSortRange.Sort (anArray1OfRange, aComparator);
std::sort (anArray1OfRange.begin(), anArray1OfRange.end(), IntTools_RangeComparator);
// filling the output arrays
myArgsArray.Resize(k);