mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-08-14 12:39:17 +08:00
Foundation Classes - Tree & collection performance optimizations, move semantics, unified map API (#1065)
NCollection_UBTree/EBTree: - Add move constructor and move assignment operators - Replace recursive Select() and delNode() with iterative stack-based traversal to avoid stack overflow on deeply unbalanced trees - Optimize EBTree::Add() and Remove() to use single-lookup TryEmplaced() instead of double-lookup UnBind()+Bind() / Contains()+operator() - Remove unused DEFINE_HUBTREE / DEFINE_HEBTREE / IMPLEMENT_HUBTREE / IMPLEMENT_HEBTREE macros - Remove unused includes from EBTree (Standard_Type, Standard_Transient, NCollection_List, Standard_Integer, NCollection_Sequence) - Fix doxygen @param tags and comment style NCollection_LocalArray: - Add move constructor and move assignment operators with optimized three-way branching (stack-stack copy, heap-heap swap, stack-heap steal) - Add Reallocate() method supporting grow-with-copy for use as a dynamically growable stack - Add static_assert enforcing trivially copyable element type NCollection_CellFilter: - Replace const_cast destructive-copy hack in Cell with proper move semantics; delete copy constructor and copy assignment - Add Cell constructor from CellIndex for lightweight lookup keys - Refactor add()/iterateAdd() to accept CellIndex instead of Cell, use TryEmplaced() for single-lookup cell insertion - Refactor remove()/inspect() to use Contained() API with const_cast instead of C-style cast on Seek() - Change ListNode default constructor from runtime throw to = delete - Use size_t for dimension loops and add dimension size guard in IsEqual - Remove SUN WorkShop 5.3 workaround - Fix typo "usially" -> "usually" in class documentation NCollection map API unification (Contained, TryEmplace, TryBind): - Add Contained() to all map types returning std::optional with std::reference_wrapper; key-only maps return const key ref, data maps return std::pair of const key ref + value ref - Add TryEmplace()/TryEmplaced() to NCollection_FlatMap and NCollection_IndexedMap for parity with NCollection_Map - Add TryBind() to NCollection_IndexedDataMap for parity with NCollection_DataMap and NCollection_FlatDataMap - Remove Seek()/ChangeSeek() from NCollection_Map (replaced by Contained()) Dead compiler workaround removal: - NCollection_DefineAlloc: remove Borland/SUN #if branch, keep only the version with placement delete - NCollection_SparseArrayBase: remove SUN WorkShop 5.3 workaround GTests: - Add move constructor/assignment tests for LocalArray, UBTree, EBTree - Add Contained tests for NCollection_Map - Add CellFilter tests and UBTree deep-unbalanced-tree stress test
This commit is contained in:
@@ -22,10 +22,20 @@
|
||||
#include <NCollection_CellFilter.hxx>
|
||||
|
||||
//! Auxiliary class to find circles shot by the given point.
|
||||
class BRepMesh_CircleInspector : public NCollection_CellFilter_InspectorXY
|
||||
class BRepMesh_CircleInspector
|
||||
{
|
||||
public:
|
||||
typedef int Target;
|
||||
static constexpr int Dimension = 2;
|
||||
|
||||
typedef gp_XY Point;
|
||||
typedef int Target;
|
||||
|
||||
static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
|
||||
|
||||
static Point Shift(const Point& thePnt, double theTol)
|
||||
{
|
||||
return Point(thePnt.X() + theTol, thePnt.Y() + theTol);
|
||||
}
|
||||
|
||||
//! Constructor.
|
||||
//! @param theTolerance tolerance to be used for identification of shot circles.
|
||||
|
||||
@@ -23,10 +23,20 @@
|
||||
#include <BRepMesh_Vertex.hxx>
|
||||
|
||||
//! Class intended for fast searching of the coincidence points.
|
||||
class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
|
||||
class BRepMesh_VertexInspector
|
||||
{
|
||||
public:
|
||||
typedef int Target;
|
||||
static constexpr int Dimension = 2;
|
||||
|
||||
typedef gp_XY Point;
|
||||
typedef int Target;
|
||||
|
||||
static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
|
||||
|
||||
static Point Shift(const Point& thePnt, double theTol)
|
||||
{
|
||||
return Point(thePnt.X() + theTol, thePnt.Y() + theTol);
|
||||
}
|
||||
|
||||
//! Constructor.
|
||||
//! @param theAllocator memory allocator to be used by internal collections.
|
||||
|
||||
@@ -249,10 +249,20 @@ protected:
|
||||
|
||||
//! This inspector will find a node nearest to the given point
|
||||
//! not far than on the given tolerance
|
||||
class NodeInspector : public NCollection_CellFilter_InspectorXYZ
|
||||
class NodeInspector
|
||||
{
|
||||
public:
|
||||
typedef int Target;
|
||||
static constexpr int Dimension = 3;
|
||||
|
||||
typedef gp_XYZ Point;
|
||||
typedef int Target;
|
||||
|
||||
static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
|
||||
|
||||
static Point Shift(const Point& thePnt, double theTol)
|
||||
{
|
||||
return Point(thePnt.X() + theTol, thePnt.Y() + theTol, thePnt.Z() + theTol);
|
||||
}
|
||||
|
||||
NodeInspector(const NCollection_Vector<FS_Vertex>& theVec,
|
||||
const gp_Pnt& thePnt,
|
||||
|
||||
@@ -24,18 +24,23 @@
|
||||
|
||||
typedef NCollection_Vector<gp_XYZ> VectorOfPoint;
|
||||
|
||||
//=======================================================================
|
||||
//! Class BRepBuilderAPI_VertexInspector
|
||||
//! derived from NCollection_CellFilter_InspectorXYZ
|
||||
//! This class define the Inspector interface for CellFilter algorithm,
|
||||
//! working with gp_XYZ points in 3d space.
|
||||
//! Used in search of coincidence points with a certain tolerance.
|
||||
//=======================================================================
|
||||
//! Inspector for CellFilter algorithm working with gp_XYZ points in 3d space.
|
||||
//! Used in search of coincidence points with a certain tolerance.
|
||||
|
||||
class BRepBuilderAPI_VertexInspector : public NCollection_CellFilter_InspectorXYZ
|
||||
class BRepBuilderAPI_VertexInspector
|
||||
{
|
||||
public:
|
||||
typedef int Target;
|
||||
static constexpr int Dimension = 3;
|
||||
|
||||
typedef gp_XYZ Point;
|
||||
typedef int Target;
|
||||
|
||||
static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
|
||||
|
||||
static Point Shift(const Point& thePnt, double theTol)
|
||||
{
|
||||
return Point(thePnt.X() + theTol, thePnt.Y() + theTol, thePnt.Z() + theTol);
|
||||
}
|
||||
|
||||
//! Constructor; remembers the tolerance
|
||||
BRepBuilderAPI_VertexInspector(const double theTol)
|
||||
|
||||
@@ -23,15 +23,22 @@
|
||||
|
||||
typedef NCollection_Vector<gp_XYZ> VectorOfPoint;
|
||||
|
||||
//! Class BRepExtrema_VertexInspector
|
||||
//! derived from NCollection_CellFilter_InspectorXYZ
|
||||
//! This class define the Inspector interface for CellFilter algorithm,
|
||||
//! working with gp_XYZ points in 3d space.
|
||||
//! Used in search of coincidence points with a certain tolerance.
|
||||
class BRepExtrema_VertexInspector : public NCollection_CellFilter_InspectorXYZ
|
||||
//! Inspector for CellFilter algorithm working with gp_XYZ points in 3d space.
|
||||
//! Used in search of coincidence points with a certain tolerance.
|
||||
class BRepExtrema_VertexInspector
|
||||
{
|
||||
public:
|
||||
typedef int Target;
|
||||
static constexpr int Dimension = 3;
|
||||
|
||||
typedef gp_XYZ Point;
|
||||
typedef int Target;
|
||||
|
||||
static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
|
||||
|
||||
static Point Shift(const Point& thePnt, double theTol)
|
||||
{
|
||||
return Point(thePnt.X() + theTol, thePnt.Y() + theTol, thePnt.Z() + theTol);
|
||||
}
|
||||
|
||||
//! Constructor; remembers the tolerance
|
||||
BRepExtrema_VertexInspector()
|
||||
@@ -53,7 +60,7 @@ public:
|
||||
myIsNeedAdd = true;
|
||||
}
|
||||
|
||||
bool IsNeedAdd() { return myIsNeedAdd; }
|
||||
bool IsNeedAdd() const { return myIsNeedAdd; }
|
||||
|
||||
//! Implementation of inspection method
|
||||
Standard_EXPORT NCollection_CellFilter_Action Inspect(const int theTarget);
|
||||
|
||||
Reference in New Issue
Block a user