mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0027915: Foundation Classes - remove the class NCollection_QuickSort
Class NCollection_QuickSort was removed. Direction of dimension lines was corrected. Updated porting notes. minor corrections in AIS
This commit is contained in:
parent
4e283d3379
commit
3c1624950a
@ -1081,3 +1081,10 @@ The following obsolete features have been removed:
|
|||||||
@subsection upgrade_occt710_correction_of_TObj_Model Correction in TObj_Model class
|
@subsection upgrade_occt710_correction_of_TObj_Model Correction in TObj_Model class
|
||||||
|
|
||||||
Methods *TObj_Model::SaveAs* and *TObj_Model::Load* receive *TCollection_ExtendedString* filename arguments instead of char*. This shows that the filename may be not-ASCII explicitly. Also it makes OCAF API related to this functionality more conform.
|
Methods *TObj_Model::SaveAs* and *TObj_Model::Load* receive *TCollection_ExtendedString* filename arguments instead of char*. This shows that the filename may be not-ASCII explicitly. Also it makes OCAF API related to this functionality more conform.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection upgrade_occt710_sorttools Removal of NCollection_QuickSort class
|
||||||
|
|
||||||
|
Class *NCollection_QuickSort* has been removed.
|
||||||
|
The code that used the tools provided by that class should be corrected manually.
|
||||||
|
The recommended approach is to use sorting algorithms provided by STL.
|
||||||
|
@ -435,33 +435,45 @@ Standard_Boolean AIS_LengthDimension::InitEdgeFaceLength (const TopoDS_Edge& the
|
|||||||
const TopoDS_Face& theFace,
|
const TopoDS_Face& theFace,
|
||||||
gp_Dir& theEdgeDir)
|
gp_Dir& theEdgeDir)
|
||||||
{
|
{
|
||||||
// Compute edge direction
|
theEdgeDir = gp::DX();
|
||||||
BRepAdaptor_Curve aCurveAdaptor (theEdge);
|
|
||||||
Handle(Geom_Curve) aCurve = Handle(Geom_Curve)::DownCast (aCurveAdaptor.Curve().Curve()->Transformed (aCurveAdaptor.Trsf()));
|
|
||||||
if (aCurve.IsNull())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
Standard_Real aFirst = aCurveAdaptor.FirstParameter();
|
|
||||||
Standard_Real aLast = aCurveAdaptor.LastParameter();
|
|
||||||
gp_Pnt aFirstPoint = !Precision::IsInfinite (aFirst) ? aCurve->Value (aFirst) : gp::Origin();
|
|
||||||
gp_Pnt aSecondPoint = !Precision::IsInfinite (aLast) ? aCurve->Value (aLast) : gp::Origin();
|
|
||||||
gce_MakeDir aMakeDir (aFirstPoint, aSecondPoint);
|
|
||||||
if (!aMakeDir.IsDone())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
theEdgeDir = aMakeDir.Value();
|
|
||||||
|
|
||||||
// Find attachment points
|
// Find attachment points (closest distance between the edge and the face)
|
||||||
BRepExtrema_DistShapeShape aDistAdaptor (theEdge, theFace, Extrema_ExtFlag_MIN);
|
BRepExtrema_DistShapeShape aDistAdaptor (theEdge, theFace, Extrema_ExtFlag_MIN);
|
||||||
if (!aDistAdaptor.IsDone())
|
if (!aDistAdaptor.IsDone() || aDistAdaptor.NbSolution() <1)
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
myFirstPoint = aDistAdaptor.PointOnShape1 (1);
|
myFirstPoint = aDistAdaptor.PointOnShape1 (1);
|
||||||
mySecondPoint = aDistAdaptor.PointOnShape2 (1);
|
mySecondPoint = aDistAdaptor.PointOnShape2 (1);
|
||||||
|
|
||||||
|
// Take direction for dimension line (will be orthogonalized later) parallel to edge
|
||||||
|
BRepAdaptor_Curve aCurveAdaptor (theEdge);
|
||||||
|
Standard_Real aParam;
|
||||||
|
if (aDistAdaptor.SupportOnShape1 (1).ShapeType() == TopAbs_EDGE)
|
||||||
|
{
|
||||||
|
aDistAdaptor.ParOnEdgeS1 (1, aParam);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Standard_Real aD1 = aCurveAdaptor.Value(aCurveAdaptor.FirstParameter()).SquareDistance (myFirstPoint);
|
||||||
|
Standard_Real aD2 = aCurveAdaptor.Value(aCurveAdaptor.LastParameter()).SquareDistance (myFirstPoint);
|
||||||
|
aParam = (aD1 < aD2 ? aCurveAdaptor.FirstParameter() : aCurveAdaptor.LastParameter());
|
||||||
|
}
|
||||||
|
gp_Pnt aP;
|
||||||
|
gp_Vec aV;
|
||||||
|
aCurveAdaptor.D1 (aParam, aP, aV);
|
||||||
|
if (aV.SquareMagnitude() > gp::Resolution())
|
||||||
|
{
|
||||||
|
theEdgeDir = aV;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reverse direction if parameter is close to the end of the curve,
|
||||||
|
// to reduce chances to have overlapping between dimension line and edge
|
||||||
|
if (Abs (aParam - aCurveAdaptor.FirstParameter()) < Abs (aParam - aCurveAdaptor.LastParameter()))
|
||||||
|
{
|
||||||
|
theEdgeDir.Reverse();
|
||||||
|
}
|
||||||
|
|
||||||
return IsValidPoints (myFirstPoint, mySecondPoint);
|
return IsValidPoints (myFirstPoint, mySecondPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@
|
|||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <BRepClass3d_SolidClassifier.hxx>
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
#include <NCollection_Comparator.hxx>
|
#include <NCollection_Comparator.hxx>
|
||||||
#include <NCollection_QuickSort.hxx>
|
|
||||||
#include <NCollection_Vector.hxx>
|
#include <NCollection_Vector.hxx>
|
||||||
#include <StdFail_NotDone.hxx>
|
#include <StdFail_NotDone.hxx>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -91,39 +91,15 @@ namespace
|
|||||||
Index2 (theIndex2),
|
Index2 (theIndex2),
|
||||||
Distance (theDistance) {}
|
Distance (theDistance) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Used by std::sort function
|
||||||
|
static Standard_Boolean BRepExtrema_CheckPair_Comparator (const BRepExtrema_CheckPair& theLeft,
|
||||||
|
const BRepExtrema_CheckPair& theRight)
|
||||||
|
{
|
||||||
|
return (theLeft.Distance < theRight.Distance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
|
||||||
class NCollection_Comparator<BRepExtrema_CheckPair>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Standard_Boolean IsLower (const BRepExtrema_CheckPair& theLeft, const BRepExtrema_CheckPair& theRight) const
|
|
||||||
{
|
|
||||||
return theLeft.Distance < theRight.Distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean IsGreater (const BRepExtrema_CheckPair& theLeft, const BRepExtrema_CheckPair& theRight) const
|
|
||||||
{
|
|
||||||
return theLeft.Distance > theRight.Distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean IsEqual (const BRepExtrema_CheckPair& theLeft, const BRepExtrema_CheckPair& theRight) const
|
|
||||||
{
|
|
||||||
return theLeft.Distance == theRight.Distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean IsLowerEqual (const BRepExtrema_CheckPair& theLeft, const BRepExtrema_CheckPair& theRight) const
|
|
||||||
{
|
|
||||||
return theLeft.Distance <= theRight.Distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean IsGreaterEqual (const BRepExtrema_CheckPair& theLeft, const BRepExtrema_CheckPair& theRight) const
|
|
||||||
{
|
|
||||||
return theLeft.Distance >= theRight.Distance;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : DistanceMapMap
|
//function : DistanceMapMap
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -149,8 +125,8 @@ void BRepExtrema_DistShapeShape::DistanceMapMap (const TopTools_IndexedMapOfShap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NCollection_QuickSort<NCollection_Vector<BRepExtrema_CheckPair>, BRepExtrema_CheckPair>::Perform (aPairList, NCollection_Comparator<BRepExtrema_CheckPair>(),
|
std::stable_sort(aPairList.begin(), aPairList.end(), BRepExtrema_CheckPair_Comparator);
|
||||||
aPairList.Lower(), aPairList.Upper());
|
|
||||||
for (NCollection_Vector<BRepExtrema_CheckPair>::Iterator aPairIter (aPairList);
|
for (NCollection_Vector<BRepExtrema_CheckPair>::Iterator aPairIter (aPairList);
|
||||||
aPairIter.More(); aPairIter.Next())
|
aPairIter.More(); aPairIter.Next())
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,6 @@ NCollection_ListNode.hxx
|
|||||||
NCollection_LocalArray.hxx
|
NCollection_LocalArray.hxx
|
||||||
NCollection_Map.hxx
|
NCollection_Map.hxx
|
||||||
NCollection_Mat4.hxx
|
NCollection_Mat4.hxx
|
||||||
NCollection_QuickSort.hxx
|
|
||||||
NCollection_Sequence.hxx
|
NCollection_Sequence.hxx
|
||||||
NCollection_Shared.hxx
|
NCollection_Shared.hxx
|
||||||
NCollection_SparseArray.hxx
|
NCollection_SparseArray.hxx
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
// Created on: 2011-01-27
|
|
||||||
// Created by: KGV
|
|
||||||
// Copyright (c) 2011-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.
|
|
||||||
|
|
||||||
#ifndef _NCollection_QuickSort_HeaderFile
|
|
||||||
#define _NCollection_QuickSort_HeaderFile
|
|
||||||
|
|
||||||
#include <NCollection_Comparator.hxx>
|
|
||||||
#include <Standard_Integer.hxx>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform sorting of enumerable collection with QuickSort algorithm.
|
|
||||||
* Enumerable collection should provide the random access to its values
|
|
||||||
* by index number with methods Value(theId) and ChangeValue(theId).
|
|
||||||
* Currently it supposed to be used with NCollection_Sequence and NCollection_Vector.
|
|
||||||
*
|
|
||||||
* Usage sample:
|
|
||||||
* // input sequence
|
|
||||||
* NCollection_Sequence<Standard_Real> aSequence;
|
|
||||||
* // perform sorting for the whole sequence.
|
|
||||||
* NCollection_QuickSort<NCollection_Sequence<Standard_Real>, Standard_Real>
|
|
||||||
* ::Perform (aSequence, NCollection_Comparator<Standard_Real>(),
|
|
||||||
* 1, aSequence.Size());
|
|
||||||
*/
|
|
||||||
template<class TheCollType, class TheItemType>
|
|
||||||
class NCollection_QuickSort
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//! Main entry call to perform sorting
|
|
||||||
static void Perform (TheCollType& theEnumColl,
|
|
||||||
const NCollection_Comparator<TheItemType>& theComparator,
|
|
||||||
const Standard_Integer theLower,
|
|
||||||
const Standard_Integer theUpper)
|
|
||||||
{
|
|
||||||
if (theLower < theUpper)
|
|
||||||
{
|
|
||||||
Standard_Integer aPivotPosition = Partition (theEnumColl, theComparator,
|
|
||||||
theLower, theUpper);
|
|
||||||
if (theLower < aPivotPosition)
|
|
||||||
{
|
|
||||||
// recursive call
|
|
||||||
Perform (theEnumColl, theComparator,
|
|
||||||
theLower, aPivotPosition - 1);
|
|
||||||
}
|
|
||||||
// recursive call
|
|
||||||
Perform (theEnumColl, theComparator,
|
|
||||||
aPivotPosition + 1, theUpper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Auxiliary function
|
|
||||||
static void SwapValues (TheItemType& x, TheItemType& y)
|
|
||||||
{
|
|
||||||
TheItemType aCopy = x;
|
|
||||||
x = y;
|
|
||||||
y = aCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Standard_Integer Partition (TheCollType& theEnumColl,
|
|
||||||
const NCollection_Comparator<TheItemType>& theComparator,
|
|
||||||
const Standard_Integer theLower,
|
|
||||||
const Standard_Integer theUpper)
|
|
||||||
{
|
|
||||||
Standard_Integer anIdLeft (theLower), anIdRight (theUpper);
|
|
||||||
const TheItemType aPivot = theEnumColl.Value (theLower);
|
|
||||||
|
|
||||||
while (anIdLeft < anIdRight)
|
|
||||||
{
|
|
||||||
while (theComparator.IsGreater (theEnumColl.Value (anIdRight), aPivot))
|
|
||||||
{
|
|
||||||
--anIdRight;
|
|
||||||
}
|
|
||||||
while ((anIdLeft < anIdRight) &&
|
|
||||||
theComparator.IsLowerEqual (theEnumColl.Value (anIdLeft), aPivot))
|
|
||||||
{
|
|
||||||
++anIdLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anIdLeft < anIdRight)
|
|
||||||
{
|
|
||||||
SwapValues (theEnumColl.ChangeValue (anIdLeft),
|
|
||||||
theEnumColl.ChangeValue (anIdRight));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
theEnumColl.ChangeValue (theLower) = theEnumColl.Value (anIdRight);
|
|
||||||
theEnumColl.ChangeValue (anIdRight) = aPivot;
|
|
||||||
return anIdRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*_NCollection_QuickSort_HeaderFile*/
|
|
@ -22,7 +22,7 @@ if { [expr abs( ${dist} - ${good_dist} )] > ${toler} } {
|
|||||||
# 2
|
# 2
|
||||||
# Point 3D : 66.6, -11.8556887483839, 0.3
|
# Point 3D : 66.6, -11.8556887483839, 0.3
|
||||||
|
|
||||||
regexp { +Point 3D : +([-0-9.+eE]+), +([-0-9.+eE]+), +([-0-9.+eE]+)} [ dump d ] full x1 y1 z1
|
regexp { +Point 3D : +([-0-9.+eE]+), +([-0-9.+eE]+), +([-0-9.+eE]+)} [ dump d2 ] full x1 y1 z1
|
||||||
set good_x1 66.6
|
set good_x1 66.6
|
||||||
set good_y1 -11.8556887483839
|
set good_y1 -11.8556887483839
|
||||||
set good_z1 0.3
|
set good_z1 0.3
|
||||||
@ -39,7 +39,7 @@ if { [expr abs( ${z1} - ${good_z1} )] > ${toler} } {
|
|||||||
# 3
|
# 3
|
||||||
# Point 3D : 66.6, 11.8556887323157, 0.3
|
# Point 3D : 66.6, 11.8556887323157, 0.3
|
||||||
|
|
||||||
regexp { +Point 3D : +([-0-9.+eE]+), +([-0-9.+eE]+), +([-0-9.+eE]+)} [ dump d2 ] full x2 y2 z2
|
regexp { +Point 3D : +([-0-9.+eE]+), +([-0-9.+eE]+), +([-0-9.+eE]+)} [ dump d ] full x2 y2 z2
|
||||||
set good_x2 66.6
|
set good_x2 66.6
|
||||||
set good_y2 11.8556887323157
|
set good_y2 11.8556887323157
|
||||||
set good_z2 0.3
|
set good_z2 0.3
|
||||||
|
@ -4,22 +4,32 @@ puts "AIS_LengthDimension can not build dimension for face-edge or edge-face"
|
|||||||
puts "============"
|
puts "============"
|
||||||
puts ""
|
puts ""
|
||||||
puts "Tests case of edge-face and face-edge input geometry for dimension"
|
puts "Tests case of edge-face and face-edge input geometry for dimension"
|
||||||
|
|
||||||
pload MODELING VISUALIZATION
|
pload MODELING VISUALIZATION
|
||||||
line aLine 0 -100 0 1 0 0
|
|
||||||
mkedge anEdge aLine -100 100
|
|
||||||
|
|
||||||
plane aPlane 0 0 50 0 0 1
|
plane aPlane 0 0 50 0 0 1
|
||||||
mkface aFace aPlane -100 100 -100 100
|
mkface aFace aPlane -100 100 -100 100
|
||||||
|
|
||||||
line aLine2 0 0 100 1 1 0
|
line aLine 0 -100 0 1 0 0
|
||||||
|
mkedge anEdge aLine -100 100
|
||||||
|
|
||||||
|
line aLine2 0 0 100 1 1 0.1
|
||||||
mkedge anEdge2 aLine2 -150 150
|
mkedge anEdge2 aLine2 -150 150
|
||||||
|
|
||||||
|
circle aCirc1 30 -30 100 0.3 -0.3 1 20.
|
||||||
|
mkedge anEdge3 aCirc1
|
||||||
|
|
||||||
|
circle aCirc2 -130 -30 100 0.3 -0.3 1 20.
|
||||||
|
mkedge anEdge4 aCirc2 30. 180.
|
||||||
|
|
||||||
vinit View1
|
vinit View1
|
||||||
vclear
|
vclear
|
||||||
vaxo
|
vaxo
|
||||||
vdisplay anEdge anEdge2 aFace
|
vdisplay anEdge anEdge2 anEdge3 anEdge4 aFace
|
||||||
vdimension aDim1 -length -shapes anEdge aFace -text 15 3d sh
|
vdimension aDim1 -length -shapes anEdge aFace -text 15 3d sh
|
||||||
vdimension aDim2 -length -shapes aFace anEdge2 -text 15 3d sh
|
vdimension aDim2 -length -shapes aFace anEdge2 -text 15 3d sh
|
||||||
|
vdimension aDim3 -length -shapes aFace anEdge3 -text 15 3d sh
|
||||||
|
vdimension aDim4 -length -shapes aFace anEdge4 -text 15 3d sh
|
||||||
vfit
|
vfit
|
||||||
|
|
||||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||||
|
Loading…
x
Reference in New Issue
Block a user