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

0033370: Foundation Classes - Moving into STL and Boost functionality

NCollection containers update:
  - NCollection_Array1 - updated functionality
  - NCollection_Array2 - NCollection_Array1 as a wrapper for 2array
  - NCollection_Vector -> NCollection_DynamicArray was renamed and reworked.
TCollection:
  - Use static empty string to avoid allocations on empty string
 NCollection allocators update:
  - NCollection_Allocator - allocator that used Standard::Allocate
  - NCollection_OccAllocator - allocator-wrapper that used OCC BaseAllocator objects
  - NCollection_IncAllocator - rework to increase performance
Standard:
  - Rework functionality to use different allocation libs
  - Implement basic of new way to wrap allocations tools
  - Define 4 ways to allocation (defines in configure stage)
 Additional changes:
  - Hash function uses std::hash functionality
   - size_t as a hash value
  - New HashUtils with Murmur and FVN hash algo for x32 and x64
  - Deprecated _0.cxx and .gxx DE classes reorganized
  - Create own utility for std memory
  - Update Standard_Transient to be more platform-independent
 Math TK changes:
  - math_Vector -> match_BaseVector<>
    - Buffer decreased to cash 32 elements instead of 512
This commit is contained in:
dpasukhi
2023-08-05 17:53:19 +01:00
parent 6dbfade692
commit 1103eb60af
649 changed files with 10704 additions and 12037 deletions

View File

@@ -138,7 +138,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
// collect sub-shapes with the same style into compounds
BRep_Builder aBuilder;
NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style> aStyleGroups;
NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound> aStyleGroups;
for (XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle aStyledShapeIter (aSettings);
aStyledShapeIter.More(); aStyledShapeIter.Next())
{
@@ -160,7 +160,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
aSettings.Clear();
// assign custom aspects
for (NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style>::Iterator aStyleGroupIter (aStyleGroups);
for (NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound>::Iterator aStyleGroupIter (aStyleGroups);
aStyleGroupIter.More(); aStyleGroupIter.Next())
{
const TopoDS_Compound& aComp = aStyleGroupIter.Value();

View File

@@ -20,8 +20,8 @@
#include <XCAFPrs_Style.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape,XCAFPrs_Style> XCAFPrs_DataMapOfStyleShape;
typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape,XCAFPrs_Style>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleShape;
typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape> XCAFPrs_DataMapOfStyleShape;
typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleShape;
#endif

View File

@@ -20,8 +20,8 @@
#include <Standard_Transient.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient),XCAFPrs_Style> XCAFPrs_DataMapOfStyleTransient;
typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient),XCAFPrs_Style>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleTransient;
typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient)> XCAFPrs_DataMapOfStyleTransient;
typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient)>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleTransient;
#endif

View File

@@ -37,20 +37,22 @@ struct XCAFPrs_DocumentNode
public: // Methods for hash map
//! Return hash code based on node string identifier.
static Standard_Integer HashCode (const XCAFPrs_DocumentNode& theNode,
const Standard_Integer theN)
bool operator==(const XCAFPrs_DocumentNode& theOther) const
{
return ::HashCode (theNode.Id, theN);
return Id == theOther.Id;
}
//! Return TRUE if two document nodes has the same string identifier.
static Standard_Boolean IsEqual (const XCAFPrs_DocumentNode& theNode1,
const XCAFPrs_DocumentNode& theNode2)
{
return theNode1.Id == theNode2.Id;
}
};
namespace std
{
template <>
struct hash<XCAFPrs_DocumentNode>
{
size_t operator()(const XCAFPrs_DocumentNode& theDocumentNode) const
{
return std::hash<TCollection_AsciiString>{}(theDocumentNode.Id);
}
};
}
#endif // _XCAFPrs_DocumentNode_HeaderFile

View File

@@ -19,8 +19,8 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Quantity_ColorRGBAHasher.hxx>
#include <XCAFDoc_VisMaterial.hxx>
#include <Standard_HashUtils.hxx>
//! Represents a set of styling settings applicable to a (sub)shape
class XCAFPrs_Style
@@ -130,38 +130,8 @@ public:
return IsEqual (theOther);
}
//! Computes a hash code for the given set of styling settings, in the range [1, theUpperBound]
//! @param theStyle the set of styling settings which hash code is to be computed
//! @param theUpperBound the upper bound of the range a computing hash code must be within
//! @return a computed hash code, in the range [1, theUpperBound]
static Standard_Integer HashCode (const XCAFPrs_Style& theStyle, const Standard_Integer theUpperBound)
{
if (!theStyle.myIsVisible)
{
return 1;
}
Standard_Integer aHashCode = 0;
if (theStyle.myHasColorSurf)
{
aHashCode = aHashCode ^ Quantity_ColorRGBAHasher::HashCode (theStyle.myColorSurf, theUpperBound);
}
if (theStyle.myHasColorCurv)
{
aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorCurv, theUpperBound);
}
if (!theStyle.myMaterial.IsNull())
{
aHashCode = aHashCode ^ ::HashCode (theStyle.myMaterial, theUpperBound);
}
return ::HashCode (aHashCode, theUpperBound);
}
//! Returns True when the two keys are the same.
static Standard_Boolean IsEqual (const XCAFPrs_Style& theS1, const XCAFPrs_Style& theS2)
{
return theS1.IsEqual (theS2);
}
template<class T>
friend struct std::hash;
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
@@ -177,4 +147,34 @@ protected:
};
namespace std
{
template <>
struct hash<XCAFPrs_Style>
{
size_t operator()(const XCAFPrs_Style& theStyle) const
{
if (!theStyle.myIsVisible)
{
return 1;
}
size_t aCombination[3];
int aCount = 0;
if (theStyle.myHasColorSurf)
{
aCombination[aCount++] = std::hash<Quantity_ColorRGBA>{}(theStyle.myColorSurf);
}
if (theStyle.myHasColorCurv)
{
aCombination[aCount++] = std::hash<Quantity_Color>{}(theStyle.myColorCurv);
}
if (!theStyle.myMaterial.IsNull())
{
aCombination[aCount++] = std::hash<Handle(XCAFDoc_VisMaterial)>{}(theStyle.myMaterial);
}
return aCount > 0 ? opencascade::hashBytes(aCombination, sizeof(size_t) * aCount) : 0;
}
};
}
#endif // _XCAFPrs_Style_HeaderFile