#define CafShapePrs_h
#include <TDF_Label.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <XCAFPrs_AISObject.hxx>
#include <XCAFPrs_Style.hxx>
typedef NCollection_DataMap<TopoDS_Shape, Handle(AIS_ColoredDrawer), TopTools_ShapeMapHasher> CafDataMapOfShapeColor;
-typedef NCollection_DataMap<TDF_Label, Handle(AIS_InteractiveObject), TDF_LabelMapHasher> MapOfPrsForShapes;
+typedef NCollection_DataMap<TDF_Label, Handle(AIS_InteractiveObject)> MapOfPrsForShapes;
//! Interactive object for shape in DECAF document
class CafShapePrs : public XCAFPrs_AISObject
#include <NCollection_IndexedDataMap.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_MapOfShape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
class StdSelect_BRepOwner;
protected:
- typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound, TColStd_MapTransientHasher> DataMapOfDrawerCompd;
+ typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound> DataMapOfDrawerCompd;
protected:
#include <StdSelect.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <TopoDS_Shape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject)
const Standard_Integer theMode)
{
typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
- typedef NCollection_DataMap<TopoDS_Shape, SensitiveList, TopTools_OrientedShapeMapHasher>
+ typedef NCollection_DataMap<TopoDS_Shape, SensitiveList>
Shapes2EntitiesMap;
if (!myReference->HasSelection (theMode))
#include <AIS_InteractiveObject.hxx>
#include <AIS_GlobalStatus.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus),TColStd_MapTransientHasher> AIS_DataMapOfIOStatus;
-typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus),TColStd_MapTransientHasher>::Iterator AIS_DataMapIteratorOfDataMapOfIOStatus;
+typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus)> AIS_DataMapOfIOStatus;
+typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus)>::Iterator AIS_DataMapIteratorOfDataMapOfIOStatus;
#endif
protected:
- //! Trivial hasher to avoid ambiguity with enumeration type.
- struct IntegerHasher
- {
- static Standard_Integer HashCode (Standard_Integer theValue, Standard_Integer theUpper) { return ::HashCode (theValue, theUpper); }
- static Standard_Boolean IsEqual (Standard_Integer theA, Standard_Integer theB) { return theA == theB; }
- };
-
-protected:
-
- NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString, IntegerHasher>
+ NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString>
myBoxSideLabels; //!< map with box side labels
- NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString, IntegerHasher>
+ NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
myAxesLabels; //!< map with axes labels
Handle(Prs3d_ShadingAspect) myBoxEdgeAspect; //!< style for box edges
Handle(Prs3d_ShadingAspect) myBoxCornerAspect; //!< style for box corner
#include <TColgp_HArray2OfPnt2d.hxx>
#include <TColgp_HArray2OfPnt.hxx>
#include <TColStd_HArray1OfInteger.hxx>
-#include <Standard_Address.hxx>
#include <AdvApprox_EvaluatorFunction.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray2OfReal.hxx>
-#include <Standard_Address.hxx>
#include <GeomAbs_Shape.hxx>
#include <AdvApprox_EvaluatorFunction.hxx>
#include <TColStd_Array1OfInteger.hxx>
if (nbpoints > 24) throw Standard_DimensionError("VBernstein: nbpoints > 24");
// math_Matrix VB(classe, nbpoints);
- Standard_Integer i, j, k = 0, Som;
+ Standard_Integer i, j, Som;
// 300 = 1+2+ ... +24 points.
Som = (Standard_Integer )( 300*((classe-1)*classe/2.-1) + classe * (nbpoints-1)*nbpoints/2.);
for (j = 1; j <= nbpoints; j++) {
M(i, j) = *tmpVB;
tmpVB++;
- k++;
}
}
}
#include <math_Matrix.hxx>
#include <NCollection_Array1.hxx>
#include <AppParCurves_Constraint.hxx>
-
+#include <math_Vector.hxx>
struct PeriodicityInfo
{
// commercial license or contractual agreement.
#include <Approx_ParametrizationType.hxx>
-#include Approx_ParLeastSquareOfMyGradient_hxx
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
Standard_Boolean Parallel;
#endif
Standard_Integer myfirstpt = firstpt, mylastpt = lastpt;
- Standard_Integer nbp = lastpt-firstpt+1, Kopt = 0;
+ Standard_Integer nbp = lastpt-firstpt+1;
math_Vector Para(firstpt, lastpt);
Parameters(Line, firstpt, lastpt, Para);
Tangent1 = LineTool::Tangency(Line, myfirstpt, tabV1);
Tangent2 = LineTool::Tangency(Line, mylastpt, tabV2);
}
-
- if (Tangent1) Kopt++;
- if (Tangent2) Kopt++;
-
-
if (nbp == 2) {
// S il n y a que 2 points, on verifie quand meme que les tangentes sont
// alignees.
#ifndef _ApproxInt_KnotTools_HeaderFile
#define _ApproxInt_KnotTools_HeaderFile
-#ifndef _Standard_DefineAlloc_HeaderFile
#include <Standard_DefineAlloc.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
-#endif
-
-#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
-#endif
-#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
-#endif
-#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
-#endif
-
#include <TColgp_Array1OfPnt2d.hxx>
+#include <NCollection_Sequence.hxx>
+#include <NCollection_List.hxx>
+#include <math_Vector.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <NCollection_LocalArray.hxx>
+#include <NCollection_Vector.hxx>
#include <Approx_ParametrizationType.hxx>
-class math_Vector;
-template <class A> class NCollection_Sequence;
-template <class A> class NCollection_List;
-template <class A> class NCollection_Vector;
-
class IntPatch_WLine;
// Corresponds for debug information output.
};
//! Map of actions with action Id as a key.
-typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Aspect_XRAction), TCollection_AsciiString> Aspect_XRActionMap;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Aspect_XRAction)> Aspect_XRActionMap;
#endif // _Aspect_XRAction_HeaderFile
Aspect_XRActionMap myActions; //!< map of actions
};
-typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Aspect_XRActionSet), TCollection_AsciiString> Aspect_XRActionSetMap;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(Aspect_XRActionSet)> Aspect_XRActionSetMap;
#endif // _Aspect_XRActionSet_HeaderFile
void BOPAlgo_BuilderFace::PerformShapesToAvoid(const Message_ProgressRange& theRange)
{
Standard_Boolean bFound;
- Standard_Integer i, iCnt, aNbV, aNbE;
+ Standard_Integer i, aNbV, aNbE;
TopTools_IndexedDataMapOfShapeListOfShape aMVE;
TopTools_ListIteratorOfListOfShape aIt;
//
//
Message_ProgressScope aPS(theRange, NULL, 1);
//
- iCnt=0;
for(;;) {
if (UserBreak(aPS))
{
return;
}
-
- ++iCnt;
bFound=Standard_False;
//
// 1. MEF
void BOPAlgo_BuilderSolid::PerformShapesToAvoid(const Message_ProgressRange& theRange)
{
Standard_Boolean bFound;
- Standard_Integer i, iCnt, aNbE, aNbF;
+ Standard_Integer i, aNbE, aNbF;
TopAbs_Orientation aOrE;
TopTools_IndexedDataMapOfShapeListOfShape aMEF;
TopTools_ListIteratorOfListOfShape aIt;
//
Message_ProgressScope aPS(theRange, NULL, 1);
//
- iCnt=0;
for(;;) {
if (UserBreak(aPS)) {
return;
}
- ++iCnt;
bFound=Standard_False;
//
// 1. MEF
//=======================================================================
typedef
NCollection_IndexedDataMap<BOPTools_Set,
- TopTools_ListOfShape,
- BOPTools_SetMapHasher> BOPAlgo_IndexedDataMapOfSetListOfShape;
+ TopTools_ListOfShape> BOPAlgo_IndexedDataMapOfSetListOfShape;
static void AddEdgeSet(const TopoDS_Shape& theS,
BOPAlgo_IndexedDataMapOfSetListOfShape& theMap,
// Data map of set of edges with all faces having this set
NCollection_IndexedDataMap<BOPTools_Set,
- TopTools_ListOfShape,
- BOPTools_SetMapHasher> anESetFaces(1, aAllocator);
+ TopTools_ListOfShape> anESetFaces(1, aAllocator);
// Map of planar bounded faces. If such faces have the same Edge set
// they are considered Same domain, without additional check.
TopTools_MapOfShape aMFPlanar(1, aAllocator);
if (bCheckPlanar && aMFPlanar.Contains(aF2))
{
// Consider planar bounded faces as Same Domain without additional check
- BOPAlgo_Tools::FillMap<TopoDS_Shape, TopTools_ShapeMapHasher>(aF1, aF2, aDMSLS, aAllocator);
+ BOPAlgo_Tools::FillMap(aF1, aF2, aDMSLS, aAllocator);
continue;
}
// Add pair for analysis
{
BOPAlgo_PairOfShapeBoolean& aPSB = aVPSB(i);
if (aPSB.Flag())
- BOPAlgo_Tools::FillMap<TopoDS_Shape, TopTools_ShapeMapHasher>
- (aPSB.Shape1(), aPSB.Shape2(), aDMSLS, aAllocator);
+ BOPAlgo_Tools::FillMap(aPSB.Shape1(), aPSB.Shape2(), aDMSLS, aAllocator);
}
aVPSB.Clear();
// Make blocks of SD faces using the back and forth map
- BOPAlgo_Tools::MakeBlocks<TopoDS_Shape, TopTools_ShapeMapHasher>
- (aDMSLS, aMBlocks, aAllocator);
+ BOPAlgo_Tools::MakeBlocks(aDMSLS, aMBlocks, aAllocator);
Message_ProgressScope aPS(aPSOuter.Next(3), "Filling same domain faces map", aMBlocks.Size());
// Fill same domain faces map
TopTools_ListIteratorOfListOfShape aItLEIm(*pLEIm);
for (; aItLEIm.More(); aItLEIm.Next())
{
- TopoDS_Edge& aSp = TopoDS::Edge(aItLEIm.Value());
+ TopoDS_Edge& aSp = TopoDS::Edge(aItLEIm.ChangeValue());
// Check if the split has multi-connected vertices
if (!bIsDegenerated && HasMultiConnected(aSp, aVerticesCounter))
#include <NCollection_DataMap.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
//! BOPAlgo_MakeConnected is the algorithm for making the touching
//! shapes connected or glued, i.e. for making the coinciding geometries
// Results
NCollection_DataMap
<TopoDS_Shape,
- TopTools_ListOfShape,
- TopTools_OrientedShapeMapHasher> myMaterials; //!< Map of the materials associations
+ TopTools_ListOfShape> myMaterials; //!< Map of the materials associations
//! for the border elements
TopTools_DataMapOfShapeListOfShape myOrigins; //!< Map of origins
//! (allows tracking the shape's ancestors)
typedef NCollection_DataMap
<Handle(BOPDS_PaveBlock),
- Bnd_Box,
- TColStd_MapTransientHasher> BOPAlgo_DataMapOfPaveBlockBndBox;
+ Bnd_Box> BOPAlgo_DataMapOfPaveBlockBndBox;
typedef NCollection_DataMap
<Handle(BOPDS_PaveBlock),
- TColStd_ListOfInteger,
- TColStd_MapTransientHasher> BOPAlgo_DataMapOfPaveBlockListOfInteger;
+ TColStd_ListOfInteger> BOPAlgo_DataMapOfPaveBlockListOfInteger;
typedef NCollection_DataMap
<Standard_Integer,
//! on a section curve.
NCollection_DataMap <BOPDS_Pair,
- NCollection_List<EdgeRangeDistance>,
- BOPDS_PairMapHasher> myDistances; //!< Map to store minimal distances between shapes
+ NCollection_List<EdgeRangeDistance>>
+ myDistances; //!< Map to store minimal distances between shapes
//! which have no real intersections
};
//
if (myDS->HasInterf(n1, n2))
{
- BOPAlgo_Tools::FillMap<Standard_Integer, TColStd_MapIntegerHasher>(n1, n2, aMILI, aAllocator);
+ BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
continue;
}
iFlag = BOPTools_AlgoTools::ComputeVV(aV1, aV2, myFuzzyValue);
if (!iFlag) {
- BOPAlgo_Tools::FillMap<Standard_Integer, TColStd_MapIntegerHasher>(n1, n2, aMILI, aAllocator);
+ BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
}
}
//
// 2. Make blocks
- BOPAlgo_Tools::MakeBlocks<Standard_Integer, TColStd_MapIntegerHasher>(aMILI, aMBlocks, aAllocator);
+ BOPAlgo_Tools::MakeBlocks(aMILI, aMBlocks, aAllocator);
//
// 3. Make vertices
NCollection_List<TColStd_ListOfInteger>::Iterator aItB(aMBlocks);
// for all vertices having the same SD vertex.
// It will also be used as a Fence map to avoid repeated
// intersection of the same SD vertex with edge
- NCollection_DataMap<BOPDS_Pair, TColStd_ListOfInteger, BOPDS_PairMapHasher> aDMVSD;
+ NCollection_DataMap<BOPDS_Pair, TColStd_ListOfInteger> aDMVSD;
//
Message_ProgressScope aPSOuter(theRange, NULL, 10);
for (i = 1; i <= aNbVE; ++i) {
BOPDS_MapOfPair aMPairs;
// Map to treat the Common Blocks
NCollection_IndexedDataMap<Handle(BOPDS_CommonBlock),
- BOPDS_ListOfPaveBlock,
- TColStd_MapTransientHasher> aMCBNewPB;
+ BOPDS_ListOfPaveBlock> aMCBNewPB;
//
// Map of vertices to init the pave blocks for them
TColStd_MapOfInteger aMVerticesToInitPB;
const BOPDS_ListOfPaveBlock& aLPBN = aMCBNewPB(i);
//
// For each group of pave blocks with the same vertices make new common block
- NCollection_IndexedDataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher> aMInds;
+ NCollection_IndexedDataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock> aMInds;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPBN);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
// 2
myDS->AddInterf(nE1, nE2);
//
- BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock), TColStd_MapTransientHasher>(aPB1, aPB2, aMPBLPB, aAllocator);
+ BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock)>(aPB1, aPB2, aMPBLPB, aAllocator);
}//case TopAbs_EDGE
break;
default:
// Fill the connection map from bounding vertices to pave blocks
// having those bounding vertices
NCollection_IndexedDataMap<BOPDS_Pair,
- BOPDS_ListOfPaveBlock,
- BOPDS_PairMapHasher> aPBMap(1, anAlloc);
+ BOPDS_ListOfPaveBlock> aPBMap(1, anAlloc);
// Fence map of pave blocks
BOPDS_MapOfPaveBlock aMPBFence(1, anAlloc);
aPBMap.Clear();
aMPBFence.Clear();
- anAlloc->Reset();
+ anAlloc->Reset(false);
Message_ProgressScope aPS(aPSOuter.Next(9), "Checking for coinciding edges", aNbPairs);
for (Standard_Integer i = 0; i < aNbPairs; i++)
const BOPDS_ListOfPaveBlock& aLPBCB = myDS->CommonBlock(aPB[j])->PaveBlocks();
BOPDS_ListIteratorOfListOfPaveBlock aItLPB(aLPBCB);
for (; aItLPB.More(); aItLPB.Next())
- BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock),
- TColStd_MapTransientHasher>(aPB[j], aItLPB.Value(), aMPBLPB, anAlloc);
+ BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock)>(aPB[j], aItLPB.Value(), aMPBLPB, anAlloc);
}
}
- BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock),
- TColStd_MapTransientHasher>(aPB[0], aPB[1], aMPBLPB, anAlloc);
+ BOPAlgo_Tools::FillMap<Handle(BOPDS_PaveBlock)>(aPB[0], aPB[1], aMPBLPB, anAlloc);
}
-
// Create new common blocks of coinciding pairs.
BOPAlgo_Tools::PerformCommonBlocks(aMPBLPB, anAlloc, myDS);
}
//
// Avoid repeated intersection of the same vertex with face in case
// the group of vertices formed a single SD vertex
- NCollection_DataMap<BOPDS_Pair, TColStd_MapOfInteger, BOPDS_PairMapHasher> aMVFPairs;
+ NCollection_DataMap<BOPDS_Pair, TColStd_MapOfInteger> aMVFPairs;
for (; myIterator->More(); myIterator->Next()) {
if (UserBreak(aPSOuter))
{
const TColStd_MapOfInteger& aMIFOn,
const TColStd_MapOfInteger& aMIFIn)
{
- Standard_Boolean bRet;
- Standard_Integer nV;
- TColStd_MapIteratorOfMapOfInteger aIt;
- //
- bRet=Standard_False;
- //
- aIt.Initialize(aMIFOn);
- for (; aIt.More(); aIt.Next()) {
- nV=aIt.Value();
- if (nV==nVx) {
- bRet=!bRet;
- return bRet;
- }
- }
- aIt.Initialize(aMIFIn);
- for (; aIt.More(); aIt.Next()) {
- nV=aIt.Value();
- if (nV==nVx) {
- bRet=!bRet;
- return bRet;
- }
+ if (aMIFOn.Contains(nVx) || aMIFIn.Contains(nVx))
+ {
+ return true;
}
- //
- return bRet;
+ return false;
}
//=======================================================================
// function: CheckFacePaves
aPSOuter.Next(0.7);
aPBMap.Clear();
- anAlloc->Reset();
+ anAlloc->Reset(false);
Message_ProgressScope aPS(aPSOuter.Next(9), "Checking for edges coinciding with faces", aNbEFs);
for (Standard_Integer i = 0; i < aNbEFs; i++)
//
// Collect all pairs of Edge/Edge interferences to check if
// some faces have to be moved to obtain more precise intersection
- NCollection_DataMap<BOPDS_Pair, TColStd_ListOfInteger, BOPDS_PairMapHasher> aEEMap;
+ NCollection_DataMap<BOPDS_Pair, TColStd_ListOfInteger> aEEMap;
const BOPDS_VectorOfInterfEE& aVEEs = myDS->InterfEE();
for (Standard_Integer iEE = 0; iEE < aVEEs.Size(); ++iEE)
{
// Map to store the real tolerance of the common block
// and avoid repeated computation of it
NCollection_DataMap<Handle(BOPDS_CommonBlock),
- Standard_Real,
- TColStd_MapTransientHasher> aMCBTol;
+ Standard_Real> aMCBTol;
// Map to avoid creation of different pave blocks for
// the same intersection edge
NCollection_DataMap<Standard_Integer, Handle(BOPDS_PaveBlock)> aMEPB;
}
// Make Blocks of the pave blocks
NCollection_List<BOPDS_ListOfPaveBlock> aMBlocks(aAllocator);
- BOPAlgo_Tools::MakeBlocks<Handle(BOPDS_PaveBlock), TColStd_MapTransientHasher>(aMPBLPB, aMBlocks, aAllocator);
+ BOPAlgo_Tools::MakeBlocks(aMPBLPB, aMBlocks, aAllocator);
// Use temporary allocator for the local fence map
Handle(NCollection_IncAllocator) anAllocTmp = new NCollection_IncAllocator;
continue;
// Reset the allocator
- anAllocTmp->Reset();
+ anAllocTmp->Reset(false);
// New common block
Handle(BOPDS_CommonBlock) aCB;
// Faces of the common block
for (Standard_Integer iPair = 0; iPair < aNbPairs; ++iPair)
{
const BOPTools_BoxPairSelector::PairIDs& aPair = aPairs[iPair];
- BOPAlgo_Tools::FillMap<Standard_Integer, TColStd_MapIntegerHasher> (aPair.ID1, aPair.ID2, aMILI, anAlloc);
+ BOPAlgo_Tools::FillMap (aPair.ID1, aPair.ID2, aMILI, anAlloc);
}
- NCollection_List<TColStd_ListOfInteger> aBlocks (anAlloc);
- BOPAlgo_Tools::MakeBlocks<Standard_Integer, TColStd_MapIntegerHasher> (aMILI, aBlocks, anAlloc);
+ NCollection_List<TColStd_ListOfInteger> aBlocks(anAlloc);
+ BOPAlgo_Tools::MakeBlocks (aMILI, aBlocks, anAlloc);
NCollection_List<TColStd_ListOfInteger>::Iterator itLI (aBlocks);
for (; itLI.More(); itLI.Next())
{
public:
- //! Makes the chains of the connected elements from the given connexity map
- template <class theType, class theTypeHasher>
- static void MakeBlocks(const NCollection_IndexedDataMap<theType, NCollection_List<theType>, theTypeHasher>& theMILI,
- NCollection_List<NCollection_List<theType>>& theMBlocks,
+ //! Makes the chains of the connected elements from the given convexity map
+ template <class TheMap, class TheList>
+ static void MakeBlocks(const TheMap& theMILI,
+ TheList& theMBlocks,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
- NCollection_Map<theType, theTypeHasher> aMFence;
+ NCollection_Map<typename TheMap::key_type, typename TheMap::hasher> aMFence;
Standard_Integer i, aNb = theMILI.Extent();
for (i = 1; i <= aNb; ++i) {
- const theType& n = theMILI.FindKey(i);
+ const typename TheMap::key_type& n = theMILI.FindKey(i);
if (!aMFence.Add(n))
continue;
//
// Start the chain
- NCollection_List<theType>& aChain = theMBlocks.Append(NCollection_List<theType>(theAllocator));
+ typename TheList::value_type& aChain = theMBlocks.Append(typename TheList::value_type(theAllocator));
aChain.Append(n);
// Look for connected elements
- typename NCollection_List<theType>::Iterator aItLChain(aChain);
+ typename TheList::value_type::Iterator aItLChain(aChain);
for (; aItLChain.More(); aItLChain.Next()) {
- const theType& n1 = aItLChain.Value();
- const NCollection_List<theType>& aLI = theMILI.FindFromKey(n1);
+ const typename TheMap::key_type& n1 = aItLChain.Value();
+ const typename TheList::value_type& aLI = theMILI.FindFromKey(n1);
// Add connected elements into the chain
- typename NCollection_List<theType>::Iterator aItLI(aLI);
+ typename TheList::value_type::Iterator aItLI(aLI);
for (; aItLI.More(); aItLI.Next()) {
- const theType& n2 = aItLI.Value();
+ const typename TheMap::key_type& n2 = aItLI.Value();
if (aMFence.Add(n2)) {
aChain.Append(n2);
}
}
//! Fills the map with the connected entities
- template <class theType, class theTypeHasher>
- static void FillMap(const theType& n1,
- const theType& n2,
- NCollection_IndexedDataMap<theType, NCollection_List<theType>, theTypeHasher>& theMILI,
+ template <class TheType, class TheMap>
+ static void FillMap(const TheType& n1,
+ const TheType& n2,
+ TheMap& theMILI,
const Handle(NCollection_BaseAllocator)& theAllocator)
{
- NCollection_List<theType> *pList1 = theMILI.ChangeSeek(n1);
+ typename TheMap::value_type *pList1 = theMILI.ChangeSeek(n1);
if (!pList1) {
- pList1 = &theMILI(theMILI.Add(n1, NCollection_List<theType>(theAllocator)));
+ pList1 = &theMILI(theMILI.Add(n1, NCollection_List<TheType>(theAllocator)));
}
pList1->Append(n2);
//
- NCollection_List<theType> *pList2 = theMILI.ChangeSeek(n2);
+ typename TheMap::value_type*pList2 = theMILI.ChangeSeek(n2);
if (!pList2) {
- pList2 = &theMILI(theMILI.Add(n2, NCollection_List<theType>(theAllocator)));
+ pList2 = &theMILI(theMILI.Add(n2, typename TheMap::value_type(theAllocator)));
}
pList2->Append(n1);
}
Standard_Integer nE, iRef, n1, n2;
BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB, aItPBN;
BOPDS_ListOfPaveBlock aLPBN;
- NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher> aMPKLPB;
- NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock, BOPDS_PairMapHasher>::Iterator aItMPKLPB;
+ NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock> aMPKLPB;
+ NCollection_DataMap<BOPDS_Pair, BOPDS_ListOfPaveBlock>::Iterator aItMPKLPB;
Handle(BOPDS_PaveBlock) aPB;
Handle(BOPDS_CommonBlock) aCBx;
BOPDS_Pair aPK;
#include <NCollection_DataMap.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
-typedef NCollection_DataMap<Standard_Integer, BOPDS_ListOfPaveBlock, TColStd_MapIntegerHasher> BOPDS_DataMapOfIntegerListOfPaveBlock;
+typedef NCollection_DataMap<Standard_Integer, BOPDS_ListOfPaveBlock> BOPDS_DataMapOfIntegerListOfPaveBlock;
#endif
#define BOPDS_DataMapOfPaveBlockCommonBlock_HeaderFile
#include <NCollection_DataMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <BOPDS_CommonBlock.hxx>
-typedef NCollection_DataMap<Handle(BOPDS_PaveBlock), Handle(BOPDS_CommonBlock), TColStd_MapTransientHasher> BOPDS_DataMapOfPaveBlockCommonBlock;
+typedef NCollection_DataMap<Handle(BOPDS_PaveBlock), Handle(BOPDS_CommonBlock)> BOPDS_DataMapOfPaveBlockCommonBlock;
typedef BOPDS_DataMapOfPaveBlockCommonBlock::Iterator BOPDS_DataMapIteratorOfDataMapOfPaveBlockCommonBlock;
#endif
#define BOPDS_DataMapOfPaveBlockListOfInteger_HeaderFile
#include <NCollection_DataMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <TColStd_ListOfInteger.hxx>
-typedef NCollection_DataMap<Handle(BOPDS_PaveBlock), TColStd_ListOfInteger, TColStd_MapTransientHasher> BOPDS_DataMapOfPaveBlockListOfInteger;
+typedef NCollection_DataMap<Handle(BOPDS_PaveBlock), TColStd_ListOfInteger> BOPDS_DataMapOfPaveBlockListOfInteger;
typedef BOPDS_DataMapOfPaveBlockListOfInteger::Iterator BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfInteger;
#endif
#define BOPDS_DataMapOfPaveBlockListOfPaveBlock_HeaderFile
#include <NCollection_DataMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
-typedef NCollection_DataMap<Handle(BOPDS_PaveBlock), BOPDS_ListOfPaveBlock, TColStd_MapTransientHasher> BOPDS_DataMapOfPaveBlockListOfPaveBlock;
+typedef NCollection_DataMap<Handle(BOPDS_PaveBlock), BOPDS_ListOfPaveBlock> BOPDS_DataMapOfPaveBlockListOfPaveBlock;
typedef BOPDS_DataMapOfPaveBlockListOfPaveBlock::Iterator BOPDS_DataMapIteratorOfDataMapOfPaveBlockListOfPaveBlock;
#endif
#define BOPDS_IndexedDataMapOfPaveBlockListOfInteger_HeaderFile
#include <NCollection_IndexedDataMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <BOPDS_PaveBlock.hxx>
-typedef NCollection_IndexedDataMap<Handle(BOPDS_PaveBlock), TColStd_ListOfInteger, TColStd_MapTransientHasher> BOPDS_IndexedDataMapOfPaveBlockListOfInteger;
+typedef NCollection_IndexedDataMap<Handle(BOPDS_PaveBlock), TColStd_ListOfInteger> BOPDS_IndexedDataMapOfPaveBlockListOfInteger;
#endif
#define BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock_HeaderFile
#include <NCollection_IndexedDataMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
-typedef NCollection_IndexedDataMap<Handle(BOPDS_PaveBlock), BOPDS_ListOfPaveBlock, TColStd_MapTransientHasher> BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock;
+typedef NCollection_IndexedDataMap<Handle(BOPDS_PaveBlock), BOPDS_ListOfPaveBlock> BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock;
#endif
#define BOPDS_IndexedMapOfPaveBlock_HeaderFile
#include <NCollection_IndexedMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <BOPDS_PaveBlock.hxx>
-typedef NCollection_IndexedMap<Handle(BOPDS_PaveBlock), TColStd_MapTransientHasher> BOPDS_IndexedMapOfPaveBlock;
+typedef NCollection_IndexedMap<Handle(BOPDS_PaveBlock)> BOPDS_IndexedMapOfPaveBlock;
#endif
#ifndef BOPDS_ListOfPaveBlock_HeaderFile
#define BOPDS_ListOfPaveBlock_HeaderFile
-#include <NCollection_List.hxx>
+#include <NCollection_List.hxx>
+#include <Standard_Handle.hxx>
class BOPDS_PaveBlock;
+
typedef NCollection_List<Handle(BOPDS_PaveBlock)> BOPDS_ListOfPaveBlock;
typedef BOPDS_ListOfPaveBlock::Iterator BOPDS_ListIteratorOfListOfPaveBlock;
#define BOPDS_MapOfCommonBlock_HeaderFile
#include <NCollection_Map.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <BOPDS_CommonBlock.hxx>
-typedef NCollection_Map<Handle(BOPDS_CommonBlock), TColStd_MapTransientHasher> BOPDS_MapOfCommonBlock;
+typedef NCollection_Map<Handle(BOPDS_CommonBlock)> BOPDS_MapOfCommonBlock;
typedef BOPDS_MapOfCommonBlock::Iterator BOPDS_MapIteratorOfMapOfCommonBlock;
#endif
#define BOPDS_MapOfPair_HeaderFile
#include <NCollection_Map.hxx>
-#include <BOPDS_PairMapHasher.hxx>
#include <BOPDS_Pair.hxx>
-typedef NCollection_Map<BOPDS_Pair, BOPDS_PairMapHasher> BOPDS_MapOfPair;
+typedef NCollection_Map<BOPDS_Pair> BOPDS_MapOfPair;
typedef BOPDS_MapOfPair::Iterator BOPDS_MapIteratorOfMapOfPair;
#endif
#define BOPDS_MapOfPave_HeaderFile
#include <NCollection_Map.hxx>
-#include <BOPDS_PaveMapHasher.hxx>
#include <BOPDS_Pave.hxx>
-typedef NCollection_Map<BOPDS_Pave, BOPDS_PaveMapHasher> BOPDS_MapOfPave;
+typedef NCollection_Map<BOPDS_Pave> BOPDS_MapOfPave;
typedef BOPDS_MapOfPave::Iterator BOPDS_MapIteratorOfMapOfPave;
#endif
#define BOPDS_MapOfPaveBlock_HeaderFile
#include <NCollection_Map.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <BOPDS_PaveBlock.hxx>
-typedef NCollection_Map<Handle(BOPDS_PaveBlock), TColStd_MapTransientHasher> BOPDS_MapOfPaveBlock;
+typedef NCollection_Map<Handle(BOPDS_PaveBlock)> BOPDS_MapOfPaveBlock;
typedef BOPDS_MapOfPaveBlock::Iterator BOPDS_MapIteratorOfMapOfPaveBlock;
#endif
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
+#include <Standard_HashUtils.hxx>
//! The class is to provide the pair of indices of interfering shapes.
(myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
}
- //! Computes a hash code for this pair, in the range [1, theUpperBound]
- //! @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]
- Standard_Integer HashCode (const Standard_Integer theUpperBound) const
+ bool operator==(const BOPDS_Pair& theOther) const
{
- return ::HashCode(myIndex1 + myIndex2, theUpperBound);
+ return IsEqual(theOther);
}
protected:
Standard_Integer myIndex2;
};
+namespace std
+{
+ template <>
+ struct hash<BOPDS_Pair>
+ {
+ size_t operator()(const BOPDS_Pair& thePair) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ int aCombination[2];
+ thePair.Indices(aCombination[0], aCombination[1]);
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
+
#endif // _BOPDS_Pair
\ No newline at end of file
+++ /dev/null
-// Created by: Eugeny MALTCHIKOV
-// Copyright (c) 2017 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 _BOPDS_PairMapHasher_HeaderFile
-#define _BOPDS_PairMapHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-#include <BOPDS_Pair.hxx>
-
-class BOPDS_Pair;
-
-class BOPDS_PairMapHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given pair, in the range [1, theUpperBound]
- //! @param thePair the pair 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 BOPDS_Pair& thePair, const Standard_Integer theUpperBound)
- {
- return thePair.HashCode (theUpperBound);
- }
-
- static Standard_Boolean IsEqual(const BOPDS_Pair& thePair1,
- const BOPDS_Pair& thePair2)
- {
- return thePair1.IsEqual(thePair2);
- }
-
-protected:
-
-private:
-
-};
-
-#endif // _BOPDS_PairMapHasher_HeaderFile
};
+namespace std
+{
+ template <>
+ struct hash<BOPDS_Pave>
+ {
+ size_t operator()(const BOPDS_Pave& thePave) const noexcept
+ {
+ size_t aCombination[2];
+ aCombination[0] = opencascade::hash(thePave.Index());
+ aCombination[1] = opencascade::hash(thePave.Parameter());
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
#include <BOPDS_Pave.lxx>
+++ /dev/null
-// Created by: Eugeny MALTCHIKOV
-// Copyright (c) 1999-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 _BOPDS_PaveMapHasher_HeaderFile
-#define _BOPDS_PaveMapHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-class BOPDS_Pave;
-
-
-
-class BOPDS_PaveMapHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given pave, in the range [1, theUpperBound]
- //! @param thePave the pave 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 BOPDS_Pave& thePave, Standard_Integer theUpperBound);
-
- static Standard_Boolean IsEqual (const BOPDS_Pave& aPave1, const BOPDS_Pave& aPave2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-#include <BOPDS_PaveMapHasher.lxx>
-
-
-
-
-
-#endif // _BOPDS_PaveMapHasher_HeaderFile
+++ /dev/null
-// Created by: Eugeny MALTCHIKOV
-// Copyright (c) 1999-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 <BOPDS_Pave.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer BOPDS_PaveMapHasher::HashCode (const BOPDS_Pave& thePave, const Standard_Integer theUpperBound)
-{
- return ::HashCode (thePave.Index(), theUpperBound);
-}
-
-//=======================================================================
-//function :IsEqual
-//purpose :
-//=======================================================================
-inline
- Standard_Boolean BOPDS_PaveMapHasher::IsEqual(const BOPDS_Pave& aPave1,
- const BOPDS_Pave& aPave2)
-{
- return aPave1.IsEqual(aPave2);
-}
BOPDS_Pave.lxx
BOPDS_PaveBlock.cxx
BOPDS_PaveBlock.hxx
-BOPDS_PaveMapHasher.hxx
-BOPDS_PaveMapHasher.lxx
BOPDS_PDS.hxx
BOPDS_PIterator.hxx
BOPDS_PIteratorSI.hxx
BOPDS_VectorOfPoint.hxx
BOPDS_VectorOfShapeInfo.hxx
BOPDS_Pair.hxx
-BOPDS_PairMapHasher.hxx
BOPDS_MapOfPair.hxx
BOPDS_VectorOfPair.hxx
BOPDS_VectorOfVectorOfPair.hxx
#define BOPTools_IndexedDataMapOfSetShape_HeaderFile
#include <BOPTools_Set.hxx>
-#include <BOPTools_SetMapHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
#include <TopoDS_Shape.hxx>
-typedef NCollection_IndexedDataMap<BOPTools_Set, TopoDS_Shape, BOPTools_SetMapHasher> BOPTools_IndexedDataMapOfSetShape;
+typedef NCollection_IndexedDataMap<BOPTools_Set, TopoDS_Shape> BOPTools_IndexedDataMapOfSetShape;
#endif
#define BOPTools_MapOfSet_HeaderFile
#include <BOPTools_Set.hxx>
-#include <BOPTools_SetMapHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<BOPTools_Set, BOPTools_SetMapHasher> BOPTools_MapOfSet;
+typedef NCollection_Map<BOPTools_Set> BOPTools_MapOfSet;
typedef BOPTools_MapOfSet::Iterator BOPTools_MapIteratorOfMapOfSet;
#endif
template<class TypeSolverVector, class TypeContext>
class ContextFunctor
{
- //! Auxiliary thread ID hasher.
- struct Hasher
- {
- //! Computes a hash code for the given thread identifier, in the range [1, theUpperBound]
- //! @param theThreadId the thread identifier 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 Standard_ThreadId theThreadId, const Standard_Integer theUpperBound)
- {
- return ::HashCode (theThreadId, theUpperBound);
- }
-
- static Standard_Boolean IsEqual(const Standard_ThreadId theKey1,
- const Standard_ThreadId theKey2)
- {
- return theKey1 == theKey2;
- }
- };
-
public:
//! Constructor
private:
TypeSolverVector& mySolverVector;
- mutable NCollection_DataMap<Standard_ThreadId, opencascade::handle<TypeContext>, Hasher> myContextMap;
+ mutable NCollection_DataMap<Standard_ThreadId, opencascade::handle<TypeContext>> myContextMap;
mutable Standard_Mutex myMutex;
};
#include <TopTools_MapOfShape.hxx>
static
- Standard_Integer NormalizedIds(const Standard_Integer aId,
- const Standard_Integer aDiv);
+ size_t NormalizedIds(const size_t aId,
+ const Standard_Integer aDiv);
//=======================================================================
//function :
return myShape;
}
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-Standard_Integer BOPTools_Set::HashCode (const Standard_Integer theUpperBound) const
-{
- return ::HashCode (mySum, theUpperBound);
-}
-
//=======================================================================
//function : IsEqual
//purpose :
void BOPTools_Set::Add(const TopoDS_Shape& theS,
const TopAbs_ShapeEnum theType)
{
- Standard_Integer aId, aIdN;
+ size_t aId, aIdN;
TopAbs_Orientation aOr;
TopExp_Explorer aExp;
//
aIt.Initialize(myShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
- aId=aSx.HashCode(myUpper);
+ aId = TopTools_ShapeMapHasher{}(aSx) % myUpper + 1;
aIdN=NormalizedIds(aId, myNbShapes);
mySum+=aIdN;
}
// function: NormalizedIds
// purpose :
//=======================================================================
-Standard_Integer NormalizedIds(const Standard_Integer aId,
- const Standard_Integer aDiv)
+size_t NormalizedIds(const size_t aId,
+ const Standard_Integer aDiv)
{
- Standard_Integer aMax, aTresh, aIdRet;
+ size_t aMax, aTresh, aIdRet;
//
aIdRet=aId;
- aMax=::IntegerLast();
+ aMax=SIZE_MAX;
aTresh=aMax/aDiv;
if (aId>aTresh) {
aIdRet=aId%aTresh;
Standard_EXPORT Standard_Boolean IsEqual (const BOPTools_Set& aOther) const;
- //! Computes a hash code for this set, in the range [1, theUpperBound]
- //! @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]
- Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
+ bool operator==(const BOPTools_Set& theOther) const
+ {
+ return IsEqual(theOther);
+ }
+ size_t GetSum() const { return mySum; }
protected:
TopTools_ListOfShape myShapes;
TopoDS_Shape myShape;
Standard_Integer myNbShapes;
- Standard_Integer mySum;
+ size_t mySum;
Standard_Integer myUpper;
-
-
-private:
-
-
-
-
-
};
-
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<BOPTools_Set>
+ {
+ size_t operator()(const BOPTools_Set& theSet) const noexcept
+ {
+ return theSet.GetSum();
+ }
+ };
+}
#endif // _BOPTools_Set_HeaderFile
+++ /dev/null
-// Created by: Peter KURNEV
-// Copyright (c) 1999-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 _BOPTools_SetMapHasher_HeaderFile
-#define _BOPTools_SetMapHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-class BOPTools_Set;
-
-
-
-class BOPTools_SetMapHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given set, in the range [1, theUpperBound]
- //! @param theSet the set 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 BOPTools_Set& theSet, Standard_Integer theUpperBound);
-
- static Standard_Boolean IsEqual (const BOPTools_Set& aSet1, const BOPTools_Set& aSet2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-#include <BOPTools_SetMapHasher.lxx>
-
-
-
-
-
-#endif // _BOPTools_SetMapHasher_HeaderFile
+++ /dev/null
-// Created by: Peter KURNEV
-// Copyright (c) 1999-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 <BOPTools_SetMapHasher.ixx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer BOPTools_SetMapHasher::HashCode (const BOPTools_Set& theSet,
- const Standard_Integer theUpperBound)
-{
- return theSet.HashCode (theUpperBound);
-}
-
-//=======================================================================
-//function :IsEqual
-//purpose :
-//=======================================================================
-inline Standard_Boolean BOPTools_SetMapHasher::IsEqual(const BOPTools_Set& theSS1,
- const BOPTools_Set& theSS2)
-{
- return theSS1.IsEqual(theSS2);
-}
BOPTools_Parallel.hxx
BOPTools_Set.cxx
BOPTools_Set.hxx
-BOPTools_SetMapHasher.hxx
-BOPTools_SetMapHasher.lxx
}
if (itcr.More()) {
- Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+ Handle(BRep_CurveRepresentation) cr = itcr.Value();
cr->Continuity(C);
}
else {
}
if (itpr.More()) {
- Handle(BRep_PointRepresentation)& pr = itpr.Value();
+ Handle(BRep_PointRepresentation) pr = itpr.Value();
pr->Parameter(p);
}
else {
}
if (itpr.More()) {
- Handle(BRep_PointRepresentation)& pr = itpr.Value();
+ Handle(BRep_PointRepresentation) pr = itpr.Value();
pr->Parameter(p);
}
else {
}
if (itpr.More()) {
- Handle(BRep_PointRepresentation)& pr = itpr.Value();
+ Handle(BRep_PointRepresentation) pr = itpr.Value();
pr->Parameter(p1);
// pr->Parameter(p2); // skv
pr->Parameter2(p2); // skv
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
while (itcr.More()) {
- Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+ Handle(BRep_CurveRepresentation) cr = itcr.Value();
if (cr->IsCurveOnSurface(S,l)) {
if (cr->IsCurveOnClosedSurface() && Eisreversed)
{
// Reorientation of all closed wires to the left.
//---------------------------------------------------------
for (; it.More(); it.Next()) {
- TopoDS_Wire& W = TopoDS::Wire(it.Value());
+ TopoDS_Wire& W = TopoDS::Wire(it.ChangeValue());
TopoDS_Shape aLocalShape = myFace.EmptyCopied();
TopoDS_Face NF = TopoDS::Face(aLocalShape);
// TopoDS_Face NF = TopoDS::Face(myFace.EmptyCopied());
// Classification of wires ones compared to the others.
//---------------------------------------------------------
for (it.Initialize(wires) ; it.More(); it.Next()) {
- TopoDS_Wire& W1 = TopoDS::Wire(it.Value());
+ const TopoDS_Wire& W1 = TopoDS::Wire(it.Value());
TopTools_ListIteratorOfListOfShape it2(wires);
if (IsClosed(W1)) {
if (pLCE)
{
for (itl1.Initialize(*pLCE); itl1.More(); itl1.Next()) {
- TopoDS_Edge& E = TopoDS::Edge(itl1.Value());
+ TopoDS_Edge& E = TopoDS::Edge(itl1.ChangeValue());
if (!Emap.Add(E))
continue;
StoreInMVE(myFace,E,MVE,YaCouture,myVerticesForSubstitute, myTolConf);
// => call only once StoreInMVE which should double them
TopTools_MapOfShape DejaVu;
for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) {
- TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ TopoDS_Edge& E = TopoDS::Edge(itl.ChangeValue());
if (DejaVu.Add(E))
StoreInMVE(myFace,E,MVE,YaCouture,myVerticesForSubstitute, myTolConf);
}
// Standard_False);
TopTools_ListIteratorOfListOfShape it(myNewWires);
for (; it.More(); it.Next()) {
- FR.Add(TopoDS::Wire(it.Value()));
+ FR.Add(TopoDS::Wire(it.ChangeValue()));
}
FR.Perform();
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Standard.hxx>
#include <Standard_Type.hxx>
-#include <Standard_Address.hxx>
#include <math_Vector.hxx>
#include <Blend_Point.hxx>
#include <gp_Pnt.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <NCollection_IndexedDataMap.hxx>
+#include <Standard_HashUtils.hxx>
namespace
{
return Standard_False;
}
+ bool operator==(const Edge& theOther) const
+ {
+ return theOther.Idx1 == Idx1 && theOther.Idx2 == Idx2;
+ }
+
//! First index. It is lower or equal than the second.
Standard_Integer Idx1;
//! Second index.
Standard_Integer Idx2;
};
+}
- //! Hasher of Edge structure.
- struct EdgeHasher
+namespace std
+{
+ template <>
+ struct hash<Edge>
{
-
- //! Returns hash code for the given edge.
- static Standard_Integer HashCode(const Edge& theEdge,
- const Standard_Integer theUpperBound)
+ size_t operator()(const Edge& theEdge) const noexcept
{
- // Circle-based collisions.
- return ::HashCode(theEdge.Idx1 * theEdge.Idx1 + theEdge.Idx2 * theEdge.Idx2, theUpperBound);
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theEdge.Idx1, theEdge.Idx2 };
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
}
-
- //! Returns true if two edges are equal.
- static Standard_Boolean IsEqual(const Edge& theEdge1,
- const Edge& theEdge2)
- {
- return theEdge1.Idx1 == theEdge2.Idx1 && theEdge1.Idx2 == theEdge2.Idx2;
- }
-
};
}
}
// Build shared edges.
- NCollection_IndexedDataMap<Edge, TopoDS_Edge, EdgeHasher> anEdgeToTEgeMap;
+ NCollection_IndexedDataMap<Edge, TopoDS_Edge> anEdgeToTEgeMap;
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
{
aPS.Next();
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <TopTools_SequenceOfShape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepCheck_Face,BRepCheck_Result)
//#include <BRepAdaptor_Curve2d.hxx>
//#include <Geom2dInt_GInter.hxx>
-typedef NCollection_DataMap<TopoDS_Shape, Bnd_Box2d, TopTools_OrientedShapeMapHasher> DataMapOfShapeBox2d;
+typedef NCollection_DataMap<TopoDS_Shape, Bnd_Box2d> DataMapOfShapeBox2d;
static Standard_Boolean Intersect(const TopoDS_Wire&,
const TopoDS_Wire&,
#include <TopoDS_Shape.hxx>
#include <BRepCheck_Result.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TopoDS_Shape,Handle(BRepCheck_Result),TopTools_OrientedShapeMapHasher> BRepCheck_IndexedDataMapOfShapeResult;
+typedef NCollection_IndexedDataMap<TopoDS_Shape,Handle(BRepCheck_Result)> BRepCheck_IndexedDataMapOfShapeResult;
#endif
return BRC_Trace;
}
-void PrintShape(const TopoDS_Shape& theShape, const Standard_Integer upper) {
+void PrintShape(const TopoDS_Shape& theShape) {
if (!theShape.IsNull()) {
- Standard_Integer code = theShape.HashCode(upper);
+ size_t code = TopTools_ShapeMapHasher{}(theShape);
std::cout << TopAbs::ShapeTypeToString (theShape.ShapeType()) << " : " << code
<< " " << TopAbs::ShapeOrientationToString(theShape.Orientation()) << std::endl;
}
#define BRepClass3d_MapOfInter_HeaderFile
#include <TopoDS_Shape.hxx>
-#include <Standard_Address.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
#include <MAT_Node.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(MAT_Node),TopTools_DataMapOfShapeShape,TColStd_MapTransientHasher> BRepFill_DataMapOfNodeDataMapOfShapeShape;
-typedef NCollection_DataMap<Handle(MAT_Node),TopTools_DataMapOfShapeShape,TColStd_MapTransientHasher>::Iterator BRepFill_DataMapIteratorOfDataMapOfNodeDataMapOfShapeShape;
+typedef NCollection_DataMap<Handle(MAT_Node),TopTools_DataMapOfShapeShape> BRepFill_DataMapOfNodeDataMapOfShapeShape;
+typedef NCollection_DataMap<Handle(MAT_Node),TopTools_DataMapOfShapeShape>::Iterator BRepFill_DataMapIteratorOfDataMapOfNodeDataMapOfShapeShape;
#endif
#include <MAT_Node.hxx>
#include <TopoDS_Shape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(MAT_Node),TopoDS_Shape,TColStd_MapTransientHasher> BRepFill_DataMapOfNodeShape;
-typedef NCollection_DataMap<Handle(MAT_Node),TopoDS_Shape,TColStd_MapTransientHasher>::Iterator BRepFill_DataMapIteratorOfDataMapOfNodeShape;
+typedef NCollection_DataMap<Handle(MAT_Node),TopoDS_Shape> BRepFill_DataMapOfNodeShape;
+typedef NCollection_DataMap<Handle(MAT_Node),TopoDS_Shape>::Iterator BRepFill_DataMapIteratorOfDataMapOfNodeShape;
#endif
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TopoDS_Shape,TopTools_ListOfShape,TopTools_OrientedShapeMapHasher> BRepFill_DataMapOfOrientedShapeListOfShape;
-typedef NCollection_DataMap<TopoDS_Shape,TopTools_ListOfShape,TopTools_OrientedShapeMapHasher>::Iterator BRepFill_DataMapIteratorOfDataMapOfOrientedShapeListOfShape;
+typedef NCollection_DataMap<TopoDS_Shape,TopTools_ListOfShape> BRepFill_DataMapOfOrientedShapeListOfShape;
+typedef NCollection_DataMap<TopoDS_Shape,TopTools_ListOfShape>::Iterator BRepFill_DataMapIteratorOfDataMapOfOrientedShapeListOfShape;
#endif
TopTools_ListIteratorOfListOfShape itl;
for (itl.Initialize(GenShapes); itl.More(); itl.Next()) {
- itl.Value().Move(LS);
+ itl.ChangeValue().Move(LS);
}
if (!myMap.IsBound(InitialSpine)) {
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TopoDS_Shape,TopTools_ListOfShape,TopTools_OrientedShapeMapHasher> BRepFill_IndexedDataMapOfOrientedShapeListOfShape;
+typedef NCollection_IndexedDataMap<TopoDS_Shape,TopTools_ListOfShape> BRepFill_IndexedDataMapOfOrientedShapeListOfShape;
#endif
{
const TopTools_ListOfShape& listSh = aSubst.Copy(itl.Value());
TopAbs_Orientation SaveOr = itl.Value().Orientation();
- itl.Value() = listSh.First();
- itl.Value().Orientation(SaveOr);
+ itl.ChangeValue() = listSh.First();
+ itl.ChangeValue().Orientation(SaveOr);
}
}
}
((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
while (itcr.More()) {
- Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+ Handle(BRep_CurveRepresentation) cr = itcr.Value();
if (cr->IsCurveOnSurface(S,l)) {
Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (cr));
if (GC->IsCurveOnClosedSurface() && Eisreversed)
#include <NCollection_Handle.hxx>
#include <NCollection_Array1.hxx>
-class math_Vector;
+template<typename T> class math_VectorBase;
+using math_Vector = math_VectorBase<double>;
//! Class performs computing of the global inertia properties
//! of geometric object in 3D space by adaptive and non-adaptive
#include <Standard_DefineAlloc.hxx>
#include <GProp_GProps.hxx>
-#include <Standard_Address.hxx>
class BRepGProp_Face;
class BRepGProp_Domain;
class gp_Pln;
#include <BRepTools_ReShape.hxx>
#include <TopTools_DataMapOfShapeReal.hxx>
#include <TopoDS_LockedShape.hxx>
+#include <Standard_HashUtils.hxx>
#include <algorithm>
TopTools_ListIteratorOfListOfShape It;
TopExp_Explorer Ex;
TopoDS_Face F1,F2;
- Standard_Boolean found;
for (Standard_Integer i = 1; i <= M.Extent(); i++){
TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
if (!theEdgesToEncode.IsEmpty())
continue;
}
- found = Standard_False;
+ Standard_Boolean found = Standard_False;
F1.Nullify();
for (It.Initialize(M.FindFromIndex(i)); It.More() && !found; It.Next()){
if (F1.IsNull()) { F1 = TopoDS::Face(It.Value()); }
Node[1] = theNode2;
}
- //! Computes a hash code for the this link
- Standard_Integer HashCode (const Standard_Integer theUpperBound) const
- {
- return ::HashCode (Node[0] + Node[1], theUpperBound);
- }
-
//! Returns true if this link has the same nodes as the other.
Standard_Boolean IsEqual (const Link& theOther) const
{
return IsEqual (theOther);
}
};
+}
- //! Computes a hash code for the given link
- inline Standard_Integer HashCode (const Link& theLink, const Standard_Integer theUpperBound)
+namespace std
+{
+ template <>
+ struct hash<Link>
{
- return theLink.HashCode (theUpperBound);
- }
+ size_t operator()(const Link& theLink) const noexcept
+ {
+ int aCombination[2]{ theLink.Node[0], theLink.Node[1] };
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
}
void BRepLib::UpdateDeflection (const TopoDS_Shape& theShape)
// of addition, thus sort the coordinates for stable result
Standard_Integer i;
NCollection_Array1<gp_Pnt> aPoints(0, aNb-1);
- NCollection_List<TopoDS_Edge>::Iterator aIt(theLV);
+ NCollection_List<TopoDS_Shape>::Iterator aIt(theLV);
for (i = 0; aIt.More(); aIt.Next(), ++i) {
const TopoDS_Vertex& aVi = *((TopoDS_Vertex*)(&aIt.Value()));
gp_Pnt aPi = BRep_Tool::Pnt(aVi);
iter.Next();
for (; iter.More(); iter.Next())
{
- TopoDS_Edge& E = TopoDS::Edge(iter.Value());
+ const TopoDS_Edge& E = TopoDS::Edge(iter.Value());
Standard_Real first, last;
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface( E, Surf, loc, first, last );
Handle(Geom2d_BoundedCurve) BC = Handle(Geom2d_BoundedCurve)::DownCast(C);
if (IsNewEdge)
{
TopoDS_Shape NewE = aCE.EmptyCopied();
- NCollection_List<TopoDS_Edge>::Iterator it(aVList);
+ NCollection_List<TopoDS_Vertex>::Iterator it(aVList);
for (; it.More(); it.Next())
aBB.Add(NewE, it.Value());
theNewEList.Append(TopoDS::Edge(NewE));
#include <MAT_BasicElt.hxx>
#include <TopoDS_Shape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(MAT_BasicElt),TopoDS_Shape,TColStd_MapTransientHasher> BRepMAT2d_DataMapOfBasicEltShape;
-typedef NCollection_DataMap<Handle(MAT_BasicElt),TopoDS_Shape,TColStd_MapTransientHasher>::Iterator BRepMAT2d_DataMapIteratorOfDataMapOfBasicEltShape;
+typedef NCollection_DataMap<Handle(MAT_BasicElt),TopoDS_Shape> BRepMAT2d_DataMapOfBasicEltShape;
+typedef NCollection_DataMap<Handle(MAT_BasicElt),TopoDS_Shape>::Iterator BRepMAT2d_DataMapIteratorOfDataMapOfBasicEltShape;
#endif
#include <Standard.hxx>
#include <BRepMesh_DegreeOfFreedom.hxx>
#include <BRepMesh_OrientedEdge.hxx>
+#include <Standard_HashUtils.hxx>
//! Light weighted structure representing link of the mesh.
class BRepMesh_Edge : public BRepMesh_OrientedEdge
BRepMesh_DegreeOfFreedom myMovability;
};
-//! Computes a hash code for the given edge, in the range [1, theUpperBound]
-//! @param theEdge the edge 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]
-inline Standard_Integer HashCode (const BRepMesh_Edge& theEdge, const Standard_Integer theUpperBound)
+namespace std
{
- return theEdge.HashCode (theUpperBound);
+ template <>
+ struct hash<BRepMesh_Edge>
+ {
+ size_t operator()(const BRepMesh_Edge& theEdge) const noexcept
+ {
+ union Combination
+ {
+ unsigned short Arr[2]; // Node can be represented as a short
+ uint32_t Hash;
+
+ } aCombination;
+ aCombination.Arr[0] = static_cast<unsigned short>(theEdge.FirstNode());
+ aCombination.Arr[1] = static_cast<unsigned short>(theEdge.LastNode());
+ if (aCombination.Arr[0] > aCombination.Arr[1])
+ {
+ std::swap(aCombination.Arr[0], aCombination.Arr[1]);
+ }
+ return static_cast<size_t>(aCombination.Hash);
+ }
+ };
}
#endif
#define _BRepMesh_OrientedEdge_HeaderFile
#include <Standard.hxx>
+#include <Standard_HashUtils.hxx>
#include <Standard_DefineAlloc.hxx>
//! Light weighted structure representing simple link.
return myLastNode;
}
- //! Computes a hash code for this oriented edge, in the range [1, theUpperBound]
- //! @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]
- Standard_Integer HashCode (const Standard_Integer theUpperBound) const
- {
- return ::HashCode (myFirstNode + myLastNode, theUpperBound);
- }
-
//! Checks this and other edge for equality.
//! @param theOther edge to be checked against this one.
//! @return TRUE if edges have the same orientation, FALSE if not.
Standard_Integer myLastNode;
};
-//! Computes a hash code for the given oriented edge, in the range [1, theUpperBound]
-//! @param theOrientedEdge the oriented edge 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]
-inline Standard_Integer HashCode (const BRepMesh_OrientedEdge& theOrientedEdge, const Standard_Integer theUpperBound)
+namespace std
{
- return theOrientedEdge.HashCode (theUpperBound);
+ template <>
+ struct hash<BRepMesh_OrientedEdge>
+ {
+ size_t operator()(const BRepMesh_OrientedEdge& theOrientedEdge) const noexcept
+ {
+ union Combination
+ {
+ unsigned short Arr[2]; // Node can be represented as a short
+ uint32_t Hash;
+
+ } aCombination;
+ aCombination.Arr[0] = static_cast<unsigned short>(theOrientedEdge.FirstNode());
+ aCombination.Arr[1] = static_cast<unsigned short>(theOrientedEdge.LastNode());
+ return static_cast<size_t>(aCombination.Hash);
+ }
+ };
}
#endif
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
+#include <Standard_HashUtils.hxx>
#include <BRepMesh_DegreeOfFreedom.hxx>
myMovability = theMovability;
}
- //! Computes a hash code for this triangle, in the range [1, theUpperBound]
- //! @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]
- Standard_Integer HashCode (const Standard_Integer theUpperBound) const
- {
- return ::HashCode (myEdges[0] + myEdges[1] + myEdges[2], theUpperBound);
- }
-
//! Checks for equality with another triangle.
//! @param theOther triangle to be checked against this one.
//! @return TRUE if equal, FALSE if not.
BRepMesh_DegreeOfFreedom myMovability;
};
-//! Computes a hash code for the given triangle, in the range [1, theUpperBound]
-//! @param theTriangle the triangle 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]
-inline Standard_Integer HashCode (const BRepMesh_Triangle& theTriangle, const Standard_Integer theUpperBound)
+namespace std
{
- return theTriangle.HashCode (theUpperBound);
+ template <>
+ struct hash<BRepMesh_Triangle>
+ {
+ size_t operator()(const BRepMesh_Triangle& theTriangle) const noexcept
+ {
+ int aCombination[3] = { theTriangle.myEdges[0], theTriangle.myEdges[1], theTriangle.myEdges[2] };
+ std::sort(aCombination, aCombination + 3); // Sort the numbers in ascending order
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
}
#endif
{
myMovability = theMovability;
}
-
- //! Computes a hash code for this vertex, in the range [1, theUpperBound]
- //! @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]
- Standard_Integer HashCode(const Standard_Integer theUpperBound) const
- {
- return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), theUpperBound);
- }
//! Checks for equality with another vertex.
//! @param theOther vertex to be checked against this one.
BRepMesh_DegreeOfFreedom myMovability;
};
-//! Computes a hash code for the given vertex, in the range [1, theUpperBound]
-//! @param theVertex the vertex 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]
-inline Standard_Integer HashCode (const BRepMesh_Vertex& theVertex, const Standard_Integer theUpperBound)
+namespace std
{
- return theVertex.HashCode (theUpperBound);
+ template <>
+ struct hash<BRepMesh_Vertex>
+ {
+ size_t operator()(const BRepMesh_Vertex& theVertex) const noexcept
+ {
+ return std::hash<double>{}((Floor(1e5 * theVertex.Coord().X()) * Floor(1e5 * theVertex.Coord().Y())));
+ }
+ };
}
#endif
// Purpose :
//=======================================================================
BRepMeshData_Curve::BRepMeshData_Curve (const Handle (NCollection_IncAllocator)& theAllocator)
-: myPoints (NCollection_StdAllocator<gp_Pnt>(theAllocator)),
- myParameters (NCollection_StdAllocator<Standard_Real>(theAllocator))
+: myPoints (NCollection_OccAllocator<gp_Pnt>(theAllocator)),
+ myParameters (NCollection_OccAllocator<Standard_Real>(theAllocator))
{
}
myDFaces (256, myAllocator),
myDEdges (256, myAllocator)
{
- myAllocator->SetThreadSafe();
+ myAllocator->SetThreadSafe(true);
}
//=======================================================================
const IMeshData::IFaceHandle& BRepMeshData_Model::AddFace (const TopoDS_Face& theFace)
{
IMeshData::IFaceHandle aFace (new (myAllocator) BRepMeshData_Face (theFace, myAllocator));
- myDFaces.Append (aFace);
- return myDFaces (FacesNb () - 1);
+ return myDFaces.Append (aFace);
}
//=======================================================================
const IMeshData::IEdgeHandle& BRepMeshData_Model::AddEdge (const TopoDS_Edge& theEdge)
{
IMeshData::IEdgeHandle aEdge (new (myAllocator) BRepMeshData_Edge (theEdge, myAllocator));
- myDEdges.Append (aEdge);
- return myDEdges (EdgesNb () - 1);
+ return myDEdges.Append (aEdge);
}
//=======================================================================
const TopAbs_Orientation theOrientation,
const Handle (NCollection_IncAllocator)& theAllocator)
: IMeshData_PCurve (theDFace, theOrientation),
- myPoints2d (NCollection_StdAllocator<gp_Pnt2d>(theAllocator)),
- myParameters (NCollection_StdAllocator<Standard_Real>(theAllocator)),
- myIndices (NCollection_StdAllocator<Standard_Integer>(theAllocator))
+ myPoints2d (NCollection_OccAllocator<gp_Pnt2d>(theAllocator)),
+ myParameters (NCollection_OccAllocator<Standard_Real>(theAllocator)),
+ myIndices (NCollection_OccAllocator<Standard_Integer>(theAllocator))
{
}
const TopoDS_Shape& aFR = aItLR.Value();
// Reset the local allocator
- anAllocLoc->Reset();
+ anAllocLoc->Reset(false);
// Find the last splits of the root face, including the ones
// created during MakeVolume operation
TopTools_ListOfShape aLFIm(anAllocLoc);
}
// Reset the local allocator
- anAllocLoc->Reset();
+ anAllocLoc->Reset(false);
// It is necessary to rebuild the solids, avoiding internal faces
// Map faces to solids
TopTools_IndexedDataMapOfShapeListOfShape aDMFS(1, anAllocLoc);
//
aLF.Clear();
aDMFS.Clear();
- anAllocLoc->Reset();
+ anAllocLoc->Reset(true);
// the result is non-manifold - resolve it comparing normal
// directions of the offset faces and original faces
// Useful only for faces without influence on others.
TopTools_ListIteratorOfListOfShape it(myGenerated);
for (; it.More(); it.Next())
- it.Value().Reverse();
+ it.ChangeValue().Reverse();
}
}
break;
// Useful only for faces without influence on others.
TopTools_ListIteratorOfListOfShape it(myGenerated);
for (; it.More(); it.Next())
- it.Value().Reverse();
+ it.ChangeValue().Reverse();
}
}
}
#define _BRepOffset_SimpleOffset_HeaderFile
#include <BRepTools_Modification.hxx>
-#include <GeomAbs_Shape.hxx>
#include <Geom2d_Curve.hxx>
-#include <Standard_Real.hxx>
+#include <GeomAbs_Shape.hxx>
+#include <NCollection_DataMap.hxx>
#include <Standard_Macro.hxx>
+#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <NCollection_DataMap.hxx>
class BRepOffset_SimpleOffset;
// BRepTopAdaptor_FClass2d FC (TopoDS::Face(FI.Oriented(TopAbs_FORWARD)),
// Precision::Confusion());
for (itE.Initialize(LOE); itE.More(); itE.Next()) {
- TopoDS_Shape& OE = itE.Value();
+ TopoDS_Shape& OE = itE.ChangeValue();
if (NewEdges.Contains(OE)) {
Handle(Geom2d_Curve) CO2d =
BRep_Tool::CurveOnSurface(TopoDS::Edge(OE),OF,f,l);
//====================================================
TopTools_ListIteratorOfListOfShape itl(WorkWires);
for (; itl.More(); itl.Next()) {
- TopoDS_Wire& W = TopoDS::Wire(itl.Value());
+ TopoDS_Wire& W = TopoDS::Wire(itl.ChangeValue());
if (W.Closed()){
FR.Add(W);
continue;
// for (TopTools_ListIteratorOfListOfShape itF(Faces); itF.More(); itF.Next()) {
TopTools_ListIteratorOfListOfShape itF;
for (itF.Initialize(Faces) ; itF.More(); itF.Next()) {
- TopoDS_Face& F = TopoDS::Face(itF.Value());
+ TopoDS_Face& F = TopoDS::Face(itF.ChangeValue());
BRepAdaptor_Surface S(F,0);
Standard_Real Tol = BRep_Tool::Tolerance(F);
TopTools_ListIteratorOfListOfShape itW(LOW);
while (itW.More()) {
- TopoDS_Wire& W = TopoDS::Wire(itW.Value());
+ const TopoDS_Wire& W = TopoDS::Wire(itW.Value());
//=======================================================
// Choice of a point on the wire. + projection on the face.
//=======================================================
for (itOW.Initialize(myLeft); itOW.More(); itOW.Next())
{
- BRepFill_OffsetWire& Algo = itOW.Value();
+ BRepFill_OffsetWire& Algo = itOW.ChangeValue();
Algo.Perform(Abs(Offset),Alt);
if (Algo.IsDone() && !Algo.Shape().IsNull())
{
for(itOW.Initialize(myRight); itOW.More(); itOW.Next())
{
- BRepFill_OffsetWire& Algo = itOW.Value();
+ BRepFill_OffsetWire& Algo = itOW.ChangeValue();
Algo.Perform(Offset,Alt);
if (Algo.IsDone() && !Algo.Shape().IsNull())
Algos = &myRight;
}
for (itOW.Initialize(*Algos); itOW.More(); itOW.Next()) {
- BRepFill_OffsetWire& OW = itOW.Value();
+ BRepFill_OffsetWire& OW = itOW.ChangeValue();
TopTools_ListOfShape L;
L = OW.GeneratedShapes(S.Oriented(TopAbs_FORWARD));
myGenerated.Append(L);
// Useful only for faces without influence on others.
TopTools_ListIteratorOfListOfShape it(myGenerated);
for (; it.More(); it.Next())
- it.Value().Reverse();
+ it.ChangeValue().Reverse();
}
}
else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
#include <BRepPrim_Revolution.hxx>
#include <BRepPrimAPI_MakeOneAxis.hxx>
-#include <Standard_Address.hxx>
class Geom_Curve;
class gp_Ax2;
#include <PLib.hxx>
#include <Precision.hxx>
#include <Standard_NotImplemented.hxx>
+#include <math_Vector.hxx>
typedef gp_Pnt Pnt;
typedef gp_Vec Vec;
#include <Standard_Type.hxx>
#include <BinMDF_ADriver.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(Standard_Type),Handle(BinMDF_ADriver),TColStd_MapTransientHasher> BinMDF_TypeADriverMap;
-typedef NCollection_DataMap<Handle(Standard_Type),Handle(BinMDF_ADriver),TColStd_MapTransientHasher>::Iterator BinMDF_DataMapIteratorOfTypeADriverMap;
+typedef NCollection_DataMap<Handle(Standard_Type),Handle(BinMDF_ADriver)> BinMDF_TypeADriverMap;
+typedef NCollection_DataMap<Handle(Standard_Type),Handle(BinMDF_ADriver)>::Iterator BinMDF_DataMapIteratorOfTypeADriverMap;
#endif
#include <Standard_Type.hxx>
#include <Standard_Integer.hxx>
-#include <TColStd_MapTransientHasher.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<Handle(Standard_Type),Standard_Integer,TColStd_MapTransientHasher,TColStd_MapIntegerHasher> BinMDF_TypeIdMap;
-typedef NCollection_DoubleMap<Handle(Standard_Type),Standard_Integer,TColStd_MapTransientHasher,TColStd_MapIntegerHasher>::Iterator BinMDF_DoubleMapIteratorOfTypeIdMap;
+typedef NCollection_DoubleMap<Handle(Standard_Type),Standard_Integer> BinMDF_TypeIdMap;
+typedef NCollection_DoubleMap<Handle(Standard_Type),Standard_Integer>::Iterator BinMDF_DoubleMapIteratorOfTypeIdMap;
#endif
if (myIsQuickPart) // enables direct writing of shapes to the stream
aDirectStream = theTarget.GetOStream();
- Standard_Integer i = 1;
for (TNaming_Iterator SIterator(aSAtt); SIterator.More(); SIterator.Next()) {
const TopoDS_Shape& anOldShape = SIterator.OldShape();
const TopoDS_Shape& aNewShape = SIterator.NewShape();
else
TranslateTo (aNewShape, theTarget, static_cast<BinTools_ShapeSet*>(aShapeSet));
}
-
- i++;
}
}
#include <BinObjMgt_Position.hxx>
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
-#include <Standard_Address.hxx>
class TCollection_AsciiString;
class TCollection_ExtendedString;
class TDF_Label;
#ifndef BinTObjDrivers_HeaderFile
#define BinTObjDrivers_HeaderFile
-#include <TObj_Common.hxx>
#include <Standard_GUID.hxx>
class BinMDF_ADriverTable;
#ifndef BinTObjDrivers_DocumentRetrievalDriver_HeaderFile
#define BinTObjDrivers_DocumentRetrievalDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinLDrivers_DocumentRetrievalDriver.hxx>
#include <BinMDF_ADriverTable.hxx>
#ifndef BinTObjDrivers_DocumentStorageDriver_HeaderFile
#define BinTObjDrivers_DocumentStorageDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinLDrivers_DocumentStorageDriver.hxx>
#include <BinMDF_ADriverTable.hxx>
#ifndef BinTObjDrivers_IntSparseArrayDriver_HeaderFile
#define BinTObjDrivers_IntSparseArrayDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinMDF_ADriver.hxx>
class BinTObjDrivers_IntSparseArrayDriver : public BinMDF_ADriver
#ifndef BinTObjDrivers_ModelDriver_HeaderFile
#define BinTObjDrivers_ModelDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinMDF_ADriver.hxx>
class BinTObjDrivers_ModelDriver : public BinMDF_ADriver
#ifndef BinTObjDrivers_ObjectDriver_HeaderFile
#define BinTObjDrivers_ObjectDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinMDF_ADriver.hxx>
class BinTObjDrivers_ObjectDriver : public BinMDF_ADriver
#ifndef BinTObjDrivers_ReferenceDriver_HeaderFile
#define BinTObjDrivers_ReferenceDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinMDF_ADriver.hxx>
class BinTObjDrivers_ReferenceDriver : public BinMDF_ADriver
#ifndef BinTObjDrivers_XYZDriver_HeaderFile
#define BinTObjDrivers_XYZDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <BinMDF_ADriver.hxx>
class BinTObjDrivers_XYZDriver : public BinMDF_ADriver
// commercial license or contractual agreement.
#include <BinTools_ShapeReader.hxx>
-#include <TopoDS.hxx>
+
+#include <BinTools_Curve2dSet.hxx>
+#include <BinTools_CurveSet.hxx>
+#include <BinTools_SurfaceSet.hxx>
+#include <BRep_Builder.hxx>
#include <BRep_PointOnCurve.hxx>
#include <BRep_PointOnCurveOnSurface.hxx>
#include <BRep_PointOnSurface.hxx>
-#include <BRep_Builder.hxx>
-#include <BinTools_CurveSet.hxx>
-#include <BinTools_Curve2dSet.hxx>
-#include <BinTools_SurfaceSet.hxx>
+#include <TopoDS.hxx>
//=======================================================================
//function : BinTools_ShapeReader
#include <BinTools_ShapeSetBase.hxx>
#include <BinTools_IStream.hxx>
#include <NCollection_DataMap.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Shape.hxx>
-class TopLoc_Location;
class Geom_Curve;
-class Geom2d_Curve;
class Geom_Surface;
+class Geom2d_Curve;
class Poly_Polygon3D;
class Poly_PolygonOnTriangulation;
class Poly_Triangulation;
BinTools_SurfaceSet mySurfaces;
BinTools_CurveSet myCurves;
BinTools_Curve2dSet myCurves2d;
- NCollection_IndexedMap<Handle(Poly_Polygon2D), TColStd_MapTransientHasher> myPolygons2D;
- NCollection_IndexedMap<Handle(Poly_Polygon3D), TColStd_MapTransientHasher> myPolygons3D;
+ NCollection_IndexedMap<Handle(Poly_Polygon2D)> myPolygons2D;
+ NCollection_IndexedMap<Handle(Poly_Polygon3D)> myPolygons3D;
NCollection_IndexedDataMap<Handle(Poly_Triangulation),
Standard_Boolean> myTriangulations; //!< Contains a boolean flag with information
//! to save normals for triangulation
- NCollection_IndexedMap<Handle(Poly_PolygonOnTriangulation), TColStd_MapTransientHasher> myNodes;
+ NCollection_IndexedMap<Handle(Poly_PolygonOnTriangulation)> myNodes;
};
#endif // _BinTools_ShapeSet_HeaderFile
//! Writes to the stream a gp_Pnt data
Standard_OStream& operator << (Standard_OStream& OS, const gp_Pnt& P);
-//! Computes a hash code for the given value of the uint64_t type, in range [1, theUpperBound]
-inline Standard_Integer HashCode (const uint64_t theValue, const Standard_Integer theUpperBound)
-{
- return IntegerHashCode(theValue, 0xffffffffffffffff, theUpperBound);
-}
-
//! A base class for all readers/writers of TopoDS_Shape into/from stream.
class BinTools_ShapeSetBase
{
#include <BinTools_ShapeSetBase.hxx>
#include <BinTools_OStream.hxx>
-#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
#include <TopTools_ShapeMapHasher.hxx>
class Geom_Curve;
#include <Standard_Integer.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
-#include <Standard_Address.hxx>
class gp_Pln;
myVMin(VMin),
myVMax(VMax),
myCoordIndx(CoordIndx),
- mySign(Sign)
+ mySign(Sign),
+ myPenalty(0.)
{
math_Vector X(1,2);
X(1) = UMin;
const TCollection_ExtendedString& aName)
{
TCollection_ExtendedString ff(aFolder);
- ff = "";
- ff += aFolder;
PutSlash(ff);
ff+=aName;
return ff;
+++ /dev/null
-// Created on: 1997-05-06
-// Created by: Jean-Louis Frenkel, Remi Lequette
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-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 CDM_DocumentHasher_HeaderFile
-#define CDM_DocumentHasher_HeaderFile
-
-#include <CDM_Document.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Handle(CDM_Document)> CDM_DocumentHasher;
-
-
-#endif
#ifndef CDM_MapOfDocument_HeaderFile
#define CDM_MapOfDocument_HeaderFile
-#include <CDM_DocumentHasher.hxx>
+#include <CDM_Document.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Handle(CDM_Document),CDM_DocumentHasher> CDM_MapOfDocument;
-typedef NCollection_Map<Handle(CDM_Document),CDM_DocumentHasher>::Iterator CDM_MapIteratorOfMapOfDocument;
+typedef NCollection_Map<Handle(CDM_Document)> CDM_MapOfDocument;
+typedef NCollection_Map<Handle(CDM_Document)>::Iterator CDM_MapIteratorOfMapOfDocument;
#endif
#include <NCollection_DataMap.hxx>
class CDM_MetaData;
-typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_MetaData),TCollection_ExtendedString> CDM_MetaDataLookUpTable;
-typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_MetaData),TCollection_ExtendedString>::Iterator CDM_DataMapIteratorOfMetaDataLookUpTable;
+typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_MetaData)> CDM_MetaDataLookUpTable;
+typedef NCollection_DataMap<TCollection_ExtendedString,Handle(CDM_MetaData)>::Iterator CDM_DataMapIteratorOfMetaDataLookUpTable;
#endif
CDM_DataMapIteratorOfMetaDataLookUpTable.hxx
CDM_Document.cxx
CDM_Document.hxx
-CDM_DocumentHasher.hxx
CDM_DocumentPointer.hxx
CDM_ListIteratorOfListOfDocument.hxx
CDM_ListIteratorOfListOfReferences.hxx
itel.Value()->Spine()->SetErrorStatus(ChFiDS_Ok);
try {
OCC_CATCH_SIGNALS
- PerformSetOfSurf(itel.Value());
+ PerformSetOfSurf(itel.ChangeValue());
}
catch(Standard_Failure const& anException) {
#ifdef OCCT_DEBUG
}
if (!hasresult) {
B1.MakeCompound(TopoDS::Compound(myShapeResult));
- for(It.Reset(); It.More(); It.Next()){
+ for(It = TColStd_MapIteratorOfMapOfInteger(MapIndSo); It.More(); It.Next()){
Standard_Integer indsol = It.Key();
const TopoDS_Shape& curshape = DStr.Shape(indsol);
TopTools_ListIteratorOfListOfShape
else {
done=Standard_False;
B1.MakeCompound(TopoDS::Compound(badShape));
- for(It.Reset(); It.More(); It.Next()){
+ for(It = TColStd_MapIteratorOfMapOfInteger(MapIndSo); It.More(); It.Next()){
Standard_Integer indsol = It.Key();
const TopoDS_Shape& curshape = DStr.Shape(indsol);
TopTools_ListIteratorOfListOfShape
#ifdef OCCT_DEBUG
if(ChFi3d_GettraceCHRON()) elspine.Start();
#endif
- ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp);
+ ChFi3d_PerformElSpine(ILES.ChangeValue(),Spine,myConti,tolesp);
#ifdef OCCT_DEBUG
if(ChFi3d_GettraceCHRON()) { elspine.Stop(); }
#endif
{
ChFiDS_ListOfHElSpine& offsetll = Spine->ChangeOffsetElSpines();
for (ILES.Initialize(offsetll); ILES.More(); ILES.Next())
- ChFi3d_PerformElSpine(ILES.Value(),Spine,myConti,tolesp,Standard_True);
+ ChFi3d_PerformElSpine(ILES.ChangeValue(),Spine,myConti,tolesp,Standard_True);
}
Spine->SplitDone(Standard_True);
}
ChFiDS_ListIteratorOfListOfStripe It;
It.Initialize(myVDataMap(Index));
- Handle(ChFiDS_Stripe)& stripe = It.Value();
+ Handle(ChFiDS_Stripe)& stripe = It.ChangeValue();
ChFiDS_SequenceOfSurfData& SeqFil =
stripe->ChangeSetOfSurfData()->ChangeSequence();
const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
//----------
ChFiDS_ListIteratorOfListOfStripe It;
It.Initialize(myVDataMap(Index));
- Handle(ChFiDS_Stripe)& Corner1 = It.Value();
+ Handle(ChFiDS_Stripe)& Corner1 = It.ChangeValue();
Standard_Integer Sens1;
Standard_Integer IFd1 =
ChFi3d_IndexOfSurfData(Vtx,Corner1,Sens1);
//the second
//----------
It.Next();
- Handle(ChFiDS_Stripe)& Corner2 = It.Value();
+ Handle(ChFiDS_Stripe)& Corner2 = It.ChangeValue();
Standard_Integer Sens2;
Standard_Integer IFd2;
if(Corner2 == Corner1) {
// tolesp = Precision::Infinite();
for (itel.Initialize(myListStripe); itel.More(); itel.Next())
{
- Handle(ChFiDS_Stripe)& curStripe = itel.Value();
+ Handle(ChFiDS_Stripe)& curStripe = itel.ChangeValue();
Handle(ChFiDS_Spine)& Spine = curStripe->ChangeSpine();
const Standard_Real current_stripe_tolesp = Spine->GetTolesp();
if (tolesp > current_stripe_tolesp)
CpOnEdge (It.Value(),i,isfirst,Eadj1,Eadj2,compoint);
if (compoint) ind=i;
}
- if (ind>=2) RemoveSD(It.Value(),1,ind-1);
+ if (ind>=2) RemoveSD(It.ChangeValue(),1,ind-1);
}
else {
ind=num;
CpOnEdge (It.Value(),i,isfirst,Eadj1,Eadj2,compoint);
if (compoint) ind=i;
}
- if (ind<num) RemoveSD(It.Value(),ind+1,num);
+ if (ind<num) RemoveSD(It.ChangeValue(),ind+1,num);
}
}
}
Standard_Integer i = 1;
for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
if(i == IC){
- PerformSetOfSurf(itel.Value(), Standard_True);
+ PerformSetOfSurf(itel.ChangeValue(), Standard_True);
break;
}
}
Standard_Integer i = 1;
for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
if(i == IC){
- PerformSetOfSurf(itel.Value(), Standard_True);
+ PerformSetOfSurf(itel.ChangeValue(), Standard_True);
break;
}
}
ChFiDS_ListIteratorOfListOfHElSpine It(elspines);
Law_ListIteratorOfLaws Itl(laws);
Handle(ChFiDS_ElSpine) Els = It.Value();
- if (Els->IsPeriodic()) Itl.Value() = ComputeLaw(Els);
+ if (Els->IsPeriodic()) Itl.ChangeValue() = ComputeLaw(Els);
else{
for (; It.More(); It.Next(), Itl.Next()) {
Els = It.Value();
Standard_Real uf = Els->FirstParameter();
Standard_Real ul = Els->LastParameter();
if(uf <= W && W <= ul) {
- Itl.Value() = ComputeLaw(Els);
+ Itl.ChangeValue() = ComputeLaw(Els);
}
}
}
#include <Standard_Integer.hxx>
#include <Adaptor2d_Curve2d.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(Adaptor2d_Curve2d),TColStd_MapIntegerHasher> ChFiKPart_RstMap;
-typedef NCollection_DataMap<Standard_Integer,Handle(Adaptor2d_Curve2d),TColStd_MapIntegerHasher>::Iterator ChFiKPart_DataMapIteratorOfRstMap;
+typedef NCollection_DataMap<Standard_Integer,Handle(Adaptor2d_Curve2d)> ChFiKPart_RstMap;
+typedef NCollection_DataMap<Standard_Integer,Handle(Adaptor2d_Curve2d)>::Iterator ChFiKPart_DataMapIteratorOfRstMap;
#endif
if (recompute)
myHidData.Remove(it);
else {
- it.Value().DrawOn(dis,myRg1,myRgN,myHid,
+ it.ChangeValue().DrawOn(dis,myRg1,myRgN,myHid,
myConnCol,myIsosCol);
if (dis.HasPicked()) {
pickshape = it.Value().LastPick();
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
-#include <NCollection_IndexedDataMap.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
-
// Providing consistency with intersection tolerance for the linear curves
static Standard_Real IntersectorConfusion = Precision::PConfusion();
static Standard_Real IntersectorTangency = Precision::PConfusion();
#include <NCollection_IndexedDataMap.hxx>
class TopoDS_Face;
class DBRep_Face;
-class TopTools_OrientedShapeMapHasher;
//! Creation of isoparametric curves.
class DBRep_IsoBuilder : public Geom2dHatch_Hatcher
protected:
typedef NCollection_IndexedDataMap
- <TopoDS_Shape, Handle(Geom2d_Curve), TopTools_OrientedShapeMapHasher>
+ <TopoDS_Shape, Handle(Geom2d_Curve)>
DataMapOfEdgePCurve;
//! Adds to the hatcher the 2D segments connecting the p-curves
#include <TDF_Transaction.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Integer.hxx>
+#include <NCollection_DefineAlloc.hxx>
class TDF_Data;
class TDF_Delta;
if (Standard_GUID::CheckGUIDFormat(arg[3]))
aGuid = Standard_GUID(arg[3]);
}
- if(Standard_GUID::IsEqual(aGuid, aNullGuid)) {
+ if(aGuid == aNullGuid) {
isdrawname = Standard_True;
aGuid = TDataStd_Integer::GetID();
}
if (Standard_GUID::CheckGUIDFormat(arg[3]))
aGuid = Standard_GUID(arg[3]);
}
- if(Standard_GUID::IsEqual(aGuid, aNullGuid)) {
+ if(aGuid == aNullGuid) {
isdrawname = Standard_True;
aGuid = TDataStd_Real::GetID();
}
n = aES.ToUTF8CString(aCstr);
anOS.write( (char*)&aCstr[0], n);
anOS.close();
+ Standard::Free(aCstr);
return 0;
}
di << "GetUTF : Data is not extracted to the specified file \n";
#include <NCollection_DataMap.hxx>
#include <TColStd_ListOfAsciiString.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString, TCollection_AsciiString> DE_ResourceMap;
+typedef NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> DE_ResourceMap;
//! Provides convenient interface to resource file
//! Allows loading of the resource file and getting attributes'
void DE_Wrapper::sort(const Handle(DE_ConfigurationContext)& theResource)
{
const TCollection_AsciiString aScope(THE_CONFIGURATION_SCOPE() + '.' + "priority");
- NCollection_List<Handle(DE_ConfigurationNode)> aVendors;
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
class XSControl_WorkSession;
class TDocStd_Document;
-typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode), TCollection_AsciiString> DE_ConfigurationVendorMap;
-typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap, TCollection_AsciiString> DE_ConfigurationFormatMap;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode)> DE_ConfigurationVendorMap;
+typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap> DE_ConfigurationFormatMap;
//! The main class for working with CAD file exchange.
//! Loads and Saves special CAD transfer property.
Standard_Integer theNbArgs,
const char** theArgVec)
{
- NCollection_IndexedMap<TCollection_AsciiString, TCollection_AsciiString> aPlugins;
+ NCollection_IndexedMap<TCollection_AsciiString> aPlugins;
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{
TCollection_AsciiString anArg (theArgVec[anArgIter]);
}
}
- for (NCollection_IndexedMap<TCollection_AsciiString, TCollection_AsciiString>::Iterator aPluginIter (aPlugins);
+ for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aPluginIter (aPlugins);
aPluginIter.More(); aPluginIter.Next())
{
const TCollection_AsciiString& aPlugin = aPluginIter.Value();
myItEd.Initialize(myEdges);
for (; myItEd.More(); myItEd.Next(),itp.Next()) {
if (myItEd.Value().IsSame(E)) {
- return itp.Value();
+ return itp.ChangeValue();
}
}
throw Standard_DomainError();
#include <NCollection_DataMap.hxx>
#include <Draw_Display.hxx>
+#include <Standard_CStringHasher.hxx>
#include <Standard_NotImplemented.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
//! Return the map of factory functions.
-static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t>& getFactoryMap()
+static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t, Standard_CStringHasher>& getFactoryMap()
{
- static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t> myToolMap;
+ static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t, Standard_CStringHasher> myToolMap;
return myToolMap;
}
#include <TCollection_AsciiString.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<TCollection_AsciiString,TCollection_AsciiString> Draw_MapOfAsciiString;
+typedef NCollection_IndexedMap<TCollection_AsciiString> Draw_MapOfAsciiString;
#endif
#include <Standard.hxx>
-#include <Standard_Address.hxx>
#include <DrawTrSurf_BSplineCurve2d.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard.hxx>
#include <DrawFairCurve_Batten.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#define Expr_MapOfNamedUnknown_HeaderFile
#include <Expr_NamedUnknown.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<Handle(Expr_NamedUnknown),TColStd_MapTransientHasher> Expr_MapOfNamedUnknown;
+typedef NCollection_IndexedMap<Handle(Expr_NamedUnknown)> Expr_MapOfNamedUnknown;
#endif
#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString, Handle(Express_Item),
- TCollection_AsciiString> Express_DataMapOfAsciiStringItem;
+typedef NCollection_DataMap<TCollection_AsciiString, Handle(Express_Item)> Express_DataMapOfAsciiStringItem;
#endif
private:
- typedef NCollection_DataMap<TCollection_AsciiString, Standard_Integer, TCollection_AsciiString> DataMapOfStringInteger;
+ typedef NCollection_DataMap<TCollection_AsciiString, Standard_Integer> DataMapOfStringInteger;
//! Create HXX/CXX files from item
Standard_EXPORT virtual Standard_Boolean GenerateClass() const Standard_OVERRIDE;
#include <Standard_Boolean.hxx>
-class math_Vector;
+template<typename T> class math_VectorBase;
+using math_Vector = math_VectorBase<double>;
//! Functional for search of extremum of the square Euclidean distance between point P and
//! surface S, starting from approximate solution (u0, v0).
for(i = Aux1->Upper() + 1; i <= Imax; i++) Coeff->SetValue(i, 0.);
Iter.Initialize(L);
for(i = 1; i < s1; Iter.Next(), i++);
- Iter.Value() = Coeff;
+ Iter.ChangeValue() = Coeff;
}
else if(Imin > Aux1->Upper() && Imax >= Aux2->Lower()) {
// merge new and first segment
for(i = Aux2->Lower(); i <= Aux2->Upper(); i++) Coeff->SetValue(i, Aux2->Value(i));
Iter.Initialize(L);
for(i = 1; i < s2; Iter.Next(), i++);
- Iter.Value() = Coeff;
+ Iter.ChangeValue() = Coeff;
}
else if(Imin > Aux1->Upper() && Imax < Aux2->Lower()) {
// inserting new between s1 and s2
for(i = Aux2->Lower(); i <= Aux2->Upper(); i++) Coeff->SetValue(i, Aux2->Value(i));
Iter.Initialize(L);
for(i = 1; i < s1; Iter.Next(), i++);
- Iter.Value() = Coeff;
+ Iter.ChangeValue() = Coeff;
Iter.Next();
L.Remove(Iter);
}
void Font_FontMgr::GetAvailableFontsNames (TColStd_SequenceOfHAsciiString& theFontsNames) const
{
theFontsNames.Clear();
- for (NCollection_IndexedMap<Handle(Font_SystemFont), Font_SystemFont>::Iterator aFontIter (myFontMap);
+ for (Font_FontMap::Iterator aFontIter (myFontMap);
aFontIter.More(); aFontIter.Next())
{
const Handle(Font_SystemFont)& aFont = aFontIter.Value();
{
return FindKey (1); // return any font
}
-
- TCollection_AsciiString aFontName (theFontName);
- aFontName.LowerCase();
- for (IndexedMapNode* aNodeIter = (IndexedMapNode* )myData1[::HashCode (aFontName, NbBuckets())];
- aNodeIter != NULL; aNodeIter = (IndexedMapNode* )aNodeIter->Next())
+ Handle(Font_SystemFont) aTmpFont = new Font_SystemFont(theFontName);
+ const int anInd = FindIndex(aTmpFont);
+ if (anInd > 0)
{
- const Handle(Font_SystemFont)& aKey = aNodeIter->Key1();
- if (aKey->FontKey().IsEqual (aFontName))
- {
- return aKey;
- }
+ return FindKey(anInd);
}
return Handle(Font_SystemFont)();
}
private:
+ struct FontHasher
+ {
+ size_t operator()(const Handle(Font_SystemFont)& theFont) const noexcept
+ {
+ return std::hash<TCollection_AsciiString>{}(theFont->FontKey());
+ }
+
+ bool operator()(const Handle(Font_SystemFont)& theFont1,
+ const Handle(Font_SystemFont)& theFont2) const
+ {
+ return theFont1->IsEqual(theFont2);
+ }
+ };
+
//! Map storing registered fonts.
- class Font_FontMap : public NCollection_IndexedMap<Handle(Font_SystemFont), Font_SystemFont>
+ class Font_FontMap : public NCollection_IndexedMap<Handle(Font_SystemFont), FontHasher>
{
public:
//! Empty constructor.
//! @param theFontName [in] font family to find (or empty string if family name can be ignored)
//! @return best match font or NULL if not found
Handle(Font_SystemFont) Find (const TCollection_AsciiString& theFontName) const;
-
- public:
- //! Computes a hash code for the system font, in the range [1, theUpperBound]. Based on Font Family, so that the
- //! whole family with different aspects can be found within the same bucket of some map
- //! @param theHExtendedString the handle referred to extended string 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 Handle (Font_SystemFont) & theSystemFont,
- const Standard_Integer theUpperBound)
- {
- return ::HashCode (theSystemFont->FontKey(), theUpperBound);
- }
-
- //! Matching two instances, for Map interface.
- static bool IsEqual (const Handle(Font_SystemFont)& theFont1,
- const Handle(Font_SystemFont)& theFont2)
- {
- return theFont1->IsEqual (theFont2);
- }
-
};
//! Structure defining font alias.
#include <Font_FontAspect.hxx>
#include <Standard.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
Standard_EXPORT TCollection_AsciiString ToString() const;
public:
- //! Computes a hash code for the system font, in the range [1, theUpperBound]. Based on Font Family, so that the whole
- //! family with different aspects can be found within the same bucket of some map
- //! @param theSystemFont the system font 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 Handle (Font_SystemFont) & theSystemFont, const Standard_Integer theUpperBound)
- {
- return ::HashCode (theSystemFont->FontKey(), theUpperBound);
- }
- //! Matching two instances, for Map interface.
- static bool IsEqual (const Handle(Font_SystemFont)& theFont1,
- const Handle(Font_SystemFont)& theFont2)
+ bool operator==(const Font_SystemFont& theFont) const
{
- return theFont1->IsEqual (theFont2);
+ return myFontKey.IsEqual(theFont.FontKey());
}
private:
};
+namespace std
+{
+ template<>
+ struct hash<Handle(Font_SystemFont)>
+ {
+ size_t operator()(const Handle (Font_SystemFont)& theLink) const noexcept
+ {
+ if (theLink.IsNull()) return 0;
+ return std::hash<TCollection_AsciiString>{}(theLink->FontKey());
+ }
+ };
+};
+
DEFINE_STANDARD_HANDLE(Font_SystemFont, Standard_Transient)
#endif // _Font_SystemFont_HeaderFile
#include <Standard_Integer.hxx>
#include <Geom2dHatch_Hatching.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Hatching,TColStd_MapIntegerHasher> Geom2dHatch_Hatchings;
-typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Hatching,TColStd_MapIntegerHasher>::Iterator Geom2dHatch_DataMapIteratorOfHatchings;
+typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Hatching> Geom2dHatch_Hatchings;
+typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Hatching>::Iterator Geom2dHatch_DataMapIteratorOfHatchings;
#endif
#define Geom2dHatch_MapOfElements_HeaderFile
#include <Geom2dHatch_Element.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Element,TColStd_MapIntegerHasher> Geom2dHatch_MapOfElements;
-typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Element,TColStd_MapIntegerHasher>::Iterator Geom2dHatch_DataMapIteratorOfMapOfElements;
+typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Element> Geom2dHatch_MapOfElements;
+typedef NCollection_DataMap<Standard_Integer,Geom2dHatch_Element>::Iterator Geom2dHatch_DataMapIteratorOfMapOfElements;
#endif
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray2OfReal.hxx>
+#include <math_Vector.hxx>
GeomFill_PolynomialConvertor::GeomFill_PolynomialConvertor():
Ordre(8),
#include <NCollection_IncAllocator.hxx>
#include <NCollection_List.hxx>
#include <NCollection_LocalArray.hxx>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
#include <TColStd_Array1OfListOfInteger.hxx>
#include <vector>
typedef NCollection_List<Standard_Integer> ListOfInteger;
//have to use std::vector, not NCollection_Vector in order to use copy constructor of
//ListOfInteger which will be created with specific allocator instance
- typedef std::vector<ListOfInteger, NCollection_StdAllocator<
+ typedef std::vector<ListOfInteger, NCollection_OccAllocator<
ListOfInteger> > ArrayOfListOfInteger;
Standard_Boolean bIsPrevPointOnBoundary, bIsCurrentPointOnBoundary;
}
//
Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator();
- NCollection_StdAllocator<ListOfInteger> anAlloc (anIncAlloc);
+ NCollection_OccAllocator<ListOfInteger> anAlloc (anIncAlloc);
const ListOfInteger aDummy (anIncAlloc); //empty list to be copy constructed from
ArrayOfListOfInteger anArrayOfLines (aNbPnts + 1, aDummy, anAlloc);
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Graphic3d_ZLayerId.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
#include <Image_PixMap.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Transient.hxx>
#include <TColStd_IndexedDataMapOfStringString.hxx>
Reset();
}
+// =======================================================================
+// function : Graphic3d_FrameStatsData
+// purpose :
+// =======================================================================
+Graphic3d_FrameStatsData::Graphic3d_FrameStatsData(const Graphic3d_FrameStatsData& theOther) :
+ myCounters(theOther.myCounters),
+ myTimers(theOther.myTimers),
+ myTimersMin(theOther.myTimersMin),
+ myTimersMax(theOther.myTimersMax),
+ myFps(theOther.myFps),
+ myFpsCpu(theOther.myFpsCpu),
+ myFpsImmediate(theOther.myFpsImmediate),
+ myFpsCpuImmediate(theOther.myFpsCpuImmediate)
+{}
+
+// =======================================================================
+// function : Graphic3d_FrameStatsData
+// purpose :
+// =======================================================================
+Graphic3d_FrameStatsData::Graphic3d_FrameStatsData(Graphic3d_FrameStatsData&& theOther) noexcept :
+ myCounters(std::move(theOther.myCounters)),
+ myTimers(std::move(theOther.myTimers)),
+ myTimersMin(std::move(theOther.myTimersMin)),
+ myTimersMax(std::move(theOther.myTimersMax)),
+ myFps(std::move(theOther.myFps)),
+ myFpsCpu(std::move(theOther.myFpsCpu)),
+ myFpsImmediate(std::move(theOther.myFpsImmediate)),
+ myFpsCpuImmediate(std::move(theOther.myFpsCpuImmediate))
+{}
+
// =======================================================================
// function : operator=
// purpose :
// =======================================================================
Graphic3d_FrameStatsData& Graphic3d_FrameStatsData::operator= (const Graphic3d_FrameStatsData& theOther)
{
+ if (&theOther == this)
+ {
+ return *this;
+ }
myFps = theOther.myFps;
myFpsCpu = theOther.myFpsCpu;
myFpsImmediate = theOther.myFpsImmediate;
return *this;
}
+// =======================================================================
+// function : operator=
+// purpose :
+// =======================================================================
+Graphic3d_FrameStatsData& Graphic3d_FrameStatsData::operator=(Graphic3d_FrameStatsData&& theOther) noexcept
+{
+ if (&theOther == this)
+ {
+ return *this;
+ }
+ myFps = std::move(theOther.myFps);
+ myFpsCpu = std::move(theOther.myFpsCpu);
+ myFpsImmediate = std::move(theOther.myFpsImmediate);
+ myFpsCpuImmediate = std::move(theOther.myFpsCpuImmediate);
+ myCounters = std::move(theOther.myCounters);
+ myTimers = std::move(theOther.myTimers);
+ myTimersMin = std::move(theOther.myTimersMin);
+ myTimersMax = std::move(theOther.myTimersMax);
+ return *this;
+}
+
// =======================================================================
// function : Reset
// purpose :
//! Empty constructor.
Standard_EXPORT Graphic3d_FrameStatsData();
+ //! Copy constructor.
+ Standard_EXPORT Graphic3d_FrameStatsData(const Graphic3d_FrameStatsData& theOther);
+
+ //! Move constructor.
+ Standard_EXPORT Graphic3d_FrameStatsData(Graphic3d_FrameStatsData&& theOther) noexcept;
+
//! Assignment operator.
Standard_EXPORT Graphic3d_FrameStatsData& operator= (const Graphic3d_FrameStatsData& theOther);
+ //! Assignment with move operator.
+ Standard_EXPORT Graphic3d_FrameStatsData& operator= (Graphic3d_FrameStatsData&& theOther) noexcept;
+
//! Reset data.
Standard_EXPORT void Reset();
#define _Graphic3d_ShaderAttribute_HeaderFile
#include <Standard_Transient.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <TCollection_AsciiString.hxx>
//! Describes custom vertex shader attribute.
for (mySegListIt.Initialize (aPsd->Edges()); mySegListIt.More(); mySegListIt.Next())
{
- HLRAlgo_BiPoint& BP = mySegListIt.Value();
+ HLRAlgo_BiPoint& BP = mySegListIt.ChangeValue();
HLRAlgo_BiPoint::PointsT& aPoints = BP.Points();
HLRAlgo_BiPoint::IndicesT& theIndices = BP.Indices();
if (aPoints.PntP1.X() < aPoints.PntP2.X()) { xSegmnMin = aPoints.PntP1.X(); xSegmnMax = aPoints.PntP2.X(); }
Standard_Boolean& theOutl,
Standard_Boolean& theIntl)
{
- HLRAlgo_BiPoint& aBP = mySegListIt.Value();
+ HLRAlgo_BiPoint& aBP = mySegListIt.ChangeValue();
HLRAlgo_BiPoint::PointsT& aPoints = aBP.Points();
HLRAlgo_BiPoint::IndicesT& anIndices = aBP.Indices();
theStatus = HLRAlgo_EdgeStatus (0.0, (Standard_ShortReal)myTriangle.TolParam,
Standard_Boolean& outl,
Standard_Boolean& intl)
{
- HLRAlgo_BiPoint& BP = mySegListIt.Value();
+ HLRAlgo_BiPoint& BP = mySegListIt.ChangeValue();
HLRAlgo_BiPoint::IndicesT& theIndices = BP.Indices();
HLRAlgo_BiPoint::PointsT& aPoints = BP.Points();
Index = theIndices.ShapeIndex;
HLRAlgo_ListIteratorOfListOfBPoint it;
for (it.Initialize(mySegList); it.More(); it.Next()) {
- HLRAlgo_BiPoint& BP = it.Value();
+ HLRAlgo_BiPoint& BP = it.ChangeValue();
HLRAlgo_BiPoint::PointsT& aPoints = BP.Points();
if (aPoints.PntP1.X() < aPoints.PntP2.X()) {
if (theBox.XMin > aPoints.PntP1.X()) theBox.XMin = aPoints.PntP1.X();
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
-#include <Standard_Address.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfReal.hxx>
It.Initialize(IL);
while(It.More() && Loop) {
- HLRAlgo_Interference& Int = It.Value();
+ const HLRAlgo_Interference& Int = It.Value();
Standard_Real p = Int.Intersection().Parameter();
if (p < param - tolpar) {
switch (Int.Transition()) {
#include <HLRBRep_SLProps.hxx>
#include <Standard_Real.hxx>
#include <HLRBRep_FaceIterator.hxx>
-#include <Standard_Address.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Standard_Boolean.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
-#include <Standard_Address.hxx>
class gp_Dir;
IL.Remove(It2);
}
// get the cumulated results
- It1.Value().Transition(transTool.Transition());
- It1.Value().BoundaryTransition(transTool.BoundaryTransition());
+ It1.ChangeValue().Transition(transTool.Transition());
+ It1.ChangeValue().BoundaryTransition(transTool.BoundaryTransition());
}
}
It1.Next();
Modif = Standard_False;
HLRAlgo_ListIteratorOfInterferenceList ItSegHidden1(ILHidden);
while(ItSegHidden1.More() && Modif==Standard_False) {
- HLRAlgo_Interference& Int1 = ItSegHidden1.Value();
+ HLRAlgo_Interference& Int1 = ItSegHidden1.ChangeValue();
Standard_Integer numseg1=Int1.Intersection().SegIndex();
if(numseg1!=0) {
HLRAlgo_ListIteratorOfInterferenceList ItSegHidden2(ILHidden);
while(ItSegHidden2.More() && Modif==Standard_False) {
- HLRAlgo_Interference& Int2 = ItSegHidden2.Value();
+ HLRAlgo_Interference& Int2 = ItSegHidden2.ChangeValue();
Standard_Integer numseg2=Int2.Intersection().SegIndex();
if(numseg1+numseg2 == 0) {
//--printf("\nHidden Traitement du segment %d %d\n",numseg1,numseg2); fflush(stdout);
while(It.More()) { // process Intersections on the Face
// *********************************
- HLRAlgo_Interference& Int = It.Value();
+ HLRAlgo_Interference& Int = It.ChangeValue();
TopAbs_State stbef, staft; // read the 3d states
Int.Boundary().State3D(stbef,staft); // ******************
while(It.More()) { // suppress multi-inside Intersections
// ***********************************
- HLRAlgo_Interference& Int = It.Value();
+ const HLRAlgo_Interference& Int = It.Value();
switch (Int.Transition()) {
case TopAbs_FORWARD :
while(It.More()) { // suppress multi-inside Intersections
// ***********************************
- HLRAlgo_Interference& Int = It.Value();
+ const HLRAlgo_Interference& Int = It.Value();
switch (Int.Transition()) {
case TopAbs_FORWARD :
{
for (HLRAlgo_ListIteratorOfListOfBPoint aBPointIter (theList); aBPointIter.More(); aBPointIter.Next())
{
- HLRAlgo_BiPoint& BP = aBPointIter.Value();
+ HLRAlgo_BiPoint& BP = aBPointIter.ChangeValue();
HLRAlgo_BiPoint::IndicesT& theIndices = BP.Indices();
if (theIndices.FaceConex1 != 0)
{
const HLRAlgo_ListOfBPoint& aList = aShell.Value (aShellIter)->Edges();
for (aBPntIter.Initialize (aList); aBPntIter.More(); aBPntIter.Next())
{
- HLRAlgo_BiPoint& aBP = aBPntIter.Value();
+ HLRAlgo_BiPoint& aBP = aBPntIter.ChangeValue();
if (aBP.IntLine())
{
const HLRAlgo_BiPoint::IndicesT& aIndices = aBP.Indices();
#include <Standard_Integer.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_HArray1OfBox.hxx>
-#include <Standard_Address.hxx>
#include <TColStd_Array1OfReal.hxx>
class Standard_OutOfRange;
class HLRBRep_SurfaceTool;
#include <Standard_Integer.hxx>
#include <TCollection_AsciiString.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <Standard_Transient.hxx>
class IFSelect_IntParam;
#include <TopTools_ShapeMapHasher.hxx>
#include <TopoDS_Shape.hxx>
#include <NCollection_DefineAlloc.hxx>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
#include <IMeshData_ParametersListArrayAdaptor.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <NCollection_EBTree.hxx>
namespace Model
{
- typedef std::deque<gp_Pnt, NCollection_StdAllocator<gp_Pnt> > SequenceOfPnt;
- typedef std::deque<gp_Pnt2d, NCollection_StdAllocator<gp_Pnt2d> > SequenceOfPnt2d;
- typedef std::deque<Standard_Real, NCollection_StdAllocator<Standard_Real> > SequenceOfReal;
- typedef std::deque<Standard_Integer, NCollection_StdAllocator<Standard_Integer> > SequenceOfInteger;
+ typedef std::deque<gp_Pnt, NCollection_OccAllocator<gp_Pnt> > SequenceOfPnt;
+ typedef std::deque<gp_Pnt2d, NCollection_OccAllocator<gp_Pnt2d> > SequenceOfPnt2d;
+ typedef std::deque<Standard_Real, NCollection_OccAllocator<Standard_Real> > SequenceOfReal;
+ typedef std::deque<Standard_Integer, NCollection_OccAllocator<Standard_Integer> > SequenceOfInteger;
}
// Lists
typedef NCollection_CellFilter<BRepMesh_CircleInspector> CircleCellFilter;
typedef NCollection_CellFilter<BRepMesh_VertexInspector> VertexCellFilter;
- // Data Maps
- template<typename Type>
- struct WeakEqual
- {
- static Standard_Boolean IsEqual(const Type* theFirst,
- const Type* theSecond)
- {
- return (theFirst == theSecond);
- }
-
- //! Computes a hash code for the given pointer, in the range [1, theUpperBound]
- //! @param thePointer the pointer 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 Type* const thePointer, Standard_Integer theUpperBound)
- {
- return ::HashCode (thePointer, theUpperBound);
- }
- };
-
- typedef NCollection_Shared<NCollection_DataMap<TopoDS_Shape, Standard_Integer, TopTools_ShapeMapHasher> > DMapOfShapeInteger;
- typedef NCollection_Shared<NCollection_DataMap<IFacePtr, ListOfInteger, WeakEqual<IMeshData_Face> > > DMapOfIFacePtrsListOfInteger;
- typedef NCollection_Shared<NCollection_Map<IEdgePtr, WeakEqual<IMeshData_Edge> > > MapOfIEdgePtr;
- typedef NCollection_Shared<NCollection_Map<IFacePtr, WeakEqual<IMeshData_Face> > > MapOfIFacePtr;
- typedef NCollection_Shared<NCollection_Map<BRepMesh_OrientedEdge> > MapOfOrientedEdges;
- typedef NCollection_Shared<NCollection_Map<Standard_Real> > MapOfReal;
- typedef NCollection_Shared<NCollection_IndexedDataMap<IFacePtr, ListOfIPCurves, WeakEqual<IMeshData_Face> > > IDMapOfIFacePtrsListOfIPCurves;
- typedef NCollection_Shared<NCollection_DataMap<IFacePtr, Handle(MapOfIEdgePtr), WeakEqual<IMeshData_Face> > > DMapOfIFacePtrsMapOfIEdgePtrs;
- typedef NCollection_Shared<NCollection_IndexedDataMap<BRepMesh_Edge, BRepMesh_PairOfIndex> > IDMapOfLink;
- typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, ListOfInteger> > DMapOfIntegerListOfInteger;
- typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, Standard_Integer> > MapOfIntegerInteger;
- typedef NCollection_Shared<NCollection_IndexedMap<Standard_Real> > IMapOfReal;
-
- typedef NCollection_Shared<NCollection_Array1<Standard_Integer> > Array1OfInteger;
+ typedef NCollection_Shared<NCollection_DataMap<TopoDS_Shape, Standard_Integer,TopTools_ShapeMapHasher> > DMapOfShapeInteger;
+ typedef NCollection_Shared<NCollection_DataMap<IFacePtr, ListOfInteger> > DMapOfIFacePtrsListOfInteger;
+ typedef NCollection_Shared<NCollection_Map<IEdgePtr> > MapOfIEdgePtr;
+ typedef NCollection_Shared<NCollection_Map<IFacePtr> > MapOfIFacePtr;
+ typedef NCollection_Shared<NCollection_Map<BRepMesh_OrientedEdge> > MapOfOrientedEdges;
+ typedef NCollection_Shared<NCollection_Map<Standard_Real> > MapOfReal;
+ typedef NCollection_Shared<NCollection_IndexedDataMap<IFacePtr, ListOfIPCurves> > IDMapOfIFacePtrsListOfIPCurves;
+ typedef NCollection_Shared<NCollection_DataMap<IFacePtr, Handle(MapOfIEdgePtr)> > DMapOfIFacePtrsMapOfIEdgePtrs;
+ typedef NCollection_Shared<NCollection_IndexedDataMap<BRepMesh_Edge, BRepMesh_PairOfIndex> > IDMapOfLink;
+ typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, ListOfInteger> > DMapOfIntegerListOfInteger;
+ typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, Standard_Boolean> > MapOfIntegerInteger;
+ typedef NCollection_Shared<NCollection_IndexedMap<Standard_Real> > IMapOfReal;
+
+ typedef NCollection_Shared<NCollection_Array1<Standard_Integer> > Array1OfInteger;
}
#endif
#include <gp_XY.hxx>
#include <NCollection_List.hxx>
-#include <NCollection_TListIterator.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Map.hxx>
#include <Standard_Boolean.hxx>
//================================================================
// TYPE DEFINITIONS
//================================================================
+namespace
+{
+ struct VtkPointerHasher
+ {
+ std::size_t operator()(const vtkSmartPointer<vtkActor>& thePointer) const
+ {
+ return std::hash<vtkActor*>{}(thePointer.Get());
+ }
+
+ bool operator()(const vtkSmartPointer<vtkActor>& thePointer1,
+ const vtkSmartPointer<vtkActor>& thePointer2) const
+ {
+ return thePointer1 == thePointer2;
+ }
+ };
+}
typedef NCollection_DoubleMap<TopoDS_Shape, TCollection_AsciiString> DoubleMapOfShapesAndNames;
-typedef NCollection_DoubleMap<vtkSmartPointer<vtkActor>, TCollection_AsciiString> DoubleMapOfActorsAndNames;
+typedef NCollection_DoubleMap<vtkSmartPointer<vtkActor>, TCollection_AsciiString, VtkPointerHasher> DoubleMapOfActorsAndNames;
typedef IVtkDraw_HighlightAndSelectionPipeline PipelinePtr;
const TCollection_AsciiString& theFile);
public: //! @name hasher interface
-
- //! Hash value, for Map interface.
- static int HashCode (const Handle(Image_Texture)& theTexture, const int theUpper)
- {
- return !theTexture.IsNull()
- ? TCollection_AsciiString::HashCode (theTexture->myTextureId, theUpper)
- : 0;
- }
-
- //! Matching two instances, for Map interface.
- static Standard_Boolean IsEqual (const Handle(Image_Texture)& theTex1,
- const Handle(Image_Texture)& theTex2)
- {
- if (theTex1.IsNull() != theTex2.IsNull())
- {
- return Standard_False;
- }
- else if (theTex1.IsNull())
- {
- return Standard_True;
- }
- return theTex1->myTextureId.IsEqual (theTex2->myTextureId);
- }
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
};
+namespace std
+{
+ template<>
+ struct equal_to<Handle(Image_Texture)>
+ {
+ bool operator()(const Handle(Image_Texture)& theTex1,
+ const Handle(Image_Texture)& theTex2) const
+ {
+ if (theTex1.IsNull() != theTex2.IsNull())
+ {
+ return Standard_False;
+ }
+ else if (theTex1.IsNull())
+ {
+ return Standard_True;
+ }
+ return theTex1->TextureId().IsEqual(theTex2->TextureId());
+ }
+ };
+
+ template<>
+ struct hash<Handle(Image_Texture)>
+ {
+ size_t operator()(const Handle(Image_Texture)& theTexture) const noexcept
+ {
+ return !theTexture.IsNull()
+ ? std::hash<TCollection_AsciiString>{}(theTexture->TextureId())
+ : 0;
+ }
+ };
+}
+
#endif // _Image_Texture_HeaderFile
#include <math_Matrix.hxx>
#include <NCollection_IncAllocator.hxx>
#include <Standard_DivideByZero.hxx>
+#include <math_Vector.hxx>
//If Abs(a) <= aNulValue then it is considered that a = 0.
static const Standard_Real aNulValue = 1.0e-11;
Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator;
for (Standard_Integer aCID = 0; aCID < 2; aCID++)
{
- anAlloc->Reset();
+ anAlloc->Reset(false);
NCollection_List<Bnd_Range> aListOfRng(anAlloc);
aListOfRng.Append(anURange[aCID][0]);
aListOfRng.Clear();
for (anITrRng.Init(aLstTemp); anITrRng.More(); anITrRng.Next())
{
- Bnd_Range& aRng = anITrRng.Value();
+ Bnd_Range& aRng = anITrRng.ChangeValue();
aRng.Split(aSplitArr[aSInd], aListOfRng, aPeriod);
}
}
anITrRng.Init(aListOfRng);
for (; anITrRng.More(); anITrRng.Next())
{
- Bnd_Range& aCurrRange = anITrRng.Value();
+ Bnd_Range& aCurrRange = anITrRng.ChangeValue();
Bnd_Range aBoundR;
aBoundR.Add(aUSBou[aCID][0]);
//
aIt.Initialize(aLC);
for (; aIt.More(); aIt.Next()) {
- IntAna_Curve& curvsol=aIt.Value();
+ IntAna_Curve& curvsol=aIt.ChangeValue();
//
curvsol.Domain(first, last);
firstp = !curvsol.IsFirstOpen();
class gp_XYZ;
class IntPatch_Point;
class IntSurf_PntOn2S;
-class math_Vector;
+
+template<typename T> class math_VectorBase;
+using math_Vector = math_VectorBase<double>;
class IntPatch_SpecialPoints
{
}
}
- anAlloc->Reset();
+ anAlloc->Reset(false);
NCollection_List<Standard_Integer> aListFC(anAlloc),
aListLC(anAlloc);
IntPolyh_ArrayOfTriangles.hxx
IntPolyh_Couple.cxx
IntPolyh_Couple.hxx
-IntPolyh_CoupleMapHasher.hxx
IntPolyh_Edge.cxx
IntPolyh_Edge.hxx
IntPolyh_Intersection.cxx
IntPolyh_Tools.cxx
IntPolyh_Tools.hxx
IntPolyh_Triangle.cxx
-IntPolyh_Triangle.hxx
\ No newline at end of file
+IntPolyh_Triangle.hxx
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
+#include <Standard_HashUtils.hxx>
//! The class represents the couple of indices with additional
//! characteristics such as analyzed flag and an angle.<br>
(myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
}
- //! Computes a hash code for this couple, in the range [1, theUpperBound]
- //! @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]
- Standard_Integer HashCode (const Standard_Integer theUpperBound) const
+ //! Returns true if the Couple is equal to <theOther>
+ bool operator==(const IntPolyh_Couple& theOther) const
{
- return ::HashCode (myIndex1 + myIndex2, theUpperBound);
+ return IsEqual(theOther);
}
// Dump
};
+namespace std
+{
+ template <>
+ struct hash<IntPolyh_Couple>
+ {
+ size_t operator()(const IntPolyh_Couple& theCouple) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theCouple.FirstValue(), theCouple.SecondValue() };
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
+
#endif // _IntPolyh_Couple_HeaderFile
+++ /dev/null
-// Created by: Eugeny MALTCHIKOV
-// Copyright (c) 2017 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 _IntPolyh_CoupleMapHasher_HeaderFile
-#define _IntPolyh_CoupleMapHasher_HeaderFile
-
-#include <Standard_Integer.hxx>
-#include <IntPolyh_Couple.hxx>
-
-class IntPolyh_Couple;
-
-class IntPolyh_CoupleMapHasher
-{
-public:
-
- //! Computes a hash code for the given couple, in the range [1, theUpperBound]
- //! @param theCouple the couple 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 IntPolyh_Couple& theCouple, const Standard_Integer theUpperBound)
- {
- return theCouple.HashCode (theUpperBound);
- }
-
- static Standard_Boolean IsEqual(const IntPolyh_Couple& theCouple1,
- const IntPolyh_Couple& theCouple2)
- {
- return theCouple1.IsEqual(theCouple2);
- }
-
-protected:
-
-private:
-
-};
-
-#endif // _IntPolyh_CoupleMapHasher_HeaderFile
#include <Adaptor3d_Surface.hxx>
#include <IntPolyh_Couple.hxx>
-#include <IntPolyh_CoupleMapHasher.hxx>
#include <IntPolyh_MaillageAffinage.hxx>
#include <IntPolyh_SectionLine.hxx>
#include <IntPolyh_StartPoint.hxx>
IntPolyh_ListOfCouples &anArrayRR) const
{
// Fence map to remove from the lists the duplicating elements.
- NCollection_Map<IntPolyh_Couple, IntPolyh_CoupleMapHasher> aFenceMap;
+ NCollection_Map<IntPolyh_Couple> aFenceMap;
//
IntPolyh_ListOfCouples* pLists[4] = {&anArrayFF, &anArrayFR, &anArrayRF, &anArrayRR};
for (Standard_Integer i = 0; i < 4; ++i) {
typedef NCollection_Array1<Standard_Integer> IntPolyh_ArrayOfInteger;
typedef NCollection_IndexedDataMap
<Standard_Integer,
- TColStd_ListOfInteger,
- TColStd_MapIntegerHasher> IntPolyh_IndexedDataMapOfIntegerListOfInteger;
+ TColStd_ListOfInteger> IntPolyh_IndexedDataMapOfIntegerListOfInteger;
static Standard_Real MyTolerance=10.0e-7;
Standard_EXPORT IntPolyh_SectionLine();
Standard_EXPORT IntPolyh_SectionLine(const Standard_Integer nn);
+
+ IntPolyh_SectionLine(const IntPolyh_SectionLine& theOther)
+ {
+ Copy(theOther);
+ }
Standard_EXPORT void Init (const Standard_Integer nn);
IntTools_CurveRangeLocalizeData.hxx
IntTools_CurveRangeSample.cxx
IntTools_CurveRangeSample.hxx
-IntTools_CurveRangeSampleMapHasher.hxx
-IntTools_DataMapIteratorOfDataMapOfCurveSampleBox.hxx
IntTools_DataMapIteratorOfDataMapOfSurfaceSampleBox.hxx
IntTools_DataMapOfCurveSampleBox.hxx
IntTools_DataMapOfSurfaceSampleBox.hxx
IntTools_SurfaceRangeSample.cxx
IntTools_SurfaceRangeSample.hxx
IntTools_SurfaceRangeSample.lxx
-IntTools_SurfaceRangeSampleMapHasher.hxx
IntTools_Tools.cxx
IntTools_Tools.hxx
IntTools_TopolTool.cxx
IntTools_ListOfCurveRangeSample& theListCurveRangeSort,
IntTools_ListOfSurfaceRangeSample& theListSurfaceRangeSort)
{
- NCollection_IndexedMap<IntTools_SurfaceRangeSample, IntTools_SurfaceRangeSampleMapHasher> aMapToAvoid;
+ NCollection_IndexedMap<IntTools_SurfaceRangeSample> aMapToAvoid;
NCollection_DataMap<Standard_Integer, TColStd_ListOfInteger> aCurveIdMap;
std::vector<IntTools_CurveRangeSample> aCurveRangeVector;
}
mySClassMap.Clear();
- for (NCollection_DataMap<Handle(Geom_Curve), GeomAPI_ProjectPointOnCurve*, TColStd_MapTransientHasher>::Iterator anIt (myProjPTMap);
+ for (NCollection_DataMap<Handle(Geom_Curve), GeomAPI_ProjectPointOnCurve*>::Iterator anIt (myProjPTMap);
anIt.More(); anIt.Next())
{
GeomAPI_ProjectPointOnCurve* pProjPT = anIt.Value();
#include <Standard_Transient.hxx>
#include <TopAbs_State.hxx>
#include <BRepAdaptor_Surface.hxx>
-#include <TColStd_MapTransientHasher.hxx>
class IntTools_FClass2d;
class TopoDS_Face;
class GeomAPI_ProjectPointOnSurf;
NCollection_DataMap<TopoDS_Shape, GeomAPI_ProjectPointOnSurf*, TopTools_ShapeMapHasher> myProjPSMap;
NCollection_DataMap<TopoDS_Shape, GeomAPI_ProjectPointOnCurve*, TopTools_ShapeMapHasher> myProjPCMap;
NCollection_DataMap<TopoDS_Shape, BRepClass3d_SolidClassifier*, TopTools_ShapeMapHasher> mySClassMap;
- NCollection_DataMap<Handle(Geom_Curve), GeomAPI_ProjectPointOnCurve*, TColStd_MapTransientHasher> myProjPTMap;
+ NCollection_DataMap<Handle(Geom_Curve), GeomAPI_ProjectPointOnCurve*> myProjPTMap;
NCollection_DataMap<TopoDS_Shape, Geom2dHatch_Hatcher*, TopTools_ShapeMapHasher> myHatcherMap;
NCollection_DataMap<TopoDS_Shape, IntTools_SurfaceRangeLocalizeData*, TopTools_ShapeMapHasher> myProjSDataMap;
NCollection_DataMap<TopoDS_Shape, Bnd_Box*, TopTools_ShapeMapHasher> myBndBoxDataMap;
#include <Standard_Handle.hxx>
#include <IntTools_BaseRangeSample.hxx>
+#include <Standard_HashUtils.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
return ((myIndex == Other.myIndex) && (GetDepth() == Other.GetDepth()));
}
+ bool operator==(const IntTools_CurveRangeSample& Other) const
+ {
+ return IsEqual(Other);
+ }
+
Standard_EXPORT IntTools_Range GetRange (const Standard_Real theFirst, const Standard_Real theLast, const Standard_Integer theNbSample) const;
Standard_Integer GetRangeIndexDeeper (const Standard_Integer theNbSample) const
};
+namespace std
+{
+ template <>
+ struct hash<IntTools_CurveRangeSample>
+ {
+ size_t operator()(const IntTools_CurveRangeSample& theCurveRangeSample) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theCurveRangeSample.GetDepth(), theCurveRangeSample.GetRangeIndex() };
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
+
#endif // _IntTools_CurveRangeSample_HeaderFile
+++ /dev/null
-// Created on: 2005-10-14
-// Created by: Mikhail KLOKOV
-// Copyright (c) 2005-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 _IntTools_CurveRangeSampleMapHasher_HeaderFile
-#define _IntTools_CurveRangeSampleMapHasher_HeaderFile
-
-#include <IntTools_CurveRangeSample.hxx>
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Integer.hxx>
-
-//! class for range index management of curve
-class IntTools_CurveRangeSampleMapHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given key, in the range [1, theUpperBound]
- //! @param theKey the key 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 IntTools_CurveRangeSample& theKey, const Standard_Integer theUpperBound)
- {
- return ::HashCode(theKey.GetDepth(), theUpperBound);
- }
-
- //! Returns True when the two keys are the same. Two
- //! same keys must have the same hashcode, the
- //! contrary is not necessary.
- static Standard_Boolean IsEqual (const IntTools_CurveRangeSample& S1, const IntTools_CurveRangeSample& S2)
- {
- return S1.IsEqual(S2);
- }
-
-};
-
-#endif // _IntTools_CurveRangeSampleMapHasher_HeaderFile
+++ /dev/null
-// Copyright (c) 2015 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 IntTools_DataMapIteratorOfDataMapOfCurveSampleBox_HeaderFile
-#define IntTools_DataMapIteratorOfDataMapOfCurveSampleBox_HeaderFile
-
-#include <IntTools_DataMapOfCurveSampleBox.hxx>
-
-#endif
#include <IntTools_CurveRangeSample.hxx>
#include <Bnd_Box.hxx>
-#include <IntTools_CurveRangeSampleMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<IntTools_CurveRangeSample,Bnd_Box,IntTools_CurveRangeSampleMapHasher> IntTools_DataMapOfCurveSampleBox;
-typedef NCollection_DataMap<IntTools_CurveRangeSample,Bnd_Box,IntTools_CurveRangeSampleMapHasher>::Iterator IntTools_DataMapIteratorOfDataMapOfCurveSampleBox;
+typedef NCollection_DataMap<IntTools_CurveRangeSample,Bnd_Box> IntTools_DataMapOfCurveSampleBox;
+typedef NCollection_DataMap<IntTools_CurveRangeSample,Bnd_Box>::Iterator IntTools_DataMapIteratorOfDataMapOfCurveSampleBox;
#endif
#include <IntTools_SurfaceRangeSample.hxx>
#include <Bnd_Box.hxx>
-#include <IntTools_SurfaceRangeSampleMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<IntTools_SurfaceRangeSample,Bnd_Box,IntTools_SurfaceRangeSampleMapHasher> IntTools_DataMapOfSurfaceSampleBox;
-typedef NCollection_DataMap<IntTools_SurfaceRangeSample,Bnd_Box,IntTools_SurfaceRangeSampleMapHasher>::Iterator IntTools_DataMapIteratorOfDataMapOfSurfaceSampleBox;
+typedef NCollection_DataMap<IntTools_SurfaceRangeSample,Bnd_Box> IntTools_DataMapOfSurfaceSampleBox;
+typedef NCollection_DataMap<IntTools_SurfaceRangeSample,Bnd_Box>::Iterator IntTools_DataMapIteratorOfDataMapOfSurfaceSampleBox;
#endif
aItP2S.Initialize(myListOfPnts);
for (; aItP2S.More(); aItP2S.Next())
{
- IntSurf_PntOn2S& aP2S=aItP2S.Value();
+ IntSurf_PntOn2S& aP2S=aItP2S.ChangeValue();
aP2S.Parameters(aU1,aV1,aU2,aV2);
aP2S.SetValue(aU2,aV2,aU1,aV1);
}
#define IntTools_MapOfCurveSample_HeaderFile
#include <IntTools_CurveRangeSample.hxx>
-#include <IntTools_CurveRangeSampleMapHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<IntTools_CurveRangeSample,IntTools_CurveRangeSampleMapHasher> IntTools_MapOfCurveSample;
-typedef NCollection_Map<IntTools_CurveRangeSample,IntTools_CurveRangeSampleMapHasher>::Iterator IntTools_MapIteratorOfMapOfCurveSample;
+typedef NCollection_Map<IntTools_CurveRangeSample> IntTools_MapOfCurveSample;
+typedef NCollection_Map<IntTools_CurveRangeSample>::Iterator IntTools_MapIteratorOfMapOfCurveSample;
#endif
#define IntTools_MapOfSurfaceSample_HeaderFile
#include <IntTools_SurfaceRangeSample.hxx>
-#include <IntTools_SurfaceRangeSampleMapHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<IntTools_SurfaceRangeSample,IntTools_SurfaceRangeSampleMapHasher> IntTools_MapOfSurfaceSample;
-typedef NCollection_Map<IntTools_SurfaceRangeSample,IntTools_SurfaceRangeSampleMapHasher>::Iterator IntTools_MapIteratorOfMapOfSurfaceSample;
+typedef NCollection_Map<IntTools_SurfaceRangeSample> IntTools_MapOfSurfaceSample;
+typedef NCollection_Map<IntTools_SurfaceRangeSample>::Iterator IntTools_MapIteratorOfMapOfSurfaceSample;
#endif
Standard_Integer GetRangeIndexVDeeper (const Standard_Integer theNbSampleV) const;
+ bool operator==(const IntTools_SurfaceRangeSample& theOther) const
+ {
+ return IsEqual(theOther);
+ }
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Standard_HashUtils.hxx>
+
inline void IntTools_SurfaceRangeSample::SetRanges(const IntTools_CurveRangeSample& theRangeU,
const IntTools_CurveRangeSample& theRangeV)
{
{
return myRangeV.GetRangeIndexDeeper(theNbSampleV);
}
+
+namespace std
+{
+ template <>
+ struct hash<IntTools_SurfaceRangeSample>
+ {
+ size_t operator()(const IntTools_SurfaceRangeSample& theSurfaceRangeSample) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ size_t aCombination[2]{ std::hash<IntTools_CurveRangeSample>{}(theSurfaceRangeSample.GetSampleRangeU()),
+ std::hash<IntTools_CurveRangeSample>{}(theSurfaceRangeSample.GetSampleRangeV()) };
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
+++ /dev/null
-// Created on: 2005-10-14
-// Created by: Mikhail KLOKOV
-// Copyright (c) 2005-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 _IntTools_SurfaceRangeSampleMapHasher_HeaderFile
-#define _IntTools_SurfaceRangeSampleMapHasher_HeaderFile
-
-#include <IntTools_SurfaceRangeSample.hxx>
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Integer.hxx>
-
-class IntTools_SurfaceRangeSampleMapHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given key, in the range [1, theUpperBound]
- //! @param theKey the key 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 IntTools_SurfaceRangeSample& theKey, Standard_Integer theUpperBound)
- {
- return ::HashCode (theKey.GetIndexU() * theKey.GetIndexV(), theUpperBound);
- }
-
- //! Returns True when the two keys are the same. Two
- //! same keys must have the same hashcode, the
- //! contrary is not necessary.
- static Standard_Boolean IsEqual (const IntTools_SurfaceRangeSample& S1, const IntTools_SurfaceRangeSample& S2)
- {
- return S1.IsEqual(S2);
- }
-
-};
-
-#endif // _IntTools_SurfaceRangeSampleMapHasher_HeaderFile
#define IntWalk_VectorOfInteger_HeaderFile
#include <vector>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
// Defines a dynamic vector of integer.
-typedef std::vector<Standard_Integer, NCollection_StdAllocator<Standard_Integer> >
+typedef std::vector<Standard_Integer, NCollection_OccAllocator<Standard_Integer> >
IntWalk_VectorOfInteger;
#endif
#define IntWalk_VectorOfWalkingData_HeaderFile
#include <vector>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
// Defines a dynamic vector of work data.
Standard_Integer etat;
};
-typedef std::vector<IntWalk_WalkingData, NCollection_StdAllocator<IntWalk_WalkingData> >
+typedef std::vector<IntWalk_WalkingData, NCollection_OccAllocator<IntWalk_WalkingData> >
IntWalk_VectorOfWalkingData;
#endif
Interface_LineBuffer.cxx
Interface_LineBuffer.hxx
Interface_Macros.hxx
-Interface_MapAsciiStringHasher.cxx
-Interface_MapAsciiStringHasher.hxx
Interface_MSG.cxx
Interface_MSG.hxx
Interface_NodeOfGeneralLib.hxx
#include <Standard_Transient.hxx>
#include <Standard_Integer.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(Standard_Transient),Standard_Integer,TColStd_MapTransientHasher> Interface_DataMapOfTransientInteger;
-typedef NCollection_DataMap<Handle(Standard_Transient),Standard_Integer,TColStd_MapTransientHasher>::Iterator Interface_DataMapIteratorOfDataMapOfTransientInteger;
+typedef NCollection_DataMap<Handle(Standard_Transient),Standard_Integer> Interface_DataMapOfTransientInteger;
+typedef NCollection_DataMap<Handle(Standard_Transient),Standard_Integer>::Iterator Interface_DataMapIteratorOfDataMapOfTransientInteger;
#endif
#define Interface_IndexedMapOfAsciiString_HeaderFile
#include <TCollection_AsciiString.hxx>
-#include <Interface_MapAsciiStringHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<TCollection_AsciiString,Interface_MapAsciiStringHasher> Interface_IndexedMapOfAsciiString;
+typedef NCollection_IndexedMap<TCollection_AsciiString> Interface_IndexedMapOfAsciiString;
#endif
+++ /dev/null
-// Copyright (c) 1999-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 <Interface_MapAsciiStringHasher.hxx>
-#include <TCollection_AsciiString.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-Standard_Integer Interface_MapAsciiStringHasher::HashCode (const TCollection_AsciiString& theAsciiString,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode (theAsciiString.ToCString(), theAsciiString.Length(), theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-
-Standard_Boolean Interface_MapAsciiStringHasher::IsEqual(const TCollection_AsciiString& K1,
- const TCollection_AsciiString& K2)
-{
- if(!K1.Length() || !K2.Length()) return Standard_False;
- return K1.IsEqual(K2);
-}
+++ /dev/null
-// Created on: 2003-05-06
-// Created by: Galina KULIKOVA
-// Copyright (c) 2003-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 _Interface_MapAsciiStringHasher_HeaderFile
-#define _Interface_MapAsciiStringHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Standard_Boolean.hxx>
-class TCollection_AsciiString;
-
-
-
-class Interface_MapAsciiStringHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given ASCII string, in the range [1, theUpperBound]
- //! @param theAsciiString the ASCII string 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]
- Standard_EXPORT static Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString,
- Standard_Integer theUpperBound);
-
- Standard_EXPORT static Standard_Boolean IsEqual (const TCollection_AsciiString& K1, const TCollection_AsciiString& K2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-
-
-
-
-
-#endif // _Interface_MapAsciiStringHasher_HeaderFile
// function : FillMap
// purpose : Fills given string-to-string map with all static data
//=======================================================================
-void Interface_Static::FillMap (NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString, TCollection_AsciiString>& theMap)
+void Interface_Static::FillMap (NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theMap)
{
theMap.Clear();
Standard_EXPORT static void Standards();
//! Fills given string-to-string map with all static data
- Standard_EXPORT static void FillMap(NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString, TCollection_AsciiString>& theMap);
+ Standard_EXPORT static void FillMap(NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theMap);
DEFINE_STANDARD_RTTIEXT(Interface_Static,Interface_TypedValue)
imbSh.UnBind(itdm.Key());
}
else {
- for (itdm.Reset(); itdm.More(); itdm.Next()) {
+ for (itdm.Initialize(imbSh); itdm.More(); itdm.Next()) {
TopoDS_Solid newSo;
B.MakeSolid(newSo);
B.Add(newSo,itdm.Key());
TopTools_DataMapOfShapeListOfShape theFFMap;
TopTools_MapOfShape toRemove;
TopTools_MapIteratorOfMapOfShape itm;
- TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itf;
// recherche des fusions de faces
for (itm.Initialize(GEdg); itm.More(); itm.Next()) {
if (ToFuse(fac,facbis)) {
// On recherche si une face a deja fusionne avec facbis
Standard_Boolean facbisfound = Standard_False;
- for (itf.Initialize(theFFMap); itf.More(); itf.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itf(theFFMap); itf.More(); itf.Next()) {
if (itf.Key().IsSame(fac)) {
continue;
}
// a fusionner avec une meme face de base
// TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itf(theFFMap);
- itf.Initialize(theFFMap);
- for (; itf.More(); itf.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itf(theFFMap); itf.More(); itf.Next())
+ {
for (itl.Initialize(itf.Value()); itl.More(); itl.Next()) {
for (exp.Init(itl.Value(),TopAbs_EDGE); exp.More(); exp.Next()) {
const TopoDS_Edge& ed = TopoDS::Edge(exp.Current());
TopTools_DataMapOfShapeShape DontFuse;
TopAbs_Orientation orient,orface;
- for (itf.Reset(); itf.More(); itf.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itf(theFFMap); itf.More(); itf.Next())
+ {
const TopoDS_Face& fac = TopoDS::Face(itf.Key());
for (exp.Init(fac,TopAbs_EDGE); exp.More(); exp.Next()) {
const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
TopTools_MapOfShape EdgAdded;
// Fusion des faces, ou reconstruction
- for (itf.Reset();itf.More(); itf.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itf(theFFMap);itf.More(); itf.Next())
+ {
const TopoDS_Face& fac = TopoDS::Face(itf.Key());
Standard_Boolean ModFace = Standard_False;
TopTools_ListOfShape listofedg;
}
while (MapFac.Extent() >= 2) {
- itm.Reset();
+ itm = TopTools_MapIteratorOfMapOfShape(MapFac);
TopTools_ListOfShape FacFuse;
TopoDS_Face FaceRef = TopoDS::Face(itm.Key());
FacFuse.Append(FaceRef);
// for (TopTools_ListIteratorOfListOfShape itl(ledg);
TopTools_ListIteratorOfListOfShape itl(ledg) ;
for ( ; itl.More(); itl.Next()) {
- TopoDS_Edge& edg = TopoDS::Edge(itl.Value());
+ const TopoDS_Edge& edg = TopoDS::Edge(itl.Value());
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(edg,F,f,l);
if (C2d.IsNull()) {
BRep_Tool::Range(edg,f,l);
GProp_GProps GP;
BRepGProp::SurfaceProperties(NewFace,GP);
if (GP.Mass() < 0) {
- itl.Value().Reverse();
+ itl.ChangeValue().Reverse();
}
}
if (lwires.Extent() == 1) {
const TopoDS_Wire& aHole = TopoDS::Wire(itl.Value());
for (itlNewF.Initialize(NewFaces); itlNewF.More(); itlNewF.Next())
{
- TopoDS_Face& aNewFace = TopoDS::Face(itlNewF.Value());
+ TopoDS_Face& aNewFace = TopoDS::Face(itlNewF.ChangeValue());
if (IsInside(aNewFace, aHole))
{
BB.Add(aNewFace, aHole);
}
theSubs.Build(myShape);
- TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdesc(myMap);
if (theSubs.IsCopied(myShape)) {
// on n`a fait que des substitutions de vertex. Donc chaque element
// est remplace par lui meme ou par un seul element du meme type.
- for (; itdesc.More(); itdesc.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdesc(myMap); itdesc.More(); itdesc.Next())
+ {
if (theSubs.IsCopied(itdesc.Key())) {
const TopTools_ListOfShape& lsub = theSubs.Copy(itdesc.Key());
#ifdef OCCT_DEBUG
// Mise a jour des descendants
- for (itdesc.Reset(); itdesc.More(); itdesc.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdesc(myMap); itdesc.More(); itdesc.Next())
+ {
const TopoDS_Shape& sori = itdesc.Key();
const TopoDS_Shape& scib = itdesc.Value().First();
myMap(sori) = theCFace.DescendantShapes(scib);
theSubs.Build(myRes);
- for (itdesc.Reset(); itdesc.More(); itdesc.Next()) {
+ for (TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itdesc(myMap); itdesc.More(); itdesc.Next())
+ {
TopTools_ListOfShape& ldesc = myMap(itdesc.Key());
TopTools_ListOfShape newdesc;
for (itl.Initialize(ldesc); itl.More(); itl.Next()) {
}
}
if (itms.More()) {
- const TopoDS_Shape& fac = itms.Key();
+ TopoDS_Shape fac = itms.Key();
for (exp.Init(fac,TopAbs_EDGE); exp.More(); exp.Next()) {
if (!Mapebord.Add(exp.Current())) {
Mapebord.Remove(exp.Current());
#include <Standard_Type.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Transient.hxx>
#include <MAT_Side.hxx>
class MAT_BasicElt;
#include <Standard.hxx>
#include <Standard_Type.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
class MAT_Arc;
#include <Standard_Integer.hxx>
#include <MAT_Arc.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Arc),TColStd_MapIntegerHasher> MAT_DataMapOfIntegerArc;
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Arc),TColStd_MapIntegerHasher>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerArc;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Arc)> MAT_DataMapOfIntegerArc;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Arc)>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerArc;
#endif
#include <Standard_Integer.hxx>
#include <MAT_BasicElt.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_BasicElt),TColStd_MapIntegerHasher> MAT_DataMapOfIntegerBasicElt;
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_BasicElt),TColStd_MapIntegerHasher>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerBasicElt;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_BasicElt)> MAT_DataMapOfIntegerBasicElt;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_BasicElt)>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerBasicElt;
#endif
#include <Standard_Integer.hxx>
#include <MAT_Bisector.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Bisector),TColStd_MapIntegerHasher> MAT_DataMapOfIntegerBisector;
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Bisector),TColStd_MapIntegerHasher>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerBisector;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Bisector)> MAT_DataMapOfIntegerBisector;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Bisector)>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerBisector;
#endif
#include <Standard_Integer.hxx>
#include <MAT_Node.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Node),TColStd_MapIntegerHasher> MAT_DataMapOfIntegerNode;
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Node),TColStd_MapIntegerHasher>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerNode;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Node)> MAT_DataMapOfIntegerNode;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT_Node)>::Iterator MAT_DataMapIteratorOfDataMapOfIntegerNode;
#endif
#include <Standard_Type.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Real.hxx>
#include <Standard_Transient.hxx>
#include <MAT_SequenceOfArc.hxx>
MAT2d_DataMapOfIntegerPnt2d.hxx
MAT2d_DataMapOfIntegerSequenceOfConnexion.hxx
MAT2d_DataMapOfIntegerVec2d.hxx
-MAT2d_MapBiIntHasher.hxx
-MAT2d_MapBiIntHasher.lxx
MAT2d_Mat2d.cxx
MAT2d_Mat2d.hxx
MAT2d_MiniPath.cxx
#include <Standard_Handle.hxx>
#include <Standard_Boolean.hxx>
-
+#include <Standard_HashUtils.hxx>
//! BiInt is a set of two integers.
class MAT2d_BiInt
};
+namespace std
+{
+ template <>
+ struct hash<MAT2d_BiInt>
+ {
+ size_t operator()(const MAT2d_BiInt& theBiInt) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theBiInt.FirstIndex(), theBiInt.SecondIndex() };
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
#define MAT2d_DataMapOfBiIntInteger_HeaderFile
#include <Standard_Integer.hxx>
-#include <MAT2d_MapBiIntHasher.hxx>
+#include <MAT2d_BiInt.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<MAT2d_BiInt,Standard_Integer,MAT2d_MapBiIntHasher> MAT2d_DataMapOfBiIntInteger;
-typedef NCollection_DataMap<MAT2d_BiInt,Standard_Integer,MAT2d_MapBiIntHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfBiIntInteger;
+typedef NCollection_DataMap<MAT2d_BiInt,Standard_Integer> MAT2d_DataMapOfBiIntInteger;
+typedef NCollection_DataMap<MAT2d_BiInt,Standard_Integer>::Iterator MAT2d_DataMapIteratorOfDataMapOfBiIntInteger;
#endif
#include <MAT2d_BiInt.hxx>
#include <TColStd_SequenceOfInteger.hxx>
-#include <MAT2d_MapBiIntHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<MAT2d_BiInt,TColStd_SequenceOfInteger,MAT2d_MapBiIntHasher> MAT2d_DataMapOfBiIntSequenceOfInteger;
-typedef NCollection_DataMap<MAT2d_BiInt,TColStd_SequenceOfInteger,MAT2d_MapBiIntHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfBiIntSequenceOfInteger;
+typedef NCollection_DataMap<MAT2d_BiInt,TColStd_SequenceOfInteger> MAT2d_DataMapOfBiIntSequenceOfInteger;
+typedef NCollection_DataMap<MAT2d_BiInt,TColStd_SequenceOfInteger>::Iterator MAT2d_DataMapIteratorOfDataMapOfBiIntSequenceOfInteger;
#endif
#define MAT2d_DataMapOfIntegerBisec_HeaderFile
#include <Bisector_Bisec.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Bisector_Bisec,TColStd_MapIntegerHasher> MAT2d_DataMapOfIntegerBisec;
-typedef NCollection_DataMap<Standard_Integer,Bisector_Bisec,TColStd_MapIntegerHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerBisec;
+typedef NCollection_DataMap<Standard_Integer,Bisector_Bisec> MAT2d_DataMapOfIntegerBisec;
+typedef NCollection_DataMap<Standard_Integer,Bisector_Bisec>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerBisec;
#endif
#include <Standard_Integer.hxx>
#include <MAT2d_Connexion.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT2d_Connexion),TColStd_MapIntegerHasher> MAT2d_DataMapOfIntegerConnexion;
-typedef NCollection_DataMap<Standard_Integer,Handle(MAT2d_Connexion),TColStd_MapIntegerHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerConnexion;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT2d_Connexion)> MAT2d_DataMapOfIntegerConnexion;
+typedef NCollection_DataMap<Standard_Integer,Handle(MAT2d_Connexion)>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerConnexion;
#endif
#define MAT2d_DataMapOfIntegerPnt2d_HeaderFile
#include <gp_Pnt2d.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,gp_Pnt2d,TColStd_MapIntegerHasher> MAT2d_DataMapOfIntegerPnt2d;
-typedef NCollection_DataMap<Standard_Integer,gp_Pnt2d,TColStd_MapIntegerHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerPnt2d;
+typedef NCollection_DataMap<Standard_Integer,gp_Pnt2d> MAT2d_DataMapOfIntegerPnt2d;
+typedef NCollection_DataMap<Standard_Integer,gp_Pnt2d>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerPnt2d;
#endif
#include <Standard_Integer.hxx>
#include <MAT2d_SequenceOfConnexion.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,MAT2d_SequenceOfConnexion,TColStd_MapIntegerHasher> MAT2d_DataMapOfIntegerSequenceOfConnexion;
-typedef NCollection_DataMap<Standard_Integer,MAT2d_SequenceOfConnexion,TColStd_MapIntegerHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerSequenceOfConnexion;
+typedef NCollection_DataMap<Standard_Integer,MAT2d_SequenceOfConnexion> MAT2d_DataMapOfIntegerSequenceOfConnexion;
+typedef NCollection_DataMap<Standard_Integer,MAT2d_SequenceOfConnexion>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerSequenceOfConnexion;
#endif
#include <Standard_Integer.hxx>
#include <gp_Vec2d.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,gp_Vec2d,TColStd_MapIntegerHasher> MAT2d_DataMapOfIntegerVec2d;
-typedef NCollection_DataMap<Standard_Integer,gp_Vec2d,TColStd_MapIntegerHasher>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerVec2d;
+typedef NCollection_DataMap<Standard_Integer,gp_Vec2d> MAT2d_DataMapOfIntegerVec2d;
+typedef NCollection_DataMap<Standard_Integer,gp_Vec2d>::Iterator MAT2d_DataMapIteratorOfDataMapOfIntegerVec2d;
#endif
+++ /dev/null
-// Created on: 1993-11-19
-// Created by: Yves FRICAUD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 _MAT2d_MapBiIntHasher_HeaderFile
-#define _MAT2d_MapBiIntHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-class MAT2d_BiInt;
-
-
-
-class MAT2d_MapBiIntHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given key, in the range [1, theUpperBound]
- //! @param theKey the key 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 MAT2d_BiInt& theKey, const Standard_Integer theUpperBound);
-
- static Standard_Boolean IsEqual (const MAT2d_BiInt& Key1, const MAT2d_BiInt& Key2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-#include <MAT2d_MapBiIntHasher.lxx>
-
-
-
-
-
-#endif // _MAT2d_MapBiIntHasher_HeaderFile
+++ /dev/null
-// Created on: 1993-11-19
-// Created by: Yves FRICAUD
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 <MAT2d_BiInt.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer MAT2d_MapBiIntHasher::HashCode (const MAT2d_BiInt& theKey, const Standard_Integer theUpperBound)
-{
- return TColStd_MapIntegerHasher::HashCode (theKey.FirstIndex(), theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-inline Standard_Boolean MAT2d_MapBiIntHasher::IsEqual
-(const MAT2d_BiInt& Key1,
- const MAT2d_BiInt& Key2)
-{
- return (Key1 == Key2);
-}
MeshVS_Tool.hxx
MeshVS_TwoColors.cxx
MeshVS_TwoColors.hxx
-MeshVS_TwoColorsHasher.hxx
MeshVS_TwoNodes.hxx
-MeshVS_TwoNodesHasher.hxx
MeshVS_VectorPrsBuilder.cxx
MeshVS_VectorPrsBuilder.hxx
#ifndef MeshVS_DataMapOfColorMapOfInteger_HeaderFile
#define MeshVS_DataMapOfColorMapOfInteger_HeaderFile
-#include <Quantity_ColorHasher.hxx>
+#include <Quantity_Color.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Quantity_Color, TColStd_MapOfInteger, Quantity_ColorHasher> MeshVS_DataMapOfColorMapOfInteger;
-typedef NCollection_DataMap<Quantity_Color, TColStd_MapOfInteger, Quantity_ColorHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger;
+typedef NCollection_DataMap<Quantity_Color, TColStd_MapOfInteger> MeshVS_DataMapOfColorMapOfInteger;
+typedef NCollection_DataMap<Quantity_Color, TColStd_MapOfInteger>::Iterator MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger;
#endif
#include <Standard_Integer.hxx>
#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_HArray1OfSequenceOfInteger),TColStd_MapIntegerHasher> MeshVS_DataMapOfHArray1OfSequenceOfInteger;
-typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_HArray1OfSequenceOfInteger),TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfHArray1OfSequenceOfInteger;
+typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_HArray1OfSequenceOfInteger)> MeshVS_DataMapOfHArray1OfSequenceOfInteger;
+typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_HArray1OfSequenceOfInteger)>::Iterator MeshVS_DataMapIteratorOfDataMapOfHArray1OfSequenceOfInteger;
#endif
#include <Standard_Integer.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TCollection_AsciiString,TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerAsciiString;
-typedef NCollection_DataMap<Standard_Integer,TCollection_AsciiString,TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerAsciiString;
+typedef NCollection_DataMap<Standard_Integer,TCollection_AsciiString> MeshVS_DataMapOfIntegerAsciiString;
+typedef NCollection_DataMap<Standard_Integer,TCollection_AsciiString>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerAsciiString;
#endif
#define MeshVS_DataMapOfIntegerBoolean_HeaderFile
#include <Standard_Integer.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Standard_Boolean,TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerBoolean;
-typedef NCollection_DataMap<Standard_Integer,Standard_Boolean,TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerBoolean;
+typedef NCollection_DataMap<Standard_Integer,Standard_Boolean> MeshVS_DataMapOfIntegerBoolean;
+typedef NCollection_DataMap<Standard_Integer,Standard_Boolean>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerBoolean;
#endif
#include <Standard_Integer.hxx>
#include <Quantity_Color.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Quantity_Color,TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerColor;
-typedef NCollection_DataMap<Standard_Integer,Quantity_Color,TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerColor;
+typedef NCollection_DataMap<Standard_Integer,Quantity_Color> MeshVS_DataMapOfIntegerColor;
+typedef NCollection_DataMap<Standard_Integer,Quantity_Color>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerColor;
#endif
#include <Standard_Integer.hxx>
#include <Graphic3d_MaterialAspect.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Graphic3d_MaterialAspect,TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerMaterial;
-typedef NCollection_DataMap<Standard_Integer,Graphic3d_MaterialAspect,TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerMaterial;
+typedef NCollection_DataMap<Standard_Integer,Graphic3d_MaterialAspect> MeshVS_DataMapOfIntegerMaterial;
+typedef NCollection_DataMap<Standard_Integer,Graphic3d_MaterialAspect>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerMaterial;
#endif
#include <Standard_Integer.hxx>
#include <MeshVS_MeshEntityOwner.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_MeshEntityOwner),TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerMeshEntityOwner;
-typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_MeshEntityOwner),TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerMeshEntityOwner;
+typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_MeshEntityOwner)> MeshVS_DataMapOfIntegerMeshEntityOwner;
+typedef NCollection_DataMap<Standard_Integer,Handle(MeshVS_MeshEntityOwner)>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerMeshEntityOwner;
#endif
#include <Standard_Integer.hxx>
#include <SelectMgr_EntityOwner.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(SelectMgr_EntityOwner),TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerOwner;
-typedef NCollection_DataMap<Standard_Integer,Handle(SelectMgr_EntityOwner),TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerOwner;
+typedef NCollection_DataMap<Standard_Integer,Handle(SelectMgr_EntityOwner)> MeshVS_DataMapOfIntegerOwner;
+typedef NCollection_DataMap<Standard_Integer,Handle(SelectMgr_EntityOwner)>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerOwner;
#endif
#include <Standard_Integer.hxx>
#include <MeshVS_TwoColors.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,MeshVS_TwoColors,TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerTwoColors;
-typedef NCollection_DataMap<Standard_Integer,MeshVS_TwoColors,TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors;
+typedef NCollection_DataMap<Standard_Integer,MeshVS_TwoColors> MeshVS_DataMapOfIntegerTwoColors;
+typedef NCollection_DataMap<Standard_Integer,MeshVS_TwoColors>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerTwoColors;
#endif
#include <Standard_Integer.hxx>
#include <gp_Vec.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,gp_Vec,TColStd_MapIntegerHasher> MeshVS_DataMapOfIntegerVector;
-typedef NCollection_DataMap<Standard_Integer,gp_Vec,TColStd_MapIntegerHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerVector;
+typedef NCollection_DataMap<Standard_Integer,gp_Vec> MeshVS_DataMapOfIntegerVector;
+typedef NCollection_DataMap<Standard_Integer,gp_Vec>::Iterator MeshVS_DataMapIteratorOfDataMapOfIntegerVector;
#endif
#ifndef MeshVS_DataMapOfTwoColorsMapOfInteger_HeaderFile
#define MeshVS_DataMapOfTwoColorsMapOfInteger_HeaderFile
+#include <MeshVS_TwoColors.hxx>
#include <TColStd_MapOfInteger.hxx>
-#include <MeshVS_TwoColorsHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<MeshVS_TwoColors,TColStd_MapOfInteger,MeshVS_TwoColorsHasher> MeshVS_DataMapOfTwoColorsMapOfInteger;
-typedef NCollection_DataMap<MeshVS_TwoColors,TColStd_MapOfInteger,MeshVS_TwoColorsHasher>::Iterator MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger;
+typedef NCollection_DataMap<MeshVS_TwoColors,TColStd_MapOfInteger> MeshVS_DataMapOfTwoColorsMapOfInteger;
+typedef NCollection_DataMap<MeshVS_TwoColors,TColStd_MapOfInteger>::Iterator MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger;
#endif
#include <Standard_Integer.hxx>
#include <MeshVS_EntityType.hxx>
#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <Standard_Address.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <MeshVS_EntityType.hxx>
#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <Standard_Address.hxx>
#include <TColStd_Array1OfInteger.hxx>
class gp_Vec;
Standard_Boolean IsExist = Standard_False;
for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger anIterC2 ( aTwoColorsOfElements );
anIterC2.More() && !IsExist; anIterC2.Next () )
- if ( IsEqual ( anIterC2.Key(), anIterM2.Value() ) )
+ if ( anIterC2.Key() == anIterM2.Value() )
{
TColStd_MapOfInteger& aChangeValue = (TColStd_MapOfInteger&) anIterC2.Value();
aChangeValue.Add ( aMKey );
#ifndef MeshVS_MapOfTwoNodes_HeaderFile
#define MeshVS_MapOfTwoNodes_HeaderFile
-#include <MeshVS_TwoNodesHasher.hxx>
+#include <MeshVS_TwoNodes.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<MeshVS_TwoNodes,MeshVS_TwoNodesHasher> MeshVS_MapOfTwoNodes;
-typedef NCollection_Map<MeshVS_TwoNodes,MeshVS_TwoNodesHasher>::Iterator MeshVS_MapIteratorOfMapOfTwoNodes;
+typedef NCollection_Map<MeshVS_TwoNodes> MeshVS_MapOfTwoNodes;
+typedef NCollection_Map<MeshVS_TwoNodes>::Iterator MeshVS_MapIteratorOfMapOfTwoNodes;
#endif
#define _MeshVS_SymmetricPairHasher_HeaderFile
#include <Standard_Type.hxx>
+#include <Standard_HashUtils.hxx>
typedef std::pair<Standard_Integer, Standard_Integer> MeshVS_NodePair;
//! Provides symmetric hash methods pair of integers.
struct MeshVS_SymmetricPairHasher
{
- //! Computes a hash code for the node pair, in the range [1, theUpperBound]
+ //! Computes a hash code for the node pair
//! @param theNodePair the node pair 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 MeshVS_NodePair& theNodePair, const Standard_Integer theUpperBound)
+ //! @return a computed hash code
+ size_t operator()(const MeshVS_NodePair& theNodePair) const noexcept
{
- return ::HashCode(theNodePair.first + theNodePair.second, theUpperBound);
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theNodePair.first, theNodePair.second };
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
}
- static Standard_Boolean IsEqual (const MeshVS_NodePair& thePair1, const MeshVS_NodePair& thePair2)
+ bool operator()(const MeshVS_NodePair& thePair1, const MeshVS_NodePair& thePair2) const noexcept
{
return (thePair1.first == thePair2.first && thePair1.second == thePair2.second)
- || (thePair1.first == thePair2.second && thePair1.second == thePair2.first);
+ || (thePair1.first == thePair2.second && thePair1.second == thePair2.first);
}
};
#include <MeshVS_TwoColors.hxx>
-
-//================================================================
-// function : HashCode
-// purpose :
-//================================================================
-Standard_Integer HashCode (const MeshVS_TwoColors& theKey, const Standard_Integer theUpperBound)
-{
-#define MESHPRS_HASH_BYTE(val) { \
- aHash += (val); \
- aHash += (aHash << 10); \
- aHash ^= (aHash >> 6); \
- }
- unsigned int aHash = 0;
- MESHPRS_HASH_BYTE (theKey.r1)
- MESHPRS_HASH_BYTE (theKey.g1)
- MESHPRS_HASH_BYTE (theKey.b1)
- MESHPRS_HASH_BYTE (theKey.r2)
- MESHPRS_HASH_BYTE (theKey.g2)
- MESHPRS_HASH_BYTE (theKey.b2)
- aHash += (aHash << 3);
- aHash ^= (aHash >> 11);
- aHash += (aHash << 15);
- return HashCode(aHash, theUpperBound);
-#undef MESHPRS_HASH_BYTE
-}
-
-//================================================================
-// Function : IsEqual
-// Purpose :
-//================================================================
-Standard_Boolean IsEqual (const MeshVS_TwoColors& K1,
- const MeshVS_TwoColors& K2)
-{
- return (((K1.r1 * 256 + K1.g1) * 256 + K1.b1) ==
- ((K2.r1 * 256 + K2.g1) * 256 + K2.b1) &&
- ((K1.r2 * 256 + K1.g2) * 256 + K1.b2) ==
- ((K2.r2 * 256 + K2.g2) * 256 + K2.b2));
-}
-
-//================================================================
-// Function : operator ==
-// Purpose :
-//================================================================
-Standard_Boolean operator== ( const MeshVS_TwoColors& K1,
- const MeshVS_TwoColors& K2 )
-{
- return IsEqual ( K1, K2 );
-}
-
//================================================================
// Function : BindTwoColors
// Purpose :
#include <Quantity_Color.hxx>
-typedef struct {
+struct MeshVS_TwoColors
+{
unsigned int r1 : 8;
unsigned int g1 : 8;
unsigned int b1 : 8;
unsigned int r2 : 8;
unsigned int g2 : 8;
unsigned int b2 : 8;
-} MeshVS_TwoColors;
+ bool operator==(const MeshVS_TwoColors& TwoColors) const
+ {
+ return (((r1 * 256 + g1) * 256 + b1) ==
+ ((TwoColors.r1 * 256 + TwoColors.g1) * 256 + TwoColors.b1) &&
+ ((r2 * 256 + g2) * 256 + b2) ==
+ ((TwoColors.r2 * 256 + TwoColors.g2) * 256 + TwoColors.b2));
+ }
+};
-//! Computes a hash code for the key, in the range [1, theUpperBound]
-//! @param theKey the key 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]
-Standard_EXPORT Standard_Integer HashCode (const MeshVS_TwoColors& theKey, Standard_Integer theUpperBound);
+namespace std
+{
+ template<>
+ struct hash<MeshVS_TwoColors>
+ {
+ size_t operator()(const MeshVS_TwoColors& TwoColors) const noexcept
+ {
+ unsigned int aHash = 0;
+ meshprsHashByte(aHash, TwoColors.r1);
+ meshprsHashByte(aHash, TwoColors.g1);
+ meshprsHashByte(aHash, TwoColors.b1);
+ meshprsHashByte(aHash, TwoColors.r2);
+ meshprsHashByte(aHash, TwoColors.g2);
+ meshprsHashByte(aHash, TwoColors.b2);
+ return std::hash<unsigned int>{}(aHash);
+ }
+ private:
+ void meshprsHashByte(unsigned int& theHash, const unsigned int theValues) const noexcept
+ {
+ theHash += (theValues);
+ theHash += (theHash << 10);
+ theHash ^= (theHash >> 6);
+ }
-Standard_EXPORT Standard_Boolean IsEqual (const MeshVS_TwoColors& K1,
- const MeshVS_TwoColors& K2 );
-
-Standard_EXPORT Standard_Boolean operator== ( const MeshVS_TwoColors& K1,
- const MeshVS_TwoColors& K2 );
+ };
+}
Standard_EXPORT MeshVS_TwoColors BindTwoColors ( const Quantity_Color&, const Quantity_Color& );
Standard_EXPORT Quantity_Color ExtractColor ( MeshVS_TwoColors&, const Standard_Integer );
+++ /dev/null
-// Created on: 2003-10-10
-// Created by: Alexander SOLOVYOV
-// Copyright (c) 2003-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 MeshVS_TwoColorsHasher_HeaderFile
-#define MeshVS_TwoColorsHasher_HeaderFile
-
-#include <MeshVS_TwoColors.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<MeshVS_TwoColors> MeshVS_TwoColorsHasher;
-
-
-#endif
#ifndef MeshVS_TwoNodes_HeaderFile
#define MeshVS_TwoNodes_HeaderFile
-#ifndef _Standard_HeaderFile
#include <Standard.hxx>
-#endif
-#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
-#endif
+#include <Standard_HashUtils.hxx>
//! Structure containing two IDs (of nodes) for using as a key in a map
//! (as representation of a mesh link)
MeshVS_TwoNodes (Standard_Integer aFirst=0, Standard_Integer aSecond=0)
: First(aFirst), Second(aSecond) {}
-};
-//! Computes a hash code for two nodes, in the range [1, theUpperBound]
-//! @param theTwoNodes the object of structure containing two IDs 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]
-inline Standard_Integer HashCode (const MeshVS_TwoNodes& theTwoNodes, const Standard_Integer theUpperBound)
-{
- // symmetrical with respect to theTwoNodes.First and theTwoNodes.Second
- const Standard_Integer aKey = theTwoNodes.First + theTwoNodes.Second;
- return HashCode (aKey, theUpperBound);
-}
-
-//================================================================
-// Function : operator ==
-// Purpose :
-//================================================================
+ bool operator==(const MeshVS_TwoNodes& theTwoNode) const
+ {
+ return ((First == theTwoNode.First) && (Second == theTwoNode.Second)) ||
+ ((First == theTwoNode.Second) && (Second == theTwoNode.First));
+ }
+};
-inline Standard_Boolean operator==( const MeshVS_TwoNodes& obj1,
- const MeshVS_TwoNodes& obj2 )
+namespace std
{
- return ( ( obj1.First == obj2.First ) && ( obj1.Second == obj2.Second ) ) ||
- ( ( obj1.First == obj2.Second ) && ( obj1.Second == obj2.First ) );
+ template<>
+ struct hash<MeshVS_TwoNodes>
+ {
+ size_t operator()(const MeshVS_TwoNodes& theTwoNodes) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theTwoNodes.First, theTwoNodes.Second };
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
}
#endif
+++ /dev/null
-// Created on: 2003-10-10
-// Created by: Alexander SOLOVYOV
-// Copyright (c) 2003-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 MeshVS_TwoNodesHasher_HeaderFile
-#define MeshVS_TwoNodesHasher_HeaderFile
-
-#include <MeshVS_TwoNodes.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<MeshVS_TwoNodes> MeshVS_TwoNodesHasher;
-
-
-#endif
#define _Message_Attribute_HeaderFile
#include <Standard_Transient.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <TCollection_AsciiString.hxx>
DEFINE_STANDARD_HANDLE(Message_Attribute, Standard_Transient)
anIterator.More(); anIterator.Next())
{
OCCT_DUMP_VECTOR_CLASS (theOStream, Message::MetricToString (anIterator.Key()),
- 2, anIterator.Value().first, anIterator.Value().second)
+ 2, anIterator.Value(), anIterator.Value())
}
}
#define _Message_AttributeObject_HeaderFile
#include <Message_Attribute.hxx>
+#include <NCollection_DefineAlloc.hxx>
//! Alert object storing a transient object
#include <Message_ConsoleColor.hxx>
#include <Message_Printer.hxx>
-#include <Standard_Address.hxx>
#include <Standard_OStream.hxx>
class Message_PrinterOStream;
#define _Message_PrinterToReport_HeaderFile
#include <Message_Printer.hxx>
-#include <Standard_Address.hxx>
#include <TCollection_AsciiString.hxx>
class Message_Report;
if (!theName.IsEmpty())
{
myIsOwnName = true;
- myName = (char* )Standard::Allocate (Standard_Size(theName.Length()) + Standard_Size(1));
+ myName = (char* )Standard::AllocateOptimal(Standard_Size(theName.Length()) + Standard_Size(1));
char* aName = (char* )myName;
memcpy (aName, theName.ToCString(), theName.Length());
aName[theName.Length()] = '\0';
MoniTool_DataMapOfTimer.hxx
MoniTool_Element.cxx
MoniTool_Element.hxx
-MoniTool_ElemHasher.cxx
-MoniTool_ElemHasher.hxx
MoniTool_HSequenceOfElement.hxx
MoniTool_IndexedDataMapOfShapeTransient.hxx
MoniTool_IntVal.cxx
MoniTool_IntVal.hxx
MoniTool_Macros.hxx
-MoniTool_MTHasher.cxx
-MoniTool_MTHasher.hxx
-MoniTool_MTHasher.lxx
MoniTool_RealVal.cxx
MoniTool_RealVal.hxx
MoniTool_SequenceOfElement.hxx
#define MoniTool_DataMapOfTimer_HeaderFile
#include <Standard_CString.hxx>
-#include <MoniTool_MTHasher.hxx>
+#include <Standard_CStringHasher.hxx>
#include <NCollection_DataMap.hxx>
class MoniTool_Timer;
-typedef NCollection_DataMap<Standard_CString,Handle(MoniTool_Timer),MoniTool_MTHasher> MoniTool_DataMapOfTimer;
-typedef NCollection_DataMap<Standard_CString,Handle(MoniTool_Timer),MoniTool_MTHasher>::Iterator MoniTool_DataMapIteratorOfDataMapOfTimer;
+typedef NCollection_DataMap<Standard_CString,Handle(MoniTool_Timer), Standard_CStringHasher> MoniTool_DataMapOfTimer;
+typedef NCollection_DataMap<Standard_CString,Handle(MoniTool_Timer), Standard_CStringHasher>::Iterator MoniTool_DataMapIteratorOfDataMapOfTimer;
#endif
+++ /dev/null
-// Copyright (c) 1999-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 <MoniTool_Element.hxx>
-#include <MoniTool_ElemHasher.hxx>
-
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer MoniTool_ElemHasher::HashCode (const Handle (MoniTool_Element) & theElement,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode(theElement->GetHashCode() - 1, theUpperBound);
-}
-
- Standard_Boolean MoniTool_ElemHasher::IsEqual
- (const Handle(MoniTool_Element)& K1, const Handle(MoniTool_Element)& K2)
-{
- if (K1.IsNull()) return Standard_False;
- return K1->Equates(K2);
-}
+++ /dev/null
-// Created on: 1994-11-04
-// Created by: Christian CAILLET
-// Copyright (c) 1994-1999 Matra Datavision
-// Copyright (c) 1999-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 _MoniTool_ElemHasher_HeaderFile
-#define _MoniTool_ElemHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Standard_Integer.hxx>
-class MoniTool_Element;
-
-
-//! ElemHasher defines HashCode for Element, which is : ask a
-//! Element its HashCode ! Because this is the Element itself
-//! which brings the HashCode for its Key
-//!
-//! This class complies to the template given in TCollection by
-//! MapHasher itself
-class MoniTool_ElemHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns hash code for the given element, in the range [1, theUpperBound].
- //! Asks theElement its HashCode, then transforms it to be in the required range.
- //! @param theElement the element 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]
- Standard_EXPORT static Standard_Integer HashCode (const Handle (MoniTool_Element) & theElement,
- Standard_Integer theUpperBound);
-
- //! Returns True if two keys are the same.
- //! The test does not work on the Elements themselves but by
- //! calling their methods Equates
- Standard_EXPORT static Standard_Boolean IsEqual (const Handle(MoniTool_Element)& K1, const Handle(MoniTool_Element)& K2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-
-
-
-
-
-#endif // _MoniTool_ElemHasher_HeaderFile
IMPLEMENT_STANDARD_RTTIEXT(MoniTool_Element,Standard_Transient)
MoniTool_Element::MoniTool_Element()
-: thecode(-1)
+: thecode(0)
{
}
-void MoniTool_Element::SetHashCode (const Standard_Integer code)
+void MoniTool_Element::SetHashCode (const size_t code)
{ thecode = code; }
- Standard_Integer MoniTool_Element::GetHashCode () const
+ size_t MoniTool_Element::GetHashCode () const
{ return thecode; }
Handle(Standard_Type) MoniTool_Element::ValueType () const
//! Returns the HashCode which has been stored by SetHashCode
//! (remark that HashCode could be deferred then be defined by
//! sub-classes, the result is the same)
- Standard_EXPORT Standard_Integer GetHashCode() const;
+ Standard_EXPORT size_t GetHashCode() const;
//! Specific testof equality : to be defined by each sub-class,
//! must be False if Elements have not the same true Type, else
//! Stores the HashCode which corresponds to the Value given to
//! create the Mapper
- Standard_EXPORT void SetHashCode (const Standard_Integer code);
+ Standard_EXPORT void SetHashCode (const size_t code);
private:
- Standard_Integer thecode;
+ size_t thecode;
MoniTool_AttrList theattrib;
+++ /dev/null
-// Created on: 2001-12-19
-// Created by: Sergey KUUL
-// Copyright (c) 2001-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.
+++ /dev/null
-// Created on: 2001-12-19
-// Created by: Sergey KUUL
-// Copyright (c) 2001-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 _MoniTool_MTHasher_HeaderFile
-#define _MoniTool_MTHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Standard_Boolean.hxx>
-
-
-
-//! The auxiliary class provides hash code for mapping objects
-class MoniTool_MTHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Returns hash code for the given string, in the range [1, theUpperBound]
- //! @param theString the string 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 (Standard_CString theString, Standard_Integer theUpperBound);
-
- //! Returns True when the two CString are the same. Two
- //! same strings must have the same hashcode, the
- //! contrary is not necessary.
- //! Default Str1 == Str2
- static Standard_Boolean IsEqual (const Standard_CString Str1, const Standard_CString Str2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-#include <MoniTool_MTHasher.lxx>
-
-
-
-
-
-#endif // _MoniTool_MTHasher_HeaderFile
+++ /dev/null
-// Copyright (c) 1999-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 <string.h>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer MoniTool_MTHasher::HashCode (const Standard_CString theString,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode (theString, theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-
-inline Standard_Boolean MoniTool_MTHasher::IsEqual(const Standard_CString Str1,
- const Standard_CString Str2)
-{
- return ! strcmp(Str1,Str2);
-}
-
-
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
-#include <TColStd_MapTransientHasher.hxx>
IMPLEMENT_STANDARD_RTTIEXT(MoniTool_TransientElem,MoniTool_Element)
MoniTool_TransientElem::MoniTool_TransientElem (const Handle(Standard_Transient)& akey)
: theval (akey)
-{ SetHashCode ( TColStd_MapTransientHasher::HashCode (akey, IntegerLast() ) ); }
+{ SetHashCode ( std::hash<Handle(Standard_Transient)>{}(akey)); }
const Handle(Standard_Transient)& MoniTool_TransientElem::Value () const
if (other->DynamicType() != DynamicType()) return Standard_False;
Handle(MoniTool_TransientElem) another = Handle(MoniTool_TransientElem)::DownCast(other);
// return (theval == another->Value());
- return TColStd_MapTransientHasher::IsEqual (theval,another->Value());
+ return theval == another->Value();
}
Handle(Standard_Type) MoniTool_TransientElem::ValueType () const
NCollection_AliasedArray.hxx
NCollection_AlignedAllocator.cxx
NCollection_AlignedAllocator.hxx
+NCollection_Allocator.hxx
NCollection_Array1.hxx
NCollection_Array2.hxx
NCollection_BaseAllocator.cxx
NCollection_BaseList.hxx
NCollection_BaseMap.cxx
NCollection_BaseMap.hxx
+NCollection_BasePointerVector.cxx
+NCollection_BasePointerVector.hxx
NCollection_BaseSequence.cxx
NCollection_BaseSequence.hxx
-NCollection_BaseVector.cxx
-NCollection_BaseVector.hxx
NCollection_Buffer.hxx
NCollection_CellFilter.hxx
NCollection_DataMap.hxx
NCollection_DefaultHasher.hxx
NCollection_DefineAlloc.hxx
-NCollection_DefineArray1.hxx
-NCollection_DefineArray2.hxx
-NCollection_DefineDataMap.hxx
-NCollection_DefineDoubleMap.hxx
NCollection_DefineHArray1.hxx
NCollection_DefineHArray2.hxx
+NCollection_DefineHasher.hxx
NCollection_DefineHSequence.hxx
-NCollection_DefineIndexedDataMap.hxx
-NCollection_DefineIndexedMap.hxx
-NCollection_DefineList.hxx
-NCollection_DefineMap.hxx
-NCollection_DefineSequence.hxx
-NCollection_DefineVector.hxx
NCollection_DoubleMap.hxx
+NCollection_DynamicArray.hxx
NCollection_EBTree.hxx
NCollection_Haft.h
NCollection_Handle.hxx
NCollection_IncAllocator.cxx
NCollection_IncAllocator.hxx
NCollection_IndexedDataMap.hxx
+NCollection_IndexedIterator.hxx
NCollection_IndexedMap.hxx
+NCollection_Iterator.hxx
NCollection_Lerp.hxx
NCollection_List.hxx
NCollection_ListNode.hxx
NCollection_Map.hxx
NCollection_Mat3.hxx
NCollection_Mat4.hxx
+NCollection_OccAllocator.hxx
NCollection_Sequence.hxx
NCollection_Shared.hxx
NCollection_SparseArray.hxx
NCollection_SparseArrayBase.cxx
NCollection_SparseArrayBase.hxx
-NCollection_StdAllocator.hxx
NCollection_StlIterator.hxx
NCollection_String.hxx
NCollection_TListIterator.hxx
// If there are no more blocks, reallocate the block to the default size
else
{
+ const Standard_Size aRoundSize = (myBlockSize + 3) & ~0x3;
Standard_Address aNewAddress = Standard::Reallocate(anAddress,
- myBlockSize);
+ aRoundSize);
if (aNewAddress == anAddress)
{
// Normally, the reallocation keeps the block at the same address
NCollection_AccAllocator::Block*
NCollection_AccAllocator::allocateNewBlock(const Standard_Size theSize)
{
- Standard_Address anAddress = Standard::Allocate(theSize);
+ const Standard_Size aRoundSize = (theSize + 3) & ~0x3;
+ Standard_Address anAddress = Standard::Allocate(aRoundSize);
// we depend on the fact that Standard::Allocate always returns
// a pointer aligned to a 4 byte boundary
mypLastBlock = myBlocks.Bound(getKey(anAddress),
//! Allocate memory with given size
Standard_EXPORT virtual void* Allocate (const size_t theSize) Standard_OVERRIDE;
+ //! Allocate memory with given size
+ void* AllocateOptimal(const size_t theSize) Standard_OVERRIDE
+ {
+ return Allocate(theSize);
+ }
+
//! Free a previously allocated memory;
//! memory is returned to the OS when all allocations in some block are freed
Standard_EXPORT virtual void Free (void* theAddress) Standard_OVERRIDE;
class Hasher
{
public:
- //! Returns hash code for the given key, in the range [1, theUpperBound]
+ //! Returns hash code for the given key
//! @param theKey the key 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 Key theKey, const Standard_Integer theUpperBound)
+ //! @return a computed hash code
+ size_t operator() (const Key theKey) const noexcept
{
- return ::HashCode (theKey.Value, theUpperBound);
+ return theKey.Value;
}
- static Standard_Boolean IsEqual(const Key theOne, const Key theTwo)
- { return theOne.Value == theTwo.Value; }
+ bool operator() (const Key theKey1, const Key theKey2) const noexcept
+ {
+ return theKey1.Value == theKey2.Value;
+ }
};
//! Descriptor of a block
//! Allocate memory with given size. Returns NULL on failure.
Standard_EXPORT virtual void* Allocate (const size_t theSize) Standard_OVERRIDE;
+ //! Allocate memory with given size. Returns NULL on failure.
+ void* AllocateOptimal(const size_t theSize) Standard_OVERRIDE
+ {
+ return Allocate(theSize);
+ }
+
//! Free a previously allocated memory.
Standard_EXPORT virtual void Free (void* thePtr) Standard_OVERRIDE;
--- /dev/null
+// Copyright (c) 2023 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_Allocator_HeaderFile
+#define _NCollection_Allocator_HeaderFile
+
+#include <Standard.hxx>
+#include <NCollection_BaseAllocator.hxx>
+
+#include <utility>
+
+//! Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.
+/*! The allocator uses a standard OCCT mechanism for memory
+ allocation and deallocation. It can be used with standard
+ containers (std::vector, std::map, etc.) to take advantage of OCCT memory optimizations.
+
+ Example of use:
+ \code
+ NCollection_Allocator<TopoDS_Shape> anSAllocator();
+ std::list<TopoDS_Shape, NCollection_Allocator<TopoDS_Shape>> aList(anSAllocator);
+ TopoDS_Solid aSolid = BRepPrimAPI_MakeBox(10., 20., 30.);
+ aList.push_back(aSolid);
+ \endcode
+*/
+template <typename ItemType>
+class NCollection_Allocator
+{
+public:
+ typedef ItemType value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ template <typename OtherType>
+ struct rebind
+ {
+ typedef NCollection_Allocator<OtherType> other;
+ };
+
+ //! Constructor.
+ //! Creates an object using the default Open CASCADE allocation mechanism, i.e., which uses
+ //! Standard::Allocate() and Standard::Free() underneath.
+ NCollection_Allocator() noexcept
+ {}
+
+ //! Constructor.
+ NCollection_Allocator(const Handle(NCollection_BaseAllocator)&) noexcept
+ {}
+
+ //! Assignment operator
+ template <typename OtherType>
+ NCollection_Allocator& operator=(const NCollection_Allocator<OtherType>&) noexcept
+ {
+ return *this;
+ }
+ //! Constructor.
+ //! Creates an object using the default Open CASCADE allocation mechanism, i.e., which uses
+ //! Standard::Allocate() and Standard::Free() underneath.
+ template <typename OtherType>
+ NCollection_Allocator(const NCollection_Allocator<OtherType>&) noexcept
+ {}
+
+ //! Returns an object address.
+ pointer address(reference theItem) const
+ {
+ return &theItem;
+ }
+
+ //! Returns an object address.
+ const_pointer address(const_reference theItem) const
+ {
+ return &theItem;
+ }
+
+ //! Allocates memory for theSize objects.
+ pointer allocate(const size_type theSize, const void* /*hint*/ = 0) const
+ {
+ return static_cast<pointer>(Standard::AllocateOptimal(theSize * sizeof(ItemType)));
+ }
+
+ //! Frees previously allocated memory.
+ void deallocate(pointer thePnt, const size_type) const
+ {
+ Standard::Free(static_cast<Standard_Address>(thePnt));
+ }
+
+ //! Reallocates memory for theSize objects.
+ pointer reallocate(pointer thePnt, const size_type theSize) const
+ {
+ return static_cast<pointer>(Standard::Reallocate(thePnt, theSize * sizeof(ItemType)));
+ }
+
+ //! Constructs an object.
+ //! Uses placement new operator and copy constructor to construct an object.
+ template<class _Objty, class... _Types>
+ void construct(_Objty* _Ptr, _Types&&... _Args)
+ {
+ ::new ((void*)_Ptr) _Objty(std::forward<_Types>(_Args)...);
+ }
+
+ //! Destroys the object.
+ //! Uses the object destructor.
+ void destroy(pointer thePnt)
+ {
+ (void)thePnt; thePnt->~value_type();
+ }
+
+ bool operator==(const NCollection_Allocator&) const
+ {
+ return true;
+ }
+
+ template<class U>
+ bool operator==(const NCollection_Allocator<U>&) const noexcept
+ {
+ return true;
+ }
+
+ bool operator!=(const NCollection_Allocator&) const noexcept
+ {
+ return false;
+ }
+
+ template<class U>
+ bool operator!=(const NCollection_Allocator<U>&) const noexcept
+ {
+ return false;
+ }
+
+};
+
+template<class U, class V>
+bool operator==(const NCollection_Allocator<U>&, const NCollection_Allocator<V>&)
+{
+ return true;
+}
+
+#endif
-// Created on: 2002-04-15
-// Created by: Alexander Kartomin (akm)
-// Copyright (c) 2002-2014 OPEN CASCADE SAS
+// Copyright (c) 2002-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#include <Standard_DimensionMismatch.hxx>
#include <Standard_OutOfMemory.hxx>
+#include <Standard_NotImplemented.hxx>
#include <Standard_OutOfRange.hxx>
#include <NCollection_DefineAlloc.hxx>
-#include <NCollection_StlIterator.hxx>
+#include <NCollection_Iterator.hxx>
+#include <NCollection_Allocator.hxx>
+#include <StdFail_NotDone.hxx>
+#include <NCollection_IndexedIterator.hxx>
+
+#include <algorithm>
+#include <array>
+#include <vector>
//! The class NCollection_Array1 represents unidimensional arrays of fixed size known at run time.
//! The range of the index is user defined.
class NCollection_Array1
{
public:
- //! STL-compliant typedef for value type
- typedef TheItemType value_type;
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC;
+ DEFINE_NCOLLECTION_ALLOC;
+public:
+ typedef NCollection_Allocator<TheItemType> allocator_type;
+public:
+ // Define various type aliases for convenience
+ using value_type = TheItemType;
+ using size_type = size_t;
+ using difference_type = size_t;
+ using pointer = TheItemType*;
+ using const_pointer = const TheItemType*;
+ using reference = TheItemType&;
+ using const_reference = const TheItemType&;
+
+ using iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_Array1, value_type, false>;
+ using const_iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_Array1, value_type, true>;
public:
- //! Implementation of the Iterator interface.
- class Iterator
+
+ // Iterator class
+ class Iterator : public NCollection_Iterator<NCollection_Array1>
{
public:
+ using NCollection_Iterator<NCollection_Array1>::NCollection_Iterator;
- //! Empty constructor - for later Init
- Iterator (void) :
- myPtrCur (NULL),
- myPtrEnd (NULL)
+ const_reference Value() const
{
- //
+ return *NCollection_Iterator<NCollection_Array1>::ValueIter();
}
- //! Constructor with initialization
- Iterator (const NCollection_Array1& theArray, Standard_Boolean theToEnd = Standard_False) :
- myPtrEnd (const_cast<TheItemType*> (&theArray.Last() + 1))
+ reference ChangeValue()
{
- myPtrCur = theToEnd ? myPtrEnd : const_cast<TheItemType*> (&theArray.First());
+ return *NCollection_Iterator<NCollection_Array1>::ChangeValueIter();
}
+ };
- //! Initialisation
- void Init (const NCollection_Array1& theArray)
- {
- myPtrCur = const_cast<TheItemType*> (&theArray.First());
- myPtrEnd = const_cast<TheItemType*> (&theArray.Last() + 1);
- }
-
- //! Check end
- Standard_Boolean More (void) const
- { return myPtrCur < myPtrEnd; }
-
- //! Increment operator
- void Next (void)
- { ++myPtrCur; }
-
- //! Decrement operator
- void Previous()
- { --myPtrCur; }
-
- //! Offset operator.
- void Offset (ptrdiff_t theOffset)
- { myPtrCur += theOffset; }
-
- //! Difference operator.
- ptrdiff_t Differ (const Iterator& theOther) const
- { return myPtrCur - theOther.myPtrCur; }
-
- //! Constant value access
- const TheItemType& Value (void) const
- { return *myPtrCur; }
-
- //! Variable value access
- TheItemType& ChangeValue (void) const
- { return *myPtrCur; }
-
- //! Performs comparison of two iterators
- Standard_Boolean IsEqual (const Iterator& theOther) const
- { return myPtrCur == theOther.myPtrCur; }
-
- private:
- TheItemType* myPtrCur; //!< Pointer to the current element in the array
- TheItemType* myPtrEnd; //!< Pointer to the past-the-end element in the array
- }; // End of the nested class Iterator
-
- //! Shorthand for a regular iterator type.
- typedef NCollection_StlIterator<std::random_access_iterator_tag, Iterator, TheItemType, false> iterator;
+ const_iterator begin() const
+ {
+ return const_iterator(*this);
+ }
- //! Shorthand for a constant iterator type.
- typedef NCollection_StlIterator<std::random_access_iterator_tag, Iterator, TheItemType, true> const_iterator;
+ iterator begin()
+ {
+ return iterator(*this);
+ }
- //! Returns an iterator pointing to the first element in the array.
- iterator begin() const { return Iterator (*this, false); }
+ const_iterator cbegin() const
+ {
+ return const_iterator(*this);
+ }
- //! Returns an iterator referring to the past-the-end element in the array.
- iterator end() const { return Iterator (*this, true); }
-
- //! Returns a const iterator pointing to the first element in the array.
- const_iterator cbegin() const { return Iterator (*this, false); }
+ iterator end()
+ {
+ return iterator(mySize, *this);
+ }
- //! Returns a const iterator referring to the past-the-end element in the array.
- const_iterator cend() const { return Iterator (*this, true); }
+ const_iterator end() const
+ {
+ return const_iterator(mySize, *this);
+ }
- public:
- // ---------- PUBLIC METHODS ------------
+ const_iterator cend() const
+ {
+ return const_iterator(mySize, *this);
+ }
- //! Empty constructor; should be used with caution.
- //! @sa methods Resize() and Move().
- NCollection_Array1()
- : myLowerBound (1),
- myUpperBound (0),
- myDeletable (Standard_False),
- myData (NULL)
+public:
+ // Constructors
+ NCollection_Array1() :
+ myLowerBound(1),
+ mySize(0)
+ {}
+
+ explicit NCollection_Array1(const Standard_Integer theLower,
+ const Standard_Integer theUpper) :
+ myLowerBound(theLower),
+ mySize(theUpper - theLower + 1)
{
- //
+ if (mySize == 0)
+ {
+ return;
+ }
+ myPointer = myAllocator.allocate(mySize);
+ myIsOwner = true;
+ construct();
}
- //! Constructor
- NCollection_Array1(const Standard_Integer theLower,
- const Standard_Integer theUpper) :
- myLowerBound (theLower),
- myUpperBound (theUpper),
- myDeletable (Standard_True)
+ explicit NCollection_Array1(const allocator_type& theAlloc,
+ const Standard_Integer theLower,
+ const Standard_Integer theUpper) :
+ myLowerBound(theLower),
+ mySize(theUpper - theLower + 1),
+ myPointer(nullptr),
+ myIsOwner(false),
+ allocator_type(theAlloc)
{
- Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Create");
- TheItemType* pBegin = new TheItemType[Length()];
- Standard_OutOfMemory_Raise_if (!pBegin, "NCollection_Array1 : Allocation failed");
+ if (mySize == 0)
+ {
+ return;
+ }
+ myPointer = myAllocator.allocate(mySize);
+ myIsOwner = true;
+ construct();
+ }
- myData = pBegin - theLower;
+ explicit NCollection_Array1(const_reference theBegin,
+ const Standard_Integer theLower,
+ const Standard_Integer theUpper,
+ const bool theUseBuffer = true) :
+ myLowerBound(theLower),
+ mySize(theUpper - theLower + 1),
+ myPointer(theUseBuffer ? const_cast<pointer>(&theBegin) : nullptr),
+ myIsOwner(!theUseBuffer)
+ {
+ if (!myIsOwner)
+ {
+ return;
+ }
+ myPointer = myAllocator.allocate(mySize);
+ myIsOwner = true;
+ construct();
}
//! Copy constructor
- NCollection_Array1 (const NCollection_Array1& theOther) :
- myLowerBound (theOther.Lower()),
- myUpperBound (theOther.Upper()),
- myDeletable (Standard_True)
+ NCollection_Array1(const NCollection_Array1& theOther) :
+ myLowerBound(theOther.myLowerBound),
+ mySize(theOther.mySize)
{
- TheItemType* pBegin = new TheItemType[Length()];
- Standard_OutOfMemory_Raise_if (!pBegin, "NCollection_Array1 : Allocation failed");
- myData = pBegin - myLowerBound;
-
- Assign (theOther);
+ if (mySize == 0)
+ {
+ return;
+ }
+ myPointer = myAllocator.allocate(mySize);
+ myIsOwner = true;
+ copyConstruct(theOther.myPointer, mySize);
}
//! Move constructor
- NCollection_Array1 (NCollection_Array1&& theOther)
- : myLowerBound (theOther.myLowerBound),
- myUpperBound (theOther.myUpperBound),
- myDeletable (theOther.myDeletable),
- myData (theOther.myData)
- {
- theOther.myDeletable = false;
- }
-
- //! C array-based constructor.
- //!
- //! Makes this array to use the buffer pointed by theBegin
- //! instead of allocating it dynamically.
- //! Argument theBegin should be a reference to the first element
- //! of the pre-allocated buffer (usually local C array buffer),
- //! with size at least theUpper - theLower + 1 items.
- //!
- //! Warning: returning array object created using this constructor
- //! from function by value will result in undefined behavior
- //! if compiler performs return value optimization (this is likely
- //! to be true for all modern compilers in release mode).
- //! The same happens if array is copied using Move() function
- //! or move constructor and target object's lifespan is longer
- //! than that of the buffer.
- NCollection_Array1 (const TheItemType& theBegin,
- const Standard_Integer theLower,
- const Standard_Integer theUpper) :
- myLowerBound (theLower),
- myUpperBound (theUpper),
- myDeletable (Standard_False)
- {
- Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Create");
- #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
- // gcc emits -Warray-bounds warning when NCollection_Array1 is initialized
- // from local array with lower index 1 (so that (&theBegin - 1) points out of array bounds).
- // NCollection_Array1 initializes myData with a shift to avoid this shift within per-element access.
- // It is undesired changing this logic, and -Warray-bounds is not useful here.
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Warray-bounds"
- #endif
- myData = (TheItemType *) &theBegin - theLower;
- #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
- #pragma GCC diagnostic pop
- #endif
+ NCollection_Array1(NCollection_Array1&& theOther) noexcept :
+ myLowerBound(theOther.myLowerBound),
+ mySize(theOther.mySize),
+ myPointer(theOther.myPointer),
+ myIsOwner(theOther.myIsOwner)
+ {
+ theOther.myIsOwner = false;
+ }
+
+ virtual ~NCollection_Array1()
+ {
+ if (!myIsOwner)
+ {
+ return;
+ }
+ destroy();
+ myAllocator.deallocate(myPointer, mySize);
}
//! Initialise the items with theValue
- void Init (const TheItemType& theValue)
+ void Init(const_reference theValue)
{
- TheItemType *pCur = &myData[myLowerBound], *pEnd=&myData[myUpperBound];
- for(; pCur <= pEnd; pCur++)
- *pCur = (TheItemType&) theValue;
+ for (size_t anIter = 0; anIter < mySize; anIter++)
+ {
+ myPointer[anIter] = theValue;
+ }
}
//! Size query
- Standard_Integer Size (void) const
- { return Length(); }
+ Standard_Integer Size() const
+ {
+ return Length();
+ }
+
//! Length query (the same)
- Standard_Integer Length (void) const
- { return (myUpperBound-myLowerBound+1); }
+ Standard_Integer Length() const
+ {
+ return static_cast<Standard_Integer>(mySize);
+ }
//! Return TRUE if array has zero length.
- Standard_Boolean IsEmpty() const { return myUpperBound < myLowerBound; }
+ Standard_Boolean IsEmpty() const
+ {
+ return mySize == 0;
+ }
//! Lower bound
- Standard_Integer Lower (void) const
- { return myLowerBound; }
- //! Upper bound
- Standard_Integer Upper (void) const
- { return myUpperBound; }
-
- //! myDeletable flag
- Standard_Boolean IsDeletable (void) const
- { return myDeletable; }
+ Standard_Integer Lower() const
+ {
+ return myLowerBound;
+ }
- //! IsAllocated flag - for naming compatibility
- Standard_Boolean IsAllocated (void) const
- { return myDeletable; }
+ //! Upper bound
+ Standard_Integer Upper() const
+ {
+ return myLowerBound + static_cast<int>(mySize) - 1;
+ }
//! Copies data of theOther array to this.
//! This array should be pre-allocated and have the same length as theOther;
//! otherwise exception Standard_DimensionMismatch is thrown.
- NCollection_Array1& Assign (const NCollection_Array1& theOther)
+ NCollection_Array1& Assign(const NCollection_Array1& theOther)
{
if (&theOther == this)
- return *this;
-
- Standard_DimensionMismatch_Raise_if (Length() != theOther.Length(), "NCollection_Array1::operator=");
- if (myData == NULL)
{
return *this;
}
-
- TheItemType * pMyItem = &myData[myLowerBound];
- TheItemType * const pEndItem = &(theOther.myData)[theOther.myUpperBound];
- TheItemType * pItem = &(theOther.myData)[theOther.myLowerBound];
- while (pItem <= pEndItem) * pMyItem ++ = * pItem ++;
+ Standard_DimensionMismatch_Raise_if(mySize != theOther.mySize, "NCollection_Array1::operator=");
+ for (size_t anInd = 0; anInd < mySize; anInd++)
+ {
+ myPointer[anInd] = theOther.myPointer[anInd];
+ }
+ // Current implementation disable changing bounds by assigning
return *this;
}
//! This array will borrow all the data from theOther.
//! The moved object will keep pointer to the memory buffer and
//! range, but it will not free the buffer on destruction.
- NCollection_Array1& Move (NCollection_Array1& theOther)
+ NCollection_Array1& Move(NCollection_Array1&& theOther) noexcept
{
if (&theOther == this)
{
return *this;
}
-
- if (myDeletable)
+ if (myIsOwner)
{
- delete[] &myData[myLowerBound];
+ destroy();
+ myAllocator.deallocate(myPointer, mySize);
}
-
myLowerBound = theOther.myLowerBound;
- myUpperBound = theOther.myUpperBound;
- myDeletable = theOther.myDeletable;
- myData = theOther.myData;
-
- theOther.myDeletable = Standard_False;
-
+ mySize = theOther.mySize;
+ myPointer = theOther.myPointer;
+ myIsOwner = theOther.myIsOwner;
+ theOther.myIsOwner = false;
return *this;
}
+ NCollection_Array1& Move(NCollection_Array1& theOther)
+ {
+ return Move(std::move(theOther));
+ }
+
//! Assignment operator; @sa Assign()
NCollection_Array1& operator= (const NCollection_Array1& theOther)
- {
- return Assign (theOther);
+ {
+ return Assign(theOther);
}
//! Move assignment operator; @sa Move()
- NCollection_Array1& operator= (NCollection_Array1&& theOther)
+ NCollection_Array1& operator= (NCollection_Array1&& theOther) noexcept
{
- return Move (theOther);
+ return Move(std::forward<NCollection_Array1>(theOther));
}
//! @return first element
- const TheItemType& First() const
+ const_reference First() const
{
- return myData[myLowerBound];
+ return myPointer[0];
}
//! @return first element
- TheItemType& ChangeFirst()
+ reference ChangeFirst()
{
- return myData[myLowerBound];
+ return myPointer[0];
}
//! @return last element
- const TheItemType& Last() const
+ const_reference Last() const
{
- return myData[myUpperBound];
+ return myPointer[mySize - 1];
}
//! @return last element
- TheItemType& ChangeLast()
+ reference ChangeLast()
{
- return myData[myUpperBound];
+ return myPointer[mySize - 1];
}
//! Constant value access
- const TheItemType& Value (const Standard_Integer theIndex) const
+ const_reference Value(const Standard_Integer theIndex) const
{
- Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::Value");
- return myData[theIndex];
+ const size_t aPos = theIndex - myLowerBound;
+ Standard_OutOfRange_Raise_if(aPos >= mySize, "NCollection_Array1::Value");
+ return myPointer[aPos];
}
//! operator() - alias to Value
- const TheItemType& operator() (const Standard_Integer theIndex) const
- { return Value (theIndex); }
+ const_reference operator() (const Standard_Integer theIndex) const
+ {
+ return Value(theIndex);
+ }
//! operator[] - alias to Value
- const TheItemType& operator[] (Standard_Integer theIndex) const { return Value (theIndex); }
+ const_reference operator[] (const Standard_Integer theIndex) const
+ {
+ return Value(theIndex);
+ }
//! Variable value access
- TheItemType& ChangeValue (const Standard_Integer theIndex)
+ reference ChangeValue(const Standard_Integer theIndex)
{
- Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::ChangeValue");
- return myData[theIndex];
+ const size_t aPos = theIndex - myLowerBound;
+ Standard_OutOfRange_Raise_if(aPos >= mySize, "NCollection_Array1::ChangeValue");
+ return myPointer[aPos];
}
//! operator() - alias to ChangeValue
- TheItemType& operator() (const Standard_Integer theIndex)
- { return ChangeValue (theIndex); }
+ reference operator() (const Standard_Integer theIndex)
+ {
+ return ChangeValue(theIndex);
+ }
//! operator[] - alias to ChangeValue
- TheItemType& operator[] (Standard_Integer theIndex) { return ChangeValue (theIndex); }
+ reference operator[] (const Standard_Integer theIndex)
+ {
+ return ChangeValue(theIndex);
+ }
+
+ //! Set value
+ void SetValue(const Standard_Integer theIndex,
+ const value_type& theItem)
+ {
+ const size_t aPos = theIndex - myLowerBound;
+ Standard_OutOfRange_Raise_if(aPos >= mySize, "NCollection_Array1::SetValue");
+ myPointer[aPos] = theItem;
+ }
//! Set value
- void SetValue (const Standard_Integer theIndex,
- const TheItemType& theItem)
+ void SetValue(const Standard_Integer theIndex,
+ value_type&& theItem)
{
- Standard_OutOfRange_Raise_if (theIndex < myLowerBound || theIndex > myUpperBound, "NCollection_Array1::SetValue");
- myData[theIndex] = theItem;
+ const size_t aPos = theIndex - myLowerBound;
+ Standard_OutOfRange_Raise_if(aPos >= mySize, "NCollection_Array1::SetValue");
+ myPointer[aPos] = std::forward<value_type>(theItem);
+ }
+
+ //! Changes the lowest bound. Do not move data
+ void UpdateLowerBound(const Standard_Integer theLower)
+ {
+ myLowerBound = theLower;
+ }
+
+ //! Changes the upper bound. Do not move data
+ void UpdateUpperBound(const Standard_Integer theUpper)
+ {
+ myLowerBound = myLowerBound - Upper() + theUpper;
}
//! Resizes the array to specified bounds.
//! @param theLower new lower bound of array
//! @param theUpper new upper bound of array
//! @param theToCopyData flag to copy existing data into new array
- void Resize (const Standard_Integer theLower,
- const Standard_Integer theUpper,
- const Standard_Boolean theToCopyData)
+ void Resize(const Standard_Integer theLower,
+ const Standard_Integer theUpper,
+ const Standard_Boolean theToCopyData)
{
- Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Resize");
- const Standard_Integer anOldLen = Length();
- const Standard_Integer aNewLen = theUpper - theLower + 1;
-
- TheItemType* aBeginOld = myData != NULL ? &myData[myLowerBound] : NULL;
- myLowerBound = theLower;
- myUpperBound = theUpper;
- if (aNewLen == anOldLen)
+ Standard_RangeError_Raise_if(theUpper < theLower, "NCollection_Array1::Resize");
+ const size_t aNewSize = static_cast<size_t>(theUpper - theLower + 1);
+ const size_t anOldSize = mySize;
+ pointer aPrevContPnt = myPointer;
+ if (aNewSize == anOldSize)
{
- myData = aBeginOld - theLower;
+ myLowerBound = theLower;
return;
}
+ if (myIsOwner)
+ {
+ if (theToCopyData)
+ destroy(myPointer, aNewSize, mySize);
+ else
+ destroy();
+ }
+ myLowerBound = theLower;
+ mySize = aNewSize;
+ if (theToCopyData)
+ {
+ const size_t aMinSize = std::min<size_t>(aNewSize, anOldSize);
+ if (myIsOwner)
+ {
+ myPointer = myAllocator.reallocate(myPointer, aNewSize);
+ }
+ else
+ {
+ myPointer = myAllocator.allocate(aNewSize);
+ copyConstruct(aPrevContPnt, aMinSize);
+ }
+ construct(anOldSize, aNewSize);
+ }
+ else
+ {
+ if (myIsOwner)
+ myAllocator.deallocate(aPrevContPnt, mySize);
+ myPointer = myAllocator.allocate(aNewSize);
+ construct();
+ }
+ myIsOwner = true;
+ }
+
+ bool IsDeletable() const
+ {
+ return myIsOwner;
+ }
+
+ friend iterator;
+ friend const_iterator;
+
+protected:
+
+ const_reference at(const size_t theIndex) const
+ {
+ Standard_OutOfRange_Raise_if(theIndex >= mySize, "NCollection_Array1::at");
+ return myPointer[theIndex];
+ }
+
+ reference at(const size_t theIndex)
+ {
+ Standard_OutOfRange_Raise_if(theIndex >= mySize, "NCollection_Array1::at");
+ return myPointer[theIndex];
+ }
+
+protected:
+
+ template <typename U = TheItemType>
+ typename std::enable_if<std::is_arithmetic<U>::value, void>::type construct()
+ {
+ // Do nothing
+ }
- if (!theToCopyData && myDeletable)
+ template <typename U = TheItemType>
+ typename std::enable_if<!std::is_arithmetic<U>::value, void>::type construct()
+ {
+ for (size_t anInd = 0; anInd < mySize; anInd++)
{
- delete[] aBeginOld;
+ myAllocator.construct(myPointer + anInd);
}
- TheItemType* aBeginNew = new TheItemType[aNewLen];
- Standard_OutOfMemory_Raise_if (aBeginNew == NULL, "NCollection_Array1 : Allocation failed");
- myData = aBeginNew - theLower;
- if (!theToCopyData)
+ }
+
+ template <typename U = TheItemType>
+ typename std::enable_if<std::is_arithmetic<U>::value, void>::type construct(const size_t,
+ const size_t)
+ {
+ // Do nothing
+ }
+
+ template <typename U = TheItemType>
+ typename std::enable_if<!std::is_arithmetic<U>::value, void>::type construct(const size_t theFrom,
+ const size_t theTo)
+ {
+ for (size_t anInd = theFrom; anInd < theTo; anInd++)
{
- myDeletable = Standard_True;
- return;
+ myAllocator.construct(myPointer + anInd);
}
+ }
- const Standard_Integer aLenCopy = Min (anOldLen, aNewLen);
- for (Standard_Integer anIter = 0; anIter < aLenCopy; ++anIter)
+ template <typename U = TheItemType>
+ typename std::enable_if<std::is_arithmetic<U>::value, void>::type destroy()
+ {
+ // Do nothing
+ }
+
+ template <typename U = TheItemType>
+ typename std::enable_if<!std::is_arithmetic<U>::value, void>::type destroy()
+ {
+ for (size_t anInd = 0; anInd < mySize; anInd++)
{
- aBeginNew[anIter] = aBeginOld[anIter];
+ myAllocator.destroy(myPointer + anInd);
}
- if (myDeletable)
+ }
+
+ template <typename U = TheItemType>
+ typename std::enable_if<std::is_arithmetic<U>::value, void>::type destroy(pointer,
+ const size_t,
+ const size_t)
+ {
+ // Do nothing
+ }
+
+ template <typename U = TheItemType>
+ typename std::enable_if<!std::is_arithmetic<U>::value, void>::type destroy(pointer theWhat,
+ const size_t theFrom,
+ const size_t theTo)
+ {
+ for (size_t anInd = theFrom; anInd < theTo; anInd++)
{
- delete[] aBeginOld;
+ myAllocator.destroy(theWhat + anInd);
}
- myDeletable = Standard_True;
}
- //! Destructor - releases the memory
- ~NCollection_Array1 (void)
- {
- if (myDeletable)
- delete [] &(myData[myLowerBound]);
+ void copyConstruct(const pointer theFrom,
+ const size_t theCount)
+ {
+ for (size_t anInd = 0; anInd < theCount; anInd++)
+ {
+ myAllocator.construct(myPointer + anInd, theFrom[anInd]);
+ }
}
- protected:
// ---------- PROTECTED FIELDS -----------
- Standard_Integer myLowerBound;
- Standard_Integer myUpperBound;
- Standard_Boolean myDeletable; //!< Flag showing who allocated the array
- TheItemType* myData; //!< Pointer to '0'th array item
+ Standard_Integer myLowerBound;
+ size_t mySize;
+ pointer myPointer = nullptr;
+ bool myIsOwner = false;
+ allocator_type myAllocator;
};
#endif
#include <Standard_DimensionMismatch.hxx>
#include <Standard_OutOfMemory.hxx>
+#include <NCollection_Allocator.hxx>
#include <Standard_OutOfRange.hxx>
+#include <NCollection_Array1.hxx>
#include <NCollection_DefineAlloc.hxx>
// *********************************************** Template for Array2 class
/**
-* Purpose: The class Array2 represents bi-dimensional arrays
-* of fixed size known at run time.
+* Purpose: The class Array2 represents bi-dimensional arrays
+* of fixed size known at run time.
* The ranges of indices are user defined.
*
* Class allocates one 1D array storing full data (all Rows and Columns)
* Warning: Programs clients of such class must be independent
* of the range of the first element. Then, a C++ for
* loop must be written like this
-*
+*
* for (i = A.LowerRow(); i <= A.UpperRow(); i++)
* for (j = A.LowerCol(); j <= A.UpperCol(); j++)
-*/
+*/
template <class TheItemType>
-class NCollection_Array2
+class NCollection_Array2 : public NCollection_Array1<TheItemType>
{
public:
- //! STL-compliant typedef for value type
- typedef TheItemType value_type;
-
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC;
+ DEFINE_NCOLLECTION_ALLOC;
public:
- // **************** Implementation of the Iterator interface.
- class Iterator
+ typedef NCollection_Allocator<TheItemType> allocator_type;
+public:
+
+ // Define various type aliases for convenience
+ using value_type = typename NCollection_Array1<TheItemType>::value_type;
+ using size_type = typename NCollection_Array1<TheItemType>::size_type;
+ using difference_type = typename NCollection_Array1<TheItemType>::difference_type;
+ using pointer = typename NCollection_Array1<TheItemType>::pointer;
+ using const_pointer = typename NCollection_Array1<TheItemType>::const_pointer;
+ using reference = typename NCollection_Array1<TheItemType>::reference;
+ using const_reference = typename NCollection_Array1<TheItemType>::const_reference;
+
+ using iterator = typename NCollection_Array1<TheItemType>::iterator;
+ using const_iterator = typename NCollection_Array1<TheItemType>::const_iterator;
+
+ static int BeginPosition(Standard_Integer theRowLower,
+ Standard_Integer /*theRowUpper*/,
+ Standard_Integer theColLower,
+ Standard_Integer theColUpper)
{
- public:
- //! Empty constructor - for later Init
- Iterator (void) :
- myCurrent (0),
- mySize (0),
- myArray (NULL) {}
- //! Constructor with initialisation
- Iterator (const NCollection_Array2& theArray) :
- myCurrent (0),
- mySize (theArray.Length()),
- myArray ((NCollection_Array2 *) &theArray) {}
- //! Initialisation
- void Init (const NCollection_Array2& theArray)
- {
- myCurrent = 0;
- mySize = theArray.Length();
- myArray = (NCollection_Array2 *) &theArray;
- }
- //! Check end
- Standard_Boolean More (void) const
- { return (myCurrent < mySize); }
- //! Make step
- void Next (void)
- { myCurrent++; }
- //! Constant value access
- const TheItemType& Value (void) const
- { return myArray->myStart[myCurrent]; }
- //! Variable value access
- TheItemType& ChangeValue (void) const
- { return myArray->myStart[myCurrent]; }
- private:
- Standard_Integer myCurrent; //!< Index of the current item
- Standard_Integer mySize; //!< Total amount of items
- NCollection_Array2* myArray; //!< Pointer to the array being iterated
- }; // End of nested class Iterator
-
- public:
+ // Calculate the offset for the beginning position
+ return theColLower + (theRowLower * (theColUpper - theColLower + 1));
+ }
+
+ static int LastPosition(Standard_Integer theRowLower,
+ Standard_Integer theRowUpper,
+ Standard_Integer theColLower,
+ Standard_Integer theColUpper)
+ {
+ return ((theRowUpper - theRowLower + 1) * (theColUpper - theColLower + 1)) + theColLower + (theRowLower * (theColUpper - theColLower + 1)) - 1;
+ }
+
+public:
// ---------- PUBLIC METHODS ------------
//! Empty constructor; should be used with caution.
//! @sa methods Resize() and Move().
- NCollection_Array2()
- : myLowerRow (1),
- myUpperRow (0),
- myLowerCol (1),
- myUpperCol (0),
- myData (NULL),
- myStart (NULL),
- myDeletable(false)
- {
- //
- }
+ NCollection_Array2() :
+ NCollection_Array1<TheItemType>(),
+ myLowerRow(1),
+ mySizeRow(0),
+ myLowerCol(1),
+ mySizeCol(0)
+ {}
//! Constructor
NCollection_Array2(const Standard_Integer theRowLower,
const Standard_Integer theRowUpper,
const Standard_Integer theColLower,
const Standard_Integer theColUpper) :
- myLowerRow (theRowLower),
- myUpperRow (theRowUpper),
- myLowerCol (theColLower),
- myUpperCol (theColUpper),
- myDeletable (Standard_True)
- { Allocate(); }
+ NCollection_Array1<TheItemType>(BeginPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ LastPosition(theRowLower, theRowUpper, theColLower, theColUpper)),
+ myLowerRow(theRowLower),
+ mySizeRow(theRowUpper - theRowLower + 1),
+ myLowerCol(theColLower),
+ mySizeCol(theColUpper - theColLower + 1)
+ {}
+
+ //! Constructor
+ explicit NCollection_Array2(const allocator_type& theAlloc,
+ const Standard_Integer theRowLower,
+ const Standard_Integer theRowUpper,
+ const Standard_Integer theColLower,
+ const Standard_Integer theColUpper) :
+ NCollection_Array1<TheItemType>(theAlloc,
+ BeginPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ LastPosition(theRowLower, theRowUpper, theColLower, theColUpper)),
+ myLowerRow(theRowLower),
+ mySizeRow(theRowUpper - theRowLower + 1),
+ myLowerCol(theColLower),
+ mySizeCol(theColUpper - theColLower + 1)
+ {}
//! Copy constructor
- NCollection_Array2 (const NCollection_Array2& theOther) :
- myLowerRow (theOther.LowerRow()),
- myUpperRow (theOther.UpperRow()),
- myLowerCol (theOther.LowerCol()),
- myUpperCol (theOther.UpperCol()),
- myDeletable (Standard_True)
- {
- Allocate();
- *this = theOther;
- }
+ NCollection_Array2(const NCollection_Array2& theOther) :
+ NCollection_Array1<TheItemType>(theOther),
+ myLowerRow(theOther.LowerRow()),
+ mySizeRow(theOther.NbRows()),
+ myLowerCol(theOther.LowerCol()),
+ mySizeCol(theOther.NbColumns())
+ {}
//! Move constructor
- NCollection_Array2 (NCollection_Array2&& theOther)
- : myLowerRow (theOther.myLowerRow),
- myUpperRow (theOther.myUpperRow),
- myLowerCol (theOther.myLowerRow),
- myUpperCol (theOther.myUpperCol),
- myData (theOther.myData),
- myStart (theOther.myStart),
- myDeletable(theOther.myDeletable)
- {
- theOther.myStart = NULL;
- theOther.myData = NULL;
- theOther.myDeletable = false;
- }
+ NCollection_Array2(NCollection_Array2&& theOther) noexcept:
+ NCollection_Array1<TheItemType>(std::forward<NCollection_Array2>(theOther)),
+ myLowerRow(theOther.LowerRow()),
+ mySizeRow(theOther.NbRows()),
+ myLowerCol(theOther.LowerCol()),
+ mySizeCol(theOther.NbColumns())
+ {}
//! C array-based constructor
- NCollection_Array2(const TheItemType& theBegin,
- const Standard_Integer theRowLower,
- const Standard_Integer theRowUpper,
- const Standard_Integer theColLower,
- const Standard_Integer theColUpper) :
- myLowerRow (theRowLower),
- myUpperRow (theRowUpper),
- myLowerCol (theColLower),
- myUpperCol (theColUpper),
- myDeletable (Standard_False)
- {
- myStart = (TheItemType *) &theBegin;
- Allocate();
- }
+ explicit NCollection_Array2(const TheItemType& theBegin,
+ const Standard_Integer theRowLower,
+ const Standard_Integer theRowUpper,
+ const Standard_Integer theColLower,
+ const Standard_Integer theColUpper) :
+ NCollection_Array1<TheItemType>(theBegin,
+ BeginPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ LastPosition(theRowLower, theRowUpper, theColLower, theColUpper)),
+ myLowerRow(theRowLower),
+ mySizeRow(theRowUpper - theRowLower + 1),
+ myLowerCol(theColLower),
+ mySizeCol(theColUpper - theColLower + 1)
+ {}
- //! Initialise the values
- void Init (const TheItemType& theValue)
+ //! Size (number of items)
+ Standard_Integer Size() const
{
- TheItemType *pCur, *pEnd=myStart+Size();
- for(pCur = myStart; pCur<pEnd; pCur++)
- *pCur = theValue;
+ return Length();
}
-
- //! Size (number of items)
- Standard_Integer Size (void) const
- { return Length(); }
//! Length (number of items)
- Standard_Integer Length (void) const
- { return NbRows() * NbColumns(); }
+ Standard_Integer Length() const
+ {
+ return NbRows() * NbColumns();
+ }
//! Returns number of rows
- Standard_Integer NbRows() const { return myUpperRow - myLowerRow + 1; }
+ Standard_Integer NbRows() const
+ {
+ return static_cast<int>(mySizeRow);
+ }
//! Returns number of columns
- Standard_Integer NbColumns() const { return myUpperCol - myLowerCol + 1; }
+ Standard_Integer NbColumns() const
+ {
+ return static_cast<int>(mySizeCol);
+ }
//! Returns length of the row, i.e. number of columns
- Standard_Integer RowLength() const { return NbColumns(); }
+ Standard_Integer RowLength() const
+ {
+ return NbColumns();
+ }
//! Returns length of the column, i.e. number of rows
- Standard_Integer ColLength() const { return NbRows(); }
+ Standard_Integer ColLength() const
+ {
+ return NbRows();
+ }
//! LowerRow
- Standard_Integer LowerRow (void) const
- { return myLowerRow; }
+ Standard_Integer LowerRow() const
+ {
+ return myLowerRow;
+ }
//! UpperRow
- Standard_Integer UpperRow (void) const
- { return myUpperRow; }
+ Standard_Integer UpperRow() const
+ {
+ return myLowerRow + static_cast<int>(mySizeRow) - 1;
+ }
//! LowerCol
- Standard_Integer LowerCol (void) const
- { return myLowerCol; }
+ Standard_Integer LowerCol() const
+ {
+ return myLowerCol;
+ }
//! UpperCol
- Standard_Integer UpperCol (void) const
- { return myUpperCol; }
-
- //! myDeletable flag
- Standard_Boolean IsDeletable (void) const
- { return myDeletable; }
+ Standard_Integer UpperCol() const
+ {
+ return myLowerCol + static_cast<int>(mySizeCol) - 1;
+ }
//! Assignment
- NCollection_Array2& Assign (const NCollection_Array2& theOther)
- {
+ NCollection_Array2& Assign(const NCollection_Array2& theOther)
+ {
if (&theOther == this)
+ {
return *this;
- Standard_DimensionMismatch_Raise_if (Length() != theOther.Length(), "NCollection_Array2::operator=");
- TheItemType * pMyItem = myStart;
- TheItemType * pItem = theOther.myStart;
- const Standard_Integer iSize = Length();
- for (Standard_Integer i=0; i < iSize; i++, pItem++, pMyItem++)
- *pMyItem = *pItem;
- return *this;
+ }
+ NCollection_Array1<TheItemType>::Assign(theOther);
+ return *this;
}
+
//! Move assignment.
//! This array will borrow all the data from theOther.
//! The moved object will be left uninitialized and should not be used anymore.
- NCollection_Array2& Move (NCollection_Array2& theOther)
+ NCollection_Array2& Move(NCollection_Array2&& theOther)
{
if (&theOther == this)
{
return *this;
}
-
- if (myDeletable)
- {
- delete[] myStart;
- }
- if (myData != NULL)
- {
- delete[] &(myData[myLowerRow]);
- }
-
- myLowerRow = theOther.myLowerRow;
- myUpperRow = theOther.myUpperRow;
- myLowerCol = theOther.myLowerRow;
- myUpperCol = theOther.myUpperCol;
- myData = theOther.myData;
- myStart = theOther.myStart;
- myDeletable = theOther.myDeletable;
-
- theOther.myStart = NULL;
- theOther.myData = NULL;
- theOther.myDeletable = Standard_False;
+ NCollection_Array1<TheItemType>::Move(theOther);
+ myLowerRow = theOther.myLowerRow;
+ mySizeRow = theOther.mySizeRow;
+ myLowerCol = theOther.myLowerCol;
+ mySizeCol = theOther.mySizeCol;
return *this;
}
+ //! Move assignment.
+ //! This array will borrow all the data from theOther.
+ //! The moved object will be left uninitialized and should not be used anymore.
+ NCollection_Array2& Move(NCollection_Array2& theOther)
+ {
+ return Move(std::move(theOther));
+ }
+
//! Assignment operator
NCollection_Array2& operator= (const NCollection_Array2& theOther)
- {
- return Assign (theOther);
+ {
+ return Assign(theOther);
}
//! Move assignment operator; @sa Move()
NCollection_Array2& operator= (NCollection_Array2&& theOther)
{
- return Move (theOther);
+ return Move(std::forward<NCollection_Array2>(theOther));
}
//! Constant value access
- const TheItemType& Value (const Standard_Integer theRow,
- const Standard_Integer theCol) const
+ const_reference Value(const Standard_Integer theRow,
+ const Standard_Integer theCol) const
{
- Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
- theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::Value");
- return myData[theRow][theCol];
+ const size_t aPos = (theRow - myLowerRow) * mySizeCol + (theCol - myLowerCol);
+ return NCollection_Array1<TheItemType>::at(aPos);
}
//! operator() - alias to ChangeValue
- const TheItemType& operator() (const Standard_Integer theRow,
- const Standard_Integer theCol) const
- { return Value (theRow,theCol); }
+ const_reference operator() (const Standard_Integer theRow,
+ const Standard_Integer theCol) const
+ {
+ const size_t aPos = (theRow - myLowerRow) * mySizeCol + (theCol - myLowerCol);
+ return NCollection_Array1<TheItemType>::at(aPos);
+ }
//! Variable value access
- TheItemType& ChangeValue (const Standard_Integer theRow,
- const Standard_Integer theCol)
+ reference ChangeValue(const Standard_Integer theRow,
+ const Standard_Integer theCol)
{
- Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
- theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::ChangeValue");
- return myData[theRow][theCol];
+ const size_t aPos = (theRow - myLowerRow) * mySizeCol + (theCol - myLowerCol);
+ return NCollection_Array1<TheItemType>::at(aPos);
}
//! operator() - alias to ChangeValue
- TheItemType& operator() (const Standard_Integer theRow,
- const Standard_Integer theCol)
- { return ChangeValue (theRow,theCol); }
+ reference operator() (const Standard_Integer theRow,
+ const Standard_Integer theCol)
+ {
+ return ChangeValue(theRow, theCol);
+ }
+
+ //! SetValue
+ void SetValue(const Standard_Integer theRow,
+ const Standard_Integer theCol,
+ const TheItemType& theItem)
+ {
+ const size_t aPos = (theRow - myLowerRow) * mySizeCol + (theCol - myLowerCol);
+ NCollection_Array1<TheItemType>::at(aPos) = theItem;
+ }
//! SetValue
- void SetValue (const Standard_Integer theRow,
- const Standard_Integer theCol,
- const TheItemType& theItem)
+ void SetValue(const Standard_Integer theRow,
+ const Standard_Integer theCol,
+ TheItemType&& theItem)
{
- Standard_OutOfRange_Raise_if (theRow < myLowerRow || theRow > myUpperRow ||
- theCol < myLowerCol || theCol > myUpperCol, "NCollection_Array2::SetValue");
- myData[theRow][theCol] = theItem;
+ const size_t aPos = (theRow - myLowerRow) * mySizeCol + (theCol - myLowerCol);
+ NCollection_Array1<TheItemType>::at(aPos) = std::forward<TheItemType>(theItem);
}
//! Resizes the array to specified bounds.
//! @param theColLower new lower Column of array
//! @param theColUpper new upper Column of array
//! @param theToCopyData flag to copy existing data into new array
- void Resize (Standard_Integer theRowLower,
- Standard_Integer theRowUpper,
- Standard_Integer theColLower,
- Standard_Integer theColUpper,
- Standard_Boolean theToCopyData)
+ void Resize(Standard_Integer theRowLower,
+ Standard_Integer theRowUpper,
+ Standard_Integer theColLower,
+ Standard_Integer theColUpper,
+ Standard_Boolean theToCopyData)
{
- Standard_RangeError_Raise_if (theRowUpper < theRowLower
- || theColUpper < theColLower, "NCollection_Array2::Resize");
- const Standard_Integer anOldNbRows = NbRows();
- const Standard_Integer anOldNbCols = NbColumns();
- const Standard_Integer aLowerRowOld = myLowerRow;
- const Standard_Integer aLowerColOld = myLowerCol;
- const Standard_Integer aNewNbRows = theRowUpper - theRowLower + 1;
- const Standard_Integer aNewNbCols = theColUpper - theColLower + 1;
-
- TheItemType* aStartOld = myStart;
- TheItemType** aTableOld = myData != NULL ? myData + aLowerRowOld : NULL;
+ Standard_RangeError_Raise_if(theRowUpper < theRowLower ||
+ theColUpper < theColLower, "NCollection_Array2::Resize");
myLowerRow = theRowLower;
- myUpperRow = theRowUpper;
myLowerCol = theColLower;
- myUpperCol = theColUpper;
- if (aNewNbRows == anOldNbRows
- && aNewNbCols == anOldNbCols)
- {
- if (myLowerCol != aLowerColOld)
- {
- fillIndexTable (aTableOld);
- }
- myData = aTableOld - myLowerRow;
- return;
- }
-
- if (myDeletable
- && !theToCopyData)
- {
- delete[] aStartOld;
- }
- delete[] aTableOld;
-
- const Standard_Boolean wasDeletable = myDeletable;
- myDeletable = Standard_True;
- Allocate();
if (!theToCopyData)
{
+ NCollection_Array1<TheItemType>::Resize(BeginPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ LastPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ false);
+ mySizeRow = theRowUpper - theRowLower + 1;
+ mySizeCol = theColUpper - theColLower + 1;
return;
}
-
- const Standard_Integer aNbRowsToCopy = Min (anOldNbRows, aNewNbRows);
- const Standard_Integer aNbColsToCopy = Min (anOldNbCols, aNewNbCols);
- for (Standard_Integer aRowIter = 0; aRowIter < aNbRowsToCopy; ++aRowIter)
+ NCollection_Array1<TheItemType> aTmpMovedCopy(std::move(*this));
+ TheItemType* anOldPointer = &aTmpMovedCopy.ChangeFirst();
+ NCollection_Array1<TheItemType>::Resize(BeginPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ LastPosition(theRowLower, theRowUpper, theColLower, theColUpper),
+ false);
+ const size_t aNewNbRows = theRowUpper - theRowLower + 1;
+ const size_t aNewNbCols = theColUpper - theColLower + 1;
+ const size_t aNbRowsToCopy = std::min<size_t>(mySizeRow, aNewNbRows);
+ const size_t aNbColsToCopy = std::min<size_t>(mySizeCol, aNewNbCols);
+ mySizeRow = aNewNbRows;
+ mySizeCol = aNewNbCols;
+ size_t aOldInter = 0;
+ for (size_t aRowIter = 0; aRowIter < aNbRowsToCopy; ++aRowIter)
{
- for (Standard_Integer aColIter = 0; aColIter < aNbColsToCopy; ++aColIter)
+ for (size_t aColIter = 0; aColIter < aNbColsToCopy; ++aColIter)
{
- myStart[size_t(aRowIter) * size_t(aNewNbCols) + size_t(aColIter)] = aStartOld[size_t(aRowIter) * size_t(anOldNbCols) + size_t(aColIter)];
+ NCollection_Array1<TheItemType>::at(aRowIter * aNewNbCols + aColIter) = std::move(anOldPointer[aOldInter++]);
}
}
-
- if (wasDeletable)
- {
- delete[] aStartOld;
- }
}
- //! Destructor - releases the memory
- ~NCollection_Array2 (void)
- {
- if (myDeletable) delete [] myStart;
- if (myData != NULL)
- {
- delete[] &(myData[myLowerRow]);
- }
- }
-
- private:
- // ----------- PRIVATE METHODS -----------
-
- //! Allocate memory for the array, set up indirection table
- void Allocate (void)
- {
- const Standard_Integer aNbRows = NbRows();
- const Standard_Integer aNbCols = NbColumns();
- Standard_RangeError_Raise_if (aNbRows <= 0 || aNbCols <= 0, "NCollection_Array2::Allocate");
- if (myDeletable)
- {
- // allocation of the data in the array
- myStart = new TheItemType[size_t(aNbRows) * size_t(aNbCols)];
- Standard_OutOfMemory_Raise_if (!myStart, "NCollection_Array2 : Allocation failed");
- }
- // else myStart is set to the beginning of the given array
-
- TheItemType** pTable = new TheItemType* [aNbRows];
- Standard_OutOfMemory_Raise_if (!pTable, "NCollection_Array2 : Allocation failed");
- fillIndexTable (pTable);
- }
-
- //! Fill index table for accessing array elements.
- void fillIndexTable (TheItemType** theTable)
- {
- // Items of table point to the 0th items in the rows of the array
- TheItemType* aRow = myStart - myLowerCol;
- const Standard_Integer aNbRows = NbRows();
- const Standard_Size aNbCols = NbColumns();
- for (Standard_Integer aRowIter = 0; aRowIter < aNbRows; ++aRowIter)
- {
- theTable[aRowIter] = aRow;
- aRow += aNbCols;
- }
-
- // Set myData to the 0th row pointer of the table
- myData = theTable - myLowerRow;
- }
-
- protected:
+protected:
// ---------- PROTECTED FIELDS -----------
Standard_Integer myLowerRow;
- Standard_Integer myUpperRow;
+ size_t mySizeRow;
Standard_Integer myLowerCol;
- Standard_Integer myUpperCol;
-
- TheItemType** myData; //!< Pointer to the row pointers table
- TheItemType* myStart; //!< Pointer to the memory array
- Standard_Boolean myDeletable; //!< Flag showing who allocated the array
+ size_t mySizeCol;
// ----------- FRIEND CLASSES ------------
- friend class Iterator;
+ friend iterator;
+ friend const_iterator;
};
-// Created on: 2002-04-12
-// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-2014 OPEN CASCADE SAS
+/// Copyright (c) 2002-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#include <NCollection_BaseAllocator.hxx>
-#include <NCollection_IncAllocator.hxx>
-#include <NCollection_DataMap.hxx>
-#include <NCollection_Map.hxx>
-#include <NCollection_List.hxx>
-#include <Standard_Mutex.hxx>
-#include <fstream>
-#include <iomanip>
-
-
IMPLEMENT_STANDARD_RTTIEXT(NCollection_BaseAllocator,Standard_Transient)
//=======================================================================
//function : Allocate
//purpose : Standard allocation
//=======================================================================
+void* NCollection_BaseAllocator::Allocate(const size_t theSize)
+{
+ return Standard::Allocate(theSize);
+}
-void* NCollection_BaseAllocator::Allocate(const size_t size)
-{
- return Standard::Allocate(size);
+//=======================================================================
+//function : AllocateOptimal
+//purpose : Optimal allocation
+//=======================================================================
+void* NCollection_BaseAllocator::AllocateOptimal(const size_t theSize)
+{
+ return Standard::AllocateOptimal(theSize);
}
//=======================================================================
//function : Free
//purpose : Standard deallocation
//=======================================================================
-
-void NCollection_BaseAllocator::Free(void *anAddress)
-{
- if (anAddress) Standard::Free(anAddress);
+void NCollection_BaseAllocator::Free(void* theAddress)
+{
+ Standard::Free(theAddress);
}
//=======================================================================
//function : CommonBaseAllocator
//purpose : Creates the only one BaseAllocator
//=======================================================================
-
const Handle(NCollection_BaseAllocator)&
NCollection_BaseAllocator::CommonBaseAllocator(void)
{
- static Handle(NCollection_BaseAllocator) pAllocator =
+ static Handle(NCollection_BaseAllocator) THE_SINGLETON_ALLOC =
new NCollection_BaseAllocator;
- return pAllocator;
-}
-
-namespace
-{
- // global variable to ensure that allocator will be created during loading the library
- static Handle(NCollection_BaseAllocator) theAllocInit = NCollection_BaseAllocator::CommonBaseAllocator();
-
- //! Structure for collecting statistics about blocks of one size
- struct StorageInfo
- {
- Standard_Size roundSize;
- int nbAlloc;
- int nbFree;
- StorageInfo() : roundSize(0), nbAlloc(0), nbFree(0) {}
- StorageInfo(Standard_Size theSize) : roundSize(theSize), nbAlloc(0), nbFree(0) {}
- };
-
- //! Static data map (block_size -> StorageInfo)
- static NCollection_DataMap<Standard_Size, StorageInfo>& StorageMap()
- {
- static NCollection_IncAllocator TheAlloc;
- static NCollection_DataMap<Standard_Size, StorageInfo> TheMap (1, & TheAlloc);
- return TheMap;
- }
-
- //! Static data map (address -> AllocationID)
- static NCollection_DataMap<Standard_Address, Standard_Size>& StorageIDMap()
- {
- static NCollection_IncAllocator TheAlloc;
- static NCollection_DataMap<Standard_Address, Standard_Size> TheMap (1, & TheAlloc);
- return TheMap;
- }
-
- //! Static map (AllocationID)
- static NCollection_Map<Standard_Size>& StorageIDSet()
- {
- static NCollection_IncAllocator TheAlloc;
- static NCollection_Map<Standard_Size> TheMap (1, & TheAlloc);
- return TheMap;
- }
-
- // dummy function for break point
- inline void place_for_break_point () {}
-
- //! Static value of the current allocation ID. It provides unique numbering of allocation events.
- static Standard_Size CurrentID = 0;
-}
-
-//=======================================================================
-/**
- * Exported value to set the block size for which it is required
- * collecting alive allocation IDs.
- * The method NCollection_BaseAllocator::PrintMemUsageStatistics
- * dumps all alive IDs into the file alive.d in the current directory.
- */
-//=======================================================================
-Standard_EXPORT Standard_Size& StandardCallBack_CatchSize()
-{
- static Standard_Size Value = 0;
- return Value;
-}
-
-//=======================================================================
-/**
- * Exported value to set the allocation ID for which it is required
- * to set a breakpoint on the moment of allocation or freeing.
- * See the method NCollection_BaseAllocator::StandardCallBack
- * where the value StandardCallBack_CatchID() is compared to the current ID.
- * There you can place a break point at the stub assignment statement "a =".
- */
-//=======================================================================
-Standard_EXPORT Standard_Size& StandardCallBack_CatchID()
-{
- static Standard_Size Value = 0;
- return Value;
-}
-
-//=======================================================================
-/**
- * Exported function to reset the callback system to the initial state
- */
-//=======================================================================
-Standard_EXPORT void StandardCallBack_Reset()
-{
- StorageMap().Clear();
- StorageIDMap().Clear();
- StorageIDSet().Clear();
- CurrentID = 0;
- StandardCallBack_CatchSize() = 0;
- StandardCallBack_CatchID() = 0;
-}
-
-//=======================================================================
-//function : StandardCallBack
-//purpose : Callback function to register alloc/free calls
-//=======================================================================
-
-void NCollection_BaseAllocator::StandardCallBack
- (const Standard_Boolean theIsAlloc,
- const Standard_Address theStorage,
- const Standard_Size theRoundSize,
- const Standard_Size /*theSize*/)
-{
- static Standard_Mutex aMutex;
- aMutex.Lock();
- // statistics by storage size
- NCollection_DataMap<Standard_Size, StorageInfo>& aStMap = StorageMap();
- if (!aStMap.IsBound(theRoundSize))
- {
- StorageInfo aEmpty(theRoundSize);
- aStMap.Bind(theRoundSize, aEmpty);
- }
- StorageInfo& aInfo = aStMap(theRoundSize);
- if (theIsAlloc)
- aInfo.nbAlloc++;
- else
- aInfo.nbFree++;
-
- if (theRoundSize == StandardCallBack_CatchSize())
- {
- // statistics by alive objects
- NCollection_DataMap<Standard_Address, Standard_Size>& aStIDMap = StorageIDMap();
- NCollection_Map<Standard_Size>& aStIDSet = StorageIDSet();
- if (theIsAlloc)
- {
- aStIDMap.Bind(theStorage, ++CurrentID);
- aStIDSet.Add(CurrentID);
- if (CurrentID == StandardCallBack_CatchID())
- {
- // Place for break point for allocation of investigated ID
- place_for_break_point();
- }
- }
- else
- {
- if (aStIDMap.IsBound(theStorage))
- {
- Standard_Size anID = aStIDMap(theStorage);
- aStIDSet.Remove(anID);
- if (anID == StandardCallBack_CatchID())
- {
- // Place for break point for freeing of investigated ID
- place_for_break_point();
- }
- }
- }
- }
-
- aMutex.Unlock();
-}
-
-//=======================================================================
-//function : PrintMemUsageStatistics
-//purpose : Prints memory usage statistics cumulated by StandardCallBack
-//=======================================================================
-
-void NCollection_BaseAllocator::PrintMemUsageStatistics()
-{
- // sort by roundsize
- NCollection_List<StorageInfo> aColl;
- NCollection_List<StorageInfo>::Iterator itLst;
- NCollection_DataMap<Standard_Size, StorageInfo>::Iterator itMap(StorageMap());
- for (; itMap.More(); itMap.Next())
- {
- for (itLst.Init(aColl); itLst.More(); itLst.Next())
- if (itMap.Value().roundSize < itLst.Value().roundSize)
- break;
- if (itLst.More())
- aColl.InsertBefore(itMap.Value(), itLst);
- else
- aColl.Append(itMap.Value());
- }
- Standard_Size aTotAlloc = 0;
- Standard_Size aTotLeft = 0;
-
- // print
- std::ofstream aFileOut ("memstat.d", std::ios_base::trunc | std::ios_base::out);
- if (!aFileOut.is_open())
- {
- std::cout << "failure writing file memstat.d" << std::endl;
- return;
- }
- aFileOut.imbue (std::locale ("C"));
-
- // header
- aFileOut << std::setw(20) << "BlockSize" << ' '
- << std::setw(12) << "NbAllocated" << ' '
- << std::setw(12) << "NbLeft" << ' '
- << std::setw(20) << "Allocated" << ' '
- << std::setw(20) << "Left" << '\n';
-
- // body
- for (itLst.Init(aColl); itLst.More(); itLst.Next())
- {
- const StorageInfo& aInfo = itLst.Value();
- Standard_Integer nbLeft = aInfo.nbAlloc - aInfo.nbFree;
- Standard_Size aSizeAlloc = aInfo.nbAlloc * aInfo.roundSize;
- Standard_Size aSizeLeft = nbLeft * aInfo.roundSize;
-
- aFileOut << std::setw(20) << aInfo.roundSize << ' '
- << std::setw(12) << aInfo.nbAlloc << ' '
- << std::setw(12) << nbLeft << ' '
- << std::setw(20) << aSizeAlloc << ' '
- << std::setw(20) << aSizeLeft << '\n';
-
- aTotAlloc += aSizeAlloc;
- aTotLeft += aSizeLeft;
- }
-
- // footer
- aFileOut << std::setw(20) << "Total:" << ' '
- << std::setw(12) << "" << ' '
- << std::setw(12) << "" << ' '
- << std::setw(20) << aTotAlloc << ' '
- << std::setw(20) << aTotLeft << '\n';
-
- if (!StorageIDSet().IsEmpty())
- {
- aFileOut << "Alive allocation numbers of size=" << StandardCallBack_CatchSize() << '\n';
- for (NCollection_Map<Standard_Size>::Iterator itMap1(StorageIDSet()); itMap1.More(); itMap1.Next())
- {
- aFileOut << itMap1.Key() << '\n';
- }
- }
- aFileOut.close();
+ return THE_SINGLETON_ALLOC;
}
// Created on: 2002-04-12
// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-2014 OPEN CASCADE SAS
+// Copyright (c) 2002-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#ifndef NCollection_BaseAllocator_HeaderFile
#define NCollection_BaseAllocator_HeaderFile
+#include <Standard_DefineHandle.hxx>
#include <Standard_Transient.hxx>
-#include <Standard_Type.hxx>
-#include <NCollection_TypeDef.hxx>
-
/**
* Purpose: Basic class for memory allocation wizards.
* inaccessible. To create the BaseAllocator use the method
* CommonBaseAllocator.
* Note that this object is managed by Handle.
-*/
+*/
class NCollection_BaseAllocator : public Standard_Transient
{
public:
// ---------- PUBLIC METHODS ------------
- Standard_EXPORT virtual void* Allocate (const size_t size);
- Standard_EXPORT virtual void Free (void * anAddress);
-
+ Standard_EXPORT virtual void* Allocate (const size_t theSize);
+ Standard_EXPORT virtual void* AllocateOptimal(const size_t theSize);
+ Standard_EXPORT virtual void Free (void* theAddress);
+
//! CommonBaseAllocator
//! This method is designed to have the only one BaseAllocator (to avoid
//! useless copying of collections). However one can use operator new to
Standard_EXPORT static const Handle(NCollection_BaseAllocator)&
CommonBaseAllocator(void);
- //! Callback function to register alloc/free calls
- Standard_EXPORT static void StandardCallBack
- (const Standard_Boolean theIsAlloc,
- const Standard_Address theStorage,
- const Standard_Size theRoundSize,
- const Standard_Size theSize);
-
- //! Prints memory usage statistics cumulated by StandardCallBack
- Standard_EXPORT static void PrintMemUsageStatistics();
-
- protected:
+protected:
//! Constructor - prohibited
- NCollection_BaseAllocator(void) {}
+ NCollection_BaseAllocator() {}
- private:
+private:
//! Copy constructor - prohibited
- NCollection_BaseAllocator(const NCollection_BaseAllocator&);
+ NCollection_BaseAllocator(const NCollection_BaseAllocator&) = delete;
- public:
+public:
// ---------- CasCade RunTime Type Information
DEFINE_STANDARD_RTTIEXT(NCollection_BaseAllocator,Standard_Transient)
};
-
DEFINE_STANDARD_HANDLE(NCollection_BaseAllocator,Standard_Transient)
#endif
return Standard_False;
}
data1 = (NCollection_ListNode **)
- myAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
- memset(data1, 0, (N+1)*sizeof(NCollection_ListNode *));
+ Standard::Allocate((N+1)*sizeof(NCollection_ListNode *));
if (isDouble)
{
data2 = (NCollection_ListNode **)
- myAllocator->Allocate((N+1)*sizeof(NCollection_ListNode *));
- memset(data2, 0, (N+1)*sizeof(NCollection_ListNode *));
+ Standard::Allocate((N+1)*sizeof(NCollection_ListNode *));
}
else
data2 = NULL;
{
(void )theNbBuckets; // obsolete parameter
if (myData1)
- myAllocator->Free(myData1);
- if (myData2)
- myAllocator->Free(myData2);
+ Standard::Free(myData1);
+ if (myData2 && isDouble)
+ Standard::Free(myData2);
myNbBuckets = N;
myData1 = data1;
myData2 = data2;
{
if (!IsEmpty())
{
- Standard_Integer i;
- NCollection_ListNode** data = (NCollection_ListNode**) myData1;
- NCollection_ListNode *p,*q;
- for (i = 0; i <= NbBuckets(); i++)
+ const int aNbBuckets = NbBuckets();
+ for (int anInd = 0; anInd <= aNbBuckets; anInd++)
{
- if (data[i])
+ if (myData1[anInd])
{
- p = data[i];
- while (p)
+ NCollection_ListNode* aCur = myData1[anInd];
+ while (aCur)
{
- q = (NCollection_ListNode*)p->Next();
- fDel (p, myAllocator);
- p = q;
+ NCollection_ListNode* aNext = aCur->Next();
+ fDel (aCur, myAllocator);
+ aCur = aNext;
}
- data[i] = NULL;
+ myData1[anInd] = nullptr;
}
}
+ if (myData2)
+ {
+ memset(myData2, 0, (aNbBuckets + 1) * sizeof(NCollection_ListNode*));
+ }
}
mySize = 0;
if (doReleaseMemory)
{
- if (myData1)
- myAllocator->Free(myData1);
- if (isDouble && myData2)
- myAllocator->Free(myData2);
+ if (myData1)
+ Standard::Free(myData1);
+ if (myData2)
+ Standard::Free(myData2);
myData1 = myData2 = NULL;
}
}
//! Constructor
NCollection_BaseMap (const Standard_Integer NbBuckets,
const Standard_Boolean single,
- const Handle(NCollection_BaseAllocator)& theAllocator)
- : myData1(NULL),
+ const Handle(NCollection_BaseAllocator)& theAllocator) :
+ myAllocator(theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator),
+ myData1(NULL),
myData2(NULL),
myNbBuckets(NbBuckets),
mySize(0),
isDouble(!single)
+ {}
+
+ //! Move Constructor
+ NCollection_BaseMap(NCollection_BaseMap&& theOther) noexcept :
+ myAllocator(theOther.myAllocator),
+ myData1(theOther.myData1),
+ myData2(theOther.myData2),
+ myNbBuckets(theOther.myNbBuckets),
+ mySize(theOther.mySize),
+ isDouble(theOther.isDouble)
{
- myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
+ theOther.myData1 = nullptr;
+ theOther.myData1 = nullptr;
+ theOther.mySize = 0;
+ theOther.myNbBuckets = 0;
}
//! Destructor
std::swap (myData2, theOther.myData2);
std::swap (myNbBuckets, theOther.myNbBuckets);
std::swap (mySize, theOther.mySize);
- //std::swap (isDouble, theOther.isDouble);
}
+ //! Move operator
+ NCollection_BaseMap& operator=(NCollection_BaseMap&&) noexcept = delete;
+
+ //! Copy Constructor
+ NCollection_BaseMap(const NCollection_BaseMap&) = delete;
+
+ //! Assign operator
+ NCollection_BaseMap& operator=(const NCollection_BaseMap&) = delete;
+
protected:
// --------- PROTECTED FIELDS -----------
Handle(NCollection_BaseAllocator) myAllocator;
// ---------- PRIVATE FIELDS ------------
Standard_Integer myNbBuckets;
Standard_Integer mySize;
- Standard_Boolean isDouble;
+ const Standard_Boolean isDouble;
// ---------- FRIEND CLASSES ------------
friend class Iterator;
--- /dev/null
+// Copyright (c) 2023 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 <NCollection_BasePointerVector.hxx>
+
+#include <TCollection.hxx>
+#include <cstring>
+
+//=======================================================================
+//function : NCollection_BasePointerVector
+//purpose :
+//=======================================================================
+NCollection_BasePointerVector::NCollection_BasePointerVector(const NCollection_BasePointerVector& theOther) :
+ mySize(theOther.mySize),
+ myCapacity(theOther.myCapacity)
+{
+ if (myCapacity > 0)
+ {
+ myArray = myAllocator.allocate(myCapacity);
+ memcpy(myArray, theOther.myArray, Size() * sizeof(void*));
+ }
+}
+
+//=======================================================================
+//function : NCollection_BasePointerVector
+//purpose :
+//=======================================================================
+NCollection_BasePointerVector::NCollection_BasePointerVector(NCollection_BasePointerVector&& theOther) noexcept :
+ mySize(std::move(theOther.mySize)),
+ myCapacity(std::move(theOther.myCapacity)),
+ myArray(std::move(theOther.myArray))
+{
+ theOther.myCapacity = 0;
+ theOther.mySize = 0;
+ theOther.myArray = nullptr;
+}
+
+//=======================================================================
+//function : Append
+//purpose :
+//=======================================================================
+void NCollection_BasePointerVector::Append (const void* thePnt)
+{
+ if (mySize == myCapacity)
+ {
+ if (myCapacity == 0)
+ {
+ myCapacity = 8; // the most optimal initial value
+ }
+ else
+ {
+ myCapacity <<= 1;
+ }
+ myArray = myAllocator.reallocate(myArray, myCapacity);
+ }
+ myArray[mySize++] = (void*)thePnt;
+}
+
+//=======================================================================
+//function : SetValue
+//purpose :
+//=======================================================================
+void NCollection_BasePointerVector::SetValue (const size_t theInd, const void* thePnt)
+{
+ if (theInd >= myCapacity)
+ {
+ if (myCapacity == 0)
+ {
+ myCapacity = 8; // the most optimal initial value
+ }
+ while (myCapacity < theInd)
+ {
+ myCapacity <<= 1;
+ }
+ myArray = myAllocator.reallocate(myArray, myCapacity);
+ memset(myArray + mySize, 0, (theInd - mySize) * sizeof(void**));
+ mySize = theInd;
+ }
+ myArray[theInd] = (void*)thePnt;
+}
+
+//=======================================================================
+//function : clear
+//purpose :
+//=======================================================================
+void NCollection_BasePointerVector::clear()
+{
+ if (myCapacity > 0)
+ {
+ myAllocator.deallocate(myArray, myCapacity);
+ }
+ myArray = nullptr;
+ myCapacity = 0;
+}
+
+//=======================================================================
+//function : operator=
+//purpose :
+//=======================================================================
+NCollection_BasePointerVector& NCollection_BasePointerVector::operator=(const NCollection_BasePointerVector& theOther)
+{
+ if (this == &theOther)
+ {
+ return *this;
+ }
+ mySize = theOther.mySize;
+ if (myCapacity < theOther.myCapacity)
+ {
+ clear();
+ myCapacity = theOther.myCapacity;
+ myArray = myAllocator.allocate(myCapacity);
+ }
+ memcpy(myArray, theOther.myArray, mySize * sizeof(void*));
+ return *this;
+}
+
+//=======================================================================
+//function : operator=
+//purpose :
+//=======================================================================
+NCollection_BasePointerVector& NCollection_BasePointerVector::operator=(NCollection_BasePointerVector&& theOther) noexcept
+{
+ if (this == &theOther)
+ {
+ return *this;
+ }
+ clear();
+ mySize = std::move(theOther.mySize);
+ myCapacity = std::move(theOther.myCapacity);
+ myArray = std::move(theOther.myArray);
+ theOther.myCapacity = 0;
+ theOther.mySize = 0;
+ theOther.myArray = nullptr;
+ return *this;
+}
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2023 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_BasePointerVector_HeaderFile
+#define NCollection_BasePointerVector_HeaderFile
+
+#include <Standard.hxx>
+
+#include <NCollection_Allocator.hxx>
+#include <NCollection_DefineAlloc.hxx>
+
+//! Simplified class for vector of pointers of void.
+//! Offers basic functionality to scalable inserts,
+//! resizes and erasing last.
+//!
+//! Control of processing values of pointers out-of-scope
+//! and should be controlled externally.
+//! Especially, copy operation should post-process elements of pointers to make deep copy.
+class NCollection_BasePointerVector
+{
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC
+ DEFINE_NCOLLECTION_ALLOC
+
+public:
+
+ //! Default constructor
+ NCollection_BasePointerVector() {}
+
+ //! Copy data from another vector
+ Standard_EXPORT NCollection_BasePointerVector(const NCollection_BasePointerVector& theOther);
+
+ //! Move data from another vector
+ Standard_EXPORT NCollection_BasePointerVector(NCollection_BasePointerVector&& theOther) noexcept;
+
+ //! Destroy container
+ ~NCollection_BasePointerVector() { clear(); }
+
+ //! Checks for an empty status
+ bool IsEmpty() const { return mySize == 0; }
+
+ //! Gets used size
+ size_t Size() const { return mySize; }
+
+ //! Gets available capacity
+ size_t Capacity() const { return myCapacity; }
+
+ //! Erases last element, decrements size.
+ void RemoveLast() { mySize--; }
+
+ //! Resets the size
+ void Clear(const bool theReleaseMemory = false)
+ {
+ if (theReleaseMemory)
+ clear();
+ mySize = 0;
+ }
+
+public:
+
+ //! Gets array, can be null
+ void** GetArray() const { return myArray; }
+
+ //! Gets value by index, no acess validation
+ void* Value (const size_t theInd) const { return myArray[theInd]; }
+
+public:
+
+ //! Inserts new element at the end, increase size,
+ //! if capacity is not enough, call resize.
+ Standard_EXPORT void Append (const void* thePnt);
+
+ //! Updates value of existed element,
+ //! If index more then size, increase size of container,
+ //! in this case capacity can be updated.
+ Standard_EXPORT void SetValue (const size_t theInd, const void* thePnt);
+
+ //! Copy vector
+ Standard_EXPORT NCollection_BasePointerVector& operator= (const NCollection_BasePointerVector& theOther);
+
+ //! Move vector
+ Standard_EXPORT NCollection_BasePointerVector& operator= (NCollection_BasePointerVector&& theOther) noexcept;
+
+private:
+
+ //! Deallocate array
+ Standard_EXPORT void clear();
+
+private:
+ size_t mySize = 0; //!< Used length of vector
+ size_t myCapacity = 0; //!< Allocated vector size
+ void** myArray = nullptr; //! Array of pointers
+ NCollection_Allocator<void*> myAllocator;
+};
+
+#endif
+++ /dev/null
-// Created on: 2002-04-24
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2002-2013 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 <NCollection_BaseVector.hxx>
-
-#include <Standard_RangeError.hxx>
-
-//=======================================================================
-//function : initV
-//purpose : Initialisation of iterator by a vector
-//=======================================================================
-
-void NCollection_BaseVector::Iterator::initV (const NCollection_BaseVector& theVector, Standard_Boolean theToEnd)
-{
- myVector = &theVector;
-
- if (theVector.myNBlocks == 0)
- {
- myCurIndex = 0;
- myEndIndex = 0;
- myICurBlock = 0;
- myIEndBlock = 0;
- }
- else
- {
- myIEndBlock = theVector.myNBlocks - 1;
- myEndIndex = theVector.myData[myIEndBlock].Length;
-
- myICurBlock = !theToEnd ? 0 : myIEndBlock;
- myCurIndex = !theToEnd ? 0 : myEndIndex;
- }
-}
-
-//=======================================================================
-//function : allocMemBlocks
-//purpose :
-//=======================================================================
-
-NCollection_BaseVector::MemBlock* NCollection_BaseVector
- ::allocMemBlocks (const Standard_Integer theCapacity,
- MemBlock* theSource,
- const Standard_Integer theSourceSize)
-{
- MemBlock* aData = (MemBlock* )myAllocator->Allocate (theCapacity * sizeof(MemBlock));
-
- // copy content from source array
- Standard_Integer aCapacity = 0;
- if (theSource != NULL)
- {
- memcpy (aData, theSource, theSourceSize * sizeof(MemBlock));
- aCapacity = theSourceSize;
- myAllocator->Free (theSource);
- }
-
- // Nullify newly allocated blocks
- if (aCapacity < theCapacity)
- {
- memset (&aData[aCapacity], 0, (theCapacity - aCapacity) * sizeof(MemBlock));
- }
- return aData;
-}
-
-//=======================================================================
-//function : Clear
-//purpose :
-//=======================================================================
-
-void NCollection_BaseVector::Clear()
-{
- if (myLength > 0)
- {
- for (Standard_Integer anItemIter = 0; anItemIter < myCapacity; ++anItemIter)
- {
- myInitBlocks (*this, myData[anItemIter], 0, 0);
- }
- myLength = 0;
- myNBlocks = 0;
- }
-}
-
-//=======================================================================
-//function : expandV
-//purpose : returns the pointer where the new data item is supposed to be put
-//=======================================================================
-
-void* NCollection_BaseVector::expandV (const Standard_Integer theIndex)
-{
- const Standard_Integer aNewLength = theIndex + 1;
- if (myNBlocks > 0)
- {
- // Take the last array in the vector of arrays
- MemBlock& aLastBlock = myData[myNBlocks - 1];
- Standard_RangeError_Raise_if (theIndex < aLastBlock.FirstIndex,
- "NColelction_BaseVector::expandV");
- Standard_Integer anIndLastBlock = theIndex - aLastBlock.FirstIndex;
- // Is there still room for 1 item in the last array?
- if (anIndLastBlock < aLastBlock.Size)
- {
- myLength = aNewLength;
- aLastBlock.Length = anIndLastBlock + 1;
- return aLastBlock.findV (anIndLastBlock, myItemSize);
- }
- myLength = aLastBlock.FirstIndex + aLastBlock.Size;
- }
-
- // There is no room in the last array
- // or the whole vector is not yet initialised.
- // Initialise a new array, but before that check whether it is available within myCapacity.
- const Standard_Integer nNewBlock = myNBlocks + 1 + (theIndex - myLength) / myIncrement;
- if (myCapacity < nNewBlock)
- {
- // Reallocate the array myData
- do myCapacity += GetCapacity(myIncrement); while (myCapacity <= nNewBlock);
-
- myData = allocMemBlocks (myCapacity, myData, myNBlocks);
- }
- if (myNBlocks > 0)
- {
- // Change length of old last block to myIncrement
- MemBlock& aLastBlock = myData[myNBlocks - 1];
- aLastBlock.Length = myIncrement;
- }
-
- // Initialise new blocks
- MemBlock* aNewBlock = &myData[myNBlocks++];
- myInitBlocks (*this, *aNewBlock, myLength, myIncrement);
- while (myNBlocks < nNewBlock)
- {
- aNewBlock->Length = myIncrement;
- myLength += myIncrement;
- aNewBlock = &myData[myNBlocks++];
- myInitBlocks (*this, *aNewBlock, myLength, myIncrement);
- }
- aNewBlock->Length = aNewLength - myLength;
- myLength = aNewLength;
- return aNewBlock->findV (theIndex - aNewBlock->FirstIndex, myItemSize);
-}
+++ /dev/null
-// Created on: 2002-04-24
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2002-2013 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_BaseVector_HeaderFile
-#define NCollection_BaseVector_HeaderFile
-
-#include <Standard_TypeDef.hxx>
-#include <Standard_OutOfRange.hxx>
-#include <NCollection_BaseAllocator.hxx>
-#include <NCollection_DefineAlloc.hxx>
-
-// this value defines the number of blocks that are reserved
-// when the capacity of vector is increased
-inline Standard_Integer GetCapacity (const Standard_Integer theIncrement)
-{
- return Max(theIncrement/8, 1);
-}
-
-//! Class NCollection_BaseVector - base for NCollection_Vector template
-class NCollection_BaseVector
-{
-public:
- //! Memory allocation
- DEFINE_STANDARD_ALLOC
- DEFINE_NCOLLECTION_ALLOC
-
-protected:
-
- // Auxiliary structure for memory blocks
- struct MemBlock
- {
-
- public:
-
- //! @param theIndex Item index in the block
- //! @param theItemSize Element size in bytes
- //! @return the address of specified item in this memory block
- void* findV (const Standard_Integer theIndex,
- const size_t theItemSize) const
- {
- return (char* )DataPtr + size_t(theIndex) * theItemSize;
- }
-
- public:
-
- void* DataPtr; //!< block of elements
- Standard_Integer FirstIndex; //!< index of the first element (among all memory blocks in collection)
- Standard_Integer Length;
- Standard_Integer Size;
-
- };
-
- //! Base class for Iterator implementation
- class Iterator
- {
- protected:
- Iterator()
- : myVector (nullptr),
- myICurBlock (0),
- myIEndBlock (0),
- myCurIndex (0),
- myEndIndex (0) {}
-
- Iterator (const NCollection_BaseVector& theVector, Standard_Boolean theToEnd = Standard_False)
- {
- initV (theVector, theToEnd);
- }
-
- Standard_EXPORT void initV (const NCollection_BaseVector& theVector, Standard_Boolean theToEnd = Standard_False);
-
- Standard_Boolean moreV() const
- {
- return (myICurBlock < myIEndBlock || myCurIndex < myEndIndex);
- }
-
- void nextV()
- {
- if (++myCurIndex >= myVector->myData[myICurBlock].Length
- && myICurBlock < myIEndBlock)
- {
- ++myICurBlock;
- myCurIndex = 0;
- }
- }
-
- void prevV()
- {
- if (--myCurIndex < 0 && myICurBlock > 0)
- {
- --myICurBlock;
- myCurIndex = myVector->myData[myICurBlock].Length - 1;
- }
- }
-
- void offsetV (Standard_Integer theOffset)
- {
- const Standard_Integer anIndex = myCurIndex + myICurBlock * myVector->myIncrement + theOffset;
- myICurBlock = anIndex / myVector->myIncrement;
- myCurIndex = anIndex % myVector->myIncrement;
- if (myICurBlock > myIEndBlock)
- {
- // make sure that iterator produced by Offset()
- // is equal to the end() iterator
- --myICurBlock;
- myCurIndex += myVector->myIncrement;
- }
- }
-
- Standard_Integer differV (const Iterator& theOther) const
- {
- return (myCurIndex - theOther.myCurIndex) + (myICurBlock - theOther.myICurBlock) * myVector->myIncrement;
- }
-
- const MemBlock* curBlockV() const
- {
- return &myVector->myData[myICurBlock];
- }
-
- protected:
- const NCollection_BaseVector* myVector; //!< the Master vector
- Standard_Integer myICurBlock; //!< # of the current block
- Standard_Integer myIEndBlock;
- Standard_Integer myCurIndex; //!< Index in the current block
- Standard_Integer myEndIndex;
- };
-
-protected: //! @name Block initializer
-
- typedef void (*initMemBlocks_t) (NCollection_BaseVector& theVector,
- MemBlock& theBlock,
- const Standard_Integer theFirst,
- const Standard_Integer theSize);
-
- //! Allocate memory for array of memory blocks.
- //! @param theCapacity Number of memory blocks in array
- //! @param theSource Original array of memory blocks, will be automatically deallocated
- //! @param theSourceSize Number of memory blocks in original array
- Standard_EXPORT MemBlock* allocMemBlocks (const Standard_Integer theCapacity,
- MemBlock* theSource = NULL,
- const Standard_Integer theSourceSize = 0);
-
-protected: //! @name protected methods
-
- //! Empty constructor
- NCollection_BaseVector (const Handle(NCollection_BaseAllocator)& theAllocator,
- initMemBlocks_t theInitBlocks,
- const size_t theSize,
- const Standard_Integer theInc)
- : myItemSize (theSize),
- myIncrement (theInc),
- myLength (0),
- myCapacity (GetCapacity (myIncrement)),
- myNBlocks (0),
- myInitBlocks (theInitBlocks)
- {
- myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
- myData = allocMemBlocks (myCapacity);
- }
-
- //! Copy constructor
- NCollection_BaseVector (const Handle(NCollection_BaseAllocator)& theAllocator,
- initMemBlocks_t theInitBlocks,
- const NCollection_BaseVector& theOther)
- : myItemSize (theOther.myItemSize),
- myIncrement (theOther.myIncrement),
- myLength (theOther.myLength),
- myCapacity (GetCapacity(myIncrement) + theOther.myLength / theOther.myIncrement),
- myNBlocks (theOther.myLength == 0 ? 0 : 1 + (theOther.myLength - 1)/theOther.myIncrement),
- myInitBlocks (theInitBlocks)
- {
- myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
- myData = allocMemBlocks (myCapacity);
- }
-
- //! Destructor
- virtual ~NCollection_BaseVector() {}
-
- //! @return pointer to memory where to put the new item
- Standard_EXPORT void* expandV (const Standard_Integer theIndex);
-
- //! Locate the memory holding the desired value
- inline void* findV (const Standard_Integer theIndex) const
- {
- Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex >= myLength,
- "NCollection_BaseVector::findV");
- const Standard_Integer aBlock = theIndex / myIncrement;
- return myData[aBlock].findV (theIndex - aBlock * myIncrement, myItemSize);
- }
-
-public: //! @name public API
-
- //! Empty the vector of its objects
- Standard_EXPORT void Clear();
- // to set the size of increment dynamically
- void SetIncrement(const Standard_Integer aIncrement) {
- if (aIncrement > 0) {
- if (!myIncrement) {
- myIncrement=aIncrement;
- }
- }
- }
-
- //! Returns attached allocator
- const Handle(NCollection_BaseAllocator)& Allocator() const
- {
- return myAllocator;
- }
-
-protected: //! @name Protected fields
-
- Handle(NCollection_BaseAllocator) myAllocator;
- size_t myItemSize;
- Standard_Integer myIncrement;
- Standard_Integer myLength;
- Standard_Integer myCapacity;
- Standard_Integer myNBlocks;
- MemBlock* myData;
- initMemBlocks_t myInitBlocks;
-
-protected:
-
- friend class Iterator;
-};
-
-#endif // NCollection_BaseVector_HeaderFile
#include <NCollection_LocalArray.hxx>
#include <NCollection_Array1.hxx>
+#include <Standard_HashUtils.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_IncAllocator.hxx>
-#include <NCollection_TypeDef.hxx>
//! Auxiliary enumeration serving as responce from method Inspect
enum NCollection_CellFilter_Action
template <class Inspector> class NCollection_CellFilter
{
public:
- typedef TYPENAME Inspector::Target Target;
- typedef TYPENAME Inspector::Point Point;
+ typedef typename Inspector::Target Target;
+ typedef typename Inspector::Point Point;
public:
return Standard_True;
}
- //! Returns hash code for this cell, in the range [1, theUpperBound]
- //! @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]
- Standard_Integer HashCode (const Standard_Integer theUpperBound) const
+ bool operator==(const Cell& theOther) const
{
- // number of bits per each dimension in the hash code
- const std::size_t aDim = index.Size();
- const std::size_t aShiftBits = (BITS (Cell_IndexType) - 1) / aDim;
- std::size_t aCode = 0;
-
- for (std::size_t i = 0; i < aDim; ++i)
- {
- aCode = (aCode << aShiftBits) ^ std::size_t(index[i]);
- }
-
- return ::HashCode(aCode, theUpperBound);
+ return IsEqual(theOther);
}
public:
NCollection_LocalArray<Cell_IndexType, 10> index;
ListNode *Objects;
};
-
- //! Returns hash code for the given cell, in the range [1, theUpperBound]
- //! @param theCell the cell object 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]
- friend Standard_Integer HashCode (const Cell& theCell, const Standard_Integer theUpperBound)
+
+ struct CellHasher
{
- return theCell.HashCode (theUpperBound);
- }
+ size_t operator()(const Cell& theCell) const noexcept
+ {
+ // number of bits per each dimension in the hash code
+ const std::size_t aDim = theCell.index.Size();
+ return opencascade::hashBytes(&theCell.index[0], static_cast<int>(aDim * sizeof(Cell_IndexType)));
+ }
- friend Standard_Boolean IsEqual (const Cell &aCell1, const Cell &aCell2)
- { return aCell1.IsEqual(aCell2); }
+ bool operator()(const Cell& theCell1,
+ const Cell& theCell2) const noexcept
+ {
+ return theCell1 == theCell2;
+ }
+ };
+
+ typedef NCollection_Map<Cell, CellHasher> CellMap;
protected:
protected:
Standard_Integer myDim;
Handle(NCollection_BaseAllocator) myAllocator;
- NCollection_Map<Cell> myCells;
+ CellMap myCells;
NCollection_Array1<Standard_Real> myCellSize;
};
#include <Standard_TypeMismatch.hxx>
#include <Standard_NoSuchObject.hxx>
+#include <utility>
+
+#include <Message.hxx>
/**
* Purpose: The DataMap is a Map to store keys with associated
NCollection_TListNode<TheItemType> (theItem, theNext),
myKey(theKey)
{}
+ //! Constructor with 'Next'
+ DataMapNode (const TheKeyType& theKey,
+ TheItemType&& theItem,
+ NCollection_ListNode* theNext) :
+ NCollection_TListNode<TheItemType> (std::forward<TheItemType>(theItem), theNext),
+ myKey(theKey)
+ {}
+ //! Constructor with 'Next'
+ DataMapNode (TheKeyType&& theKey,
+ const TheItemType& theItem,
+ NCollection_ListNode* theNext) :
+ NCollection_TListNode<TheItemType> (theItem, theNext),
+ myKey(std::forward<TheKeyType>(theKey))
+ {}
+ //! Constructor with 'Next'
+ DataMapNode (TheKeyType&& theKey,
+ TheItemType&& theItem,
+ NCollection_ListNode* theNext) :
+ NCollection_TListNode<TheItemType> (std::forward<TheItemType>(theItem), theNext),
+ myKey(std::forward<TheKeyType>(theKey))
+ {}
//! Key
const TheKeyType& Key (void) const
//! Copy constructor
NCollection_DataMap (const NCollection_DataMap& theOther)
: NCollection_BaseMap (theOther.NbBuckets(), Standard_True, theOther.myAllocator)
- { *this = theOther; }
+ {
+ const int anExt = theOther.Extent();
+ if (anExt <= 0)
+ return;
+ ReSize(anExt - 1);
+ for (Iterator anIter(theOther); anIter.More(); anIter.Next())
+ Bind(anIter.Key(), anIter.Value());
+ }
+
+ //! Move constructor
+ NCollection_DataMap(NCollection_DataMap&& theOther) noexcept :
+ NCollection_BaseMap(std::forward<NCollection_BaseMap>(theOther))
+ {}
//! Exchange the content of two maps without re-allocations.
//! Notice that allocators will be swapped as well!
return Assign (theOther);
}
+ //! Move operator
+ NCollection_DataMap& operator= (NCollection_DataMap&& theOther) noexcept
+ {
+ if (this == &theOther)
+ return *this;
+ exchangeMapsData(theOther);
+ return *this;
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
{
DataMapNode** olddata = (DataMapNode**) myData1;
DataMapNode *p, *q;
- Standard_Integer i,k;
- for (i = 0; i <= NbBuckets(); i++)
+ for (int i = 0; i <= NbBuckets(); i++)
{
if (olddata[i])
{
p = olddata[i];
while (p)
{
- k = Hasher::HashCode(p->Key(),newBuck);
+ const size_t k = HashCode(p->Key(),newBuck);
q = (DataMapNode*) p->Next();
p->Next() = newdata[k];
newdata[k] = p;
//! Bind binds Item to Key in map.
//! @param theKey key to add/update
- //! @param theItem new item; overrides value previously bound to the key, if any
+ //! @param theItem new item; overrides value previously bound to the key
//! @return Standard_True if Key was not bound already
Standard_Boolean Bind (const TheKeyType& theKey, const TheItemType& theItem)
{
if (Resizable())
ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
+ {
+ aNode->ChangeValue() = theItem;
+ return Standard_False;
+ }
DataMapNode** data = (DataMapNode**)myData1;
- Standard_Integer k = Hasher::HashCode (theKey, NbBuckets());
- DataMapNode* p = data[k];
- while (p)
+ data[aHash] = new (this->myAllocator) DataMapNode (theKey, theItem, data[aHash]);
+ Increment();
+ return Standard_True;
+ }
+
+ //! Bind binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return Standard_True if Key was not bound already
+ Standard_Boolean Bind (TheKeyType&& theKey, const TheItemType& theItem)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
{
- if (Hasher::IsEqual(p->Key(), theKey))
- {
- p->ChangeValue() = theItem;
- return Standard_False;
- }
- p = (DataMapNode *) p->Next();
+ aNode->ChangeValue() = theItem;
+ return Standard_False;
+ }
+ DataMapNode** data = (DataMapNode**)myData1;
+ data[aHash] = new (this->myAllocator) DataMapNode (std::forward<TheKeyType>(theKey), theItem, data[aHash]);
+ Increment();
+ return Standard_True;
+ }
+
+ //! Bind binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return Standard_True if Key was not bound already
+ Standard_Boolean Bind (const TheKeyType& theKey, TheItemType&& theItem)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
+ {
+ aNode->ChangeValue() = std::forward<TheItemType>(theItem);
+ return Standard_False;
+ }
+ DataMapNode** data = (DataMapNode**)myData1;
+ data[aHash] = new (this->myAllocator) DataMapNode (theKey, std::forward<TheItemType>(theItem), data[aHash]);
+ Increment();
+ return Standard_True;
+ }
+
+ //! Bind binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return Standard_True if Key was not bound already
+ Standard_Boolean Bind (TheKeyType&& theKey, TheItemType&& theItem)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
+ {
+ aNode->ChangeValue() = theItem;
+ return Standard_False;
}
- data[k] = new (this->myAllocator) DataMapNode (theKey, theItem, data[k]);
+ DataMapNode** data = (DataMapNode**)myData1;
+ data[aHash] = new (this->myAllocator) DataMapNode (std::forward<TheKeyType>(theKey),
+ std::forward<TheItemType>(theItem), data[aHash]);
Increment();
return Standard_True;
}
- //! Bound binds Item to Key in map. Returns modifiable Item
+ //! Bound binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return pointer to modifiable Item
TheItemType* Bound (const TheKeyType& theKey, const TheItemType& theItem)
{
if (Resizable())
ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
+ {
+ aNode->ChangeValue() = theItem;
+ return &aNode->ChangeValue();
+ }
DataMapNode** data = (DataMapNode**)myData1;
- Standard_Integer k = Hasher::HashCode (theKey, NbBuckets());
- DataMapNode* p = data[k];
- while (p)
+ data[aHash] = new (this->myAllocator) DataMapNode (theKey, theItem, data[aHash]);
+ Increment();
+ return &data[aHash]->ChangeValue();
+ }
+
+ //! Bound binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return pointer to modifiable Item
+ TheItemType* Bound (TheKeyType&& theKey, const TheItemType& theItem)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
{
- if (Hasher::IsEqual(p->Key(), theKey))
- {
- p->ChangeValue() = theItem;
- return &p->ChangeValue();
- }
- p = (DataMapNode*)p->Next();
+ aNode->ChangeValue() = theItem;
+ return &aNode->ChangeValue();
+ }
+ DataMapNode** data = (DataMapNode**)myData1;
+ data[aHash] = new (this->myAllocator) DataMapNode (std::forward<TheKeyType>(theKey), theItem, data[aHash]);
+ Increment();
+ return &data[aHash]->ChangeValue();
+ }
+
+ //! Bound binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return pointer to modifiable Item
+ TheItemType* Bound (const TheKeyType& theKey, TheItemType&& theItem)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
+ {
+ aNode->ChangeValue() = std::forward<TheItemType>(theItem);
+ return &aNode->ChangeValue();
}
- data[k] = new (this->myAllocator) DataMapNode (theKey, theItem, data[k]);
+ DataMapNode** data = (DataMapNode**)myData1;
+ data[aHash] = new (this->myAllocator) DataMapNode (theKey, std::forward<TheItemType>(theItem), data[aHash]);
+ Increment();
+ return &data[aHash]->ChangeValue();
+ }
+
+ //! Bound binds Item to Key in map.
+ //! @param theKey key to add/update
+ //! @param theItem new item; overrides value previously bound to the key
+ //! @return pointer to modifiable Item
+ TheItemType* Bound (TheKeyType&& theKey, TheItemType&& theItem)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ size_t aHash;
+ DataMapNode* aNode;
+ if (lookup(theKey, aNode, aHash))
+ {
+ aNode->ChangeValue() = std::forward<TheItemType>(theItem);
+ return &aNode->ChangeValue();
+ }
+ DataMapNode** data = (DataMapNode**)myData1;
+ data[aHash] = new (this->myAllocator) DataMapNode (std::forward<TheKeyType>(theKey),
+ std::forward<TheItemType>(theItem), data[aHash]);
Increment();
- return &data[k]->ChangeValue();
+ return &data[aHash]->ChangeValue();
}
//! IsBound
if (IsEmpty())
return Standard_False;
DataMapNode** data = (DataMapNode**) myData1;
- Standard_Integer k = Hasher::HashCode(theKey,NbBuckets());
+ const size_t k = HashCode(theKey,NbBuckets());
DataMapNode* p = data[k];
DataMapNode* q = NULL;
while (p)
{
- if (Hasher::IsEqual(p->Key(), theKey))
+ if (IsEqual(p->Key(), theKey))
{
Decrement();
if (q)
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
- void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
+ void Clear(const Standard_Boolean doReleaseMemory = Standard_False)
{ Destroy (DataMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{
- Clear();
+ Clear(theAllocator != this->myAllocator);
this->myAllocator = ( ! theAllocator.IsNull() ? theAllocator :
NCollection_BaseAllocator::CommonBaseAllocator() );
}
//! Destructor
virtual ~NCollection_DataMap (void)
- { Clear(); }
+ { Clear(true); }
//! Size
Standard_Integer Size(void) const
protected:
- // ---------- PROTECTED METHODS ----------
- //! Lookup for particular key in map. Returns true if key is found and
- //! thepNode points to binded node. Returns false if key is not found,
- //! thehNode value is this case is not usable.
- Standard_Boolean lookup(const TheKeyType& theKey,DataMapNode*& thepNode) const
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey,DataMapNode*& theNode) const
{
if (IsEmpty())
return Standard_False; // Not found
- for (thepNode = (DataMapNode*)myData1[Hasher::HashCode(theKey, NbBuckets())];
- thepNode; thepNode = (DataMapNode*)thepNode->Next())
+ for (theNode = (DataMapNode*)myData1[HashCode(theKey, NbBuckets())];
+ theNode; theNode = (DataMapNode*)theNode->Next())
{
- if (Hasher::IsEqual(thepNode->Key(), theKey))
+ if (IsEqual(theNode->Key(), theKey))
return Standard_True;
}
return Standard_False; // Not found
}
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @param[out] theHash computed bounded hash code for current key.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, DataMapNode*& theNode, size_t& theHash) const
+ {
+ theHash = HashCode(theKey, NbBuckets());
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (DataMapNode*)myData1[theHash];
+ theNode; theNode = (DataMapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key(), theKey))
+ {
+ return Standard_True;
+ }
+ }
+ return Standard_False; // Not found
+ }
+
+ bool IsEqual(const TheKeyType& theKey1,
+ const TheKeyType& theKey2) const
+ {
+ return myHasher(theKey1, theKey2);
+ }
+
+ size_t HashCode(const TheKeyType& theKey,
+ const int theUpperBound) const
+ {
+ return myHasher(theKey) % theUpperBound + 1;
+ }
+
+private:
+
+ Hasher myHasher;
};
#endif
#ifndef NCollection_DefaultHasher_HeaderFile
#define NCollection_DefaultHasher_HeaderFile
-#include <Standard_Integer.hxx>
-
-//=======================================================================
-//function : HashCode_Proxy
-//purpose : Function is required to call the global function HashCode.
-//=======================================================================
-
-//! Returns hash code for the given key, in the range [1, theUpperBound]
-//! @tparam TheKeyType the type of the given key
-//! @param theKey the key 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]
-template <class TheKeyType>
-inline Standard_Integer HashCode_Proxy (const TheKeyType& theKey, const Standard_Integer theUpperBound)
-{
- return HashCode (theKey, theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose : Default implementation of IsEqual via operator ==
-//=======================================================================
-
-template <class TheKeyType>
-inline Standard_Boolean IsEqual (const TheKeyType& theKey1,
- const TheKeyType& theKey2)
-{
- return theKey1 == theKey2;
-}
-
-//=======================================================================
-//function : IsEqual_Proxy
-//purpose : Function is required to call the global function IsEqual.
-//=======================================================================
-
-template <class TheKeyType>
-inline Standard_Boolean IsEqual_Proxy (const TheKeyType& theKey1,
- const TheKeyType& theKey2)
-{
- return IsEqual (theKey1, theKey2);
-}
+#include <functional>
+#include <Standard_HashUtils.hxx>
+#include <NCollection_DefineHasher.hxx>
/**
* Purpose: The DefaultHasher is a Hasher that is used by
- * default in NCollection maps.
+ * default in NCollection maps.
* To compute the hash code of the key is used the
* global function HashCode.
* To compare two keys is used the global function
* IsEqual.
*/
-template <class TheKeyType> class NCollection_DefaultHasher {
-public:
- //! Returns hash code for the given key, in the range [1, theUpperBound]
- //! @param theKey the key 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 TheKeyType& theKey, const Standard_Integer theUpperBound)
+template <class TheKeyType>
+DEFINE_HASHER(NCollection_DefaultHasher, TheKeyType, std::hash<TheKeyType>, std::equal_to<TheKeyType>)
+
+
+#define DEFINE_DEFAULT_HASHER_PURE(TheKeyType) \
+template <> struct NCollection_DefaultHasher<TheKeyType> \
+{ \
+ size_t operator()(const TheKeyType theKey) const noexcept \
+ { \
+ return static_cast<size_t>(theKey); \
+ } \
+ \
+ bool operator() (const TheKeyType theK1, \
+ const TheKeyType theK2) const noexcept \
+ { \
+ return theK1 == theK2; \
+ } \
+};
+
+/// Explicit specialization for bool.
+DEFINE_DEFAULT_HASHER_PURE(bool)
+
+/// Explicit specialization for char.
+DEFINE_DEFAULT_HASHER_PURE(char)
+
+/// Explicit specialization for signed char.
+DEFINE_DEFAULT_HASHER_PURE(signed char)
+
+/// Explicit specialization for unsigned char.
+DEFINE_DEFAULT_HASHER_PURE(unsigned char)
+
+/// Explicit specialization for wchar_t.
+DEFINE_DEFAULT_HASHER_PURE(wchar_t)
+
+/// Explicit specialization for char16_t.
+DEFINE_DEFAULT_HASHER_PURE(char16_t)
+
+/// Explicit specialization for char32_t.
+DEFINE_DEFAULT_HASHER_PURE(char32_t)
+
+/// Explicit specialization for short.
+DEFINE_DEFAULT_HASHER_PURE(short)
+
+/// Explicit specialization for int.
+DEFINE_DEFAULT_HASHER_PURE(int)
+
+/// Explicit specialization for long.
+DEFINE_DEFAULT_HASHER_PURE(long)
+
+/// Explicit specialization for long long.
+DEFINE_DEFAULT_HASHER_PURE(long long)
+
+/// Explicit specialization for unsigned short.
+DEFINE_DEFAULT_HASHER_PURE(unsigned short)
+
+/// Explicit specialization for unsigned int.
+DEFINE_DEFAULT_HASHER_PURE(unsigned int)
+
+/// Explicit specialization for unsigned long.
+DEFINE_DEFAULT_HASHER_PURE(unsigned long)
+
+/// Explicit specialization for unsigned long long.
+DEFINE_DEFAULT_HASHER_PURE(unsigned long long)
+
+/// Explicit specialization for pointer.
+template <class TheKeyType>
+struct NCollection_DefaultHasher<TheKeyType*>
+{
+ size_t operator()(const TheKeyType* theKey) const noexcept
{
- return HashCode_Proxy (theKey, theUpperBound);
+ return static_cast<size_t>(reinterpret_cast<std::uintptr_t>(theKey));
}
- //
- static Standard_Boolean IsEqual(const TheKeyType& theKey1,
- const TheKeyType& theKey2) {
- return IsEqual_Proxy(theKey1, theKey2);
+ bool operator() (const TheKeyType* theK1, const TheKeyType* theK2) const noexcept
+ {
+ return theK1 == theK2;
}
};
+++ /dev/null
-// Created on: 2002-04-15
-// Created by: Alexander Kartomin (akm)
-// Copyright (c) 2002-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.
-
-// Automatically created from NCollection_Array1.hxx by GAWK
-// Purpose: The class Array2 represents unidimensional arrays
-// of fixed size known at run time.
-// The range of the index is user defined.
-// An array1 can be constructed with a "C array".
-// This functionality is useful to call methods expecting
-// an Array1. It allows to carry the bounds inside the arrays.
-// Examples: Item tab[100]; // An example with a C array
-// Array1OfItem ttab (tab[0],1,100);
-// Array1OfItem tttab (ttab(10),10,20); // a slice of ttab
-// If you want to reindex an array from 1 to Length do :
-// Array1 tab1(tab(tab.Lower()),1,tab.Length());
-// Warning: Programs client of such a class must be independent
-// of the range of the first element. Then, a C++ for
-// loop must be written like this
-// for (i = A.Lower(); i <= A.Upper(); i++)
-// Changes: In comparison to TCollection the flag isAllocated was
-// renamed into myDeletable (alike in the Array2). For naming
-// compatibility the method IsAllocated remained in class along
-// with IsDeletable.
-
-#ifndef NCollection_DefineArray1_HeaderFile
-#define NCollection_DefineArray1_HeaderFile
-
-#include <NCollection_Array1.hxx>
-
-// *********************************************** Template for Array1 class
-
-#define DEFINE_ARRAY1(_ClassName_, _BaseCollection_, TheItemType) \
-typedef NCollection_Array1<TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-15
-// Created by: Alexander Kartomin (akm)
-// Copyright (c) 2002-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.
-
-// Automatically created from NCollection_Array2.hxx by GAWK
-// Purpose: The class Array2 represents bi-dimensional arrays
-// of fixed size known at run time.
-// The ranges of indices are user defined.
-// Warning: Programs clients of such class must be independent
-// of the range of the first element. Then, a C++ for
-// loop must be written like this
-// for (i = A.LowerRow(); i <= A.UpperRow(); i++)
-// for (j = A.LowerCol(); j <= A.UpperCol(); j++)
-
-#ifndef NCollection_DefineArray2_HeaderFile
-#define NCollection_DefineArray2_HeaderFile
-
-#include <NCollection_Array2.hxx>
-
-// *********************************************** Template for Array2 class
-
-#define DEFINE_ARRAY2(_ClassName_, _BaseCollection_, TheItemType) \
-typedef NCollection_Array2<TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-24
-// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-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.
-
-// Purpose: The DataMap is a Map to store keys with associated
-// Items. See Map from NCollection for a discussion
-// about the number of buckets.
-// The DataMap can be seen as an extended array where
-// the Keys are the indices. For this reason the
-// operator () is defined on DataMap to fetch an Item
-// from a Key. So the following syntax can be used :
-// anItem = aMap(aKey);
-// aMap(aKey) = anItem;
-// This analogy has its limit. aMap(aKey) = anItem
-// can be done only if aKey was previously bound to
-// an item in the map.
-
-#ifndef NCollection_DefineDataMap_HeaderFile
-#define NCollection_DefineDataMap_HeaderFile
-
-#include <NCollection_DataMap.hxx>
-
-// *********************************************** Class DataMap *************
-
-#define DEFINE_DATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
-typedef NCollection_DataMap<TheKeyType, TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-24
-// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-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.
-
-// Purpose: The DoubleMap is used to bind pairs (Key1,Key2)
-// and retrieve them in linear time.
-// See Map from NCollection for a discussion about the number
-// of buckets
-
-#ifndef NCollection_DefineDoubleMap_HeaderFile
-#define NCollection_DefineDoubleMap_HeaderFile
-
-#include <NCollection_DoubleMap.hxx>
-
-// *********************************************** Class DoubleMap ************
-
-#define DEFINE_DOUBLEMAP(_ClassName_, _BaseCollection_, TheKey1Type, TheKey2Type) \
-typedef NCollection_DoubleMap <TheKey1Type, TheKey2Type > _ClassName_;
-
-#endif
#define NCollection_DefineHArray1_HeaderFile
#include <Standard_Type.hxx>
-#include <NCollection_DefineArray1.hxx>
#include <Standard_Transient.hxx>
// Declaration of Array1 class managed by Handle
#define DEFINE_HARRAY1(HClassName, _Array1Type_) \
-class HClassName : public _Array1Type_, public Standard_Transient { \
+class HClassName : public _Array1Type_, public Standard_Transient { \
public: \
DEFINE_STANDARD_ALLOC \
DEFINE_NCOLLECTION_ALLOC \
const Standard_Integer theUpper, \
const _Array1Type_::value_type& theValue) : \
_Array1Type_ (theLower,theUpper) { Init (theValue); } \
+ explicit HClassName (const typename _Array1Type_::value_type& theBegin, \
+ const Standard_Integer theLower, \
+ const Standard_Integer theUpper, \
+ const bool) : \
+ _Array1Type_ (theBegin,theLower,theUpper) {} \
HClassName (const _Array1Type_& theOther) : _Array1Type_(theOther) {} \
const _Array1Type_& Array1 () const { return *this; } \
_Array1Type_& ChangeArray1 () { return *this; } \
- DEFINE_STANDARD_RTTI_INLINE(HClassName,Standard_Transient) \
+ DEFINE_STANDARD_RTTI_INLINE(HClassName,Standard_Transient) \
}; \
DEFINE_STANDARD_HANDLE (HClassName, Standard_Transient)
-#define IMPLEMENT_HARRAY1(HClassName)
-
-
+#define IMPLEMENT_HARRAY1(HClassName)
#endif
#define NCollection_DefineHArray2_HeaderFile
#include <Standard_Type.hxx>
-#include <NCollection_DefineArray2.hxx>
#include <Standard_Transient.hxx>
// Declaration of Array2 class managed by Handle
#define NCollection_DefineHSequence_HeaderFile
#include <Standard_Type.hxx>
-#include <NCollection_DefineSequence.hxx>
#include <Standard_Transient.hxx>
// Declaration of Sequence class managed by Handle
--- /dev/null
+// Copyright (c) 2023 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_DefineHasher_HeaderFile
+#define NCollection_DefineHasher_HeaderFile
+
+#define DEFINE_HASHER(HasherName, TheKeyType, HashFunctor, EqualFunctor) \
+struct HasherName : protected HashFunctor, EqualFunctor \
+{ \
+ size_t operator()(const TheKeyType& theKey) const noexcept \
+ { \
+ return HashFunctor::operator()(theKey); \
+ } \
+ \
+ bool operator() (const TheKeyType& theK1, \
+ const TheKeyType& theK2) const noexcept \
+ { \
+ return EqualFunctor::operator()(theK1, theK2); \
+ } \
+};
+
+#endif
+++ /dev/null
-// Created on: 2002-04-24
-// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-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.
-
-// Purpose: An indexed map is used to store keys and to bind
-// an index to them. Each new key stored in the map
-// gets an index. Index are incremented as keys are
-// stored in the map. A key can be found by the index
-// and an index by the key. No key but the last can
-// be removed so the indices are in the range 1..
-// Extent. An Item is stored with each key.
-// This class is similar to IndexedMap from
-// NCollection with the Item as a new feature. Note
-// the important difference on the operator (). In
-// the IndexedMap this operator returns the Key. In
-// the IndexedDataMap this operator returns the Item.
-// See the class Map from NCollection for a
-// discussion about the number of buckets.
-
-#ifndef NCollection_DefineIndexedDataMap_HeaderFile
-#define NCollection_DefineIndexedDataMap_HeaderFile
-
-#include <NCollection_IndexedDataMap.hxx>
-
-// *********************************************** Class IndexedDataMap ******
-
-#define DEFINE_INDEXEDDATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
-typedef NCollection_IndexedDataMap <TheKeyType, TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-24
-// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-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.
-
-// Purpose: An indexed map is used to store keys and to bind
-// an index to them. Each new key stored in the map
-// gets an index. Index are incremented as keys are
-// stored in the map. A key can be found by the index
-// and an index by the key. No key but the last can
-// be removed so the indices are in the range 1..Extent.
-// See the class Map from NCollection for a
-// discussion about the number of buckets.
-
-#ifndef NCollection_DefineIndexedMap_HeaderFile
-#define NCollection_DefineIndexedMap_HeaderFile
-
-#include <NCollection_IndexedMap.hxx>
-
-// *********************************************** Class IndexedMap ***********
-
-#define DEFINE_INDEXEDMAP(_ClassName_, _BaseCollection_, TheKeyType) \
-typedef NCollection_IndexedMap <TheKeyType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-17
-// Created by: Alexander Kartomin (akm)
-// Copyright (c) 2002-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.
-
-// Automatically created from NCollection_List.hxx by GAWK
-// Purpose: Simple list to link items together keeping the first
-// and the last one.
-// Inherits BaseList, adding the data item to each node.
-
-
-#ifndef NCollection_DefineList_HeaderFile
-#define NCollection_DefineList_HeaderFile
-
-#include <NCollection_List.hxx>
-
-// **************************************** Template for List class ********
-
-#define DEFINE_LIST(_ClassName_, _BaseCollection_, TheItemType) \
-typedef NCollection_List <TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-23
-// Created by: Alexander KARTOMIN (akm)
-// Copyright (c) 2002-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.
-
-// Purpose: Single hashed Map. This Map is used to store and
-// retrieve keys in linear time.
-// The ::Iterator class can be used to explore the
-// content of the map. It is not wise to iterate and
-// modify a map in parallel.
-// To compute the hashcode of the key the function
-// ::HashCode must be defined in the global namespace
-// To compare two keys the function ::IsEqual must be
-// defined in the global namespace.
-// The performance of a Map is conditioned by its
-// number of buckets that should be kept greater to
-// the number of keys. This map has an automatic
-// management of the number of buckets. It is resized
-// when the number of Keys becomes greater than the
-// number of buckets.
-// If you have a fair idea of the number of objects
-// you can save on automatic resizing by giving a
-// number of buckets at creation or using the ReSize
-// method. This should be consider only for crucial
-// optimisation issues.
-
-#ifndef NCollection_DefineMap_HeaderFile
-#define NCollection_DefineMap_HeaderFile
-
-#include <NCollection_Map.hxx>
-
-// *********************************************** Class Map *****************
-
-#define DEFINE_MAP(_ClassName_, _BaseCollection_, TheKeyType) \
-typedef NCollection_Map <TheKeyType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-03-28
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2002-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.
-
-// Automatically created from NCollection_Sequence.hxx by GAWK
-// Purpose: Definition of a sequence of elements indexed by
-// an Integer in range of 1..n
-
-
-#ifndef NCollection_DefineSequence_HeaderFile
-#define NCollection_DefineSequence_HeaderFile
-
-#include <NCollection_Sequence.hxx>
-
-// **************************************** Template for Sequence class ********
-
-#define DEFINE_SEQUENCE(_ClassName_, _BaseCollection_, TheItemType) \
-typedef NCollection_Sequence<TheItemType > _ClassName_;
-
-#endif
+++ /dev/null
-// Created on: 2002-04-23
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2002-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.
-
-// Automatically created from NCollection_Vector.hxx by GAWK
-
-
-#ifndef NCollection_DefineVector_HeaderFile
-#define NCollection_DefineVector_HeaderFile
-
-#include <NCollection_Vector.hxx>
-
-// Class NCollection_Vector (dynamic array of objects)
-// This class is similar to NCollection_Array1 though the indices always start
-// at 0 (in Array1 the first index must be specified)
-// The Vector is always created with 0 length. It can be enlarged by two means:
-// 1. Calling the method Append (val) - then "val" is added to the end of the
-// vector (the vector length is incremented)
-// 2. Calling the method SetValue (i, val) - if "i" is greater than or equal
-// to the current length of the vector, the vector is enlarged to accomo-
-// The methods Append and SetValue return a non-const reference to the copied
-// object inside the vector. This reference is guaranteed to be valid until
-// the vector is destroyed. It can be used to access the vector member directly
-// or to pass its address to other data structures.
-// The vector iterator remembers the length of the vector at the moment of the
-// creation or initialisation of the iterator. Therefore the iteration begins
-// at index 0 and stops at the index equal to (remembered_length-1). It is OK
-// to enlarge the vector during the iteration.
-
-#define DEFINE_VECTOR(_ClassName_, _BaseCollection_, TheItemType) \
-typedef NCollection_Vector<TheItemType > _ClassName_;
-
-#endif
{
TheKey1Type aKey1 = anIter.Key1();
TheKey2Type aKey2 = anIter.Key2();
- Standard_Integer iK1 = Hasher1::HashCode (aKey1, NbBuckets());
- Standard_Integer iK2 = Hasher2::HashCode (aKey2, NbBuckets());
+ const size_t iK1 = HashCode1 (aKey1, NbBuckets());
+ const size_t iK2 = HashCode2 (aKey2, NbBuckets());
DoubleMapNode * pNode = new (this->myAllocator) DoubleMapNode (aKey1, aKey2,
myData1[iK1],
myData2[iK2]);
if (myData1)
{
DoubleMapNode *p, *q;
- Standard_Integer i, iK1, iK2;
- for (i = 0; i <= NbBuckets(); i++)
+ for (int i = 0; i <= NbBuckets(); i++)
{
if (myData1[i])
{
p = (DoubleMapNode *) myData1[i];
while (p)
{
- iK1 = Hasher1::HashCode (p->Key1(), newBuck);
- iK2 = Hasher2::HashCode (p->Key2(), newBuck);
+ const size_t iK1 = HashCode1 (p->Key1(), newBuck);
+ const size_t iK2 = HashCode2 (p->Key2(), newBuck);
q = (DoubleMapNode*) p->Next();
p->Next() = ppNewData1[iK1];
p->Next2() = (DoubleMapNode*)ppNewData2[iK2];
{
if (Resizable())
ReSize(Extent());
- Standard_Integer iK1 = Hasher1::HashCode (theKey1, NbBuckets());
- Standard_Integer iK2 = Hasher2::HashCode (theKey2, NbBuckets());
+ const size_t iK1 = HashCode1 (theKey1, NbBuckets());
+ const size_t iK2 = HashCode2 (theKey2, NbBuckets());
DoubleMapNode * pNode;
pNode = (DoubleMapNode *) myData1[iK1];
while (pNode)
{
- if (Hasher1::IsEqual (pNode->Key1(), theKey1))
+ if (IsEqual1 (pNode->Key1(), theKey1))
throw Standard_MultiplyDefined("NCollection_DoubleMap:Bind");
pNode = (DoubleMapNode *) pNode->Next();
}
pNode = (DoubleMapNode *) myData2[iK2];
while (pNode)
{
- if (Hasher2::IsEqual (pNode->Key2(), theKey2))
+ if (IsEqual2 (pNode->Key2(), theKey2))
throw Standard_MultiplyDefined("NCollection_DoubleMap:Bind");
pNode = (DoubleMapNode *) pNode->Next();
}
{
if (IsEmpty())
return Standard_False;
- Standard_Integer iK1 = Hasher1::HashCode (theKey1, NbBuckets());
- Standard_Integer iK2 = Hasher2::HashCode (theKey2, NbBuckets());
+ const size_t iK1 = HashCode1 (theKey1, NbBuckets());
+ const size_t iK2 = HashCode2 (theKey2, NbBuckets());
DoubleMapNode * pNode1, * pNode2;
pNode1 = (DoubleMapNode *) myData1[iK1];
while (pNode1)
{
- if (Hasher1::IsEqual(pNode1->Key1(), theKey1))
+ if (IsEqual1(pNode1->Key1(), theKey1))
break;
pNode1 = (DoubleMapNode *) pNode1->Next();
}
pNode2 = (DoubleMapNode *) myData2[iK2];
while (pNode2)
{
- if (Hasher2::IsEqual(pNode2->Key2(), theKey2))
+ if (IsEqual2(pNode2->Key2(), theKey2))
break;
pNode2 = (DoubleMapNode *) pNode2->Next();
}
{
if (IsEmpty())
return Standard_False;
- Standard_Integer iK1 = Hasher1::HashCode (theKey1, NbBuckets());
+ const size_t iK1 = HashCode1 (theKey1, NbBuckets());
DoubleMapNode * pNode1;
pNode1 = (DoubleMapNode *) myData1[iK1];
while (pNode1)
{
- if (Hasher1::IsEqual(pNode1->Key1(), theKey1))
+ if (IsEqual1(pNode1->Key1(), theKey1))
return Standard_True;
pNode1 = (DoubleMapNode *) pNode1->Next();
}
{
if (IsEmpty())
return Standard_False;
- Standard_Integer iK2 = Hasher2::HashCode (theKey2, NbBuckets());
+ const size_t iK2 = HashCode2 (theKey2, NbBuckets());
DoubleMapNode * pNode2;
pNode2 = (DoubleMapNode *) myData2[iK2];
while (pNode2)
{
- if (Hasher2::IsEqual(pNode2->Key2(), theKey2))
+ if (IsEqual2(pNode2->Key2(), theKey2))
return Standard_True;
pNode2 = (DoubleMapNode *) pNode2->Next2();
}
{
if (IsEmpty())
return Standard_False;
- Standard_Integer iK1 = Hasher1::HashCode (theKey1, NbBuckets());
+ const size_t iK1 = HashCode1 (theKey1, NbBuckets());
DoubleMapNode * p1, * p2, * q1, *q2;
q1 = q2 = NULL;
p1 = (DoubleMapNode *) myData1[iK1];
while (p1)
{
- if (Hasher1::IsEqual (p1->Key1(), theKey1))
+ if (IsEqual1 (p1->Key1(), theKey1))
{
// remove from the data1
if (q1)
q1->Next() = p1->Next();
else
myData1[iK1] = (DoubleMapNode*) p1->Next();
- Standard_Integer iK2 = Hasher2::HashCode (p1->Key2(), NbBuckets());
+ const size_t iK2 = HashCode2 (p1->Key2(), NbBuckets());
p2 = (DoubleMapNode *) myData2[iK2];
while (p2)
{
{
if (IsEmpty())
return Standard_False;
- Standard_Integer iK2 = Hasher2::HashCode (theKey2, NbBuckets());
+ const size_t iK2 = HashCode2 (theKey2, NbBuckets());
DoubleMapNode * p1, * p2, * q1, *q2;
q1 = q2 = NULL;
p2 = (DoubleMapNode *) myData2[iK2];
while (p2)
{
- if (Hasher2::IsEqual (p2->Key2(), theKey2))
+ if (IsEqual2 (p2->Key2(), theKey2))
{
// remove from the data2
if (q2)
- q2->Next() = p2->Next();
+ {
+ q2->Next2() = p2->Next2();
+ }
else
myData2[iK2] = (DoubleMapNode*) p2->Next2();
- Standard_Integer iK1 = Hasher1::HashCode (p2->Key1(), NbBuckets());
+ const size_t iK1 = HashCode1 (p2->Key1(), NbBuckets());
p1 = (DoubleMapNode *) myData1[iK1];
while (p1)
{
//! @return pointer to Key2 or NULL if Key1 is not found
const TheKey2Type* Seek1 (const TheKey1Type& theKey1) const
{
- for (DoubleMapNode* aNode1 = !IsEmpty() ? (DoubleMapNode* )myData1[Hasher1::HashCode (theKey1, NbBuckets())] : NULL;
+ for (DoubleMapNode* aNode1 = !IsEmpty() ? (DoubleMapNode* )myData1[HashCode1 (theKey1, NbBuckets())] : NULL;
aNode1 != NULL; aNode1 = (DoubleMapNode* )aNode1->Next())
{
- if (Hasher1::IsEqual (aNode1->Key1(), theKey1))
+ if (IsEqual1 (aNode1->Key1(), theKey1))
{
return &aNode1->Key2();
}
//! @return pointer to Key1 if Key2 has been found
const TheKey1Type* Seek2 (const TheKey2Type& theKey2) const
{
- for (DoubleMapNode* aNode2 = !IsEmpty() ? (DoubleMapNode* )myData2[Hasher2::HashCode (theKey2, NbBuckets())] : NULL;
+ for (DoubleMapNode* aNode2 = !IsEmpty() ? (DoubleMapNode* )myData2[HashCode2 (theKey2, NbBuckets())] : NULL;
aNode2 != NULL; aNode2 = (DoubleMapNode* )aNode2->Next2())
{
- if (Hasher2::IsEqual (aNode2->Key2(), theKey2))
+ if (IsEqual2 (aNode2->Key2(), theKey2))
{
return &aNode2->Key1();
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
- void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
+ void Clear(const Standard_Boolean doReleaseMemory = Standard_False)
{ Destroy (DoubleMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{
- Clear();
+ Clear(true);
this->myAllocator = ( ! theAllocator.IsNull() ? theAllocator :
NCollection_BaseAllocator::CommonBaseAllocator() );
}
//! Destructor
~NCollection_DoubleMap (void)
- { Clear(); }
+ { Clear(true); }
//! Size
Standard_Integer Size(void) const
{ return Extent(); }
+protected:
+
+ bool IsEqual1(const TheKey1Type& theKey1,
+ const TheKey1Type& theKey2) const
+ {
+ return myHasher1(theKey1, theKey2);
+ }
+
+ size_t HashCode1(const TheKey1Type& theKey,
+ const int theUpperBound) const
+ {
+ return myHasher1(theKey) % theUpperBound + 1;
+ }
+
+ bool IsEqual2(const TheKey2Type& theKey1,
+ const TheKey2Type& theKey2) const
+ {
+ return myHasher2(theKey1, theKey2);
+ }
+
+ size_t HashCode2(const TheKey2Type& theKey,
+ const int theUpperBound) const
+ {
+ return myHasher2(theKey) % theUpperBound + 1;
+ }
+
+protected:
+
+ Hasher1 myHasher1;
+ Hasher2 myHasher2;
};
#endif
--- /dev/null
+// Copyright (c) 2002-2023 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_DynamicArray_HeaderFile
+#define NCollection_DynamicArray_HeaderFile
+
+#include "NCollection_Allocator.hxx"
+#include "NCollection_BasePointerVector.hxx"
+#include <Standard_DimensionMismatch.hxx>
+#include <Standard_OutOfMemory.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <Standard_OutOfRange.hxx>
+
+#include <NCollection_BasePointerVector.hxx>
+#include <NCollection_DefineAlloc.hxx>
+#include <NCollection_Allocator.hxx>
+#include <NCollection_Iterator.hxx>
+#include <NCollection_OccAllocator.hxx>
+#include <StdFail_NotDone.hxx>
+#include <NCollection_IndexedIterator.hxx>
+
+#include <locale>
+#include <vector>
+
+//! Class NCollection_DynamicArray (dynamic array of objects)
+//!
+//! The array's indices always start at 0.
+//!
+//! The Vector is always created with 0 length. It can be enlarged by two means:
+//! 1. Calling the method Append (val) - then "val" is added to the end of the
+//! vector (the vector length is incremented)
+//! 2. Calling the method SetValue (i, val) - if "i" is greater than or equal
+//! to the current length of the vector, the vector is enlarged to accomo-
+//! date this index
+//!
+//! The methods Append and SetValue return a non-const reference to the copied
+//! object inside the vector. This reference is guaranteed to be valid until
+//! the vector is destroyed. It can be used to access the vector member directly
+//! or to pass its address to other data structures.
+//!
+//! The vector iterator remembers the length of the vector at the moment of the
+//! creation or initialisation of the iterator. Therefore the iteration begins
+//! at index 0 and stops at the index equal to (remembered_length-1). It is OK
+//! to enlarge the vector during the iteration.
+template <class TheItemType>
+class NCollection_DynamicArray
+{
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC;
+ DEFINE_NCOLLECTION_ALLOC;
+public:
+ typedef NCollection_OccAllocator<TheItemType> allocator_type;
+ typedef NCollection_BasePointerVector vector;
+public:
+
+ // Define various type aliases for convenience
+ using value_type = TheItemType;
+ using size_type = size_t;
+ using difference_type = size_t;
+ using pointer = TheItemType*;
+ using const_pointer = TheItemType&;
+ using reference = TheItemType&;
+ using const_reference = const TheItemType&;
+
+public:
+
+ using iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_DynamicArray, value_type, false>;
+ using const_iterator = NCollection_IndexedIterator<std::random_access_iterator_tag, NCollection_DynamicArray, value_type, true>;
+
+public:
+
+ // Iterator class
+ class Iterator : public NCollection_Iterator<NCollection_DynamicArray>
+ {
+ public:
+ using NCollection_Iterator<NCollection_DynamicArray>::NCollection_Iterator;
+
+ const_reference Value() const
+ {
+ return *NCollection_Iterator<NCollection_DynamicArray>::ValueIter();
+ }
+
+ reference ChangeValue()
+ {
+ return *NCollection_Iterator<NCollection_DynamicArray>::ChangeValueIter();
+ }
+ };
+
+ const_iterator begin() const
+ {
+ return const_iterator(*this);
+ }
+
+ iterator begin()
+ {
+ return iterator(*this);
+ }
+
+ const_iterator cbegin() const
+ {
+ return const_iterator(*this);
+ }
+
+ iterator end()
+ {
+ return iterator(myUsedSize, *this);
+ }
+
+ const_iterator end() const
+ {
+ return const_iterator(myUsedSize, *this);
+ }
+
+ const_iterator cend() const
+ {
+ return const_iterator(myUsedSize, *this);
+ }
+
+public: //! @name public methods
+
+ NCollection_DynamicArray(const Standard_Integer theIncrement = 256) :
+ myContainer(),
+ myAlloc(),
+ myInternalSize(theIncrement),
+ myUsedSize(0)
+ {}
+
+ // Constructor taking an allocator
+ explicit NCollection_DynamicArray(const Standard_Integer theIncrement,
+ const Handle(NCollection_BaseAllocator)& theAllocator) :
+ myContainer(),
+ myAlloc(allocator_type(theAllocator)),
+ myInternalSize(theIncrement),
+ myUsedSize(0)
+ {}
+
+ // Constructor taking an allocator
+ explicit NCollection_DynamicArray(const Standard_Integer theIncrement,
+ const allocator_type& theAllocator) :
+ myContainer(),
+ myAlloc(theAllocator),
+ myInternalSize(theIncrement),
+ myUsedSize(0)
+ {}
+
+ //! Copy constructor
+ NCollection_DynamicArray(const NCollection_DynamicArray& theOther) :
+ myContainer(theOther.myContainer),
+ myAlloc(theOther.myAlloc),
+ myInternalSize(theOther.myInternalSize),
+ myUsedSize(theOther.myUsedSize)
+ {
+ copyDate();
+ }
+
+ NCollection_DynamicArray(NCollection_DynamicArray&& theOther) noexcept :
+ myContainer(std::move(theOther.myContainer)),
+ myAlloc(theOther.myAlloc),
+ myInternalSize(theOther.myInternalSize),
+ myUsedSize(theOther.myUsedSize)
+ {
+ theOther.myUsedSize = 0;
+ }
+
+ ~NCollection_DynamicArray()
+ {
+ Clear(true);
+ }
+
+ //! Total number of items
+ Standard_Integer Length() const
+ {
+ return static_cast<int>(myUsedSize);
+ }
+
+ //! Total number of items in the vector
+ Standard_Integer Size() const
+ {
+ return Length();
+ }
+
+ //! Method for consistency with other collections.
+ //! @return Lower bound (inclusive) for iteration.
+ Standard_Integer Lower() const
+ {
+ return 0;
+ }
+
+ //! Method for consistency with other collections.
+ //! @return Upper bound (inclusive) for iteration.
+ Standard_Integer Upper() const
+ {
+ return Length() - 1;
+ }
+
+ //! Empty query
+ Standard_Boolean IsEmpty() const
+ {
+ return myUsedSize == 0;
+ }
+
+ //! Assignment to the collection of the same type
+ NCollection_DynamicArray& Assign(const NCollection_DynamicArray& theOther,
+ const bool theOwnAllocator = true)
+ {
+ if (&theOther == this)
+ {
+ return *this;
+ }
+ if (!theOwnAllocator)
+ {
+ Clear(myAlloc != theOther.myAlloc);
+ myAlloc = theOther.myAlloc;
+ }
+ else
+ {
+ Clear(false);
+ }
+ myContainer = theOther.myContainer;
+ myInternalSize = theOther.myInternalSize;
+ myUsedSize = theOther.myUsedSize;
+ copyDate();
+ return *this;
+ }
+
+ NCollection_DynamicArray& Assign(NCollection_DynamicArray&& theOther)
+ {
+ if (&theOther == this)
+ {
+ return *this;
+ }
+ Clear(true);
+ myContainer = std::move(theOther.myContainer);
+ myAlloc = theOther.myAlloc;
+ myInternalSize = theOther.myInternalSize;
+ myUsedSize = theOther.myUsedSize;
+ theOther.myUsedSize = 0;
+ return *this;
+ }
+
+ //! Assignment operator
+ NCollection_DynamicArray& operator= (const NCollection_DynamicArray& theOther)
+ {
+ return Assign(theOther, false);
+ }
+
+ //! Assignment operator
+ NCollection_DynamicArray& operator= (NCollection_DynamicArray&& theOther)
+ {
+ return Assign(std::forward<NCollection_DynamicArray>(theOther));
+ }
+
+ //! Append
+ reference Append(const TheItemType& theValue)
+ {
+ if (myUsedSize >= availableSize())
+ {
+ expandArray();
+ }
+ pointer aPnt = &at(myUsedSize++);
+ myAlloc.construct(aPnt, theValue);
+ return *aPnt;
+ }
+
+ //! Append
+ reference Append(TheItemType&& theValue)
+ {
+ if (myUsedSize >= availableSize())
+ {
+ expandArray();
+ }
+ pointer aPnt = &at(myUsedSize++);
+ myAlloc.construct(aPnt, std::forward<TheItemType>(theValue));
+ return *aPnt;
+ }
+
+ void EraseLast()
+ {
+ if (myUsedSize == 0)
+ {
+ return;
+ }
+ TheItemType* aLastElem = &ChangeLast();
+ myAlloc.destroy(aLastElem);
+ myUsedSize--;
+ }
+
+ //! Appends an empty value and returns the reference to it
+ reference Appended()
+ {
+ if (myUsedSize >= availableSize())
+ {
+ expandArray();
+ }
+ pointer aPnt = &at(myUsedSize++);
+ myAlloc.construct(aPnt);
+ return *aPnt;
+ }
+
+ //! Operator() - query the const value
+ const_reference operator() (const Standard_Integer theIndex) const
+ {
+ return Value(theIndex);
+ }
+
+ //! Operator[] - query the const value
+ const_reference operator[] (const Standard_Integer theIndex) const
+ {
+ return Value(theIndex);
+ }
+
+ //! Operator[] - query the const value
+ const_reference operator[] (const size_t theIndex) const
+ {
+ return at(theIndex);
+ }
+
+ const_reference Value(const Standard_Integer theIndex) const
+ {
+ return at(static_cast<int>(theIndex));
+ }
+
+ //! @return first element
+ const_reference First() const
+ {
+ return getArray()[0][0];
+ }
+
+ //! @return first element
+ reference ChangeFirst()
+ {
+ return getArray()[0][0];
+ }
+
+ //! @return last element
+ const_reference Last() const
+ {
+ return at(myUsedSize - 1);
+ }
+
+ //! @return last element
+ reference ChangeLast()
+ {
+ return at(myUsedSize - 1);
+ }
+
+ //! Operator() - query the value
+ reference operator() (const Standard_Integer theIndex)
+ {
+ return ChangeValue(theIndex);
+ }
+
+ //! Operator[] - query the value
+ reference operator[] (const Standard_Integer theIndex)
+ {
+ return ChangeValue(theIndex);
+ }
+
+ //! Operator[] - query the value
+ reference operator[] (const size_t theIndex)
+ {
+ return at(theIndex);
+ }
+
+ reference ChangeValue(const Standard_Integer theIndex)
+ {
+ return at(static_cast<int>(theIndex));
+ }
+
+ //! SetValue () - set or append a value
+ reference SetValue(const Standard_Integer theIndex,
+ const TheItemType& theValue)
+ {
+ const size_t aBlockInd = static_cast<size_t>(theIndex / myInternalSize);
+ const size_t anIndex = static_cast<size_t>(theIndex);
+ for (size_t aInd = myContainer.Size(); aInd <= aBlockInd; aInd++)
+ {
+ expandArray();
+ }
+ if (myUsedSize <= anIndex)
+ {
+ for (; myUsedSize < anIndex; myUsedSize++)
+ {
+ pointer aPnt = &at(myUsedSize);
+ myAlloc.construct(aPnt);
+ }
+ myUsedSize++;
+ }
+ pointer aPnt = &at(anIndex);
+ myAlloc.construct(aPnt, theValue);
+ return *aPnt;
+ }
+
+ //! SetValue () - set or append a value
+ reference SetValue(const Standard_Integer theIndex,
+ TheItemType&& theValue)
+ {
+ const size_t aBlockInd = static_cast<size_t>(theIndex / myInternalSize);
+ const size_t anIndex = static_cast<size_t>(theIndex);
+ for (size_t aInd = myContainer.Size(); aInd <= aBlockInd; aInd++)
+ {
+ expandArray();
+ }
+ if (myUsedSize <= anIndex)
+ {
+ for (; myUsedSize < anIndex; myUsedSize++)
+ {
+ pointer aPnt = &at(myUsedSize);
+ myAlloc.construct(aPnt);
+ }
+ myUsedSize++;
+ }
+ pointer aPnt = &at(anIndex);
+ myAlloc.construct(aPnt, std::forward<TheItemType>(theValue));
+ return *aPnt;
+ }
+
+ void Clear(const bool theReleaseMemory = false)
+ {
+ size_t aUsedSize = 0;
+ for (size_t aBlockInd = 0; aBlockInd < myContainer.Size(); aBlockInd++)
+ {
+ TheItemType* aCurStart = getArray()[aBlockInd];
+ for (size_t anElemInd = 0; anElemInd < myInternalSize && aUsedSize < myUsedSize; anElemInd++, aUsedSize++)
+ {
+ aCurStart[anElemInd].~TheItemType();
+ }
+ if (theReleaseMemory)
+ myAlloc.deallocate(aCurStart, myInternalSize);
+ }
+ if (theReleaseMemory)
+ myContainer.Clear(theReleaseMemory);
+ myUsedSize = 0;
+ }
+
+ void SetIncrement(const Standard_Integer theIncrement)
+ {
+ if (myUsedSize != 0)
+ {
+ return;
+ }
+ myInternalSize = static_cast<size_t>(theIncrement);
+ }
+
+ friend iterator;
+ friend const_iterator;
+
+protected:
+
+ size_t availableSize() const
+ {
+ return myContainer.Size() * myInternalSize;
+ }
+
+ TheItemType* expandArray()
+ {
+ TheItemType* aNewBlock = myAlloc.allocate(myInternalSize);
+ myContainer.Append(aNewBlock);
+ return aNewBlock;
+ }
+
+ reference at(const size_t theInd)
+ {
+ return getArray()[theInd / myInternalSize][theInd % myInternalSize];
+ }
+
+ const_reference at(const size_t theInd) const
+ {
+ return getArray()[theInd / myInternalSize][theInd % myInternalSize];
+ }
+
+ void copyDate()
+ {
+ size_t aUsedSize = 0;
+ for (size_t aBlockInd = 0; aBlockInd < myContainer.Size(); aBlockInd++)
+ {
+ TheItemType* aCurStart = getArray()[aBlockInd];
+ TheItemType* aNewBlock = myAlloc.allocate(myInternalSize);
+ for (size_t anElemInd = 0; anElemInd < myInternalSize && aUsedSize < myUsedSize; anElemInd++, aUsedSize++)
+ {
+ pointer aPnt = &aNewBlock[anElemInd];
+ myAlloc.construct(aPnt, aCurStart[anElemInd]);
+ }
+ getArray()[aBlockInd] = aNewBlock;
+ }
+ }
+
+ //! Wrapper to extract array
+ TheItemType** getArray() const { return (TheItemType**) myContainer.GetArray(); }
+
+protected:
+
+ vector myContainer;
+ allocator_type myAlloc;
+ size_t myInternalSize;
+ size_t myUsedSize;
+};
+
+#endif // NCollection_DynamicArray_HeaderFile
{
public:
typedef NCollection_UBTree <TheObjType, TheBndType> UBTree;
- typedef TYPENAME UBTree::TreeNode TreeNode;
+ typedef typename UBTree::TreeNode TreeNode;
// ---------- PUBLIC METHODS ----------
/**
public:
// ---------- PUBLIC METHODS ----------
Standard_EXPORT virtual void* Allocate (const Standard_Size theSize) Standard_OVERRIDE;
+ void* AllocateOptimal(const Standard_Size theSize) Standard_OVERRIDE { return Allocate(theSize); }
Standard_EXPORT virtual void Free (void * anAddress) Standard_OVERRIDE;
Standard_EXPORT static const Handle(NCollection_HeapAllocator)&
-// Created on: 2002-04-12
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2002-2014 OPEN CASCADE SAS
+// Copyright (c) 2002-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// commercial license or contractual agreement.
#include <NCollection_IncAllocator.hxx>
-#include <NCollection_DataMap.hxx>
-#include <NCollection_Map.hxx>
+
#include <Standard_Mutex.hxx>
#include <Standard_OutOfMemory.hxx>
-#include <stdio.h>
-#include <fstream>
-#include <iomanip>
+#include <cmath>
-IMPLEMENT_STANDARD_RTTIEXT(NCollection_IncAllocator,NCollection_BaseAllocator)
+IMPLEMENT_STANDARD_RTTIEXT(NCollection_IncAllocator, NCollection_BaseAllocator)
namespace
{
-
- inline size_t IMEM_SIZE (const size_t theSize)
- {
- return (theSize - 1) / sizeof(NCollection_IncAllocator::aligned_t) + 1;
- }
-
- inline size_t IMEM_ALIGN (const void* theAddress)
+ // Bounds for checking block size level
+ static constexpr unsigned THE_SMALL_BOUND_BLOCK_SIZE = NCollection_IncAllocator::THE_DEFAULT_BLOCK_SIZE * 16; // 196 KB
+ static constexpr unsigned THE_MEDIUM_BOUND_BLOCK_SIZE = NCollection_IncAllocator::THE_DEFAULT_BLOCK_SIZE * 64; // 786 KB
+ static constexpr unsigned THE_LARGE_BOUND_BLOCK_SIZE = NCollection_IncAllocator::THE_DEFAULT_BLOCK_SIZE * 1024; // 12 MB
+
+ //=======================================================================
+ //function : computeLevel
+ //purpose :
+ //=======================================================================
+ NCollection_IncAllocator::IBlockSizeLevel computeLevel(const unsigned int theSize)
{
- return sizeof(NCollection_IncAllocator::aligned_t) * IMEM_SIZE (size_t(theAddress));
+ if (theSize < NCollection_IncAllocator::THE_DEFAULT_BLOCK_SIZE)
+ {
+ return NCollection_IncAllocator::IBlockSizeLevel::Min;
+ }
+ else if (theSize < THE_SMALL_BOUND_BLOCK_SIZE)
+ {
+ return NCollection_IncAllocator::IBlockSizeLevel::Small;
+ }
+ else if (theSize < THE_MEDIUM_BOUND_BLOCK_SIZE)
+ {
+ return NCollection_IncAllocator::IBlockSizeLevel::Medium;
+ }
+ else if (theSize < THE_LARGE_BOUND_BLOCK_SIZE)
+ {
+ return NCollection_IncAllocator::IBlockSizeLevel::Large;
+ }
+ else
+ {
+ return NCollection_IncAllocator::IBlockSizeLevel::Max;
+ }
}
-
- #define IMEM_FREE(p_bl) (size_t(p_bl->p_end_block - p_bl->p_free_space))
-
-#ifdef OCCT_DEBUG
- // auxiliary dummy function used to get a place where break point can be set
- inline void place_for_breakpoint() {}
-#endif
-}
-
-#define MaxLookup 16
-
-static Standard_Boolean IS_DEBUG = Standard_False;
-
-//=======================================================================
-/**
- * Static data map (address -> AllocatorID)
- */
-//=======================================================================
-static NCollection_DataMap<Standard_Address, Standard_Size>& StorageIDMap()
-{
- static NCollection_DataMap<Standard_Address, Standard_Size> TheMap;
- return TheMap;
-}
-
-//=======================================================================
-/**
- * Static map (AllocatorID)
- */
-//=======================================================================
-static NCollection_Map<Standard_Size>& StorageIDSet()
-{
- static NCollection_Map<Standard_Size> TheMap;
- return TheMap;
-}
-
-//=======================================================================
-//function : IncAllocator_SetDebugFlag
-//purpose : Turn on/off debugging of memory allocation
-//=======================================================================
-
-Standard_EXPORT void IncAllocator_SetDebugFlag(const Standard_Boolean theDebug)
-{
- IS_DEBUG = theDebug;
-}
-
-#ifdef OCCT_DEBUG
-
-//=======================================================================
-/**
- * Static value of the current allocation ID. It provides unique
- * numbering of allocators.
- */
-//=======================================================================
-static Standard_Size CurrentID = 0;
-static Standard_Size CATCH_ID = 0;
-
-//=======================================================================
-//function : Debug_Create
-//purpose : Store the allocator address in the internal maps
-//=======================================================================
-
-static void Debug_Create(Standard_Address theAlloc)
-{
- static Standard_Mutex aMutex;
- aMutex.Lock();
- StorageIDMap().Bind(theAlloc, ++CurrentID);
- StorageIDSet().Add(CurrentID);
- if (CurrentID == CATCH_ID)
- place_for_breakpoint();
- aMutex.Unlock();
}
//=======================================================================
-//function : Debug_Destroy
-//purpose : Forget the allocator address from the internal maps
+//function : NCollection_IncAllocator
+//purpose : Constructor
//=======================================================================
-
-static void Debug_Destroy(Standard_Address theAlloc)
-{
- static Standard_Mutex aMutex;
- aMutex.Lock();
- if (StorageIDMap().IsBound(theAlloc))
- {
- Standard_Size anID = StorageIDMap()(theAlloc);
- StorageIDSet().Remove(anID);
- StorageIDMap().UnBind(theAlloc);
- }
- aMutex.Unlock();
-}
-
-#endif /* OCCT_DEBUG */
+NCollection_IncAllocator::NCollection_IncAllocator(const size_t theDefaultSize) :
+ myBlockSize(static_cast<unsigned>(theDefaultSize < THE_MINIMUM_BLOCK_SIZE ? THE_DEFAULT_BLOCK_SIZE : theDefaultSize))
+{}
//=======================================================================
-//function : IncAllocator_PrintAlive
-//purpose : Outputs the alive numbers to the file inc_alive.d
+//function : SetThreadSafe
+//purpose : Constructor
//=======================================================================
-
-Standard_EXPORT void IncAllocator_PrintAlive()
+void NCollection_IncAllocator::SetThreadSafe (const bool theIsThreadSafe)
{
- if (StorageIDSet().IsEmpty())
+ if(theIsThreadSafe)
{
- return;
- }
-
- std::ofstream aFileOut ("inc_alive.d", std::ios_base::trunc | std::ios_base::out);
- if (!aFileOut.is_open())
- {
- std::cout << "failure writing file inc_alive.d" << std::endl;
- return;
+ if (!myMutex)
+ {
+ myMutex = new Standard_Mutex;
+ }
}
- aFileOut.imbue (std::locale ("C"));
- aFileOut << std::fixed << std::setprecision(1);
-
- aFileOut << "Alive IncAllocators (number, size in Kb)\n";
- Standard_Size aTotSize = 0;
- Standard_Integer nbAlloc = 0;
- for (NCollection_DataMap<Standard_Address, Standard_Size>::Iterator itMap (StorageIDMap());
- itMap.More(); itMap.Next())
+ else
{
- const NCollection_IncAllocator* anAlloc = static_cast<NCollection_IncAllocator*>(itMap.Key());
- Standard_Size anID = itMap.Value();
- Standard_Size aSize = anAlloc->GetMemSize();
- aTotSize += aSize;
- nbAlloc++;
- aFileOut << std::setw(20) << anID << ' '
- << std::setw(20) << (double(aSize) / 1024.0)
- << '\n';
+ delete myMutex;
+ myMutex = nullptr;
}
- aFileOut << "Total:\n"
- << std::setw(20) << nbAlloc << ' '
- << std::setw(20) << (double(aTotSize) / 1024.0)
- << '\n';
- aFileOut.close();
-}
-
-//=======================================================================
-//function : NCollection_IncAllocator()
-//purpose : Constructor
-//=======================================================================
-
-NCollection_IncAllocator::NCollection_IncAllocator (size_t theBlockSize)
-: myMutex (NULL)
-{
-#ifdef ALLOC_TRACK_USAGE
- printf ("\n..NCollection_IncAllocator: Created (%x)\n",this);
-#endif
-#ifdef OCCT_DEBUG
- if (IS_DEBUG)
- Debug_Create(this);
-#endif
- const size_t aDefault = DefaultBlockSize;
- const size_t aSize = IMEM_SIZE(sizeof(IBlock)) +
- IMEM_SIZE((theBlockSize > 2*sizeof(IBlock)) ? theBlockSize : aDefault);
- IBlock * const aBlock = (IBlock *) malloc (aSize * sizeof(aligned_t));
- myFirstBlock = aBlock;
- mySize = aSize - IMEM_SIZE(sizeof(IBlock));
- myMemSize = aSize * sizeof(aligned_t);
- if (aBlock == NULL)
- throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
- aBlock -> p_free_space = (aligned_t *) IMEM_ALIGN (&aBlock[1]);
- aBlock -> p_end_block = ((aligned_t *) aBlock) + aSize;
- aBlock -> p_next = NULL;
}
//=======================================================================
//function : ~NCollection_IncAllocator
//purpose : Destructor
//=======================================================================
-
-NCollection_IncAllocator::~NCollection_IncAllocator ()
+NCollection_IncAllocator::~NCollection_IncAllocator()
{
+ clean();
delete myMutex;
-#ifdef OCCT_DEBUG
- if (IS_DEBUG)
- Debug_Destroy(this);
-#endif
- Clean();
- free (myFirstBlock);
}
//=======================================================================
-//function : SetThreadSafe
-//purpose :
+//function : AllocateOptimal
+//purpose : allocate a memory
//=======================================================================
-void NCollection_IncAllocator::SetThreadSafe (bool theIsThreadSafe)
+void* NCollection_IncAllocator::AllocateOptimal(const size_t theSize)
{
- if (myMutex == NULL
- && theIsThreadSafe)
+ Standard_Mutex::Sentry aLock(myMutex);
+ // Allocating using general block
+ IBlock* aBlock = nullptr;
+ // Use allocated blocks
+ if (myAllocationHeap && myAllocationHeap->AvailableSize >= theSize)
{
- myMutex = new Standard_Mutex();
+ aBlock = myAllocationHeap;
}
- else if (!theIsThreadSafe)
+ else // Allocate new general block
{
- delete myMutex;
- myMutex = NULL;
+ if (++myBlockCount % 5 == 0) // increase count before checking
+ {
+ increaseBlockSize();
+ }
+ if (myBlockSize < theSize)
+ {
+ myBlockSize = static_cast<unsigned>(theSize);
+ }
+ void* aBufferBlock = Standard::AllocateOptimal(myBlockSize + sizeof(IBlock));
+ aBlock = new (aBufferBlock) IBlock(aBufferBlock, myBlockSize);
+ aBlock->NextBlock = myAllocationHeap;
+ aBlock->NextOrderedBlock = myOrderedBlocks;
+ myOrderedBlocks = aBlock;
+ myAllocationHeap = aBlock;
}
+ void* aRes = aBlock->CurPointer;
+ aBlock->CurPointer += theSize;
+ aBlock->AvailableSize -= theSize;
+ if (aBlock->AvailableSize < 16)
+ {
+ myAllocationHeap = aBlock->NextBlock;
+ aBlock->NextBlock = myUsedHeap;
+ myUsedHeap = aBlock;
+ }
+ else
+ {
+ IBlock* aBlockIter = aBlock->NextBlock;
+ IBlock* aBlockToReplaceAfter = nullptr;
+ while (aBlockIter) // Search new sorted position
+ {
+ if (aBlockIter->AvailableSize > aBlock->AvailableSize)
+ {
+ aBlockToReplaceAfter = aBlockIter;
+ aBlockIter = aBlockIter->NextBlock;
+ continue;
+ }
+ break;
+ }
+ if (aBlockToReplaceAfter) // Update list order
+ {
+ IBlock* aNext = aBlockToReplaceAfter->NextBlock;
+ aBlockToReplaceAfter->NextBlock = aBlock;
+ myAllocationHeap = aBlock->NextBlock;
+ aBlock->NextBlock = aNext;
+ }
+ }
+ return aRes;
}
//=======================================================================
//function : Allocate
-//purpose : allocate a memory
-//remark : returns NULL if allocation fails
+//purpose : Allocate a memory
//=======================================================================
-
-void * NCollection_IncAllocator::Allocate (const size_t aSize)
+void* NCollection_IncAllocator::Allocate(const size_t theSize)
{
- aligned_t * aResult = NULL;
- const size_t cSize = aSize ? IMEM_SIZE(aSize) : 0;
-
- Standard_Mutex::Sentry aLock (myMutex);
- if (cSize > mySize) {
- /* If the requested size exceeds normal allocation size, allocate
- a separate block and place it as the head of the list */
- aResult = (aligned_t *) allocateNewBlock (cSize+1);
- if (aResult)
- myFirstBlock -> p_free_space = myFirstBlock -> p_end_block;
- else
- throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
- } else
- if (cSize <= IMEM_FREE(myFirstBlock)) {
- /* If the requested size fits into the free space in the 1st block */
- aResult = myFirstBlock -> allocateInBlock (cSize);
- } else {
- /* Search for a block in the list with enough free space */
- int aMaxLookup = MaxLookup; /* limit the number of blocks to query */
- IBlock * aCurrentBlock = myFirstBlock -> p_next;
- while (aCurrentBlock && aMaxLookup--) {
- if (cSize <= IMEM_FREE(aCurrentBlock)) {
- aResult = aCurrentBlock -> allocateInBlock (cSize);
- break;
- }
- aCurrentBlock = aCurrentBlock -> p_next;
- }
- if (aResult == NULL) {
- /* There is no available block with enough free space. Create a new
- one and place it in the head of the list */
- aResult = (aligned_t *) allocateNewBlock (mySize);
- if (aResult)
- myFirstBlock -> p_free_space = aResult + cSize;
- else
- {
- const size_t aDefault = IMEM_SIZE(DefaultBlockSize);
- if (cSize > aDefault)
- throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
- else
- {
- aResult = (aligned_t *) allocateNewBlock (aDefault);
- if (aResult)
- myFirstBlock -> p_free_space = aResult + cSize;
- else
- throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
- }
- }
- }
- }
- return aResult;
+ return AllocateOptimal(theSize);
}
//=======================================================================
-//function : Reallocate
+//function : clean
//purpose :
//=======================================================================
-
-void * NCollection_IncAllocator::Reallocate (void * theAddress,
- const size_t oldSize,
- const size_t newSize)
+void NCollection_IncAllocator::clean()
{
-// Check that the dummy parameters are OK
- if (theAddress == NULL || oldSize == 0)
- return Allocate (newSize);
-
- const size_t cOldSize = IMEM_SIZE(oldSize);
- const size_t cNewSize = newSize ? IMEM_SIZE(newSize) : 0;
- aligned_t * anAddress = (aligned_t *) theAddress;
-
- Standard_Mutex::Sentry aLock (myMutex);
-// We check only the LAST allocation to do the real extension/contraction
- if (anAddress + cOldSize == myFirstBlock -> p_free_space) {
- myFirstBlock -> p_free_space = anAddress;
-// If the new size fits into the memory block => OK
-// This also includes any case of contraction
- if (cNewSize <= IMEM_FREE(myFirstBlock)) {
- myFirstBlock -> p_free_space += cNewSize;
- return anAddress;
- }
- }
-// In case of contraction of non-terminating allocation, do nothing
- else if (cOldSize >= cNewSize)
- return anAddress;
-// Extension of non-terminated allocation if there is enough room in the
-// current memory block
- if (cNewSize <= IMEM_FREE(myFirstBlock)) {
- aligned_t * aResult = myFirstBlock -> allocateInBlock (cNewSize);
- if (aResult)
- for (unsigned i = 0; i < cOldSize; i++)
- aResult[i] = anAddress[i];
- return aResult;
- }
-
-// This is either of the cases:
-// - extension of non-terminating allocation, or
-// - extension of terminating allocation when the new size is too big
-// In both cases create a new memory block, allocate memory and copy there
-// the reallocated memory.
- size_t cMaxSize = mySize > cNewSize ? mySize : cNewSize;
- aligned_t * aResult = (aligned_t *) allocateNewBlock (cMaxSize);
- if (aResult) {
- myFirstBlock -> p_free_space = aResult + cNewSize;
- for (unsigned i = 0; i < cOldSize; i++)
- aResult[i] = anAddress[i];
- }
- else
+ Standard_Mutex::Sentry aLock(myMutex);
+ IBlock* aHeapIter = myOrderedBlocks;
+ while (aHeapIter)
{
- throw Standard_OutOfMemory("NCollection_IncAllocator: out of memory");
+ IBlock* aCur = aHeapIter;
+ aHeapIter = aHeapIter->NextOrderedBlock;
+ Standard::Free(aCur);
}
- return aResult;
+ myOrderedBlocks = nullptr;
+ myAllocationHeap = nullptr;
+ myUsedHeap = nullptr;
+ myBlockCount = 0;
+ myBlockSize = THE_DEFAULT_BLOCK_SIZE;
}
//=======================================================================
-//function : Free
-//purpose :
-//=======================================================================
-
-void NCollection_IncAllocator::Free (void *)
-{}
-
-//=======================================================================
-//function : Clean
+//function : increaseBlockSize
//purpose :
//=======================================================================
-
-void NCollection_IncAllocator::Clean ()
+void NCollection_IncAllocator::increaseBlockSize()
{
-#ifdef ALLOC_TRACK_USAGE
- printf ("\n..NCollection_IncAllocator: Memory size to clean:%8.1f kB (%x)\n",
- double(GetMemSize())/1024, this);
-#endif
- IBlock * aBlock = myFirstBlock;
- if (aBlock) {
- aBlock -> p_free_space = (aligned_t *) &aBlock[1];
- aBlock = aBlock -> p_next;
- while (aBlock) {
- IBlock * aNext = aBlock -> p_next;
- free (aBlock);
- aBlock = aNext;
- }
- myFirstBlock -> p_next = NULL;
+ switch (computeLevel(myBlockSize))
+ {
+ case NCollection_IncAllocator::IBlockSizeLevel::Min:
+ myBlockSize *= 8;
+ break;
+ case NCollection_IncAllocator::IBlockSizeLevel::Small:
+ myBlockSize *= 4;
+ break;
+ case NCollection_IncAllocator::IBlockSizeLevel::Medium:
+ myBlockSize *= 2;
+ break;
+ case NCollection_IncAllocator::IBlockSizeLevel::Large:
+ myBlockSize = static_cast<unsigned>(std::lround(myBlockSize * 1.5));
+ break;
+ case NCollection_IncAllocator::IBlockSizeLevel::Max:
+ break;
}
- myMemSize = 0;
}
//=======================================================================
-//function : Reset
+//function : resetBlock
//purpose :
//=======================================================================
-
-void NCollection_IncAllocator::Reset (const Standard_Boolean doReleaseMem)
+void NCollection_IncAllocator::resetBlock(IBlock* theBlock) const
{
- Standard_Mutex::Sentry aLock (myMutex);
- if (doReleaseMem)
- Clean();
- else {
- Standard_Integer aBlockCount(0);
- IBlock * aBlock = myFirstBlock;
- while (aBlock)
- if (aBlockCount++ < MaxLookup) {
- aBlock -> p_free_space = (aligned_t *) &aBlock[1];
- if (aBlockCount < MaxLookup)
- aBlock = aBlock -> p_next;
- else {
- IBlock * aNext = aBlock -> p_next;
- aBlock -> p_next = NULL;
- aBlock = aNext;
- }
- } else {
- IBlock * aNext = aBlock -> p_next;
- myMemSize -= (aBlock -> p_end_block - (aligned_t *) aBlock) * sizeof (aligned_t);
- free (aBlock);
- aBlock = aNext;
- }
- }
+ theBlock->AvailableSize = theBlock->AvailableSize + (theBlock->CurPointer - (reinterpret_cast<char*>(theBlock) + sizeof(IBlock)));
+ theBlock->CurPointer = reinterpret_cast<char*>(theBlock) + sizeof(IBlock);
}
//=======================================================================
-//function : GetMemSize
-//purpose : diagnostic utility
+//function : Reset
+//purpose :
//=======================================================================
-
-size_t NCollection_IncAllocator::GetMemSize () const
+void NCollection_IncAllocator::Reset(const Standard_Boolean theReleaseMemory)
{
-// size_t aResult = 0;
-// IBlock * aBlock = myFirstBlock;
-// while (aBlock) {
-// aResult += (aBlock -> p_end_block - (aligned_t *) aBlock);
-// aBlock = aBlock -> p_next;
-// }
-// return aResult * sizeof (aligned_t);
- return myMemSize;
+ if (theReleaseMemory)
+ {
+ clean();
+ return;
+ }
+ Standard_Mutex::Sentry aLock(myMutex);
+ IBlock* aHeapIter = myOrderedBlocks;
+ while (aHeapIter)
+ {
+ IBlock* aCur = aHeapIter;
+ aHeapIter = aHeapIter->NextOrderedBlock;
+ aCur->NextBlock = aHeapIter;
+ resetBlock(aCur); // reset size and pointer
+ }
+ myAllocationHeap = myOrderedBlocks;
+ myUsedHeap = nullptr;
}
//=======================================================================
-//function : allocateNewBlock
+//function : IBlockSmall::IBlockSmall
//purpose :
//=======================================================================
-
-void * NCollection_IncAllocator::allocateNewBlock (const size_t cSize)
-{
- aligned_t * aResult = 0L;
- const size_t aSz = cSize + IMEM_SIZE(sizeof(IBlock));
- IBlock * aBlock = (IBlock *) malloc (aSz * sizeof(aligned_t));
- if (aBlock) {
- aBlock -> p_end_block = ((aligned_t *)aBlock) + aSz;
- aBlock -> p_next = myFirstBlock;
- myFirstBlock = aBlock;
- aResult = (aligned_t *) IMEM_ALIGN(&aBlock[1]);
- myMemSize += aSz * sizeof(aligned_t);
- }
- return aResult;
-}
+NCollection_IncAllocator::IBlock::IBlock(void* thePointer,
+ const size_t theSize) :
+ CurPointer(static_cast<char*>(thePointer) + sizeof(IBlock)),
+ AvailableSize(theSize)
+{}
-// Created on: 2002-04-12
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2002-2014 OPEN CASCADE SAS
+// Copyright (c) 2002-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#ifndef NCollection_IncAllocator_HeaderFile
#define NCollection_IncAllocator_HeaderFile
-
+
#include <NCollection_BaseAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
+#include <NCollection_Allocator.hxx>
+
+#include <utility>
class Standard_Mutex;
*/
class NCollection_IncAllocator : public NCollection_BaseAllocator
{
- public:
- // The type defining the alignement of allocated objects
- typedef void * aligned_t;
-
- // ---------- PUBLIC METHODS ----------
+public:
//! Constructor.
//! Note that this constructor does NOT setup mutex for using allocator concurrently from different threads,
//! platform for the repeated operations (and thus multiple allocations)
//! because Low Fragmentation Heap is not going to be used for these allocations,
//! leading to memory fragmentation and eventual performance slow down.
- Standard_EXPORT NCollection_IncAllocator (size_t theBlockSize = DefaultBlockSize);
+ Standard_EXPORT NCollection_IncAllocator (const size_t theBlockSize = THE_DEFAULT_BLOCK_SIZE);
//! Setup mutex for thread-safe allocations.
- Standard_EXPORT void SetThreadSafe (bool theIsThreadSafe = true);
+ Standard_EXPORT void SetThreadSafe (const bool theIsThreadSafe = true);
//! Allocate memory with given size. Returns NULL on failure
- Standard_EXPORT virtual void* Allocate (const size_t size) Standard_OVERRIDE;
+ Standard_EXPORT void* Allocate(const size_t size) Standard_OVERRIDE;
- //! Free a previously allocated memory. Does nothing
- Standard_EXPORT virtual void Free (void *anAddress) Standard_OVERRIDE;
+ //! Allocate memory with given size. Returns NULL on failure
+ Standard_EXPORT void* AllocateOptimal(const size_t size) Standard_OVERRIDE;
- //! Diagnostic method, returns the total allocated size
- Standard_EXPORT size_t GetMemSize () const;
+ //! Free a previously allocated memory. Does nothing
+ void Free(void*) Standard_OVERRIDE
+ {
+ // Do nothing
+ }
//! Destructor (calls Clean() internally)
- Standard_EXPORT ~NCollection_IncAllocator ();
-
- //! Reallocation: it is always allowed but is only efficient with the
- //! last allocated item
- Standard_EXPORT void * Reallocate (void * anAddress,
- const size_t oldSize,
- const size_t newSize);
+ Standard_EXPORT ~NCollection_IncAllocator();
//! Re-initialize the allocator so that the next Allocate call should
//! start allocating in the very beginning as though the allocator is just
//! constructed. Warning: make sure that all previously allocated data are
//! no more used in your code!
- //! @param doReleaseMem
+ //! @param theReleaseMemory
//! True - release all previously allocated memory, False - preserve it
//! for future allocations.
- Standard_EXPORT void Reset (const Standard_Boolean
- doReleaseMem=Standard_True);
+ Standard_EXPORT void Reset(const bool theReleaseMemory = false);
+
+private:
+ // Prohibited methods
+ NCollection_IncAllocator(const NCollection_IncAllocator&) = delete;
+ NCollection_IncAllocator& operator = (const NCollection_IncAllocator&) = delete;
+
+public:
+
+ //! Forward list to keep multi-time allocated pointers.
+ //! On Reset operation objects will be reused.
+ struct IBlock
+ {
+ IBlock(void* thePointer,
+ const size_t theSize);
+
+ char* CurPointer;
+ size_t AvailableSize;
+ IBlock* NextBlock = nullptr; //! Pointer to next sorted block
+ IBlock* NextOrderedBlock = nullptr; //! Pointer to next ordered block
+ };
+
+ //! Description ability to next growing size each 5-th new block
+ enum class IBlockSizeLevel : unsigned short
+ {
+ Min = 0, // x8 growing
+ Small, // x4 growing
+ Medium, // x2 growing
+ Large, // x1.5 growing
+ Max // no growing
+ };
- //! Default size for the memory blocks - 12KB
- static const size_t DefaultBlockSize = 12300;
+protected:
- protected:
- struct IBlock;
+ //! Increases size according current block size level
+ void increaseBlockSize();
+
+ //! Resets available size and CurPointer field
+ void resetBlock(IBlock* theBlock) const;
//! Flush all previously allocated data. All pointers returned by
//! Allocate() become invalid -- be very careful with this
- Standard_EXPORT void Clean ();
+ void clean();
- //! Allocate a new block and return a pointer to it
- //! ** only for internal usage **
- void * allocateNewBlock (const size_t cSize);
+public:
- private:
- // Prohibited methods
- NCollection_IncAllocator (const NCollection_IncAllocator&);
- NCollection_IncAllocator& operator = (const NCollection_IncAllocator&);
-
- protected:
- // ----- PROTECTED CLASS IBlock -------
- struct IBlock {
- aligned_t * allocateInBlock (const size_t cSize)
- {
- aligned_t * aResult = p_free_space;
- p_free_space += cSize;
- return aResult;
- }
- aligned_t * p_free_space;
- aligned_t * p_end_block;
- struct IBlock * p_next;
- };
- protected:
- // --------- PROTECTED FIELDS ---------
- Standard_Mutex* myMutex;
- IBlock * myFirstBlock;
- size_t mySize;
- size_t myMemSize;
-
- public:
-// Declaration of CASCADE RTTI
- DEFINE_STANDARD_RTTIEXT(NCollection_IncAllocator,NCollection_BaseAllocator)
+ static constexpr size_t THE_DEFAULT_BLOCK_SIZE = 1024 * 12;
+
+ static constexpr size_t THE_MINIMUM_BLOCK_SIZE = 1024 * 2;
+
+private:
+ unsigned int myBlockSize; //!< Block size to incremental allocations
+ unsigned int myBlockCount = 0; //!< Count of created blocks
+ Standard_Mutex* myMutex = nullptr; //!< Thread-safety mutex
+ IBlock* myAllocationHeap = nullptr; //!< Sorted list for allocations
+ IBlock* myUsedHeap = nullptr; //!< Sorted list for store empty blocks
+ IBlock* myOrderedBlocks = nullptr; //!< Ordered list for store growing size blocks
+
+public:
+ // Declaration of CASCADE RTTI
+ DEFINE_STANDARD_RTTIEXT(NCollection_IncAllocator, NCollection_BaseAllocator)
};
// Definition of HANDLE object using Standard_DefineHandle.hxx
-DEFINE_STANDARD_HANDLE (NCollection_IncAllocator, NCollection_BaseAllocator)
+DEFINE_STANDARD_HANDLE(NCollection_IncAllocator, NCollection_BaseAllocator)
#endif
#include <NCollection_DefaultHasher.hxx>
#include <Standard_OutOfRange.hxx>
+#include <utility>
/**
* Purpose: An indexed map is used to store keys and to bind
typedef TheKeyType key_type;
//! STL-compliant typedef for value type
typedef TheItemType value_type;
+ typedef Hasher hasher;
private:
//! Adaptation of the TListNode to the INDEXEDDatamap
: NCollection_TListNode<TheItemType>(theItem,theNext1),
myKey1 (theKey1),
myIndex (theIndex)
- {
- }
+ {}
+ //! Constructor with 'Next'
+ IndexedDataMapNode (TheKeyType&& theKey1,
+ const Standard_Integer theIndex,
+ const TheItemType& theItem,
+ NCollection_ListNode* theNext1)
+ : NCollection_TListNode<TheItemType>(theItem,theNext1),
+ myKey1 (std::forward<TheKeyType>(theKey1)),
+ myIndex (theIndex)
+ {}
+ //! Constructor with 'Next'
+ IndexedDataMapNode (const TheKeyType& theKey1,
+ const Standard_Integer theIndex,
+ TheItemType&& theItem,
+ NCollection_ListNode* theNext1)
+ : NCollection_TListNode<TheItemType>(std::forward<TheItemType>(theItem),theNext1),
+ myKey1 (theKey1),
+ myIndex (theIndex)
+ {}
+ //! Constructor with 'Next'
+ IndexedDataMapNode (TheKeyType&& theKey1,
+ const Standard_Integer theIndex,
+ TheItemType&& theItem,
+ NCollection_ListNode* theNext1)
+ : NCollection_TListNode<TheItemType>(std::forward<TheItemType>(theItem),theNext1),
+ myKey1 (std::forward<TheKeyType>(theKey1)),
+ myIndex (theIndex)
+ {}
//! Key1
TheKeyType& Key1() { return myKey1; }
//! Index
// ---------- PUBLIC METHODS ------------
//! Empty constructor.
- NCollection_IndexedDataMap() : NCollection_BaseMap (1, Standard_False, Handle(NCollection_BaseAllocator)()) {}
+ NCollection_IndexedDataMap() : NCollection_BaseMap (1, true, Handle(NCollection_BaseAllocator)()) {}
//! Constructor
explicit NCollection_IndexedDataMap (const Standard_Integer theNbBuckets,
const Handle(NCollection_BaseAllocator)& theAllocator = 0L)
- : NCollection_BaseMap (theNbBuckets, Standard_False, theAllocator) {}
+ : NCollection_BaseMap (theNbBuckets, true, theAllocator) {}
//! Copy constructor
NCollection_IndexedDataMap (const NCollection_IndexedDataMap& theOther)
- : NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
+ : NCollection_BaseMap (theOther.NbBuckets(), true, theOther.myAllocator)
{ *this = theOther; }
+ //! Move constructor
+ NCollection_IndexedDataMap(NCollection_IndexedDataMap&& theOther) noexcept :
+ NCollection_BaseMap(std::forward<NCollection_BaseMap>(theOther))
+ {}
+
//! Exchange the content of two maps without re-allocations.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_IndexedDataMap& theOther)
{
const TheKeyType& aKey1 = theOther.FindKey (anIndexIter);
const TheItemType& anItem = theOther.FindFromIndex(anIndexIter);
- const Standard_Integer iK1 = Hasher::HashCode (aKey1, NbBuckets());
+ const size_t iK1 = HashCode (aKey1, NbBuckets());
IndexedDataMapNode* pNode = new (this->myAllocator) IndexedDataMapNode (aKey1, anIndexIter, anItem, myData1[iK1]);
myData1[iK1] = pNode;
myData2[anIndexIter - 1] = pNode;
return Assign (theOther);
}
+ //! Move operator
+ NCollection_IndexedDataMap& operator= (NCollection_IndexedDataMap&& theOther) noexcept
+ {
+ if (this == &theOther)
+ return *this;
+ exchangeMapsData(theOther);
+ return *this;
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
{
if (myData1)
{
- memcpy (ppNewData2, myData2, sizeof(IndexedDataMapNode*) * Extent());
for (Standard_Integer aBucketIter = 0; aBucketIter <= NbBuckets(); ++aBucketIter)
{
if (myData1[aBucketIter])
IndexedDataMapNode* p = (IndexedDataMapNode *) myData1[aBucketIter];
while (p)
{
- const Standard_Integer iK1 = Hasher::HashCode (p->Key1(), newBuck);
+ const size_t iK1 = HashCode (p->Key1(), newBuck);
IndexedDataMapNode* q = (IndexedDataMapNode* )p->Next();
p->Next() = ppNewData1[iK1];
ppNewData1[iK1] = p;
}
}
}
- EndResize (N, newBuck, ppNewData1, ppNewData2);
+ EndResize (N, newBuck, ppNewData1, (NCollection_ListNode**)
+ Standard::Reallocate(myData2, (newBuck + 1) * sizeof(NCollection_ListNode*)));
}
}
{
ReSize(Extent());
}
+ IndexedDataMapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey1, aNode, aHash))
+ {
+ return aNode->Index();
+ }
+ const Standard_Integer aNewIndex = Increment();
+ aNode = new (this->myAllocator) IndexedDataMapNode (theKey1, aNewIndex, theItem, myData1[aHash]);
+ myData1[aHash] = aNode;
+ myData2[aNewIndex - 1] = aNode;
+ return aNewIndex;
+ }
- const Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
- IndexedDataMapNode* pNode = (IndexedDataMapNode* )myData1[iK1];
- while (pNode)
+ //! Returns the Index of already bound Key or appends new Key with specified Item value.
+ //! @param theKey1 Key to search (and to bind, if it was not bound already)
+ //! @param theItem Item value to set for newly bound Key; ignored if Key was already bound
+ //! @return index of Key
+ Standard_Integer Add (TheKeyType&& theKey1, const TheItemType& theItem)
+ {
+ if (Resizable())
{
- if (Hasher::IsEqual (pNode->Key1(), theKey1))
- {
- return pNode->Index();
- }
- pNode = (IndexedDataMapNode *) pNode->Next();
+ ReSize(Extent());
}
+ IndexedDataMapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey1, aNode, aHash))
+ {
+ return aNode->Index();
+ }
+ const Standard_Integer aNewIndex = Increment();
+ aNode = new (this->myAllocator) IndexedDataMapNode (std::forward<TheKeyType>(theKey1), aNewIndex, theItem, myData1[aHash]);
+ myData1[aHash] = aNode;
+ myData2[aNewIndex - 1] = aNode;
+ return aNewIndex;
+ }
+ //! Returns the Index of already bound Key or appends new Key with specified Item value.
+ //! @param theKey1 Key to search (and to bind, if it was not bound already)
+ //! @param theItem Item value to set for newly bound Key; ignored if Key was already bound
+ //! @return index of Key
+ Standard_Integer Add (const TheKeyType& theKey1, TheItemType&& theItem)
+ {
+ if (Resizable())
+ {
+ ReSize(Extent());
+ }
+ IndexedDataMapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey1, aNode, aHash))
+ {
+ return aNode->Index();
+ }
const Standard_Integer aNewIndex = Increment();
- pNode = new (this->myAllocator) IndexedDataMapNode (theKey1, aNewIndex, theItem, myData1[iK1]);
- myData1[iK1] = pNode;
- myData2[aNewIndex - 1] = pNode;
+ aNode = new (this->myAllocator) IndexedDataMapNode (theKey1, aNewIndex, std::forward<TheItemType>(theItem), myData1[aHash]);
+ myData1[aHash] = aNode;
+ myData2[aNewIndex - 1] = aNode;
+ return aNewIndex;
+ }
+
+ //! Returns the Index of already bound Key or appends new Key with specified Item value.
+ //! @param theKey1 Key to search (and to bind, if it was not bound already)
+ //! @param theItem Item value to set for newly bound Key; ignored if Key was already bound
+ //! @return index of Key
+ Standard_Integer Add (TheKeyType&& theKey1, TheItemType&& theItem)
+ {
+ if (Resizable())
+ {
+ ReSize(Extent());
+ }
+ IndexedDataMapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey1, aNode, aHash))
+ {
+ return aNode->Index();
+ }
+ const Standard_Integer aNewIndex = Increment();
+ aNode = new (this->myAllocator) IndexedDataMapNode (std::forward<TheKeyType>(theKey1), aNewIndex,
+ std::forward<TheItemType>(theItem), myData1[aHash]);
+ myData1[aHash] = aNode;
+ myData2[aNewIndex - 1] = aNode;
return aNewIndex;
}
//! Contains
Standard_Boolean Contains (const TheKeyType& theKey1) const
{
- if (IsEmpty())
- return Standard_False;
- Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
- IndexedDataMapNode * pNode1;
- pNode1 = (IndexedDataMapNode *) myData1[iK1];
- while (pNode1)
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- if (Hasher::IsEqual(pNode1->Key1(), theKey1))
- return Standard_True;
- pNode1 = (IndexedDataMapNode *) pNode1->Next();
+ return true;
}
- return Standard_False;
+ return false;
}
//! Substitute
"Index is out of range");
// check if theKey1 is not already in the map
- const Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
- IndexedDataMapNode* p = (IndexedDataMapNode *) myData1[iK1];
- while (p)
+ size_t aHash;
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode, aHash))
{
- if (Hasher::IsEqual (p->Key1(), theKey1))
+ if (aNode->Index() != theIndex)
{
- if (p->Index() != theIndex)
- {
- throw Standard_DomainError ("NCollection_IndexedDataMap::Substitute : "
- "Attempt to substitute existing key");
- }
- p->Key1() = theKey1;
- p->ChangeValue() = theItem;
- return;
+ throw Standard_DomainError("NCollection_IndexedDataMap::Substitute : "
+ "Attempt to substitute existing key");
}
- p = (IndexedDataMapNode *) p->Next();
+ aNode->Key1() = theKey1;
+ aNode->ChangeValue() = theItem;
+ return;
}
// Find the node for the index I
- p = (IndexedDataMapNode* )myData2[theIndex - 1];
+ aNode = (IndexedDataMapNode* )myData2[theIndex - 1];
// remove the old key
- const Standard_Integer iK = Hasher::HashCode (p->Key1(), NbBuckets());
+ const size_t iK = HashCode (aNode->Key1(), NbBuckets());
IndexedDataMapNode * q = (IndexedDataMapNode *) myData1[iK];
- if (q == p)
- myData1[iK] = (IndexedDataMapNode *) p->Next();
+ if (q == aNode)
+ myData1[iK] = (IndexedDataMapNode *)aNode->Next();
else
{
- while (q->Next() != p)
+ while (q->Next() != aNode)
q = (IndexedDataMapNode *) q->Next();
- q->Next() = p->Next();
+ q->Next() = aNode->Next();
}
// update the node
- p->Key1() = theKey1;
- p->ChangeValue() = theItem;
- p->Next() = myData1[iK1];
- myData1[iK1] = p;
+ aNode->Key1() = theKey1;
+ aNode->ChangeValue() = theItem;
+ aNode->Next() = myData1[aHash];
+ myData1[aHash] = aNode;
}
//! Swaps two elements with the given indices.
myData2[aLastIndex - 1] = NULL;
// remove the key
- const Standard_Integer iK1 = Hasher::HashCode (p->Key1(), NbBuckets());
+ const size_t iK1 = HashCode (p->Key1(), NbBuckets());
IndexedDataMapNode* q = (IndexedDataMapNode *) myData1[iK1];
if (q == p)
myData1[iK1] = (IndexedDataMapNode *) p->Next();
//! FindIndex
Standard_Integer FindIndex(const TheKeyType& theKey1) const
{
- if (IsEmpty()) return 0;
- IndexedDataMapNode* pNode1 = (IndexedDataMapNode* )myData1[Hasher::HashCode(theKey1,NbBuckets())];
- while (pNode1)
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- if (Hasher::IsEqual (pNode1->Key1(), theKey1))
- {
- return pNode1->Index();
- }
- pNode1 = (IndexedDataMapNode*) pNode1->Next();
+ return aNode->Index();
}
return 0;
}
const TheItemType& FindFromKey(const TheKeyType& theKey1) const
{
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_IndexedDataMap::FindFromKey");
-
- IndexedDataMapNode* pNode1 = (IndexedDataMapNode* )myData1[Hasher::HashCode(theKey1,NbBuckets())];
- while (pNode1)
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- if (Hasher::IsEqual (pNode1->Key1(), theKey1))
- {
- return pNode1->Value();
- }
- pNode1 = (IndexedDataMapNode*) pNode1->Next();
+ return aNode->Value();
}
throw Standard_NoSuchObject("NCollection_IndexedDataMap::FindFromKey");
}
TheItemType& ChangeFromKey (const TheKeyType& theKey1)
{
Standard_NoSuchObject_Raise_if (IsEmpty(), "NCollection_IndexedDataMap::ChangeFromKey");
-
- IndexedDataMapNode* pNode1 = (IndexedDataMapNode* )myData1[Hasher::HashCode(theKey1,NbBuckets())];
- while (pNode1)
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- if (Hasher::IsEqual (pNode1->Key1(), theKey1))
- {
- return pNode1->ChangeValue();
- }
- pNode1 = (IndexedDataMapNode*) pNode1->Next();
+ return aNode->ChangeValue();
}
throw Standard_NoSuchObject("NCollection_IndexedDataMap::ChangeFromKey");
}
const TheItemType* Seek(const TheKeyType& theKey1) const
{
return const_cast< NCollection_IndexedDataMap * >( this )->ChangeSeek(theKey1);
- //NCollection_IndexedDataMap *pMap=(NCollection_IndexedDataMap *)this;
- //return pMap->ChangeSeek(theKey1);
}
//! ChangeSeek returns modifiable pointer to Item by Key. Returns
//! NULL if Key was not found.
TheItemType* ChangeSeek (const TheKeyType& theKey1)
{
- if (!IsEmpty())
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- IndexedDataMapNode* pNode1 = (IndexedDataMapNode* )myData1[Hasher::HashCode(theKey1,NbBuckets())];
- while (pNode1)
- {
- if (Hasher::IsEqual (pNode1->Key1(), theKey1))
- {
- return &pNode1->ChangeValue();
- }
- pNode1 = (IndexedDataMapNode*) pNode1->Next();
- }
+ return &aNode->ChangeValue();
}
- return 0L;
+ return nullptr;
}
//! Find value for key with copying.
Standard_Boolean FindFromKey (const TheKeyType& theKey1,
TheItemType& theValue) const
{
- if (IsEmpty())
- {
- return Standard_False;
- }
- for (IndexedDataMapNode* aNode = (IndexedDataMapNode* )myData1[Hasher::HashCode (theKey1, NbBuckets())];
- aNode != NULL; aNode = (IndexedDataMapNode* )aNode->Next())
+ IndexedDataMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- if (Hasher::IsEqual (aNode->Key1(), theKey1))
- {
theValue = aNode->Value();
return Standard_True;
- }
}
return Standard_False;
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
- void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
+ void Clear(const Standard_Boolean doReleaseMemory = Standard_False)
{ Destroy (IndexedDataMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{
- Clear();
+ Clear(theAllocator != this->myAllocator);
this->myAllocator = ( ! theAllocator.IsNull() ? theAllocator :
NCollection_BaseAllocator::CommonBaseAllocator() );
}
//! Destructor
virtual ~NCollection_IndexedDataMap (void)
- { Clear(); }
+ { Clear(true); }
//! Size
Standard_Integer Size(void) const
{ return Extent(); }
- private:
- // ----------- PRIVATE METHODS -----------
+protected:
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @param[out] theHash computed bounded hash code for current key.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, IndexedDataMapNode*& theNode, size_t& theHash) const
+ {
+ theHash = HashCode(theKey, NbBuckets());
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (IndexedDataMapNode*)myData1[theHash];
+ theNode; theNode = (IndexedDataMapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key1(), theKey))
+ return Standard_True;
+ }
+ return Standard_False; // Not found
+ }
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, IndexedDataMapNode*& theNode) const
+ {
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (IndexedDataMapNode*)myData1[HashCode(theKey, NbBuckets())];
+ theNode; theNode = (IndexedDataMapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key1(), theKey))
+ {
+ return Standard_True;
+ }
+ }
+ return Standard_False; // Not found
+ }
+
+ bool IsEqual(const TheKeyType& theKey1,
+ const TheKeyType& theKey2) const
+ {
+ return myHasher(theKey1, theKey2);
+ }
+
+ size_t HashCode(const TheKeyType& theKey,
+ const int theUpperBound) const
+ {
+ return myHasher(theKey) % theUpperBound + 1;
+ }
+
+protected:
+ Hasher myHasher;
};
#endif
--- /dev/null
+// Copyright (c) 2023 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_IndexedIterator_HeaderFile
+#define NCollection_IndexedIterator_HeaderFile
+
+#include <Standard_Assert.hxx>
+#include <iterator>
+
+//! Helper class that allows to use NCollection iterators as STL iterators.
+//! NCollection iterator can be extended to STL iterator of any category by
+//! adding necessary methods: STL forward iterator requires IsEqual method,
+//! STL bidirectional iterator requires Previous method, and STL random access
+//! iterator requires Offset and Differ methods. See NCollection_Vector as
+//! example of declaring custom STL iterators.
+template<class Category, class BaseIndexedMap, class ItemType, bool IsConstant>
+class NCollection_IndexedIterator
+{
+public:
+
+ // Since C++20 inheritance from std::iterator is deprecated, so define predefined types manually:
+ using iterator_category = Category;
+ using value_type = ItemType;
+ using difference_type = ptrdiff_t;
+ using pointer = typename std::conditional<IsConstant, const ItemType*, ItemType*>::type;
+ using reference = typename std::conditional<IsConstant, const ItemType&, ItemType&>::type;
+
+ //! Default constructor
+ NCollection_IndexedIterator() : myIndex(0), myIndexedMap(nullptr)
+ {}
+
+ //! Constructor from NCollection_Indexed*Map
+ NCollection_IndexedIterator(const BaseIndexedMap& theMap) :
+ myIndex(0), myIndexedMap((&const_cast<BaseIndexedMap&>(theMap)))
+ {}
+
+ //! Constructor from NCollection_Indexed*Map
+ NCollection_IndexedIterator(const size_t theIndex, const BaseIndexedMap& theMap) :
+ myIndex(theIndex), myIndexedMap(&const_cast<BaseIndexedMap&>(theMap))
+ {}
+
+ //! Cast from non-const variant to const one
+ NCollection_IndexedIterator(const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, false>& theOther) :
+ myIndex(theOther.myIndex), myIndexedMap(theOther.myIndexedMap)
+ {}
+
+ //! Assignment of non-const iterator to const one
+ NCollection_IndexedIterator& operator= (const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, false>& theOther)
+ {
+ myIndex = theOther.myIndex;
+ myIndexedMap = theOther.myIndexedMap;
+ return *this;
+ }
+
+protected: //! @name methods related to forward STL iterator
+
+ // Note: Here we use SFINAE (Substitution failure is not an error) to choose
+ // an appropriate method based on template arguments (at instantiation time).
+
+ template<bool Condition>
+ typename std::enable_if<!Condition, ItemType&>::type Reference() const
+ {
+ return myIndexedMap->at(myIndex);
+ }
+
+ template<bool Condition>
+ typename std::enable_if<Condition, const ItemType&>::type Reference() const
+ {
+ return myIndexedMap->at(myIndex);
+ }
+
+public: //! @name methods related to forward STL iterator
+
+ //! Test for equality
+ bool operator== (const NCollection_IndexedIterator& theOther) const
+ {
+ return myIndexedMap == theOther.myIndexedMap &&
+ myIndex == theOther.myIndex;
+ }
+
+ template<bool theOtherIsConstant>
+ bool operator== (const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, theOtherIsConstant>& theOther) const
+ {
+ return myIndexedMap == theOther.myIndexedMap &&
+ myIndex == theOther.myIndex;
+ }
+
+ template<bool theOtherIsConstant>
+ bool operator!= (const NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, theOtherIsConstant>& theOther) const
+ {
+ return myIndexedMap != theOther.myIndexedMap ||
+ myIndex != theOther.myIndex;
+ }
+
+ //! Test for inequality
+ bool operator!= (const NCollection_IndexedIterator& theOther) const
+ {
+ return !(*this == theOther);
+ }
+
+ //! Get reference to current item
+ typename NCollection_IndexedIterator::reference operator*() const
+ {
+ return Reference<IsConstant>();
+ }
+
+ //! Dereferencing operator
+ typename NCollection_IndexedIterator::pointer operator->() const
+ {
+ return &Reference<IsConstant>();
+ }
+
+ //! Prefix increment
+ NCollection_IndexedIterator& operator++()
+ {
+ myIndex++;
+ return *this;
+ }
+
+ //! Postfix increment
+ NCollection_IndexedIterator operator++(int)
+ {
+ const NCollection_IndexedIterator theOld(*this);
+ ++(*this);
+ return theOld;
+ }
+
+public: //! @name methods related to bidirectional STL iterator
+
+ //! Prefix decrement
+ NCollection_IndexedIterator& operator--()
+ {
+ Standard_STATIC_ASSERT((opencascade::std::is_same<std::bidirectional_iterator_tag, Category>::value ||
+ opencascade::std::is_same<std::random_access_iterator_tag, Category>::value));
+ myIndex--;
+ return *this;
+ }
+
+ //! Postfix decrement
+ NCollection_IndexedIterator operator--(int)
+ {
+ NCollection_IndexedIterator theOld(*this);
+ --(*this);
+ return theOld;
+ }
+
+public: //! @name methods related to random access STL iterator
+
+ //! Move forward
+ NCollection_IndexedIterator& operator+= (typename NCollection_IndexedIterator::difference_type theOffset)
+ {
+ Standard_STATIC_ASSERT((opencascade::std::is_same<std::random_access_iterator_tag, Category>::value));
+ myIndex += theOffset;
+ return *this;
+ }
+
+ //! Addition
+ NCollection_IndexedIterator operator+ (typename NCollection_IndexedIterator::difference_type theOffset) const
+ {
+ NCollection_IndexedIterator aTemp(*this);
+ return aTemp += theOffset;
+ }
+
+ //! Move backward
+ NCollection_IndexedIterator& operator-= (typename NCollection_IndexedIterator::difference_type theOffset)
+ {
+ return *this += -theOffset;
+ }
+
+ //! Decrease
+ NCollection_IndexedIterator operator- (typename NCollection_IndexedIterator::difference_type theOffset) const
+ {
+ NCollection_IndexedIterator aTemp(*this);
+ return aTemp += -theOffset;
+ }
+
+ //! Difference
+ typename NCollection_IndexedIterator::difference_type operator- (const NCollection_IndexedIterator& theOther) const
+ {
+ Standard_STATIC_ASSERT((opencascade::std::is_same<std::random_access_iterator_tag, Category>::value));
+ return myIndex - theOther.myIndex;
+ }
+
+ //! Get item at offset from current
+ typename NCollection_IndexedIterator::reference operator[] (typename NCollection_IndexedIterator::difference_type theOffset) const
+ {
+ return *(*this + theOffset);
+ }
+
+ //! Comparison
+ bool operator< (const NCollection_IndexedIterator& theOther) const
+ {
+ return (*this - theOther) < 0;
+ }
+
+ //! Comparison
+ bool operator> (const NCollection_IndexedIterator& theOther) const
+ {
+ return theOther < *this;
+ }
+
+ //! Comparison
+ bool operator<= (const NCollection_IndexedIterator& theOther) const
+ {
+ return !(theOther < *this);
+ }
+
+ //! Comparison
+ bool operator>= (const NCollection_IndexedIterator& theOther) const
+ {
+ return !(*this < theOther);
+ }
+
+ friend class NCollection_IndexedIterator<Category, BaseIndexedMap, ItemType, !IsConstant>;
+
+private:
+ //! NCollection iterator
+ size_t myIndex;
+ BaseIndexedMap* myIndexedMap;
+};
+
+#endif // NCollection_IndexedIterator_HeaderFile
NCollection_ListNode* theNext1)
: NCollection_TListNode<TheKeyType> (theKey1, theNext1),
myIndex (theIndex)
- {
- }
+ {}
+ //! Constructor with 'Next'
+ IndexedMapNode (TheKeyType&& theKey1,
+ const Standard_Integer theIndex,
+ NCollection_ListNode* theNext1)
+ : NCollection_TListNode<TheKeyType> (std::forward<TheKeyType>(theKey1), theNext1),
+ myIndex (theIndex)
+ {}
//! Key1
TheKeyType& Key1() { return this->ChangeValue(); }
// ---------- PUBLIC METHODS ------------
//! Empty constructor.
- NCollection_IndexedMap() : NCollection_BaseMap (1, Standard_False, Handle(NCollection_BaseAllocator)()) {}
+ NCollection_IndexedMap() : NCollection_BaseMap (1, true, Handle(NCollection_BaseAllocator)()) {}
//! Constructor
explicit NCollection_IndexedMap (const Standard_Integer theNbBuckets,
const Handle(NCollection_BaseAllocator)& theAllocator=0L)
- : NCollection_BaseMap (theNbBuckets, Standard_False, theAllocator) {}
+ : NCollection_BaseMap (theNbBuckets, true, theAllocator) {}
//! Copy constructor
NCollection_IndexedMap (const NCollection_IndexedMap& theOther)
- : NCollection_BaseMap (theOther.NbBuckets(), Standard_False, theOther.myAllocator)
+ : NCollection_BaseMap (theOther.NbBuckets(), true, theOther.myAllocator)
{ *this = theOther; }
+ //! Move constructor
+ NCollection_IndexedMap(NCollection_IndexedMap&& theOther) noexcept :
+ NCollection_BaseMap(std::forward<NCollection_BaseMap>(theOther))
+ {}
+
//! Exchange the content of two maps without re-allocations.
//! Notice that allocators will be swapped as well!
void Exchange (NCollection_IndexedMap& theOther)
for (Standard_Integer anIndexIter = 1; anIndexIter <= anExt; ++anIndexIter)
{
const TheKeyType& aKey1 = theOther.FindKey (anIndexIter);
- const Standard_Integer iK1 = Hasher::HashCode (aKey1, NbBuckets());
+ const size_t iK1 = HashCode (aKey1, NbBuckets());
IndexedMapNode* pNode = new (this->myAllocator) IndexedMapNode (aKey1, anIndexIter, myData1[iK1]);
myData1[iK1] = pNode;
myData2[anIndexIter - 1] = pNode;
return Assign (theOther);
}
+ //! Move operator
+ NCollection_IndexedMap& operator= (NCollection_IndexedMap&& theOther) noexcept
+ {
+ if (this == &theOther)
+ return *this;
+ exchangeMapsData(theOther);
+ return *this;
+ }
+
//! ReSize
void ReSize (const Standard_Integer theExtent)
{
{
if (myData1)
{
- memcpy (ppNewData2, myData2, sizeof(IndexedMapNode*) * Extent());
for (Standard_Integer aBucketIter = 0; aBucketIter <= NbBuckets(); ++aBucketIter)
{
if (myData1[aBucketIter])
IndexedMapNode* p = (IndexedMapNode* )myData1[aBucketIter];
while (p)
{
- const Standard_Integer iK1 = Hasher::HashCode (p->Key1(), newBuck);
+ const size_t iK1 = HashCode (p->Key1(), newBuck);
IndexedMapNode* q = (IndexedMapNode* )p->Next();
p->Next() = ppNewData1[iK1];
ppNewData1[iK1] = p;
}
}
}
- EndResize (theExtent, newBuck, ppNewData1, ppNewData2);
+ EndResize (theExtent, newBuck, ppNewData1, (NCollection_ListNode**)
+ Standard::Reallocate(myData2, (newBuck + 1) * sizeof(NCollection_ListNode*)));
}
}
{
ReSize (Extent());
}
-
- Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
- IndexedMapNode* pNode = (IndexedMapNode* )myData1[iK1];
- while (pNode)
+ IndexedMapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey1, aNode, aHash))
{
- if (Hasher::IsEqual (pNode->Key1(), theKey1))
- {
- return pNode->Index();
- }
- pNode = (IndexedMapNode *) pNode->Next();
+ return aNode->Index();
}
+ const Standard_Integer aNewIndex = Increment();
+ aNode = new (this->myAllocator) IndexedMapNode (theKey1, aNewIndex, myData1[aHash]);
+ myData1[aHash] = aNode;
+ myData2[aNewIndex - 1] = aNode;
+ return aNewIndex;
+ }
+ //! Add
+ Standard_Integer Add (TheKeyType&& theKey1)
+ {
+ if (Resizable())
+ {
+ ReSize(Extent());
+ }
+ size_t aHash;
+ IndexedMapNode* aNode;
+ if (lookup(theKey1, aNode, aHash))
+ {
+ return aNode->Index();
+ }
const Standard_Integer aNewIndex = Increment();
- pNode = new (this->myAllocator) IndexedMapNode (theKey1, aNewIndex, myData1[iK1]);
- myData1[iK1] = pNode;
- myData2[aNewIndex - 1] = pNode;
+ aNode = new (this->myAllocator) IndexedMapNode(std::forward<TheKeyType>(theKey1),
+ aNewIndex, myData1[aHash]);
+ myData1[aHash] = aNode;
+ myData2[aNewIndex - 1] = aNode;
return aNewIndex;
}
//! Contains
Standard_Boolean Contains (const TheKeyType& theKey1) const
{
- if (IsEmpty())
- return Standard_False;
- Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
- IndexedMapNode * pNode1;
- pNode1 = (IndexedMapNode *) myData1[iK1];
- while (pNode1)
- {
- if (Hasher::IsEqual(pNode1->Key1(), theKey1))
- return Standard_True;
- pNode1 = (IndexedMapNode *) pNode1->Next();
- }
- return Standard_False;
+ IndexedMapNode* p;
+ return lookup(theKey1, p);
}
//! Substitute
"Index is out of range");
// check if theKey1 is not already in the map
- Standard_Integer iK1 = Hasher::HashCode (theKey1, NbBuckets());
- IndexedMapNode* p = (IndexedMapNode *) myData1[iK1];
- while (p)
+ IndexedMapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey1, aNode, aHash))
{
- if (Hasher::IsEqual (p->Key1(), theKey1))
+ if (aNode->Index() != theIndex)
{
- if (p->Index() != theIndex)
- {
- throw Standard_DomainError ("NCollection_IndexedMap::Substitute : "
- "Attempt to substitute existing key");
- }
- p->Key1() = theKey1;
- return;
+ throw Standard_DomainError ("NCollection_IndexedMap::Substitute : "
+ "Attempt to substitute existing key");
}
- p = (IndexedMapNode *) p->Next();
+ aNode->Key1() = theKey1;
+ return;
}
-
// Find the node for the index I
- p = (IndexedMapNode* )myData2[theIndex - 1];
+ aNode = (IndexedMapNode* )myData2[theIndex - 1];
// remove the old key
- Standard_Integer iK = Hasher::HashCode (p->Key1(), NbBuckets());
+ const size_t iK = HashCode (aNode->Key1(), NbBuckets());
IndexedMapNode * q = (IndexedMapNode *) myData1[iK];
- if (q == p)
- myData1[iK] = (IndexedMapNode *) p->Next();
+ if (q == aNode)
+ myData1[iK] = (IndexedMapNode *) aNode->Next();
else
{
- while (q->Next() != p)
+ while (q->Next() != aNode)
q = (IndexedMapNode *) q->Next();
- q->Next() = p->Next();
+ q->Next() = aNode->Next();
}
// update the node
- p->Key1() = theKey1;
- p->Next() = myData1[iK1];
- myData1[iK1] = p;
+ aNode->Key1() = theKey1;
+ aNode->Next() = myData1[aHash];
+ myData1[aHash] = aNode;
}
//! Swaps two elements with the given indices.
myData2[aLastIndex - 1] = NULL;
// remove the key
- Standard_Integer iK1 = Hasher::HashCode (p->Key1(), NbBuckets());
+ const size_t iK1 = HashCode (p->Key1(), NbBuckets());
IndexedMapNode* q = (IndexedMapNode *) myData1[iK1];
if (q == p)
myData1[iK1] = (IndexedMapNode *) p->Next();
//! FindIndex
Standard_Integer FindIndex(const TheKeyType& theKey1) const
{
- if (IsEmpty()) return 0;
- IndexedMapNode* pNode1 = (IndexedMapNode* )myData1[Hasher::HashCode(theKey1,NbBuckets())];
- while (pNode1)
+ IndexedMapNode* aNode;
+ if (lookup(theKey1, aNode))
{
- if (Hasher::IsEqual (pNode1->Key1(), theKey1))
- {
- return pNode1->Index();
- }
- pNode1 = (IndexedMapNode*) pNode1->Next();
+ return aNode->Index();
}
return 0;
}
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
- void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
+ void Clear(const Standard_Boolean doReleaseMemory = Standard_False)
{ Destroy (IndexedMapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{
- Clear();
+ Clear(theAllocator != this->myAllocator);
this->myAllocator = ( ! theAllocator.IsNull() ? theAllocator :
NCollection_BaseAllocator::CommonBaseAllocator() );
}
//! Destructor
virtual ~NCollection_IndexedMap (void)
- { Clear(); }
+ { Clear(true); }
//! Size
Standard_Integer Size(void) const
{ return Extent(); }
+
+protected:
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @param[out] theHash computed bounded hash code for current key.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, IndexedMapNode*& theNode, size_t& theHash) const
+ {
+ theHash = HashCode(theKey, NbBuckets());
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (IndexedMapNode*)myData1[theHash];
+ theNode; theNode = (IndexedMapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key1(), theKey))
+ return Standard_True;
+ }
+ return Standard_False; // Not found
+ }
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, IndexedMapNode*& theNode) const
+ {
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (IndexedMapNode*)myData1[HashCode(theKey, NbBuckets())];
+ theNode; theNode = (IndexedMapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key1(), theKey))
+ {
+ return Standard_True;
+ }
+ }
+ return Standard_False; // Not found
+ }
+
+ bool IsEqual(const TheKeyType& theKey1,
+ const TheKeyType& theKey2) const
+ {
+ return myHasher(theKey1, theKey2);
+ }
+
+ size_t HashCode(const TheKeyType& theKey,
+ const int theUpperBound) const
+ {
+ return myHasher(theKey) % theUpperBound + 1;
+ }
+
+protected:
+
+ Hasher myHasher;
};
#endif
--- /dev/null
+// Copyright (c) 2023 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_Iterator_HeaderFile
+#define NCollection_Iterator_HeaderFile
+
+#include <Standard_Assert.hxx>
+#include <iterator>
+
+//! Helper class that allows to use NCollection iterators as STL iterators.
+//! NCollection iterator can be extended to STL iterator of any category by
+//! adding necessary methods: STL forward iterator requires IsEqual method,
+//! STL bidirectional iterator requires Previous method, and STL random access
+//! iterator requires Offset and Differ methods. See NCollection_Vector as
+//! example of declaring custom STL iterators.
+template<class Container>
+class NCollection_Iterator
+{
+public:
+
+ NCollection_Iterator() : myCur(typename Container::iterator()), myLast(typename Container::iterator()) {}
+
+ NCollection_Iterator(const NCollection_Iterator& theOther) : myCur(theOther.myCur), myLast(theOther.myLast) {}
+
+ NCollection_Iterator(const Container& theList) : myCur(const_cast<Container&>(theList).begin()), myLast(const_cast<Container&>(theList).end()) {}
+
+ NCollection_Iterator(const Container& theList, const typename Container::iterator& theOther)
+ : myCur(theOther), myLast(const_cast<Container&>(theList).end()) {}
+
+ NCollection_Iterator(const Container& theList, typename Container::iterator&& theOther)
+ : myCur(theOther), myLast(const_cast<Container&>(theList).end())
+ {}
+
+ ~NCollection_Iterator() {}
+
+ void Init(Container& theList)
+ {
+ myCur = theList.begin();
+ myLast = theList.end();
+ }
+
+ void Init(const Container& theList)
+ {
+ Init(const_cast<Container&>(theList));
+ }
+
+ virtual bool More() const
+ {
+ return myCur != myLast;
+ }
+
+ void Initialize(Container& theList)
+ {
+ Init(theList);
+ }
+
+ void Initialize(const Container& theList)
+ {
+ Init(theList);
+ }
+
+ const typename Container::iterator& ValueIter() const
+ {
+ return myCur;
+ }
+
+ typename Container::iterator& ChangeValueIter()
+ {
+ return myCur;
+ }
+
+ const typename Container::iterator& EndIter() const
+ {
+ return myLast;
+ }
+
+ typename Container::iterator& ChangeEndIter()
+ {
+ return myLast;
+ }
+
+ virtual void Next()
+ {
+ ++(myCur);
+ }
+
+ bool operator==(const NCollection_Iterator& theOther) { return myLast == theOther.myLast && myCur == theOther.myCur; }
+
+ bool operator!=(const NCollection_Iterator& theOther) { return myLast != theOther.myLast || myCur != theOther.myCur; }
+
+ NCollection_Iterator& operator=(const NCollection_Iterator& theOther)
+ {
+ if (this != &theOther)
+ {
+ myLast = theOther.myLast;
+ myCur = theOther.myCur;
+ }
+ return *this;
+ }
+
+ NCollection_Iterator& operator=(NCollection_Iterator&& theOther)
+ {
+ if (this != &theOther)
+ {
+ myLast = std::move(theOther.myLast);
+ myCur = std::move(theOther.myCur);
+ }
+ return *this;
+ }
+
+private:
+ typename Container::iterator myCur;
+ typename Container::iterator myLast;
+};
+
+
+#endif // NCollection_Iterator_HeaderFile
NCollection_List (const NCollection_List& theOther) :
NCollection_BaseList(theOther.myAllocator)
{
- Assign (theOther);
+ appendList(theOther.PFirst());
+ }
+
+ //! Move constructor
+ NCollection_List(NCollection_List&& theOther) noexcept :
+ NCollection_BaseList(theOther.myAllocator)
+ {
+ this->operator=(std::forward<NCollection_List>(theOther));
}
//! Size - Number of items
return Assign (theOther);
}
+ //! Move operator
+ NCollection_List& operator= (NCollection_List&& theOther) noexcept
+ {
+ if (this == &theOther)
+ {
+ return *this;
+ }
+ Clear(theOther.myAllocator);
+ myFirst = theOther.myFirst;
+ myLast = theOther.myLast;
+ myLength = theOther.myLength;
+ theOther.myFirst = theOther.myLast = nullptr;
+ theOther.myLength = 0;
+ return *this;
+ }
+
//! Clear this list
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator=0L)
{
return ((ListNode *) PLast())->ChangeValue();
}
+ //! Append one item at the end
+ TheItemType& Append (TheItemType&& theItem)
+ {
+ ListNode * pNew = new (this->myAllocator) ListNode(std::forward<TheItemType>(theItem));
+ PAppend(pNew);
+ return ((ListNode *) PLast())->ChangeValue();
+ }
+
//! Append one item at the end and output iterator
//! pointing at the appended item
void Append (const TheItemType& theItem, Iterator& theIter)
PAppend(pNew, theIter);
}
+ //! Append one item at the end and output iterator
+ //! pointing at the appended item
+ void Append (TheItemType&& theItem, Iterator& theIter)
+ {
+ ListNode * pNew = new (this->myAllocator) ListNode(std::forward<TheItemType>(theItem));
+ PAppend(pNew, theIter);
+ }
+
//! Append another list at the end.
//! After this operation, theOther list will be cleared.
void Append (NCollection_List& theOther)
return ((ListNode *) PFirst())->ChangeValue();
}
+ //! Prepend one item at the beginning
+ TheItemType& Prepend (TheItemType&& theItem)
+ {
+ ListNode * pNew = new (this->myAllocator) ListNode(std::forward<TheItemType>(theItem));
+ PPrepend(pNew);
+ return ((ListNode *) PFirst())->ChangeValue();
+ }
+
//! Prepend another list at the beginning
void Prepend (NCollection_List& theOther)
{
return pNew -> ChangeValue();
}
+ //! InsertBefore
+ TheItemType& InsertBefore (TheItemType&& theItem,
+ Iterator& theIter)
+ {
+ ListNode * pNew = new (this->myAllocator) ListNode(std::forward<TheItemType>(theItem));
+ PInsertBefore (pNew, theIter);
+ return pNew -> ChangeValue();
+ }
+
//! InsertBefore
void InsertBefore (NCollection_List& theOther,
Iterator& theIter)
return pNew -> ChangeValue();
}
+ //! InsertAfter
+ TheItemType& InsertAfter (TheItemType&& theItem,
+ Iterator& theIter)
+ {
+ ListNode * pNew = new (this->myAllocator) ListNode(std::forward<TheItemType>(theItem));
+ PInsertAfter (pNew, theIter);
+ return pNew -> ChangeValue();
+ }
+
//! InsertAfter
void InsertAfter (NCollection_List& theOther,
Iterator& theIter)
#include <NCollection_DefaultHasher.hxx>
#include <Standard_NoSuchObject.hxx>
+#include <utility>
/**
* Purpose: Single hashed Map. This Map is used to store and
public:
//! STL-compliant typedef for key type
typedef TheKeyType key_type;
+ typedef Hasher hasher;
public:
//! Adaptation of the TListNode to the map notations
MapNode (const TheKeyType& theKey,
NCollection_ListNode* theNext) :
NCollection_TListNode<TheKeyType> (theKey, theNext) {}
+ //! Constructor with 'Next'
+ MapNode (TheKeyType&& theKey,
+ NCollection_ListNode* theNext) :
+ NCollection_TListNode<TheKeyType> (std::forward<TheKeyType>(theKey), theNext) {}
//! Key
const TheKeyType& Key (void)
{ return this->Value(); }
: NCollection_BaseMap (theNbBuckets, Standard_True, theAllocator) {}
//! Copy constructor
- NCollection_Map (const NCollection_Map& theOther) :
- NCollection_BaseMap (theOther.NbBuckets(), Standard_True, theOther.myAllocator)
- { *this = theOther; }
+ NCollection_Map(const NCollection_Map& theOther) :
+ NCollection_BaseMap(theOther.NbBuckets(), Standard_True, theOther.myAllocator)
+ {
+ const int anExt = theOther.Extent();
+ if (anExt <= 0)
+ return;
+ ReSize(anExt - 1);
+ for (Iterator anIter(theOther); anIter.More(); anIter.Next())
+ Add(anIter.Key());
+ }
+
+ //! Move constructor
+ NCollection_Map (NCollection_Map&& theOther) noexcept :
+ NCollection_BaseMap (std::forward<NCollection_BaseMap>(theOther))
+ {}
//! Exchange the content of two maps without re-allocations.
//! Notice that allocators will be swapped as well!
return Assign(theOther);
}
+ //! Move operator
+ NCollection_Map& operator= (NCollection_Map&& theOther) noexcept
+ {
+ if (this == &theOther)
+ return *this;
+ exchangeMapsData(theOther);
+ return *this;
+ }
+
//! ReSize
void ReSize (const Standard_Integer N)
{
{
MapNode** olddata = (MapNode**) myData1;
MapNode *p, *q;
- Standard_Integer i,k;
- for (i = 0; i <= NbBuckets(); i++)
+ for (int i = 0; i <= NbBuckets(); i++)
{
if (olddata[i])
{
p = olddata[i];
while (p)
{
- k = Hasher::HashCode(p->Key(),newBuck);
+ const size_t k = HashCode(p->Key(),newBuck);
q = (MapNode*) p->Next();
p->Next() = newdata[k];
newdata[k] = p;
}
//! Add
- Standard_Boolean Add(const TheKeyType& K)
+ Standard_Boolean Add(const TheKeyType& theKey)
{
if (Resizable())
ReSize(Extent());
+ MapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey, aNode, aHash))
+ {
+ return Standard_False;
+ }
MapNode** data = (MapNode**)myData1;
- Standard_Integer k = Hasher::HashCode(K,NbBuckets());
- MapNode* p = data[k];
- while (p)
+ data[aHash] = new (this->myAllocator) MapNode(theKey,data[aHash]);
+ Increment();
+ return Standard_True;
+ }
+
+ //! Add
+ Standard_Boolean Add(TheKeyType&& theKey)
+ {
+ if (Resizable())
+ ReSize(Extent());
+ MapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey, aNode, aHash))
{
- if (Hasher::IsEqual(p->Key(),K))
- return Standard_False;
- p = (MapNode *) p->Next();
+ return Standard_False;
}
- data[k] = new (this->myAllocator) MapNode(K,data[k]);
+ MapNode** data = (MapNode**)myData1;
+ data[aHash] = new (this->myAllocator) MapNode(std::forward<TheKeyType>(theKey),data[aHash]);
Increment();
return Standard_True;
}
//! Added: add a new key if not yet in the map, and return
//! reference to either newly added or previously existing object
- const TheKeyType& Added(const TheKeyType& K)
+ const TheKeyType& Added(const TheKeyType& theKey)
{
if (Resizable())
ReSize(Extent());
- MapNode** data = (MapNode**)myData1;
- Standard_Integer k = Hasher::HashCode(K,NbBuckets());
- MapNode* p = data[k];
- while (p)
+ MapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey, aNode, aHash))
{
- if (Hasher::IsEqual(p->Key(),K))
- return p->Key();
- p = (MapNode *) p->Next();
+ return aNode->Key();
}
- data[k] = new (this->myAllocator) MapNode(K,data[k]);
+ MapNode** data = (MapNode**)myData1;
+ data[aHash] = new (this->myAllocator) MapNode(theKey,data[aHash]);
Increment();
- return data[k]->Key();
+ return data[aHash]->Key();
}
- //! Contains
- Standard_Boolean Contains(const TheKeyType& K) const
+ //! Added: add a new key if not yet in the map, and return
+ //! reference to either newly added or previously existing object
+ const TheKeyType& Added(TheKeyType&& theKey)
{
- if (IsEmpty())
- return Standard_False;
- MapNode** data = (MapNode**) myData1;
- MapNode* p = data[Hasher::HashCode(K,NbBuckets())];
- while (p)
+ if (Resizable())
+ ReSize(Extent());
+ MapNode* aNode;
+ size_t aHash;
+ if (lookup(theKey, aNode, aHash))
{
- if (Hasher::IsEqual(p->Key(),K))
- return Standard_True;
- p = (MapNode *) p->Next();
+ return aNode->Key();
}
- return Standard_False;
+ MapNode** data = (MapNode**)myData1;
+ data[aHash] = new (this->myAllocator) MapNode(std::forward<TheKeyType>(theKey),data[aHash]);
+ Increment();
+ return data[aHash]->Key();
+ }
+
+ //! Contains
+ Standard_Boolean Contains(const TheKeyType& theKey) const
+ {
+ MapNode* p;
+ return lookup(theKey, p);
}
//! Remove
if (IsEmpty())
return Standard_False;
MapNode** data = (MapNode**) myData1;
- Standard_Integer k = Hasher::HashCode(K,NbBuckets());
+ const size_t k = HashCode(K,NbBuckets());
MapNode* p = data[k];
MapNode* q = NULL;
while (p)
{
- if (Hasher::IsEqual(p->Key(),K))
+ if (IsEqual(p->Key(),K))
{
Decrement();
if (q)
//! Clear data. If doReleaseMemory is false then the table of
//! buckets is not released and will be reused.
- void Clear(const Standard_Boolean doReleaseMemory = Standard_True)
+ void Clear(const Standard_Boolean doReleaseMemory = Standard_False)
{ Destroy (MapNode::delNode, doReleaseMemory); }
//! Clear data and reset allocator
void Clear (const Handle(NCollection_BaseAllocator)& theAllocator)
{
- Clear();
+ Clear(theAllocator != this->myAllocator);
this->myAllocator = ( ! theAllocator.IsNull() ? theAllocator :
NCollection_BaseAllocator::CommonBaseAllocator() );
}
//! Destructor
virtual ~NCollection_Map (void)
- { Clear(); }
+ { Clear(true); }
//! Size
Standard_Integer Size(void) const
return anOldExtent != Extent();
}
- //!@}
+protected:
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @param[out] theHash computed bounded hash code for current key.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, MapNode*& theNode, size_t& theHash) const
+ {
+ theHash = HashCode(theKey, NbBuckets());
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (MapNode*)myData1[theHash];
+ theNode; theNode = (MapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key(), theKey))
+ return Standard_True;
+ }
+ return Standard_False; // Not found
+ }
+
+ //! Lookup for particular key in map.
+ //! @param[in] theKey key to compute hash
+ //! @param[out] theNode the detected node with equal key. Can be null.
+ //! @return true if key is found
+ Standard_Boolean lookup(const TheKeyType& theKey, MapNode*& theNode) const
+ {
+ if (IsEmpty())
+ return Standard_False; // Not found
+ for (theNode = (MapNode*)myData1[HashCode(theKey, NbBuckets())];
+ theNode; theNode = (MapNode*)theNode->Next())
+ {
+ if (IsEqual(theNode->Key(), theKey))
+ {
+ return Standard_True;
+ }
+ }
+ return Standard_False; // Not found
+ }
+
+ bool IsEqual(const TheKeyType& theKey1,
+ const TheKeyType& theKey2) const
+ {
+ return myHasher(theKey1, theKey2);
+ }
+
+ size_t HashCode(const TheKeyType& theKey,
+ const int theUpperBound) const
+ {
+ return myHasher(theKey) % theUpperBound + 1;
+ }
+protected:
+
+ Hasher myHasher;
};
#endif
--- /dev/null
+// Copyright (c) 2023 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_OccAllocator_HeaderFile
+#define _NCollection_OccAllocator_HeaderFile
+
+#include <NCollection_BaseAllocator.hxx>
+#include <Standard.hxx>
+
+#include <memory>
+
+//! Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.
+/*! The allocator uses a standard OCCT mechanism for memory
+ allocation and deallocation. It can be used with standard
+ containers (std::vector, std::map, etc.) to take advantage of OCCT memory optimizations.
+
+ Example of use:
+ \code
+ NCollection_OccAllocator<TopoDS_Shape> anSAllocator();
+ std::list<TopoDS_Shape, NCollection_OccAllocator<TopoDS_Shape>> aList(anSAllocator);
+ TopoDS_Solid aSolid = BRepPrimAPI_MakeBox(10., 20., 30.);
+ aList.push_back(aSolid);
+ \endcode
+*/
+template <typename ItemType>
+class NCollection_OccAllocator
+{
+public:
+
+ typedef ItemType value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef std::false_type propagate_on_container_move_assignment; // std::false_type
+
+ template <typename OtherType>
+ struct rebind
+ {
+ typedef NCollection_OccAllocator<OtherType> other;
+ };
+
+ //! Constructor.
+ //! Creates an object using the default Open CASCADE allocation mechanism, i.e., which uses
+ //! Standard::Allocate() and Standard::Free() underneath.
+ NCollection_OccAllocator() :
+ myAllocator(nullptr)
+ {}
+
+ //! Constructor.
+ NCollection_OccAllocator(const Handle(NCollection_BaseAllocator)& theAlloc) :
+ myAllocator(theAlloc)
+ {}
+
+ //! Constructor.
+ NCollection_OccAllocator(Handle(NCollection_BaseAllocator)&& theAlloc) :
+ myAllocator(theAlloc)
+ {}
+
+ //! Constructor.
+ NCollection_OccAllocator(const NCollection_OccAllocator& theOther) :
+ myAllocator(theOther.myAllocator)
+ {}
+
+ //! Constructor.
+ NCollection_OccAllocator(NCollection_OccAllocator&& theOther) noexcept :
+ myAllocator(theOther.myAllocator)
+ {}
+
+ //! Assignment operator
+ NCollection_OccAllocator& operator=(const NCollection_OccAllocator& theOther)
+ {
+ myAllocator = theOther.myAllocator;
+ return *this;
+ }
+
+ //! Assignment operator
+ NCollection_OccAllocator& operator=(NCollection_OccAllocator&& theOther) noexcept
+ {
+ myAllocator = theOther.myAllocator;
+ return *this;
+ }
+
+ //! Assignment operator
+ template <typename OtherType>
+ NCollection_OccAllocator& operator=(const NCollection_OccAllocator<OtherType>& theOther)
+ {
+ myAllocator = theOther.myAllocator;
+ return *this;
+ }
+
+ //! Constructor.
+ //! Creates an object using the default Open CASCADE allocation mechanism, i.e., which uses
+ //! Standard::Allocate() and Standard::Free() underneath.
+ template <typename OtherType>
+ NCollection_OccAllocator(const NCollection_OccAllocator<OtherType>& theOther) :
+ myAllocator(theOther.Allocator())
+ {}
+
+ void SetAllocator(const Handle(NCollection_BaseAllocator)& theAlloc)
+ {
+ myAllocator = theAlloc;
+ }
+
+ const Handle(NCollection_BaseAllocator)& Allocator() const
+ {
+ return myAllocator;
+ }
+
+ //! Allocates memory for theSize objects.
+ pointer allocate(size_type theSize, const void* = 0)
+ {
+ return static_cast<pointer> (myAllocator.IsNull() ?
+ Standard::AllocateOptimal(theSize * sizeof(ItemType)) :
+ myAllocator->AllocateOptimal(theSize * sizeof(ItemType)));
+ }
+
+ //! Template version of function Free(), nullifies the argument pointer
+ //! @param thePtr - previously allocated memory block to be freed
+ template <typename T>
+ void deallocate(T* thePnt, size_type)
+ {
+ myAllocator.IsNull() ?
+ Standard::Free(thePnt) :
+ myAllocator->Free(thePnt);
+ }
+
+ //! Frees previously allocated memory.
+ void deallocate(pointer thePnt, size_type)
+ {
+ myAllocator.IsNull() ?
+ Standard::Free(thePnt) :
+ myAllocator->Free(thePnt);
+ }
+
+ //! Constructs an object.
+ //! Uses placement new operator and copy constructor to construct an object.
+ template<class _Objty, class... _Types>
+ void construct(_Objty* _Ptr, _Types&&... _Args)
+ {
+ ::new ((void*)_Ptr) _Objty(std::forward<_Types>(_Args)...);
+ }
+
+ //! Returns an object address.
+ pointer address(reference theItem) const
+ {
+ return &theItem;
+ }
+
+ //! Returns an object address.
+ const_pointer address(const_reference theItem) const
+ {
+ return &theItem;
+ }
+
+ //! Destroys the object.
+ //! Uses the object destructor.
+ template<class _Uty>
+ void destroy(_Uty* _Ptr)
+ {
+ (void)_Ptr; _Ptr->~_Uty();
+ }
+
+ //! Estimate maximum array size
+ size_t max_size() const noexcept
+ {
+ return ((size_t)(-1) / sizeof(ItemType));
+ }
+
+ bool operator==(const NCollection_OccAllocator& theOther) const
+ {
+ return theOther.Allocator() == myAllocator;
+ }
+
+ template<class U>
+ bool operator==(const NCollection_OccAllocator<U>& theOther) const
+ {
+ return theOther.Allocator() == myAllocator;
+ }
+
+ bool operator!=(const NCollection_OccAllocator& theOther) const
+ {
+ return theOther.Allocator() != myAllocator;
+ }
+
+ template<class U>
+ bool operator!=(const NCollection_OccAllocator<U>& theOther) const
+ {
+ return theOther.Allocator() != myAllocator;
+ }
+
+private:
+
+ Handle(NCollection_BaseAllocator) myAllocator;
+};
+
+template<class U, class V>
+bool operator==(const NCollection_OccAllocator<U>& theFirst, const NCollection_OccAllocator<V>& theSecond)
+{
+ return theFirst.Allocator() == theSecond.Allocator();
+}
+
+#endif
#include <Standard_OutOfRange.hxx>
#include <Standard_NoSuchObject.hxx>
+#include <utility>
/**
* Purpose: Definition of a sequence of elements indexed by
Node (const TheItemType& theItem) :
NCollection_SeqNode ()
{ myValue = theItem; }
+ //! Constructor
+ Node (TheItemType&& theItem) :
+ NCollection_SeqNode ()
+ { myValue = std::forward<TheItemType>(theItem); }
//! Constant value access
const TheItemType& Value () const { return myValue; }
//! Variable value access
NCollection_Sequence (const NCollection_Sequence& theOther) :
NCollection_BaseSequence(theOther.myAllocator)
{
- Assign (theOther);
+ appendSeq((const Node*)theOther.myFirstItem);
+ }
+
+ //! Move constructor
+ NCollection_Sequence(NCollection_Sequence&& theOther) noexcept :
+ NCollection_BaseSequence(theOther.myAllocator)
+ {
+ this->operator=(std::forward<NCollection_Sequence>(theOther));
}
//! Number of items
return Assign (theOther);
}
+ //! Move operator
+ NCollection_Sequence& operator= (NCollection_Sequence&& theOther) noexcept
+ {
+ if (this == &theOther)
+ {
+ return *this;
+ }
+ Clear(theOther.myAllocator);
+ myFirstItem = theOther.myFirstItem;
+ myLastItem = theOther.myLastItem;
+ myCurrentItem = theOther.myCurrentItem;
+ myCurrentIndex = theOther.myCurrentIndex;
+ mySize = theOther.mySize;
+
+ theOther.myFirstItem = nullptr;
+ theOther.myLastItem = nullptr;
+ theOther.myCurrentItem = nullptr;
+ theOther.myCurrentIndex = 0;
+ theOther.mySize = 0;
+ return *this;
+ }
+
//! Remove one item
void Remove (Iterator& thePosition)
{ RemoveSeq (thePosition, delNode); }
void Append (const TheItemType& theItem)
{ PAppend (new (this->myAllocator) Node (theItem)); }
+ //! Append one item
+ void Append (TheItemType&& theItem)
+ { PAppend (new (this->myAllocator) Node (std::forward<TheItemType>(theItem))); }
+
//! Append another sequence (making it empty)
void Append (NCollection_Sequence& theSeq)
{
void Prepend (const TheItemType& theItem)
{ PPrepend (new (this->myAllocator) Node (theItem)); }
+ //! Prepend one item
+ void Prepend (TheItemType&& theItem)
+ { PPrepend (new (this->myAllocator) Node (std::forward<TheItemType>(theItem))); }
+
//! Prepend another sequence (making it empty)
void Prepend (NCollection_Sequence& theSeq)
{
const TheItemType& theItem)
{ InsertAfter (theIndex-1, theItem); }
+ //! InsertBefore theIndex theItem
+ void InsertBefore (const Standard_Integer theIndex,
+ TheItemType&& theItem)
+ { InsertAfter (theIndex-1, theItem); }
+
//! InsertBefore theIndex another sequence (making it empty)
void InsertBefore (const Standard_Integer theIndex,
NCollection_Sequence& theSeq)
const TheItemType& theItem)
{ PInsertAfter (thePosition, new (this->myAllocator) Node (theItem)); }
+ //! InsertAfter the position of iterator
+ void InsertAfter (Iterator& thePosition,
+ TheItemType&& theItem)
+ { PInsertAfter (thePosition, new (this->myAllocator) Node (theItem)); }
+
//! InsertAfter theIndex another sequence (making it empty)
void InsertAfter (const Standard_Integer theIndex,
NCollection_Sequence& theSeq)
PInsertAfter (theIndex, new (this->myAllocator) Node (theItem));
}
+ //! InsertAfter theIndex theItem
+ void InsertAfter (const Standard_Integer theIndex,
+ TheItemType&& theItem)
+ {
+ Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > mySize, "NCollection_Sequence::InsertAfter");
+ PInsertAfter (theIndex, new (this->myAllocator) Node (theItem));
+ }
+
//! Split in two sequences
void Split (const Standard_Integer theIndex, NCollection_Sequence& theSeq)
{
typedef unsigned char Cell; //!< type of items used to hold bits
//! Number of bits in each cell
- static Standard_Size BitsPerCell() { return sizeof(Cell) * 8/*BITSPERBYTE*/; }
+ static Standard_Size BitsPerCell() { return sizeof(Cell) * 8; }
public:
+++ /dev/null
-// Author: Roman Lygin, 2012.
-// This file is in the Public Domain and thus can freely be used for any purpose.
-// The author disclaims any rights and liabilities.
-
-#ifndef _NCollection_StdAllocator_HeaderFile
-#define _NCollection_StdAllocator_HeaderFile
-
-#include <NCollection_BaseAllocator.hxx>
-
-#if _MSC_VER
- //Workaround for false "unreferenced parameter" warning in destroy().
- #pragma warning (push)
- #pragma warning (disable: 4100)
-#endif
-
-//! Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.
-/*! The allocator uses instance of the NCollection_BaseAllocator (sub)class for memory
- allocation/deallocation. The allocator can be used with standard
- containers (std::vector, std::map, etc) to take advantage of NCollection_IncAllocator
- which implements memory region concept, and hence to increase performance in specific
- cases.
-
- The underlying NCollection_BaseAllocator instance can be received using the Allocator()
- method.
-
- Example of use:
- \code
- Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator();
- NCollection_StdAllocator<TopoDS_Shape> aSAlloc (anIncAlloc);
- std::list<TopoDS_Shape, NCollection_StdAllocator<TopoDS_Shape> > aL (aSAlloc);
- TopoDS_Solid aSolid = BRepPrimAPI_MakeBox (10., 20., 30.);
- aL.push_back (aSolid);
- \endcode
-*/
-template<typename T>
-class NCollection_StdAllocator {
-public:
- typedef T value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- template<typename U> struct rebind {
- typedef NCollection_StdAllocator<U> other;
- };
-
- //! Constructor.
- /*! Creates an object using default Open CASCADE allocation mechanism, i.e. which uses
- Standard::Allocate() and Standard::Free() underneath.
- */
- NCollection_StdAllocator()
- { myAlloc = NCollection_BaseAllocator::CommonBaseAllocator(); }
-
- //! Constructor.
- /*! Saves \a theAlloc as an underlying allocator instance.*/
- NCollection_StdAllocator( const Handle(NCollection_BaseAllocator)& theAlloc)
- { myAlloc = theAlloc; }
-
- //! Copy constructor.
- /*! Copies Allocator() from \a Y.*/
- template<typename U> NCollection_StdAllocator( const NCollection_StdAllocator<U>& Y)
- { myAlloc = Y.Allocator(); }
-
- //! Assignment operator
- template<typename U> NCollection_StdAllocator& operator= (const NCollection_StdAllocator<U>& Y)
- { myAlloc = Y.Allocator(); return *this; }
-
- //! Returns an object address.
- /*! Returns &x.*/
- pointer address( reference x ) const { return &x; }
-
- //! Returns an object address.
- /*! Returns &x.*/
- const_pointer address( const_reference x ) const { return &x; }
-
- //! Allocates memory for \a n objects.
- /*! Uses underlying allocator to allocate memory.*/
- pointer allocate( size_type n, const void* /*hint*/ = 0 )
- { return pointer( myAlloc->Allocate( n * sizeof( value_type ))); }
-
- //! Frees previously allocated memory.
- /*! Uses underlying allocator to deallocate memory.*/
- void deallocate( pointer p, size_type ) { myAlloc->Free( p ); }
-
- //! Returns the largest value for which method allocate might succeed.
- size_type max_size() const
- {
- size_type aMax = static_cast<size_type>( -1 ) / sizeof( value_type );
- return aMax;
- }
-
- //! Constructs an object.
- /*! Uses placement new operator and copy constructor to construct an object.*/
- void construct( pointer p, const_reference val )
- { new( static_cast<void*>( p )) value_type( val ); }
-
- //! Destroys the object.
- /*! Uses object destructor.*/
- void destroy( pointer p ) { p->~value_type(); }
-
- //! Returns an underlying NCollection_BaseAllocator instance.
- /*! Returns an object specified in the constructor.*/
- const Handle(NCollection_BaseAllocator)& Allocator() const { return myAlloc; }
-
-protected:
- Handle(NCollection_BaseAllocator) myAlloc;
-};
-
-#if _MSC_VER
- #pragma warning (pop)
-#endif
-
-
-//! Implements specialization NCollection_StdAllocator<void>.
-/*! Specialization is of low value and should normally be avoided in favor of a typed specialization.
-
- Example of use:
- \code
- Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator();
- NCollection_StdAllocator<void> aVAlloc (anIncAlloc);
- std::vector<double, NCollection_StdAllocator<double> > aV3 (aVAlloc);
- aV3.push_back (10.);
- \endcode
-*/
-template<>
-class NCollection_StdAllocator<void> {
-public:
- typedef void* pointer;
- typedef const void* const_pointer;
- typedef void value_type;
- template<typename U> struct rebind {
- typedef NCollection_StdAllocator<U> other;
- };
-
- //! Constructor.
- /*! Creates an object using default Open CASCADE allocation mechanism, i.e. which uses
- Standard::Allocate() and Standard::Free() underneath.
- */
- NCollection_StdAllocator()
- { myAlloc = NCollection_BaseAllocator::CommonBaseAllocator(); }
-
- //! Constructor.
- /*! Saves \a theAlloc as an underlying allocator instance.*/
- NCollection_StdAllocator( const Handle(NCollection_BaseAllocator)& theAlloc)
- { myAlloc = theAlloc; }
-
- //! Constructor.
- /*! Copies Allocator() from \a X.*/
- NCollection_StdAllocator( const NCollection_StdAllocator& X) { myAlloc = X.myAlloc; }
-
- //! Returns an underlying NCollection_BaseAllocator instance.
- /*! Returns an object specified in the constructor.*/
- const Handle(NCollection_BaseAllocator)& Allocator() const { return myAlloc; }
-
- //! Assignment operator
- NCollection_StdAllocator& operator=(const NCollection_StdAllocator& X)
- {
- myAlloc = X.myAlloc;
- return *this;
- }
-
-protected:
- Handle(NCollection_BaseAllocator) myAlloc;
-};
-
-template<typename T, typename U>
-inline bool operator==( const NCollection_StdAllocator<T>& X, const NCollection_StdAllocator<U>& Y)
-{ return !!(X.Allocator() == Y.Allocator()); }
-
-template<typename T, typename U>
-inline bool operator!=( const NCollection_StdAllocator<T>& X, const NCollection_StdAllocator<U>& Y)
-{ return !(X == Y); }
-
-
-#endif
#define NCollection_TListNode_HeaderFile
#include <NCollection_ListNode.hxx>
+#include <utility>
/**
* Purpose: Abstract list node class. Used by BaseList
NCollection_TListNode (const TheItemType& theItem,
NCollection_ListNode* theNext=NULL) :
NCollection_ListNode (theNext), myValue(theItem) { }
+ NCollection_TListNode (TheItemType&& theItem,
+ NCollection_ListNode* theNext=NULL) :
+ NCollection_ListNode (theNext), myValue(std::forward<TheItemType>(theItem)) { }
//! Constant value access
const TheItemType& Value () const { return myValue; }
//! Variable value access
//! UBTree algorithm
typedef NCollection_UBTree<TheObjType, TheBndType> UBTree;
- typedef TYPENAME UBTree::TreeNode UBTreeNode;
+ typedef typename UBTree::TreeNode UBTreeNode;
// ---------- PUBLIC METHODS ----------
template <class TheObjType, class TheBndType>
Standard_Real NCollection_UBTreeFiller<TheObjType,TheBndType>::checkNode
- (const TYPENAME NCollection_UBTree<TheObjType, TheBndType>::TreeNode& theNode,
+ (const typename NCollection_UBTree<TheObjType, TheBndType>::TreeNode& theNode,
const Standard_Integer theLength,
Standard_Integer& theNumber)
{
#ifndef NCollection_Vector_HeaderFile
#define NCollection_Vector_HeaderFile
-#include <NCollection_BaseVector.hxx>
-#include <NCollection_StlIterator.hxx>
+#include <NCollection_DynamicArray.hxx>
//! Class NCollection_Vector (dynamic array of objects)
//!
-//! This class is similar to NCollection_Array1 though the indices always start
+//! This class is similar to NCollection_Vector though the indices always start
//! at 0 (in Array1 the first index must be specified)
//!
//! The Vector is always created with 0 length. It can be enlarged by two means:
//! at index 0 and stops at the index equal to (remembered_length-1). It is OK
//! to enlarge the vector during the iteration.
template <class TheItemType>
-class NCollection_Vector : public NCollection_BaseVector
-{
-public:
- //! STL-compliant typedef for value type
- typedef TheItemType value_type;
-
-public:
-
- //! Nested class Iterator
- class Iterator : public NCollection_BaseVector::Iterator
- {
- public:
-
- //! Empty constructor - for later Init
- Iterator() {}
-
- //! Constructor with initialisation
- Iterator (const NCollection_Vector& theVector, Standard_Boolean theToEnd = Standard_False)
- : NCollection_BaseVector::Iterator (theVector, theToEnd) {}
-
- //! Initialisation
- void Init (const NCollection_Vector& theVector)
- {
- initV (theVector);
- }
-
- //! Check end
- Standard_Boolean More() const
- {
- return moreV();
- }
-
- //! Increment operator.
- void Next()
- {
- nextV();
- }
-
- //! Decrement operator.
- void Previous()
- {
- prevV();
- }
-
- //! Offset operator.
- void Offset (ptrdiff_t theOffset)
- {
- offsetV (static_cast<int>(theOffset));
- }
-
- // Workaround for a bug (endless compilation) occurred in MS Visual Studio 2019 / Win32 / Release configuration
- // with DISABLED Whole Program Optimization (as it is by default in OCCT). The problem is
- // at the line std::stable_sort(aPairList.begin(), aPairList.end(), BRepExtrema_CheckPair_Comparator);
- // of BRepExtrema_DistShapeShape.cxx source file.
- // To enable Whole Program Optimization use command line keys: /GL for compiler and /LTCG for linker.
- // Remove this workaround after the bug in VS2019 will be fixed (see OCCT bug #0031628).
-#if defined (_MSC_VER) && (_MSC_VER >= 1920) && !defined (_WIN64) && !defined (_DEBUG)
- __declspec(noinline) __declspec(deprecated("TODO remove this workaround for VS2019 compiler hanging bug"))
-#endif
- //! Difference operator.
- ptrdiff_t Differ (const Iterator& theOther) const
- {
- return differV (theOther);
- }
-
- //! Constant value access
- const TheItemType& Value() const
- {
- return ((const TheItemType* )curBlockV()->DataPtr)[myCurIndex];
- }
-
- //! Variable value access
- TheItemType& ChangeValue() const
- {
- return ((TheItemType* )curBlockV()->DataPtr)[myCurIndex];
- }
-
- //! Performs comparison of two iterators.
- Standard_Boolean IsEqual (const Iterator& theOther) const
- {
- return myVector == theOther.myVector
- && myCurIndex == theOther.myCurIndex
- && myEndIndex == theOther.myEndIndex
- && myICurBlock == theOther.myICurBlock
- && myIEndBlock == theOther.myIEndBlock;
- }
- };
-
- //! Shorthand for a regular iterator type.
- typedef NCollection_StlIterator<std::random_access_iterator_tag, Iterator, TheItemType, false> iterator;
-
- //! Shorthand for a constant iterator type.
- typedef NCollection_StlIterator<std::random_access_iterator_tag, Iterator, TheItemType, true> const_iterator;
-
- //! Returns an iterator pointing to the first element in the vector.
- iterator begin() const { return Iterator (*this, false); }
-
- //! Returns an iterator referring to the past-the-end element in the vector.
- iterator end() const { return Iterator (*this, true); }
-
- //! Returns a const iterator pointing to the first element in the vector.
- const_iterator cbegin() const { return Iterator (*this, false); }
-
- //! Returns a const iterator referring to the past-the-end element in the vector.
- const_iterator cend() const { return Iterator (*this, true); }
-
-public: //! @name public methods
-
- //! Constructor
- explicit NCollection_Vector (const Standard_Integer theIncrement = 256,
- const Handle(NCollection_BaseAllocator)& theAlloc = NULL) :
- NCollection_BaseVector (theAlloc, initMemBlocks, sizeof(TheItemType), theIncrement)
- {}
-
- //! Copy constructor
- NCollection_Vector (const NCollection_Vector& theOther) :
- NCollection_BaseVector (theOther.myAllocator, initMemBlocks, theOther)
- {
- copyData (theOther);
- }
-
- //! Destructor
- virtual ~NCollection_Vector()
- {
- for (Standard_Integer anItemIter = 0; anItemIter < myCapacity; ++anItemIter)
- {
- initMemBlocks (*this, myData[anItemIter], 0, 0);
- }
- this->myAllocator->Free (myData);
- }
-
- //! Total number of items
- Standard_Integer Length() const
- {
- return myLength;
- }
-
- //! Total number of items in the vector
- Standard_Integer Size() const
- {
- return myLength;
- }
-
- //! Method for consistency with other collections.
- //! @return Lower bound (inclusive) for iteration.
- Standard_Integer Lower() const
- {
- return 0;
- }
-
- //! Method for consistency with other collections.
- //! @return Upper bound (inclusive) for iteration.
- Standard_Integer Upper() const
- {
- return myLength - 1;
- }
-
- //! Empty query
- Standard_Boolean IsEmpty() const
- {
- return (myLength == 0);
- }
-
- //! Assignment to the collection of the same type
- inline void Assign (const NCollection_Vector& theOther,
- const Standard_Boolean theOwnAllocator = Standard_True);
-
- //! Assignment operator
- NCollection_Vector& operator= (const NCollection_Vector& theOther)
- {
- Assign (theOther, Standard_False);
- return *this;
- }
-
- //! Append
- TheItemType& Append (const TheItemType& theValue)
- {
- TheItemType& anAppended = *(TheItemType* )expandV (myLength);
- anAppended = theValue;
- return anAppended;
- }
-
- //! Appends an empty value and returns the reference to it
- TheItemType& Appended ()
- {
- TheItemType& anAppended = *(TheItemType* )expandV (myLength);
- return anAppended;
- }
-
- //! Operator() - query the const value
- const TheItemType& operator() (const Standard_Integer theIndex) const
- {
- return Value (theIndex);
- }
-
- //! Operator[] - query the const value
- const TheItemType& operator[] (Standard_Integer theIndex) const { return Value (theIndex); }
-
- const TheItemType& Value (const Standard_Integer theIndex) const
- {
- return *(const TheItemType* )findV (theIndex);
- }
-
- //! @return first element
- const TheItemType& First() const
- {
- return *(const TheItemType* )findV (Lower());
- }
-
- //! @return first element
- TheItemType& ChangeFirst()
- {
- return *(TheItemType* )findV (Lower());
- }
-
- //! @return last element
- const TheItemType& Last() const
- {
- return *(const TheItemType* )findV (Upper());
- }
-
- //! @return last element
- TheItemType& ChangeLast()
- {
- return *(TheItemType* )findV (Upper());
- }
-
- //! Operator() - query the value
- TheItemType& operator() (const Standard_Integer theIndex)
- {
- return ChangeValue (theIndex);
- }
-
- //! Operator[] - query the value
- TheItemType& operator[] ( Standard_Integer theIndex) { return ChangeValue (theIndex); }
-
- TheItemType& ChangeValue (const Standard_Integer theIndex)
- {
- return *(TheItemType* )findV (theIndex);
- }
-
- //! SetValue () - set or append a value
- TheItemType& SetValue (const Standard_Integer theIndex,
- const TheItemType& theValue)
- {
- Standard_OutOfRange_Raise_if (theIndex < 0, "NCollection_Vector::SetValue");
- TheItemType* const aVecValue = (TheItemType* )(theIndex < myLength ? findV (theIndex) : expandV (theIndex));
- *aVecValue = theValue;
- return *aVecValue;
- }
-
-private: //! @name private methods
-
- void copyData (const NCollection_Vector& theOther)
- {
- Standard_Integer iBlock = 0;
- /*NCollection_Vector::*/Iterator anIter (theOther);
- for (Standard_Integer aLength = 0; aLength < myLength; aLength += myIncrement)
- {
- MemBlock& aBlock = myData[iBlock];
- initMemBlocks (*this, aBlock, aLength, myIncrement);
- Standard_Integer anItemIter = 0;
- for (; anItemIter < myIncrement; ++anItemIter)
- {
- if (!anIter.More())
- {
- break;
- }
-
- ((TheItemType* )aBlock.DataPtr)[anItemIter] = anIter.Value();
- anIter.Next();
- }
- aBlock.Length = anItemIter;
- iBlock++;
- }
- }
-
- //! Method to initialize memory block content
- static void initMemBlocks (NCollection_BaseVector& theVector,
- NCollection_BaseVector::MemBlock& theBlock,
- const Standard_Integer theFirst,
- const Standard_Integer theSize)
- {
- NCollection_Vector& aSelf = static_cast<NCollection_Vector&> (theVector);
- Handle(NCollection_BaseAllocator)& anAllocator = aSelf.myAllocator;
-
- // release current content
- if (theBlock.DataPtr != NULL)
- {
- for (Standard_Integer anItemIter = 0; anItemIter < theBlock.Size; ++anItemIter)
- {
- ((TheItemType* )theBlock.DataPtr)[anItemIter].~TheItemType();
- }
- anAllocator->Free (theBlock.DataPtr);
- theBlock.DataPtr = NULL;
- }
-
- // allocate new content if requested
- if (theSize > 0)
- {
- theBlock.DataPtr = anAllocator->Allocate (theSize * sizeof(TheItemType));
- for (Standard_Integer anItemIter = 0; anItemIter < theSize; ++anItemIter)
- {
- new (&((TheItemType* )theBlock.DataPtr)[anItemIter]) TheItemType;
- }
- }
- theBlock.FirstIndex = theFirst;
- theBlock.Size = theSize;
- theBlock.Length = 0;
- }
-
- friend class Iterator;
-
-};
-
-//! Assignment to the collection of the same type
-template <class TheItemType> inline
-void NCollection_Vector<TheItemType>::Assign (const NCollection_Vector& theOther,
- const Standard_Boolean theOwnAllocator)
-{
- if (this == &theOther)
- {
- return;
- }
-
- // destroy current data using current allocator
- for (Standard_Integer anItemIter = 0; anItemIter < myCapacity; ++anItemIter)
- {
- initMemBlocks (*this, myData[anItemIter], 0, 0);
- }
- this->myAllocator->Free (myData);
-
- // allocate memory blocks with new allocator
- if (!theOwnAllocator)
- {
- this->myAllocator = theOther.myAllocator;
- }
- myIncrement = theOther.myIncrement;
- myLength = theOther.myLength;
- myNBlocks = (myLength == 0) ? 0 : (1 + (myLength - 1)/myIncrement);
- myCapacity = GetCapacity (myIncrement) + myLength / myIncrement;
- myData = allocMemBlocks (myCapacity);
-
- // copy data
- copyData (theOther);
-}
+using NCollection_Vector = NCollection_DynamicArray<TheItemType>;
#endif // NCollection_Vector_HeaderFile
//! Allocate memory
Standard_EXPORT virtual void* Allocate (const Standard_Size theSize) Standard_OVERRIDE;
+ //! Allocate memory
+ void* AllocateOptimal(const Standard_Size theSize) Standard_OVERRIDE { return Allocate(theSize); }
+
//! Release memory
Standard_EXPORT virtual void Free (void* theAddress) Standard_OVERRIDE;
#include <OSD.hxx>
+#include <Standard_CString.hxx>
+
//=======================================================================
//function : RealToCString
//purpose :
#include <OSD_StreamBuffer.hxx>
#include <TCollection_AsciiString.hxx>
+#include <NCollection_DefineAlloc.hxx>
//! Base interface for a file stream provider.
//! It is intended to be implemented for specific file protocol.
#ifndef OSD_MemInfo_HeaderFile
#define OSD_MemInfo_HeaderFile
-#include <NCollection_Map.hxx>
#include <TCollection_AsciiString.hxx>
//! This class provide information about memory utilized by current process.
#include <OSD_SharedLibrary.hxx>
#include <stdio.h>
+#include <cstring>
+
#ifdef __some_crappy_system__
/*
* Values for 'mode' argument in dlopen().
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
-#include <Standard_Address.hxx>
#include <Standard_PCharacter.hxx>
#include <OSD_LoadMode.hxx>
#include <OSD_Function.hxx>
#ifndef OSD_ThreadFunction_HeaderFile
#define OSD_ThreadFunction_HeaderFile
-#include <Standard_Address.hxx>
//! Typedef for prototype of function to be used as main function of a thread.
//!
class OpenGl_LayerStack
{
public:
+ typedef NCollection_Array1<const Graphic3d_Layer*>::const_iterator const_iterator;
typedef NCollection_Array1<const Graphic3d_Layer*>::iterator iterator;
//! Reallocate internal buffer of the stack.
else
{
NCollection_Array1<const Graphic3d_Layer*> aDummy;
- myStackSpace.Move (aDummy);
+ myStackSpace.Move (std::move(aDummy));
myBackPtr = iterator();
}
}
void Push (const OpenGl_Layer* theLayer) { (*myBackPtr++) = theLayer; }
//! Returns iterator to the origin of the stack.
- iterator Origin() const { return myStackSpace.IsEmpty() ? iterator() : myStackSpace.begin(); }
+ const_iterator Origin() const { return myStackSpace.IsEmpty() ? const_iterator() : myStackSpace.begin(); }
//! Returns iterator to the back of the stack (after last item added).
iterator Back() const { return myBackPtr; }
+ //! Returns iterator to the origin of the stack.
+ iterator Origin() { return myStackSpace.IsEmpty() ? iterator() : myStackSpace.begin(); }
+
//! Returns true if nothing has been pushed into the stack.
Standard_Boolean IsEmpty() const { return Back() == Origin(); }
BVH_Geometry<Standard_ShortReal, 3>::BVH_Geometry::Clear();
std::vector<OpenGl_RaytraceLight,
- NCollection_StdAllocator<OpenGl_RaytraceLight> > anEmptySources;
+ NCollection_OccAllocator<OpenGl_RaytraceLight> > anEmptySources;
Sources.swap (anEmptySources);
std::vector<OpenGl_RaytraceMaterial,
- NCollection_StdAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
+ NCollection_OccAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
Materials.swap (anEmptyMaterials);
}
#include <BVH_Geometry.hxx>
#include <BVH_Triangulation.hxx>
#include <BVH_BinnedBuilder.hxx>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_Sampler.hxx>
//! Array of properties of light sources.
std::vector<OpenGl_RaytraceLight,
- NCollection_StdAllocator<OpenGl_RaytraceLight> > Sources;
+ NCollection_OccAllocator<OpenGl_RaytraceLight> > Sources;
//! Array of 'front' material properties.
std::vector<OpenGl_RaytraceMaterial,
- NCollection_StdAllocator<OpenGl_RaytraceMaterial> > Materials;
+ NCollection_OccAllocator<OpenGl_RaytraceMaterial> > Materials;
//! Global ambient from all light sources.
BVH_Vec4f Ambient;
void ClearMaterials()
{
std::vector<OpenGl_RaytraceMaterial,
- NCollection_StdAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
+ NCollection_OccAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
Materials.swap (anEmptyMaterials);
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
#include <NCollection_List.hxx>
class PCDM_ReaderFilter;
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
#include <Plate_SequenceOfPinpointConstraint.hxx>
#include <Plate_SequenceOfLinearXYZConstraint.hxx>
#include <Plate_SequenceOfLinearScalarConstraint.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,OSD_Function,TCollection_AsciiString> Plugin_MapOfFunctions;
-typedef NCollection_DataMap<TCollection_AsciiString,OSD_Function,TCollection_AsciiString>::Iterator Plugin_DataMapIteratorOfMapOfFunctions;
+typedef NCollection_DataMap<TCollection_AsciiString,OSD_Function> Plugin_MapOfFunctions;
+typedef NCollection_DataMap<TCollection_AsciiString,OSD_Function>::Iterator Plugin_DataMapIteratorOfMapOfFunctions;
#endif
{
Standard_Integer aIndexS = myStartIndices.Top();
- aTempAlloc->Reset();
+ aTempAlloc->Reset(false);
NCollection_IndexedMap<Standard_Integer> aContour (100, aTempAlloc);
Standard_Integer aStartNumber = findContour (aIndexS, aContour, aTempAlloc, aTempAlloc1);
#ifdef OCCT_DEBUG
// collect the list of links from this node able to participate
// in this contour
- theTempAlloc1->Reset();
+ theTempAlloc1->Reset(false);
NCollection_List<Standard_Integer> aLstIndS (theTempAlloc1);
const ListOfLink& aLinks = myHelper->GetAdjacentLinks (aLastNode);
Poly_MakeLoops::ListOfLink::Iterator itLinks (aLinks);
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_List.hxx>
+#include <NCollection_OccAllocator.hxx>
+#include <Standard_HashUtils.hxx>
/**
{
return node1 == 0 || node2 == 0;
}
+
+ bool operator==(const Link& theOther) const
+ {
+ return (theOther.node1 == node1 && theOther.node2 == node2) ||
+ (theOther.node1 == node2 && theOther.node2 == node1);
+ }
+ };
+
+ struct Hasher
+ {
+ size_t operator()(const Poly_MakeLoops::Link& theLink) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ int aCombination[2]{ theLink.node1, theLink.node2 };
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+
+ bool operator()(const Poly_MakeLoops::Link& theLink1, const Poly_MakeLoops::Link& theLink2) const noexcept
+ {
+ return theLink1 == theLink2;
+ }
};
// Define the Loop as a list of links
// FIELDS
const Helper* myHelper;
- Handle(NCollection_BaseAllocator) myAlloc;
- NCollection_IndexedMap<Link> myMapLink;
+ Handle(NCollection_BaseAllocator) myAlloc;
+ NCollection_IndexedMap<Link, Hasher> myMapLink;
NCollection_Sequence<Loop> myLoops;
HeapOfInteger myStartIndices;
TColStd_PackedMapOfInteger myHangIndices;
};
-//! Computes a hash code for the given link, in the range [1, theUpperBound]
-//! @param theLink the link 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]
-inline Standard_Integer HashCode (const Poly_MakeLoops::Link& theLink, const Standard_Integer theUpperBound)
-{
- return HashCode (theLink.node1 + theLink.node2, theUpperBound);
-}
-
-/**
- * IsEqual method is needed for maps
- */
-inline Standard_Boolean IsEqual(const Poly_MakeLoops::Link& theKey1,
- const Poly_MakeLoops::Link& theKey2)
-{
- return ((theKey1.node1 == theKey2.node1 && theKey1.node2 == theKey2.node2) ||
- (theKey1.node1 == theKey2.node2 && theKey1.node2 == theKey2.node1));
-}
-
/**
* Implementation for 3D space
*/
Standard_Boolean myRightWay;
};
+
+namespace std
+{
+ template <>
+ struct hash<Poly_MakeLoops::Link>
+ {
+ size_t operator()(const Poly_MakeLoops::Link& theLink) const noexcept
+ {
+ return Poly_MakeLoops::Hasher{}(theLink);
+ }
+ };
+
+ template<>
+ struct equal_to<Poly_MakeLoops::Link>
+ {
+ bool operator()(const Poly_MakeLoops::Link& theLink1,
+ const Poly_MakeLoops::Link& theLink2) const noexcept
+ {
+ return theLink1 == theLink2;
+ }
+ };
+}
+
#endif
#include <Poly_MergeNodesTool.hxx>
#include <NCollection_IncAllocator.hxx>
+#include <Standard_CStringHasher.hxx>
#include <algorithm>
// function : MergedNodesMap::hashCode
// purpose :
// =======================================================================
-inline int Poly_MergeNodesTool::MergedNodesMap::vec3iHashCode (const Poly_MergeNodesTool::MergedNodesMap::CellVec3i& theVec,
- const int theUpper)
+inline size_t Poly_MergeNodesTool::MergedNodesMap::vec3iHashCode (const Poly_MergeNodesTool::MergedNodesMap::CellVec3i& theVec,
+ const int theUpper)
{
// copied from NCollection_CellFilter
- const uint64_t aShiftBits = (BITS(int64_t)-1) / 3;
+ constexpr uint64_t aShiftBits = (CHAR_BIT * sizeof(int64_t)-1) / 3;
uint64_t aHashCode = 0;
aHashCode = (aHashCode << aShiftBits) ^ theVec[0];
aHashCode = (aHashCode << aShiftBits) ^ theVec[1];
aHashCode = (aHashCode << aShiftBits) ^ theVec[2];
- return IntegerHashCode(aHashCode, 0x7fffffffffffffff, theUpper);
+ return aHashCode % theUpper + 1;
}
// =======================================================================
// function : MergedNodesMap::hashCode
// purpose :
// =======================================================================
-inline int Poly_MergeNodesTool::MergedNodesMap::hashCode (const NCollection_Vec3<float>& thePos,
- const NCollection_Vec3<float>& theNorm,
- const int theUpper) const
+inline size_t Poly_MergeNodesTool::MergedNodesMap::hashCode (const NCollection_Vec3<float>& thePos,
+ const NCollection_Vec3<float>& theNorm,
+ const int theUpper) const
{
(void )theNorm;
if (myInvTol <= 0.0f)
{
- return ::HashCode (::HashCodes ((Standard_CString )&thePos, sizeof(NCollection_Vec3<float>)), theUpper);
+ // compute DJB2 hash of a string
+ const size_t aLength = sizeof(NCollection_Vec3<float>);
+ unsigned int aHashCode = 0;
+ const Standard_Character* c = (Standard_CString )&thePos;
+ for (size_t i = 0; i < aLength; ++i, ++c)
+ {
+ aHashCode = ((aHashCode << 5) + aHashCode) ^ (*c);
+ }
+ return aHashCode % theUpper + 1;
}
const CellVec3i anIndex = vec3ToCell (thePos);
}
DataMapNode** aData = (DataMapNode** )myData1;
- const int aHash = hashCode (thePos, theNorm, NbBuckets());
+ const size_t aHash = hashCode (thePos, theNorm, NbBuckets());
for (DataMapNode* aNodeIter = aData[aHash]; aNodeIter != NULL;
aNodeIter = (DataMapNode* )aNodeIter->Next())
{
for (int aNeigIter = 0; aNeigIter < 26; ++aNeigIter)
{
const CellVec3i anIndex = anIndexCnt + THE_NEIGHBRS[aNeigIter];
- const int aHashEx = vec3iHashCode (anIndex, NbBuckets());
+ const size_t aHashEx = vec3iHashCode (anIndex, NbBuckets());
for (DataMapNode* aNodeIter = aData[aHashEx]; aNodeIter != NULL;
aNodeIter = (DataMapNode* )aNodeIter->Next())
{
{
for (DataMapNode* anOldNodeIter = anOldData[anOldBuckIter]; anOldNodeIter != NULL; )
{
- const Standard_Integer aNewHash = hashCode (anOldNodeIter->Key(), aNbNewBuck);
+ const size_t aNewHash = hashCode (anOldNodeIter->Key(), aNbNewBuck);
DataMapNode* aNextNode = (DataMapNode* )anOldNodeIter->Next();
anOldNodeIter->Next() = aNewData[aNewHash];
aNewData[aNewHash] = anOldNodeIter;
#include <NCollection_Map.hxx>
#include <Poly_Triangulation.hxx>
+#include <Standard_HashUtils.hxx>
//! Auxiliary tool for merging triangulation nodes for visualization purposes.
//! Tool tries to merge all nodes within input triangulation, but split the ones on sharp corners at specified angle.
}
//! Hash code for integer vec3.
- Standard_EXPORT static int vec3iHashCode (const Poly_MergeNodesTool::MergedNodesMap::CellVec3i& theVec,
- const int theUpper);
+ Standard_EXPORT static size_t vec3iHashCode (const Poly_MergeNodesTool::MergedNodesMap::CellVec3i& theVec,
+ const int theUpper);
//! Compute hash code.
- Standard_EXPORT int hashCode (const NCollection_Vec3<float>& thePos,
- const NCollection_Vec3<float>& theNorm,
- const int theUpper) const;
+ Standard_EXPORT size_t hashCode (const NCollection_Vec3<float>& thePos,
+ const NCollection_Vec3<float>& theNorm,
+ const int theUpper) const;
//! Compute hash code.
- int hashCode (const Vec3AndNormal& theKey, const int theUpper) const
+ size_t hashCode (const Vec3AndNormal& theKey, const int theUpper) const
{
return hashCode (theKey.Pos, theKey.Norm, theUpper);
}
//! Hasher for merging equal elements (with pre-sorted indexes).
struct MergedElemHasher
{
- static int HashCode (const NCollection_Vec4<int>& theVec, const int theUpper)
+ size_t operator()(const NCollection_Vec4<int>& theVec) const
{
- unsigned int aHashCode = 0;
- aHashCode = aHashCode ^ ::HashCode (theVec[0], theUpper);
- aHashCode = aHashCode ^ ::HashCode (theVec[1], theUpper);
- aHashCode = aHashCode ^ ::HashCode (theVec[2], theUpper);
- aHashCode = aHashCode ^ ::HashCode (theVec[3], theUpper);
- return ((aHashCode & 0x7fffffff) % theUpper) + 1;
+ return opencascade::hashBytes(&theVec[0], 4 * sizeof(int));
}
- static bool IsEqual (const NCollection_Vec4<int>& theKey1, const NCollection_Vec4<int>& theKey2)
+ bool operator()(const NCollection_Vec4<int>& theKey1, const NCollection_Vec4<int>& theKey2) const
{
return theKey1.IsEqual (theKey2);
}
}
#include <math_Matrix.hxx>
+#include <math_Vector.hxx>
static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if(argc != 9){
}
#include <DDF.hxx>
#include <TDataStd_Real.hxx>
-#include <NCollection_BaseMap.hxx>
static Standard_Integer OCC1919_real (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if (argc == 4) {
Standard_Boolean IsSameGuid (const Standard_GUID& aGuidNull, const Standard_GUID& aGuid2)
{
Standard_Boolean isSame (Standard_False);
- if(Standard_GUID::IsEqual(aGuidNull, aGuid2)) {
+ if(aGuidNull == aGuid2) {
aGuid2.ShallowDump(std::cout);
isSame = Standard_True;
} else {
#include <Standard_CString.hxx>
#include <TopTools_ListOfShape.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
#include <Draw_Interpretor.hxx>
class TopoDS_Shape;
class TDF_Data;
#include <QANCollection.hxx>
#include <Draw_Interpretor.hxx>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
#include <NCollection_IncAllocator.hxx>
#include <Standard_Assert.hxx>
//type definitions
typedef Handle(Standard_Transient) elem_type;
- typedef NCollection_StdAllocator<elem_type> allocator_type;
+ typedef NCollection_OccAllocator<elem_type> allocator_type;
Standard_STATIC_ASSERT (sizeof (allocator_type::value_type) == sizeof (elem_type));
Standard_STATIC_ASSERT (sizeof (allocator_type::pointer) == sizeof (void*));
Standard_STATIC_ASSERT (sizeof (allocator_type::const_pointer) == sizeof (void*));
{
//typed allocator
- NCollection_StdAllocator<int> aSAlloc (anIncAlloc);
- std::list<int, NCollection_StdAllocator<int> > aL (aSAlloc);
+ NCollection_OccAllocator<int> aSAlloc (anIncAlloc);
+ std::list<int, NCollection_OccAllocator<int> > aL (aSAlloc);
aL.push_back (2);
if ( aL.size() == size_t (1) ) {
di << "Test1 : OK\n";
}
//type cast
- NCollection_StdAllocator<char> aCAlloc;
- std::vector<int, NCollection_StdAllocator<int> > aV (aCAlloc);
+ NCollection_OccAllocator<char> aCAlloc;
+ std::vector<int, NCollection_OccAllocator<int> > aV (aCAlloc);
aV.push_back (1);
if ( aV.size() == size_t (1) ) {
di << "Test2 : OK\n";
}
//using void-specialization allocator
- NCollection_StdAllocator<void> aVAlloc;
- std::vector<int, NCollection_StdAllocator<int> > aV2 (aVAlloc);
+ NCollection_OccAllocator<void*> aVAlloc;
+ std::vector<int, NCollection_OccAllocator<int> > aV2 (aVAlloc);
aV2.resize (10);
aV2.push_back (-1);
} else {
di << "Test4 : Error\n";
}
- NCollection_StdAllocator<int> anIAlloc (anIncAlloc);
+ NCollection_OccAllocator<int> anIAlloc (anIncAlloc);
if ( aSAlloc == anIAlloc ) {
di << "Test5 : OK\n";
} else {
#define QANCollection_DataMapOfRealPnt_HeaderFile
#include <gp_Pnt.hxx>
-#include <TColStd_MapRealHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Real,gp_Pnt,TColStd_MapRealHasher> QANCollection_DataMapOfRealPnt;
-typedef NCollection_DataMap<Standard_Real,gp_Pnt,TColStd_MapRealHasher>::Iterator QANCollection_DataMapIteratorOfDataMapOfRealPnt;
+typedef NCollection_DataMap<Standard_Real,gp_Pnt> QANCollection_DataMapOfRealPnt;
+typedef NCollection_DataMap<Standard_Real,gp_Pnt>::Iterator QANCollection_DataMapIteratorOfDataMapOfRealPnt;
#endif
#define QANCollection_DoubleMapOfRealInteger_HeaderFile
#include <Standard_Integer.hxx>
-#include <TColStd_MapRealHasher.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<Standard_Real,Standard_Integer,TColStd_MapRealHasher,TColStd_MapIntegerHasher> QANCollection_DoubleMapOfRealInteger;
-typedef NCollection_DoubleMap<Standard_Real,Standard_Integer,TColStd_MapRealHasher,TColStd_MapIntegerHasher>::Iterator QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger;
+typedef NCollection_DoubleMap<Standard_Real,Standard_Integer> QANCollection_DoubleMapOfRealInteger;
+typedef NCollection_DoubleMap<Standard_Real,Standard_Integer>::Iterator QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger;
#endif
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_HeapAllocator.hxx>
#include <OSD_Timer.hxx>
#define QANCollection_IndexedDataMapOfRealPnt_HeaderFile
#include <gp_Pnt.hxx>
-#include <TColStd_MapRealHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<Standard_Real,gp_Pnt,TColStd_MapRealHasher> QANCollection_IndexedDataMapOfRealPnt;
+typedef NCollection_IndexedDataMap<Standard_Real,gp_Pnt> QANCollection_IndexedDataMapOfRealPnt;
#endif
// So must be defined ::HashCode and ::IsEqual too
#include <NCollection_DefineHArray1.hxx>
+#define DEFINE_ARRAY1(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_Array1<TheItemType > _ClassName_;
+
////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType)
DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf)
#include <NCollection_DefineHArray2.hxx>
+#define DEFINE_ARRAY2(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_Array2<TheItemType > _ClassName_;
////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType)
DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf)
-
-#include <NCollection_DefineMap.hxx>
-#include <NCollection_DefineDataMap.hxx>
-#include <NCollection_DefineDoubleMap.hxx>
-#include <NCollection_DefineIndexedMap.hxx>
-#include <NCollection_DefineIndexedDataMap.hxx>
////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
+#define DEFINE_DATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
+typedef NCollection_DataMap<TheKeyType, TheItemType > _ClassName_;
+#define DEFINE_DOUBLEMAP(_ClassName_, _BaseCollection_, TheKey1Type, TheKey2Type) \
+typedef NCollection_DoubleMap <TheKey1Type, TheKey2Type > _ClassName_;
+#define DEFINE_INDEXEDDATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
+typedef NCollection_IndexedDataMap <TheKeyType, TheItemType > _ClassName_;
+#define DEFINE_INDEXEDMAP(_ClassName_, _BaseCollection_, TheKeyType) \
+typedef NCollection_IndexedMap <TheKeyType > _ClassName_;
+#define DEFINE_MAP(_ClassName_, _BaseCollection_, TheKeyType) \
+typedef NCollection_Map <TheKeyType > _ClassName_;
DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type)
DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type)
DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type)
DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
-#include <NCollection_DefineList.hxx>
////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
+#define DEFINE_LIST(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_List <TheItemType > _ClassName_;
DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
#include <NCollection_DefineHSequence.hxx>
+#define DEFINE_SEQUENCE(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_Sequence<TheItemType > _ClassName_;
////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType)
#include <NCollection_Vector.hxx>
#include <NCollection_IncAllocator.hxx>
+#include <NCollection_Array2.hxx>
#define ItemType gp_Pnt
#define Key1Type Standard_Real
#define Key2Type Standard_Integer
#include <NCollection_DefineHArray1.hxx>
+#define DEFINE_ARRAY1(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_Array1<TheItemType > _ClassName_;
////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
DEFINE_ARRAY1(QANCollection_Array1Func,QANCollection_BaseColFunc,ItemType)
DEFINE_HARRAY1(QANCollection_HArray1Func,QANCollection_Array1Func)
#include <NCollection_DefineHArray2.hxx>
+#define DEFINE_ARRAY2(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_Array2<TheItemType > _ClassName_;
////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
DEFINE_ARRAY2(QANCollection_Array2Func,QANCollection_BaseColFunc,ItemType)
DEFINE_HARRAY2(QANCollection_HArray2Func,QANCollection_Array2Func)
-#include <NCollection_DefineMap.hxx>
-#include <NCollection_DefineDataMap.hxx>
-#include <NCollection_DefineDoubleMap.hxx>
-#include <NCollection_DefineIndexedMap.hxx>
-#include <NCollection_DefineIndexedDataMap.hxx>
+
////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
+#include <NCollection_DoubleMap.hxx>
+#include <NCollection_IndexedMap.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+#define DEFINE_DATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
+typedef NCollection_DataMap<TheKeyType, TheItemType > _ClassName_;
+#define DEFINE_DOUBLEMAP(_ClassName_, _BaseCollection_, TheKey1Type, TheKey2Type) \
+typedef NCollection_DoubleMap <TheKey1Type, TheKey2Type > _ClassName_;
+#define DEFINE_INDEXEDDATAMAP(_ClassName_, _BaseCollection_, TheKeyType, TheItemType) \
+typedef NCollection_IndexedDataMap <TheKeyType, TheItemType > _ClassName_;
+#define DEFINE_INDEXEDMAP(_ClassName_, _BaseCollection_, TheKeyType) \
+typedef NCollection_IndexedMap <TheKeyType > _ClassName_;
+#define DEFINE_MAP(_ClassName_, _BaseCollection_, TheKeyType) \
+typedef NCollection_Map <TheKeyType > _ClassName_;
DEFINE_MAP(QANCollection_MapFunc,QANCollection_Key1BaseColFunc,Key1Type)
DEFINE_DATAMAP(QANCollection_DataMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
DEFINE_DOUBLEMAP(QANCollection_DoubleMapFunc,QANCollection_Key2BaseColFunc,Key1Type,Key2Type)
DEFINE_INDEXEDMAP(QANCollection_IndexedMapFunc,QANCollection_Key1BaseColFunc,Key1Type)
DEFINE_INDEXEDDATAMAP(QANCollection_IDMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
-#include <NCollection_DefineList.hxx>
////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
+#define DEFINE_LIST(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_List <TheItemType > _ClassName_;
+DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
DEFINE_LIST(QANCollection_ListFunc,QANCollection_BaseColFunc,ItemType)
#include <NCollection_DefineHSequence.hxx>
+#include <NCollection_Sequence.hxx>
+#define DEFINE_SEQUENCE(_ClassName_, _BaseCollection_, TheItemType) \
+typedef NCollection_Sequence<TheItemType > _ClassName_;
////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
DEFINE_SEQUENCE(QANCollection_SequenceFunc,QANCollection_BaseColFunc,ItemType)
DEFINE_HSEQUENCE(QANCollection_HSequenceFunc,QANCollection_SequenceFunc)
-// HashCode and IsEquel must be defined for key types of maps
-
-//! Computes a hash code for the point, in the range [1, theUpperBound]
-//! @param thePoint the point 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]
-Standard_Integer HashCode (const gp_Pnt& thePoint, int theUpperBound)
-{
- return HashCode (thePoint.X(), theUpperBound);
-}
-
-Standard_Boolean IsEqual(const gp_Pnt& theP1, const gp_Pnt& theP2)
-{
- return theP1.IsEqual(theP2,gp::Resolution());
-}
-
////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl,
template <class Coll>
void printCollection (Coll& aColl, const char * str)
Quantity_Color.cxx
Quantity_Color.hxx
Quantity_ColorTable.pxx
-Quantity_ColorHasher.hxx
Quantity_ColorRGBA.cxx
Quantity_ColorRGBA.hxx
-Quantity_ColorRGBAHasher.hxx
Quantity_Date.cxx
Quantity_Date.hxx
Quantity_DateDefinitionError.hxx
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
+#include <Standard_HashUtils.hxx>
#include <Standard_ShortReal.hxx>
#include <Quantity_NameOfColor.hxx>
};
+namespace std
+{
+ template <>
+ struct hash<Quantity_Color>
+ {
+ std::size_t operator()(const Quantity_Color& theColor) const noexcept
+ {
+ unsigned char aByteArr[3] = { static_cast<unsigned char>(255 * theColor.Red()),
+ static_cast<unsigned char>(255 * theColor.Green()),
+ static_cast<unsigned char>(255 * theColor.Blue()) };
+ return opencascade::hashBytes(aByteArr, sizeof(aByteArr));
+ }
+ };
+}
+
#endif // _Quantity_Color_HeaderFile
+++ /dev/null
-// Created on: 2016-12-13
-// Copyright (c) 2016 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 _Quantity_ColorHasher_HeaderFile
-#define _Quantity_ColorHasher_HeaderFile
-
-#include <Quantity_Color.hxx>
-
-//! Hasher of Quantity_Color.
-struct Quantity_ColorHasher
-{
- //! Returns hash code for the given RGB color, in the range [1, theUpperBound]
- //! @param theColor the RGB color object which hash code is to be computed
- //! @param theUpperBound the upper bound of the range a computing range must be within
- //! @return a computed hash code, in the range [1, theUpperBound]
- static Standard_Integer HashCode (const Quantity_Color& theColor,
- const Standard_Integer theUpperBound)
- {
- Standard_Integer aRed = Standard_Integer (255 * theColor.Red());
- Standard_Integer aGreen = Standard_Integer (255 * theColor.Green());
- Standard_Integer aBlue = Standard_Integer (255 * theColor.Blue());
-
- unsigned int aHash = 0;
-
- updateHash (aHash, aRed);
- updateHash (aHash, aGreen);
- updateHash (aHash, aBlue);
- aHash += (aHash << 3);
- aHash ^= (aHash >> 11);
- aHash += (aHash << 15);
-
- return IntegerHashCode(aHash, 0x7fff, theUpperBound);
- }
-
- //! Returns true if two colors are equal.
- static Standard_Boolean IsEqual (const Quantity_Color& theColor1,
- const Quantity_Color& theColor2)
- {
- return theColor1 == theColor2;
- }
-
-protected:
- static void updateHash (unsigned int& theHash, const Standard_Integer theValue)
- {
- theHash += theValue;
- theHash += (theHash << 10);
- theHash ^= (theHash >> 6);
- }
-};
-
-#endif
};
+namespace std
+{
+ template <>
+ struct hash<Quantity_ColorRGBA>
+ {
+ std::size_t operator()(const Quantity_ColorRGBA& theColor) const noexcept
+ {
+ const Quantity_Color& anRGB = theColor.GetRGB();
+ unsigned char aByteArr[4] = { static_cast<unsigned char>(100 * theColor.Alpha()),
+ static_cast<unsigned char>(255 * anRGB.Red()),
+ static_cast<unsigned char>(255 * anRGB.Green()),
+ static_cast<unsigned char>(255 * anRGB.Blue()) };
+ return opencascade::hashBytes(aByteArr, sizeof(aByteArr));
+ }
+ };
+}
#endif // _Quantity_ColorRGBA_HeaderFile
+++ /dev/null
-// Copyright (c) 2017 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 _Quantity_ColorRGBAHasher_HeaderFile
-#define _Quantity_ColorRGBAHasher_HeaderFile
-
-#include <Quantity_ColorRGBA.hxx>
-#include <Quantity_ColorHasher.hxx>
-
-//! Hasher of Quantity_ColorRGBA.
-struct Quantity_ColorRGBAHasher
-{
-
- //! Returns hash code for the given RGBA color, in the range [1, theUpperBound]
- //! @param theColor the RGBA color object 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 Quantity_ColorRGBA& theColor,
- const Standard_Integer theUpperBound)
- {
- const NCollection_Vec4<float>& aColor = theColor;
- uint32_t aColor32 = (uint32_t(aColor.a() * 255.0f) << 24)
- + (uint32_t(aColor.b() * 255.0f) << 16)
- + (uint32_t(aColor.g() * 255.0f) << 8)
- + uint32_t(aColor.r() * 255.0f);
- return ::HashCode(aColor32, theUpperBound);
- }
-
- //! Returns true if two colors are equal.
- static Standard_Boolean IsEqual (const Quantity_ColorRGBA& theColor1,
- const Quantity_ColorRGBA& theColor2)
- {
- return theColor1 == theColor2;
- }
-
-};
-
-#endif // _Quantity_ColorRGBAHasher_HeaderFile
};
// dispatch faces
- NCollection_DataMap<XCAFPrs_Style, Handle(RWGltf_GltfFace), XCAFPrs_Style> aMergedFaces;
+ NCollection_DataMap<XCAFPrs_Style, Handle(RWGltf_GltfFace)> aMergedFaces;
for (XCAFPrs_DocumentExplorer aDocExplorer (theDocument, theRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
aDocExplorer.More() && aPSentryBin.More(); aDocExplorer.Next())
{
TopoDS_Shape Shape;
XCAFPrs_Style Style;
- RWGltf_StyledShape() {}
- explicit RWGltf_StyledShape (const TopoDS_Shape& theShape) : Shape (theShape) {}
- explicit RWGltf_StyledShape (const TopoDS_Shape& theShape,
- const XCAFPrs_Style& theStyle) : Shape (theShape), Style (theStyle) {}
- public:
- //! Computes a hash code.
- static Standard_Integer HashCode (const RWGltf_StyledShape& theShape, Standard_Integer theUpperBound)
+ RWGltf_StyledShape()
+ {}
+ explicit RWGltf_StyledShape(const TopoDS_Shape& theShape) : Shape(theShape)
+ {}
+ explicit RWGltf_StyledShape(const TopoDS_Shape& theShape,
+ const XCAFPrs_Style& theStyle) : Shape(theShape), Style(theStyle)
+ {}
+ bool operator==(const RWGltf_StyledShape& theStyledShape) const
{
- return theShape.Shape.HashCode (theUpperBound);
+ return Shape.IsSame(theStyledShape.Shape)
+ && Style.IsEqual(theStyledShape.Style);
}
- //! Equality comparison.
- static Standard_Boolean IsEqual (const RWGltf_StyledShape& theS1, const RWGltf_StyledShape& theS2)
+ };
+
+ struct Hasher
+ {
+ size_t operator()(const RWGltf_StyledShape& theShape) const noexcept
+ {
+ return std::hash<TopoDS_Shape>{}(theShape.Shape);
+ }
+
+ bool operator()(const RWGltf_StyledShape& theShape1,
+ const RWGltf_StyledShape& theShape2) const noexcept
{
- return theS1.Shape.IsSame (theS2.Shape)
- && theS1.Style.IsEqual(theS2.Style);
+ return theShape1 == theShape2;
}
};
- typedef NCollection_IndexedDataMap<RWGltf_StyledShape, Handle(RWGltf_GltfFaceList), RWGltf_StyledShape> ShapeToGltfFaceMap;
+ typedef NCollection_IndexedDataMap<RWGltf_StyledShape, Handle(RWGltf_GltfFaceList), Hasher> ShapeToGltfFaceMap;
protected:
private:
- NCollection_DataMap<TCollection_AsciiString, const RWGltf_JsonValue*, TCollection_AsciiString> myChildren;
+ NCollection_DataMap<TCollection_AsciiString, const RWGltf_JsonValue*> myChildren;
const RWGltf_JsonValue* myRoot;
};
Standard_Integer& theBuffViewId)
{
#ifdef HAVE_RAPIDJSON
- for (NCollection_IndexedDataMap<Handle(Image_Texture), RWGltf_GltfBufferView, Image_Texture>::Iterator aBufViewIter (myImageMap);
+ for (NCollection_IndexedDataMap<Handle(Image_Texture), RWGltf_GltfBufferView>::Iterator aBufViewIter (myImageMap);
aBufViewIter.More(); aBufViewIter.Next())
{
RWGltf_GltfBufferView& aBuffView = aBufViewIter.ChangeValue();
{
#ifdef HAVE_RAPIDJSON
bool isStarted = false;
- for (NCollection_IndexedDataMap<Handle(Image_Texture), RWGltf_GltfBufferView, Image_Texture>::Iterator aBufViewIter (myImageMap);
+ for (NCollection_IndexedDataMap<Handle(Image_Texture), RWGltf_GltfBufferView>::Iterator aBufViewIter (myImageMap);
aBufViewIter.More(); aBufViewIter.Next())
{
const Handle(Image_Texture)& aTexture = aBufViewIter.Key();
protected:
RWGltf_GltfOStreamWriter* myWriter;
- NCollection_IndexedDataMap<Handle(Image_Texture), RWGltf_GltfBufferView, Image_Texture> myImageMap;
- NCollection_Map<Handle(Image_Texture), Image_Texture> myTextureMap;
+ NCollection_IndexedDataMap<Handle(Image_Texture), RWGltf_GltfBufferView> myImageMap;
+ NCollection_Map<Handle(Image_Texture)> myTextureMap;
Standard_Integer myDefSamplerId;
#include <XCAFPrs_DocumentExplorer.hxx>
//! Indexed map of scene nodes with custom search algorithm.
-class RWGltf_GltfSceneNodeMap : public NCollection_IndexedMap<XCAFPrs_DocumentNode, XCAFPrs_DocumentNode>
+class RWGltf_GltfSceneNodeMap : public NCollection_IndexedMap<XCAFPrs_DocumentNode>
{
public:
{
return 0;
}
-
- for (IndexedMapNode* aNode1Iter = (IndexedMapNode* )myData1[::HashCode (theNodeId, NbBuckets())]; aNode1Iter != NULL; aNode1Iter = (IndexedMapNode* )aNode1Iter->Next())
- {
- if (::IsEqual (aNode1Iter->Key1().Id, theNodeId))
- {
- return aNode1Iter->Index();
- }
- }
- return 0;
+ XCAFPrs_DocumentNode aDocNode;
+ aDocNode.Id = theNodeId;
+ return NCollection_IndexedMap<XCAFPrs_DocumentNode>::FindIndex(aDocNode);
}
};
TCollection_AsciiString myFileName; //!< output glTF file path
TCollection_AsciiString myShortFileNameBase; //!< output glTF file name without extension
TCollection_AsciiString myKeyPrefix; //!< prefix for generated keys
- NCollection_DoubleMap<XCAFPrs_Style, TCollection_AsciiString,
- XCAFPrs_Style, TCollection_AsciiString>
+ NCollection_DoubleMap<XCAFPrs_Style, TCollection_AsciiString>
myStyles; //!< map of processed styles
- NCollection_Map<Handle(Image_Texture), Image_Texture>
+ NCollection_Map<Handle(Image_Texture)>
myImageFailMap; //!< map of images failed to be copied
XCAFPrs_Style myDefaultStyle; //!< default material definition to be used for nodes with only color defined
Standard_Integer myNbMaterials; //!< number of registered materials
#ifndef _RWObj_ObjMaterialMap_HeaderFiler
#define _RWObj_ObjMaterialMap_HeaderFiler
+#include <NCollection_DataMap.hxx>
#include <RWMesh_MaterialMap.hxx>
//! Material MTL file writer for OBJ export.
private:
FILE* myFile;
- NCollection_DataMap<Handle(Image_Texture), TCollection_AsciiString, Image_Texture> myImageMap;
+ NCollection_DataMap<Handle(Image_Texture), TCollection_AsciiString> myImageMap;
};
#include <RWObj_SubMesh.hxx>
#include <RWObj_SubMeshReason.hxx>
#include <RWObj_Tools.hxx>
+#include <Standard_HashUtils.hxx>
#include <vector>
//! Hasher for 3 ordered integers.
struct ObjVec3iHasher
{
- static Standard_Integer HashCode (const Graphic3d_Vec3i& theKey,
- const Standard_Integer theUpper)
+ std::size_t operator()(const Graphic3d_Vec3i& theKey) const noexcept
{
- return ::HashCode (::HashCodes ((Standard_CString )&theKey, sizeof(Graphic3d_Vec3i)), theUpper);
+ return opencascade::hashBytes(&theKey[0], 3 * sizeof(int));
}
- static Standard_Boolean IsEqual (const Graphic3d_Vec3i& theKey1,
- const Graphic3d_Vec3i& theKey2)
+ bool operator()(const Graphic3d_Vec3i& theKey1,
+ const Graphic3d_Vec3i& theKey2) const noexcept
{
return theKey1[0] == theKey2[0]
&& theKey1[1] == theKey2[1]
#include <TCollection_AsciiString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,TCollection_AsciiString,TCollection_AsciiString> Resource_DataMapOfAsciiStringAsciiString;
-typedef NCollection_DataMap<TCollection_AsciiString,TCollection_AsciiString,TCollection_AsciiString>::Iterator Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString;
+typedef NCollection_DataMap<TCollection_AsciiString,TCollection_AsciiString> Resource_DataMapOfAsciiStringAsciiString;
+typedef NCollection_DataMap<TCollection_AsciiString,TCollection_AsciiString>::Iterator Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString;
#endif
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,TCollection_ExtendedString,TCollection_AsciiString> Resource_DataMapOfAsciiStringExtendedString;
-typedef NCollection_DataMap<TCollection_AsciiString,TCollection_ExtendedString,TCollection_AsciiString>::Iterator Resource_DataMapIteratorOfDataMapOfAsciiStringExtendedString;
+typedef NCollection_DataMap<TCollection_AsciiString,TCollection_ExtendedString> Resource_DataMapOfAsciiStringExtendedString;
+typedef NCollection_DataMap<TCollection_AsciiString,TCollection_ExtendedString>::Iterator Resource_DataMapIteratorOfDataMapOfAsciiStringExtendedString;
#endif
#include <Standard_CString.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
-#include <Standard_ExtString.hxx>
class Resource_Manager;
#include <TDF_Label.hxx>
#include <STEPCAFControl_ExternFile.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TDF_Label,Handle(STEPCAFControl_ExternFile),TDF_LabelMapHasher> STEPCAFControl_DataMapOfLabelExternFile;
-typedef NCollection_DataMap<TDF_Label,Handle(STEPCAFControl_ExternFile),TDF_LabelMapHasher>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfLabelExternFile;
+typedef NCollection_DataMap<TDF_Label,Handle(STEPCAFControl_ExternFile)> STEPCAFControl_DataMapOfLabelExternFile;
+typedef NCollection_DataMap<TDF_Label,Handle(STEPCAFControl_ExternFile)>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfLabelExternFile;
#endif
#define STEPCAFControl_DataMapOfLabelShape_HeaderFile
#include <TopoDS_Shape.hxx>
-#include <TDF_LabelMapHasher.hxx>
+#include <TDF_Label.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TDF_Label,TopoDS_Shape,TDF_LabelMapHasher> STEPCAFControl_DataMapOfLabelShape;
-typedef NCollection_DataMap<TDF_Label,TopoDS_Shape,TDF_LabelMapHasher>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfLabelShape;
+typedef NCollection_DataMap<TDF_Label,TopoDS_Shape> STEPCAFControl_DataMapOfLabelShape;
+typedef NCollection_DataMap<TDF_Label,TopoDS_Shape>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfLabelShape;
#endif
#include <StepBasic_ProductDefinition.hxx>
#include <STEPCAFControl_ExternFile.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(StepBasic_ProductDefinition),Handle(STEPCAFControl_ExternFile),TColStd_MapTransientHasher> STEPCAFControl_DataMapOfPDExternFile;
-typedef NCollection_DataMap<Handle(StepBasic_ProductDefinition),Handle(STEPCAFControl_ExternFile),TColStd_MapTransientHasher>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfPDExternFile;
+typedef NCollection_DataMap<Handle(StepBasic_ProductDefinition),Handle(STEPCAFControl_ExternFile)> STEPCAFControl_DataMapOfPDExternFile;
+typedef NCollection_DataMap<Handle(StepBasic_ProductDefinition),Handle(STEPCAFControl_ExternFile)>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfPDExternFile;
#endif
#include <StepShape_ShapeDefinitionRepresentation.hxx>
#include <STEPCAFControl_ExternFile.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(StepShape_ShapeDefinitionRepresentation),Handle(STEPCAFControl_ExternFile),TColStd_MapTransientHasher> STEPCAFControl_DataMapOfSDRExternFile;
-typedef NCollection_DataMap<Handle(StepShape_ShapeDefinitionRepresentation),Handle(STEPCAFControl_ExternFile),TColStd_MapTransientHasher>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfSDRExternFile;
+typedef NCollection_DataMap<Handle(StepShape_ShapeDefinitionRepresentation),Handle(STEPCAFControl_ExternFile)> STEPCAFControl_DataMapOfSDRExternFile;
+typedef NCollection_DataMap<Handle(StepShape_ShapeDefinitionRepresentation),Handle(STEPCAFControl_ExternFile)>::Iterator STEPCAFControl_DataMapIteratorOfDataMapOfSDRExternFile;
#endif
STEPConstruct_ExternRefs.hxx
STEPConstruct_Part.cxx
STEPConstruct_Part.hxx
-STEPConstruct_PointHasher.cxx
-STEPConstruct_PointHasher.hxx
-STEPConstruct_PointHasher.lxx
STEPConstruct_Styles.cxx
STEPConstruct_Styles.hxx
STEPConstruct_Tool.cxx
#include <Standard_Transient.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Standard_Transient),TCollection_AsciiString> STEPConstruct_DataMapOfAsciiStringTransient;
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Standard_Transient),TCollection_AsciiString>::Iterator STEPConstruct_DataMapIteratorOfDataMapOfAsciiStringTransient;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Standard_Transient)> STEPConstruct_DataMapOfAsciiStringTransient;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Standard_Transient)>::Iterator STEPConstruct_DataMapIteratorOfDataMapOfAsciiStringTransient;
#endif
#include <gp_Pnt.hxx>
#include <Standard_Transient.hxx>
-#include <STEPConstruct_PointHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<gp_Pnt,Handle(Standard_Transient),STEPConstruct_PointHasher> STEPConstruct_DataMapOfPointTransient;
-typedef NCollection_DataMap<gp_Pnt,Handle(Standard_Transient),STEPConstruct_PointHasher>::Iterator STEPConstruct_DataMapIteratorOfDataMapOfPointTransient;
+typedef NCollection_DataMap<gp_Pnt,Handle(Standard_Transient)> STEPConstruct_DataMapOfPointTransient;
+typedef NCollection_DataMap<gp_Pnt,Handle(Standard_Transient)>::Iterator STEPConstruct_DataMapIteratorOfDataMapOfPointTransient;
#endif
+++ /dev/null
-// Copyright (c) 1999-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 <gp_Pnt.hxx>
-#include <STEPConstruct_PointHasher.hxx>
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-Standard_Boolean STEPConstruct_PointHasher::IsEqual(const gp_Pnt& point1,
- const gp_Pnt& point2)
-{
- if(Abs(point1.X()-point2.X()) > Epsilon(point1.X())) return Standard_False;
- if(Abs(point1.Y()-point2.Y()) > Epsilon(point1.Y())) return Standard_False;
- if(Abs(point1.Z()-point2.Z()) > Epsilon(point1.Z())) return Standard_False;
- return Standard_True;
-}
+++ /dev/null
-// Created on: 2003-01-15
-// Created by: data exchange team
-// Copyright (c) 2003-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 _STEPConstruct_PointHasher_HeaderFile
-#define _STEPConstruct_PointHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-class gp_Pnt;
-
-
-
-class STEPConstruct_PointHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the point, in the range [1, theUpperBound]
- //! @param thePoint the point 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 gp_Pnt& thePoint, const Standard_Integer theUpperBound);
-
- //! Returns True when the two keys are the same. Two
- //! same keys must have the same hashcode, the
- //! contrary is not necessary.
- Standard_EXPORT static Standard_Boolean IsEqual (const gp_Pnt& Point1, const gp_Pnt& Point2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-#include <STEPConstruct_PointHasher.lxx>
-
-
-
-
-
-#endif // _STEPConstruct_PointHasher_HeaderFile
+++ /dev/null
-// Copyright (c) 1999-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.
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer STEPConstruct_PointHasher::HashCode (const gp_Pnt& thePoint,
- const Standard_Integer theUpperBound)
-{
- union
- {
- Standard_Real R[3];
- Standard_Integer I[6];
- } U;
-
- thePoint.Coord (U.R[0], U.R[1], U.R[2]);
-
- return ::HashCode (U.I[0] / 23 + U.I[1] / 19 + U.I[2] / 17 + U.I[3] / 13 + U.I[4] / 11 + U.I[5] / 7, theUpperBound);
- // return ::HashCode((U.I[0]>>4)+(U.I[1]>>3)+(U.I[2]>>2)+(U.I[3]>>1)+(U.I[4]>>4)+(U.I[5]>>3),theUpperBound);
-}
myPool(nullptr),
myMutex(),
myToCatchFpe (Standard_False)
- {
+ {}
- }
+
+ BVHThread(const BVHThread& theOther)
+ : OSD_Thread(theOther),
+ myPool(theOther.myPool),
+ myMutex(),
+ myToCatchFpe(theOther.myToCatchFpe)
+ {}
//! Returns mutex used for BVH building
Standard_Mutex& BVHMutex()
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SortCriterion.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<Handle(SelectMgr_EntityOwner), SelectMgr_SortCriterion, TColStd_MapTransientHasher> SelectMgr_IndexedDataMapOfOwnerCriterion;
+typedef NCollection_IndexedDataMap<Handle(SelectMgr_EntityOwner), SelectMgr_SortCriterion> SelectMgr_IndexedDataMapOfOwnerCriterion;
#endif
#include <math_BullardGenerator.hxx>
#include <NCollection_Map.hxx>
#include <StdSelect_TypeOfSelectionImage.hxx>
-#include <Quantity_ColorHasher.hxx>
class SelectMgr_ViewerSelector;
Image_PixMap* myImage;
SelectMgr_ViewerSelector* myMainSel;
math_BullardGenerator myBullardGenerator;
- NCollection_Map<Quantity_Color, Quantity_ColorHasher> myUniqueColors;
+ NCollection_Map<Quantity_Color> myUniqueColors;
};
#endif
template<class HSequence>
static inline void ReverseSeq (HSequence& Seq)
{
- Standard_Integer j=Seq.Length();
- for(Standard_Integer i=1; i<Seq.Length(); i++) {
- if(i>=j) break;
- Seq.Exchange(i,j);
- j--;
- }
+ Seq.Reverse();
}
//=======================================================================
//function : TotCross2D
#include <Standard_Transient.hxx>
#include <Message_ListOfMsg.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(Standard_Transient),Message_ListOfMsg,TColStd_MapTransientHasher> ShapeExtend_DataMapOfTransientListOfMsg;
-typedef NCollection_DataMap<Handle(Standard_Transient),Message_ListOfMsg,TColStd_MapTransientHasher>::Iterator ShapeExtend_DataMapIteratorOfDataMapOfTransientListOfMsg;
+typedef NCollection_DataMap<Handle(Standard_Transient),Message_ListOfMsg> ShapeExtend_DataMapOfTransientListOfMsg;
+typedef NCollection_DataMap<Handle(Standard_Transient),Message_ListOfMsg>::Iterator ShapeExtend_DataMapIteratorOfDataMapOfTransientListOfMsg;
#endif
for ( theLIterator.Initialize( theList );
theLIterator.More();
theLIterator.Next() ) {
- TopoDS_Vertex& theVertex = TopoDS::Vertex( theLIterator.Value() );
+ const TopoDS_Vertex& theVertex = TopoDS::Vertex( theLIterator.Value() );
theLIterator.Next();
- TopoDS_Edge& theEdge = TopoDS::Edge( theLIterator.Value() );
+ TopoDS_Edge& theEdge = TopoDS::Edge( theLIterator.ChangeValue() );
// Determine usage of curve bound points
TopoDS_Vertex theStart, theEnd;
for ( theLIterator.Initialize( theList );
theLIterator.More();
theLIterator.Next() ) {
- TopoDS_Vertex& theVertex = TopoDS::Vertex( theLIterator.Value() );
+ const TopoDS_Vertex& theVertex = TopoDS::Vertex( theLIterator.Value() );
theLIterator.Next();
- TopoDS_Edge& theEdge = TopoDS::Edge( theLIterator.Value() );
+ TopoDS_Edge& theEdge = TopoDS::Edge( theLIterator.ChangeValue() );
// Determine usage of old vertices
TopoDS_Vertex theStart, theEnd;
Standard.cxx
Standard.hxx
Standard_AbortiveTransaction.hxx
-Standard_Address.hxx
Standard_ArrayStreamBuffer.hxx
Standard_ArrayStreamBuffer.cxx
Standard_Assert.hxx
Standard_Copy.tcl
Standard_CString.cxx
Standard_CString.hxx
+Standard_CStringHasher.hxx
Standard_DefineAlloc.hxx
Standard_DefineException.hxx
Standard_DefineHandle.hxx
Standard_ErrorHandler.cxx
Standard_ErrorHandler.hxx
Standard_ExtCharacter.hxx
-Standard_ExtString.cxx
-Standard_ExtString.hxx
Standard_Failure.cxx
Standard_Failure.hxx
Standard_WarningDisableFunctionCast.hxx
Standard_GUID.hxx
Standard_Handle.hxx
Standard_HandlerStatus.hxx
+Standard_HashUtils.hxx
+Standard_HashUtils.lxx
Standard_ImmutableObject.hxx
Standard_Integer.hxx
Standard_IStream.hxx
Standard_LicenseError.hxx
Standard_LicenseNotFound.hxx
Standard_Macro.hxx
-Standard_math.cxx
-Standard_math.hxx
+Standard_MemoryUtils.hxx
Standard_MMgrOpt.cxx
Standard_MMgrOpt.hxx
-Standard_MMgrRaw.cxx
-Standard_MMgrRaw.hxx
Standard_MMgrRoot.cxx
Standard_MMgrRoot.hxx
-Standard_MMgrTBBalloc.cxx
-Standard_MMgrTBBalloc.hxx
Standard_MultiplyDefined.hxx
Standard_Mutex.cxx
Standard_Mutex.hxx
Standard_ReadLineBuffer.hxx
Standard_Real.cxx
Standard_Real.hxx
-Standard_ShortReal.cxx
Standard_ShortReal.hxx
-Standard_Size.hxx
Standard_SStream.hxx
Standard_StackTrace.cxx
Standard_Std.hxx
Standard_TypeMismatch.hxx
Standard_Underflow.hxx
Standard_UUID.hxx
-Standard_values.h
Standard_Version.hxx
Standard_WarningsDisable.hxx
-Standard_WarningsRestore.hxx
\ No newline at end of file
+Standard_WarningsRestore.hxx
-// Created on: 2005-03-15
-// Created by: Peter KURNEV
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 1999-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
#include <Standard.hxx>
-#include <Standard_MMgrOpt.hxx>
-#include <Standard_MMgrRaw.hxx>
-#include <Standard_MMgrTBBalloc.hxx>
-#include <Standard_Assert.hxx>
+
+#include <Standard_OutOfMemory.hxx>
#include <stdlib.h>
+
#if(defined(_WIN32) || defined(__WIN32__))
- #include <windows.h>
- #include <malloc.h>
- #include <locale.h>
+#include <windows.h>
+#include <malloc.h>
+#include <locale.h>
#endif
#if defined(_MSC_VER) || defined(__ANDROID__) || defined(__QNX__)
- #include <malloc.h>
+#include <malloc.h>
#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && (defined(__i386) || defined(__x86_64)))
- #include <mm_malloc.h>
+#include <mm_malloc.h>
+#else
+extern "C" int posix_memalign(void** thePtr, size_t theAlign, size_t theSize);
+#endif
+
+// Temp define, after it will be part of CMake
+#define OCCT_MMGT_OPT_NATIVE
+
+namespace
+{
+ static Standard::AllocatorType& allocatorTypeInstance()
+ {
+ static Standard::AllocatorType aType =
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
+ Standard::AllocatorType::NATIVE;
+#elif defined OCCT_MMGT_OPT_NATIVE
+ Standard::AllocatorType::NATIVE;
+#elif defined OCCT_MMGT_OPT_TBB
+ Standard::AllocatorType::TBB;
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ Standard::AllocatorType::JEMALLOC;
+#endif
+ return aType;
+ }
+}
+
+#ifdef OCCT_MMGT_OPT_JEMALLOC
+#define JEMALLOC_NO_DEMANGLE
+#include <jemalloc/jemalloc.h>
+#endif // OCCT_MMGT_OPT_JEMALLOC
+
+// Available macros definition
+// - OCCT_MMGT_OPT_FLEXIBLE, modifiable in real time
+// - OCCT_MMGT_OPT_TBB, using tbb::scalable_allocator
+// - OCCT_MMGT_OPT_NATIVE, using native calloc, free
+// - OCCT_MMGT_OPT_JEMALLOC, using external jecalloc, jefree
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
+#include <Standard_MMgrOpt.hxx>
+#include <Standard_Assert.hxx>
+
+ // paralleling with Intel TBB
+#ifdef HAVE_TBB
+#pragma comment (lib, "tbbmalloc.lib")
+#include <tbb/scalable_allocator.h>
#else
- extern "C" int posix_memalign (void** thePtr, size_t theAlign, size_t theSize);
+#define scalable_malloc malloc
+#define scalable_calloc calloc
+#define scalable_realloc realloc
+#define scalable_free free
#endif
// There is no support for environment variables in UWP
#ifndef OCCT_MMGT_OPT_DEFAULT
#define OCCT_MMGT_OPT_DEFAULT 0
#endif
-
-//=======================================================================
-//class : Standard_MMgrFactory
-//purpose : Container for pointer to memory manager;
-// used to construct appropriate memory manager according
-// to environment settings, and to ensure destruction upon exit
-//=======================================================================
-class Standard_MMgrFactory
+namespace
{
-public:
- static Standard_MMgrRoot* GetMMgr();
- ~Standard_MMgrFactory();
+ /**
+ * Implementation of raw OCC memory manager which uses standard C
+ * functions: malloc (or calloc), free and realloc
+ * without any optimization
+ */
+ class Standard_MMgrRaw : public Standard_MMgrRoot
+ {
+ public:
+ //! Constructor; if theToClear is True, the memory will be nullified
+ //! upon allocation.
+ Standard_MMgrRaw(const Standard_Boolean theToClear = Standard_False)
+ {
+ myClear = theToClear;
+ }
-private:
- Standard_MMgrFactory();
- Standard_MMgrFactory (const Standard_MMgrFactory&);
- Standard_MMgrFactory& operator= (const Standard_MMgrFactory&);
+ //! Allocate theSize bytes
+ Standard_Address Allocate(const Standard_Size theSize) override
+ {
+ // we use ?: operator instead of if() since it is faster :-)
+ Standard_Address aPtr = (myClear ? calloc(theSize, sizeof(char)) :
+ malloc(theSize));
+ if (!aPtr)
+ throw Standard_OutOfMemory("Standard_MMgrRaw::Allocate(): malloc failed");
+ return aPtr;
+ }
-private:
- Standard_MMgrRoot* myFMMgr;
-};
+ //! Reallocate thePtr to the size theSize.
+ //! The new pointer is returned.
+ Standard_Address Reallocate(Standard_Address thePtr,
+ const Standard_Size theSize) override
+ {
+ Standard_Address newStorage = (Standard_Address)realloc(thePtr, theSize);
+ if (!newStorage)
+ throw Standard_OutOfMemory("Standard_MMgrRaw::Reallocate(): realloc failed");
+ // Note that it is not possible to ensure that additional memory
+ // allocated by realloc will be cleared (so as to satisfy myClear mode);
+ // in order to do that we would need using memset...
+ return newStorage;
+ }
-//=======================================================================
-//function : Standard_MMgrFactory
-//purpose : Check environment variables and create appropriate memory manager
-//=======================================================================
+ //! Free allocated memory. The pointer is nullified.
+ void Free(Standard_Address thePtr) override
+ {
+ free(thePtr);
+ }
-Standard_MMgrFactory::Standard_MMgrFactory()
-: myFMMgr (NULL)
-{
-/*#if defined(_MSC_VER) && (_MSC_VER > 1400)
- // Turn ON thread-safe C locale globally to avoid side effects by setlocale() calls between threads.
- // After this call all following _configthreadlocale() will be ignored assuming
- // Notice that this is MSVCRT feature - on POSIX systems xlocale API (uselocale instead of setlocale)
- // should be used explicitly to ensure thread-safety!
-
- // This is not well documented call because _ENABLE_PER_THREAD_LOCALE_GLOBAL flag is defined but not implemented for some reason.
- // -1 will set global locale flag to force _ENABLE_PER_THREAD_LOCALE_GLOBAL + _ENABLE_PER_THREAD_LOCALE_NEW behaviour
- // although there NO way to turn it off again and following calls will have no effect (locale will be changed only for current thread).
- _configthreadlocale (-1);
-#endif*/
-
- // Check basic assumption.
- // If assertion happens, then OCCT should be corrected for compatibility with such CPU architecture.
- Standard_STATIC_ASSERT(sizeof(Standard_Utf8Char) == 1);
- Standard_STATIC_ASSERT(sizeof(short) == 2);
- Standard_STATIC_ASSERT(sizeof(Standard_Utf16Char) == 2);
- Standard_STATIC_ASSERT(sizeof(Standard_Utf32Char) == 4);
+ protected:
+ Standard_Boolean myClear; //! Option to nullify allocated memory
+ };
+
+ //! Implementation of OCC memory manager which uses Intel TBB
+ //! scalable allocator.
+ //!
+ //! On configurations where TBB is not available standard RTL functions
+ //! malloc() / free() are used.
+ class Standard_MMgrTBBalloc : public Standard_MMgrRoot
+ {
+ public:
+ //! Constructor; if theClear is True, the memory will be nullified
+ //! upon allocation.
+ Standard_MMgrTBBalloc(const Standard_Boolean theClear = Standard_False)
+ {
+ myClear = theClear;
+ }
+
+ //! Allocate theSize bytes
+ Standard_Address Allocate(const Standard_Size theSize) override
+ {
+ // we use ?: operator instead of if() since it is faster :-)
+ Standard_Address aPtr = (myClear ? scalable_calloc(theSize, sizeof(char)) :
+ scalable_malloc(theSize));
+ if (!aPtr)
+ throw Standard_OutOfMemory("Standard_MMgrTBBalloc::Allocate(): malloc failed");
+ return aPtr;
+ }
+
+ //! Reallocate thePtr to the size theSize.
+ //! The new pointer is returned.
+ Standard_Address Reallocate(Standard_Address thePtr,
+ const Standard_Size theSize) override
+ {
+ Standard_Address newStorage = (Standard_Address)scalable_realloc(thePtr, theSize);
+ if (!newStorage)
+ throw Standard_OutOfMemory("Standard_MMgrTBBalloc::Reallocate(): realloc failed");
+ // Note that it is not possible to ensure that additional memory
+ // allocated by realloc will be cleared (so as to satisfy myClear mode);
+ // in order to do that we would need using memset...
+ return newStorage;
+ }
+
+ //! Free allocated memory
+ void Free(Standard_Address thePtr) override
+ {
+ scalable_free(thePtr);
+ }
+
+ protected:
+ Standard_Boolean myClear; //! Option to nullify allocated memory
+ };
+
+ //=======================================================================
+ //class : Standard_MMgrFactory
+ //purpose : Container for pointer to memory manager;
+ // used to construct appropriate memory manager according
+ // to environment settings, and to ensure destruction upon exit
+ //=======================================================================
+ class Standard_MMgrFactory
+ {
+ public:
+ static Standard_MMgrRoot* GetMMgr();
+ ~Standard_MMgrFactory();
+
+ private:
+ Standard_MMgrFactory();
+ Standard_MMgrFactory(const Standard_MMgrFactory&);
+ Standard_MMgrFactory& operator= (const Standard_MMgrFactory&);
+
+ private:
+ Standard_MMgrRoot* myFMMgr;
+ };
+
+ //=======================================================================
+ //function : Standard_MMgrFactory
+ //purpose : Check environment variables and create appropriate memory manager
+ //=======================================================================
+
+ Standard_MMgrFactory::Standard_MMgrFactory()
+ : myFMMgr(NULL)
+ {
+ /*#if defined(_MSC_VER) && (_MSC_VER > 1400)
+ // Turn ON thread-safe C locale globally to avoid side effects by setlocale() calls between threads.
+ // After this call all following _configthreadlocale() will be ignored assuming
+ // Notice that this is MSVCRT feature - on POSIX systems xlocale API (uselocale instead of setlocale)
+ // should be used explicitly to ensure thread-safety!
+
+ // This is not well documented call because _ENABLE_PER_THREAD_LOCALE_GLOBAL flag is defined but not implemented for some reason.
+ // -1 will set global locale flag to force _ENABLE_PER_THREAD_LOCALE_GLOBAL + _ENABLE_PER_THREAD_LOCALE_NEW behaviour
+ // although there NO way to turn it off again and following calls will have no effect (locale will be changed only for current thread).
+ _configthreadlocale (-1);
+ #endif*/
+
+ // Check basic assumption.
+ // If assertion happens, then OCCT should be corrected for compatibility with such CPU architecture.
+ Standard_STATIC_ASSERT(sizeof(Standard_Utf8Char) == 1);
+ Standard_STATIC_ASSERT(sizeof(short) == 2);
+ Standard_STATIC_ASSERT(sizeof(Standard_Utf16Char) == 2);
+ Standard_STATIC_ASSERT(sizeof(Standard_Utf32Char) == 4);
#ifdef _WIN32
- Standard_STATIC_ASSERT(sizeof(Standard_WideChar) == sizeof(Standard_Utf16Char));
+ Standard_STATIC_ASSERT(sizeof(Standard_WideChar) == sizeof(Standard_Utf16Char));
#endif
- char* aVar;
- aVar = getenv ("MMGT_OPT");
- Standard_Integer anAllocId = (aVar ? atoi (aVar): OCCT_MMGT_OPT_DEFAULT);
+ char* aVar;
+ aVar = getenv("MMGT_OPT");
+ Standard_Integer anAllocId = (aVar ? atoi(aVar) : OCCT_MMGT_OPT_DEFAULT);
#if defined(HAVE_TBB) && defined(_M_IX86)
- if (anAllocId == 2)
- {
- // CR25396: Check if SSE2 instructions are supported on 32-bit x86 processor on Windows platform,
- // if not then use MMgrRaw instead of MMgrTBBalloc.
- // It is to avoid runtime crash when running on a CPU
- // that supports SSE but does not support SSE2 (some modifications of AMD Sempron).
- static const DWORD _SSE2_FEATURE_BIT(0x04000000);
- DWORD volatile dwFeature;
- _asm
+ if (anAllocId == 2)
{
- push eax
- push ebx
- push ecx
- push edx
-
- // get the CPU feature bits
- mov eax, 1
- cpuid
- mov dwFeature, edx
-
- pop edx
- pop ecx
- pop ebx
- pop eax
+ // CR25396: Check if SSE2 instructions are supported on 32-bit x86 processor on Windows platform,
+ // if not then use MMgrRaw instead of MMgrTBBalloc.
+ // It is to avoid runtime crash when running on a CPU
+ // that supports SSE but does not support SSE2 (some modifications of AMD Sempron).
+ static const DWORD _SSE2_FEATURE_BIT(0x04000000);
+ DWORD volatile dwFeature;
+ _asm
+ {
+ push eax
+ push ebx
+ push ecx
+ push edx
+
+ // get the CPU feature bits
+ mov eax, 1
+ cpuid
+ mov dwFeature, edx
+
+ pop edx
+ pop ecx
+ pop ebx
+ pop eax
+ }
+ if ((dwFeature & _SSE2_FEATURE_BIT) == 0)
+ anAllocId = 0;
}
- if ((dwFeature & _SSE2_FEATURE_BIT) == 0)
- anAllocId = 0;
- }
#endif
- aVar = getenv ("MMGT_CLEAR");
- Standard_Boolean toClear = (aVar ? (atoi (aVar) != 0) : Standard_True);
+ aVar = getenv("MMGT_CLEAR");
+ Standard_Boolean toClear = (aVar ? (atoi(aVar) != 0) : Standard_True);
- // on Windows (actual for XP and 2000) activate low fragmentation heap
- // for CRT heap in order to get best performance.
- // Environment variable MMGT_LFH can be used to switch off this action (if set to 0)
+ // on Windows (actual for XP and 2000) activate low fragmentation heap
+ // for CRT heap in order to get best performance.
+ // Environment variable MMGT_LFH can be used to switch off this action (if set to 0)
#if defined(_MSC_VER)
- aVar = getenv ("MMGT_LFH");
- if ( aVar == NULL || atoi (aVar) != 0 )
- {
- ULONG aHeapInfo = 2;
- HANDLE aCRTHeap = (HANDLE)_get_heap_handle();
- HeapSetInformation (aCRTHeap, HeapCompatibilityInformation, &aHeapInfo, sizeof(aHeapInfo));
- }
+ aVar = getenv("MMGT_LFH");
+ if (aVar == NULL || atoi(aVar) != 0)
+ {
+ ULONG aHeapInfo = 2;
+ HANDLE aCRTHeap = (HANDLE)_get_heap_handle();
+ HeapSetInformation(aCRTHeap, HeapCompatibilityInformation, &aHeapInfo, sizeof(aHeapInfo));
+ }
#endif
- switch (anAllocId)
- {
- case 1: // OCCT optimized memory allocator
+ switch (anAllocId)
{
- aVar = getenv ("MMGT_MMAP");
- Standard_Boolean bMMap = (aVar ? (atoi (aVar) != 0) : Standard_True);
- aVar = getenv ("MMGT_CELLSIZE");
- Standard_Integer aCellSize = (aVar ? atoi (aVar) : 200);
- aVar = getenv ("MMGT_NBPAGES");
- Standard_Integer aNbPages = (aVar ? atoi (aVar) : 1000);
- aVar = getenv ("MMGT_THRESHOLD");
- Standard_Integer aThreshold = (aVar ? atoi (aVar) : 40000);
- myFMMgr = new Standard_MMgrOpt (toClear, bMMap, aCellSize, aNbPages, aThreshold);
- break;
+ case 1: // OCCT optimized memory allocator
+ {
+ aVar = getenv("MMGT_MMAP");
+ Standard_Boolean bMMap = (aVar ? (atoi(aVar) != 0) : Standard_True);
+ aVar = getenv("MMGT_CELLSIZE");
+ Standard_Integer aCellSize = (aVar ? atoi(aVar) : 200);
+ aVar = getenv("MMGT_NBPAGES");
+ Standard_Integer aNbPages = (aVar ? atoi(aVar) : 1000);
+ aVar = getenv("MMGT_THRESHOLD");
+ Standard_Integer aThreshold = (aVar ? atoi(aVar) : 40000);
+ myFMMgr = new Standard_MMgrOpt(toClear, bMMap, aCellSize, aNbPages, aThreshold);
+ break;
+ }
+ case 2: // TBB memory allocator
+ myFMMgr = new Standard_MMgrTBBalloc(toClear);
+ break;
+ case 0:
+ default: // system default memory allocator
+ myFMMgr = new Standard_MMgrRaw(toClear);
}
- case 2: // TBB memory allocator
- myFMMgr = new Standard_MMgrTBBalloc (toClear);
- break;
- case 0:
- default: // system default memory allocator
- myFMMgr = new Standard_MMgrRaw (toClear);
+ allocatorTypeInstance() = static_cast<Standard::AllocatorType>(anAllocId);
+ }
+
+ //=======================================================================
+ //function : ~Standard_MMgrFactory
+ //purpose :
+ //=======================================================================
+
+ Standard_MMgrFactory::~Standard_MMgrFactory()
+ {
+ if (myFMMgr)
+ myFMMgr->Purge(Standard_True);
+ }
+
+ //=======================================================================
+ // function: GetMMgr
+ //
+ // This static function has a purpose to wrap static holder for memory
+ // manager instance.
+ //
+ // Wrapping holder inside a function is needed to ensure that it will
+ // be initialized not later than the first call to memory manager (that
+ // would be impossible to guarantee if holder was static variable on
+ // global or file scope, because memory manager may be called from
+ // constructors of other static objects).
+ //
+ // Note that at the same time we could not guarantee that the holder
+ // object is destroyed after last call to memory manager, since that
+ // last call may be from static Handle() object which has been initialized
+ // dynamically during program execution rather than in its constructor.
+ //
+ // Therefore holder currently does not call destructor of the memory manager
+ // but only its method Purge() with Standard_True.
+ //
+ // To free the memory completely, we probably could use compiler-specific
+ // pragmas (such as '#pragma fini' on SUN Solaris and '#pragma init_seg' on
+ // WNT MSVC++) to put destructing function in code segment that is called
+ // after destructors of other (even static) objects. However, this is not
+ // done by the moment since it is compiler-dependent and there is no guarantee
+ // that some other object calling memory manager is not placed also in that segment...
+ //
+ // Note that C runtime function atexit() could not help in this problem
+ // since its behaviour is the same as for destructors of static objects
+ // (see ISO 14882:1998 "Programming languages -- C++" 3.6.3)
+ //
+ // The correct approach to deal with the problem would be to have memory manager
+ // to properly control its memory allocation and caching free blocks so
+ // as to release all memory as soon as it is returned to it, and probably
+ // even delete itself if all memory it manages has been released and
+ // last call to method Purge() was with True.
+ //
+ // Note that one possible method to control memory allocations could
+ // be counting calls to Allocate() and Free()...
+ //
+ //=======================================================================
+ Standard_MMgrRoot* Standard_MMgrFactory::GetMMgr()
+ {
+ static Standard_MMgrFactory aFactory;
+ return aFactory.myFMMgr;
}
}
+#endif // OCCT_MMGT_OPT_FLEXIBLE
//=======================================================================
-//function : ~Standard_MMgrFactory
-//purpose :
+//function : Allocate
+//purpose :
//=======================================================================
-
-Standard_MMgrFactory::~Standard_MMgrFactory()
+Standard::AllocatorType Standard::GetAllocatorType()
{
- if ( myFMMgr )
- myFMMgr->Purge(Standard_True);
+ return allocatorTypeInstance();
}
//=======================================================================
-// function: GetMMgr
-//
-// This static function has a purpose to wrap static holder for memory
-// manager instance.
-//
-// Wrapping holder inside a function is needed to ensure that it will
-// be initialized not later than the first call to memory manager (that
-// would be impossible to guarantee if holder was static variable on
-// global or file scope, because memory manager may be called from
-// constructors of other static objects).
-//
-// Note that at the same time we could not guarantee that the holder
-// object is destroyed after last call to memory manager, since that
-// last call may be from static Handle() object which has been initialized
-// dynamically during program execution rather than in its constructor.
-//
-// Therefore holder currently does not call destructor of the memory manager
-// but only its method Purge() with Standard_True.
-//
-// To free the memory completely, we probably could use compiler-specific
-// pragmas (such as '#pragma fini' on SUN Solaris and '#pragma init_seg' on
-// WNT MSVC++) to put destructing function in code segment that is called
-// after destructors of other (even static) objects. However, this is not
-// done by the moment since it is compiler-dependent and there is no guarantee
-// that some other object calling memory manager is not placed also in that segment...
-//
-// Note that C runtime function atexit() could not help in this problem
-// since its behaviour is the same as for destructors of static objects
-// (see ISO 14882:1998 "Programming languages -- C++" 3.6.3)
-//
-// The correct approach to deal with the problem would be to have memory manager
-// to properly control its memory allocation and caching free blocks so
-// as to release all memory as soon as it is returned to it, and probably
-// even delete itself if all memory it manages has been released and
-// last call to method Purge() was with True.
-//
-// Note that one possible method to control memory allocations could
-// be counting calls to Allocate() and Free()...
-//
+//function : Allocate
+//purpose :
//=======================================================================
-Standard_MMgrRoot* Standard_MMgrFactory::GetMMgr()
+Standard_Address Standard::Allocate(const Standard_Size theSize)
{
- static Standard_MMgrFactory aFactory;
- return aFactory.myFMMgr;
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
+ return Standard_MMgrFactory::GetMMgr()->Allocate(theSize);
+#elif defined OCCT_MMGT_OPT_NATIVE
+ Standard_Address aPtr = calloc(theSize, sizeof(char));
+ if (!aPtr)
+ throw Standard_OutOfMemory("Standard_MMgrRaw::Allocate(): malloc failed");
+ return aPtr;
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ Standard_Address aPtr = je_calloc(theSize, sizeof(char));
+ if (!aPtr)
+ throw Standard_OutOfMemory("Standard_MMgrRaw::Allocate(): malloc failed");
+ return aPtr;
+#endif // OCCT_MMGT_OPT_FLEXIBLE
}
//=======================================================================
-//function : Allocate
-//purpose :
+//function : AllocateOptimal
+//purpose :
//=======================================================================
-
-Standard_Address Standard::Allocate(const Standard_Size size)
+Standard_Address Standard::AllocateOptimal(const Standard_Size theSize)
{
- return Standard_MMgrFactory::GetMMgr()->Allocate(size);
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
+ return Standard_MMgrFactory::GetMMgr()->Allocate(theSize);
+#elif defined OCCT_MMGT_OPT_NATIVE
+ return malloc(theSize);
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ return je_malloc(theSize);
+#endif
}
//=======================================================================
//function : Free
-//purpose :
+//purpose :
//=======================================================================
-
-void Standard::Free (Standard_Address theStorage)
+void Standard::Free(Standard_Address theStorage)
{
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
Standard_MMgrFactory::GetMMgr()->Free(theStorage);
+#elif defined OCCT_MMGT_OPT_NATIVE
+ free(theStorage);
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ return je_free(theStorage);
+#endif
}
//=======================================================================
//function : Reallocate
-//purpose :
+//purpose :
//=======================================================================
-
-Standard_Address Standard::Reallocate (Standard_Address theStorage,
- const Standard_Size theSize)
+Standard_Address Standard::Reallocate(Standard_Address theStorage,
+ const Standard_Size theSize)
{
- return Standard_MMgrFactory::GetMMgr()->Reallocate (theStorage, theSize);
+ // Note that it is not possible to ensure that additional memory
+ // allocated by realloc will be cleared (so as to satisfy myClear mode);
+ // in order to do that we would need using memset..
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
+ return Standard_MMgrFactory::GetMMgr()->Reallocate(theStorage, theSize);
+#elif defined OCCT_MMGT_OPT_NATIVE
+ Standard_Address aNewStorage = (Standard_Address)realloc(theStorage, theSize);
+ if (!aNewStorage)
+ throw Standard_OutOfMemory("Standard_MMgrRaw::Reallocate(): realloc failed");
+ return aNewStorage;
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ Standard_Address newStorage = (Standard_Address)je_realloc(theStorage, theSize);
+ if (!newStorage)
+ throw Standard_OutOfMemory("Standard_MMgrRaw::Reallocate(): realloc failed");
+ return newStorage;
+#endif
}
//=======================================================================
//function : Purge
-//purpose :
+//purpose :
//=======================================================================
-
Standard_Integer Standard::Purge()
{
+#ifdef OCCT_MMGT_OPT_FLEXIBLE
return Standard_MMgrFactory::GetMMgr()->Purge();
+#else
+ return true;
+#endif // OCCT_MMGT_OPT_FLEXIBLE
}
//=======================================================================
//function : AllocateAligned
//purpose :
//=======================================================================
-
-Standard_Address Standard::AllocateAligned (const Standard_Size theSize,
- const Standard_Size theAlign)
+Standard_Address Standard::AllocateAligned(const Standard_Size theSize,
+ const Standard_Size theAlign)
{
+#if defined(OCCT_MMGT_OPT_FLEXIBLE) || defined(OCCT_MMGT_OPT_NATIVE)
#if defined(_MSC_VER)
- return _aligned_malloc (theSize, theAlign);
+ return _aligned_malloc(theSize, theAlign);
#elif defined(__ANDROID__) || defined(__QNX__)
- return memalign (theAlign, theSize);
+ return memalign(theAlign, theSize);
#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && (defined(__i386) || defined(__x86_64)))
- return _mm_malloc (theSize, theAlign);
+ return _mm_malloc(theSize, theAlign);
#else
void* aPtr;
- if (posix_memalign (&aPtr, theAlign, theSize))
+ if (posix_memalign(&aPtr, theAlign, theSize))
{
return NULL;
}
return aPtr;
#endif
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ return je_aligned_alloc(theAlign, theSize);
+#endif
}
//=======================================================================
//function : FreeAligned
//purpose :
//=======================================================================
-
-void Standard::FreeAligned (Standard_Address thePtrAligned)
+void Standard::FreeAligned(Standard_Address thePtrAligned)
{
+#if defined(OCCT_MMGT_OPT_FLEXIBLE) || defined(OCCT_MMGT_OPT_NATIVE)
#if defined(_MSC_VER)
- _aligned_free (thePtrAligned);
+ _aligned_free(thePtrAligned);
#elif defined(__ANDROID__) || defined(__QNX__)
- free (thePtrAligned);
+ free(thePtrAligned);
#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && (defined(__i386) || defined(__x86_64)))
- _mm_free (thePtrAligned);
+ _mm_free(thePtrAligned);
#else
- free (thePtrAligned);
+ free(thePtrAligned);
+#endif
+#elif defined OCCT_MMGT_OPT_JEMALLOC
+ return je_free(thePtrAligned);
#endif
}
#define _Standard_HeaderFile
#include <Standard_DefineAlloc.hxx>
-#include <Standard_Address.hxx>
-#include <Standard_Size.hxx>
#include <Standard_Integer.hxx>
-
//! The package Standard provides global memory allocator and other basic
//! services used by other OCCT components.
DEFINE_STANDARD_ALLOC
+ //! Enumiration of possible allocator types
+ enum class AllocatorType
+ {
+ NATIVE = 0,
+ OPT = 1,
+ TBB = 2,
+ JEMALLOC = 3
+ };
+
+ //! Returns default allocator type
+ Standard_EXPORT static AllocatorType GetAllocatorType();
//! Allocates memory blocks
- //! aSize - bytes to allocate
- Standard_EXPORT static Standard_Address Allocate (const Standard_Size aSize);
+ //! theSize - bytes to allocate
+ Standard_EXPORT static Standard_Address Allocate (const Standard_Size theSize);
+
+ //! Allocates memory blocks
+ //! theSize - bytes to allocate
+ Standard_EXPORT static Standard_Address AllocateOptimal (const Standard_Size theSize);
//! Deallocates memory blocks
//! @param thePtr - previously allocated memory block to be freed
}
//! Reallocates memory blocks
- //! aStorage - previously allocated memory block
- //! aNewSize - new size in bytes
- Standard_EXPORT static Standard_Address Reallocate (const Standard_Address aStorage, const Standard_Size aNewSize);
+ //! theStorage - previously allocated memory block
+ //! theNewSize - new size in bytes
+ Standard_EXPORT static Standard_Address Reallocate (const Standard_Address theStorage, const Standard_Size theNewSize);
//! Allocates aligned memory blocks.
//! Should be used with CPU instructions which require specific alignment.
};
-// include definition of handle to make it always visible
-// (put at the and of the file due to cyclic dependency between headers)
-#include <Standard_Transient.hxx>
-
#endif // _Standard_HeaderFile
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 _Standard_Address_HeaderFile
-#define _Standard_Address_HeaderFile
-
-#include <Standard_Integer.hxx>
-
-//! Returns a hash code of the given memory pointer
-//! @param thePointer the memory pointer which hash code it to be computed
-//! @param theUpperBound the upper bound of the range a resulting hash code must be within
-//! @return a value of a computed hash code, in range [1, UpperBound]
-inline Standard_Integer HashCode (const void* const thePointer, const Standard_Integer theUpperBound)
-{
- union
- {
- const void* L;
- Standard_Integer I[2];
- } U;
-
- U.I[0] = 0;
- U.I[1] = 0;
- U.L = thePointer;
-
- return HashCode (U.I[0] ^ U.I[1], theUpperBound);
-}
-
-//============================================================================
-// IsEqual : Returns Standard_True if two CString have the same value
-//============================================================================
-
-inline Standard_Boolean IsEqual(const Standard_Address One
- ,const Standard_Address Two)
-{ return One == Two; }
-
-#endif
#include <string.h>
#include <stdarg.h>
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer HashCode (const Standard_CString theString, const Standard_Integer theUpperBound)
-{
- const Standard_Integer aLength = static_cast<Standard_Integer> (strlen (theString));
-
- return HashCode (theString, aLength, theUpperBound);
-}
-
-//============================================================================
-// function : HashCodes
-// purpose :
-//============================================================================
-Standard_Integer HashCodes (const Standard_CString theString, const Standard_Integer theLength)
-{
- // compute DJB2 hash of a string
- unsigned int hash = 0;
- const Standard_Character* c = theString;
-
- for (Standard_Integer i = 0; i < theLength; ++i, ++c)
- {
- /* hash = hash * 33 ^ c */
- hash = ((hash << 5) + hash) ^ (*c);
- }
-
- return static_cast<Standard_Integer>(hash);
-}
-
//======================================================================
// Locale-independent equivalents of C functions dealing with conversion
// of string to real and vice-versa
#define vfprintf_l(theFile, theLocale, theFormat, theArgPtr) vfprintf(theFile, theFormat, theArgPtr)
#endif
-/*
-double Strtod (const char* theStr, char** theNextPtr)
-{
- return strtod_l (theStr, theNextPtr, Standard_CLocaleSentry::GetCLocale());
-}
-*/
-
double Atof (const char* theStr)
{
return Strtod (theStr, NULL);
// C++ only definitions
#ifdef __cplusplus
-#include <Standard_Integer.hxx>
-
-//! Returns bounded hash code for the null-terminated string, in the range [1, theUpperBound]
-//! @param theString the null-terminated string 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]
-Standard_EXPORT Standard_Integer HashCode (Standard_CString theString, Standard_Integer theUpperBound);
-
-//! Returns 32-bit hash code for the first theLen characters in the string theStr.
-//! The result is unbound (may be not only positive, but also negative)
-//! @param theString the string which hash code is to be computed
-//! @param theLength the length of the given string
-//! @return a computed hash code of the given string
-Standard_EXPORT Standard_Integer HashCodes (Standard_CString theString, Standard_Integer theLength);
-
-//! Returns bounded hash code for the first theLength characters in the string theString, in the range [1, theUpperBound]
-//! @param theString the string which hash code is to be computed
-//! @param theLength the length of the initial substring of the given string 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 of the given string
-inline Standard_Integer HashCode (const Standard_CString theString,
- const Standard_Integer theLength,
- const Standard_Integer theUpperBound)
-{
-// return (Abs( HashCodes( Value , Len ) ) % Upper ) + 1 ;
- return HashCode (HashCodes (theString, theLength), theUpperBound);
-}
+#include <Standard_TypeDef.hxx>
//! Returns Standard_True if two strings are equal
inline Standard_Boolean IsEqual (const Standard_CString theOne, const Standard_CString theTwo)
--- /dev/null
+// Copyright (c) 2023 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 _Standard_CStringHasher_HeaderFile
+#define _Standard_CStringHasher_HeaderFile
+
+#include <Standard_CString.hxx>
+#include <Standard_HashUtils.hxx>
+#include <Standard_TypeDef.hxx>
+
+#include <functional>
+
+class Standard_CStringHasher
+{
+public:
+
+ size_t operator()(const Standard_CString& theString) const noexcept
+ {
+ const int aLen = static_cast<int>(strlen(theString));
+ if (aLen < 4)
+ {
+ return opencascade::FNVHash::hash_combine(*theString, aLen);
+ }
+ return opencascade::hashBytes(theString, aLen);
+ }
+
+ bool operator()(const Standard_CString& theString1,
+ const Standard_CString& theString2) const noexcept
+ {
+ return strcmp(theString1, theString2) == 0;
+ }
+
+};
+
+#endif
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 <Standard_ExtString.hxx>
-#include <Standard_Type.hxx>
-
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer HashCode (const Standard_ExtString theExtString, const Standard_Integer theUpperBound)
-{
- // compute SDBM hash of an ext string
- unsigned int hash = 0;
-
- for (const Standard_ExtCharacter* c = theExtString; *c; ++c)
- {
- /* hash = hash * 33 ^ c */
- hash = (*c) + (hash << 6) + (hash << 16) - hash;
- }
-
- return HashCode (hash, theUpperBound);
-}
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//============================================================================
-//==== Title: Standard_ExtString.hxx
-//====
-//==== Implementation: This is a primitive type implementadef with typedef
-//==== typedef short* Standard_ExtString;
-//============================================================================
-
-#ifndef _Standard_ExtString_HeaderFile
-#define _Standard_ExtString_HeaderFile
-
-#include <Standard_TypeDef.hxx>
-
-//! Computes a hash code for the given wide character string, in the range [1, theUpperBound]
-//! @param theExtString the wide character string 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]
-Standard_EXPORT Standard_Integer HashCode (Standard_ExtString theExtString, Standard_Integer theUpperBound);
-
-#endif
ToCString(sguid);
aStream << sguid;
}
-
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer Standard_GUID::HashCode (const Standard_GUID& theGuid, const Standard_Integer theUpperBound)
-{
- return theGuid.Hash (theUpperBound);
-}
-
-Standard_Integer Standard_GUID::Hash(const Standard_Integer Upper) const
-{
- if (Upper < 1){
- throw Standard_RangeError("Standard_GUID::Hash: Try to apply HashCode method with negative or null argument.");
- }
-
- char sguid[Standard_GUID_SIZE_ALLOC];
- ToCString(sguid);
-
- return ::HashCode(sguid,Upper);
-}
-
-Standard_Boolean Standard_GUID::IsEqual(const Standard_GUID& aGuid1,const Standard_GUID& aGuid2)
-{
- return (aGuid1 == aGuid2);
-}
-
//! Check the format of a GUID string.
//! It checks the size, the position of the '-' and the correct size of fields.
Standard_EXPORT static Standard_Boolean CheckGUIDFormat (const Standard_CString aGuid);
-
- //! Hash function for GUID.
- Standard_EXPORT Standard_Integer Hash (const Standard_Integer Upper) const;
-
- //! Computes a hash code for the given GUID of the Standard_Integer type, in the range [1, theUpperBound]
- //! @param theGUID the GUID 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]
- Standard_EXPORT static Standard_Integer HashCode (const Standard_GUID& theGUID, Standard_Integer theUpperBound);
-
- //! Returns True when the two GUID are the same.
- Standard_EXPORT static Standard_Boolean IsEqual (const Standard_GUID& string1, const Standard_GUID& string2);
-
-
-
-
-protected:
-
-
-
+ template<class T>
+ friend struct std::hash;
private:
-
-
Standard_Integer my32b;
Standard_ExtCharacter my16b1;
Standard_ExtCharacter my16b2;
Standard_Byte my8b4;
Standard_Byte my8b5;
Standard_Byte my8b6;
-
-
};
-
+namespace std
+{
+ template <>
+ struct hash<Standard_GUID>
+ {
+ size_t operator()(const Standard_GUID& theGUID) const noexcept
+ {
+ struct GUID
+ {
+ Standard_Integer my32b;
+ Standard_ExtCharacter my16b1;
+ Standard_ExtCharacter my16b2;
+ Standard_ExtCharacter my16b3;
+ Standard_Byte my8b1;
+ Standard_Byte my8b2;
+ Standard_Byte my8b3;
+ Standard_Byte my8b4;
+ Standard_Byte my8b5;
+ Standard_Byte my8b6;
+ };
+ GUID aGUID{ theGUID.my32b, theGUID.my16b1,
+ theGUID.my16b2, theGUID.my16b3,
+ theGUID.my8b1, theGUID.my8b2,
+ theGUID.my8b3, theGUID.my8b4,
+ theGUID.my8b5, theGUID.my8b6 };
+ return opencascade::hashBytes(&aGUID, sizeof(GUID));
+ }
+ };
+}
#ifndef _Standard_Handle_HeaderFile
#define _Standard_Handle_HeaderFile
-#include <Standard_Address.hxx>
#include <Standard_Std.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Transient.hxx>
//! Define Handle() macro
#define Handle(Class) opencascade::handle<Class>
-//! Computes a hash code for the standard handle, in the range [1, theUpperBound]
-//! @param theHandle the handle 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]
-template <class TheTransientType>
-Standard_Integer HashCode (const Handle (TheTransientType) & theHandle, const Standard_Integer theUpperBound)
+#include <Standard_HashUtils.hxx>
+
+namespace std
{
- return ::HashCode (theHandle.get(), theUpperBound);
+ template <class TheTransientType>
+ struct hash<Handle(TheTransientType)>
+ {
+ size_t operator()(const Handle(TheTransientType)& theHandle) const noexcept
+ {
+ return static_cast<size_t>(reinterpret_cast<std::uintptr_t>(theHandle.get()));
+ }
+ };
}
//! For compatibility with previous versions of OCCT, define Handle_Class alias for opencascade::handle<Class>.
--- /dev/null
+// Copyright (c) 2023 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 _Standard_HashUtils_HeaderFile
+#define _Standard_HashUtils_HeaderFile
+
+#include <Standard_Macro.hxx>
+
+#include <cstdint>
+#include <cstddef>
+#include <functional>
+#include <type_traits>
+
+namespace opencascade
+{
+ //! Implementation of Murmur hash with autodetect of sizeof(size_t).
+ //!
+ //! The default value for the seed is optimal for general cases at a certain hash size.
+ namespace MurmurHash
+ {
+ uint32_t MurmurHash2A(const void* theKey, int theLen, uint32_t theSeed);
+ uint64_t MurmurHash64A(const void* theKey, int theLen, uint64_t theSeed);
+
+ template <typename T1, typename T = size_t>
+ typename std::enable_if<sizeof(T) == 8, uint64_t>::type
+ hash_combine(const T1& theValue, const int theLen = sizeof(T1), const T theSeed = 0xA329F1D3A586ULL)
+ {
+ return MurmurHash::MurmurHash64A(&theValue, theLen, theSeed);
+ }
+
+ template <typename T1, typename T = size_t>
+ typename std::enable_if<sizeof(T) != 8, T>::type
+ hash_combine(const T1& theValue, const int theLen = sizeof(T1), const T theSeed = 0xc70f6907U)
+ {
+ return static_cast<T>(MurmurHash::MurmurHash2A(&theValue, theLen, theSeed));
+ }
+
+ template <typename T = size_t>
+ constexpr typename std::enable_if<sizeof(T) == 8, uint64_t>::type optimalSeed()
+ {
+ return 0xA329F1D3A586ULL;
+ }
+
+ template <typename T = size_t>
+ constexpr typename std::enable_if<sizeof(T) != 8, T >::type optimalSeed()
+ {
+ return static_cast<T>(0xc70f6907U);
+ }
+ };
+
+ //! Implementation of FNV-1a with autodetect of sizeof(size_t).
+ //! This function should work on unsigned char, otherwise it does not
+ //! correctly implement the FNV-1a algorithm.
+ //! The existing behaviour is retained for backwards compatibility.
+ //!
+ //! The default value for the seed is optimal for general cases at a certain hash size.
+ namespace FNVHash
+ {
+ uint32_t FNVHash1A(const void* theKey, int theLen, uint32_t theSeed);
+ uint64_t FNVHash64A(const void* theKey, int theLen, uint64_t theSeed);
+
+ template <typename T1, typename T = size_t>
+ static typename std::enable_if<sizeof(T) == 8, uint64_t>::type
+ hash_combine(const T1& theValue, const int theLen = sizeof(T1), const T theSeed = 14695981039346656037ULL)
+ {
+ return FNVHash::FNVHash64A(&theValue, theLen, theSeed);
+ }
+
+ template <typename T1, typename T = size_t>
+ static typename std::enable_if<sizeof(T) != 8, T>::type
+ hash_combine(const T1& theValue, const int theLen = sizeof(T1), const T theSeed = 2166136261U)
+ {
+ return static_cast<T>(FNVHash::FNVHash1A(&theValue, theLen, theSeed));
+ }
+
+ template <typename T = size_t>
+ constexpr typename std::enable_if<sizeof(T) == 8, uint64_t>::type optimalSeed()
+ {
+ return 14695981039346656037ULL;
+ }
+
+ template <typename T = size_t>
+ constexpr typename std::enable_if<sizeof(T) != 8, T>::type optimalSeed()
+ {
+ return static_cast<T>(2166136261U);
+ }
+ };
+
+ template <typename T1, typename T = size_t>
+ T hash(const T1 theValue) noexcept
+ {
+ return opencascade::MurmurHash::hash_combine<T1, T>(theValue);
+ }
+
+ template <typename T1, typename T = size_t>
+ T hashBytes(const T1* theKey, int theLen)
+ {
+ return opencascade::MurmurHash::hash_combine<T1, T>(*theKey, theLen);
+ }
+
+ template <typename T1, typename T = size_t>
+ T hash_combine(const T1 theValue, const int theLen, const T theSeed)
+ {
+ return opencascade::MurmurHash::hash_combine<T1, T>(theValue, theLen, theSeed);
+ }
+}
+
+#include <Standard_HashUtils.lxx>
+
+#endif
--- /dev/null
+// Copyright (c) 2023 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 <cstring>
+
+namespace opencascade
+{
+namespace MurmurHash
+{
+namespace MurmurHashUtils
+{
+ inline uint64_t shift_mix(uint64_t theV)
+ {
+ return theV ^ (theV >> 47);
+ }
+
+ // Loads n bytes, where 1 <= n < 8.
+ inline uint64_t load_bytes(const char* thePnt, int theNb)
+ {
+ uint64_t aRes = 0;
+ --theNb;
+ do
+ aRes = (aRes << 8) + static_cast<unsigned char>(thePnt[theNb]);
+ while (--theNb >= 0);
+ return aRes;
+ }
+ template <typename T>
+ inline T unaligned_load(const char* thePnt)
+ {
+ T aRes;
+ memcpy(&aRes, thePnt, sizeof(aRes));
+ return aRes;
+ }
+}
+
+//=======================================================================
+//function : MurmurHash64A
+//purpose :
+//=======================================================================
+inline uint64_t MurmurHash64A(const void* theKey, int theLen, uint64_t theSeed)
+{
+ static constexpr uint64_t aMul = (((uint64_t)0xc6a4a793UL) << 32UL)
+ + (uint64_t)0x5bd1e995UL;
+ const char* const aBuf = static_cast<const char*>(theKey);
+
+ // Remove the bytes not divisible by the sizeof(uint64_t). This
+ // allows the main loop to process the data as 64-bit integers.
+ const uint64_t aLenAligned = theLen & ~(uint64_t)0x7;
+ const char* const anEnd = aBuf + aLenAligned;
+ uint64_t aHash = theSeed ^ (theLen * aMul);
+ for (const char* aPnt = aBuf; aPnt != anEnd; aPnt += 8)
+ {
+ const uint64_t aData = MurmurHashUtils::shift_mix(MurmurHashUtils::unaligned_load<uint64_t>(aPnt) * aMul) * aMul;
+ aHash ^= aData;
+ aHash *= aMul;
+ }
+ if ((theLen & 0x7) != 0)
+ {
+ const uint64_t data = MurmurHashUtils::load_bytes(anEnd, theLen & 0x7);
+ aHash ^= data;
+ aHash *= aMul;
+ }
+ aHash = MurmurHashUtils::shift_mix(aHash) * aMul;
+ aHash = MurmurHashUtils::shift_mix(aHash);
+ return aHash;
+}
+
+//=======================================================================
+//function : MurmurHash2A
+//purpose :
+//=======================================================================
+inline uint32_t MurmurHash2A(const void* theKey, int theLen, uint32_t theSeed)
+{
+ const uint32_t aMul = 0x5bd1e995;
+ uint32_t aHash = theSeed ^ theLen;
+ const char* aBuf = static_cast<const char*>(theKey);
+
+ // Mix 4 bytes at a time into the hash.
+ while (theLen >= 4)
+ {
+ uint32_t aKey = MurmurHashUtils::unaligned_load<uint32_t>(aBuf);
+ aKey *= aMul;
+ aKey ^= aKey >> 24;
+ aKey *= aMul;
+ aHash *= aMul;
+ aHash ^= aKey;
+ aBuf += 4;
+ theLen -= 4;
+ }
+
+ uint32_t aKey;
+ // Handle the last few bytes of the input array.
+ switch (theLen)
+ {
+ case 3:
+ aKey = static_cast<unsigned char>(aBuf[2]);
+ aHash ^= aKey << 16;
+ Standard_FALLTHROUGH
+ case 2:
+ aKey = static_cast<unsigned char>(aBuf[1]);
+ aHash ^= aKey << 8;
+ Standard_FALLTHROUGH
+ case 1:
+ aKey = static_cast<unsigned char>(aBuf[0]);
+ aHash ^= aKey;
+ aHash *= aMul;
+ };
+
+ // Do a few final mixes of the hash.
+ aHash ^= aHash >> 13;
+ aHash *= aMul;
+ aHash ^= aHash >> 15;
+ return aHash;
+}
+} // MurmurHash
+
+namespace FNVHash
+{
+//=======================================================================
+//function : FNVHash1A
+//purpose :
+//=======================================================================
+inline uint32_t FNVHash1A(const void* theKey, int theLen, uint32_t theSeed)
+{
+ const char* cptr = static_cast<const char*>(theKey);
+ for (; theLen; --theLen)
+ {
+ theSeed ^= static_cast<uint32_t>(*cptr++);
+ theSeed *= static_cast<uint32_t>(16777619UL);
+ }
+ return theSeed;
+}
+
+//=======================================================================
+//function : FNVHash64A
+//purpose :
+//=======================================================================
+inline uint64_t FNVHash64A(const void* theKey, int theLen, uint64_t theSeed)
+{
+ const char* cptr = static_cast<const char*>(theKey);
+ for (; theLen; --theLen)
+ {
+ theSeed ^= static_cast<uint64_t>(*cptr++);
+ theSeed *= static_cast<uint64_t>(1099511628211ULL);
+ }
+ return theSeed;
+}
+} // FNVHash
+} // opencascade
#include <Standard_Std.hxx>
#include <Standard_TypeDef.hxx>
-#include <Standard_values.h>
+
+#include <climits>
// ===============
// Inline methods
// ------------------------------------------------------------------
// IntegerFirst : Returns the minimum value of an integer
// ------------------------------------------------------------------
-inline Standard_Integer IntegerFirst()
+constexpr Standard_Integer IntegerFirst()
{ return INT_MIN; }
// ------------------------------------------------------------------
// IntegerLast : Returns the maximum value of an integer
// ------------------------------------------------------------------
-inline Standard_Integer IntegerLast()
+constexpr Standard_Integer IntegerLast()
{ return INT_MAX; }
// ------------------------------------------------------------------
// IntegerSize : Returns the size in digits of an integer
// ------------------------------------------------------------------
-inline Standard_Integer IntegerSize()
-{ return BITS(Standard_Integer); }
-
-
-//! Computes a hash code for the given value of some integer type, in range [1, theUpperBound]
-//! @tparam TheInteger the type of the integer which hash code is to be computed
-//! @param theValue the value of the TheInteger type which hash code is to be computed
-//! @param theMask the mask for the last bits of the value that are used in the computation of a hash code
-//! @param theUpperBound the upper bound of the range a computing hash code must be within
-//! @return a computed hash code, in range [1, theUpperBound]
-template <typename TheInteger>
-typename opencascade::std::enable_if<opencascade::is_integer<TheInteger>::value, Standard_Integer>::type
-IntegerHashCode (const TheInteger theValue,
- const typename opencascade::disable_deduction<TheInteger>::type theMask,
- const Standard_Integer theUpperBound)
-{
- return static_cast<Standard_Integer> ((theValue & theMask) % theUpperBound + 1);
-}
-
-//! Computes a hash code for the given value of the Standard_Integer type, in range [1, theUpperBound]
-//! @param theValue the value of the Standard_Integer type 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 range [1, theUpperBound]
-inline Standard_Integer HashCode (const Standard_Integer theValue,
- const Standard_Integer theUpperBound)
-{
- // return (Abs (theMe) % theUpper) + 1;
- return IntegerHashCode(theValue, IntegerLast(), theUpperBound);
-}
-
-// ------------------------------------------------------------------
-// IsEqual : Returns Standard_True if two integers are equal
-// ------------------------------------------------------------------
-inline Standard_Boolean IsEqual (const Standard_Integer theOne,
- const Standard_Integer theTwo)
-{
- return theOne == theTwo;
-}
-
-//! Computes a hash value for the given unsigned integer, in range [1, theUpperBound]
-//! @param theValue the unsigned integer which hash code is to be computed
-//! @param theUpperBound the upper bound of the range a computing hash code must be within
-//! @return a hash value computed for the given unsigned integer, in range [1, theUpperBound]
-inline Standard_Integer HashCode (const unsigned int theValue, const Standard_Integer theUpperBound)
-{
- return ::HashCode (static_cast<Standard_Integer> (theValue), theUpperBound);
-}
-
-//! Computes a hash code for the given value of the "long long int" type, in range [1, theUpperBound]
-//! @param theValue the value of the "long long int" type 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 range [1, theUpperBound]
-inline Standard_Integer HashCode (const long long int theValue, const Standard_Integer theUpperBound)
-{
- return IntegerHashCode(theValue, 0x7fffffffffffffff, theUpperBound);
-}
-
-#if (defined(_LP64) || defined(__LP64__) || defined(_WIN64)) || defined(__APPLE__)
-
-//! Computes a hash code for the given value of the Standard_Utf32Char type, in the range [1, theUpperBound]
-//! @tparam TheUtf32Char the type of the given value (it is Standard_Utf32Char,
-//! and must not be the same as "unsigned int", because the overload of the HashCode function
-//! for "unsigned int" type is already presented in Standard_Integer.hxx)
-//! @param theValue the value of the Standard_Utf32Char type 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]
-template <typename TheUtf32Char>
-typename opencascade::std::enable_if<!opencascade::std::is_same<Standard_Utf32Char, unsigned int>::value
- && opencascade::std::is_same<TheUtf32Char, Standard_Utf32Char>::value,
- Standard_Integer>::type
-HashCode (const TheUtf32Char theValue, const Standard_Integer theUpperBound)
-{
- return IntegerHashCode (theValue, IntegerLast(), theUpperBound);
-}
-
-// ------------------------------------------------------------------
-// IsEqual : Returns Standard_True if two integers are equal
-// ------------------------------------------------------------------
-inline Standard_Boolean IsEqual (const Standard_Utf32Char theOne,
- const Standard_Utf32Char theTwo)
-{
- return theOne == theTwo;
-}
-
-#endif
+constexpr Standard_Integer IntegerSize()
+{ return CHAR_BIT * sizeof(Standard_Integer); }
#endif
+++ /dev/null
-// Created on: 2005-03-15
-// Created by: Peter KURNEV
-// Copyright (c) 2005-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 <Standard_MMgrRaw.hxx>
-#include <Standard_OutOfMemory.hxx>
-
-//=======================================================================
-//function : Standard_MMgrRaw
-//purpose :
-//=======================================================================
-
-Standard_MMgrRaw::Standard_MMgrRaw(const Standard_Boolean aClear)
-{
- myClear = aClear;
-}
-
-//=======================================================================
-//function : Allocate
-//purpose :
-//=======================================================================
-
-Standard_Address Standard_MMgrRaw::Allocate(const Standard_Size aSize)
-{
- // the size is rounded up to 4 since some OCC classes
- // (e.g. TCollection_AsciiString) assume memory to be double word-aligned
- const Standard_Size aRoundSize = (aSize + 3) & ~0x3;
- // we use ?: operator instead of if() since it is faster :-)
- Standard_Address aPtr = ( myClear ? calloc(aRoundSize, sizeof(char)) :
- malloc(aRoundSize) );
- if ( ! aPtr )
- throw Standard_OutOfMemory("Standard_MMgrRaw::Allocate(): malloc failed");
- return aPtr;
-}
-
-//=======================================================================
-//function : Free
-//purpose :
-//=======================================================================
-
-void Standard_MMgrRaw::Free(Standard_Address theStorage)
-{
- free(theStorage);
-}
-
-//=======================================================================
-//function : Reallocate
-//purpose :
-//=======================================================================
-
-Standard_Address Standard_MMgrRaw::Reallocate(Standard_Address theStorage,
- const Standard_Size theSize)
-{
- // the size is rounded up to 4 since some OCC classes
- // (e.g. TCollection_AsciiString) assume memory to be double word-aligned
- const Standard_Size aRoundSize = (theSize + 3) & ~0x3;
- Standard_Address newStorage = (Standard_Address)realloc(theStorage, aRoundSize);
- if ( ! newStorage )
- throw Standard_OutOfMemory("Standard_MMgrRaw::Reallocate(): realloc failed");
- // Note that it is not possible to ensure that additional memory
- // allocated by realloc will be cleared (so as to satisfy myClear mode);
- // in order to do that we would need using memset...
- return newStorage;
-}
+++ /dev/null
-// Created on: 2005-03-15
-// Created by: Peter KURNEV
-// Copyright (c) 2005-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 _Standard_MMgrRaw_HeaderFile
-#define _Standard_MMgrRaw_HeaderFile
-
-#include <Standard_MMgrRoot.hxx>
-
-/**
-* Implementation of raw OCC memory manager which uses standard C
-* functions: malloc (or calloc), free and realloc
-* without any optimization
-*/
-
-class Standard_MMgrRaw : public Standard_MMgrRoot
-{
- public:
- //! Constructor; if aClear is True, the memory will be nullified
- //! upon allocation.
- Standard_EXPORT Standard_MMgrRaw(const Standard_Boolean aClear=Standard_False);
-
- //! Allocate aSize bytes
- Standard_EXPORT virtual Standard_Address Allocate(const Standard_Size aSize);
-
- //! Reallocate aPtr to the size aSize.
- //! The new pointer is returned.
- Standard_EXPORT virtual Standard_Address Reallocate(Standard_Address thePtr,
- const Standard_Size theSize);
-
- //! Free allocated memory. The pointer is nullified.
- Standard_EXPORT virtual void Free (Standard_Address thePtr);
-
- protected:
- Standard_Boolean myClear; //! Option to nullify allocated memory
-};
-
-#endif
+++ /dev/null
-// Created on: 2010-03-15
-// Created by: Sergey KUUL
-// Copyright (c) 2010-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 <Standard_MMgrTBBalloc.hxx>
-#include <Standard_OutOfMemory.hxx>
-
-// paralleling with Intel TBB
-#ifdef HAVE_TBB
-#pragma comment (lib, "tbbmalloc.lib")
-#include <tbb/scalable_allocator.h>
-using namespace tbb;
-#else
-#define scalable_malloc malloc
-#define scalable_calloc calloc
-#define scalable_realloc realloc
-#define scalable_free free
-#endif
-
-//=======================================================================
-//function : Standard_MMgrTBBalloc
-//purpose :
-//=======================================================================
-
-Standard_MMgrTBBalloc::Standard_MMgrTBBalloc(const Standard_Boolean aClear)
-{
- myClear = aClear;
-}
-
-//=======================================================================
-//function : Allocate
-//purpose :
-//=======================================================================
-
-Standard_Address Standard_MMgrTBBalloc::Allocate(const Standard_Size aSize)
-{
- // the size is rounded up to 4 since some OCC classes
- // (e.g. TCollection_AsciiString) assume memory to be double word-aligned
- const Standard_Size aRoundSize = (aSize + 3) & ~0x3;
- // we use ?: operator instead of if() since it is faster :-)
- Standard_Address aPtr = ( myClear ? scalable_calloc(aRoundSize, sizeof(char)) :
- scalable_malloc(aRoundSize) );
- if ( ! aPtr )
- throw Standard_OutOfMemory("Standard_MMgrTBBalloc::Allocate(): malloc failed");
- return aPtr;
-}
-
-//=======================================================================
-//function : Free
-//purpose :
-//=======================================================================
-
-void Standard_MMgrTBBalloc::Free (Standard_Address theStorage)
-{
- scalable_free (theStorage);
-}
-
-//=======================================================================
-//function : Reallocate
-//purpose :
-//=======================================================================
-
-Standard_Address Standard_MMgrTBBalloc::Reallocate (Standard_Address theStorage,
- const Standard_Size theSize)
-{
- // the size is rounded up to 4 since some OCC classes
- // (e.g. TCollection_AsciiString) assume memory to be double word-aligned
- const Standard_Size aRoundSize = (theSize + 3) & ~0x3;
- Standard_Address newStorage = (Standard_Address)scalable_realloc(theStorage, aRoundSize);
- if ( ! newStorage )
- throw Standard_OutOfMemory("Standard_MMgrTBBalloc::Reallocate(): realloc failed");
- // Note that it is not possible to ensure that additional memory
- // allocated by realloc will be cleared (so as to satisfy myClear mode);
- // in order to do that we would need using memset...
- return newStorage;
-}
+++ /dev/null
-// Created on: 2010-03-15
-// Created by: Sergey KUUL
-// Copyright (c) 2010-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 _Standard_MMgrTBBalloc_HeaderFile
-#define _Standard_MMgrTBBalloc_HeaderFile
-
-#include <Standard_MMgrRoot.hxx>
-
-//!
-//! Implementation of OCC memory manager which uses Intel TBB
-//! scalable allocator.
-//!
-//! On configurations where TBB is not available standard RTL functions
-//! malloc() / free() are used.
-
-class Standard_MMgrTBBalloc : public Standard_MMgrRoot
-{
- public:
- //! Constructor; if aClear is True, the memory will be nullified
- //! upon allocation.
- Standard_EXPORT Standard_MMgrTBBalloc(const Standard_Boolean aClear=Standard_False);
-
- //! Allocate aSize bytes
- Standard_EXPORT virtual Standard_Address Allocate(const Standard_Size aSize);
-
- //! Reallocate aPtr to the size aSize.
- //! The new pointer is returned.
- Standard_EXPORT virtual Standard_Address Reallocate (Standard_Address thePtr,
- const Standard_Size theSize);
-
- //! Free allocated memory
- Standard_EXPORT virtual void Free (Standard_Address thePtr);
-
- protected:
- Standard_Boolean myClear; //! Option to nullify allocated memory
-};
-
-#endif
--- /dev/null
+// Copyright (c) 2023 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 _Standard_MemoryUtils_HeaderFile
+#define _Standard_MemoryUtils_HeaderFile
+
+#include <NCollection_Allocator.hxx>
+#include <NCollection_OccAllocator.hxx>
+
+#include <memory>
+
+namespace opencascade
+{
+ template< class T, class... Args >
+ std::shared_ptr<T> make_shared(Args&&... theArgs)
+ {
+ return std::allocate_shared<T, NCollection_Allocator<T>, Args...>(NCollection_Allocator<T>(),
+ std::forward<Args>(theArgs)...);
+ }
+
+ template< class T, class... Args >
+ std::shared_ptr<T> make_oshared(const Handle(NCollection_BaseAllocator)& theAlloc,
+ Args&&... theArgs)
+ {
+ return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(NCollection_OccAllocator<T>(theAlloc),
+ std::forward<Args>(theArgs)...);
+ }
+
+ template< class T, class... Args >
+ std::shared_ptr<T> make_oshared(const NCollection_OccAllocator<T>& theAlloc,
+ Args&&... theArgs)
+ {
+ return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(theAlloc,
+ std::forward<Args>(theArgs)...);
+ }
+
+ template< class T, class... Args >
+ std::shared_ptr<T> make_oshared(NCollection_OccAllocator<T>&& theAlloc,
+ Args&&... theArgs)
+ {
+ return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(std::forward<NCollection_OccAllocator<T>(>theAlloc),
+ std::forward<Args>(theArgs)...);
+ }
+
+ template <typename T, class... Args>
+ std::unique_ptr<T> make_unique(Args&&... theArgs)
+ {
+ return std::unique_ptr<T>(new T(std::forward<Args>(theArgs)...));
+ }
+}
+
+#endif
#include <Standard_Character.hxx>
#include <Standard_ExtCharacter.hxx>
#include <Standard_CString.hxx>
-#include <Standard_ExtString.hxx>
-#include <Standard_Address.hxx>
#endif
static const Standard_Real ACosLimit = 1. + Epsilon(1.);
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer HashCode (const Standard_Real theReal, const Standard_Integer theUpperBound)
-{
- if (theUpperBound < 1)
- {
- throw Standard_RangeError ("Try to apply HashCode method with negative or null argument.");
- }
- union
- {
- Standard_Real R;
- Standard_Integer I[2];
- } U;
-
- // U.R = Abs(me); // Treat me = -0.0 ADN 27/11/97
- U.R = theReal;
-
- return HashCode (U.I[0] ^ U.I[1], theUpperBound);
-}
-
//-------------------------------------------------------------------
// ACos : Returns the value of the arc cosine of a real
//-------------------------------------------------------------------
#define _Standard_Real_HeaderFile
#include <cmath>
+#include <climits>
#include <float.h>
-#include <Standard_values.h>
-#include <Standard_math.hxx>
+
+#ifdef _MSC_VER
+#ifndef _USE_MATH_DEFINES
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#endif
+
#include <Standard_TypeDef.hxx>
// ===============================================
// Methods implemented in Standard_Real.cxx
// ==================================
-//! Computes a hash code for the given real, in the range [1, theUpperBound]
-//! @param theReal the real value 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]
-Standard_EXPORT Standard_Integer HashCode (Standard_Real theReal, Standard_Integer theUpperBound);
-
Standard_EXPORT Standard_Real ACos (const Standard_Real );
Standard_EXPORT Standard_Real ACosApprox (const Standard_Real );
Standard_EXPORT Standard_Real ASin (const Standard_Real );
//-------------------------------------------------------------------
// RealSmall : Returns the smallest positive real
//-------------------------------------------------------------------
-inline Standard_Real RealSmall()
+constexpr Standard_Real RealSmall()
{ return DBL_MIN; }
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// RealDigit : Returns the number of digits of precision in a real
//-------------------------------------------------------------------
-inline Standard_Integer RealDigits()
+constexpr Standard_Integer RealDigits()
{ return DBL_DIG; }
//-------------------------------------------------------------------
// RealEpsilon : Returns the minimum positive real such that
// 1.0 + x is not equal to 1.0
//-------------------------------------------------------------------
-inline Standard_Real RealEpsilon()
+constexpr Standard_Real RealEpsilon()
{ return DBL_EPSILON; }
//-------------------------------------------------------------------
// RealFirst : Returns the minimum negative value of a real
//-------------------------------------------------------------------
-inline Standard_Real RealFirst()
+constexpr Standard_Real RealFirst()
{ return -DBL_MAX; }
//-------------------------------------------------------------------
// RealFirst10Exp : Returns the minimum value of exponent(base 10) of
// a real.
//-------------------------------------------------------------------
-inline Standard_Integer RealFirst10Exp()
+constexpr Standard_Integer RealFirst10Exp()
{ return DBL_MIN_10_EXP; }
//-------------------------------------------------------------------
// RealLast : Returns the maximum value of a real
//-------------------------------------------------------------------
-inline Standard_Real RealLast()
+constexpr Standard_Real RealLast()
{ return DBL_MAX; }
//-------------------------------------------------------------------
// RealLast10Exp : Returns the maximum value of exponent(base 10) of
// a real.
//-------------------------------------------------------------------
-inline Standard_Integer RealLast10Exp()
+constexpr Standard_Integer RealLast10Exp()
{ return DBL_MAX_10_EXP; }
//-------------------------------------------------------------------
// RealMantissa : Returns the size in bits of the matissa part of a
// real.
//-------------------------------------------------------------------
-inline Standard_Integer RealMantissa()
+constexpr Standard_Integer RealMantissa()
{ return DBL_MANT_DIG; }
//-------------------------------------------------------------------
// RealRadix : Returns the radix of exponent representation
//-------------------------------------------------------------------
-inline Standard_Integer RealRadix()
+constexpr Standard_Integer RealRadix()
{ return FLT_RADIX; }
//-------------------------------------------------------------------
// RealSize : Returns the size in bits of an integer
//-------------------------------------------------------------------
-inline Standard_Integer RealSize()
-{ return BITS(Standard_Real); }
+constexpr Standard_Integer RealSize()
+{ return CHAR_BIT * sizeof(Standard_Real); }
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 <Standard_ShortReal.hxx>
-#include <Standard_NullValue.hxx>
-
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer HashCode (const Standard_ShortReal theShortReal, const Standard_Integer theUpperBound)
-{
- if (theUpperBound < 1)
- {
- throw Standard_RangeError ("Try to apply HashCode method with negative or null argument.");
- }
- union
- {
- Standard_ShortReal R;
- Standard_Integer I;
- } U;
- U.R = theShortReal;
-
- return HashCode (U.I, theUpperBound);
-}
#define _Standard_ShortReal_HeaderFile
#include <cmath>
+#include <climits>
#include <float.h>
-#include <Standard_values.h>
#include <Standard_TypeDef.hxx>
// *********************************** //
//-------------------------------------------------------------------
// ShortRealSmall : Returns the smallest positive ShortReal
//-------------------------------------------------------------------
-inline Standard_ShortReal ShortRealSmall()
+constexpr Standard_ShortReal ShortRealSmall()
{ return FLT_MIN; }
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// ShortRealDigit : Returns the number of digits of precision in a ShortReal
//-------------------------------------------------------------------
-inline Standard_Integer ShortRealDigits()
+constexpr Standard_Integer ShortRealDigits()
{ return FLT_DIG; }
//-------------------------------------------------------------------
// ShortRealEpsilon : Returns the minimum positive ShortReal such that
// 1.0 + x is not equal to 1.0
//-------------------------------------------------------------------
-inline Standard_ShortReal ShortRealEpsilon()
+constexpr Standard_ShortReal ShortRealEpsilon()
{ return FLT_EPSILON; }
//-------------------------------------------------------------------
// ShortRealFirst10Exp : Returns the minimum value of exponent(base 10) of
// a ShortReal.
//-------------------------------------------------------------------
-inline Standard_Integer ShortRealFirst10Exp()
+constexpr Standard_Integer ShortRealFirst10Exp()
{ return FLT_MIN_10_EXP; }
//-------------------------------------------------------------------
// ShortRealLast : Returns the maximum value of a ShortReal
//-------------------------------------------------------------------
-inline Standard_ShortReal ShortRealLast()
+constexpr Standard_ShortReal ShortRealLast()
{ return FLT_MAX; }
//-------------------------------------------------------------------
// ShortRealLast10Exp : Returns the maximum value of exponent(base 10) of
// a ShortReal.
//-------------------------------------------------------------------
-inline Standard_Integer ShortRealLast10Exp()
+constexpr Standard_Integer ShortRealLast10Exp()
{ return FLT_MAX_10_EXP; }
//-------------------------------------------------------------------
// ShortRealMantissa : Returns the size in bits of the matissa part of a
// ShortReal.
//-------------------------------------------------------------------
-inline Standard_Integer ShortRealMantissa()
+constexpr Standard_Integer ShortRealMantissa()
{ return FLT_MANT_DIG; }
//-------------------------------------------------------------------
// ShortRealRadix : Returns the radix of exponent representation
//-------------------------------------------------------------------
-inline Standard_Integer ShortRealRadix()
+constexpr Standard_Integer ShortRealRadix()
{ return FLT_RADIX; }
//-------------------------------------------------------------------
// ShortRealSize : Returns the size in bits of an integer
//-------------------------------------------------------------------
-inline Standard_Integer ShortRealSize()
-{ return BITS(Standard_ShortReal); }
+constexpr Standard_Integer ShortRealSize()
+{ return CHAR_BIT * sizeof(Standard_ShortReal); }
//-------------------------------------------------------------------
// Max : Returns the maximum value of two ShortReals
}
}
-// ===============================================
-// Methods from Standard_Entity class which are redefined:
-// - Hascode
-// - IsEqual
-// ===============================================
-
-// ==================================
-// Methods implemented in Standard_ShortReal.cxx
-// ==================================
-
-//! Computes a hash code for the given short real, in the range [1, theUpperBound]
-//! @param theShortReal the short real value 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]
-Standard_EXPORT Standard_Integer HashCode (Standard_ShortReal theShortReal, Standard_Integer theUpperBound);
-
-//-------------------------------------------------------------------
-// IsEqual : Returns Standard_True if two ShortReals are equal
-//-------------------------------------------------------------------
-inline Standard_Boolean IsEqual (const Standard_ShortReal Value1,
- const Standard_ShortReal Value2)
-{ return Abs((Value1 - Value2)) < ShortRealSmall(); }
-
#endif
+++ /dev/null
-// Created on: 2006-08-22
-// Created by: Alexander GRIGORIEV
-// Copyright (c) 2006-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 _Standard_Size_HeaderFile
-#define _Standard_Size_HeaderFile
-
-#include <Standard_Integer.hxx>
-
-// msv 26.05.2009: add HashCode and IsEqual functions
-
-//! Computes a hash code for the given value of the Standard_Size type, in the range [1, theUpperBound]
-//! @tparam TheSize the type of the given value (it is Standard_Size,
-//! and must not be the same as "unsigned int", because the overload of the HashCode function
-//! for "unsigned int" type is already presented in Standard_Integer.hxx)
-//! @param theValue the value of the Standard_Size type 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]
-template <typename TheSize>
-typename opencascade::std::enable_if<!opencascade::std::is_same<Standard_Size, unsigned int>::value
- && opencascade::std::is_same<TheSize, Standard_Size>::value,
- Standard_Integer>::type
-HashCode (const TheSize theValue, const Standard_Integer theUpperBound)
-{
- Standard_Size aKey = ~theValue + (theValue << 18);
- aKey ^= (aKey >> 31);
- aKey *= 21;
- aKey ^= (aKey >> 11);
- aKey += (aKey << 6);
- aKey ^= (aKey >> 22);
- return IntegerHashCode(aKey, IntegerLast(), theUpperBound);
-}
-
-// ------------------------------------------------------------------
-// IsEqual : Returns Standard_True if two values are equal
-// ------------------------------------------------------------------
-inline Standard_Boolean IsEqual(const Standard_Size One,
- const Standard_Size Two)
-{
- return One == Two;
-}
-
-#endif
#ifndef Standard_ThreadId_HeaderFile
#define Standard_ThreadId_HeaderFile
-#include <Standard_Size.hxx>
// Platform-independent definition of the thread identifier type
typedef Standard_Size Standard_ThreadId;
// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 1999-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
-#include <Standard_Atomic.hxx>
+
+#include <Standard_Type.hxx>
#include <Standard_CString.hxx>
#include <Standard_ProgramError.hxx>
-void Standard_Transient::Delete() const
-{
- delete this;
-}
-
const Handle(Standard_Type)& Standard_Transient::get_type_descriptor ()
{
return opencascade::type_instance<Standard_Transient>::get();
throw Standard_ProgramError("Attempt to create handle to object created in stack, not yet constructed, or destroyed");
return const_cast<Standard_Transient*> (this);
}
-
-// Increment reference counter
-void Standard_Transient::IncrementRefCounter() const
-{
- Standard_Atomic_Increment (&myRefCount_);
-}
-
-// Decrement reference counter
-Standard_Integer Standard_Transient::DecrementRefCounter() const
-{
- return Standard_Atomic_Decrement(&myRefCount_);
-}
// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 1999-2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#include <Standard_DefineAlloc.hxx>
#include <Standard_PrimitiveTypes.hxx>
+#include <atomic>
+
class Standard_Type;
-namespace opencascade {
+namespace opencascade
+{
template <class T> class handle;
}
//! Destructor must be virtual
virtual ~Standard_Transient() {}
- //! Memory deallocator for transient classes
- Standard_EXPORT virtual void Delete() const;
-
public:
//!@name Support of run-time type information (RTTI)
typedef void base_type;
- static const char* get_type_name () { return "Standard_Transient"; }
+ static constexpr const char* get_type_name () { return "Standard_Transient"; }
//! Returns type descriptor of Standard_Transient class
Standard_EXPORT static const opencascade::handle<Standard_Type>& get_type_descriptor ();
//!@name Reference counting, for use by handle<>
//! Get the reference counter of this object
- Standard_Integer GetRefCount() const { return myRefCount_; }
+ inline Standard_Integer GetRefCount() const noexcept { return myRefCount_; }
//! Increments the reference counter of this object
- Standard_EXPORT void IncrementRefCounter() const;
+ inline void IncrementRefCounter() noexcept
+ {
+ myRefCount_.operator++();
+ }
//! Decrements the reference counter of this object;
//! returns the decremented value
- Standard_EXPORT Standard_Integer DecrementRefCounter() const;
+ inline Standard_Integer DecrementRefCounter() noexcept
+ {
+ return myRefCount_.operator--();
+ }
+
+ //! Memory deallocator for transient classes
+ virtual void Delete() const
+ {
+ delete this;
+ }
private:
//! Reference counter.
//! Note use of underscore, aimed to reduce probability
//! of conflict with names of members of derived classes.
- mutable volatile Standard_Integer myRefCount_;
+ std::atomic_int myRefCount_;
};
-
-//! Computes a hash code for the given transient object, in the range [1, theUpperBound]
-//! @param theTransientObject the transient object 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]
-inline Standard_Integer HashCode (const Standard_Transient* const theTransientObject,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode (static_cast<const void*> (theTransientObject), theUpperBound);
-}
-
//! Definition of Handle_Standard_Transient as typedef for compatibility
typedef opencascade::handle<Standard_Transient> Handle_Standard_Transient;
#include <Standard_Type.hxx>
#include <Standard_Mutex.hxx>
+#include <Standard_Assert.hxx>
-#include <NCollection_DataMap.hxx>
+#include <unordered_map>
IMPLEMENT_STANDARD_RTTIEXT(Standard_Type,Standard_Transient)
//============================================================================
-namespace {
-static Standard_CString copy_string (const char* theString)
-{
- size_t aLength = strlen (theString);
- char* aResult = static_cast<char*> (Standard::Allocate (aLength + 1));
- strncpy (aResult, theString, aLength + 1); //including null-character
- return aResult;
-}
-}
-
-Standard_Type::Standard_Type (const char* theSystemName,
+Standard_Type::Standard_Type (const std::type_info& theInfo,
const char* theName,
Standard_Size theSize,
const Handle(Standard_Type)& theParent) :
- mySystemName(copy_string (theSystemName)),
- myName(copy_string (theName)),
+ myInfo(theInfo),
+ myName(theName),
mySize(theSize),
myParent(theParent)
{
//============================================================================
namespace {
- // Value-based hasher for plain C string (char*)
- struct CStringHasher
- {
- //! Computes a hash code of the given Standard_CString, in the range [1, theUpperBound]
- //! @param theKey the key 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 Standard_CString& theKey, const Standard_Integer theUpperBound)
- {
- return ::HashCode (theKey, theUpperBound);
- }
- static bool IsEqual (const Standard_CString& theKey1, const Standard_CString& theKey2)
- {
- return ! strcmp (theKey1, theKey2);
- }
- };
-
// Map of string to type
- typedef NCollection_DataMap<Standard_CString, Standard_Type*, CStringHasher> registry_type;
+ typedef std::unordered_map<std::type_index, Standard_Type*> registry_type;
// Registry is made static in the function to ensure that it gets
// initialized by the time of first access
Handle(Standard_Type) theType = STANDARD_TYPE(Standard_Transient);
}
-Standard_Type* Standard_Type::Register (const char* theSystemName, const char* theName,
+Standard_Type* Standard_Type::Register (const std::type_info& theInfo, const char* theName,
Standard_Size theSize, const Handle(Standard_Type)& theParent)
{
// Access to registry is protected by mutex; it should not happen often because
// return existing descriptor if already in the registry
registry_type& aRegistry = GetRegistry();
Standard_Type* aType = 0;
- if (aRegistry.Find (theSystemName, aType))
- return aType;
+ auto anIter = aRegistry.find(theInfo);
+ if (anIter != aRegistry.end())
+ return anIter->second;
// else create a new descriptor
- aType = new Standard_Type (theSystemName, theName, theSize, theParent);
+ aType = new Standard_Type (theInfo, theName, theSize, theParent);
// then add it to registry and return (the reference to the handle stored in the registry)
- aRegistry.Bind (aType->mySystemName, aType);
-
-// std::cout << "Registering " << theSystemName << ": " << aRegistry.Extent() << std::endl;
-
+ aRegistry.emplace(theInfo, aType);
return aType;
}
{
// remove descriptor from the registry
registry_type& aRegistry = GetRegistry();
- Standard_ASSERT(aRegistry.UnBind (mySystemName), "Standard_Type::~Standard_Type() cannot find itself in registry",);
-
-// std::cout << "Unregistering " << mySystemName << ": " << aRegistry.Extent() << std::endl;
- Standard::Free (mySystemName);
- Standard::Free (myName);
+ Standard_ASSERT(aRegistry.erase(myInfo) > 0, "Standard_Type::~Standard_Type() cannot find itself in registry",);
}
#include <Standard_OStream.hxx>
#include <typeinfo>
+#include <typeindex>
// Auxiliary tools to check at compile time that class declared as base in
// DEFINE_STANDARD_RTTI* macro is actually a base class.
public:
//! Returns the system type name of the class (typeinfo.name)
- Standard_CString SystemName() const { return mySystemName; }
+ Standard_CString SystemName() const { return myInfo.name(); }
//! Returns the given name of the class type (get_type_name)
Standard_CString Name() const { return myName; }
//! Register a type; returns either new or existing descriptor.
//!
- //! @param theSystemName name of the class as returned by typeid(class).name()
+ //! @param theInfo object stores system name of the class
//! @param theName name of the class to be stored in Name field
//! @param theSize size of the class instance
//! @param theParent base class in the Transient hierarchy
//!
//! Note that this function is intended for use by opencascade::type_instance only.
Standard_EXPORT static
- Standard_Type* Register (const char* theSystemName, const char* theName,
+ Standard_Type* Register (const std::type_info& theInfo, const char* theName,
Standard_Size theSize, const Handle(Standard_Type)& theParent);
//! Destructor removes the type from the registry
private:
//! Constructor is private
- Standard_Type (const char* theSystemName, const char* theName,
+ Standard_Type (const std::type_info& theInfo, const char* theName,
Standard_Size theSize, const Handle(Standard_Type)& theParent);
private:
- Standard_CString mySystemName; //!< System name of the class (typeinfo.name)
+ std::type_index myInfo; //!< Object to store system name of the class
Standard_CString myName; //!< Given name of the class
Standard_Size mySize; //!< Size of the class instance, in bytes
Handle(Standard_Type) myParent; //!< Type descriptor of parent class
// static variable inside function ensures that descriptors
// are initialized in correct sequence
static Handle(Standard_Type) anInstance =
- Standard_Type::Register (typeid(T).name(), T::get_type_name(), sizeof(T),
+ Standard_Type::Register (typeid(T), T::get_type_name(), sizeof(T),
type_instance<typename T::base_type>::get());
return anInstance;
}
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 <Standard_math.hxx>
-
-// MSVC versions prior to 12 did not provided acosh, asinh, atanh functions in standard library
-#if defined(_MSC_VER) && (_MSC_VER < 1800)
-
-Standard_EXPORT double __cdecl acosh( double X)
-{
- double res;
- res = log(X + sqrt(X * X - 1));
- return res;
-};
-Standard_EXPORT double __cdecl asinh( double X)
-{
- double res;
-// Modified by Sergey KHROMOV - Mon Nov 11 16:27:11 2002 Begin
-// Correction of the formula to avoid numerical problems.
-// res = log(X + sqrt(X * X + 1));
- if (X > 0.)
- res = log(X + sqrt(X * X + 1));
- else
- res = -log(sqrt(X * X + 1) - X);
-// Modified by Sergey KHROMOV - Mon Nov 11 16:27:13 2002 End
- return res;
-};
-Standard_EXPORT double __cdecl atanh( double X)
-{
- double res;
- res = log((1 + X) / (1 - X)) / 2;
- return res;
-};
-
-#endif
+++ /dev/null
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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 Standard_math_HeaderFile
-#define Standard_math_HeaderFile
-
-#ifndef _Standard_Macro_HeaderFile
-#include <Standard_Macro.hxx>
-#endif
-
-#ifdef _MSC_VER
-
-#ifndef _USE_MATH_DEFINES
-#define _USE_MATH_DEFINES
-#endif
-
-#include <math.h>
-
-// MSVC versions prior to 12 did not provided acosh, asinh, atanh functions in standard library
-#if _MSC_VER < 1800
-Standard_EXPORT double __cdecl acosh ( double );
-Standard_EXPORT double __cdecl asinh ( double );
-Standard_EXPORT double __cdecl atanh ( double );
-#endif
-
-#endif /* _MSC_VER */
-
-
-#endif
+++ /dev/null
-/*
- Copyright (c) 1991-1999 Matra Datavision
- Copyright (c) 1999-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 _Standard_values_HeaderFile
-# define _Standard_values_HeaderFile
-
-#if defined(_MSC_VER)
-# include <limits>
-#else
-# include <limits.h>
-#endif
-
-#if defined (__hpux) || defined (HPUX)
-# ifdef MAXINT
-# undef MAXINT
-# endif
-#endif
-
-#ifndef BITSPERBYTE
-# define BITSPERBYTE CHAR_BIT
-#endif
-#ifndef BITS
-# define BITS(type) (BITSPERBYTE * sizeof(type))
-#endif
-
-#endif
-
class StdObjMgt_MapOfInstantiators
: public NCollection_DataMap<TCollection_AsciiString,
- StdObjMgt_Persistent::Instantiator,
- TCollection_AsciiString>
+ StdObjMgt_Persistent::Instantiator>
{
public:
template <class Persistent>
void Bind (const TCollection_AsciiString& theTypeName)
{
NCollection_DataMap<TCollection_AsciiString,
- StdObjMgt_Persistent::Instantiator,
- TCollection_AsciiString>
+ StdObjMgt_Persistent::Instantiator>
::Bind (theTypeName, Persistent::template Instantiate<Persistent>);
}
#include <StdStorage_Root.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(StdStorage_Root), TCollection_AsciiString> StdStorage_MapOfRoots;
-typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(StdStorage_Root), TCollection_AsciiString>::Iterator StdStorage_DataMapIteratorOfMapOfRoots;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(StdStorage_Root)> StdStorage_MapOfRoots;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(StdStorage_Root)>::Iterator StdStorage_DataMapIteratorOfMapOfRoots;
#endif // StdStorage_MapOfRoots_HeaderFile
#include <Standard_Integer.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TCollection_AsciiString, Standard_Integer, TCollection_AsciiString> StdStorage_MapOfTypes;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString, Standard_Integer> StdStorage_MapOfTypes;
#endif
e1 = e1->Next();
}
// d abord effacer les next en cours ...
- NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator iter(dic);
- for (; iter.More(); iter.Next()) {
+ for (NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator iter(dic);
+ iter.More(); iter.Next()) {
e1 = GetCasted(StepData_FreeFormEntity,iter.Value());
if (!e1.IsNull()) e1->SetNext(e2);
}
// ... puis les remettre dans l ordre
e1.Nullify();
- for (iter.Reset(); iter.More(); iter.Next()) {
+ for (NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator iter(dic);
+ iter.More(); iter.Next()) {
e2 = GetCasted(StepData_FreeFormEntity,iter.Value());
if (!e1.IsNull()) e1->SetNext(e2);
e1 = e2;
StepToTopoDS_Builder.cxx
StepToTopoDS_Builder.hxx
StepToTopoDS_BuilderError.hxx
-StepToTopoDS_CartesianPointHasher.cxx
-StepToTopoDS_CartesianPointHasher.hxx
StepToTopoDS_DataMapIteratorOfDataMapOfRI.hxx
StepToTopoDS_DataMapIteratorOfDataMapOfRINames.hxx
StepToTopoDS_DataMapIteratorOfDataMapOfTRI.hxx
StepToTopoDS_PointEdgeMap.hxx
StepToTopoDS_PointPair.cxx
StepToTopoDS_PointPair.hxx
-StepToTopoDS_PointPairHasher.cxx
-StepToTopoDS_PointPairHasher.hxx
StepToTopoDS_PointVertexMap.hxx
StepToTopoDS_Root.cxx
StepToTopoDS_Root.hxx
+++ /dev/null
-// Created on: 1993-08-30
-// Created by: Martine LANGLOIS
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 <StepGeom_CartesianPoint.hxx>
-#include <StepToTopoDS_CartesianPointHasher.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-Standard_Integer StepToTopoDS_CartesianPointHasher::HashCode (const Handle (StepGeom_CartesianPoint)
- & theCartesianPoint,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode (theCartesianPoint, theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-
-Standard_Boolean StepToTopoDS_CartesianPointHasher::IsEqual
- (const Handle(StepGeom_CartesianPoint)& K1,
- const Handle(StepGeom_CartesianPoint)& K2)
-{
- return (K1 == K2);
-}
+++ /dev/null
-// Created on: 1993-08-30
-// Created by: Martine LANGLOIS
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 _StepToTopoDS_CartesianPointHasher_HeaderFile
-#define _StepToTopoDS_CartesianPointHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Standard_Integer.hxx>
-class StepGeom_CartesianPoint;
-
-
-
-class StepToTopoDS_CartesianPointHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the cartesian point, in the range [1, theUpperBound]
- //! @param theCartesianPoint the cartesian point 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]
- Standard_EXPORT static Standard_Integer HashCode (const Handle (StepGeom_CartesianPoint) & theCartesianPoint,
- Standard_Integer theUpperBound);
-
- //! Returns True when the two CartesianPoint are the same
- Standard_EXPORT static Standard_Boolean IsEqual (const Handle(StepGeom_CartesianPoint)& K1, const Handle(StepGeom_CartesianPoint)& K2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-
-
-
-
-
-#endif // _StepToTopoDS_CartesianPointHasher_HeaderFile
#include <StepRepr_RepresentationItem.hxx>
#include <TopoDS_Shape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(StepRepr_RepresentationItem),TopoDS_Shape,TColStd_MapTransientHasher> StepToTopoDS_DataMapOfRI;
-typedef NCollection_DataMap<Handle(StepRepr_RepresentationItem),TopoDS_Shape,TColStd_MapTransientHasher>::Iterator StepToTopoDS_DataMapIteratorOfDataMapOfRI;
+typedef NCollection_DataMap<Handle(StepRepr_RepresentationItem),TopoDS_Shape> StepToTopoDS_DataMapOfRI;
+typedef NCollection_DataMap<Handle(StepRepr_RepresentationItem),TopoDS_Shape>::Iterator StepToTopoDS_DataMapIteratorOfDataMapOfRI;
#endif
#include <TopoDS_Shape.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,TopoDS_Shape,TCollection_AsciiString> StepToTopoDS_DataMapOfRINames;
-typedef NCollection_DataMap<TCollection_AsciiString,TopoDS_Shape,TCollection_AsciiString>::Iterator StepToTopoDS_DataMapIteratorOfDataMapOfRINames;
+typedef NCollection_DataMap<TCollection_AsciiString,TopoDS_Shape> StepToTopoDS_DataMapOfRINames;
+typedef NCollection_DataMap<TCollection_AsciiString,TopoDS_Shape>::Iterator StepToTopoDS_DataMapIteratorOfDataMapOfRINames;
#endif
#include <StepShape_TopologicalRepresentationItem.hxx>
#include <TopoDS_Shape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(StepShape_TopologicalRepresentationItem),TopoDS_Shape,TColStd_MapTransientHasher> StepToTopoDS_DataMapOfTRI;
-typedef NCollection_DataMap<Handle(StepShape_TopologicalRepresentationItem),TopoDS_Shape,TColStd_MapTransientHasher>::Iterator StepToTopoDS_DataMapIteratorOfDataMapOfTRI;
+typedef NCollection_DataMap<Handle(StepShape_TopologicalRepresentationItem),TopoDS_Shape> StepToTopoDS_DataMapOfTRI;
+typedef NCollection_DataMap<Handle(StepShape_TopologicalRepresentationItem),TopoDS_Shape>::Iterator StepToTopoDS_DataMapIteratorOfDataMapOfTRI;
#endif
#include <StepToTopoDS_PointPair.hxx>
#include <TopoDS_Edge.hxx>
-#include <StepToTopoDS_PointPairHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<StepToTopoDS_PointPair,TopoDS_Edge,StepToTopoDS_PointPairHasher> StepToTopoDS_PointEdgeMap;
-typedef NCollection_DataMap<StepToTopoDS_PointPair,TopoDS_Edge,StepToTopoDS_PointPairHasher>::Iterator StepToTopoDS_DataMapIteratorOfPointEdgeMap;
+typedef NCollection_DataMap<StepToTopoDS_PointPair,TopoDS_Edge> StepToTopoDS_PointEdgeMap;
+typedef NCollection_DataMap<StepToTopoDS_PointPair,TopoDS_Edge>::Iterator StepToTopoDS_DataMapIteratorOfPointEdgeMap;
#endif
#include <StepGeom_CartesianPoint.hxx>
#include <StepToTopoDS_PointPair.hxx>
-#include <StepToTopoDS_PointPairHasher.hxx>
//=======================================================================
//function : StepToTopoDS_PointPair
class StepGeom_CartesianPoint;
-
//! Stores a pair of Points from step
class StepToTopoDS_PointPair
{
Standard_EXPORT StepToTopoDS_PointPair(const Handle(StepGeom_CartesianPoint)& P1, const Handle(StepGeom_CartesianPoint)& P2);
+ const Handle(StepGeom_CartesianPoint)& GetPoint1() const
+ {
+ return myP1;
+ }
-friend class StepToTopoDS_PointPairHasher;
+ const Handle(StepGeom_CartesianPoint)& GetPoint2() const
+ {
+ return myP2;
+ }
+ bool operator==(const StepToTopoDS_PointPair& thePointPair) const
+ {
+ return (((myP1 == thePointPair.myP1) && (myP2 == thePointPair.myP2)) ||
+ ((myP1 == thePointPair.myP2) && (myP2 == thePointPair.myP1)));
+ }
protected:
};
+namespace std
+{
+ template <>
+ struct hash<StepToTopoDS_PointPair>
+ {
+ size_t operator()(const StepToTopoDS_PointPair& thePointPair) const noexcept
+ {
+ // Combine two int values into a single hash value.
+ size_t aCombination[2];
+ aCombination[0] = std::hash<Handle(StepGeom_CartesianPoint)>{}(thePointPair.GetPoint1());
+ aCombination[1] = std::hash<Handle(StepGeom_CartesianPoint)>{}(thePointPair.GetPoint2());
+ if (aCombination[0] > aCombination[1])
+ {
+ std::swap(aCombination[0], aCombination[1]);
+ }
+ return opencascade::hashBytes(aCombination, sizeof(aCombination));
+ }
+ };
+}
+++ /dev/null
-// Created on: 1993-08-06
-// Created by: Martine LANGLOIS
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 <StepGeom_CartesianPoint.hxx>
-#include <StepToTopoDS_PointPair.hxx>
-#include <StepToTopoDS_PointPairHasher.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-Standard_Integer StepToTopoDS_PointPairHasher::HashCode (const StepToTopoDS_PointPair& thePointPair,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode (::HashCode (thePointPair.myP1, theUpperBound) + ::HashCode (thePointPair.myP2, theUpperBound),
- theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-
-Standard_Boolean StepToTopoDS_PointPairHasher::IsEqual
- (const StepToTopoDS_PointPair& P1,
- const StepToTopoDS_PointPair& P2)
-{
- return (((P1.myP1 == P2.myP1) && (P1.myP2 == P2.myP2)) ||
- ((P1.myP1 == P2.myP2) && (P1.myP2 == P2.myP1)));
-}
+++ /dev/null
-// Created on: 1993-08-06
-// Created by: Martine LANGLOIS
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 _StepToTopoDS_PointPairHasher_HeaderFile
-#define _StepToTopoDS_PointPairHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-class StepToTopoDS_PointPair;
-
-
-
-class StepToTopoDS_PointPairHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the point pair, in the range [1, theUpperBound]
- //! @param thePointPair the point pair 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]
- Standard_EXPORT static Standard_Integer HashCode (const StepToTopoDS_PointPair& thePointPair, Standard_Integer theUpperBound);
-
- //! Returns True when the two PointPair are the same
- Standard_EXPORT static Standard_Boolean IsEqual (const StepToTopoDS_PointPair& K1, const StepToTopoDS_PointPair& K2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-
-
-
-
-
-#endif // _StepToTopoDS_PointPairHasher_HeaderFile
#include <StepGeom_CartesianPoint.hxx>
#include <TopoDS_Vertex.hxx>
-#include <StepToTopoDS_CartesianPointHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(StepGeom_CartesianPoint),TopoDS_Vertex,StepToTopoDS_CartesianPointHasher> StepToTopoDS_PointVertexMap;
-typedef NCollection_DataMap<Handle(StepGeom_CartesianPoint),TopoDS_Vertex,StepToTopoDS_CartesianPointHasher>::Iterator StepToTopoDS_DataMapIteratorOfPointVertexMap;
+typedef NCollection_DataMap<Handle(StepGeom_CartesianPoint),TopoDS_Vertex> StepToTopoDS_PointVertexMap;
+typedef NCollection_DataMap<Handle(StepGeom_CartesianPoint),TopoDS_Vertex>::Iterator StepToTopoDS_DataMapIteratorOfPointVertexMap;
#endif
#include <Storage_TypedCallBack.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_TypedCallBack),TCollection_AsciiString> Storage_MapOfCallBack;
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_TypedCallBack),TCollection_AsciiString>::Iterator Storage_DataMapIteratorOfMapOfCallBack;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_TypedCallBack)> Storage_MapOfCallBack;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_TypedCallBack)>::Iterator Storage_DataMapIteratorOfMapOfCallBack;
#endif
#include <TCollection_AsciiString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_Root),TCollection_AsciiString> Storage_MapOfPers;
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_Root),TCollection_AsciiString>::Iterator Storage_DataMapIteratorOfMapOfPers;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_Root)> Storage_MapOfPers;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(Storage_Root)>::Iterator Storage_DataMapIteratorOfMapOfPers;
#endif
#include <Standard_Integer.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TCollection_AsciiString,Standard_Integer,TCollection_AsciiString> Storage_PType;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString,Standard_Integer> Storage_PType;
#endif
// containing migration types table: oldtype - newtype
//=======================================================================
Standard_Boolean Storage_Schema::CheckTypeMigration(
- const TCollection_AsciiString& oldName,
- TCollection_AsciiString& newName)
+ const TCollection_AsciiString& oldName,
+ TCollection_AsciiString& newName)
{
static Standard_Boolean isChecked(Standard_False);
static DataMapOfAStringAString aDMap;
Standard_Boolean aMigration(Standard_False);
-
- if(!isChecked) {
+
+ if (!isChecked)
+ {
isChecked = Standard_True;
-// TCollection_AsciiString aFileName = getenv("CSF_MIGRATION_TYPES");
+ // TCollection_AsciiString aFileName = getenv("CSF_MIGRATION_TYPES");
OSD_Environment csf(TCollection_AsciiString("CSF_MIGRATION_TYPES"));
TCollection_AsciiString aFileName = csf.Value();
- if(aFileName.Length() > 0) {
- OSD_Path aPath(aFileName,OSD_Default);
- OSD_File aFile;
- aFile.SetPath(aPath);
- if(aFile.Exists()) {
- OSD_Protection aProt(OSD_R,OSD_R,OSD_R,OSD_R);
- aFile.Open(OSD_ReadOnly, aProt);
- if(aFile.IsOpen() && aFile.IsReadable()) {
- TCollection_AsciiString aLine;
- Standard_Integer aNbReaded(0);
- for (;;) {
- aFile.ReadLine(aLine, 80, aNbReaded);
- if(aFile.IsAtEnd() || !aNbReaded) {
- aFile.Close();
- break;
- }
+ OSD_File aFile;
+ OSD_Path aPath(aFileName, OSD_Default);
+ aFile.SetPath(aPath);
+ if (aFile.Exists())
+ {
+ OSD_Protection aProt(OSD_R, OSD_R, OSD_R, OSD_R);
+ aFile.Open(OSD_ReadOnly, aProt);
+ if (aFile.IsOpen() && aFile.IsReadable())
+ {
+ TCollection_AsciiString aLine;
+ Standard_Integer aNbReaded(0);
+ for (;;)
+ {
+ aFile.ReadLine(aLine, 80, aNbReaded);
+ if (aFile.IsAtEnd() || !aNbReaded)
+ {
+ aFile.Close();
+ break;
+ }
#ifdef OCCT_DEBUG
- std::cout << "Storage_Sheme:: Line: = " << aLine <<std::endl;
+ std::cout << "Storage_Sheme:: Line: = " << aLine << std::endl;
#endif
- TCollection_AsciiString aKey, aValue;
- aKey = aLine.Token();
- aValue = aLine.Token(" \t\n\r", 2);
- aDMap.Bind(aKey, aValue);
- }
+ TCollection_AsciiString aKey, aValue;
+ aKey = aLine.Token();
+ aValue = aLine.Token(" \t\n\r", 2);
+ aDMap.Bind(aKey, aValue);
}
}
- else
- {
- // hard-code migration table for known types
- aDMap.Bind("TDataStd_Shape", "TDataXtd_Shape");
- aDMap.Bind("TDataStd_Constraint", "TDataXtd_Constraint");
- aDMap.Bind("TDataStd_Geometry", "TDataXtd_Geometry");
- aDMap.Bind("TDataStd_Axis", "TDataXtd_Axis");
- aDMap.Bind("TDataStd_Point", "TDataXtd_Point");
- aDMap.Bind("TDataStd_Plane", "TDataXtd_Plane");
- aDMap.Bind("TDataStd_Position", "TDataXtd_Position");
- aDMap.Bind("TDataStd_Placement", "TDataXtd_Placement");
- aDMap.Bind("TDataStd_PatternStd", "TDataXtd_PatternStd");
- aDMap.Bind("TPrsStd_AISPresentation", "TDataXtd_Presentation");
- aDMap.Bind("PDataStd_Shape", "PDataXtd_Shape");
- aDMap.Bind("PDataStd_Constraint", "PDataXtd_Constraint");
- aDMap.Bind("PDataStd_Geometry", "PDataXtd_Geometry");
- aDMap.Bind("PDataStd_Axis", "PDataXtd_Axis");
- aDMap.Bind("PDataStd_Point", "PDataXtd_Point");
- aDMap.Bind("PDataStd_Plane", "PDataXtd_Plane");
- aDMap.Bind("PDataStd_Position", "PDataXtd_Position");
- aDMap.Bind("PDataStd_Placement", "PDataXtd_Placement");
- aDMap.Bind("PDataStd_PatternStd", "PDataXtd_PatternStd");
- }
+ }
+ else
+ {
+ // hard-code migration table for known types
+ aDMap.Bind("TDataStd_Shape", "TDataXtd_Shape");
+ aDMap.Bind("TDataStd_Constraint", "TDataXtd_Constraint");
+ aDMap.Bind("TDataStd_Geometry", "TDataXtd_Geometry");
+ aDMap.Bind("TDataStd_Axis", "TDataXtd_Axis");
+ aDMap.Bind("TDataStd_Point", "TDataXtd_Point");
+ aDMap.Bind("TDataStd_Plane", "TDataXtd_Plane");
+ aDMap.Bind("TDataStd_Position", "TDataXtd_Position");
+ aDMap.Bind("TDataStd_Placement", "TDataXtd_Placement");
+ aDMap.Bind("TDataStd_PatternStd", "TDataXtd_PatternStd");
+ aDMap.Bind("TPrsStd_AISPresentation", "TDataXtd_Presentation");
+ aDMap.Bind("PDataStd_Shape", "PDataXtd_Shape");
+ aDMap.Bind("PDataStd_Constraint", "PDataXtd_Constraint");
+ aDMap.Bind("PDataStd_Geometry", "PDataXtd_Geometry");
+ aDMap.Bind("PDataStd_Axis", "PDataXtd_Axis");
+ aDMap.Bind("PDataStd_Point", "PDataXtd_Point");
+ aDMap.Bind("PDataStd_Plane", "PDataXtd_Plane");
+ aDMap.Bind("PDataStd_Position", "PDataXtd_Position");
+ aDMap.Bind("PDataStd_Placement", "PDataXtd_Placement");
+ aDMap.Bind("PDataStd_PatternStd", "PDataXtd_PatternStd");
+ }
#ifdef OCCT_DEBUG
- std::cout << "Storage_Sheme:: aDataMap.Size = " << aDMap.Extent() << std::endl;
+ std::cout << "Storage_Sheme:: aDataMap.Size = " << aDMap.Extent() << std::endl;
#endif
- }
}
- if(aDMap.Extent()) {
- if(aDMap.IsBound(oldName)) {
+ if (aDMap.Extent())
+ {
+ if (aDMap.IsBound(oldName))
+ {
newName.Clear();
newName = aDMap.Find(oldName);
aMigration = Standard_True;
std::cout << " newName = " << newName << std::endl;
#endif
}
- }
+ }
return aMigration;
}
#endif
TColStd_ListOfInteger.hxx
TColStd_ListOfReal.hxx
TColStd_ListOfTransient.hxx
-TColStd_MapIntegerHasher.hxx
TColStd_MapIteratorOfMapOfAsciiString.hxx
TColStd_MapIteratorOfMapOfInteger.hxx
TColStd_MapIteratorOfMapOfReal.hxx
TColStd_MapOfInteger.hxx
TColStd_MapOfReal.hxx
TColStd_MapOfTransient.hxx
-TColStd_MapRealHasher.hxx
-TColStd_MapTransientHasher.hxx
TColStd_PackedMapOfInteger.cxx
TColStd_PackedMapOfInteger.hxx
TColStd_SequenceOfAddress.hxx
#include <Standard_Integer.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer,TCollection_AsciiString> TColStd_DataMapOfAsciiStringInteger;
-typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer,TCollection_AsciiString>::Iterator TColStd_DataMapIteratorOfDataMapOfAsciiStringInteger;
+typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer> TColStd_DataMapOfAsciiStringInteger;
+typedef NCollection_DataMap<TCollection_AsciiString,Standard_Integer>::Iterator TColStd_DataMapIteratorOfDataMapOfAsciiStringInteger;
#endif
#define TColStd_DataMapOfIntegerInteger_HeaderFile
#include <Standard_Integer.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Standard_Integer,TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerInteger;
-typedef NCollection_DataMap<Standard_Integer,Standard_Integer,TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerInteger;
+typedef NCollection_DataMap<Standard_Integer,Standard_Integer> TColStd_DataMapOfIntegerInteger;
+typedef NCollection_DataMap<Standard_Integer,Standard_Integer>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerInteger;
#endif
#include <Standard_Integer.hxx>
#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger,TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerListOfInteger;
-typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger,TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger;
+typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger> TColStd_DataMapOfIntegerListOfInteger;
+typedef NCollection_DataMap<Standard_Integer,TColStd_ListOfInteger>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger;
#endif
#define TColStd_DataMapOfIntegerReal_HeaderFile
#include <Standard_Integer.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Standard_Real,TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerReal;
-typedef NCollection_DataMap<Standard_Integer,Standard_Real,TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerReal;
+typedef NCollection_DataMap<Standard_Integer,Standard_Real> TColStd_DataMapOfIntegerReal;
+typedef NCollection_DataMap<Standard_Integer,Standard_Real>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerReal;
#endif
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient),TColStd_MapIntegerHasher> TColStd_DataMapOfIntegerTransient;
-typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient),TColStd_MapIntegerHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerTransient;
+typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient)> TColStd_DataMapOfIntegerTransient;
+typedef NCollection_DataMap<Standard_Integer,Handle(Standard_Transient)>::Iterator TColStd_DataMapIteratorOfDataMapOfIntegerTransient;
#endif
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer,TCollection_ExtendedString> TColStd_DataMapOfStringInteger;
-typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer,TCollection_ExtendedString>::Iterator TColStd_DataMapIteratorOfDataMapOfStringInteger;
+typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer> TColStd_DataMapOfStringInteger;
+typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Integer>::Iterator TColStd_DataMapIteratorOfDataMapOfStringInteger;
#endif
#define TColStd_DataMapOfTransientTransient_HeaderFile
#include <Standard_Transient.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_DataMapOfTransientTransient;
-typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient),TColStd_MapTransientHasher>::Iterator TColStd_DataMapIteratorOfDataMapOfTransientTransient;
+typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient)> TColStd_DataMapOfTransientTransient;
+typedef NCollection_DataMap<Handle(Standard_Transient),Handle(Standard_Transient)>::Iterator TColStd_DataMapIteratorOfDataMapOfTransientTransient;
#endif
#include <TCollection_AsciiString.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TCollection_AsciiString,TCollection_AsciiString,TCollection_AsciiString> TColStd_IndexedDataMapOfStringString;
+typedef NCollection_IndexedDataMap<TCollection_AsciiString,TCollection_AsciiString> TColStd_IndexedDataMapOfStringString;
#endif // TColStd_IndexedDataMapOfStringString_HeaderFile
#define TColStd_IndexedDataMapOfTransientTransient_HeaderFile
#include <Standard_Transient.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<Handle(Standard_Transient),Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_IndexedDataMapOfTransientTransient;
+typedef NCollection_IndexedDataMap<Handle(Standard_Transient),Handle(Standard_Transient)> TColStd_IndexedDataMapOfTransientTransient;
#endif
#define TColStd_IndexedMapOfInteger_HeaderFile
#include <Standard_Integer.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<Standard_Integer,TColStd_MapIntegerHasher> TColStd_IndexedMapOfInteger;
+typedef NCollection_IndexedMap<Standard_Integer> TColStd_IndexedMapOfInteger;
#endif
#ifndef TColStd_IndexedMapOfReal_HeaderFile
#define TColStd_IndexedMapOfReal_HeaderFile
-#include <TColStd_MapRealHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<Standard_Real,TColStd_MapRealHasher> TColStd_IndexedMapOfReal;
+typedef NCollection_IndexedMap<Standard_Real> TColStd_IndexedMapOfReal;
#endif
#define TColStd_IndexedMapOfTransient_HeaderFile
#include <Standard_Transient.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_IndexedMapOfTransient;
+typedef NCollection_IndexedMap<Handle(Standard_Transient)> TColStd_IndexedMapOfTransient;
#endif
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 TColStd_MapIntegerHasher_HeaderFile
-#define TColStd_MapIntegerHasher_HeaderFile
-
-#include <Standard_Integer.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Standard_Integer> TColStd_MapIntegerHasher;
-
-
-#endif
#include <TCollection_AsciiString.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<TCollection_AsciiString,TCollection_AsciiString> TColStd_MapOfAsciiString;
-typedef NCollection_Map<TCollection_AsciiString,TCollection_AsciiString>::Iterator TColStd_MapIteratorOfMapOfAsciiString;
+typedef NCollection_Map<TCollection_AsciiString> TColStd_MapOfAsciiString;
+typedef NCollection_Map<TCollection_AsciiString>::Iterator TColStd_MapIteratorOfMapOfAsciiString;
#endif
#define TColStd_MapOfInteger_HeaderFile
#include <Standard_Integer.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Standard_Integer,TColStd_MapIntegerHasher> TColStd_MapOfInteger;
-typedef NCollection_Map<Standard_Integer,TColStd_MapIntegerHasher>::Iterator TColStd_MapIteratorOfMapOfInteger;
+typedef NCollection_Map<Standard_Integer> TColStd_MapOfInteger;
+typedef NCollection_Map<Standard_Integer>::Iterator TColStd_MapIteratorOfMapOfInteger;
#endif
#ifndef TColStd_MapOfReal_HeaderFile
#define TColStd_MapOfReal_HeaderFile
-#include <TColStd_MapRealHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Standard_Real,TColStd_MapRealHasher> TColStd_MapOfReal;
-typedef NCollection_Map<Standard_Real,TColStd_MapRealHasher>::Iterator TColStd_MapIteratorOfMapOfReal;
+typedef NCollection_Map<Standard_Real> TColStd_MapOfReal;
+typedef NCollection_Map<Standard_Real>::Iterator TColStd_MapIteratorOfMapOfReal;
#endif
#define TColStd_MapOfTransient_HeaderFile
#include <Standard_Transient.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Handle(Standard_Transient),TColStd_MapTransientHasher> TColStd_MapOfTransient;
-typedef NCollection_Map<Handle(Standard_Transient),TColStd_MapTransientHasher>::Iterator TColStd_MapIteratorOfMapOfTransient;
+typedef NCollection_Map<Handle(Standard_Transient)> TColStd_MapOfTransient;
+typedef NCollection_Map<Handle(Standard_Transient)>::Iterator TColStd_MapIteratorOfMapOfTransient;
#endif
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 TColStd_MapRealHasher_HeaderFile
-#define TColStd_MapRealHasher_HeaderFile
-
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Standard_Real> TColStd_MapRealHasher;
-
-
-#endif
+++ /dev/null
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-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 TColStd_MapTransientHasher_HeaderFile
-#define TColStd_MapTransientHasher_HeaderFile
-
-#include <Standard_Transient.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Handle(Standard_Transient)> TColStd_MapTransientHasher;
-
-
-#endif
#include <NCollection_Array1.hxx>
#include <TCollection.hxx>
+namespace
+{
+ size_t HashCode(const int theKey,
+ const size_t theBound)
+ {
+ return static_cast<size_t>(theKey) % theBound + 1;
+ }
+}
+
//=======================================================================
//function : TColStd_intMapNode_findNext
//purpose :
{
for (const TColStd_intMapNode* p = theOther.myData1[i]; p != NULL; )
{
- const Standard_Integer aHashCode = p->HashCode(nBuckets);
+ const size_t aHashCode = p->HashCode(nBuckets);
myData1[aHashCode] = new TColStd_intMapNode (p->Mask(), p->Data(), myData1[aHashCode]);
++myNbPackedMapNodes;
p = p->Next();
aNewBuck = myNbBuckets;
}
- TColStd_intMapNode** aNewData = (TColStd_intMapNode** )Standard::Allocate ((aNewBuck + 1) * sizeof(TColStd_intMapNode*));
+ TColStd_intMapNode** aNewData = (TColStd_intMapNode** )Standard::AllocateOptimal ((aNewBuck + 1) * sizeof(TColStd_intMapNode*));
memset (aNewData, 0, (aNewBuck + 1) * sizeof(TColStd_intMapNode*));
if (myData1 != NULL)
{
{
for (TColStd_intMapNode* p = anOldData[i]; p != NULL; )
{
- Standard_Integer k = p->HashCode (aNewBuck);
+ size_t k = p->HashCode(aNewBuck);
TColStd_intMapNode* q = p->Next();
p->SetNext (aNewData[k]);
aNewData[k] = p;
}
const Standard_Integer aKeyInt = packedKeyIndex (aKey);
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
TColStd_intMapNode* aBucketHead = myData1[aHashCode];
for (TColStd_intMapNode* p = aBucketHead; p != NULL; p = p->Next())
{
if (Resizable()) {
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode] = new TColStd_intMapNode (aNewMask, aNewData,
myData1[aHashCode]);
++myNbPackedMapNodes;
{
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (p2->Mask(), p2->Data(),
myData1[aHashCode]);
++myNbPackedMapNodes;
const Standard_Integer aKey = p2->Key();
const Standard_Integer aKeyInt = packedKeyIndex (aKey);
// Find the corresponding block in the 1st (this) map
- Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
TColStd_intMapNode* p1 = myData1[aHashCode];
while (p1)
{
{
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
unsigned int aNewMask = p1->Mask();
myExtent += TColStd_Population (aNewMask, aNewData);
myData1[aHashCode]= new TColStd_intMapNode(aNewMask, aNewData,
{
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (aNewMask, aNewData,
myData1[aHashCode]);
++myNbPackedMapNodes;
{
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (aNewMask, aNewData,
myData1[aHashCode]);
++myNbPackedMapNodes;
{
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode]= new TColStd_intMapNode (p2->Mask(), p2->Data(),
myData1[aHashCode]);
++myNbPackedMapNodes;
{
ReSize (myNbPackedMapNodes);
}
- const Standard_Integer aHashCode = HashCode (aKeyInt, myNbBuckets);
+ const size_t aHashCode = HashCode(aKeyInt,myNbBuckets);
myData1[aHashCode] = new TColStd_intMapNode (p2->Mask(), p2->Data(),
myData1[aHashCode]);
++myNbPackedMapNodes;
#define TColStd_PackedMapOfInteger_HeaderFile
#include <Standard.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
//! Support of Map interface.
Standard_Integer HashCode (Standard_Integer theUpper) const
{
- return ::HashCode (Standard_Integer(myMask >> 5), theUpper);
+ return (myMask >> 5) % theUpper + 1;
}
//! Support of Map interface.
#ifndef TColStd_SequenceOfAddress_HeaderFile
#define TColStd_SequenceOfAddress_HeaderFile
-#include <Standard_Address.hxx>
#include <NCollection_Sequence.hxx>
typedef NCollection_Sequence<Standard_Address> TColStd_SequenceOfAddress;
#include <cctype>
#include <cstring>
-// Shortcuts to standard allocate and reallocate functions
-static inline Standard_PCharacter Allocate(const Standard_Size aLength)
+namespace
{
- return (Standard_PCharacter)Standard::Allocate (aLength);
-}
-static inline Standard_PCharacter Reallocate (Standard_Address aAddr,
- const Standard_Size aLength)
-{
- return (Standard_PCharacter)Standard::Reallocate (aAddr, aLength);
-}
-static inline void Free (Standard_PCharacter aAddr)
-{
- Standard_Address aPtr = aAddr;
- Standard::Free (aPtr);
+ static char THE_DEFAULT_CHAR_STRING[1] = {'\0'};
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString()
{
- mylength = 0;
-
- mystring = Allocate(mylength+1);
- mystring[mylength] = '\0';
+ allocate(0);
}
// Create an asciistring from a Standard_CString
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const Standard_CString theString)
-: mystring(0),
- mylength(0)
{
if (theString == NULL)
{
throw Standard_NullObject ("TCollection_AsciiString(): NULL pointer passed to constructor");
}
-
- mylength = Standard_Integer (strlen (theString));
- mystring = Allocate (mylength + 1);
+ allocate (static_cast<int>(strlen(theString)));
memcpy (mystring, theString, mylength);
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const Standard_CString theString,
const Standard_Integer theLen)
-: mystring (NULL),
- mylength (0)
{
if (theString == NULL)
{
throw Standard_NullObject ("TCollection_AsciiString(): NULL pointer passed to constructor");
}
-
- for (; mylength < theLen && theString[mylength] != '\0'; ++mylength) {}
- mystring = Allocate (mylength + 1);
+ int aLength = 0;
+ for (; aLength < theLen && theString[aLength] != '\0'; ++aLength) {}
+ allocate (aLength);
memcpy (mystring, theString, mylength);
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
// Create an asciistring from a Standard_Character
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString(const Standard_Character aChar)
- : mystring(0)
{
if ( aChar != '\0' ) {
- mylength = 1;
- mystring = Allocate(2);
+ allocate(1);
mystring[0] = aChar;
- mystring[1] = '\0';
}
else {
- mylength = 0;
- mystring = Allocate(mylength+1);
- mystring[mylength] = '\0';
+ allocate(0);
}
}
TCollection_AsciiString::TCollection_AsciiString(const Standard_Integer length,
const Standard_Character filler )
{
- mystring = Allocate(length+1);
- mylength = length;
- for (int i = 0 ; i < length ; i++) mystring[i] = filler;
- mystring[length] = '\0';
+ allocate(length);
+ memset(mystring, filler, length);
}
// ----------------------------------------------------------------------------
// Create an AsciiString from an Integer
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString(const Standard_Integer aValue)
- : mystring(0)
{
char t [13];
- mylength = Sprintf( t,"%d",aValue);
- mystring = Allocate(mylength+1);
+ allocate(Sprintf(t, "%d", aValue));
memcpy (mystring, t, mylength);
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
// Create an asciistring from a real
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString(const Standard_Real aValue)
- : mystring(0)
{
char t [50];
- mylength = Sprintf( t,"%g",aValue);
- mystring = Allocate(mylength+1);
+ allocate(Sprintf(t, "%g", aValue));
memcpy (mystring, t, mylength);
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
// Create an asciistring from an asciistring
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString& theString)
-: mystring (Allocate (theString.mylength + 1)),
- mylength (theString.mylength)
{
+ allocate(theString.mylength);
if (mylength != 0)
{
memcpy (mystring, theString.mystring, mylength);
}
- mystring[mylength] = '\0';
+}
+
+//=======================================================================
+//function : TCollection_AsciiString
+//purpose :
+//=======================================================================
+TCollection_AsciiString::TCollection_AsciiString(TCollection_AsciiString&& theOther) Standard_Noexcept
+{
+ if (theOther.mystring == THE_DEFAULT_CHAR_STRING)
+ {
+ allocate(0);
+ }
+ else
+ {
+ mystring = theOther.mystring;
+ mylength = theOther.mylength;
+ }
+ theOther.mylength = 0;
+ theOther.mystring = THE_DEFAULT_CHAR_STRING;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString& theString,
const Standard_Character theChar)
-: mystring (NULL),
- mylength (theString.mylength + 1)
{
- mystring = Allocate (mylength + 1);
+ allocate (theString.mylength + 1);
if (theString.mylength != 0)
{
memcpy (mystring, theString.mystring, theString.mylength);
}
mystring[mylength - 1] = theChar;
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString& theString1,
const Standard_CString theString2)
-: mystring (0)
{
const Standard_Integer aStr2Len = Standard_Integer (theString2 ? strlen (theString2) : 0);
- mylength = theString1.mylength + aStr2Len;
- mystring = Allocate (mylength + 1);
+ allocate (theString1.mylength + aStr2Len);
if (theString1.mylength != 0)
{
memcpy (mystring, theString1.mystring, theString1.mylength);
{
memcpy (mystring + theString1.mylength, theString2, aStr2Len);
}
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString& theString1,
const TCollection_AsciiString& theString2)
-: mystring (0),
- mylength (theString1.mylength + theString2.mylength)
{
- mystring = Allocate (mylength + 1);
+ allocate (theString1.mylength + theString2.mylength);
if (theString1.mylength)
{
memcpy (mystring, theString1.mystring, theString1.mylength);
{
memcpy (mystring + theString1.mylength, theString2.mystring, theString2.mylength);
}
- mystring[mylength] = '\0';
}
//---------------------------------------------------------------------------
// Create an asciistring from an ExtendedString
//---------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString(const TCollection_ExtendedString& astring,
- const Standard_Character replaceNonAscii)
-: mystring (0)
+ const Standard_Character replaceNonAscii)
{
if (replaceNonAscii)
{
- mylength = astring.Length();
- mystring = Allocate(mylength+1);
+ allocate(astring.Length());
for(int i = 0; i < mylength; i++) {
Standard_ExtCharacter c = astring.Value(i+1);
mystring[i] = ( IsAnAscii(c) ? ToCharacter(c) : replaceNonAscii );
}
- mystring[mylength] = '\0';
}
else {
// create UTF-8 string
- mylength = astring.LengthOfCString();
- mystring = Allocate(mylength+1);
+ allocate(astring.LengthOfCString());
astring.ToUTF8CString(mystring);
}
}
// Create an TCollection_AsciiString from a Standard_WideChar
//---------------------------------------------------------------------------
TCollection_AsciiString::TCollection_AsciiString (const Standard_WideChar* theStringUtf)
-: mystring (NULL),
- mylength (0)
{
+ int aLength = 0;
for (NCollection_UtfWideIter anIter (theStringUtf); *anIter != 0; ++anIter)
{
- mylength += anIter.AdvanceBytesUtf8();
+ aLength += anIter.AdvanceBytesUtf8();
}
-
- mystring = Allocate (mylength + 1);
- mystring[mylength] = '\0';
+ allocate (aLength);
NCollection_UtfWideIter anIterRead (theStringUtf);
for (Standard_Utf8Char* anIterWrite = mystring; *anIterRead != 0; ++anIterRead)
{
void TCollection_AsciiString::AssignCat(const Standard_Character other)
{
if (other != '\0') {
- mystring = Reallocate (mystring, mylength + 2);
- mystring[mylength] = other ;
- mylength += 1;
- mystring[mylength] = '\0';
+ reallocate (mylength + 1);
+ mystring[mylength - 1] = other;
}
}
Standard_Integer anOtherLen = Standard_Integer (strlen (theOther));
if (anOtherLen != 0)
{
- const Standard_Integer aNewLen = mylength + anOtherLen;
- mystring = Reallocate (mystring, aNewLen + 1);
- memcpy (mystring + mylength, theOther, anOtherLen + 1);
- mylength = aNewLen;
+ const Standard_Integer anOldLength = mylength;
+ reallocate (mylength + anOtherLen);
+ memcpy (mystring + anOldLength, theOther, anOtherLen + 1);
}
}
{
if (theOther.mylength != 0)
{
- const Standard_Integer aNewLen = mylength + theOther.mylength;
- mystring = Reallocate (mystring, aNewLen + 1);
- memcpy (mystring + mylength, theOther.mystring, theOther.mylength + 1);
- mylength = aNewLen;
+ const Standard_Integer anOldLength = mylength;
+ reallocate(mylength + theOther.mylength);
+ memcpy (mystring + anOldLength, theOther.mystring, theOther.mylength + 1);
}
}
// ----------------------------------------------------------------------------
void TCollection_AsciiString::Clear()
{
- if ( mylength > 0 )
- {
- Free (mystring);
- mylength = 0;
- mystring = Allocate(mylength+1);
- mystring[mylength] = '\0';
- }
+ deallocate();
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void TCollection_AsciiString::Copy(const Standard_CString fromwhere)
{
- if (fromwhere) {
- mylength = Standard_Integer( strlen( fromwhere ));
- mystring = Reallocate (mystring, mylength + 1);
- memcpy (mystring, fromwhere, mylength + 1);
+ if (fromwhere == mystring)
+ {
+ return;
}
- else {
+ if (fromwhere && fromwhere[0] != '\0')
+ {
+ reallocate (static_cast<int>(strlen(fromwhere)));
+ memcpy (mystring, fromwhere, mylength);
+ }
+ else
+ {
mylength = 0;
- mystring[mylength] = '\0';
+ mystring = THE_DEFAULT_CHAR_STRING;
}
}
// ----------------------------------------------------------------------------
void TCollection_AsciiString::Copy(const TCollection_AsciiString& fromwhere)
{
- if (fromwhere.mystring) {
- mylength = fromwhere.mylength;
- mystring = Reallocate (mystring, mylength + 1);
- memcpy (mystring, fromwhere.mystring, mylength + 1);
+ if (&fromwhere == this)
+ {
+ return;
}
- else {
+ if (fromwhere.mystring && fromwhere.mylength > 0)
+ {
+ reallocate (fromwhere.mylength);
+ memcpy (mystring, fromwhere.mystring, mylength);
+ }
+ else if (mystring != THE_DEFAULT_CHAR_STRING)
+ {
mylength = 0;
mystring[mylength] = '\0';
}
}
+//=======================================================================
+//function : Move
+//purpose :
+//=======================================================================
+void TCollection_AsciiString::Move(TCollection_AsciiString&& theOther)
+{
+ if (&theOther == this)
+ {
+ return;
+ }
+ if (mystring != THE_DEFAULT_CHAR_STRING)
+ {
+ Standard::Free(mystring);
+ }
+ mystring = theOther.mystring;
+ mylength = theOther.mylength;
+ theOther.mystring = THE_DEFAULT_CHAR_STRING;
+ theOther.mylength = 0;
+}
+
// ----------------------------------------------------------------------------
// Swap
// ----------------------------------------------------------------------------
void TCollection_AsciiString::Swap (TCollection_AsciiString& theOther)
{
+ if (&theOther == this)
+ {
+ return;
+ }
std::swap (mystring, theOther.mystring);
std::swap (mylength, theOther.mylength);
}
// ----------------------------------------------------------------------------
TCollection_AsciiString::~TCollection_AsciiString()
{
- if (mystring)
- Free (mystring);
- mystring = 0L;
+ deallocate ();
}
// ----------------------------------------------------------------------------
if (where > mylength + 1 ) throw Standard_OutOfRange("TCollection_AsciiString::Insert : Parameter where is too big");
if (where < 1) throw Standard_OutOfRange("TCollection_AsciiString::Insert : Parameter where is too small");
- mystring = Reallocate (mystring, mylength + 2);
- if (where != mylength +1) {
- for (int i=mylength-1; i >= where-1; i--)
+ const int anOldLength = mylength;
+ reallocate (mylength + 1);
+ if (where != anOldLength +1) {
+ for (int i= anOldLength -1; i >= where-1; i--)
mystring[i+1] = mystring[i];
}
mystring[where-1] = what;
- mylength++;
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
{
if (where <= mylength + 1 && where > 0) {
if(what) {
- Standard_Integer whatlength = Standard_Integer( strlen( what ) );
- Standard_Integer newlength = mylength + whatlength;
-
- mystring = Reallocate (mystring, newlength + 1);
- if (where != mylength +1) {
- for (int i=mylength-1; i >= where-1; i--)
+ const Standard_Integer whatlength = Standard_Integer( strlen( what ) );
+ const int anOldLength = mylength;
+ reallocate (mylength + whatlength);
+ if (where != anOldLength +1) {
+ for (int i= anOldLength -1; i >= where-1; i--)
mystring[i+whatlength] = mystring[i];
}
for (int i=0; i < whatlength; i++)
mystring[where-1+i] = what[i];
-
- mylength = newlength;
- mystring[mylength] = '\0';
}
}
else {
{
Standard_CString swhat = what.mystring;
if (where <= mylength + 1) {
- Standard_Integer whatlength = what.mylength;
+ const Standard_Integer whatlength = what.mylength;
if(whatlength) {
- Standard_Integer newlength = mylength + whatlength;
-
- mystring = Reallocate (mystring, newlength + 1);
+ const int anOldLength = mylength;
+ reallocate (mylength + whatlength);
- if (where != mylength +1) {
- for (int i=mylength-1; i >= where-1; i--)
+ if (where != anOldLength +1) {
+ for (int i= anOldLength -1; i >= where-1; i--)
mystring[i+whatlength] = mystring[i];
}
for (int i=0; i < whatlength; i++)
mystring[where-1+i] = swhat[i];
-
- mylength = newlength;
- mystring[mylength] = '\0';
}
}
else {
const Standard_Character Filler)
{
if (Width > mylength) {
- mystring = Reallocate (mystring, Width + 1);
- for (int i = mylength; i < Width ; i++) mystring[i] = Filler;
- mylength = Width;
- mystring[mylength] = '\0';
+ const int anOldLength = mylength;
+ reallocate (Width);
+ for (int i = anOldLength; i < Width ; i++) mystring[i] = Filler;
}
else if (Width < 0) {
throw Standard_NegativeValue();
astream.width( oldWidth );
// put to string
- mylength = Standard_Integer( strlen( buffer ));
- mystring = Reallocate (mystring, mylength + 1);
+ reallocate (Standard_Integer(strlen(buffer)));
memcpy (mystring, buffer, mylength);
- mystring[mylength] = '\0';
}
}
}
mylength = c;
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
for (int i=0; i < mylength; i++)
if (mystring[i] != what) mystring[c++] = mystring[i];
mylength = c;
- mystring[mylength] = '\0';
}
// ----------------------------------------------------------------------------
void TCollection_AsciiString::RightJustify(const Standard_Integer Width,
const Standard_Character Filler)
{
- Standard_Integer i ;
- Standard_Integer k ;
if (Width > mylength) {
- mystring = Reallocate (mystring, Width + 1);
-
- for ( i = mylength-1, k = Width-1 ; i >= 0 ; i--, k--)
+ const int anOldLength = mylength;
+ reallocate (Width);
+ int i, k;
+ for ( i = anOldLength-1, k = Width-1 ; i >= 0 ; i--, k--)
mystring[k] = mystring[i];
for(; k >= 0 ; k--) mystring[k] = Filler;
- mylength = Width;
- mystring[mylength] = '\0';
}
else if (Width < 0) {
throw Standard_NegativeValue();
Standard_Integer size = Standard_Integer( what ? strlen( what ) : 0 );
size += (where - 1);
if (size >= mylength) {
- mystring = Reallocate (mystring, size + 1);
- mylength = size;
+ reallocate (size);
}
for (int i = where-1; i < size; i++)
mystring[i] = what[i-(where-1)];
- mystring[mylength] = '\0';
}
else {
throw Standard_OutOfRange("TCollection_AsciiString::SetValue : "
Standard_CString swhat = what.mystring;
size += (where - 1);
if (size >= mylength) {
- mystring = Reallocate (mystring, size + 1);
- mylength = size;
+ reallocate (size);
}
for (int i = where-1; i < size; i++)
mystring[i] = swhat[i-(where-1)];
- mystring[mylength] = '\0';
}
else {
throw Standard_OutOfRange("TCollection_AsciiString::SetValue : "
}
}
-// ----------------------------------------------------------------------------
-// Split
-// Private
-// ----------------------------------------------------------------------------
-void TCollection_AsciiString::Split(const Standard_Integer where,
- TCollection_AsciiString& res)
-{
- if (where >= 0 && where <= mylength) {
- res = &mystring[where] ;
- Trunc(where);
- return ;
- }
- throw Standard_OutOfRange("TCollection_AsciiString::Split index");
- return ;
-}
// ----------------------------------------------------------------------------
// Split
throw Standard_OutOfRange("TCollection_AsciiString::Split index");
}
-// ----------------------------------------------------------------------------
-// SubString
-// Private
-// ----------------------------------------------------------------------------
-void TCollection_AsciiString::SubString(const Standard_Integer FromIndex,
- const Standard_Integer ToIndex,
- TCollection_AsciiString& res) const
-{
-
- if (ToIndex > mylength || FromIndex <= 0 || FromIndex > ToIndex )
- {
- throw Standard_OutOfRange();
- }
-
- Standard_Integer newlength = ToIndex-FromIndex+1;
- res.mystring =Reallocate (res.mystring, newlength + 1);
- memcpy (res.mystring, mystring + FromIndex - 1, newlength);
- res.mystring[newlength] = '\0';
- res.mylength = newlength;
- return ;
-}
-
-// ----------------------------------------------------------------------------
-// Token
-// Private
-// ----------------------------------------------------------------------------
-void TCollection_AsciiString::Token(const Standard_CString separators,
- const Standard_Integer whichone,
- TCollection_AsciiString& res)const
-{
- res = Token( separators , whichone ) ;
-}
-
// ----------------------------------------------------------------------------
// Token
// ----------------------------------------------------------------------------
}
throw Standard_OutOfRange("TCollection_AsciiString::Value : parameter where");
}
+
+//=======================================================================
+//function : allocate
+//purpose :
+//=======================================================================
+void TCollection_AsciiString::allocate(const int theLength)
+{
+ mylength = theLength;
+ if (theLength == 0)
+ {
+ mystring = THE_DEFAULT_CHAR_STRING;
+ }
+ else
+ {
+ const Standard_Size aRoundSize = (theLength + 4) & ~0x3;
+ mystring = static_cast<Standard_PCharacter>(
+ Standard::AllocateOptimal(aRoundSize));
+ mystring[mylength] = '\0';
+ }
+}
+
+//=======================================================================
+//function : reallocate
+//purpose :
+//=======================================================================
+void TCollection_AsciiString::reallocate(const int theLength)
+{
+ if (theLength != 0)
+ {
+ if (mystring == THE_DEFAULT_CHAR_STRING)
+ {
+ const Standard_Size aRoundSize = (theLength + 4) & ~0x3;
+ mystring = static_cast<Standard_PCharacter>(
+ Standard::AllocateOptimal(aRoundSize));
+ }
+ else
+ {
+ mystring = static_cast<Standard_PCharacter>(
+ Standard::Reallocate(mystring, theLength + 1));
+ }
+ mystring[theLength] = '\0';
+ }
+ if (mystring != THE_DEFAULT_CHAR_STRING)
+ {
+ mystring[theLength] = '\0';
+ }
+ mylength = theLength;
+}
+
+//=======================================================================
+//function : deallocate
+//purpose :
+//=======================================================================
+void TCollection_AsciiString::deallocate()
+{
+ if (mystring != THE_DEFAULT_CHAR_STRING)
+ {
+ Standard::Free(mystring);
+ }
+ mylength = 0;
+ mystring = THE_DEFAULT_CHAR_STRING;
+}
Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring);
//! Move constructor
- TCollection_AsciiString (TCollection_AsciiString&& theOther) Standard_Noexcept
- : mystring (theOther.mystring),
- mylength (theOther.mylength)
- {
- theOther.mystring = NULL;
- theOther.mylength = 0;
- }
+ Standard_EXPORT TCollection_AsciiString (TCollection_AsciiString&& theOther) Standard_Noexcept;
//! Initializes a AsciiString with copy of another AsciiString
//! concatenated with the message character.
//! Used as operator =
//! Example: aString = anotherString;
Standard_EXPORT void Copy (const TCollection_AsciiString& fromwhere);
-void operator = (const TCollection_AsciiString& fromwhere)
-{
- Copy(fromwhere);
-}
- //! Exchange the data of two strings (without reallocating memory).
- Standard_EXPORT void Swap (TCollection_AsciiString& theOther);
+ //! Copy assignment operator
+ TCollection_AsciiString& operator= (const TCollection_AsciiString& theOther)
+ {
+ Copy(theOther);
+ return *this;
+ }
+
+ //! Moves string without reallocations
+ Standard_EXPORT void Move (TCollection_AsciiString&& theOther);
//! Move assignment operator
- TCollection_AsciiString& operator= (TCollection_AsciiString&& theOther) Standard_Noexcept { Swap (theOther); return *this; }
+ TCollection_AsciiString& operator= (TCollection_AsciiString&& theOther) noexcept
+ {
+ Move(std::forward<TCollection_AsciiString>(theOther));
+ return *this;
+ }
+
+ //! Exchange the data of two strings (without reallocating memory).
+ Standard_EXPORT void Swap (TCollection_AsciiString& theOther);
//! Frees memory allocated by AsciiString.
Standard_EXPORT ~TCollection_AsciiString();
//! aString.Value(2) returns 'e'
Standard_EXPORT Standard_Character Value (const Standard_Integer where) const;
- //! Computes a hash code for the given ASCII string, in the range [1, theUpperBound].
+ //! Computes a hash code for the given ASCII string
//! Returns the same integer value as the hash function for TCollection_ExtendedString
- //! @param theAsciiString the ASCII string 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 TCollection_AsciiString& theAsciiString, Standard_Integer theUpperBound);
+ //! @return a computed hash code
+ size_t HashCode() const;
//! Returns True when the two strings are the same.
//! (Just for HashCode for AsciiString)
private:
- Standard_EXPORT void Split (const Standard_Integer where, TCollection_AsciiString& result);
-
- Standard_EXPORT void SubString (const Standard_Integer FromIndex, const Standard_Integer ToIndex, TCollection_AsciiString& result) const;
-
- Standard_EXPORT void Token (const Standard_CString separators, const Standard_Integer whichone, TCollection_AsciiString& result) const;
+ //! Internal wrapper to allocate on stack or heap
+ void allocate(const int theLength);
-private:
+ //! Internal wrapper to reallocate on stack or heap
+ void reallocate(const int theLength);
- Standard_PCharacter mystring; //!< NULL-terminated string
- Standard_Integer mylength; //!< length in bytes (excluding terminating NULL symbol)
+ //! Internal wrapper to deallocate on stack
+ void deallocate();
+
+private:
+ Standard_PCharacter mystring{}; //!< NULL-terminated string
+ Standard_Integer mylength{}; //!< length in bytes (excluding terminating NULL symbol)
};
#include <TCollection_AsciiString.lxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_CString.hxx>
+#include <Standard_HashUtils.hxx>
+#include "TCollection_AsciiString.hxx"
// definition global methods for using in NCollection
-//! Computes a hash code for the given ASCII string, in the range [1, theUpperBound]
-//! @param theAsciiString the ASCII string 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]
-inline Standard_Integer HashCode (const TCollection_AsciiString& theAsciiString, const Standard_Integer theUpperBound)
+namespace std
{
- return TCollection_AsciiString::HashCode (theAsciiString, theUpperBound);
+ template <>
+ struct hash<TCollection_AsciiString>
+ {
+ size_t operator()(const TCollection_AsciiString& theString) const
+ {
+ return theString.HashCode();
+ }
+ };
}
-
//------------------------------------------------------------------------
// IsEqual
//------------------------------------------------------------------------
return TCollection_AsciiString::IsEqual(string1,string2);
}
-
-
// ----------------------------------------------------------------------------
// ToCString
// ----------------------------------------------------------------------------
// function : HashCode
// purpose :
//============================================================================
-inline Standard_Integer TCollection_AsciiString::HashCode (const TCollection_AsciiString& theAsciiString,
- const Standard_Integer theUpperBound)
+inline size_t TCollection_AsciiString::HashCode() const
{
- return ::HashCode (theAsciiString.ToCString(), theAsciiString.Length(), theUpperBound);
+ if (mylength < 4)
+ {
+ return opencascade::FNVHash::hash_combine(*mystring, mylength);
+ }
+ return opencascade::hashBytes(mystring, mylength);
}
namespace
{
- //! Allocate string buffer (automatically adding extra symbol for NULL-termination).
- static Standard_ExtCharacter* allocateExtChars (const Standard_Size theLength)
- {
- return (Standard_ExtCharacter* )Standard::Allocate ((theLength + 1) * sizeof(Standard_ExtCharacter));
- }
-
- //! Re-allocate string buffer (automatically adding extra symbol for NULL-termination).
- static Standard_ExtCharacter* reallocateExtChars (Standard_Address theAddr,
- const Standard_Size theLength)
- {
- return (Standard_ExtCharacter* )Standard::Reallocate (theAddr, (theLength + 1) * sizeof(Standard_ExtCharacter));
- }
-
- static const Standard_ExtCharacter NULL_EXTSTRING[1] = {0};
+ static Standard_ExtCharacter THE_DEFAULT_EXT_CHAR_STRING[1] = {0};
//! Returns the number of 16-bit code units in Unicode string
template<typename T>
Standard_Integer& theLength)
{
theLength = nbSymbols (theUtfString);
- Standard_ExtCharacter* aString = allocateExtChars (theLength);
+ if (theLength == 0)
+ {
+ return THE_DEFAULT_EXT_CHAR_STRING;
+ }
+ const Standard_Size aRoundSize = (((theLength + 1) * sizeof(Standard_ExtCharacter)) + 3) & ~0x3;
+ Standard_ExtCharacter* aString = static_cast<Standard_PExtCharacter>(Standard::AllocateOptimal(aRoundSize));
NCollection_UtfWideIter anIterRead (theUtfString);
for (Standard_ExtCharacter* anIterWrite = aString; *anIterRead != 0; ++anIterRead)
{
Standard_Integer& theLength)
{
for (theLength = 0; theUtfString[theLength] != 0; ++theLength) {}
- Standard_ExtCharacter* aString = allocateExtChars (theLength);
+ if (theLength == 0)
+ {
+ return THE_DEFAULT_EXT_CHAR_STRING;
+ }
+ const Standard_Size aRoundSize = (((theLength + 1) * sizeof(Standard_ExtCharacter)) + 3) & ~0x3;
+ Standard_ExtCharacter* aString = static_cast<Standard_PExtCharacter>(Standard::AllocateOptimal(aRoundSize));
const Standard_Integer aSize = theLength * sizeof(Standard_ExtCharacter);
memcpy (aString, theUtfString, aSize);
aString[theLength] = 0;
// Create an empty ExtendedString
// ----------------------------------------------------------------------------
TCollection_ExtendedString::TCollection_ExtendedString()
-: mystring (allocateExtChars (0)),
- mylength (0)
{
- mystring[0] = 0;
+ allocate(0);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
TCollection_ExtendedString::TCollection_ExtendedString
(const Standard_CString theString,
- const Standard_Boolean isMultiByte)
-: mystring (NULL),
- mylength (0)
+ const Standard_Boolean isMultiByte)
{
if (theString == NULL)
{
if (isMultiByte)
{
- mylength = nbSymbols (theString);
- mystring = allocateExtChars (mylength);
+ allocate(nbSymbols(theString));
mystring[mylength] = 0;
if (ConvertToUnicode (theString))
{
return;
}
+ reallocate((int)strlen(theString));
+ }
+ else
+ {
+ allocate((int)strlen(theString));
}
-
- mylength = (int)strlen(theString);
- mystring = reallocateExtChars (mystring, mylength);
for (int aCharIter = 0; aCharIter < mylength; ++aCharIter)
{
mystring[aCharIter] = ToExtCharacter (theString[aCharIter]);
}
- mystring[mylength] = 0;
}
//---------------------------------------------------------------------------
// Create an ExtendedString from an ExtString
//--------------------------------------------------------------------------
TCollection_ExtendedString::TCollection_ExtendedString (const Standard_ExtString theString)
-: mystring (NULL),
- mylength (0)
{
if (theString == NULL)
{
}
for (mylength = 0; theString[mylength] != 0; ++mylength) {}
- mystring = allocateExtChars (mylength);
- const Standard_Integer aSizeBytes = mylength * sizeof(Standard_ExtCharacter);
- memcpy (mystring, theString, aSizeBytes);
- mystring[mylength] = 0;
+ allocate (mylength);
+ memcpy (mystring, theString, mylength * sizeof(Standard_ExtCharacter));
}
// ----------------------------------------------------------------------------
// TCollection_ExtendedString
// ----------------------------------------------------------------------------
TCollection_ExtendedString::TCollection_ExtendedString (const Standard_WideChar* theStringUtf)
-: mystring (NULL),
- mylength (0)
{
if (theStringUtf == NULL)
{
TCollection_ExtendedString::TCollection_ExtendedString
(const Standard_Character aChar)
{
- if ( aChar != '\0' ) {
- mylength = 1;
- mystring = allocateExtChars (1);
+ if ( aChar != '\0' )
+ {
+ allocate(1);
mystring[0] = ToExtCharacter(aChar);
- mystring[1] = 0;
}
- else {
- // mystring = 0L;
- mylength = 0;
- mystring = allocateExtChars (0);
- mystring[0] = 0;
+ else
+ {
+ allocate(0);
}
}
TCollection_ExtendedString::TCollection_ExtendedString
(const Standard_ExtCharacter aChar)
{
- mylength = 1;
- mystring = allocateExtChars (1);
+ allocate(1);
mystring[0] = aChar;
- mystring[1] = 0;
}
// ----------------------------------------------------------------------------
(const Standard_Integer length,
const Standard_ExtCharacter filler )
{
- mystring = allocateExtChars (length);
- mylength = length;
+ allocate(length);
for (int i = 0 ; i < length ; i++) mystring[i] = filler;
- mystring[mylength] = 0;
}
// ----------------------------------------------------------------------------
union {int bid ;
char t [13];} CHN ;
Sprintf(&CHN.t[0],"%d",aValue);
- mylength = (int)strlen(CHN.t);
- mystring = allocateExtChars (mylength);
+ allocate((int)strlen(CHN.t));
for (int i = 0 ; i < mylength ; i++) mystring[i] = ToExtCharacter(CHN.t[i]);
- mystring[mylength] = 0;
}
// ----------------------------------------------------------------------------
union {int bid ;
char t [50];} CHN ;
Sprintf(&CHN.t[0],"%g",aValue);
- mylength = (int)strlen( CHN.t );
- mystring = allocateExtChars (mylength);
+ allocate((int)strlen(CHN.t));
for (int i = 0 ; i < mylength ; i++) mystring[i] = ToExtCharacter(CHN.t[i]);
- mystring[mylength] = 0;
}
//-----------------------------------------------------------------------------
// create an extendedstring from an extendedstring
// ----------------------------------------------------------------------------
TCollection_ExtendedString::TCollection_ExtendedString
- (const TCollection_ExtendedString& astring)
+ (const TCollection_ExtendedString& theOther)
{
- const Standard_Integer aSizeBytes = astring.mylength * sizeof(Standard_ExtCharacter);
- mylength = astring.mylength;
- mystring = allocateExtChars (astring.mylength);
- memcpy (mystring, astring.mystring, aSizeBytes);
- mystring[mylength] = 0;
+ allocate(theOther.mylength);
+ memcpy(mystring, theOther.mystring, mylength * sizeof(Standard_ExtCharacter));
+}
+
+//=======================================================================
+//function : TCollection_ExtendedString
+//purpose :
+//=======================================================================
+TCollection_ExtendedString::TCollection_ExtendedString (TCollection_ExtendedString&& theOther) noexcept
+{
+ if (theOther.mystring == THE_DEFAULT_EXT_CHAR_STRING)
+ {
+ allocate(0);
+ }
+ else
+ {
+ mystring = theOther.mystring;
+ mylength = theOther.mylength;
+ }
+ theOther.mystring = THE_DEFAULT_EXT_CHAR_STRING;
+ theOther.mylength = 0;
}
//---------------------------------------------------------------------------
(const TCollection_AsciiString& theString,
const Standard_Boolean isMultiByte)
{
- mylength = nbSymbols (theString.ToCString());
- mystring = allocateExtChars (mylength);
- mystring[mylength] = 0;
+ allocate(nbSymbols (theString.ToCString()));
if (isMultiByte && ConvertToUnicode (theString.ToCString()))
{
return;
}
-
- mylength = theString.Length();
- mystring = reallocateExtChars (mystring, mylength);
+ reallocate(theString.Length());
Standard_CString aCString = theString.ToCString();
for (Standard_Integer aCharIter = 0; aCharIter <= mylength; ++aCharIter)
{
mystring[aCharIter] = ToExtCharacter (aCString[aCharIter]);
}
- mystring[mylength] = 0;
}
// ----------------------------------------------------------------------------
}
const Standard_Integer anOtherLength = theOther.mylength;
- const Standard_Integer aNewlength = mylength + anOtherLength;
- if (mystring != NULL)
- {
- mystring = reallocateExtChars (mystring, aNewlength);
- memcpy (mystring + mylength, theOther.mystring, anOtherLength * sizeof(Standard_ExtCharacter));
- }
- else
- {
- mystring = allocateExtChars (aNewlength);
- memcpy (mystring, theOther.mystring, anOtherLength * sizeof(Standard_ExtCharacter));
- }
- mylength = aNewlength;
- mystring[mylength] = 0;
+ const Standard_Integer anOldLength = mylength;
+ reallocate(mylength + anOtherLength);
+ memcpy (mystring + anOldLength, theOther.mystring, anOtherLength * sizeof(Standard_ExtCharacter));
}
// ----------------------------------------------------------------------------
{
if (theChar != '\0')
{
- mystring = reallocateExtChars(mystring, mylength + 1);
- mystring[mylength] = theChar;
- mylength += 1;
- mystring[mylength] = '\0';
+ reallocate(mylength + 1);
+ mystring[mylength - 1] = theChar;
}
}
// ----------------------------------------------------------------------------
void TCollection_ExtendedString::Clear()
{
- if (mylength == 0)
- {
- return;
- }
-
- Standard::Free (mystring);
- mylength = 0;
- mystring = allocateExtChars (mylength);
- mystring[0] = 0;
+ deallocate();
}
// ----------------------------------------------------------------------------
// Copy
// ----------------------------------------------------------------------------
-void TCollection_ExtendedString::Copy (const TCollection_ExtendedString& fromwhere)
+void TCollection_ExtendedString::Copy(const TCollection_ExtendedString& fromwhere)
{
-
- if (fromwhere.mystring) {
- const Standard_Integer newlength = fromwhere.mylength;
- const Standard_Integer aSizeBytes = newlength * sizeof(Standard_ExtCharacter);
- if (mystring != NULL)
- {
- mystring = reallocateExtChars (mystring, newlength);
- }
- else {
- mystring = allocateExtChars (newlength);
- }
- mylength = newlength;
- memcpy (mystring, fromwhere.mystring, aSizeBytes);
+ if (&fromwhere == this)
+ {
+ return;
+ }
+ if (fromwhere.mystring && fromwhere.mylength > 0)
+ {
+ reallocate (fromwhere.mylength);
+ memcpy (mystring, fromwhere.mystring, mylength * sizeof(Standard_ExtCharacter));
+ }
+ else if (mystring != THE_DEFAULT_EXT_CHAR_STRING)
+ {
+ mylength = 0;
mystring[mylength] = 0;
}
+}
+
+//=======================================================================
+//function : Move
+//purpose :
+//=======================================================================
+void TCollection_ExtendedString::Move(TCollection_ExtendedString&& theOther)
+{
+ if (&theOther == this)
+ {
+ return;
+ }
+ if (theOther.mystring == THE_DEFAULT_EXT_CHAR_STRING)
+ {
+ reallocate(0);
+ }
else
{
- if (mystring != 0)
+ if (mystring != THE_DEFAULT_EXT_CHAR_STRING)
{
- mylength = 0;
- mystring[0] = 0;
+ Standard::Free(mystring);
}
+ mystring = theOther.mystring;
+ mylength = theOther.mylength;
}
+ theOther.mystring = THE_DEFAULT_EXT_CHAR_STRING;
+ theOther.mylength = 0;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void TCollection_ExtendedString::Swap (TCollection_ExtendedString& theOther)
{
- std::swap (mystring, theOther.mystring);
+ if (&theOther == this)
+ {
+ return;
+ }
+ std::swap(mystring, theOther.mystring);
std::swap (mylength, theOther.mylength);
}
// ----------------------------------------------------------------------------
TCollection_ExtendedString::~TCollection_ExtendedString()
{
- if (mystring) Standard::Free(mystring);
- mystring = 0L;
+ deallocate ();
}
//----------------------------------------------------------------------------
if (where < 0)
throw Standard_OutOfRange("TCollection_ExtendedString::Insert : "
"Parameter where is negative");
-
- if (mystring != NULL)
- {
- mystring = reallocateExtChars (mystring, mylength + 1);
- }
- else {
- mystring = allocateExtChars (mylength + 1);
- }
- if (where != mylength +1) {
- for (int i=mylength-1; i >= where-1; i--)
+ reallocate(mylength + 1);
+ if (where != mylength) {
+ for (int i=mylength-2; i >= where-1; i--)
mystring[i+1] = mystring[i];
}
mystring[where-1] = what;
- mylength++;
- mystring[mylength] = 0;
}
// ----------------------------------------------------------------------------
if (where <= mylength + 1) {
Standard_Integer whatlength = what.mylength;
if(whatlength) {
- Standard_Integer newlength = mylength + whatlength;
-
- if (mystring) {
- mystring = reallocateExtChars (mystring, newlength);
- }
- else {
- mystring = allocateExtChars (newlength);
- }
- if (where != mylength +1) {
- for (int i=mylength-1; i >= where-1; i--)
+ const int anOldLength = mylength;
+ reallocate(mylength + whatlength);
+ if (where != anOldLength +1) {
+ for (int i=anOldLength-1; i >= where-1; i--)
mystring[i+whatlength] = mystring[i];
}
for (int i=0; i < whatlength; i++)
mystring[where-1+i] = swhat[i];
-
- mylength = newlength;
- mystring[mylength] = 0;
}
}
else {
Standard_ExtString swhat = what.mystring;
size += (where - 1);
if (size >= mylength){
- if (mystring) {
- mystring = reallocateExtChars (mystring, size);
- }
- else {
- mystring = allocateExtChars (size);
- }
- mylength = size;
+ reallocate(size);
}
for (int i = where-1; i < size; i++)
mystring[i] = swhat[i-(where-1)];
- mystring[mylength] = '\0';
}
else
throw Standard_OutOfRange("TCollection_ExtendedString::SetValue : "
(const Standard_ExtString separators,
const Standard_Integer whichone) const
{
- TCollection_ExtendedString res;
+ if (mylength == 0)
+ {
+ return TCollection_ExtendedString();
+ }
+ TCollection_ExtendedString res(mylength, 0);
if (!separators)
throw Standard_NullObject("TCollection_ExtendedString::Token : "
"parameter 'separators'");
int i,j,k,l;
- Standard_PExtCharacter buftmp = allocateExtChars (mylength);
+ Standard_PExtCharacter buftmp = res.mystring;
Standard_ExtCharacter aSep;
Standard_Boolean isSepFound = Standard_False, otherSepFound;
}
}
- if (i < whichone) {
- buftmp[0] = 0;
- Standard::Free(buftmp);
+ if (i < whichone)
+ {
+ res.mylength = 0;
+ res.mystring[0] = 0;
}
- else {
- Standard::Free(res.mystring);
- res.mystring = buftmp;
+ else
+ {
for ( res.mylength=0; buftmp[res.mylength]; ++res.mylength );
res.mystring[res.mylength] = '\0';
}
// ----------------------------------------------------------------------------
Standard_ExtString TCollection_ExtendedString::ToExtString() const
{
- if(mystring) return mystring;
- return NULL_EXTSTRING;
+ return mystring;
}
// ----------------------------------------------------------------------------
*anIterWrite = '\0';
return Standard_Integer(anIterWrite - theCString);
}
+
+//=======================================================================
+//function : allocate
+//purpose :
+//=======================================================================
+void TCollection_ExtendedString::allocate(const int theLength)
+{
+ mylength = theLength;
+ if (theLength == 0)
+ {
+ mystring = THE_DEFAULT_EXT_CHAR_STRING;
+ }
+ else
+ {
+ const Standard_Size aRoundSize = (((theLength + 1) * sizeof(Standard_ExtCharacter)) + 3) & ~0x3;
+ mystring = static_cast<Standard_PExtCharacter>(
+ Standard::AllocateOptimal(aRoundSize));
+ mystring[mylength] = '\0';
+ }
+}
+
+//=======================================================================
+//function : reallocate
+//purpose :
+//=======================================================================
+void TCollection_ExtendedString::reallocate(const int theLength)
+{
+ if (theLength != 0)
+ {
+ if (mystring == THE_DEFAULT_EXT_CHAR_STRING)
+ {
+ const Standard_Size aRoundSize = (((theLength + 1) * sizeof(Standard_ExtCharacter)) + 3) & ~0x3;
+ mystring = static_cast<Standard_PExtCharacter>(Standard::AllocateOptimal(aRoundSize));
+ }
+ else
+ {
+ mystring = static_cast<Standard_PExtCharacter>(
+ Standard::Reallocate(mystring, (theLength + 1) * sizeof(Standard_ExtCharacter)));
+ }
+ mystring[theLength] = 0;
+ }
+ if (mystring != THE_DEFAULT_EXT_CHAR_STRING)
+ {
+ mystring[theLength] = 0;
+ }
+ mylength = theLength;
+}
+
+//=======================================================================
+//function : deallocate
+//purpose :
+//=======================================================================
+void TCollection_ExtendedString::deallocate()
+{
+ if (mystring != THE_DEFAULT_EXT_CHAR_STRING)
+ {
+ Standard::Free(mystring);
+ }
+ mylength = 0;
+ mystring = THE_DEFAULT_EXT_CHAR_STRING;
+}
#include <Standard_Integer.hxx>
#include <Standard_CString.hxx>
#include <Standard_Boolean.hxx>
-#include <Standard_ExtString.hxx>
#include <Standard_Character.hxx>
#include <Standard_ExtCharacter.hxx>
#include <Standard_Real.hxx>
Standard_EXPORT TCollection_ExtendedString(const TCollection_ExtendedString& astring);
//! Move constructor
- TCollection_ExtendedString (TCollection_ExtendedString&& theOther) Standard_Noexcept
- : mystring (theOther.mystring),
- mylength (theOther.mylength)
- {
- theOther.mystring = NULL;
- theOther.mylength = 0;
- }
+ Standard_EXPORT TCollection_ExtendedString (TCollection_ExtendedString&& theOther) Standard_Noexcept;
//! Creation by converting an Ascii string to an extended
//! string. The string is treated as having UTF-8 coding.
//! Copy <fromwhere> to <me>.
//! Used as operator =
Standard_EXPORT void Copy (const TCollection_ExtendedString& fromwhere);
-void operator = (const TCollection_ExtendedString& fromwhere)
-{
- Copy(fromwhere);
-}
- //! Exchange the data of two strings (without reallocating memory).
- Standard_EXPORT void Swap (TCollection_ExtendedString& theOther);
+ //! Copy assignment operator
+ TCollection_ExtendedString& operator= (const TCollection_ExtendedString& theOther)
+ {
+ Copy(theOther);
+ return *this;
+ }
+
+ //! Moves string without reallocations
+ Standard_EXPORT void Move (TCollection_ExtendedString&& theOther);
//! Move assignment operator
- TCollection_ExtendedString& operator= (TCollection_ExtendedString&& theOther) Standard_Noexcept { Swap (theOther); return *this; }
+ TCollection_ExtendedString& operator= (TCollection_ExtendedString&& theOther) noexcept
+ {
+ Move(std::forward<TCollection_ExtendedString>(theOther));
+ return *this;
+ }
+
+ //! Exchange the data of two strings (without reallocating memory).
+ Standard_EXPORT void Swap (TCollection_ExtendedString& theOther);
//! Frees memory allocated by ExtendedString.
Standard_EXPORT ~TCollection_ExtendedString();
//! the bounds of this extended string.
Standard_EXPORT Standard_ExtCharacter Value (const Standard_Integer where) const;
- //! Returns a hashed value for the extended string within the range 1 .. theUpper.
+ //! Returns a hashed value for the extended string.
//! Note: if string is ASCII, the computed value is the same as the value computed with the HashCode function on a
//! TCollection_AsciiString string composed with equivalent ASCII characters.
- //! @param theString the extended string 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 TCollection_ExtendedString& theString,
- const Standard_Integer theUpperBound)
+ //! @return a computed hash code
+ size_t HashCode () const
{
- return ::HashCode (theString.ToExtString(), theUpperBound);
+ const int aSize = mylength * sizeof(Standard_ExtCharacter);
+ if (mylength < 2)
+ {
+ return opencascade::FNVHash::hash_combine(*mystring, aSize);
+ }
+ return opencascade::hashBytes(mystring, aSize);
}
//! Returns true if the characters in this extended
private:
//! Returns true if the input CString was successfully converted to UTF8 coding.
- Standard_EXPORT Standard_Boolean ConvertToUnicode (const Standard_CString astring);
+ Standard_Boolean ConvertToUnicode (const Standard_CString astring);
-private:
+ //! Internal wrapper to allocate on stack or heap
+ void allocate(const int theLength);
- Standard_PExtCharacter mystring; //!< NULL-terminated string
- Standard_Integer mylength; //!< length in 16-bit code units (excluding terminating NULL symbol)
+ //! Internal wrapper to reallocate on stack or heap
+ void reallocate(const int theLength);
+ //! Internal wrapper to deallocate on stack
+ void deallocate();
+
+private:
+
+ Standard_PExtCharacter mystring{}; //!< NULL-terminated string
+ Standard_Integer mylength{}; //!< length in 16-bit code units (excluding terminating NULL symbol)
};
-//! Computes a hash code for the given extended string, in the range [1, theUpperBound]
-//! @param theExtendedString the extended string 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]
-inline Standard_Integer HashCode (const TCollection_ExtendedString& theExtendedString,
- const Standard_Integer theUpperBound)
+namespace std
{
- return TCollection_ExtendedString::HashCode (theExtendedString, theUpperBound);
+ template <>
+ struct hash<TCollection_ExtendedString>
+ {
+ size_t operator()(const TCollection_ExtendedString& theString) const
+ {
+ return theString.HashCode();
+ }
+ };
}
#endif // _TCollection_ExtendedString_HeaderFile
//! Initializes a HAsciiString with a AsciiString.
Standard_EXPORT TCollection_HAsciiString(const TCollection_AsciiString& aString);
+
+ //! Initializes a HAsciiString with a AsciiString.
+ TCollection_HAsciiString(TCollection_AsciiString&& theString) noexcept :
+ myString(std::move(theString))
+ {}
//! Initializes a HAsciiString with a HAsciiString.
Standard_EXPORT TCollection_HAsciiString(const Handle(TCollection_HAsciiString)& aString);
// ----------------------------------------------------------------------------
inline Standard_CString TCollection_HAsciiString::ToCString() const
{ return myString.ToCString(); }
+
+namespace std
+{
+ template <>
+ struct hash<Handle(TCollection_HAsciiString)>
+ {
+ size_t operator()(const Handle(TCollection_HAsciiString)& theString) const
+ {
+ if (theString.IsNull()) return 0;
+ return std::hash<TCollection_AsciiString>{}(theString->String());
+ }
+ };
+
+ template<>
+ struct equal_to<Handle(TCollection_HAsciiString)>
+ {
+ bool operator()(const Handle(TCollection_HAsciiString)& theString1,
+ const Handle(TCollection_HAsciiString)& theString2) const
+ {
+ return theString1 == theString2 ||
+ (!theString1.IsNull() && !theString2.IsNull() && theString1->String() == theString2->String());
+ }
+ };
+}
//! and filled with <filler>. This is useful for buffers.
Standard_EXPORT TCollection_HExtendedString(const Standard_Integer length, const Standard_ExtCharacter filler);
- //! Initializes a HExtendedString with a HExtendedString.
+ //! Initializes a HExtendedString with a ExtendedString.
Standard_EXPORT TCollection_HExtendedString(const TCollection_ExtendedString& aString);
+
+ //! Initializes a HExtendedString with a ExtendedString.
+ TCollection_HExtendedString(TCollection_ExtendedString&& theString) noexcept :
+ myString(std::move(theString))
+ {}
//! Initializes a HExtendedString with an HAsciiString.
Standard_EXPORT TCollection_HExtendedString(const Handle(TCollection_HAsciiString)& aString);
};
-
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<Handle(TCollection_HExtendedString)>
+ {
+ size_t operator()(const Handle(TCollection_HExtendedString)& theString) const
+ {
+ if (theString.IsNull()) return 0;
+ return std::hash<TCollection_ExtendedString>{}(theString->String());
+ }
+ };
+
+ template<>
+ struct equal_to<Handle(TCollection_HExtendedString)>
+ {
+ bool operator()(const Handle(TCollection_HExtendedString)& theString1,
+ const Handle(TCollection_HExtendedString)& theString2) const
+ {
+ return theString1 == theString2 ||
+ (!theString1.IsNull() && !theString2.IsNull() && theString1->String() == theString2->String());
+
+ }
+ };
+}
#endif // _TCollection_HExtendedString_HeaderFile
TDF_LabelIntegerMap.hxx
TDF_LabelList.hxx
TDF_LabelMap.hxx
-TDF_LabelMapHasher.hxx
TDF_LabelNode.cxx
TDF_LabelNode.hxx
TDF_LabelNodePtr.hxx
#define TDF_AttributeDataMap_HeaderFile
#include <TDF_Attribute.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(TDF_Attribute),Handle(TDF_Attribute),TColStd_MapTransientHasher> TDF_AttributeDataMap;
-typedef NCollection_DataMap<Handle(TDF_Attribute),Handle(TDF_Attribute),TColStd_MapTransientHasher>::Iterator TDF_DataMapIteratorOfAttributeDataMap;
+typedef NCollection_DataMap<Handle(TDF_Attribute),Handle(TDF_Attribute)> TDF_AttributeDataMap;
+typedef NCollection_DataMap<Handle(TDF_Attribute),Handle(TDF_Attribute)>::Iterator TDF_DataMapIteratorOfAttributeDataMap;
#endif
#include <TDF_Attribute.hxx>
#include <TDF_Attribute.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<Handle(TDF_Attribute),Handle(TDF_Attribute),TColStd_MapTransientHasher,TColStd_MapTransientHasher> TDF_AttributeDoubleMap;
-typedef NCollection_DoubleMap<Handle(TDF_Attribute),Handle(TDF_Attribute),TColStd_MapTransientHasher,TColStd_MapTransientHasher>::Iterator TDF_DoubleMapIteratorOfAttributeDoubleMap;
+typedef NCollection_DoubleMap<Handle(TDF_Attribute),Handle(TDF_Attribute)> TDF_AttributeDoubleMap;
+typedef NCollection_DoubleMap<Handle(TDF_Attribute),Handle(TDF_Attribute)>::Iterator TDF_DoubleMapIteratorOfAttributeDoubleMap;
#endif
#ifndef TDF_AttributeIndexedMap_HeaderFile
#define TDF_AttributeIndexedMap_HeaderFile
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_IndexedMap.hxx>
class TDF_Attribute;
-typedef NCollection_IndexedMap<Handle(TDF_Attribute),TColStd_MapTransientHasher> TDF_AttributeIndexedMap;
+typedef NCollection_IndexedMap<Handle(TDF_Attribute)> TDF_AttributeIndexedMap;
#endif
#define TDF_AttributeMap_HeaderFile
#include <TDF_Attribute.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Handle(TDF_Attribute),TColStd_MapTransientHasher> TDF_AttributeMap;
-typedef NCollection_Map<Handle(TDF_Attribute),TColStd_MapTransientHasher>::Iterator TDF_MapIteratorOfAttributeMap;
+typedef NCollection_Map<Handle(TDF_Attribute)> TDF_AttributeMap;
+typedef NCollection_Map<Handle(TDF_Attribute)>::Iterator TDF_MapIteratorOfAttributeMap;
#endif
#include <TDF_LabelMap.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
#include <TDF_RelocationTable.hxx>
+#include <Standard_TypeMismatch.hxx>
//=======================================================================
//function : Copy
#include <NCollection_DataMap.hxx>
#include <Standard_Mutex.hxx>
+#include <Standard_CStringHasher.hxx>
#include <TCollection_AsciiString.hxx>
namespace TDF_DerivedAttributeGlobals
return THE_CREATORS_LIST;
}
//! Global map of the string-type of derived attribute -> instance of such attribute
- static NCollection_DataMap<Standard_CString, Handle(TDF_Attribute)>& Attributes()
+ static NCollection_DataMap<Standard_CString, Handle(TDF_Attribute), Standard_CStringHasher>& Attributes()
{
- static NCollection_DataMap<Standard_CString, Handle(TDF_Attribute)> THE_DERIVED;
+ static NCollection_DataMap<Standard_CString, Handle(TDF_Attribute), Standard_CStringHasher> THE_DERIVED;
return THE_DERIVED;
}
//! Global map of the string-type of derived attribute -> type name to identify this attribute
- static NCollection_DataMap<Standard_CString, TCollection_AsciiString*>& Types()
+ static NCollection_DataMap<Standard_CString, TCollection_AsciiString*, Standard_CStringHasher>& Types()
{
- static NCollection_DataMap<Standard_CString, TCollection_AsciiString*> THE_DERIVED_TYPES;
+ static NCollection_DataMap<Standard_CString, TCollection_AsciiString*, Standard_CStringHasher> THE_DERIVED_TYPES;
return THE_DERIVED_TYPES;
}
{
Standard_Mutex::Sentry aSentry (TDF_DerivedAttributeGlobals::Mutex());
Initialize();
- NCollection_DataMap<Standard_CString, Handle(TDF_Attribute)>::Iterator anAttrIter;
+ NCollection_DataMap<Standard_CString, Handle(TDF_Attribute), Standard_CStringHasher>::Iterator anAttrIter;
for (anAttrIter.Initialize (TDF_DerivedAttributeGlobals::Attributes()); anAttrIter.More(); anAttrIter.Next())
{
theList.Append (anAttrIter.Value());
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<Standard_GUID,TCollection_ExtendedString,Standard_GUID,TCollection_ExtendedString> TDF_GUIDProgIDMap;
-typedef NCollection_DoubleMap<Standard_GUID,TCollection_ExtendedString,Standard_GUID,TCollection_ExtendedString>::Iterator TDF_DoubleMapIteratorOfGUIDProgIDMap;
+typedef NCollection_DoubleMap<Standard_GUID,TCollection_ExtendedString> TDF_GUIDProgIDMap;
+typedef NCollection_DoubleMap<Standard_GUID,TCollection_ExtendedString>::Iterator TDF_DoubleMapIteratorOfGUIDProgIDMap;
#endif
#include <Standard_GUID.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Standard_GUID,Standard_GUID> TDF_IDMap;
-typedef NCollection_Map<Standard_GUID,Standard_GUID>::Iterator TDF_MapIteratorOfIDMap;
+typedef NCollection_Map<Standard_GUID> TDF_IDMap;
+typedef NCollection_Map<Standard_GUID>::Iterator TDF_MapIteratorOfIDMap;
#endif
friend class TDF_Attribute;
friend class TDF_AttributeIterator;
friend class TDF_Data;
-friend class TDF_LabelMapHasher;
+template<class T>
+friend struct std::hash;
protected:
#include <TDF_TagSource.hxx>
#include <TDF_Data.hxx>
+namespace std
+{
+ template<>
+ struct hash<TDF_Label>
+ {
+ size_t operator()(const TDF_Label& theNode) const
+ {
+ return std::hash<TDF_LabelNodePtr>{}(theNode.myLabelNode);
+ }
+ };
+}
+
inline TDF_Label::TDF_Label()
:myLabelNode(NULL)
{}
#define TDF_LabelDataMap_HeaderFile
#include <TDF_Label.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TDF_Label,TDF_Label,TDF_LabelMapHasher> TDF_LabelDataMap;
-typedef NCollection_DataMap<TDF_Label,TDF_Label,TDF_LabelMapHasher>::Iterator TDF_DataMapIteratorOfLabelDataMap;
+typedef NCollection_DataMap<TDF_Label,TDF_Label> TDF_LabelDataMap;
+typedef NCollection_DataMap<TDF_Label,TDF_Label>::Iterator TDF_DataMapIteratorOfLabelDataMap;
#endif
#ifndef TDF_LabelDoubleMap_HeaderFile
#define TDF_LabelDoubleMap_HeaderFile
-#include <TDF_LabelMapHasher.hxx>
+#include <TDF_Label.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<TDF_Label,TDF_Label,TDF_LabelMapHasher,TDF_LabelMapHasher> TDF_LabelDoubleMap;
-typedef NCollection_DoubleMap<TDF_Label,TDF_Label,TDF_LabelMapHasher,TDF_LabelMapHasher>::Iterator TDF_DoubleMapIteratorOfLabelDoubleMap;
+typedef NCollection_DoubleMap<TDF_Label,TDF_Label> TDF_LabelDoubleMap;
+typedef NCollection_DoubleMap<TDF_Label,TDF_Label>::Iterator TDF_DoubleMapIteratorOfLabelDoubleMap;
#endif
#ifndef TDF_LabelIndexedMap_HeaderFile
#define TDF_LabelIndexedMap_HeaderFile
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<TDF_Label,TDF_LabelMapHasher> TDF_LabelIndexedMap;
+typedef NCollection_IndexedMap<TDF_Label> TDF_LabelIndexedMap;
#endif
#include <TDF_Label.hxx>
#include <Standard_Integer.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TDF_Label,Standard_Integer,TDF_LabelMapHasher> TDF_LabelIntegerMap;
-typedef NCollection_DataMap<TDF_Label,Standard_Integer,TDF_LabelMapHasher>::Iterator TDF_DataMapIteratorOfLabelIntegerMap;
+typedef NCollection_DataMap<TDF_Label,Standard_Integer> TDF_LabelIntegerMap;
+typedef NCollection_DataMap<TDF_Label,Standard_Integer>::Iterator TDF_DataMapIteratorOfLabelIntegerMap;
#endif
#define TDF_LabelMap_HeaderFile
#include <TDF_Label.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<TDF_Label,TDF_LabelMapHasher> TDF_LabelMap;
-typedef NCollection_Map<TDF_Label,TDF_LabelMapHasher>::Iterator TDF_MapIteratorOfLabelMap;
+typedef NCollection_Map<TDF_Label> TDF_LabelMap;
+typedef NCollection_Map<TDF_Label>::Iterator TDF_MapIteratorOfLabelMap;
#endif
+++ /dev/null
-// Created by: DAUTRY Philippe
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-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 _TDF_LabelMapHasher_HeaderFile
-#define _TDF_LabelMapHasher_HeaderFile
-
-#include <TDF_Label.hxx>
-
-//! A label hasher for label maps.
-class TDF_LabelMapHasher
-{
-public:
- //! Computes a hash code for the given label, in the range [1, theUpperBound]
- //! @param theLabel the label 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 TDF_Label& theLabel, const Standard_Integer theUpperBound)
- {
- return ::HashCode(theLabel.myLabelNode, theUpperBound);
- }
-
- //! Returns True when the two keys are the same. Two
- //! same keys must have the same hashcode, the
- //! contrary is not necessary.
- static Standard_Boolean IsEqual(const TDF_Label& aLab1, const TDF_Label& aLab2)
- {
- return aLab1.IsEqual(aLab2);
- }
-};
-
-#endif // _TDF_LabelMapHasher_HeaderFile
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Byte,TCollection_ExtendedString> TDataStd_DataMapOfStringByte;
-typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Byte,TCollection_ExtendedString>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringByte;
+typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Byte> TDataStd_DataMapOfStringByte;
+typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Byte>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringByte;
#endif
#include <TColStd_HArray1OfInteger.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfInteger),TCollection_ExtendedString> TDataStd_DataMapOfStringHArray1OfInteger;
-typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfInteger),TCollection_ExtendedString>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger;
+typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfInteger)> TDataStd_DataMapOfStringHArray1OfInteger;
+typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfInteger)>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger;
#endif
#include <TColStd_HArray1OfReal.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfReal),TCollection_ExtendedString> TDataStd_DataMapOfStringHArray1OfReal;
-typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfReal),TCollection_ExtendedString>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal;
+typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfReal)> TDataStd_DataMapOfStringHArray1OfReal;
+typedef NCollection_DataMap<TCollection_ExtendedString,Handle(TColStd_HArray1OfReal)>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal;
#endif
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Real,TCollection_ExtendedString> TDataStd_DataMapOfStringReal;
-typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Real,TCollection_ExtendedString>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringReal;
+typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Real> TDataStd_DataMapOfStringReal;
+typedef NCollection_DataMap<TCollection_ExtendedString,Standard_Real>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringReal;
#endif
#include <TCollection_ExtendedString.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_ExtendedString,TCollection_ExtendedString,TCollection_ExtendedString> TDataStd_DataMapOfStringString;
-typedef NCollection_DataMap<TCollection_ExtendedString,TCollection_ExtendedString,TCollection_ExtendedString>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringString;
+typedef NCollection_DataMap<TCollection_ExtendedString,TCollection_ExtendedString> TDataStd_DataMapOfStringString;
+typedef NCollection_DataMap<TCollection_ExtendedString,TCollection_ExtendedString>::Iterator TDataStd_DataMapIteratorOfDataMapOfStringString;
#endif
#include <TDF_DeltaList.hxx>
#include <CDM_Document.hxx>
#include <TDF_LabelMap.hxx>
-#include <Standard_Address.hxx>
#include <TDocStd_FormatVersion.hxx>
class TDF_Data;
class TDF_Delta;
#include <TDF_Label.hxx>
#include <TDF_IDMap.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TDF_Label,TDF_IDMap,TDF_LabelMapHasher> TDocStd_LabelIDMapDataMap;
-typedef NCollection_DataMap<TDF_Label,TDF_IDMap,TDF_LabelMapHasher>::Iterator TDocStd_DataMapIteratorOfLabelIDMapDataMap;
+typedef NCollection_DataMap<TDF_Label,TDF_IDMap> TDocStd_LabelIDMapDataMap;
+typedef NCollection_DataMap<TDF_Label,TDF_IDMap>::Iterator TDocStd_DataMapIteratorOfLabelIDMapDataMap;
#endif
#include <Standard_GUID.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_GUID,Handle(TFunction_Driver),Standard_GUID> TFunction_DataMapOfGUIDDriver;
-typedef NCollection_DataMap<Standard_GUID,Handle(TFunction_Driver),Standard_GUID>::Iterator TFunction_DataMapIteratorOfDataMapOfGUIDDriver;
+typedef NCollection_DataMap<Standard_GUID,Handle(TFunction_Driver)> TFunction_DataMapOfGUIDDriver;
+typedef NCollection_DataMap<Standard_GUID,Handle(TFunction_Driver)>::Iterator TFunction_DataMapIteratorOfDataMapOfGUIDDriver;
#endif
#define TFunction_DataMapOfLabelListOfLabel_HeaderFile
#include <TDF_LabelList.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TDF_Label,TDF_LabelList,TDF_LabelMapHasher> TFunction_DataMapOfLabelListOfLabel;
-typedef NCollection_DataMap<TDF_Label,TDF_LabelList,TDF_LabelMapHasher>::Iterator TFunction_DataMapIteratorOfDataMapOfLabelListOfLabel;
+typedef NCollection_DataMap<TDF_Label,TDF_LabelList> TFunction_DataMapOfLabelListOfLabel;
+typedef NCollection_DataMap<TDF_Label,TDF_LabelList>::Iterator TFunction_DataMapIteratorOfDataMapOfLabelListOfLabel;
#endif
#include <Standard_Integer.hxx>
#include <TDF_Label.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
-#include <TDF_LabelMapHasher.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<Standard_Integer,TDF_Label,TColStd_MapIntegerHasher,TDF_LabelMapHasher> TFunction_DoubleMapOfIntegerLabel;
-typedef NCollection_DoubleMap<Standard_Integer,TDF_Label,TColStd_MapIntegerHasher,TDF_LabelMapHasher>::Iterator TFunction_DoubleMapIteratorOfDoubleMapOfIntegerLabel;
+typedef NCollection_DoubleMap<Standard_Integer,TDF_Label> TFunction_DoubleMapOfIntegerLabel;
+typedef NCollection_DoubleMap<Standard_Integer,TDF_Label>::Iterator TFunction_DoubleMapIteratorOfDoubleMapOfIntegerLabel;
#endif
TNaming_NamedShape.cxx
TNaming_NamedShape.hxx
TNaming_NamedShape.lxx
-TNaming_NamedShapeHasher.hxx
TNaming_NameType.hxx
TNaming_Naming.cxx
TNaming_Naming.hxx
// Standard_Boolean Found = Standard_False;
for (; itS.More(); itS.Next(),itSS.Next()) {
if (In.IsSame(itS.Value())) {
- TopTools_MapOfShape& SubShapes = itSS.Value();
+ TopTools_MapOfShape& SubShapes = itSS.ChangeValue();
for (TopExp_Explorer exp(In,TS); exp.More(); exp.Next()) {
const TopoDS_Shape& SS = exp.Current();
if (SubShapes.Contains(SS)) {
//-----------------------
// Ancetres existent.
//-----------------------
- TopTools_IndexedDataMapOfShapeListOfShape& Anc = itA.Value();
+ TopTools_IndexedDataMapOfShapeListOfShape& Anc = itA.ChangeValue();
TopExp_Explorer exp(In,TS);
#ifdef OCCT_DEBUG
#ifndef TNaming_MapOfNamedShape_HeaderFile
#define TNaming_MapOfNamedShape_HeaderFile
-#include <TNaming_NamedShapeHasher.hxx>
+#include <TNaming_NamedShape.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<Handle(TNaming_NamedShape),TNaming_NamedShapeHasher> TNaming_MapOfNamedShape;
-typedef NCollection_Map<Handle(TNaming_NamedShape),TNaming_NamedShapeHasher>::Iterator TNaming_MapIteratorOfMapOfNamedShape;
+typedef NCollection_Map<Handle(TNaming_NamedShape)> TNaming_MapOfNamedShape;
+typedef NCollection_Map<Handle(TNaming_NamedShape)>::Iterator TNaming_MapIteratorOfMapOfNamedShape;
#endif
+++ /dev/null
-// Created on: 1997-03-17
-// Created by: Yves FRICAUD
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-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 TNaming_NamedShapeHasher_HeaderFile
-#define TNaming_NamedShapeHasher_HeaderFile
-
-#include <TNaming_NamedShape.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<Handle(TNaming_NamedShape)> TNaming_NamedShapeHasher;
-
-
-#endif
TObj_Assistant.hxx
TObj_CheckModel.cxx
TObj_CheckModel.hxx
-TObj_Common.hxx
TObj_Container.hxx
TObj_DeletingMode.hxx
TObj_HiddenPartition.cxx
#define TObj_Application_HeaderFile
#include <TDocStd_Application.hxx>
-#include <TObj_Common.hxx>
#include <Message_Gravity.hxx>
#include <Message_Messenger.hxx>
#include <TObj_Assistant.hxx>
-#include <TObj_Common.hxx>
#include <TObj_Model.hxx>
#include <TColStd_SequenceOfTransient.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#ifndef TObj_Assistant_HeaderFile
#define TObj_Assistant_HeaderFile
-#include <TObj_Common.hxx>
#include <TColStd_SequenceOfTransient.hxx>
#include <TColStd_IndexedMapOfTransient.hxx>
+++ /dev/null
-// Created on: 2004-11-22
-// Created by: Pavel TELKOV
-// Copyright (c) 2004-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.
-
-// The original implementation Copyright: (C) RINA S.p.A
-
-// Purpose: This header file collects basic definitions
-// to be included in most of sources
-
-#ifndef TObj_Common_HeaderFile
-#define TObj_Common_HeaderFile
-
-//! Basic CASCADE definitions
-#include <Standard_Transient.hxx>
-#include <TCollection_HExtendedString.hxx>
-
-//! Methods inline implementation for HExtendedString
-
-//! Computes a hash code for the given handle referred to extended string, in the range [1, theUpperBound]
-//! @param theHExtendedString the handle referred to extended string 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]
-inline Standard_Integer HashCode (const Handle (TCollection_HExtendedString) & theHExtendedString,
- const Standard_Integer theUpperBound)
-{
- return TCollection_ExtendedString::HashCode (theHExtendedString->String(), theUpperBound);
-}
-
-inline Standard_Boolean IsEqual (const Handle(TCollection_HExtendedString)& theStr1,
- const Handle(TCollection_HExtendedString)& theStr2)
-{
- return TCollection_ExtendedString::IsEqual(theStr1->String(),theStr2->String());
-}
-
-#endif
-
-#ifdef _MSC_VER
-#pragma once
-#endif
#include <TCollection_HExtendedString.hxx>
#include <TDF_Label.hxx>
-#include <TObj_Common.hxx>
#include <TObj_SequenceOfObject.hxx>
typedef NCollection_DataMap<Handle(TCollection_HExtendedString), TDF_Label> TObj_DataMapOfNameLabel;
#ifndef TObj_Object_HeaderFile
#define TObj_Object_HeaderFile
-#include <TObj_Common.hxx>
#include <TObj_DeletingMode.hxx>
#include <TObj_SequenceOfObject.hxx>
class TObj_ObjectIterator;
class TObj_TNameContainer;
class TCollection_HExtendedString;
+class TCollection_HAsciiString;
+
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfExtendedString.hxx>
#ifndef TObj_ObjectIterator_HeaderFile
#define TObj_ObjectIterator_HeaderFile
-#include <TObj_Common.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_DefineHandle.hxx>
class TObj_Object;
#ifndef TObj_TIntSparseArray_HeaderFile
#define TObj_TIntSparseArray_HeaderFile
-#include <TObj_Common.hxx>
#include <NCollection_SparseArray.hxx>
#include <TDF_Label.hxx>
#ifndef TObj_TObject_HeaderFile
#define TObj_TObject_HeaderFile
-#include <TObj_Common.hxx>
#include <TObj_Object.hxx>
#include <TDF_Attribute.hxx>
#ifndef TObj_TReference_HeaderFile
#define TObj_TReference_HeaderFile
-#include <TObj_Common.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Label.hxx>
#ifndef TObj_TXYZ_HeaderFile
#define TObj_TXYZ_HeaderFile
-#include <TObj_Common.hxx>
#include <gp_XYZ.hxx>
#include <TDF_Attribute.hxx>
#include <TPrsStd_Driver.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_GUID,Handle(TPrsStd_Driver),Standard_GUID> TPrsStd_DataMapOfGUIDDriver;
-typedef NCollection_DataMap<Standard_GUID,Handle(TPrsStd_Driver),Standard_GUID>::Iterator TPrsStd_DataMapIteratorOfDataMapOfGUIDDriver;
+typedef NCollection_DataMap<Standard_GUID,Handle(TPrsStd_Driver)> TPrsStd_DataMapOfGUIDDriver;
+typedef NCollection_DataMap<Standard_GUID,Handle(TPrsStd_Driver)>::Iterator TPrsStd_DataMapIteratorOfDataMapOfGUIDDriver;
#endif
TopLoc_Location.hxx
TopLoc_Location.lxx
TopLoc_MapIteratorOfMapOfLocation.hxx
-TopLoc_MapLocationHasher.hxx
TopLoc_MapOfLocation.hxx
TopLoc_SListNodeOfItemLocation.cxx
TopLoc_SListNodeOfItemLocation.hxx
#define TopLoc_IndexedMapOfLocation_HeaderFile
#include <TopLoc_Location.hxx>
-#include <TopLoc_MapLocationHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<TopLoc_Location,TopLoc_MapLocationHasher> TopLoc_IndexedMapOfLocation;
+typedef NCollection_IndexedMap<TopLoc_Location> TopLoc_IndexedMapOfLocation;
#endif
#include <TopLoc_Location.hxx>
#include <TopLoc_SListOfItemLocation.hxx>
-static const gp_Trsf TheIdentity;
-
//=======================================================================
//function : TopLoc_Location
//purpose : constructor Identity
TopLoc_Location::TopLoc_Location(const gp_Trsf& T)
{
Handle(TopLoc_Datum3D) D = new TopLoc_Datum3D(T);
- myItems.Construct(TopLoc_ItemLocation(D,1));
+ myItems.Construct(TopLoc_ItemLocation(D, 1));
}
//=======================================================================
const gp_Trsf& TopLoc_Location::Transformation() const
{
+ static const gp_Trsf THE_IDENTITY_TRSF;
if (IsIdentity())
- return TheIdentity;
+ return THE_IDENTITY_TRSF;
else
return myItems.Value().myTrsf;
}
else return Inverted().Powered(-pwr);
}
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-Standard_Integer TopLoc_Location::HashCode (const Standard_Integer theUpperBound) const
-{
- // the HashCode computed for a Location is the bitwise exclusive or
- // of values computed for each element of the list
- // to compute this value, the depth of the element is computed
- // the depth is the position of the element in the list
- // this depth is multiplied by 3
- // each element is an elementary Datum raised to a Power
- // the Power is bitwise left shifted by depth
- // this is added to the HashCode of the Datum
- // this value is biwise rotated by depth
- // the use of depth avoids getting the same result for two permutated lists.
-
- Standard_Integer depth = 0;
- unsigned int h = 0;
- TopLoc_SListOfItemLocation items = myItems;
- while (items.More())
- {
- depth += 3;
- unsigned int i = ::HashCode (items.Value().myDatum, theUpperBound);
- const Standard_Integer aClampedDepth = depth % 32;
- unsigned int j = ((i + items.Value().myPower) << aClampedDepth);
- j = j >> (32 - aClampedDepth) | j << aClampedDepth;
- h ^= j;
- items.Next ();
- }
- return ::HashCode (h, theUpperBound);
-}
-
//=======================================================================
//function : IsEqual
//purpose : operator ==
Standard_NODISCARD Standard_EXPORT TopLoc_Location Powered (const Standard_Integer pwr) const;
//! Returns a hashed value for this local coordinate system. This value is used, with map tables, to store and
- //! retrieve the object easily, and is in the range [1, theUpperBound].
- //! @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]
- Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
+ //! retrieve the object easily
+ //! @return a computed hash code
+ size_t HashCode () const;
//! Returns true if this location and the location Other
//! have the same elementary data, i.e. contain the same
};
-
#include <TopLoc_Location.lxx>
-
-//! Computes a hash code for the given location, in the range [1, theUpperBound]
-//! @param theLocation the location 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]
-inline Standard_Integer HashCode (const TopLoc_Location& theLocation, const Standard_Integer theUpperBound)
-{
- return theLocation.HashCode (theUpperBound);
-}
-
-inline void ShallowDump(const TopLoc_Location& me,Standard_OStream& S) {
- me.ShallowDump(S);
-}
-
-
-
#endif // _TopLoc_Location_HeaderFile
// commercial license or contractual agreement.
#include <TopLoc_SListOfItemLocation.hxx>
+#include <TopLoc_Datum3D.hxx>
#include <TopLoc_ItemLocation.hxx>
//=======================================================================
return (*(TopLoc_Location*) &(myItems.Tail()));
}
+//=======================================================================
+// function : HashCode
+// purpose :
+//=======================================================================
+inline size_t TopLoc_Location::HashCode() const
+{
+ // Hashing base on IsEqual function
+ if (myItems.IsEmpty())
+ {
+ return 0;
+ }
+ size_t aHash = opencascade::MurmurHash::optimalSeed<size_t>();
+ TopLoc_SListOfItemLocation items = myItems;
+ size_t aCombined[3];
+ while (items.More())
+ {
+ aCombined[0] = std::hash<Handle(TopLoc_Datum3D)>{}(items.Value().myDatum);
+ aCombined[1] = opencascade::hash(items.Value().myPower);
+ aCombined[2] = aHash;
+ aHash = opencascade::hashBytes(aCombined, sizeof(aCombined));
+ items.Next();
+ }
+ return aHash;
+}
+//=======================================================================
+// function : ShallowDump
+// purpose :
+//=======================================================================
+inline void ShallowDump(const TopLoc_Location& me, Standard_OStream& S)
+{
+ me.ShallowDump(S);
+}
+
+namespace std
+{
+ template <>
+ struct hash<TopLoc_Location>
+ {
+ size_t operator()(const TopLoc_Location& theLocation) const
+ {
+ return theLocation.HashCode();
+ }
+ };
+}
+++ /dev/null
-// Created on: 1990-12-19
-// Created by: Christophe MARION
-// Copyright (c) 1990-1999 Matra Datavision
-// Copyright (c) 1999-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 TopLoc_MapLocationHasher_HeaderFile
-#define TopLoc_MapLocationHasher_HeaderFile
-
-#include <TopLoc_Location.hxx>
-#include <NCollection_DefaultHasher.hxx>
-
-typedef NCollection_DefaultHasher<TopLoc_Location> TopLoc_MapLocationHasher;
-
-
-#endif
#ifndef TopLoc_MapOfLocation_HeaderFile
#define TopLoc_MapOfLocation_HeaderFile
-#include <TopLoc_MapLocationHasher.hxx>
+#include <TopLoc_Location.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<TopLoc_Location,TopLoc_MapLocationHasher> TopLoc_MapOfLocation;
-typedef NCollection_Map<TopLoc_Location,TopLoc_MapLocationHasher>::Iterator TopLoc_MapIteratorOfMapOfLocation;
+typedef NCollection_Map<TopLoc_Location> TopLoc_MapOfLocation;
+typedef NCollection_Map<TopLoc_Location>::Iterator TopLoc_MapIteratorOfMapOfLocation;
#endif
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ const TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
- (LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
+ (LoopIter,AreaIter.ChangeValue(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
#include <TopOpeBRepBuild_AreaBuilder.hxx>
#include <Standard_Boolean.hxx>
#include <TopOpeBRepBuild_ListOfLoop.hxx>
-#include <Standard_Address.hxx>
class TopOpeBRepBuild_PaveSet;
class TopOpeBRepBuild_PaveClassifier;
class TopOpeBRepBuild_LoopSet;
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK );
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
- (LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
+ (LoopIter,AreaIter.ChangeValue(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK );
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
- (LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
+ (LoopIter,AreaIter.ChangeValue(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next()) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ const TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_BLOCK );
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
ADD_Loop_TO_LISTOFLoop(L,aArea,(void*)("IN, to current area"));
}
else if ( ! Loopinside ) {
Loopinside = Standard_False;
for (AreaIter.Initialize(myArea); AreaIter.More(); AreaIter.Next() ) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ const TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
if ( aArea.IsEmpty() ) continue;
state = CompareLoopWithListOfLoop(LC,L,aArea,TopOpeBRepBuild_ANYLOOP);
if (state == TopAbs_UNKNOWN) Atomize(state,TopAbs_IN);
} // end of Area scan
if ( Loopinside) {
- TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.Value();
+ TopOpeBRepBuild_ListOfLoop& aArea = AreaIter.ChangeValue();
Standard_Boolean allShape = Standard_True;
TopOpeBRepBuild_ListOfLoop removedLoops;
LoopIter.Initialize(aArea);
allShape = allShape && curL->IsShape();
REM_Loop_FROM_LISTOFLoop
- (LoopIter,AreaIter.Value(),(void*)("loop of cur. area, cur. area"));
+ (LoopIter,AreaIter.ChangeValue(),(void*)("loop of cur. area, cur. area"));
}
else {
LoopIter.Next();
#include <TopOpeBRepBuild_ListOfLoop.hxx>
#include <TopOpeBRepBuild_LoopEnum.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
class TopOpeBRepBuild_LoopSet;
class TopOpeBRepBuild_LoopClassifier;
class TopOpeBRepBuild_Loop;
TopTools_ListIteratorOfListOfShape It(EL);
Standard_Integer inewC = -1;
for (; It.More(); It.Next()) {
- TopoDS_Edge& newEdge = TopoDS::Edge(It.Value());
+ TopoDS_Edge& newEdge = TopoDS::Edge(It.ChangeValue());
myBuildTool.RecomputeCurves(curC,TopoDS::Edge(anEdge),newEdge,inewC,HDS);
if (inewC != -1) ChangeNewEdges(inewC).Append(newEdge);
}
}
else {
for (It.Initialize(EL);It.More();It.Next()) {
- TopoDS_Edge& newEdge = TopoDS::Edge(It.Value());
+ TopoDS_Edge& newEdge = TopoDS::Edge(It.ChangeValue());
myBuildTool.UpdateEdge(anEdge,newEdge);
}
}
Standard_Boolean TopOpeBRepBuild_Builder::Contains(const TopoDS_Shape& S,const TopTools_ListOfShape& L)
{
for (TopTools_ListIteratorOfListOfShape it(L); it.More(); it.Next() ) {
- TopoDS_Shape& SL = it.Value();
+ const TopoDS_Shape& SL = it.Value();
Standard_Boolean issame = SL.IsSame(S);
if ( issame ) return Standard_True;
}
#include <TopTools_DataMapOfIntegerShape.hxx>
#include <TopOpeBRepDS_Config.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
-#include <Standard_Address.hxx>
class TopOpeBRepDS_HDataStructure;
class TopOpeBRepTool_ShapeExplorer;
class TopOpeBRepBuild_ShapeSet;
TopTools_ListIteratorOfListOfShape its(Merged(myShape1,myState1));
for (; its.More(); its.Next()) {
- CorrectResult2d(its.Value());
+ CorrectResult2d(its.ChangeValue());
}
}
// we are looking for the same piece as aPieceObj among aPartOnTool
TopTools_ListIteratorOfListOfShape anItTool(aPartOnTool);
for (k=1; anItTool.More(); anItTool.Next(), k++) {
- TopoDS_Shape& aPieceTool=anItTool.Value();
+ TopoDS_Shape& aPieceTool=anItTool.ChangeValue();
aPieceTool.Orientation(anEdgeTool.Orientation());
Standard_Boolean aIsSameCnd, IsDegFlag;
TopoDS_Shape mySDFaceToFill;
TopoDS_Shape myBaseFaceToFill;
TopTools_IndexedDataMapOfShapeListOfShape myMapOfEdgeFaces;
- NCollection_DataMap<TopoDS_Shape, Standard_Boolean, TopTools_OrientedShapeMapHasher> myMapOfEdgeWithFaceState;
+ NCollection_DataMap<TopoDS_Shape, Standard_Boolean> myMapOfEdgeWithFaceState;
TopTools_IndexedMapOfShape myProcessedPartsOut2d;
TopTools_IndexedMapOfShape myProcessedPartsON2d;
TopTools_IndexedMapOfShape mySplitsONtoKeep;
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
-#include <Standard_Address.hxx>
#include <TopOpeBRepBuild_LoopClassifier.hxx>
#include <TopAbs_State.hxx>
class TopOpeBRepBuild_BlockBuilder;
#include <TopoDS_Wire.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedMapOfOrientedShape.hxx>
-#include <Standard_Address.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
class TopoDS_Edge;
class gp_Pnt2d;
// TopAbs_State state = myState1;
TopTools_ListOfShape& ls = ChangeMerged(myShape1,myState1);
for (TopTools_ListIteratorOfListOfShape itls(ls);itls.More();itls.Next()) {
- TopoDS_Shape& SFE = itls.Value();
+ TopoDS_Shape& SFE = itls.ChangeValue();
TopOpeBRepTool_FuseEdges FE(SFE);
// avoid fusing old edges
// les faces construites (LOFS) prennent l'orientation originale de FF
TopAbs_Orientation odsFF = myDataStructure->Shape(iFF).Orientation();
- for(TopTools_ListIteratorOfListOfShape itt(LOFS);itt.More();itt.Next()) itt.Value().Orientation(odsFF);
+ for(TopTools_ListIteratorOfListOfShape itt(LOFS);itt.More();itt.Next()) itt.ChangeValue().Orientation(odsFF);
TopTools_ListIteratorOfListOfShape it1;
for (it1.Initialize(LF1); it1.More(); it1.Next()) {
TopTools_ListOfShape& LOFS)
{
for (TopTools_ListIteratorOfListOfShape it(LOFS);it.More();it.Next()) {
- TopoDS_Shape& f = it.Value();
+ TopoDS_Shape& f = it.ChangeValue();
Standard_Boolean of1,of2; FUNBUILD_ANCESTORRANKGET(B,f,of1,of2);
TopAbs_Orientation orif = f.Orientation();
Standard_Boolean r12 = B.Reverse(TB1,TB2); Standard_Boolean r21 = B.Reverse(TB2,TB1);
its.Initialize(los);
if(re == 1)
for(; its.More(); its.Next()) {
- TopoDS_Shape& SecEdg = its.Value();
+ const TopoDS_Shape& SecEdg = its.Value();
if(!mySectEdgeDSEdges1.IsBound(SecEdg))
mySectEdgeDSEdges1.Bind(SecEdg, ei);
}
else if(re == 2)
for(; its.More(); its.Next()) {
- TopoDS_Shape& SecEdg = its.Value();
+ const TopoDS_Shape& SecEdg = its.Value();
if(!mySectEdgeDSEdges2.IsBound(SecEdg))
mySectEdgeDSEdges2.Bind(SecEdg,ei);
}
}
TopTools_ListIteratorOfListOfShape itlon(lon); for(;itlon.More();itlon.Next()) {
- TopoDS_Edge& eon = TopoDS::Edge(itlon.Value());
+ TopoDS_Edge& eon = TopoDS::Edge(itlon.ChangeValue());
Standard_Real f,l; Standard_Boolean hasPC = FC2D_HasCurveOnSurface(eon,F);
if (hasPC) continue;
#ifdef OCCT_DEBUG
#include <TopoDS_Solid.hxx>
#include <TopOpeBRepBuild_ShapeSet.hxx>
-#include <Standard_Address.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopTools_ListOfShape.hxx>
class TopoDS_Shape;
it1.Initialize(LI);
Standard_Boolean IsOK = Standard_True;
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference) I1 = it1.Value();
IsOK = IsOK && CheckDS(I1->Support(), I1->SupportType());
IsOK = IsOK && CheckDS(I1->Geometry(), I1->GeometryType());
it1.Next();
const TopOpeBRepDS_ListOfInterference& LI = DS.ShapeInterferences(i);
it1.Initialize(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference) I1 = it1.Value();
Handle(TopOpeBRepDS_EdgeVertexInterference) EVI =
Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I1);
if(!EVI.IsNull()) {
PrintMap(myMapPointStatus, "Point", OS);
//display of the topology
- TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(myMapShapeStatus);
TopOpeBRepDS_DataMapOfCheckStatus MapVertex, MapEdge, MapWire, MapFace, MapSolid;
Standard_Integer i;
// different Map keep their index of myMapShapeStatus
- for(DMI.Reset();DMI.More();DMI.Next()) {
+ for(TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(myMapShapeStatus); DMI.More();DMI.Next())
+ {
i = DMI.Key();
const TopoDS_Shape& S =myHDS->Shape(i);
switch(S.ShapeType()) {
Standard_Boolean& b,
Standard_OStream& OS)
{
- TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(MapStat);
Standard_Boolean bb = !b;
b = Standard_True;
Standard_Integer i;
TopOpeBRepDS_CheckStatus s;
- for(DMI.Reset();DMI.More();DMI.Next()) {
+ for(TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(MapStat);
+ DMI.More();DMI.Next())
+ {
s = DMI.Value();
i = DMI.Key();
if(s == Stat) {
#include <Standard_Integer.hxx>
#include <TopOpeBRepDS_CheckStatus.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CheckStatus,TColStd_MapIntegerHasher> TopOpeBRepDS_DataMapOfCheckStatus;
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CheckStatus,TColStd_MapIntegerHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CheckStatus> TopOpeBRepDS_DataMapOfCheckStatus;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CheckStatus>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus;
#endif
#include <Standard_Integer.hxx>
#include <TopOpeBRepDS_ListOfInterference.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ListOfInterference,TColStd_MapIntegerHasher> TopOpeBRepDS_DataMapOfIntegerListOfInterference;
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ListOfInterference,TColStd_MapIntegerHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ListOfInterference> TopOpeBRepDS_DataMapOfIntegerListOfInterference;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ListOfInterference>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfIntegerListOfInterference;
#endif
#define TopOpeBRepDS_DataMapOfInterferenceListOfInterference_HeaderFile
#include <TopOpeBRepDS_ListOfInterference.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopOpeBRepDS_ListOfInterference,TColStd_MapTransientHasher> TopOpeBRepDS_DataMapOfInterferenceListOfInterference;
-typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopOpeBRepDS_ListOfInterference,TColStd_MapTransientHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfInterferenceListOfInterference;
+typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopOpeBRepDS_ListOfInterference> TopOpeBRepDS_DataMapOfInterferenceListOfInterference;
+typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopOpeBRepDS_ListOfInterference>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfInterferenceListOfInterference;
#endif
#include <TopOpeBRepDS_Interference.hxx>
#include <TopoDS_Shape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopoDS_Shape,TColStd_MapTransientHasher> TopOpeBRepDS_DataMapOfInterferenceShape;
-typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopoDS_Shape,TColStd_MapTransientHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfInterferenceShape;
+typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopoDS_Shape> TopOpeBRepDS_DataMapOfInterferenceShape;
+typedef NCollection_DataMap<Handle(TopOpeBRepDS_Interference),TopoDS_Shape>::Iterator TopOpeBRepDS_DataMapIteratorOfDataMapOfInterferenceShape;
#endif
#ifndef TopOpeBRepDS_DoubleMapOfIntegerShape_HeaderFile
#define TopOpeBRepDS_DoubleMapOfIntegerShape_HeaderFile
-#include <TColStd_MapIntegerHasher.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DoubleMap.hxx>
-typedef NCollection_DoubleMap<Standard_Integer,TopoDS_Shape,TColStd_MapIntegerHasher,TopTools_ShapeMapHasher> TopOpeBRepDS_DoubleMapOfIntegerShape;
-typedef NCollection_DoubleMap<Standard_Integer,TopoDS_Shape,TColStd_MapIntegerHasher,TopTools_ShapeMapHasher>::Iterator TopOpeBRepDS_DoubleMapIteratorOfDoubleMapOfIntegerShape;
+typedef NCollection_DoubleMap<Standard_Integer,TopoDS_Shape,NCollection_DefaultHasher<int>,TopTools_ShapeMapHasher> TopOpeBRepDS_DoubleMapOfIntegerShape;
+typedef TopOpeBRepDS_DoubleMapOfIntegerShape::Iterator TopOpeBRepDS_DoubleMapIteratorOfDoubleMapOfIntegerShape;
#endif
TopOpeBRepDS_ListIteratorOfListOfInterference it1; // set hasONFACE = True if LI contains interfs with (ON,FACE) transition(s).
Standard_Boolean hasONFACE = Standard_False;
for (it1.Initialize(LI); it1.More(); it1.Next() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
if ( GT1 == TopOpeBRepDS_POINT ) {
hasONFACE = FUN_hasStateShape(I1->Transition(),TopAbs_ON,TopAbs_FACE);
// LI has (ON,FACE) : remove all other interf (POINT,(not(ON,FACE)))
it1.Initialize(LI);
while( it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
if ( GT1 == TopOpeBRepDS_POINT ) {
hasONFACE = FUN_hasStateShape(I1->Transition(),TopAbs_ON,TopAbs_FACE);
if (redu2d) { // {I1d=(Tr(Esd),vG,Esd), I2d=(Tr(F),vG,E)}
TopOpeBRepDS_ListIteratorOfListOfInterference it(l2dFE); TopOpeBRepDS_ListOfInterference al2dFE;
while (it.More()) {
- Handle(TopOpeBRepDS_Interference)& I2dFE = it.Value();
+ Handle(TopOpeBRepDS_Interference)& I2dFE = it.ChangeValue();
TopOpeBRepDS_Transition newT2d; Standard_Boolean ok = FUN_ds_redu2d1d(BDS,ISE,I2dFE,l1dE, newT2d);
if (!ok) {it.Next(); continue;}
I2dFE->ChangeTransition() = newT2d; al2dFE.Append(I2dFE);
TopOpeBRepDS_ListIteratorOfListOfInterference itF(LIF);
for (;itF.More();itF.Next()) {
- Handle(TopOpeBRepDS_Interference)& IF = itF.Value(); FDS_data(IF,GT1,G1,ST1,S1);
+ Handle(TopOpeBRepDS_Interference) IF = itF.Value(); FDS_data(IF,GT1,G1,ST1,S1);
const TopoDS_Face& F = TopoDS::Face(BDS.Shape(S1));
TopAbs_Orientation oEinF; Standard_Boolean edonfa = FUN_tool_orientEinFFORWARD(E,F,oEinF );
if ( edonfa ) Pok = Standard_True;
for (;itI.More();itI.Next()) {
Standard_Boolean pardef = Standard_False;
- Handle(TopOpeBRepDS_Interference)& I = itI.Value(); FDS_data(I,GT1,G1,ST1,S1);
+ Handle(TopOpeBRepDS_Interference)& I = itI.ChangeValue(); FDS_data(I,GT1,G1,ST1,S1);
Handle(TopOpeBRepDS_CurvePointInterference) CPI (Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I));
Handle(TopOpeBRepDS_ShapeShapeInterference) SSI (Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I));
if (!CPI.IsNull()) {
mosd.Clear();
TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
for (TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);it1.More();it1.Next()) {
- Handle(TopOpeBRepDS_Interference)& I1=it1.Value(); FDS_data(I1,GT1,G1,ST1,S1);
+ Handle(TopOpeBRepDS_Interference)& I1=it1.ChangeValue(); FDS_data(I1,GT1,G1,ST1,S1);
if ( GT1 != MDSke || ST1 != MDSkf ) continue;
const TopoDS_Shape& SG1 = BDS.Shape(G1);
TopOpeBRepDS_ShapeData thedata;
#include <Standard_Integer.hxx>
#include <TopOpeBRepDS_CurveData.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CurveData,TColStd_MapIntegerHasher> TopOpeBRepDS_MapOfCurve;
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CurveData,TColStd_MapIntegerHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfCurve;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CurveData> TopOpeBRepDS_MapOfCurve;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_CurveData>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfCurve;
#endif
#define TopOpeBRepDS_MapOfIntegerShapeData_HeaderFile
#include <TopOpeBRepDS_ShapeData.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ShapeData,TColStd_MapIntegerHasher> TopOpeBRepDS_MapOfIntegerShapeData;
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ShapeData,TColStd_MapIntegerHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfIntegerShapeData;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ShapeData> TopOpeBRepDS_MapOfIntegerShapeData;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_ShapeData>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfIntegerShapeData;
#endif
#include <Standard_Integer.hxx>
#include <TopOpeBRepDS_PointData.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_PointData,TColStd_MapIntegerHasher> TopOpeBRepDS_MapOfPoint;
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_PointData,TColStd_MapIntegerHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfPoint;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_PointData> TopOpeBRepDS_MapOfPoint;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_PointData>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfPoint;
#endif
#include <Standard_Integer.hxx>
#include <TopOpeBRepDS_SurfaceData.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_SurfaceData,TColStd_MapIntegerHasher> TopOpeBRepDS_MapOfSurface;
-typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_SurfaceData,TColStd_MapIntegerHasher>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfSurface;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_SurfaceData> TopOpeBRepDS_MapOfSurface;
+typedef NCollection_DataMap<Standard_Integer,TopOpeBRepDS_SurfaceData>::Iterator TopOpeBRepDS_DataMapIteratorOfMapOfSurface;
#endif
#include <TColStd_HArray1OfBoolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
-#include <Standard_Address.hxx>
class TopOpeBRepDS_Marker;
TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
Standard_Boolean k1 = ::FUN_keepEinterference(BDS,I1,E);
if ( !k1 ) {
LI.Remove(it1);
it1.Initialize(LI);
while (it1.More() ) {
Standard_Boolean it1toremove = Standard_False;
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; ::FDS_Tdata(I1,tsb1,isb1,tsa1,isa1);
const TopOpeBRepDS_Transition T1 = I1->Transition();
it1.Initialize(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; FDS_Tdata(I1,tsb1,isb1,tsa1,isa1);
// I1->Transition();
it1.Initialize(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
const TopOpeBRepDS_Transition& T1 = I1->Transition();
// process interferences of LI with UNKNOWN transition
for (it1.Initialize(LI); it1.More(); it1.Next() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
const TopOpeBRepDS_Transition& T1 = I1->Transition();
Standard_Boolean isunk = T1.IsUnknown();
if (!isunk) continue;
it1.Initialize(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1;
const TopOpeBRepDS_Transition& T1 = I1->Transition();
Standard_Boolean isunk1 = T1.IsUnknown();
// process interferences of LI with UNKNOWN transition
for (it1.Initialize(LI); it1.More(); it1.Next() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
const TopOpeBRepDS_Transition& T1 = I1->Transition();
Standard_Boolean isunk = T1.IsUnknown();
if (!isunk) continue;
// process interferences of LI with VERTEX geometry
it1.Initialize(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
const TopOpeBRepDS_Transition& T1 = I1->Transition();
TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
it1.Initialize(LI);
while (it1.More() ) {
- Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
+ Handle(TopOpeBRepDS_Interference)& I1 = it1.ChangeValue();
const TopOpeBRepDS_Transition& T1 = I1->Transition();
Standard_Boolean isunk = T1.IsUnknown();
TopAbs_ShapeEnum SB1,SA1; Standard_Integer IB1,IA1; FDS_Tdata(I1,SB1,IB1,SA1,IA1);
while ( it2.More()){
- Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
+ Handle(TopOpeBRepDS_Interference)& I2 = it2.ChangeValue();
TopAbs_Orientation O2 = I2->Transition().Orientation(TopAbs_IN);
TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
TopAbs_ShapeEnum SB2,SA2; Standard_Integer IB2,IA2; FDS_Tdata(I2,SB2,IB2,SA2,IA2);
#include <TopoDS_Shape.hxx>
#include <TopOpeBRepTool_C2DF.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TopoDS_Shape,TopOpeBRepTool_C2DF,TopTools_OrientedShapeMapHasher> TopOpeBRepTool_DataMapOfOrientedShapeC2DF;
-typedef NCollection_DataMap<TopoDS_Shape,TopOpeBRepTool_C2DF,TopTools_OrientedShapeMapHasher>::Iterator TopOpeBRepTool_DataMapIteratorOfDataMapOfOrientedShapeC2DF;
+typedef NCollection_DataMap<TopoDS_Shape,TopOpeBRepTool_C2DF> TopOpeBRepTool_DataMapOfOrientedShapeC2DF;
+typedef NCollection_DataMap<TopoDS_Shape,TopOpeBRepTool_C2DF>::Iterator TopOpeBRepTool_DataMapIteratorOfDataMapOfOrientedShapeC2DF;
#endif
iter.Next();
for (; iter.More(); iter.Next())
{
- TopoDS_Edge& E = TopoDS::Edge(iter.Value());
+ const TopoDS_Edge& E = TopoDS::Edge(iter.Value());
Standard_Real first, last;
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface( E, Surf, loc, first, last );
Handle(Geom2d_BoundedCurve) BC = Handle(Geom2d_BoundedCurve)::DownCast(C);
#include <TopoDS_Shape.hxx>
#include <Bnd_Box.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TopoDS_Shape,Bnd_Box,TopTools_OrientedShapeMapHasher> TopOpeBRepTool_IndexedDataMapOfShapeBox;
+typedef NCollection_IndexedDataMap<TopoDS_Shape,Bnd_Box> TopOpeBRepTool_IndexedDataMapOfShapeBox;
#endif
#include <TopoDS_Shape.hxx>
#include <Bnd_Box2d.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
-typedef NCollection_IndexedDataMap<TopoDS_Shape,Bnd_Box2d,TopTools_OrientedShapeMapHasher> TopOpeBRepTool_IndexedDataMapOfShapeBox2d;
+typedef NCollection_IndexedDataMap<TopoDS_Shape,Bnd_Box2d> TopOpeBRepTool_IndexedDataMapOfShapeBox2d;
#endif
TopTools_MapOfShape.hxx
TopTools_MutexForShapeProvider.cxx
TopTools_MutexForShapeProvider.hxx
-TopTools_OrientedShapeMapHasher.hxx
-TopTools_OrientedShapeMapHasher.lxx
TopTools_SequenceOfShape.hxx
TopTools_ShapeMapHasher.hxx
-TopTools_ShapeMapHasher.lxx
TopTools_ShapeSet.cxx
TopTools_ShapeSet.hxx
#include <Standard_Integer.hxx>
#include <TopTools_ListOfShape.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopTools_ListOfShape,TColStd_MapIntegerHasher> TopTools_DataMapOfIntegerListOfShape;
-typedef NCollection_DataMap<Standard_Integer,TopTools_ListOfShape,TColStd_MapIntegerHasher>::Iterator TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape;
+typedef NCollection_DataMap<Standard_Integer,TopTools_ListOfShape> TopTools_DataMapOfIntegerListOfShape;
+typedef NCollection_DataMap<Standard_Integer,TopTools_ListOfShape>::Iterator TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape;
#endif
#include <Standard_Integer.hxx>
#include <TopoDS_Shape.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TopoDS_Shape,TColStd_MapIntegerHasher> TopTools_DataMapOfIntegerShape;
-typedef NCollection_DataMap<Standard_Integer,TopoDS_Shape,TColStd_MapIntegerHasher>::Iterator TopTools_DataMapIteratorOfDataMapOfIntegerShape;
+typedef NCollection_DataMap<Standard_Integer,TopoDS_Shape> TopTools_DataMapOfIntegerShape;
+typedef NCollection_DataMap<Standard_Integer,TopoDS_Shape>::Iterator TopTools_DataMapIteratorOfDataMapOfIntegerShape;
#endif
#include <TopoDS_Shape.hxx>
#include <Standard_Integer.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TopoDS_Shape,Standard_Integer,TopTools_OrientedShapeMapHasher> TopTools_DataMapOfOrientedShapeInteger;
-typedef NCollection_DataMap<TopoDS_Shape,Standard_Integer,TopTools_OrientedShapeMapHasher>::Iterator TopTools_DataMapIteratorOfDataMapOfOrientedShapeInteger;
+typedef NCollection_DataMap<TopoDS_Shape,Standard_Integer> TopTools_DataMapOfOrientedShapeInteger;
+typedef NCollection_DataMap<TopoDS_Shape,Standard_Integer>::Iterator TopTools_DataMapIteratorOfDataMapOfOrientedShapeInteger;
#endif
#define TopTools_DataMapOfOrientedShapeShape_HeaderFile
#include <TopoDS_Shape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TopoDS_Shape,TopoDS_Shape,TopTools_OrientedShapeMapHasher> TopTools_DataMapOfOrientedShapeShape;
-typedef NCollection_DataMap<TopoDS_Shape,TopoDS_Shape,TopTools_OrientedShapeMapHasher>::Iterator TopTools_DataMapIteratorOfDataMapOfOrientedShapeShape;
+typedef NCollection_DataMap<TopoDS_Shape,TopoDS_Shape> TopTools_DataMapOfOrientedShapeShape;
+typedef NCollection_DataMap<TopoDS_Shape,TopoDS_Shape>::Iterator TopTools_DataMapIteratorOfDataMapOfOrientedShapeShape;
#endif
#define TopTools_IndexedDataMapOfShapeAddress_HeaderFile
#include <TopoDS_Shape.hxx>
-#include <Standard_Address.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_IndexedDataMap.hxx>
#define TopTools_IndexedMapOfOrientedShape_HeaderFile
#include <TopoDS_Shape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-typedef NCollection_IndexedMap<TopoDS_Shape,TopTools_OrientedShapeMapHasher> TopTools_IndexedMapOfOrientedShape;
+typedef NCollection_IndexedMap<TopoDS_Shape> TopTools_IndexedMapOfOrientedShape;
#endif
#define TopTools_MapOfOrientedShape_HeaderFile
#include <TopoDS_Shape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
#include <NCollection_Map.hxx>
-typedef NCollection_Map<TopoDS_Shape,TopTools_OrientedShapeMapHasher> TopTools_MapOfOrientedShape;
-typedef NCollection_Map<TopoDS_Shape,TopTools_OrientedShapeMapHasher>::Iterator TopTools_MapIteratorOfMapOfOrientedShape;
+typedef NCollection_Map<TopoDS_Shape> TopTools_MapOfOrientedShape;
+typedef NCollection_Map<TopoDS_Shape>::Iterator TopTools_MapIteratorOfMapOfOrientedShape;
#endif
+++ /dev/null
-// Created on: 1993-08-30
-// Created by: Modelistation
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 _TopTools_OrientedShapeMapHasher_HeaderFile
-#define _TopTools_OrientedShapeMapHasher_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
-#include <Standard_Integer.hxx>
-class TopoDS_Shape;
-
-
-
-class TopTools_OrientedShapeMapHasher
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given shape, in the range [1, theUpperBound]
- //! @param theShape the shape 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 TopoDS_Shape& theShape, const Standard_Integer theUpperBound);
-
- //! Returns True when the two keys are equal. Two same
- //! keys must have the same hashcode, the contrary is
- //! not necessary.
- static Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
-};
-
-
-#include <TopTools_OrientedShapeMapHasher.lxx>
-
-
-
-
-
-#endif // _TopTools_OrientedShapeMapHasher_HeaderFile
+++ /dev/null
-// Created on: 1993-01-14
-// Created by: Remi LEQUETTE
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 <TopoDS_Shape.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer TopTools_OrientedShapeMapHasher::HashCode (const TopoDS_Shape& theShape,
- const Standard_Integer theUpperBound)
-{
- return theShape.HashCode (theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-inline Standard_Boolean TopTools_OrientedShapeMapHasher::IsEqual
- (const TopoDS_Shape& S1, const TopoDS_Shape& S2)
-{
- return S1.IsEqual(S2);
-}
#ifndef _TopTools_ShapeMapHasher_HeaderFile
#define _TopTools_ShapeMapHasher_HeaderFile
+#include <TopoDS_Shape.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
-class TopoDS_Shape;
-
-
//! Hash tool, used for generating maps of shapes in topology.
-class TopTools_ShapeMapHasher
+class TopTools_ShapeMapHasher
{
public:
- DEFINE_STANDARD_ALLOC
-
- //! Computes a hash code for the given shape, in the range [1, theUpperBound]
- //! @param theShape the shape 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 TopoDS_Shape& theShape, Standard_Integer theUpperBound);
-
- //! Returns True when the two keys are the same. Two
- //! same keys must have the same hashcode, the
- //! contrary is not necessary.
- static Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
+ DEFINE_STANDARD_ALLOC;
+ size_t operator()(const TopoDS_Shape& theShape) const noexcept
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ bool operator()(const TopoDS_Shape& S1, const TopoDS_Shape& S2) const noexcept
+ {
+ return S1.IsSame(S2);
+ }
};
-
-#include <TopTools_ShapeMapHasher.lxx>
-
-
-
-
-
#endif // _TopTools_ShapeMapHasher_HeaderFile
+++ /dev/null
-// Created on: 1993-01-14
-// Created by: Remi LEQUETTE
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-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 <TopoDS_Shape.hxx>
-
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-inline Standard_Integer TopTools_ShapeMapHasher::HashCode (const TopoDS_Shape& theShape,
- const Standard_Integer theUpperBound)
-{
- return theShape.HashCode (theUpperBound);
-}
-
-//=======================================================================
-//function : IsEqual
-//purpose :
-//=======================================================================
-inline Standard_Boolean TopTools_ShapeMapHasher::IsEqual
- (const TopoDS_Shape& S1, const TopoDS_Shape& S2)
-{
- return S1.IsSame(S2);
-}
TopoDS_Builder.hxx
TopoDS_Builder.lxx
TopoDS_Compound.hxx
-TopoDS_Compound.lxx
TopoDS_CompSolid.hxx
-TopoDS_CompSolid.lxx
TopoDS_Edge.hxx
-TopoDS_Edge.lxx
TopoDS_Face.hxx
-TopoDS_Face.lxx
TopoDS_FrozenShape.hxx
TopoDS_HShape.cxx
TopoDS_HShape.hxx
TopoDS_Shape.cxx
TopoDS_Shape.hxx
TopoDS_Shell.hxx
-TopoDS_Shell.lxx
TopoDS_Solid.hxx
-TopoDS_Solid.lxx
TopoDS_TCompound.cxx
TopoDS_TCompound.hxx
TopoDS_TCompound.lxx
TopoDS_TWire.lxx
TopoDS_UnCompatibleShapes.hxx
TopoDS_Vertex.hxx
-TopoDS_Vertex.lxx
TopoDS_Wire.hxx
-TopoDS_Wire.lxx
TopoDS_AlertWithShape.cxx
TopoDS_AlertWithShape.hxx
#ifndef _TopoDS_CompSolid_HeaderFile
#define _TopoDS_CompSolid_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a composite solid which
//! - references an underlying composite solid with the
//! potential to be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Constructs an Undefined CompSolid.
- TopoDS_CompSolid();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_CompSolid() {}
};
-
-#include <TopoDS_CompSolid.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_CompSolid>
+ {
+ size_t operator()(const TopoDS_CompSolid& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_CompSolid_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_CompSolid
-//purpose :
-//=======================================================================
-
-inline TopoDS_CompSolid::TopoDS_CompSolid ()
-{
-}
#ifndef _TopoDS_Compound_HeaderFile
#define _TopoDS_Compound_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a compound which
//! - references an underlying compound with the
//! potential to be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Constructs an Undefined Compound.
- TopoDS_Compound();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Compound() {}
};
-
-#include <TopoDS_Compound.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Compound>
+ {
+ size_t operator()(const TopoDS_Compound& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Compound_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Compound
-//purpose :
-//=======================================================================
-
-inline TopoDS_Compound::TopoDS_Compound ()
-{
-}
#ifndef _TopoDS_Edge_HeaderFile
#define _TopoDS_Edge_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes an edge which
//! - references an underlying edge with the potential to
//! be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Undefined Edge.
- TopoDS_Edge();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Edge() {}
};
-
-#include <TopoDS_Edge.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Edge>
+ {
+ size_t operator()(const TopoDS_Edge& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Edge_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Edge
-//purpose : Empty Constructor
-//=======================================================================
-
-inline TopoDS_Edge::TopoDS_Edge ()
-{
-}
#ifndef _TopoDS_Face_HeaderFile
#define _TopoDS_Face_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a face which
//! - references an underlying face with the potential to
//! be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Undefined Face.
- TopoDS_Face();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Face() {}
};
-
-#include <TopoDS_Face.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Face>
+ {
+ size_t operator()(const TopoDS_Face& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Face_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Face
-//purpose :
-//=======================================================================
-
-inline TopoDS_Face::TopoDS_Face ()
-{
-}
#include <TopLoc_Location.hxx>
#include <TopoDS_TShape.hxx>
-//=======================================================================
-// function : HashCode
-// purpose :
-//=======================================================================
-Standard_Integer TopoDS_Shape::HashCode (const Standard_Integer theUpperBound) const
-{
- // PKV
- const Standard_Integer aHS = ::HashCode (myTShape.get(), theUpperBound);
- const Standard_Integer aHL = myLocation.HashCode (theUpperBound);
- return ::HashCode (aHS ^ aHL, theUpperBound);
-}
-
//=======================================================================
//function : DumpJson
//purpose :
#include <Standard_Handle.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_TShape.hxx>
+#include <Standard_HashUtils.hxx>
// resolve name collisions with X11 headers
#ifdef Convex
Standard_Boolean IsNotEqual (const TopoDS_Shape& theOther) const { return !IsEqual (theOther); }
Standard_Boolean operator != (const TopoDS_Shape& theOther) const { return IsNotEqual (theOther); }
- //! Returns a hashed value denoting <me>. This value is in the range [1, theUpperBound]. It is computed from the
- //! TShape and the Location. The Orientation is not used.
- //! @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]
- Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
-
//! Replace <me> by a new Shape with the same
//! Orientation and Location and a new TShape with the
//! same geometry and no sub-shapes.
};
-//! Computes a hash code for the given shape, in the range [1, theUpperBound]
-//! @param theShape the shape 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]
-inline Standard_Integer HashCode (const TopoDS_Shape& theShape, const Standard_Integer theUpperBound)
+namespace std
{
- return theShape.HashCode (theUpperBound);
+ template <>
+ struct hash<TopoDS_Shape>
+ {
+ size_t operator()(const TopoDS_Shape& theShape) const noexcept
+ {
+ const size_t aHL = std::hash<TopLoc_Location>{}(theShape.Location());
+ return aHL == 0 ? opencascade::hash(theShape.TShape().get())
+ : opencascade::MurmurHash::hash_combine(theShape.TShape().get(), sizeof(void*), aHL);
+ }
+ };
}
#endif // _TopoDS_Shape_HeaderFile
#ifndef _TopoDS_Shell_HeaderFile
#define _TopoDS_Shell_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a shell which
//! - references an underlying shell with the potential to
//! be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Constructs an Undefined Shell.
- TopoDS_Shell();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Shell() {}
};
-
-#include <TopoDS_Shell.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Shell>
+ {
+ size_t operator()(const TopoDS_Shell& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Shell_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Shell
-//purpose :
-//=======================================================================
-
-inline TopoDS_Shell::TopoDS_Shell ()
-{
-}
#ifndef _TopoDS_Solid_HeaderFile
#define _TopoDS_Solid_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a solid shape which
//! - references an underlying solid shape with the
//! potential to be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Constructs an Undefined Solid.
- TopoDS_Solid();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Solid() {}
};
-
-#include <TopoDS_Solid.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Solid>
+ {
+ size_t operator()(const TopoDS_Solid& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Solid_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Solid
-//purpose :
-//=======================================================================
-
-inline TopoDS_Solid::TopoDS_Solid ()
-{
-}
#ifndef _TopoDS_Vertex_HeaderFile
#define _TopoDS_Vertex_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a vertex which
//! - references an underlying vertex with the potential
//! to be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Undefined Vertex.
- TopoDS_Vertex();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Vertex() {}
};
-
-#include <TopoDS_Vertex.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Vertex>
+ {
+ size_t operator()(const TopoDS_Vertex& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Vertex_HeaderFile
+++ /dev/null
-// Created on: 1991-04-12
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Vertex
-//purpose :
-//=======================================================================
-
-inline TopoDS_Vertex::TopoDS_Vertex()
-{
-}
#ifndef _TopoDS_Wire_HeaderFile
#define _TopoDS_Wire_HeaderFile
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-
#include <TopoDS_Shape.hxx>
-
//! Describes a wire which
//! - references an underlying wire with the potential to
//! be given a location and an orientation
DEFINE_STANDARD_ALLOC
-
//! Undefined Wire.
- TopoDS_Wire();
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ TopoDS_Wire() {}
};
-
-#include <TopoDS_Wire.lxx>
-
-
-
-
+namespace std
+{
+ template <>
+ struct hash<TopoDS_Wire>
+ {
+ size_t operator()(const TopoDS_Wire& theShape) const
+ {
+ return std::hash<TopoDS_Shape>{}(theShape);
+ }
+ };
+}
#endif // _TopoDS_Wire_HeaderFile
+++ /dev/null
-// Created on: 1991-04-16
-// Created by: Remi LEQUETTE
-// Copyright (c) 1991-1999 Matra Datavision
-// Copyright (c) 1999-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.
-
-//=======================================================================
-//function : TopoDS_Wire
-//purpose :
-//=======================================================================
-
-inline TopoDS_Wire::TopoDS_Wire ()
-{
-}
-Transfer_Actor.gxx
Transfer_ActorDispatch.cxx
Transfer_ActorDispatch.hxx
Transfer_ActorOfFinderProcess.cxx
Transfer_Finder.hxx
Transfer_FinderProcess.cxx
Transfer_FinderProcess.hxx
-Transfer_FindHasher.cxx
Transfer_FindHasher.hxx
Transfer_HSequenceOfBinder.hxx
Transfer_HSequenceOfFinder.hxx
-Transfer_Iterator.gxx
Transfer_IteratorOfProcessForFinder.hxx
Transfer_IteratorOfProcessForFinder_0.cxx
Transfer_IteratorOfProcessForTransient.hxx
Transfer_IteratorOfProcessForTransient_0.cxx
Transfer_MapContainer.cxx
Transfer_MapContainer.hxx
-Transfer_Mapper.gxx
Transfer_MultipleBinder.cxx
Transfer_MultipleBinder.hxx
Transfer_ProcessForFinder.hxx
Transfer_TransferMapOfProcessForTransient.hxx
Transfer_TransferOutput.cxx
Transfer_TransferOutput.hxx
-Transfer_TransferProcess.gxx
Transfer_TransientListBinder.cxx
Transfer_TransientListBinder.hxx
Transfer_TransientMapper.hxx
+++ /dev/null
-// Copyright (c) 1999-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 <Transfer_Actor.ixx>
-
-// TheStart : Handle(Standard_Transient) ou (Transfer_Finder)
-
-
-
-Transfer_Actor::Transfer_Actor () { }
-
-
- Standard_Boolean Transfer_Actor::Recognize (const TheStart& /*start*/)
- { return Standard_True; }
-
- Handle(Transfer_Binder) Transfer_Actor::Transferring
- (const TheStart& /*start*/,
- const Handle(Transfer_TransferProcess)& /*TP*/,
- const Message_ProgressRange& /*theProgress*/)
- { return NullResult(); }
-
-
- Handle(Transfer_SimpleBinderOfTransient)
- Transfer_Actor::TransientResult
- (const Handle(Standard_Transient)& res) const
-{
- Handle(Transfer_SimpleBinderOfTransient) binder;
- if (res.IsNull()) return binder;
- binder = new Transfer_SimpleBinderOfTransient;
- binder->SetResult (res);
- return binder;
-}
-
-
- Handle(Transfer_Binder) Transfer_Actor::NullResult () const
-{
- Handle(Transfer_Binder) binder;
- return binder;
-}
-
-
- void Transfer_Actor::SetNext
- (const Handle(Transfer_Actor)& next)
-{
- if (thenext == next) return;
- if (thenext.IsNull()) thenext = next;
- else if (thenext->IsLast()) { next->SetNext(thenext); thenext = next; }
- else thenext->SetNext(next);
-}
-
- Handle(Transfer_Actor) Transfer_Actor::Next () const
- { return thenext; }
-
- void Transfer_Actor::SetLast (const Standard_Boolean mode)
- { thelast = mode; }
-
-
- Standard_Boolean Transfer_Actor::IsLast () const
- { return thelast; }
#include <Transfer_ActorOfProcessForFinder.hxx>
+#include <Standard_DomainError.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
-
#include <Transfer_ActorOfProcessForFinder.hxx>
-#include <Standard_DomainError.hxx>
+#include <Transfer_Binder.hxx>
#include <Transfer_Finder.hxx>
#include <Transfer_FindHasher.hxx>
-#include <Transfer_ProcessForFinder.hxx>
-#include <Transfer_TransferMapOfProcessForFinder.hxx>
#include <Transfer_IteratorOfProcessForFinder.hxx>
-#include <Transfer_Binder.hxx>
+#include <Transfer_ProcessForFinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
-#include <Standard_Transient.hxx>
+#include <Transfer_TransferMapOfProcessForFinder.hxx>
+
+//=======================================================================
+// Function: Transfer_ActorOfProcessForFinder
+// Purpose :
+//=======================================================================
+Transfer_ActorOfProcessForFinder::Transfer_ActorOfProcessForFinder() { }
+
+//=======================================================================
+// Function: Recognize
+// Purpose :
+//=======================================================================
+Standard_Boolean Transfer_ActorOfProcessForFinder::Recognize(const Handle(Transfer_Finder)& /*start*/)
+{
+ return Standard_True;
+}
+
+//=======================================================================
+// Function: Transferring
+// Purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ActorOfProcessForFinder::Transferring
+(const Handle(Transfer_Finder)& /*start*/,
+ const Handle(Transfer_ProcessForFinder)& /*TP*/,
+ const Message_ProgressRange& /*theProgress*/)
+{
+ return NullResult();
+}
+
+//=======================================================================
+// Function: TransientResult
+// Purpose :
+//=======================================================================
+Handle(Transfer_SimpleBinderOfTransient)
+Transfer_ActorOfProcessForFinder::TransientResult
+(const Handle(Standard_Transient)& res) const
+{
+ Handle(Transfer_SimpleBinderOfTransient) binder;
+ if (res.IsNull()) return binder;
+ binder = new Transfer_SimpleBinderOfTransient;
+ binder->SetResult(res);
+ return binder;
+}
+
+//=======================================================================
+// Function: NullResult
+// Purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ActorOfProcessForFinder::NullResult() const
+{
+ Handle(Transfer_Binder) binder;
+ return binder;
+}
+
+//=======================================================================
+// Function: SetNext
+// Purpose :
+//=======================================================================
+void Transfer_ActorOfProcessForFinder::SetNext
+(const Handle(Transfer_ActorOfProcessForFinder)& next)
+{
+ if (thenext == next)
+ return;
+ if (thenext.IsNull())
+ thenext = next;
+ else if (thenext->IsLast())
+ {
+ next->SetNext(thenext);
+ thenext = next;
+ }
+ else
+ thenext->SetNext(next);
+}
+
+//=======================================================================
+// Function: Next
+// Purpose :
+//=======================================================================
+Handle(Transfer_ActorOfProcessForFinder) Transfer_ActorOfProcessForFinder::Next() const
+{
+ return thenext;
+}
-#define TheStart Handle(Transfer_Finder)
-#define TheStart_hxx <Transfer_Finder.hxx>
-#define TheMapHasher Transfer_FindHasher
-#define TheMapHasher_hxx <Transfer_FindHasher.hxx>
-#define Handle_TheList Handle(Transfer_HSequenceOfFinder)
-#define TheList Transfer_HSequenceOfFinder
-#define TheList_hxx <Transfer_HSequenceOfFinder.hxx>
-#define Transfer_TransferMap Transfer_TransferMapOfProcessForFinder
-#define Transfer_TransferMap_hxx <Transfer_TransferMapOfProcessForFinder.hxx>
-#define Transfer_Iterator Transfer_IteratorOfProcessForFinder
-#define Transfer_Iterator_hxx <Transfer_IteratorOfProcessForFinder.hxx>
-#define Transfer_Actor Transfer_ActorOfProcessForFinder
-#define Transfer_Actor_hxx <Transfer_ActorOfProcessForFinder.hxx>
-#define Handle_Transfer_Actor Handle(Transfer_ActorOfProcessForFinder)
-#define Transfer_TransferProcess Transfer_ProcessForFinder
-#define Transfer_TransferProcess_hxx <Transfer_ProcessForFinder.hxx>
-#define Handle_Transfer_TransferProcess Handle(Transfer_ProcessForFinder)
-#include <Transfer_Actor.gxx>
+//=======================================================================
+// Function: SetLast
+// Purpose :
+//=======================================================================
+void Transfer_ActorOfProcessForFinder::SetLast(const Standard_Boolean mode)
+{
+ thelast = mode;
+}
+//=======================================================================
+// Function: IsLast
+// Purpose :
+//=======================================================================
+Standard_Boolean Transfer_ActorOfProcessForFinder::IsLast() const
+{
+ return thelast;
+}
#include <Transfer_ActorOfProcessForTransient.hxx>
-#include <Standard_Type.hxx>
-
-#include <Transfer_ActorOfProcessForTransient.hxx>
#include <Standard_DomainError.hxx>
#include <Standard_Transient.hxx>
-#include <Transfer_ProcessForTransient.hxx>
-#include <Transfer_TransferMapOfProcessForTransient.hxx>
-#include <Transfer_IteratorOfProcessForTransient.hxx>
+#include <Standard_Type.hxx>
+#include <Transfer_ActorOfProcessForTransient.hxx>
#include <Transfer_Binder.hxx>
+#include <Transfer_IteratorOfProcessForTransient.hxx>
+#include <Transfer_ProcessForTransient.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
+#include <Transfer_TransferMapOfProcessForTransient.hxx>
+
+//=======================================================================
+// Function: Transfer_ActorOfProcessForTransient
+// Purpose :
+//=======================================================================
+Transfer_ActorOfProcessForTransient::Transfer_ActorOfProcessForTransient()
+{}
+
+
+//=======================================================================
+// Function: Recognize
+// Purpose :
+//=======================================================================
+Standard_Boolean Transfer_ActorOfProcessForTransient::Recognize(const Handle(Standard_Transient)& /*start*/)
+{
+ return Standard_True;
+}
+
+//=======================================================================
+// Function: Transferring
+// Purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ActorOfProcessForTransient::Transferring
+(const Handle(Standard_Transient)& /*start*/,
+ const Handle(Transfer_ProcessForTransient)& /*TP*/,
+ const Message_ProgressRange& /*theProgress*/)
+{
+ return NullResult();
+}
+
+//=======================================================================
+// Function: TransientResult
+// Purpose :
+//=======================================================================
+Handle(Transfer_SimpleBinderOfTransient)
+Transfer_ActorOfProcessForTransient::TransientResult
+(const Handle(Standard_Transient)& res) const
+{
+ Handle(Transfer_SimpleBinderOfTransient) binder;
+ if (res.IsNull()) return binder;
+ binder = new Transfer_SimpleBinderOfTransient;
+ binder->SetResult(res);
+ return binder;
+}
+
+//=======================================================================
+// Function: NullResult
+// Purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ActorOfProcessForTransient::NullResult() const
+{
+ Handle(Transfer_Binder) binder;
+ return binder;
+}
+
+//=======================================================================
+// Function: SetNext
+// Purpose :
+//=======================================================================
+void Transfer_ActorOfProcessForTransient::SetNext
+(const Handle(Transfer_ActorOfProcessForTransient)& next)
+{
+ if (thenext == next)
+ return;
+ if (thenext.IsNull())
+ thenext = next;
+ else if (thenext->IsLast())
+ {
+ next->SetNext(thenext);
+ thenext = next;
+ }
+ else
+ thenext->SetNext(next);
+}
+
+
+//=======================================================================
+// Function: Next
+// Purpose :
+//=======================================================================
+Handle(Transfer_ActorOfProcessForTransient) Transfer_ActorOfProcessForTransient::Next() const
+{
+ return thenext;
+}
+
+
+//=======================================================================
+// Function: SetLast
+// Purpose :
+//=======================================================================
+void Transfer_ActorOfProcessForTransient::SetLast(const Standard_Boolean mode)
+{
+ thelast = mode;
+}
+
-#define TheStart Handle(Standard_Transient)
-#define TheStart_hxx <Standard_Transient.hxx>
-#define TheMapHasher TColStd_MapTransientHasher
-#define TheMapHasher_hxx <TColStd_MapTransientHasher.hxx>
-#define Handle_TheList Handle(TColStd_HSequenceOfTransient)
-#define TheList TColStd_HSequenceOfTransient
-#define TheList_hxx <TColStd_HSequenceOfTransient.hxx>
-#define Transfer_TransferMap Transfer_TransferMapOfProcessForTransient
-#define Transfer_TransferMap_hxx <Transfer_TransferMapOfProcessForTransient.hxx>
-#define Transfer_Iterator Transfer_IteratorOfProcessForTransient
-#define Transfer_Iterator_hxx <Transfer_IteratorOfProcessForTransient.hxx>
-#define Transfer_Actor Transfer_ActorOfProcessForTransient
-#define Transfer_Actor_hxx <Transfer_ActorOfProcessForTransient.hxx>
-#define Handle_Transfer_Actor Handle(Transfer_ActorOfProcessForTransient)
-#define Transfer_TransferProcess Transfer_ProcessForTransient
-#define Transfer_TransferProcess_hxx <Transfer_ProcessForTransient.hxx>
-#define Handle_Transfer_TransferProcess Handle(Transfer_ProcessForTransient)
-#include <Transfer_Actor.gxx>
+//=======================================================================
+// Function: IsLast
+// Purpose :
+//=======================================================================
+Standard_Boolean Transfer_ActorOfProcessForTransient::IsLast() const
+{
+ return thelast;
+}
+++ /dev/null
-// Copyright (c) 1999-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 <Transfer_Finder.hxx>
-#include <Transfer_FindHasher.hxx>
-
-
-//============================================================================
-// function : HashCode
-// purpose :
-//============================================================================
-Standard_Integer Transfer_FindHasher::HashCode (const Handle (Transfer_Finder) & theFinder,
- const Standard_Integer theUpperBound)
-{
- return ::HashCode (theFinder->GetHashCode() - 1, theUpperBound);
-}
-
- Standard_Boolean Transfer_FindHasher::IsEqual
- (const Handle(Transfer_Finder)& K1, const Handle(Transfer_Finder)& K2)
-{
- if (K1.IsNull()) return Standard_False;
- return K1->Equates(K2);
-}
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
+#include <Transfer_Finder.hxx>
#include <Standard_Handle.hxx>
-#include <Standard_Integer.hxx>
-class Transfer_Finder;
-
-
//! FindHasher defines HashCode for Finder, which is : ask a
//! Finder its HashCode ! Because this is the Finder itself which
//! brings the HashCode for its Key
//!
//! This class complies to the template given in TCollection by
//! MapHasher itself
-class Transfer_FindHasher
+class Transfer_FindHasher
{
public:
-
- DEFINE_STANDARD_ALLOC
-
-
- //! Returns hash code for the given finder, in the range [1, theUpperBound].
- //! Asks the finder its hash code, then transforms it to be in the required range
- //! @param theFinder the finder 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]
- Standard_EXPORT static Standard_Integer HashCode (const Handle (Transfer_Finder) & theFinder,
- Standard_Integer theUpperBound);
+ size_t operator()(const Handle(Transfer_Finder)& theFinder) const
+ {
+ return theFinder->GetHashCode();
+ }
//! Returns True if two keys are the same.
//! The test does not work on the Finders themselves but by
//! calling their methods Equates
- Standard_EXPORT static Standard_Boolean IsEqual (const Handle(Transfer_Finder)& K1, const Handle(Transfer_Finder)& K2);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
+ bool operator() (const Handle(Transfer_Finder)& theK1,
+ const Handle(Transfer_Finder)& theK2) const
+ {
+ if (theK1.IsNull()) return false;
+ return theK1->Equates(theK2);
+ }
};
-
-
-
-
-
-
#endif // _Transfer_FindHasher_HeaderFile
IMPLEMENT_STANDARD_RTTIEXT(Transfer_Finder,Standard_Transient)
-void Transfer_Finder::SetHashCode (const Standard_Integer code)
+void Transfer_Finder::SetHashCode (const size_t code)
{ thecode = code; }
- Standard_Integer Transfer_Finder::GetHashCode () const
+ size_t Transfer_Finder::GetHashCode () const
{ return thecode; }
Handle(Standard_Type) Transfer_Finder::ValueType () const
//! Returns the HashCode which has been stored by SetHashCode
//! (remark that HashCode could be deferred then be defined by
//! sub-classes, the result is the same)
- Standard_EXPORT Standard_Integer GetHashCode() const;
+ Standard_EXPORT size_t GetHashCode() const;
//! Specific testof equality : to be defined by each sub-class,
//! must be False if Finders have not the same true Type, else
//! Stores the HashCode which corresponds to the Value given to
//! create the Mapper
- Standard_EXPORT void SetHashCode (const Standard_Integer code);
+ Standard_EXPORT void SetHashCode (const size_t code);
private:
- Standard_Integer thecode;
+ size_t thecode;
NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> theattrib;
+++ /dev/null
-// Copyright (c) 1999-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.
-
-// Transfer_Iterator.gxx
-#include <Standard_NoSuchObject.hxx>
-
-
-// TheStart est suppose Handle(Standard_Transient) ou (Transfer_Finder)
-// Il a servi a instancier TheList qui est une HSequence
-
-
-Transfer_Iterator::Transfer_Iterator (const Standard_Boolean withstarts)
- : Transfer_TransferIterator ()
-{ if (withstarts) thestarts = new TheList(); }
-
-
- void Transfer_Iterator::Add
- (const Handle(Transfer_Binder)& binder)
-{
- if (!thestarts.IsNull()) throw Standard_NoSuchObject("Transfer_Iterator : Add, Starting Object required not provided");
- AddItem(binder);
-}
-
- void Transfer_Iterator::Add
- (const Handle(Transfer_Binder)& binder, const TheStart& start)
-{
- AddItem(binder);
- if (!thestarts.IsNull()) thestarts->Append(start);
-}
-
- void Transfer_Iterator::Filter
- (const Handle(TheList)& list, const Standard_Boolean keep)
-{
- if (list.IsNull() || thestarts.IsNull()) return;
- Standard_Integer i, j, nb = thestarts->Length();
- if (nb == 0) return;
- Handle(Transfer_Binder) factice;
- Transfer_TransferMap amap (nb);
- for (i = 1; i <= nb; i ++) {
- j = amap.Add (thestarts->Value(i),factice);
- SelectItem (j,!keep);
- }
-
-// Comparaison
- nb = list->Length();
- for (i = 1; i <= nb; i ++) {
- j = amap.FindIndex (list->Value(i));
- if (j > 0) SelectItem (j,keep);
- }
-}
-
- Standard_Boolean Transfer_Iterator::HasStarting () const
- { return (!thestarts.IsNull()); }
-
- const TheStart& Transfer_Iterator::Starting () const
-{
-// if (thecurr == 0 || thecurr > themaxi) throw Standard_NoSuchObject
-// ("TransferIterator : Starting");
-// if (theselect->Value(thecurr) == 0) throw Standard_NoSuchObject
-// ("TransferIterator : Starting");
- if (thestarts.IsNull()) throw Standard_NoSuchObject("TransferIterator : No Starting defined at all");
- return thestarts->Value(thecurr);
-}
#include <Transfer_TransferMapOfProcessForFinder.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
#include <Transfer_Binder.hxx>
-
-
-#define TheStart Handle(Transfer_Finder)
-#define TheStart_hxx <Transfer_Finder.hxx>
-#define TheMapHasher Transfer_FindHasher
-#define TheMapHasher_hxx <Transfer_FindHasher.hxx>
-#define Handle_TheList Handle(Transfer_HSequenceOfFinder)
-#define TheList Transfer_HSequenceOfFinder
-#define TheList_hxx <Transfer_HSequenceOfFinder.hxx>
-#define Transfer_TransferMap Transfer_TransferMapOfProcessForFinder
-#define Transfer_TransferMap_hxx <Transfer_TransferMapOfProcessForFinder.hxx>
-#define Transfer_Iterator Transfer_IteratorOfProcessForFinder
-#define Transfer_Iterator_hxx <Transfer_IteratorOfProcessForFinder.hxx>
-#define Transfer_Actor Transfer_ActorOfProcessForFinder
-#define Transfer_Actor_hxx <Transfer_ActorOfProcessForFinder.hxx>
-#define Handle_Transfer_Actor Handle(Transfer_ActorOfProcessForFinder)
-#define Transfer_TransferProcess Transfer_ProcessForFinder
-#define Transfer_TransferProcess_hxx <Transfer_ProcessForFinder.hxx>
-#define Handle_Transfer_TransferProcess Handle(Transfer_ProcessForFinder)
-#include <Transfer_Iterator.gxx>
+
+//=======================================================================
+// Function: Transfer_IteratorOfProcessForFinder
+// Purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForFinder::Transfer_IteratorOfProcessForFinder(const Standard_Boolean withstarts)
+ : Transfer_TransferIterator()
+{
+ if (withstarts) thestarts = new Transfer_HSequenceOfFinder();
+}
+
+//=======================================================================
+// Function: Add
+// Purpose :
+//=======================================================================
+void Transfer_IteratorOfProcessForFinder::Add
+(const Handle(Transfer_Binder)& binder)
+{
+ if (!thestarts.IsNull()) throw Standard_NoSuchObject("Transfer_IteratorOfProcessForFinder : Add, Starting Object required not provided");
+ AddItem(binder);
+}
+
+//=======================================================================
+// Function: Add
+// Purpose :
+//=======================================================================
+void Transfer_IteratorOfProcessForFinder::Add
+(const Handle(Transfer_Binder)& binder, const Handle(Transfer_Finder)& start)
+{
+ AddItem(binder);
+ if (!thestarts.IsNull()) thestarts->Append(start);
+}
+
+//=======================================================================
+// Function: Filter
+// Purpose :
+//=======================================================================
+void Transfer_IteratorOfProcessForFinder::Filter
+(const Handle(Transfer_HSequenceOfFinder)& list, const Standard_Boolean keep)
+{
+ if (list.IsNull() || thestarts.IsNull()) return;
+ Standard_Integer i, j, nb = thestarts->Length();
+ if (nb == 0) return;
+ Handle(Transfer_Binder) factice;
+ Transfer_TransferMapOfProcessForFinder amap(nb);
+ for (i = 1; i <= nb; i++) {
+ j = amap.Add(thestarts->Value(i), factice);
+ SelectItem(j, !keep);
+ }
+
+ // Comparison
+ nb = list->Length();
+ for (i = 1; i <= nb; i++) {
+ j = amap.FindIndex(list->Value(i));
+ if (j > 0) SelectItem(j, keep);
+ }
+}
+
+//=======================================================================
+// Function: HasStarting
+// Purpose :
+//=======================================================================
+Standard_Boolean Transfer_IteratorOfProcessForFinder::HasStarting() const
+{
+ return (!thestarts.IsNull());
+}
+
+//=======================================================================
+// Function: Starting
+// Purpose :
+//=======================================================================
+const Handle(Transfer_Finder)& Transfer_IteratorOfProcessForFinder::Starting() const
+{
+ if (thestarts.IsNull()) throw Standard_NoSuchObject("TransferIterator : No Starting defined at all");
+ return thestarts->Value(thecurr);
+}
#include <Transfer_TransferMapOfProcessForTransient.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx>
#include <Transfer_Binder.hxx>
-
-
-#define TheStart Handle(Standard_Transient)
-#define TheStart_hxx <Standard_Transient.hxx>
-#define TheMapHasher TColStd_MapTransientHasher
-#define TheMapHasher_hxx <TColStd_MapTransientHasher.hxx>
-#define Handle_TheList Handle(TColStd_HSequenceOfTransient)
-#define TheList TColStd_HSequenceOfTransient
-#define TheList_hxx <TColStd_HSequenceOfTransient.hxx>
-#define Transfer_TransferMap Transfer_TransferMapOfProcessForTransient
-#define Transfer_TransferMap_hxx <Transfer_TransferMapOfProcessForTransient.hxx>
-#define Transfer_Iterator Transfer_IteratorOfProcessForTransient
-#define Transfer_Iterator_hxx <Transfer_IteratorOfProcessForTransient.hxx>
-#define Transfer_Actor Transfer_ActorOfProcessForTransient
-#define Transfer_Actor_hxx <Transfer_ActorOfProcessForTransient.hxx>
-#define Handle_Transfer_Actor Handle(Transfer_ActorOfProcessForTransient)
-#define Transfer_TransferProcess Transfer_ProcessForTransient
-#define Transfer_TransferProcess_hxx <Transfer_ProcessForTransient.hxx>
-#define Handle_Transfer_TransferProcess Handle(Transfer_ProcessForTransient)
-#include <Transfer_Iterator.gxx>
+//=======================================================================
+//function : Transfer_IteratorOfProcessForTransient
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForTransient::Transfer_IteratorOfProcessForTransient(const Standard_Boolean withstarts)
+ : Transfer_TransferIterator()
+{
+ if (withstarts) thestarts = new TColStd_HSequenceOfTransient();
+}
+
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+void Transfer_IteratorOfProcessForTransient::Add
+(const Handle(Transfer_Binder)& binder)
+{
+ if (!thestarts.IsNull()) throw Standard_NoSuchObject("Transfer_IteratorOfProcessForTransient : Add, Starting Object required not provided");
+ AddItem(binder);
+}
+
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+void Transfer_IteratorOfProcessForTransient::Add
+(const Handle(Transfer_Binder)& binder, const Handle(Standard_Transient)& start)
+{
+ AddItem(binder);
+ if (!thestarts.IsNull()) thestarts->Append(start);
+}
+
+//=======================================================================
+//function : Filter
+//purpose :
+//=======================================================================
+void Transfer_IteratorOfProcessForTransient::Filter
+(const Handle(TColStd_HSequenceOfTransient)& list, const Standard_Boolean keep)
+{
+ if (list.IsNull() || thestarts.IsNull()) return;
+ Standard_Integer i, j, nb = thestarts->Length();
+ if (nb == 0) return;
+ Handle(Transfer_Binder) factice;
+ Transfer_TransferMapOfProcessForTransient amap(nb);
+ for (i = 1; i <= nb; i++)
+ {
+ j = amap.Add(thestarts->Value(i), factice);
+ SelectItem(j, !keep);
+ }
+
+ // Comparison
+ nb = list->Length();
+ for (i = 1; i <= nb; i++)
+ {
+ j = amap.FindIndex(list->Value(i));
+ if (j > 0) SelectItem(j, keep);
+ }
+}
+
+//=======================================================================
+//function : HasStarting
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_IteratorOfProcessForTransient::HasStarting() const
+{
+ return (!thestarts.IsNull());
+}
+
+//=======================================================================
+//function : Starting
+//purpose :
+//=======================================================================
+const Handle(Standard_Transient)& Transfer_IteratorOfProcessForTransient::Starting() const
+{
+ if (thestarts.IsNull()) throw Standard_NoSuchObject("TransferIterator : No Starting defined at all");
+ return thestarts->Value(thecurr);
+}
+++ /dev/null
-// Copyright (c) 1999-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 <Transfer_Mapper.ixx>
-#include <Standard_Integer.hxx>
-
-
-Transfer_Mapper::Transfer_Mapper (const TheKey& akey)
- : theval (akey)
-{ SetHashCode ( TheHasher::HashCode (akey, IntegerLast() ) ); }
-
-
- const TheKey& Transfer_Mapper::Value () const
- { return theval; }
-
- Standard_Boolean Transfer_Mapper::Equates
- (const Handle(Transfer_Finder)& other) const
-{
- if (other.IsNull()) return Standard_False;
- if (GetHashCode() != other->GetHashCode()) return Standard_False;
- if (other->DynamicType() != DynamicType()) return Standard_False;
- Handle(Transfer_Mapper) another = Handle(Transfer_Mapper)::DownCast(other);
-// return (theval == another->Value());
- return TheHasher::IsEqual (theval,another->Value());
-}
-
- Handle(Standard_Type) Transfer_Mapper::ValueType () const
- { return TheInfo::Type(theval); }
-
- Standard_CString Transfer_Mapper::ValueTypeName () const
- { return TheInfo::TypeName(theval); }
#include <Transfer_ProcessForFinder.hxx>
-#include <Standard_Type.hxx>
-
+#include <Interface_Check.hxx>
+#include <Interface_CheckIterator.hxx>
+#include <Interface_InterfaceError.hxx>
+#include <Message.hxx>
#include <Message_Messenger.hxx>
-#include <Transfer_Finder.hxx>
-#include <Transfer_Binder.hxx>
+#include <Message_Msg.hxx>
+#include <Message_Msg.hxx>
+#include <Message_ProgressScope.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <Transfer_ActorOfProcessForFinder.hxx>
-#include <Interface_InterfaceError.hxx>
-#include <Transfer_TransferFailure.hxx>
+#include <Transfer_Binder.hxx>
+#include <Transfer_Finder.hxx>
#include <Transfer_FindHasher.hxx>
-#include <Transfer_TransferMapOfProcessForFinder.hxx>
#include <Transfer_IteratorOfProcessForFinder.hxx>
-#include <Message_Msg.hxx>
-#include <Interface_Check.hxx>
-#include <Standard_Transient.hxx>
-#include <Interface_CheckIterator.hxx>
+#include <Transfer_MultipleBinder.hxx>
+#include <Transfer_SimpleBinderOfTransient.hxx>
+#include <Transfer_StatusResult.hxx>
+#include <Transfer_TransferDeadLoop.hxx>
+#include <Transfer_TransferFailure.hxx>
+#include <Transfer_TransferMapOfProcessForFinder.hxx>
+#include <Transfer_VoidBinder.hxx>
+
+//=======================================================================
+//function : Transfer_ProcessForFinder
+//purpose :
+//=======================================================================
+Transfer_ProcessForFinder::Transfer_ProcessForFinder(const Standard_Integer nb)
+ : themap(nb)
+{
+ theerrh = Standard_True;
+ therootm = Standard_False;
+ thelevel = 0; therootl = 0;
+ themessenger = Message::DefaultMessenger();
+ thetrace = 0;
+ theindex = 0;
+}
+
+//=======================================================================
+//function : Transfer_ProcessForFinder
+//purpose :
+//=======================================================================
+Transfer_ProcessForFinder::Transfer_ProcessForFinder(const Handle(Message_Messenger)& messenger,
+ const Standard_Integer nb)
+ : themap(nb)
+{
+ theerrh = Standard_True;
+ therootm = Standard_False;
+ thelevel = 0; therootl = 0;
+ SetMessenger(messenger);
+ thetrace = 1;
+ theindex = 0;
+}
+
+//=======================================================================
+//function : Clear
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::Clear()
+{
+ thelevel = 0; therootl = 0;
+ theroots.Clear();
+ themap.Clear();
+ theindex = 0; thelastobj.Nullify(); thelastbnd.Nullify();
+}
+
+//=======================================================================
+//function : Clean
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::Clean()
+{
+ Standard_Integer i, nb = NbMapped();
+ Standard_Integer j, unb = 0;
+ for (i = 1; i <= nb; i++)
+ {
+ if (themap(i).IsNull()) unb++;
+ }
+ if (unb == 0) return;
+
+ // Redo the map -> offsets
+ TColStd_Array1OfInteger unbs(1, nb); unbs.Init(0);
+ Transfer_TransferMapOfProcessForFinder newmap(nb * 2);
+ for (i = 1; i <= nb; i++)
+ {
+ Handle(Transfer_Finder) ent = Mapped(i);
+ Handle(Transfer_Binder) bnd = MapItem(i);
+ if (bnd.IsNull()) continue;
+ j = newmap.Add(ent, bnd);
+ unbs.SetValue(i, j);
+ }
+ themap.Assign(newmap);
+
+ // Update Root List
+ TColStd_IndexedMapOfInteger aNewRoots;
+ for (i = 1; i <= theroots.Extent(); i++)
+ {
+ j = theroots.FindKey(i);
+ Standard_Integer k = unbs.Value(j);
+ if (k) aNewRoots.Add(k);
+ }
+ theroots.Clear();
+ theroots = aNewRoots;
+
+ // The rest: cleaning
+ thelastobj.Nullify();
+ thelastbnd.Nullify();
+ theindex = 0;
+}
+
+//=======================================================================
+//function : Resize
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::Resize(const Standard_Integer nb)
+{
+ if (nb > themap.NbBuckets()) themap.ReSize(nb);
+}
+
+//=======================================================================
+//function : SetActor
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SetActor(const Handle(Transfer_ActorOfProcessForFinder)& actor)
+{
+ if (theactor == actor) return;
+ if (theactor.IsNull()) theactor = actor;
+ else if (actor.IsNull()) theactor = actor;
+ else if (theactor->IsLast()) { actor->SetNext(theactor); theactor = actor; }
+ else theactor->SetNext(actor);
+}
+
+//=======================================================================
+//function : Actor
+//purpose :
+//=======================================================================
+Handle(Transfer_ActorOfProcessForFinder) Transfer_ProcessForFinder::Actor() const
+{
+ return theactor;
+}
+
+//=======================================================================
+//function : Find
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::Find(const Handle(Transfer_Finder)& start) const
+{
+ if (thelastobj == start)
+ {
+ if (theindex > 0) return thelastbnd;
+ }
+ Standard_Integer index = themap.FindIndex(start);
+ if (index > 0)
+ {
+ const Handle(Transfer_Binder)& binder = themap.FindFromIndex(index);
+ return binder;
+ }
+ return Handle(Transfer_Binder)();
+}
+
+//=======================================================================
+//function : IsBound
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::IsBound(const Handle(Transfer_Finder)& start) const
+{
+ Handle(Transfer_Binder) binder = Find(start);
+ if (binder.IsNull()) return Standard_False;
+ return binder->HasResult();
+}
+
+//=======================================================================
+//function : IsAlreadyUsed
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::IsAlreadyUsed(const Handle(Transfer_Finder)& start) const
+{
+ Handle(Transfer_Binder) binder = Find(start);
+ if (binder.IsNull())
+ {
+ StartTrace(binder, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : IsAlreadyUsed, transfer not done cannot be used...");
+ }
+ return (binder->Status() == Transfer_StatusUsed);
+}
+
+//=======================================================================
+//function : FindAndMask
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::FindAndMask(const Handle(Transfer_Finder)& start)
+{
+ if (thelastobj == start)
+ {
+ if (theindex > 0) return thelastbnd;
+ }
+ thelastobj = start;
+ theindex = themap.FindIndex(start);
+ if (theindex > 0) thelastbnd = themap.FindFromIndex(theindex);
+ else thelastbnd.Nullify();
+ return thelastbnd;
+}
+
+//=======================================================================
+//function : Bind
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::Bind(const Handle(Transfer_Finder)& start,
+ const Handle(Transfer_Binder)& binder)
+{
+ if (binder.IsNull()) return;
+ Handle(Transfer_Binder) former = FindAndMask(start);
+ if (!former.IsNull())
+ {
+ // We admit VoidBinder: then we resume our Check
+ if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder))
+ {
+ binder->Merge(former);
+ themap(theindex) = binder;
+ }
+ else if (former->Status() == Transfer_StatusUsed)
+ {
+ StartTrace(former, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : Bind, already Bound");
+ }
+ else
+ {
+ if (thetrace > 2) StartTrace(former, start, thelevel, 5);
+ binder->CCheck()->GetMessages(former->Check());
+ }
+ }
+ if (theindex == 0 || thelastbnd.IsNull())
+ {
+ if (theindex == 0) theindex = themap.Add(start, binder);
+ else themap(theindex) = binder;
+ thelastbnd = binder;
+ }
+ else
+ {
+ thelastbnd = binder;
+ themap(theindex) = binder;
+ }
+}
+
+//=======================================================================
+//function : Rebind
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::Rebind(const Handle(Transfer_Finder)& start,
+ const Handle(Transfer_Binder)& binder)
+{
+ Bind(start, binder);
+}
+
+//=======================================================================
+//function : Unbind
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::Unbind(const Handle(Transfer_Finder)& start)
+{
+ Handle(Transfer_Binder) former = FindAndMask(start);
+ if (theindex == 0) return Standard_False;
+ if (former.IsNull()) return Standard_False;
+ if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) return Standard_True;
+ themap(theindex) = thelastbnd;
+ if (theroots.Contains(theindex))
+ {
+ TColStd_IndexedMapOfInteger aNewRoots;
+ for (Standard_Integer i = 1; i <= theroots.Extent(); i++)
+ if (theindex != theroots.FindKey(i))
+ aNewRoots.Add(theroots.FindKey(i));
+
+ theroots.Clear();
+ theroots = aNewRoots;
+ }
+
+ thelastobj.Nullify();
+ thelastbnd.Nullify();
+ theindex = 0;
+ return Standard_True;
+}
+
+//=======================================================================
+//function : FindElseBind
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::FindElseBind(const Handle(Transfer_Finder)& start)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (!binder.IsNull()) return binder;
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ return binder;
+}
+
+//=======================================================================
+//function : SetMessenger
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SetMessenger(const Handle(Message_Messenger)& messenger)
+{
+ if (messenger.IsNull())
+ themessenger = Message::DefaultMessenger();
+ else
+ themessenger = messenger;
+}
+
+//=======================================================================
+//function : Messenger
+//purpose :
+//=======================================================================
+Handle(Message_Messenger) Transfer_ProcessForFinder::Messenger() const
+{
+ return themessenger;
+}
+
+//=======================================================================
+//function : SetTraceLevel
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SetTraceLevel(const Standard_Integer tracelev)
+{
+ thetrace = tracelev;
+}
+
+//=======================================================================
+//function : TraceLevel
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::TraceLevel() const
+{
+ return thetrace;
+}
+
+//=======================================================================
+//function : SendFail
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SendFail(const Handle(Transfer_Finder)& start,
+ const Message_Msg& amsg)
+{
+ AddFail(start, amsg);
+}
+
+//=======================================================================
+//function : SendWarning
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SendWarning(const Handle(Transfer_Finder)& start,
+ const Message_Msg& amsg)
+{
+ AddWarning(start, amsg);
+}
+
+//=======================================================================
+//function : SendMsg
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SendMsg(const Handle(Transfer_Finder)& start,
+ const Message_Msg& amsg)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull())
+ {
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ }
+ // Feeds the trace: Causing rule (user messages)
+ if (thetrace > 0)
+ {
+ StartTrace(binder, start, thelevel, 6);
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+ aSender << amsg.Value();
+ if (amsg.IsEdited() && thetrace > 2)
+ aSender << " [from: " << amsg.Original() << "]";
+ aSender << std::endl;
+ }
+}
+
+//=======================================================================
+//function : AddFail
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::AddFail(const Handle(Transfer_Finder)& start,
+ const Standard_CString mess,
+ const Standard_CString orig)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull())
+ {
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ }
+ binder->AddFail(mess, orig);
+ if (thetrace > 0)
+ {
+ StartTrace(binder, start, thelevel, 1);
+ Message_Messenger::StreamBuffer aSender = themessenger->SendFail();
+ aSender << " --> Fail : " << mess;
+ if (orig[0] != '\0' && thetrace > 2) aSender << " [from: " << orig << "]";
+ aSender << std::endl;
+ }
+}
+
+//=======================================================================
+//function : AddError
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::AddError(const Handle(Transfer_Finder)& start,
+ const Standard_CString mess,
+ const Standard_CString orig)
+{
+ AddFail(start, mess, orig);
+}
+
+//=======================================================================
+//function : AddFail
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::AddFail(const Handle(Transfer_Finder)& start,
+ const Message_Msg& amsg)
+{
+ if (amsg.IsEdited()) AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString(),
+ TCollection_AsciiString(amsg.Original()).ToCString());
+ else AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString());
+}
+
+//=======================================================================
+//function : AddWarning
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::AddWarning(const Handle(Transfer_Finder)& start,
+ const Standard_CString mess,
+ const Standard_CString orig)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull())
+ {
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ }
+ binder->AddWarning(mess, orig);
+ if (thetrace > 1)
+ {
+ StartTrace(binder, start, thelevel, 2);
+ Message_Messenger::StreamBuffer aSender = themessenger->SendWarning();
+ aSender << " --> Warning : " << mess;
+ if (orig[0] != '\0' && thetrace > 2) aSender << " [from: " << orig << "]";
+ aSender << std::endl;
+ }
+}
+
+//=======================================================================
+//function : AddWarning
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::AddWarning(const Handle(Transfer_Finder)& start,
+ const Message_Msg& amsg)
+{
+ if (amsg.IsEdited()) AddWarning(start, TCollection_AsciiString(amsg.Value()).ToCString(),
+ TCollection_AsciiString(amsg.Original()).ToCString());
+ else AddWarning(start, TCollection_AsciiString(amsg.Value()).ToCString());
+}
+
+//=======================================================================
+//function : Mend
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::Mend(const Handle(Transfer_Finder)& start,
+ const Standard_CString pref)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull()) return; // rien a faire ...
+ Handle(Interface_Check) ach = binder->CCheck();
+ ach->Mend(pref);
+}
+
+//=======================================================================
+//function : Check
+//purpose :
+//=======================================================================
+Handle(Interface_Check) Transfer_ProcessForFinder::Check(const Handle(Transfer_Finder)& start) const
+{
+ const Handle(Transfer_Binder)& binder = Find(start);
+ if (binder.IsNull())
+ {
+ Handle(Interface_Check) check;
+ return check;
+ }
+ return binder->Check();
+}
+
+//=======================================================================
+//function : BindTransient
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::BindTransient(const Handle(Transfer_Finder)& start,
+ const Handle(Standard_Transient)& res)
+{
+ if (res.IsNull()) return;
+ Handle(Transfer_Binder) former = Find(start);
+ Handle(Transfer_SimpleBinderOfTransient) binder =
+ Handle(Transfer_SimpleBinderOfTransient)::DownCast(former);
+ // Binding sur place ?
+ if (!binder.IsNull())
+ {
+ if (binder->Status() == Transfer_StatusVoid) { binder->SetResult(res); return; }
+ }
+ // Otherwise, redo
+ binder = new Transfer_SimpleBinderOfTransient;
+ binder->SetResult(res);
+ if (former.IsNull()) Bind(start, binder);
+ else Rebind(start, binder);
+}
+
+//=======================================================================
+//function : FindTransient
+//purpose :
+//=======================================================================
+const Handle(Standard_Transient)& Transfer_ProcessForFinder::FindTransient
+(const Handle(Transfer_Finder)& start) const
+{
+ static const Handle(Standard_Transient) aDummy;
+ Handle(Transfer_SimpleBinderOfTransient) binder =
+ Handle(Transfer_SimpleBinderOfTransient)::DownCast(Find(start));
+ if (binder.IsNull()) return aDummy;
+ if (!binder->HasResult()) return aDummy;
+ return binder->Result();
+}
+
+//=======================================================================
+//function : BindMultiple
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::BindMultiple(const Handle(Transfer_Finder)& start)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (!binder.IsNull())
+ {
+ if (!binder->IsKind(STANDARD_TYPE(Transfer_MultipleBinder)))
+ {
+ StartTrace(thelastbnd, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : BindMultiple");
+ }
+ }
+ else Bind(start, new Transfer_MultipleBinder);
+}
+
+//=======================================================================
+//function : AddMultiple
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::AddMultiple(const Handle(Transfer_Finder)& start,
+ const Handle(Standard_Transient)& res)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ Handle(Transfer_MultipleBinder) multr =
+ Handle(Transfer_MultipleBinder)::DownCast(binder);
+ if (multr.IsNull())
+ {
+ StartTrace(binder, start, thelevel, 4);
+ if (binder.IsNull()) throw Transfer_TransferFailure("TransferProcess : AddMultiple, nothing bound");
+ else throw Transfer_TransferFailure("TransferProcess : AddMultiple, Binder not a MultipleBinder");
+ }
+ multr->AddResult(res);
+}
+
+//=======================================================================
+//function : FindTypedTransient
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::FindTypedTransient
+(const Handle(Transfer_Finder)& start, const Handle(Standard_Type)& atype,
+ Handle(Standard_Transient)& val) const
+{
+ return GetTypedTransient(Find(start), atype, val);
+}
+
+//=======================================================================
+//function : GetTypedTransient
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::GetTypedTransient
+(const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype,
+ Handle(Standard_Transient)& val) const
+{
+ return Transfer_SimpleBinderOfTransient::GetTypedResult(binder, atype, val);
+}
+
+//=======================================================================
+//function : NbMapped
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::NbMapped() const
+{
+ return themap.Extent();
+}
+
+//=======================================================================
+//function : Mapped
+//purpose :
+//=======================================================================
+const Handle(Transfer_Finder)& Transfer_ProcessForFinder::Mapped(const Standard_Integer num) const
+{
+ return themap.FindKey(num);
+}
+
+//=======================================================================
+//function : MapIndex
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::MapIndex(const Handle(Transfer_Finder)& start) const
+{
+ return themap.FindIndex(start);
+}
+
+//=======================================================================
+//function : MapItem
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::MapItem(const Standard_Integer num) const
+{
+ Handle(Transfer_Binder) binder = themap.FindFromIndex(num);
+ return binder;
+}
+
+//=======================================================================
+//function : SetRoot
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SetRoot(const Handle(Transfer_Finder)& start)
+{
+ Standard_Integer index = MapIndex(start);
+ if (index == 0)
+ {
+ return;
+ }
+ theroots.Add(index);
+ if (thetrace > 2) StartTrace(MapItem(index), start, thelevel, 3);
+}
+
+//=======================================================================
+//function : SetRootManagement
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SetRootManagement(const Standard_Boolean stat)
+{
+ therootm = stat;
+}
+
+//=======================================================================
+//function : NbRoots
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::NbRoots() const
+{
+ return theroots.Extent();
+}
+
+//=======================================================================
+//function : Root
+//purpose :
+//=======================================================================
+const Handle(Transfer_Finder)& Transfer_ProcessForFinder::Root(const Standard_Integer num) const
+{
+ Standard_Integer ind = 0;
+ if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
+ return themap.FindKey(ind);
+}
+
+//=======================================================================
+//function : RootItem
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::RootItem(const Standard_Integer num) const
+{
+ Standard_Integer ind = 0;
+ if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
+ return themap.FindFromIndex(ind);
+}
+
+//=======================================================================
+//function : RootIndex
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::RootIndex(const Handle(Transfer_Finder)& start) const
+{
+ Standard_Integer index = MapIndex(start);
+ if (index == 0) return 0;
+ return theroots.FindIndex(index);
+}
+
+//=======================================================================
+//function : NestingLevel
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::NestingLevel() const
+{
+ return thelevel;
+}
+
+//=======================================================================
+//function : ResetNestingLevel
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::ResetNestingLevel()
+{
+ thelevel = 0;
+}
+
+//=======================================================================
+//function : Recognize
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::Recognize(const Handle(Transfer_Finder)& start) const
+{
+ Handle(Transfer_ActorOfProcessForFinder) actor = theactor;
+ // We scan the Next until we have a Result
+ while (!actor.IsNull())
+ {
+ if (actor->Recognize(start)) return Standard_True;
+ actor = actor->Next();
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Transferring
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::Transferring(const Handle(Transfer_Finder)& start,
+ const Message_ProgressRange& theProgress)
+{
+ Handle(Transfer_Binder) former = FindAndMask(start);
+ // Transfer already done with Result?
+
+ // We consider that this new Transfer request therefore corresponds to a
+ // additional use: note "AlreadyUsed", therefore non-modifiable result
+ if (!former.IsNull())
+ {
+ if (former->HasResult())
+ {
+ former->SetAlreadyUsed();
+ return former;
+ }
+ // Initial State: perhaps already done... or infeasible!
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+ Transfer_StatusExec statex = former->StatusExec();
+ switch (statex)
+ {
+ case Transfer_StatusInitial:
+ break;
+ case Transfer_StatusDone:
+ aSender << " .. and Transfer done" << std::endl;
+ return former;
+ case Transfer_StatusRun:
+ former->SetStatusExec(Transfer_StatusLoop);
+ return former;
+ case Transfer_StatusError:
+ if (thetrace)
+ {
+ aSender << " *** Transfer in Error Status :" << std::endl;
+ StartTrace(former, start, thelevel, 0);
+ }
+ else StartTrace(former, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status");
+ case Transfer_StatusLoop:
+ if (thetrace)
+ {
+ aSender << " *** Transfer Head of Dead Loop :" << std::endl;
+ StartTrace(former, start, thelevel, 0);
+ }
+ else StartTrace(former, start, thelevel, 4);
+ throw Transfer_TransferDeadLoop("TransferProcess : Transfer at Head of a Dead Loop");
+ }
+ former->SetStatusExec(Transfer_StatusRun);
+ }
+#ifdef TRANSLOG
+ std::cout << " GO .." << std::endl;
+#endif
+
+ Handle(Transfer_Binder) binder;
+ Standard_Boolean newbind = Standard_False;
+ if (theerrh)
+ {
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+
+ // Transfer under protection for exceptions (for notification in fact
+ Standard_Integer oldlev = thelevel;
+ try
+ {
+ OCC_CATCH_SIGNALS
+ binder = TransferProduct(start, theProgress);
+ }
+
+ // Exceptions to catch up on: they are not all the same
+ catch (Transfer_TransferDeadLoop const&)
+ {
+ if (binder.IsNull())
+ {
+ aSender << " *** Dead Loop with no Result" << std::endl;
+ if (thetrace) StartTrace(binder, start, thelevel - 1, 0);
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder); newbind = Standard_True;
+ }
+ else if (binder->StatusExec() == Transfer_StatusLoop)
+ {
+ if (thetrace)
+ {
+ aSender << " *** Dead Loop : Finding head of Loop :" << std::endl;
+ StartTrace(binder, start, thelevel - 1, 0);
+ }
+ else StartTrace(binder, start, thelevel - 1, 4);
+ throw Transfer_TransferFailure("TransferProcess : Head of Dead Loop");
+ // In other words, we change the exception (we exit the loop)
+ }
+ else
+ {
+ if (thetrace)
+ {
+ aSender << " *** Dead Loop : Actor in Loop :" << std::endl;
+ StartTrace(binder, start, thelevel - 1, 0);
+ }
+ }
+ binder->AddFail("Transfer in dead Loop");
+ thelevel = oldlev;
+ }
+ catch (Standard_Failure const& anException)
+ {
+ if (binder.IsNull())
+ {
+ aSender << " *** Exception Raised with no Result" << std::endl;
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder); newbind = Standard_True;
+ }
+ binder->AddFail("Transfer stopped by exception raising");
+ if (thetrace)
+ {
+ aSender << " *** Raised : " << anException.GetMessageString() << std::endl;
+ StartTrace(binder, start, thelevel - 1, 4);
+ }
+ thelevel = oldlev;
+ }
+ }
+
+ // Unprotected transfer (thus, dbx by hand in case of crash by Raise)
+ else binder = TransferProduct(start, theProgress);
+
+ if (theProgress.UserBreak())
+ return Handle(Transfer_Binder)();
+
+ // Conclusion: Note in the Map
+
+ if (!newbind && !binder.IsNull())
+ {
+ if (former.IsNull())
+ {
+ // Maybe <theactor> did Bind himself... check if not do it
+ if (!IsBound(start)) Bind(start, binder);
+ else
+ {
+ Rebind(start, binder);
+ }
+ }
+ else Rebind(start, binder);
+ }
+ else
+ {
+ if (!former.IsNull()) former->SetStatusExec(Transfer_StatusDone); //+
+ return Handle(Transfer_Binder)();
+ }
+
+ // Manage Roots (if provided)
+
+ if (therootl >= thelevel)
+ {
+ therootl = 0;
+ if (therootm && binder->Status() != Transfer_StatusVoid)
+ {
+ SetRoot(start);
+ }
+ }
+ return thelastbnd;
+}
+
+
+//=======================================================================
+//function : TransferProduct
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForFinder::TransferProduct
+(const Handle(Transfer_Finder)& start,
+ const Message_ProgressRange& theProgress)
+{
+ thelevel++; // if decrements and == 0, root transfer
+ Handle(Transfer_Binder) binder;
+ Handle(Transfer_ActorOfProcessForFinder) actor = theactor;
+
+ // We scan the Next until we have a Result
+ Message_ProgressScope aScope(theProgress, NULL, 1, true);
+ while (!actor.IsNull())
+ {
+ if (actor->Recognize(start)) binder = actor->Transferring(start, this, aScope.Next());
+ else binder.Nullify();
+ if (!binder.IsNull()) break;
+ actor = actor->Next();
+ }
+ if (aScope.UserBreak())
+ return Handle(Transfer_Binder)();
+
+ if (binder.IsNull())
+ {
+ if (thelevel > 0) thelevel--;
+ return binder;
+ }
+ // Root level management (.. take a closer look..)
+ if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone)
+ therootl = thelevel - 1;
+
+ if (thelevel > 0) thelevel--;
+ return binder;
+}
+
+//=======================================================================
+//function : Transfer
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::Transfer(const Handle(Transfer_Finder)& start,
+ const Message_ProgressRange& theProgress)
+{
+ Handle(Transfer_Binder) binder = Transferring(start, theProgress);
+ return (!binder.IsNull());
+}
+
+//=======================================================================
+//function : SetErrorHandle
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::SetErrorHandle(const Standard_Boolean err)
+{
+ theerrh = err;
+}
+
+//=======================================================================
+//function : ErrorHandle
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::ErrorHandle() const
+{
+ return theerrh;
+}
+
+//=======================================================================
+//function : StartTrace
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::StartTrace(const Handle(Transfer_Binder)& binder,
+ const Handle(Transfer_Finder)& start,
+ const Standard_Integer level,
+ const Standard_Integer mode) const
+{
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+ // ### Fail (Roots:50) -- Start start->DynamicType()
+ // ### Fail (Roots:50) -- Start id:#label.. Type:start->DynamicType()
+ if (thetrace > 3)
+ { // Internal to be switch when searching bug (trace >= 4)
+ if (mode == 1) aSender << " ### Fail";
+ if (mode == 2) aSender << " ### Warning";
+ if (mode == 3) aSender << " ### New Root n0 " << theroots.Extent();
+ if (mode == 4) aSender << " ### Exception";
+ if (mode == 5) aSender << " ### Substitution";
+ if (mode == 6) aSender << " ### Information";
+ if (level > 1)
+ aSender << " (nested)";
+ if (mode >= 0 && mode != 3)
+ aSender << " at " << theroots.Extent() << " Roots";
+ }
+ if (!start.IsNull()) PrintTrace(start, aSender);
+
+ if (!binder.IsNull())
+ {
+ Handle(Transfer_Binder) bnd = binder;
+ Standard_Boolean hasres = Standard_False;
+ while (!bnd.IsNull())
+ {
+ if (bnd->Status() != Transfer_StatusVoid)
+ {
+ if (!hasres)
+ aSender << "\n --- Result Type : ";
+ else
+ aSender << " , ";
+ aSender << bnd->ResultTypeName();
+ hasres = Standard_True;
+ }
+ bnd = bnd->NextResult();
+ }
+ if (!hasres && mode > 2)
+ {
+ aSender << "\n --- No Result recorded";
+ }
+ }
+ aSender << std::endl;
+}
+
+//=======================================================================
+//function : PrintTrace
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::PrintTrace(const Handle(Transfer_Finder)& start, Standard_OStream& S) const
+{
+ if (!start.IsNull()) S << " Type:" << start->DynamicType()->Name();
+}
+
+//=======================================================================
+//function : IsLooping
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::IsLooping
+(const Standard_Integer alevel) const
+{
+ return alevel > NbMapped();
+}
+
+//=======================================================================
+//function : RootResult
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::RootResult(const Standard_Boolean withstart) const
+{
+ Transfer_IteratorOfProcessForFinder iter(withstart);
+ Standard_Integer max = theroots.Extent();
+ for (Standard_Integer j = 1; j <= max; j++)
+ {
+ Standard_Integer i = theroots.FindKey(j);
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ if (withstart) iter.Add(binder, Mapped(i));
+ else iter.Add(binder);
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : CompleteResult
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::CompleteResult
+(const Standard_Boolean withstart) const
+{
+ Transfer_IteratorOfProcessForFinder iter(withstart);
+ Standard_Integer max = NbMapped();
+ for (Standard_Integer i = 1; i <= max; i++)
+ {
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ if (withstart) iter.Add(binder, Mapped(i));
+ else iter.Add(binder);
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : AbnormalResult
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::AbnormalResult() const
+{
+ Transfer_IteratorOfProcessForFinder iter(Standard_True);
+ Standard_Integer max = NbMapped();
+ for (Standard_Integer i = 1; i <= max; i++)
+ {
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ Transfer_StatusExec statex = binder->StatusExec();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
+ iter.Add(binder, Mapped(i)); // we note the "not normal" cases
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : CheckList
+//purpose :
+//=======================================================================
+Interface_CheckIterator Transfer_ProcessForFinder::CheckList
+(const Standard_Boolean erronly) const
+{
+ Interface_CheckIterator list;
+ Standard_Integer num, max = NbMapped();
+ for (Standard_Integer i = 1; i <= max; i++)
+ {
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ Transfer_StatusExec statex = binder->StatusExec();
+ Handle(Interface_Check) check = binder->Check();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
+ !check->HasFailed())
+ check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
+ if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
+ const Handle(Transfer_Finder)& ent = Mapped(i);
+ num = CheckNum(ent);
+ if (num == 0) num = i;
+ check->SetEntity(ent);
+ list.Add(check, num);
+ }
+ return list;
+}
+
+//=======================================================================
+//function : ResultOne
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForFinder Transfer_ProcessForFinder::ResultOne(const Handle(Transfer_Finder)& start,
+ const Standard_Integer level,
+ const Standard_Boolean withstart) const
+{
+ Transfer_IteratorOfProcessForFinder iter(withstart);
+ Standard_Integer max = NbMapped();
+ Standard_Integer ind = MapIndex(start);
+ if (ind == 0) return iter;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ for (Standard_Integer i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ if (withstart) iter.Add(binder, Mapped(ind));
+ else iter.Add(binder);
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : CheckListOne
+//purpose :
+//=======================================================================
+Interface_CheckIterator Transfer_ProcessForFinder::CheckListOne
+(const Handle(Transfer_Finder)& start, const Standard_Integer level,
+ const Standard_Boolean erronly) const
+{
+ Interface_CheckIterator list;
+ Standard_Integer max = NbMapped();
+ Standard_Integer num, ind = MapIndex(start);
+ if (ind == 0) return list;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ for (Standard_Integer i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(ind);
+ if (binder.IsNull()) continue;
+ Transfer_StatusExec statex = binder->StatusExec();
+ Handle(Interface_Check) check = binder->Check();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
+ !check->HasFailed())
+ check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
+ if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
+ const Handle(Transfer_Finder)& ent = Mapped(ind);
+ num = CheckNum(ent); if (num == 0) num = ind;
+ check->SetEntity(ent);
+ list.Add(check, num);
+ }
+ return list;
+}
+
+//=======================================================================
+//function : IsCheckListEmpty
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForFinder::IsCheckListEmpty
+(const Handle(Transfer_Finder)& start, const Standard_Integer level,
+ const Standard_Boolean erronly) const
+{
+ Standard_Integer max = NbMapped();
+ Standard_Integer ind = MapIndex(start);
+ if (ind == 0) return Standard_False;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ for (Standard_Integer i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(ind);
+ if (binder.IsNull()) continue;
+
+ Transfer_StatusExec statex = binder->StatusExec();
+ Handle(Interface_Check) check = binder->Check();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
+ return Standard_False;
+ if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : RemoveResult
+//purpose :
+//=======================================================================
+void Transfer_ProcessForFinder::RemoveResult(const Handle(Transfer_Finder)& start,
+ const Standard_Integer level,
+ const Standard_Boolean /*compute*/)
+{
+ Standard_Integer max = NbMapped();
+ Standard_Integer ind = MapIndex(start);
+ if (ind == 0) return;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
-#define TheStart Handle(Transfer_Finder)
-#define TheStart_hxx <Transfer_Finder.hxx>
-#define TheMapHasher Transfer_FindHasher
-#define TheMapHasher_hxx <Transfer_FindHasher.hxx>
-#define Handle_TheList Handle(Transfer_HSequenceOfFinder)
-#define TheList Transfer_HSequenceOfFinder
-#define TheList_hxx <Transfer_HSequenceOfFinder.hxx>
-#define Transfer_TransferMap Transfer_TransferMapOfProcessForFinder
-#define Transfer_TransferMap_hxx <Transfer_TransferMapOfProcessForFinder.hxx>
-#define Transfer_Iterator Transfer_IteratorOfProcessForFinder
-#define Transfer_Iterator_hxx <Transfer_IteratorOfProcessForFinder.hxx>
-#define Transfer_Actor Transfer_ActorOfProcessForFinder
-#define Transfer_Actor_hxx <Transfer_ActorOfProcessForFinder.hxx>
-#define Handle_Transfer_Actor Handle(Transfer_ActorOfProcessForFinder)
-#define Transfer_TransferProcess Transfer_ProcessForFinder
-#define Transfer_TransferProcess_hxx <Transfer_ProcessForFinder.hxx>
-#define Handle_Transfer_TransferProcess Handle(Transfer_ProcessForFinder)
-#include <Transfer_TransferProcess.gxx>
+ Standard_Integer i;
+ for (i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(ind);
+ if (binder.IsNull()) continue;
+ }
+}
+//=======================================================================
+//function : CheckNum
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForFinder::CheckNum(const Handle(Transfer_Finder)&) const
+{
+ return 0;
+}
#include <Transfer_ProcessForTransient.hxx>
-#include <Standard_Type.hxx>
-
+#include <Interface_Check.hxx>
+#include <Interface_CheckIterator.hxx>
+#include <Interface_InterfaceError.hxx>
+#include <Message.hxx>
#include <Message_Messenger.hxx>
+#include <Message_Msg.hxx>
+#include <Message_Msg.hxx>
+#include <Message_Msg.hxx>
+#include <Message_ProgressScope.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
#include <Standard_Transient.hxx>
-#include <Transfer_Binder.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <Transfer_ActorOfProcessForTransient.hxx>
-#include <Interface_InterfaceError.hxx>
+#include <Transfer_ActorOfProcessForTransient.hxx>
+#include <Transfer_Binder.hxx>
+#include <Transfer_FindHasher.hxx>
+#include <Transfer_IteratorOfProcessForTransient.hxx>
+#include <Transfer_IteratorOfProcessForTransient.hxx>
+#include <Transfer_MultipleBinder.hxx>
+#include <Transfer_SimpleBinderOfTransient.hxx>
+#include <Transfer_StatusResult.hxx>
+#include <Transfer_TransferDeadLoop.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Transfer_TransferMapOfProcessForTransient.hxx>
-#include <Transfer_IteratorOfProcessForTransient.hxx>
-#include <Message_Msg.hxx>
-#include <Interface_Check.hxx>
-#include <Interface_CheckIterator.hxx>
+#include <Transfer_TransferMapOfProcessForTransient.hxx>
+#include <Transfer_VoidBinder.hxx>
+
+//=======================================================================
+//function : Transfer_ProcessForTransient
+//purpose :
+//=======================================================================
+Transfer_ProcessForTransient::Transfer_ProcessForTransient(const Standard_Integer nb)
+ : themap(nb)
+{
+ theerrh = Standard_True;
+ therootm = Standard_False;
+ thelevel = 0; therootl = 0;
+ themessenger = Message::DefaultMessenger();
+ thetrace = 0;
+ theindex = 0;
+}
+
+//=======================================================================
+//function : Transfer_ProcessForTransient
+//purpose :
+//=======================================================================
+Transfer_ProcessForTransient::Transfer_ProcessForTransient(const Handle(Message_Messenger)& messenger,
+ const Standard_Integer nb)
+ : themap(nb)
+{
+ theerrh = Standard_True;
+ therootm = Standard_False;
+ thelevel = 0; therootl = 0;
+ SetMessenger(messenger);
+ thetrace = 1;
+ theindex = 0;
+}
+
+//=======================================================================
+//function : Clear
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::Clear()
+{
+ thelevel = 0; therootl = 0;
+ theroots.Clear();
+ themap.Clear();
+ theindex = 0; thelastobj.Nullify(); thelastbnd.Nullify();
+}
+
+//=======================================================================
+//function : Clean
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::Clean()
+{
+ Standard_Integer i, nb = NbMapped();
+ Standard_Integer j, unb = 0;
+ for (i = 1; i <= nb; i++)
+ {
+ if (themap(i).IsNull()) unb++;
+ }
+ if (unb == 0) return;
+
+ // Redo the map -> offsets
+ TColStd_Array1OfInteger unbs(1, nb); unbs.Init(0);
+ Transfer_TransferMapOfProcessForTransient newmap(nb * 2);
+ for (i = 1; i <= nb; i++)
+ {
+ Handle(Standard_Transient) ent = Mapped(i);
+ Handle(Transfer_Binder) bnd = MapItem(i);
+ if (bnd.IsNull()) continue;
+ j = newmap.Add(ent, bnd);
+ unbs.SetValue(i, j);
+ }
+ themap.Assign(newmap);
+
+ // Update Root List
+ TColStd_IndexedMapOfInteger aNewRoots;
+ for (i = 1; i <= theroots.Extent(); i++)
+ {
+ j = theroots.FindKey(i);
+ Standard_Integer k = unbs.Value(j);
+ if (k) aNewRoots.Add(k);
+ }
+ theroots.Clear();
+ theroots = aNewRoots;
+
+ // The rest: cleaning
+ thelastobj.Nullify();
+ thelastbnd.Nullify();
+ theindex = 0;
+}
+
+//=======================================================================
+//function : Resize
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::Resize(const Standard_Integer nb)
+{
+ if (nb > themap.NbBuckets()) themap.ReSize(nb);
+}
+
+//=======================================================================
+//function : SetActor
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SetActor(const Handle(Transfer_ActorOfProcessForTransient)& actor)
+{
+ if (theactor == actor) return;
+ if (theactor.IsNull()) theactor = actor;
+ else if (actor.IsNull()) theactor = actor;
+ else if (theactor->IsLast())
+ {
+ actor->SetNext(theactor); theactor = actor;
+ }
+ else theactor->SetNext(actor);
+}
+
+//=======================================================================
+//function : Actor
+//purpose :
+//=======================================================================
+Handle(Transfer_ActorOfProcessForTransient) Transfer_ProcessForTransient::Actor() const
+{
+ return theactor;
+}
+
+//=======================================================================
+//function : Find
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::Find(const Handle(Standard_Transient)& start) const
+{
+ if (thelastobj == start)
+ {
+ if (theindex > 0) return thelastbnd;
+ }
+ Standard_Integer index = themap.FindIndex(start);
+ if (index > 0)
+ {
+ const Handle(Transfer_Binder)& binder = themap.FindFromIndex(index);
+ return binder;
+ }
+ return Handle(Transfer_Binder)();
+}
+
+//=======================================================================
+//function : IsBound
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::IsBound(const Handle(Standard_Transient)& start) const
+{
+ Handle(Transfer_Binder) binder = Find(start);
+ if (binder.IsNull()) return Standard_False;
+ return binder->HasResult();
+}
+
+//=======================================================================
+//function : IsAlreadyUsed
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::IsAlreadyUsed(const Handle(Standard_Transient)& start) const
+{
+ Handle(Transfer_Binder) binder = Find(start);
+ if (binder.IsNull())
+ {
+ StartTrace(binder, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : IsAlreadyUsed, transfer not done cannot be used...");
+ }
+ return (binder->Status() == Transfer_StatusUsed);
+}
+
+//=======================================================================
+//function : FindAndMask
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::FindAndMask(const Handle(Standard_Transient)& start)
+{
+ if (thelastobj == start)
+ {
+ if (theindex > 0) return thelastbnd;
+ }
+ thelastobj = start;
+ theindex = themap.FindIndex(start);
+ if (theindex > 0) thelastbnd = themap.FindFromIndex(theindex);
+ else thelastbnd.Nullify();
+ return thelastbnd;
+}
+
+//=======================================================================
+//function : Bind
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::Bind(const Handle(Standard_Transient)& start,
+ const Handle(Transfer_Binder)& binder)
+{
+ if (binder.IsNull()) return;
+ Handle(Transfer_Binder) former = FindAndMask(start);
+ if (!former.IsNull())
+ {
+ // We admit VoidBinder: then we resume our Check
+ if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder))
+ {
+ binder->Merge(former);
+ themap(theindex) = binder;
+ }
+ else if (former->Status() == Transfer_StatusUsed)
+ {
+ StartTrace(former, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : Bind, already Bound");
+ }
+ else
+ {
+ if (thetrace > 2) StartTrace(former, start, thelevel, 5);
+ binder->CCheck()->GetMessages(former->Check());
+ }
+ }
+ if (theindex == 0 || thelastbnd.IsNull())
+ {
+ if (theindex == 0) theindex = themap.Add(start, binder);
+ else themap(theindex) = binder;
+ thelastbnd = binder;
+ }
+ else
+ {
+ thelastbnd = binder;
+ themap(theindex) = binder;
+ }
+}
+
+//=======================================================================
+//function : Rebind
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::Rebind(const Handle(Standard_Transient)& start,
+ const Handle(Transfer_Binder)& binder)
+{
+ Bind(start, binder);
+}
+
+//=======================================================================
+//function : Unbind
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::Unbind(const Handle(Standard_Transient)& start)
+{
+ Handle(Transfer_Binder) former = FindAndMask(start);
+ if (theindex == 0) return Standard_False;
+ if (former.IsNull()) return Standard_False;
+ if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) return Standard_True;
+ themap(theindex) = thelastbnd;
+ if (theroots.Contains(theindex))
+ {
+ TColStd_IndexedMapOfInteger aNewRoots;
+ for (Standard_Integer i = 1; i <= theroots.Extent(); i++)
+ if (theindex != theroots.FindKey(i))
+ aNewRoots.Add(theroots.FindKey(i));
+
+ theroots.Clear();
+ theroots = aNewRoots;
+ }
+
+ thelastobj.Nullify();
+ thelastbnd.Nullify();
+ theindex = 0;
+ return Standard_True;
+}
+
+//=======================================================================
+//function : FindElseBind
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::FindElseBind(const Handle(Standard_Transient)& start)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (!binder.IsNull()) return binder;
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ return binder;
+}
+
+//=======================================================================
+//function : SetMessenger
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SetMessenger(const Handle(Message_Messenger)& messenger)
+{
+ if (messenger.IsNull())
+ themessenger = Message::DefaultMessenger();
+ else
+ themessenger = messenger;
+}
+
+//=======================================================================
+//function : Messenger
+//purpose :
+//=======================================================================
+Handle(Message_Messenger) Transfer_ProcessForTransient::Messenger() const
+{
+ return themessenger;
+}
+
+//=======================================================================
+//function : SetTraceLevel
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SetTraceLevel(const Standard_Integer tracelev)
+{
+ thetrace = tracelev;
+}
+
+//=======================================================================
+//function : TraceLevel
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::TraceLevel() const
+{
+ return thetrace;
+}
+
+//=======================================================================
+//function : SendFail
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SendFail(const Handle(Standard_Transient)& start,
+ const Message_Msg& amsg)
+{
+ AddFail(start, amsg);
+}
+
+//=======================================================================
+//function : SendWarning
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SendWarning(const Handle(Standard_Transient)& start,
+ const Message_Msg& amsg)
+{
+ AddWarning(start, amsg);
+}
+
+//=======================================================================
+//function : SendMsg
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SendMsg(const Handle(Standard_Transient)& start,
+ const Message_Msg& amsg)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull())
+ {
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ }
+ // Feeds the trace: Causing rule (user messages)
+ if (thetrace > 0)
+ {
+ StartTrace(binder, start, thelevel, 6);
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+ aSender << amsg.Value();
+ if (amsg.IsEdited() && thetrace > 2)
+ aSender << " [from: " << amsg.Original() << "]";
+ aSender << std::endl;
+ }
+}
+
+//=======================================================================
+//function : AddFail
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::AddFail(const Handle(Standard_Transient)& start,
+ const Standard_CString mess,
+ const Standard_CString orig)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull())
+ {
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ }
+ binder->AddFail(mess, orig);
+ if (thetrace > 0)
+ {
+ StartTrace(binder, start, thelevel, 1);
+ Message_Messenger::StreamBuffer aSender = themessenger->SendFail();
+ aSender << " --> Fail : " << mess;
+ if (orig[0] != '\0' && thetrace > 2) aSender << " [from: " << orig << "]";
+ aSender << std::endl;
+ }
+}
+
+//=======================================================================
+//function : AddError
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::AddError(const Handle(Standard_Transient)& start,
+ const Standard_CString mess,
+ const Standard_CString orig)
+{
+ AddFail(start, mess, orig);
+}
+
+//=======================================================================
+//function : AddFail
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::AddFail(const Handle(Standard_Transient)& start,
+ const Message_Msg& amsg)
+{
+ if (amsg.IsEdited()) AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString(),
+ TCollection_AsciiString(amsg.Original()).ToCString());
+ else AddFail(start, TCollection_AsciiString(amsg.Value()).ToCString());
+}
+
+//=======================================================================
+//function : AddWarning
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::AddWarning(const Handle(Standard_Transient)& start,
+ const Standard_CString mess,
+ const Standard_CString orig)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull())
+ {
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder);
+ }
+ binder->AddWarning(mess, orig);
+ if (thetrace > 1)
+ {
+ StartTrace(binder, start, thelevel, 2);
+ Message_Messenger::StreamBuffer aSender = themessenger->SendWarning();
+ aSender << " --> Warning : " << mess;
+ if (orig[0] != '\0' && thetrace > 2) aSender << " [from: " << orig << "]";
+ aSender << std::endl;
+ }
+}
+
+//=======================================================================
+//function : AddWarning
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::AddWarning(const Handle(Standard_Transient)& start,
+ const Message_Msg& amsg)
+{
+ if (amsg.IsEdited()) AddWarning(start, TCollection_AsciiString(amsg.Value()).ToCString(),
+ TCollection_AsciiString(amsg.Original()).ToCString());
+ else AddWarning(start, TCollection_AsciiString(amsg.Value()).ToCString());
+}
+
+//=======================================================================
+//function : Mend
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::Mend(const Handle(Standard_Transient)& start,
+ const Standard_CString pref)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (binder.IsNull()) return;
+ Handle(Interface_Check) ach = binder->CCheck();
+ ach->Mend(pref);
+}
+
+//=======================================================================
+//function : Check
+//purpose :
+//=======================================================================
+Handle(Interface_Check) Transfer_ProcessForTransient::Check(const Handle(Standard_Transient)& start) const
+{
+ const Handle(Transfer_Binder)& binder = Find(start);
+ if (binder.IsNull())
+ {
+ Handle(Interface_Check) check;
+ return check;
+ }
+ return binder->Check();
+}
+
+//=======================================================================
+//function : BindTransient
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::BindTransient(const Handle(Standard_Transient)& start,
+ const Handle(Standard_Transient)& res)
+{
+ if (res.IsNull()) return;
+ Handle(Transfer_Binder) former = Find(start);
+ Handle(Transfer_SimpleBinderOfTransient) binder =
+ Handle(Transfer_SimpleBinderOfTransient)::DownCast(former);
+ if (!binder.IsNull())
+ {
+ if (binder->Status() == Transfer_StatusVoid)
+ {
+ binder->SetResult(res); return;
+ }
+ }
+ binder = new Transfer_SimpleBinderOfTransient;
+ binder->SetResult(res);
+ if (former.IsNull()) Bind(start, binder);
+ else Rebind(start, binder);
+}
+
+//=======================================================================
+//function : FindTransient
+//purpose :
+//=======================================================================
+const Handle(Standard_Transient)& Transfer_ProcessForTransient::FindTransient
+(const Handle(Standard_Transient)& start) const
+{
+ static const Handle(Standard_Transient) aDummy;
+ Handle(Transfer_SimpleBinderOfTransient) binder =
+ Handle(Transfer_SimpleBinderOfTransient)::DownCast(Find(start));
+ if (binder.IsNull()) return aDummy;
+ if (!binder->HasResult()) return aDummy;
+ return binder->Result();
+}
+
+//=======================================================================
+//function : BindMultiple
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::BindMultiple(const Handle(Standard_Transient)& start)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ if (!binder.IsNull())
+ {
+ if (!binder->IsKind(STANDARD_TYPE(Transfer_MultipleBinder)))
+ {
+ StartTrace(thelastbnd, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : BindMultiple");
+ }
+ }
+ else Bind(start, new Transfer_MultipleBinder);
+}
+
+//=======================================================================
+//function : AddMultiple
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::AddMultiple(const Handle(Standard_Transient)& start,
+ const Handle(Standard_Transient)& res)
+{
+ Handle(Transfer_Binder) binder = FindAndMask(start);
+ Handle(Transfer_MultipleBinder) multr =
+ Handle(Transfer_MultipleBinder)::DownCast(binder);
+ if (multr.IsNull())
+ {
+ StartTrace(binder, start, thelevel, 4);
+ if (binder.IsNull()) throw Transfer_TransferFailure("TransferProcess : AddMultiple, nothing bound");
+ else throw Transfer_TransferFailure("TransferProcess : AddMultiple, Binder not a MultipleBinder");
+ }
+ multr->AddResult(res);
+}
+
+//=======================================================================
+//function : FindTypedTransient
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::FindTypedTransient
+(const Handle(Standard_Transient)& start, const Handle(Standard_Type)& atype,
+ Handle(Standard_Transient)& val) const
+{
+ return GetTypedTransient(Find(start), atype, val);
+}
+
+//=======================================================================
+//function : GetTypedTransient
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::GetTypedTransient
+(const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype,
+ Handle(Standard_Transient)& val) const
+{
+ return Transfer_SimpleBinderOfTransient::GetTypedResult(binder, atype, val);
+}
+
+//=======================================================================
+//function : NbMapped
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::NbMapped() const
+{
+ return themap.Extent();
+}
+
+//=======================================================================
+//function : Mapped
+//purpose :
+//=======================================================================
+const Handle(Standard_Transient)& Transfer_ProcessForTransient::Mapped(const Standard_Integer num) const
+{
+ return themap.FindKey(num);
+}
+
+//=======================================================================
+//function : MapIndex
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::MapIndex(const Handle(Standard_Transient)& start) const
+{
+ return themap.FindIndex(start);
+}
+
+//=======================================================================
+//function : MapItem
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::MapItem(const Standard_Integer num) const
+{
+ Handle(Transfer_Binder) binder = themap.FindFromIndex(num);
+ return binder;
+}
+
+//=======================================================================
+//function : SetRoot
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SetRoot(const Handle(Standard_Transient)& start)
+{
+ Standard_Integer index = MapIndex(start);
+ if (index == 0)
+ {
+ return;
+ }
+
+ theroots.Add(index);
+ if (thetrace > 2) StartTrace(MapItem(index), start, thelevel, 3);
+}
+
+//=======================================================================
+//function : SetRootManagement
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SetRootManagement(const Standard_Boolean stat)
+{
+ therootm = stat;
+}
+
+//=======================================================================
+//function : NbRoots
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::NbRoots() const
+{
+ return theroots.Extent();
+}
+
+//=======================================================================
+//function : Root
+//purpose :
+//=======================================================================
+const Handle(Standard_Transient)& Transfer_ProcessForTransient::Root(const Standard_Integer num) const
+{
+ Standard_Integer ind = 0;
+ if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
+ return themap.FindKey(ind);
+}
+
+//=======================================================================
+//function : RootItem
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::RootItem(const Standard_Integer num) const
+{
+ Standard_Integer ind = 0;
+ if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
+ return themap.FindFromIndex(ind);
+}
+
+//=======================================================================
+//function : RootIndex
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::RootIndex(const Handle(Standard_Transient)& start) const
+{
+ Standard_Integer index = MapIndex(start);
+ if (index == 0) return 0;
+ return theroots.FindIndex(index);
+}
+
+//=======================================================================
+//function : NestingLevel
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::NestingLevel() const
+{
+ return thelevel;
+}
+
+//=======================================================================
+//function : ResetNestingLevel
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::ResetNestingLevel()
+{
+ thelevel = 0;
+}
+
+//=======================================================================
+//function : Recognize
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::Recognize(const Handle(Standard_Transient)& start) const
+{
+ Handle(Transfer_ActorOfProcessForTransient) actor = theactor;
+ // We scan the Next until we have a Result
+ while (!actor.IsNull())
+ {
+ if (actor->Recognize(start)) return Standard_True;
+ actor = actor->Next();
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : Transferring
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::Transferring(const Handle(Standard_Transient)& start,
+ const Message_ProgressRange& theProgress)
+{
+ Handle(Transfer_Binder) former = FindAndMask(start);
+ // We consider that this new Transfer request therefore corresponds to a
+ // additional use: note "AlreadyUsed", therefore non-modifiable result
+ if (!former.IsNull())
+ {
+ if (former->HasResult())
+ {
+ former->SetAlreadyUsed();
+ return former;
+ }
+
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+ Transfer_StatusExec statex = former->StatusExec();
+ switch (statex)
+ {
+ case Transfer_StatusInitial:
+ break;
+ case Transfer_StatusDone:
+ aSender << " .. and Transfer done" << std::endl;
+ return former;
+ case Transfer_StatusRun:
+ former->SetStatusExec(Transfer_StatusLoop);
+ return former;
+ case Transfer_StatusError:
+ if (thetrace)
+ {
+ aSender << " *** Transfer in Error Status :" << std::endl;
+ StartTrace(former, start, thelevel, 0);
+ }
+ else StartTrace(former, start, thelevel, 4);
+ throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status");
+ case Transfer_StatusLoop:
+ if (thetrace)
+ {
+ aSender << " *** Transfer Head of Dead Loop :" << std::endl;
+ StartTrace(former, start, thelevel, 0);
+ }
+ else StartTrace(former, start, thelevel, 4);
+ throw Transfer_TransferDeadLoop("TransferProcess : Transfer at Head of a Dead Loop");
+ }
+ former->SetStatusExec(Transfer_StatusRun);
+ }
+
+ Handle(Transfer_Binder) binder;
+ Standard_Boolean newbind = Standard_False;
+ if (theerrh)
+ {
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+
+ // Transfer under protection for exceptions (for notification in fact)
+ Standard_Integer oldlev = thelevel;
+ try
+ {
+ OCC_CATCH_SIGNALS
+ binder = TransferProduct(start, theProgress);
+ }
+
+ // Exceptions to catch up on: they are not all the same
+ catch (Transfer_TransferDeadLoop const&)
+ {
+ if (binder.IsNull())
+ {
+ aSender << " *** Dead Loop with no Result" << std::endl;
+ if (thetrace) StartTrace(binder, start, thelevel - 1, 0);
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder); newbind = Standard_True;
+ }
+ else if (binder->StatusExec() == Transfer_StatusLoop)
+ {
+ if (thetrace)
+ {
+ aSender << " *** Dead Loop : Finding head of Loop :" << std::endl;
+ StartTrace(binder, start, thelevel - 1, 0);
+ }
+ else StartTrace(binder, start, thelevel - 1, 4);
+ throw Transfer_TransferFailure("TransferProcess : Head of Dead Loop");
+ // In other words, we change the exception (we exit the loop)
+ }
+ else
+ {
+ if (thetrace)
+ {
+ aSender << " *** Dead Loop : Actor in Loop :" << std::endl;
+ StartTrace(binder, start, thelevel - 1, 0);
+ }
+ }
+ binder->AddFail("Transfer in dead Loop");
+ thelevel = oldlev;
+ }
+ catch (Standard_Failure const& anException)
+ {
+ if (binder.IsNull())
+ {
+ aSender << " *** Exception Raised with no Result" << std::endl;
+ binder = new Transfer_VoidBinder;
+ Bind(start, binder); newbind = Standard_True;
+ }
+ binder->AddFail("Transfer stopped by exception raising");
+ if (thetrace)
+ {
+ aSender << " *** Raised : " << anException.GetMessageString() << std::endl;
+ StartTrace(binder, start, thelevel - 1, 4);
+ }
+ thelevel = oldlev;
+ }
+ }
+
+ // Unprotected transfer (thus, dbx by hand in case of crash by Raise)
+ else binder = TransferProduct(start, theProgress);
+
+ if (theProgress.UserBreak())
+ return Handle(Transfer_Binder)();
+
+ if (!newbind && !binder.IsNull())
+ {
+ if (former.IsNull())
+ {
+ if (!IsBound(start)) Bind(start, binder);
+ else
+ {
+ Rebind(start, binder);
+ }
+ }
+ else Rebind(start, binder);
+ }
+ else
+ {
+ if (!former.IsNull()) former->SetStatusExec(Transfer_StatusDone); //+
+ return Handle(Transfer_Binder)(); // Binder Null ... que faire d autre ?
+ }
+
+ if (therootl >= thelevel)
+ {
+ therootl = 0;
+ if (therootm && binder->Status() != Transfer_StatusVoid)
+ {
+ SetRoot(start);
+ }
+ }
+ return thelastbnd;
+}
+
+
+//=======================================================================
+//function : TransferProduct
+//purpose :
+//=======================================================================
+Handle(Transfer_Binder) Transfer_ProcessForTransient::TransferProduct
+(const Handle(Standard_Transient)& start,
+ const Message_ProgressRange& theProgress)
+{
+ thelevel++;
+ Handle(Transfer_Binder) binder;
+ Handle(Transfer_ActorOfProcessForTransient) actor = theactor;
+
+ // We scan the Next until we have a Result
+ Message_ProgressScope aScope(theProgress, NULL, 1, true);
+ while (!actor.IsNull())
+ {
+ if (actor->Recognize(start)) binder = actor->Transferring(start, this, aScope.Next());
+ else binder.Nullify();
+ if (!binder.IsNull()) break;
+ actor = actor->Next();
+ }
+ if (aScope.UserBreak())
+ return Handle(Transfer_Binder)();
+
+ if (binder.IsNull())
+ {
+ if (thelevel > 0) thelevel--;
+ return binder;
+ }
+ if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone)
+ therootl = thelevel - 1;
+
+ if (thelevel > 0) thelevel--;
+ return binder;
+}
+
+//=======================================================================
+//function : Transfer
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::Transfer(const Handle(Standard_Transient)& start,
+ const Message_ProgressRange& theProgress)
+{
+ Handle(Transfer_Binder) binder = Transferring(start, theProgress);
+ return (!binder.IsNull());
+}
+
+//=======================================================================
+//function : SetErrorHandle
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::SetErrorHandle(const Standard_Boolean err)
+{
+ theerrh = err;
+}
+
+//=======================================================================
+//function : ErrorHandle
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::ErrorHandle() const
+{
+ return theerrh;
+}
+
+//=======================================================================
+//function : StartTrace
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::StartTrace(const Handle(Transfer_Binder)& binder,
+ const Handle(Standard_Transient)& start,
+ const Standard_Integer level,
+ const Standard_Integer mode) const
+{
+ Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
+ // ### Fail (Roots:50) -- Start start->DynamicType()
+ // ### Fail (Roots:50) -- Start id:#label.. Type:start->DynamicType()
+ if (thetrace > 3)
+ { // Internal to be switch when searching bug (trace >= 4)
+ if (mode == 1) aSender << " ### Fail";
+ if (mode == 2) aSender << " ### Warning";
+ if (mode == 3) aSender << " ### New Root n0 " << theroots.Extent();
+ if (mode == 4) aSender << " ### Exception";
+ if (mode == 5) aSender << " ### Substitution";
+ if (mode == 6) aSender << " ### Information";
+ if (level > 1)
+ aSender << " (nested)";
+ if (mode >= 0 && mode != 3)
+ aSender << " at " << theroots.Extent() << " Roots";
+ }
+ if (!start.IsNull()) PrintTrace(start, aSender);
+
+ if (!binder.IsNull())
+ {
+ Handle(Transfer_Binder) bnd = binder;
+ Standard_Boolean hasres = Standard_False;
+ while (!bnd.IsNull())
+ {
+ if (bnd->Status() != Transfer_StatusVoid)
+ {
+ if (!hasres)
+ aSender << "\n --- Result Type : ";
+ else
+ aSender << " , ";
+ aSender << bnd->ResultTypeName();
+ hasres = Standard_True;
+ }
+ bnd = bnd->NextResult();
+ }
+ if (!hasres && mode > 2)
+ {
+ aSender << "\n --- No Result recorded";
+ }
+ }
+ aSender << std::endl;
+}
+
+//=======================================================================
+//function : PrintTrace
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::PrintTrace(const Handle(Standard_Transient)& start, Standard_OStream& S) const
+{
+ if (!start.IsNull()) S << " Type:" << start->DynamicType()->Name();
+}
+
+//=======================================================================
+//function : IsLooping
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::IsLooping
+(const Standard_Integer alevel) const
+{
+ return alevel > NbMapped();
+}
+
+//=======================================================================
+//function : RootResult
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::RootResult(const Standard_Boolean withstart) const
+{
+ Transfer_IteratorOfProcessForTransient iter(withstart);
+ Standard_Integer max = theroots.Extent();
+ for (Standard_Integer j = 1; j <= max; j++)
+ {
+ Standard_Integer i = theroots.FindKey(j);
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ if (withstart) iter.Add(binder, Mapped(i));
+ else iter.Add(binder);
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : CompleteResult
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::CompleteResult
+(const Standard_Boolean withstart) const
+{
+ Transfer_IteratorOfProcessForTransient iter(withstart);
+ Standard_Integer max = NbMapped();
+ for (Standard_Integer i = 1; i <= max; i++)
+ {
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ if (withstart) iter.Add(binder, Mapped(i));
+ else iter.Add(binder);
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : AbnormalResult
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::AbnormalResult() const
+{
+ Transfer_IteratorOfProcessForTransient iter(Standard_True);
+ Standard_Integer max = NbMapped();
+ for (Standard_Integer i = 1; i <= max; i++)
+ {
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ Transfer_StatusExec statex = binder->StatusExec();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
+ iter.Add(binder, Mapped(i));
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : CheckList
+//purpose :
+//=======================================================================
+Interface_CheckIterator Transfer_ProcessForTransient::CheckList
+(const Standard_Boolean erronly) const
+{
+ Interface_CheckIterator list;
+ Standard_Integer num, max = NbMapped();
+ for (Standard_Integer i = 1; i <= max; i++)
+ {
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ Transfer_StatusExec statex = binder->StatusExec();
+ Handle(Interface_Check) check = binder->Check();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
+ !check->HasFailed())
+ check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
+ if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
+ const Handle(Standard_Transient)& ent = Mapped(i);
+ num = CheckNum(ent);
+ if (num == 0) num = i;
+ check->SetEntity(ent);
+ list.Add(check, num);
+ }
+ return list;
+}
+
+//=======================================================================
+//function : ResultOne
+//purpose :
+//=======================================================================
+Transfer_IteratorOfProcessForTransient Transfer_ProcessForTransient::ResultOne(const Handle(Standard_Transient)& start,
+ const Standard_Integer level,
+ const Standard_Boolean withstart) const
+{
+ Transfer_IteratorOfProcessForTransient iter(withstart);
+ Standard_Integer max = NbMapped();
+ Standard_Integer ind = MapIndex(start);
+ if (ind == 0) return iter;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ for (Standard_Integer i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(i);
+ if (binder.IsNull()) continue;
+ if (withstart) iter.Add(binder, Mapped(ind));
+ else iter.Add(binder);
+ }
+ return iter;
+}
+
+//=======================================================================
+//function : CheckListOne
+//purpose :
+//=======================================================================
+Interface_CheckIterator Transfer_ProcessForTransient::CheckListOne
+(const Handle(Standard_Transient)& start, const Standard_Integer level,
+ const Standard_Boolean erronly) const
+{
+ Interface_CheckIterator list;
+ Standard_Integer max = NbMapped();
+ Standard_Integer num, ind = MapIndex(start);
+ if (ind == 0) return list;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ for (Standard_Integer i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(ind);
+ if (binder.IsNull()) continue;
+ Transfer_StatusExec statex = binder->StatusExec();
+ Handle(Interface_Check) check = binder->Check();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
+ !check->HasFailed())
+ check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
+ if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
+ const Handle(Standard_Transient)& ent = Mapped(ind);
+ num = CheckNum(ent); if (num == 0) num = ind;
+ check->SetEntity(ent);
+ list.Add(check, num);
+ }
+ return list;
+}
+
+//=======================================================================
+//function : IsCheckListEmpty
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_ProcessForTransient::IsCheckListEmpty
+(const Handle(Standard_Transient)& start, const Standard_Integer level,
+ const Standard_Boolean erronly) const
+{
+ Standard_Integer max = NbMapped();
+ Standard_Integer ind = MapIndex(start);
+ if (ind == 0) return Standard_False;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ for (Standard_Integer i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(ind);
+ if (binder.IsNull()) continue;
+
+ Transfer_StatusExec statex = binder->StatusExec();
+ Handle(Interface_Check) check = binder->Check();
+ if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
+ return Standard_False;
+ if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : RemoveResult
+//purpose :
+//=======================================================================
+void Transfer_ProcessForTransient::RemoveResult(const Handle(Standard_Transient)& start,
+ const Standard_Integer level,
+ const Standard_Boolean /*compute*/)
+{
+ //if (compute) ComputeScopes();
+ Standard_Integer max = NbMapped();
+ Standard_Integer ind = MapIndex(start);
+ if (ind == 0) return;
+ Standard_Integer i1 = (level == 0 ? ind : 1);
+ Standard_Integer i2 = (level == 0 ? ind : max);
+ Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger(i1, i2, 0);
+
+ Standard_Integer i;
+ for (i = i1; i <= i2; i++)
+ {
+ ind = map->Value(i);
+ if (ind == 0) continue;
+ Handle(Transfer_Binder) binder = MapItem(ind);
+ if (binder.IsNull()) continue;
+ }
+}
+
+//=======================================================================
+//function : CheckNum
+//purpose :
+//=======================================================================
+Standard_Integer Transfer_ProcessForTransient::CheckNum(const Handle(Standard_Transient)&) const
+{
+ return 0;
+}
-#define TheStart Handle(Standard_Transient)
-#define TheStart_hxx <Standard_Transient.hxx>
-#define TheMapHasher TColStd_MapTransientHasher
-#define TheMapHasher_hxx <TColStd_MapTransientHasher.hxx>
-#define Handle_TheList Handle(TColStd_HSequenceOfTransient)
-#define TheList TColStd_HSequenceOfTransient
-#define TheList_hxx <TColStd_HSequenceOfTransient.hxx>
-#define Transfer_TransferMap Transfer_TransferMapOfProcessForTransient
-#define Transfer_TransferMap_hxx <Transfer_TransferMapOfProcessForTransient.hxx>
-#define Transfer_Iterator Transfer_IteratorOfProcessForTransient
-#define Transfer_Iterator_hxx <Transfer_IteratorOfProcessForTransient.hxx>
-#define Transfer_Actor Transfer_ActorOfProcessForTransient
-#define Transfer_Actor_hxx <Transfer_ActorOfProcessForTransient.hxx>
-#define Handle_Transfer_Actor Handle(Transfer_ActorOfProcessForTransient)
-#define Transfer_TransferProcess Transfer_ProcessForTransient
-#define Transfer_TransferProcess_hxx <Transfer_ProcessForTransient.hxx>
-#define Handle_Transfer_TransferProcess Handle(Transfer_ProcessForTransient)
-#include <Transfer_TransferProcess.gxx>
#define _Transfer_TransferMapOfProcessForTransient_HeaderFile
#include <NCollection_IndexedDataMap.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <Transfer_Binder.hxx>
-typedef NCollection_IndexedDataMap<Handle(Standard_Transient),Handle(Transfer_Binder),TColStd_MapTransientHasher> Transfer_TransferMapOfProcessForTransient;
+typedef NCollection_IndexedDataMap<Handle(Standard_Transient),Handle(Transfer_Binder)> Transfer_TransferMapOfProcessForTransient;
#endif // _Transfer_TransferMapOfProcessForTransient_HeaderFile
+++ /dev/null
-// Copyright (c) 1999-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.
-
-// DCE 21.01.99 S3767 Display original messages only
-// if the level is greater than 2
-
-//#include <Transfer_TransferProcess.ixx>
-// Class generique
-
-// TheStart est suppose Handle(Standard_Transient) ou (Transfer_Finder)
-// Il doit offrir : "==" , .IsNull() , ->DynamicType()
-
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-
-#include <Message_Messenger.hxx>
-#include <Message_Msg.hxx>
-#include <Message.hxx>
-#include <Message_ProgressScope.hxx>
-
-#include <Transfer_VoidBinder.hxx>
-#include <Transfer_SimpleBinderOfTransient.hxx>
-#include <Transfer_MultipleBinder.hxx>
-#include <Transfer_StatusResult.hxx>
-#include <Transfer_TransferFailure.hxx>
-#include <Transfer_TransferDeadLoop.hxx>
-
-#include <TCollection_HAsciiString.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <TColStd_HArray1OfInteger.hxx>
-
-
-//#define TRANSLOG // debug
-
-static Handle(Standard_Transient) nultrans; // pour retour const&(Null) ...
-static Handle(Transfer_Binder) nulbinder;
-
-
-//=======================================================================
-//function : Transfer_TransferProcess
-//purpose :
-//=======================================================================
-
-Transfer_TransferProcess::Transfer_TransferProcess (const Standard_Integer nb)
- : themap (nb)
-{
- theerrh = Standard_True;
- therootm = Standard_False;
- thelevel = 0; therootl = 0;
- themessenger = Message::DefaultMessenger();
- thetrace = 0;
-// theroots = new TColStd_HSequenceOfInteger ();
- theindex = 0;
-}
-
-
-//=======================================================================
-//function : Transfer_TransferProcess
-//purpose :
-//=======================================================================
-
-Transfer_TransferProcess::Transfer_TransferProcess(const Handle(Message_Messenger)& messenger,
- const Standard_Integer nb)
- : themap (nb)
-{
- theerrh = Standard_True;
- therootm = Standard_False;
- thelevel = 0; therootl = 0;
- SetMessenger (messenger);
- thetrace = 1;
-// theroots = new TColStd_HSequenceOfInteger ();
- theindex = 0;
-}
-
- void Transfer_TransferProcess::Clear ()
-{
- thelevel = 0; therootl = 0;
- theroots.Clear();
- themap.Clear();
- theindex = 0; thelastobj.Nullify(); thelastbnd.Nullify();
-}
-
- void Transfer_TransferProcess::Clean ()
-{
- Standard_Integer i, nb = NbMapped();
- Standard_Integer j,unb = 0;
- for (i = 1; i <= nb; i ++) {
- if (themap(i).IsNull()) unb ++;
- }
- if (unb == 0) return;
-
-// Refaire la map -> decalages
- TColStd_Array1OfInteger unbs (1,nb); unbs.Init(0);
- Transfer_TransferMap newmap (nb*2);
- for (i = 1; i <= nb; i ++) {
- TheStart ent = Mapped(i);
- Handle(Transfer_Binder) bnd = MapItem(i);
- if (bnd.IsNull()) continue;
- j = newmap.Add (ent,bnd);
- unbs.SetValue (i,j);
- }
- themap.Assign (newmap);
-
- // Update La liste des racines
- TColStd_IndexedMapOfInteger aNewRoots;
- for( i=1; i<= theroots.Extent(); i++ ) {
- j = theroots.FindKey(i);
- Standard_Integer k = unbs.Value(j);
- if ( k ) aNewRoots.Add ( k );
- }
- theroots.Clear();
- theroots = aNewRoots;
-
-// Le reste : nettoyage
- thelastobj.Nullify();
- thelastbnd.Nullify();
- theindex = 0;
-}
-
-
-//=======================================================================
-//function : Resize
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::Resize (const Standard_Integer nb)
-{
- if (nb > themap.NbBuckets()) themap.ReSize(nb);
-}
-
-
-//=======================================================================
-//function : SetActor
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SetActor(const Handle(Transfer_Actor)& actor)
-{
- if (theactor == actor) return;
- if (theactor.IsNull()) theactor = actor;
- else if (actor.IsNull()) theactor = actor; // declenche RAZ
- else if (theactor->IsLast()) { actor->SetNext(theactor); theactor = actor; }
- else theactor->SetNext(actor);
-}
-
-
-//=======================================================================
-//function : Actor
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Actor) Transfer_TransferProcess::Actor () const
-{
- return theactor;
-}
-
-
-// ########################################################################
-// .... MAPPING ....
-
-// ## ## ## Actions Generales sur Binders ## ## ##
-// ## ## ## Consultations ## ## ##
-
-
-// ## ## Find ## ##
-
-//=======================================================================
-//function : Find
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Binder) Transfer_TransferProcess::Find (const TheStart& start) const
-// const Standard_Integer categ) const
-{
- if (thelastobj == start) {
- //if (theindex > 0) return thelastbnd->Search(categ); //skl
- if (theindex > 0) return thelastbnd; //skl
- }
- Standard_Integer index = themap.FindIndex (start);
- if (index > 0) {
- const Handle(Transfer_Binder)& binder = themap.FindFromIndex(index);
- //if (binder.IsNull()) //skl
- return binder;
- //return binder->Search(categ); //skl
- }
- return nulbinder;
-}
-
-// ## ## IsBound ## ##
-
-//=======================================================================
-//function : IsBound
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::IsBound(const TheStart& start) const
-// const Standard_Integer categ) const
-{
- Handle(Transfer_Binder) binder = Find(start); //,categ); skl
- if (binder.IsNull()) return Standard_False;
- return binder->HasResult();
-}
-
-// ## ## IsAlreadyUsed ## ##
-
-//=======================================================================
-//function : IsAlreadyUsed
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::IsAlreadyUsed(const TheStart& start) const
-// const Standard_Integer categ) const
-{
- Handle(Transfer_Binder) binder = Find(start); //,categ); skl
- if (binder.IsNull()) {
- StartTrace (binder,start,thelevel,4);
- throw Transfer_TransferFailure("TransferProcess : IsAlreadyUsed, transfer not done cannot be used...");
- }
- return (binder->Status() == Transfer_StatusUsed);
-}
-
-
-// ## ## FindAndMask (private) ## ##
-
-//=======================================================================
-//function : FindAndMask
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Binder) Transfer_TransferProcess::FindAndMask(const TheStart& start)
-// const Standard_Integer categ)
-{
- if (thelastobj == start) {
- if (theindex > 0) return thelastbnd; //skl ->Search(categ);
- }
- thelastobj = start;
- theindex = themap.FindIndex (start);
- if (theindex > 0) thelastbnd = themap.FindFromIndex(theindex);
- else thelastbnd.Nullify();
- //if (thelastbnd.IsNull()) skl
- return thelastbnd;
- //return thelastbnd->Search(categ); //skl
-}
-
-
-// ## ## ## Modifications ## ## ##
-
-
-//=======================================================================
-//function : Bind
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::Bind (const TheStart& start,
- const Handle(Transfer_Binder)& binder)
-// const Standard_Integer categ)
-{
- if (binder.IsNull()) return;
- Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl
- if (!former.IsNull()) {
-// On admet VoidBinder : alors on reprend son Check
- if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) {
- binder->Merge(former);
- //binder->SetCategory(categ); //skl
- themap(theindex) = binder; // Substitution
- }
- else if (former->Status() == Transfer_StatusUsed) {
- StartTrace (former,start,thelevel,4);
- throw Transfer_TransferFailure("TransferProcess : Bind, already Bound");
- }
- else {
- if (thetrace > 2) StartTrace (former,start,thelevel,5);
- binder->CCheck()->GetMessages (former->Check());
- }
- }
- //binder->SetCategory(categ); //skl
- if (theindex == 0 || thelastbnd.IsNull()) {
- if (theindex == 0) theindex = themap.Add(start,binder); // Nouveau
- else themap(theindex) = binder; // idem en fait
- thelastbnd = binder;
- }
- else { //skl
- //binder->AddResult(thelastbnd);
- thelastbnd = binder;
- themap(theindex) = binder;
- }
-/*skl else if (thelastbnd->Category() == categ) { // Substitue cette categorie
- binder->Next(Standard_False)->SetNext(thelastbnd->Next(Standard_True),Standard_True);
- thelastbnd = binder;
- themap(theindex) = binder;
- } else {
- thelastbnd->AddNext (binder,categ,Standard_True);
- } */
-}
-
-
-//=======================================================================
-//function : Rebind
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::Rebind (const TheStart& start,
- const Handle(Transfer_Binder)& binder)
-// const Standard_Integer categ)
-{
- Bind(start,binder); //,categ);skl
- // entre les deux, les differences allaient s amenuisant
- // au debut, on criait si pas encore Bound (idiot)
- // ne restait plus comme difference que le test StatusUsed sur Rebind,
- // tandis que Bind refusait des lors qu il y avait un resultat
- // -> a present, Bind s aligne sur Rebind
-}
-
-
-//=======================================================================
-//function : Unbind
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::Unbind(const TheStart& start)
-// const Standard_Integer categ)
-{
- Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl
- if (theindex == 0) return Standard_False;
- if (former.IsNull()) return Standard_False;
- if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) return Standard_True;
- //const Interface_Check& ach = thelastbnd->Check();
- //Handle(Transfer_Binder) newbinder = thelastbnd->RemoveNext(categ);skl
- //if (newbinder != thelastbnd)skl
- themap(theindex) = thelastbnd;// = newbinder;skl
- if(theroots.Contains(theindex)) {
- TColStd_IndexedMapOfInteger aNewRoots;
- for(Standard_Integer i = 1; i <= theroots.Extent(); i++)
- if(theindex!= theroots.FindKey(i))
- aNewRoots.Add(theroots.FindKey(i));
-
- theroots.Clear();
- theroots = aNewRoots;
- }
-
- thelastobj.Nullify();
- thelastbnd.Nullify();
- theindex = 0;
- return Standard_True;
-}
-
-
-//=======================================================================
-//function : FindElseBind
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Binder) Transfer_TransferProcess::FindElseBind(const TheStart& start)
-// const Standard_Integer categ)
-{
- Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl
- if (!binder.IsNull()) return binder;
- binder = new Transfer_VoidBinder;
- Bind(start,binder);//,categ);skl
- return binder;
-}
-
-
-// ## ## ## Messages associes ## ## ##
-
-//=======================================================================
-//function : SetMessenger
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SetMessenger (const Handle(Message_Messenger)& messenger)
-{
- if ( messenger.IsNull() )
- themessenger = Message::DefaultMessenger();
- else
- themessenger = messenger;
-}
-
-//=======================================================================
-//function : Messenger
-//purpose :
-//=======================================================================
-
-Handle(Message_Messenger) Transfer_TransferProcess::Messenger () const
-{
- return themessenger;
-}
-
-//=======================================================================
-//function : SetTraceLevel
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SetTraceLevel (const Standard_Integer tracelev)
-{
- thetrace = tracelev;
-}
-
-//=======================================================================
-//function : TraceLevel
-//purpose :
-//=======================================================================
-
-Standard_Integer Transfer_TransferProcess::TraceLevel () const
-{
- return thetrace;
-}
-
-//=======================================================================
-//function : SendFail
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SendFail(const TheStart& start,
- const Message_Msg& amsg)
-{
- AddFail(start,amsg);
-}
-
-
-//=======================================================================
-//function : SendWarning
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SendWarning(const TheStart& start,
- const Message_Msg& amsg)
-{
- AddWarning(start,amsg);
-}
-
-
-//=======================================================================
-//function : SendMsg
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SendMsg(const TheStart& start,
- const Message_Msg& amsg)
-{
- Handle(Transfer_Binder) binder = FindAndMask(start);
- if (binder.IsNull()) {
- binder = new Transfer_VoidBinder;
- Bind (start,binder);
- }
- // Alimente la trace : Regle causant (user messages)
- if (thetrace > 0) {
- StartTrace (binder,start,thelevel,6);
- Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
- aSender << amsg.Value();
- if (amsg.IsEdited()&&thetrace>2)
- aSender << " [from: " << amsg.Original() << "]";
- aSender << std::endl;
- }
-}
-
-
-//=======================================================================
-//function : AddFail
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::AddFail(const TheStart& start,
- const Standard_CString mess,
- const Standard_CString orig)
-{
- Handle(Transfer_Binder) binder = FindAndMask(start);
- if (binder.IsNull()) {
- binder = new Transfer_VoidBinder;
- Bind (start,binder);
- }
- binder->AddFail (mess,orig);
- if (thetrace > 0) {
- StartTrace (binder,start,thelevel,1);
- Message_Messenger::StreamBuffer aSender = themessenger->SendFail();
- aSender << " --> Fail : " << mess;
- if (orig[0] != '\0'&&thetrace>2) aSender << " [from: " << orig << "]";
- aSender << std::endl;
- }
-}
-
-
-//=======================================================================
-//function : AddError
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::AddError(const TheStart& start,
- const Standard_CString mess,
- const Standard_CString orig)
-{
- AddFail (start,mess,orig);
-}
-
-
-//=======================================================================
-//function : AddFail
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::AddFail(const TheStart& start,
- const Message_Msg& amsg)
-{
- if (amsg.IsEdited()) AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString(),
- TCollection_AsciiString(amsg.Original()).ToCString());
- else AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString());
-}
-
-
-//=======================================================================
-//function : AddWarning
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::AddWarning(const TheStart& start,
- const Standard_CString mess,
- const Standard_CString orig)
-{
- Handle(Transfer_Binder) binder = FindAndMask(start);
- if (binder.IsNull()) {
- binder = new Transfer_VoidBinder;
- Bind (start,binder);
- }
- binder->AddWarning(mess,orig);
- if (thetrace > 1) {
- StartTrace (binder,start,thelevel,2);
- Message_Messenger::StreamBuffer aSender = themessenger->SendWarning();
- aSender << " --> Warning : " << mess;
- if (orig[0] != '\0'&&thetrace>2) aSender << " [from: " << orig << "]";
- aSender << std::endl;
- }
-}
-
-
-//=======================================================================
-//function : AddWarning
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::AddWarning(const TheStart& start,
- const Message_Msg& amsg)
-{
- if (amsg.IsEdited()) AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString(),
- TCollection_AsciiString(amsg.Original()).ToCString());
- else AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString());
-}
-
-
-//=======================================================================
-//function : Mend
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::Mend(const TheStart& start,
- const Standard_CString pref)
-{
- Handle(Transfer_Binder) binder = FindAndMask(start);
- if (binder.IsNull()) return; // rien a faire ...
- Handle(Interface_Check) ach = binder->CCheck();
- ach->Mend (pref);
-}
-
-
-//=======================================================================
-//function : Check
-//purpose :
-//=======================================================================
-
-Handle(Interface_Check) Transfer_TransferProcess::Check(const TheStart& start) const
-{
- const Handle(Transfer_Binder)& binder = Find(start);
- if (binder.IsNull()) {
- Handle(Interface_Check) check;
- return check;
- }
- return binder->Check();
-}
-
-/*skl
-void Transfer_TransferProcess::AddCaseName(const TheStart& start,
- const Standard_CString casename)
-{
- AddCaseValue (start, new TCollection_HAsciiString (casename));
-}
-
-
-void Transfer_TransferProcess::AddCaseValue(const TheStart& start,
- const Handle(Standard_Transient)& caseval)
-{
- Handle(Transfer_Binder) binder = FindAndMask(start);
- if (binder.IsNull()) {
- binder = new Transfer_VoidBinder;
- Bind (start,binder);
- }
- binder->AddCaseValue (caseval);
-}
-
-
-Handle(TColStd_HSequenceOfTransient) Transfer_TransferProcess::CaseList
- (const TheStart& start) const
-{
- Handle(TColStd_HSequenceOfTransient) list;
- const Handle(Transfer_Binder)& binder = Find(start);
- if (binder.IsNull()) return list;
- return binder->CaseList();
-}
-
-Standard_Integer Transfer_TransferProcess::NextItemWithAttribute
- (const Standard_CString name, const Standard_Integer num0) const
-{
- Standard_Integer num, nb = NbMapped();
- for (num = num0+1; num <= nb; num ++) {
- Handle(Transfer_Binder) bnd = MapItem (num);
- if (bnd.IsNull()) continue;
- if (!bnd->Attribute(name).IsNull()) return num;
- }
- return 0;
-}
-
-
-Interface_ParamType Transfer_TransferProcess::AttributeType
- (const Standard_CString name) const
-{
- Interface_ParamType aty, res = Interface_ParamVoid;
- Standard_Integer num, nb = NbMapped();
- for (num = 1; num <= nb; num ++) {
- Handle(Transfer_Binder) bnd = MapItem (num);
- if (bnd.IsNull()) continue;
- aty = bnd->AttributeType(name);
- if (aty == Interface_ParamVoid) continue;
- if (res == Interface_ParamVoid) res = aty;
- else if (res != aty) return Interface_ParamMisc;
- }
- return res;
-}
-
-Handle(Dico_DictionaryOfInteger) Transfer_TransferProcess::Attributes
- (const Standard_CString rootname) const
-{
- Handle(Dico_DictionaryOfInteger) list = new Dico_DictionaryOfInteger;
- Standard_Integer num, nb = NbMapped();
- for (num = 1; num <= nb; num ++) {
- Handle(Transfer_Binder) bnd = MapItem (num);
- if (bnd.IsNull()) continue;
- Handle(Dico_DictionaryOfTransient) atr = bnd->AttrList();
- if (atr.IsNull()) continue;
- Dico_IteratorOfDictionaryOfTransient iatr(atr,rootname);
- for (; iatr.More(); iatr.Next()) {
- TCollection_AsciiString name = iatr.Name();
- Standard_Boolean deja;
- Standard_Integer& nbval = list->NewItem (name.ToCString(),deja);
- if (!deja) nbval = 0;
- nbval ++;
- }
-
- }
- return list;
-}
-skl*/
-
-
-// ## ## ## Actions sur Types Privilegies ## ## ##
-// ## ## ## (Transient) ## ## ##
-
-// Bind associe un objet a un objet resultat; or la Map associe un Objet a un
-// Binder (qui designe son resultat)
-// *Transient travaillent avec un SimpleBinderOfTransient
-// si deja la, on considere son resultat
-// sinon, on cree un Binder du bon type
-
-
-//=======================================================================
-//function : BindTransient
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::BindTransient(const TheStart& start,
- const Handle(Standard_Transient)& res)
-// const Standard_Integer categ)
-{
- if (res.IsNull()) return;
- Handle(Transfer_Binder) former = Find(start);//,categ);skl
- Handle(Transfer_SimpleBinderOfTransient) binder =
- Handle(Transfer_SimpleBinderOfTransient)::DownCast(former);
-// Binding sur place ?
- if (!binder.IsNull()) {
- if (binder->Status() == Transfer_StatusVoid) { binder->SetResult(res); return; }
- }
-// Sinon, refaire
- binder = new Transfer_SimpleBinderOfTransient;
- binder->SetResult (res);
- if (former.IsNull()) Bind(start,binder);//,categ);skl
- else Rebind(start,binder);//,categ);skl
-}
-
-
-//=======================================================================
-//function : FindTransient
-//purpose :
-//=======================================================================
-
-const Handle(Standard_Transient)& Transfer_TransferProcess::FindTransient
- (const TheStart& start) const
-{
- Handle(Transfer_SimpleBinderOfTransient) binder =
- Handle(Transfer_SimpleBinderOfTransient)::DownCast(Find(start));
- if (binder.IsNull()) return nultrans;
- if (!binder->HasResult()) return nultrans;
- return binder->Result();
-}
-
-
-// Binding Multiple : D abord le declarer par BindMultiple (si pas deja fait)
-// Puis ajouter les termes par AddMultiple
-
-//=======================================================================
-//function : BindMultiple
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::BindMultiple(const TheStart& start)
-// const Standard_Integer categ)
-{
- Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl
- if (!binder.IsNull()) {
- if (!binder->IsKind(STANDARD_TYPE(Transfer_MultipleBinder))) {
- StartTrace (thelastbnd,start,thelevel,4);
- throw Transfer_TransferFailure("TransferProcess : BindMultiple");
- }
- }
- else Bind(start,new Transfer_MultipleBinder);//,categ);skl
-}
-
-
-//=======================================================================
-//function : AddMultiple
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::AddMultiple(const TheStart& start,
- const Handle(Standard_Transient)& res)
-// const Standard_Integer categ)
-{
- Handle(Transfer_Binder) binder = FindAndMask(start);//,categ);skl
- Handle(Transfer_MultipleBinder) multr =
- Handle(Transfer_MultipleBinder)::DownCast(binder);
- if (multr.IsNull()) {
- StartTrace (binder,start,thelevel,4);
- if (binder.IsNull()) throw Transfer_TransferFailure("TransferProcess : AddMultiple, nothing bound");
- else throw Transfer_TransferFailure("TransferProcess : AddMultiple, Binder not a MultipleBinder");
- }
- multr->AddResult(res);
-}
-
-
-//=======================================================================
-//function : FindTypedTransient
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::FindTypedTransient
- (const TheStart& start, const Handle(Standard_Type)& atype,
- Handle(Standard_Transient)& val) const
-{
- return GetTypedTransient (Find(start),atype,val);
-}
-
-
-//=======================================================================
-//function : GetTypedTransient
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::GetTypedTransient
- (const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype,
- Handle(Standard_Transient)& val) const
-{
- return Transfer_SimpleBinderOfTransient::GetTypedResult(binder,atype,val);
-}
-
-
-// ## ## ## ## ## Acces Atomique ## ## ## ## ##
-// (ne gere pas le scope mais donne acces aux categories)
-
-//=======================================================================
-//function : NbMapped
-//purpose :
-//=======================================================================
-
-Standard_Integer Transfer_TransferProcess::NbMapped () const
-{
- return themap.Extent();
-}
-
-
-//=======================================================================
-//function : Mapped
-//purpose :
-//=======================================================================
-
-const TheStart& Transfer_TransferProcess::Mapped(const Standard_Integer num) const
-{
- return themap.FindKey(num);
-}
-
-
-//=======================================================================
-//function : MapIndex
-//purpose :
-//=======================================================================
-
-Standard_Integer Transfer_TransferProcess::MapIndex(const TheStart& start) const
-{
- return themap.FindIndex(start);
-}
-
-
-//=======================================================================
-//function : MapItem
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Binder) Transfer_TransferProcess::MapItem(const Standard_Integer num) const
-// const Standard_Integer categ) const
-{
- Handle(Transfer_Binder) binder = themap.FindFromIndex(num);
- //sklif (binder.IsNull())
- return binder;
- //sklreturn binder->Search (categ);
-}
-
-
-// ########################################################################
-// .... ROOT MANAGEMENT ....
-
-//=======================================================================
-//function : SetRoot
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SetRoot (const TheStart& start)
-{
- Standard_Integer index = MapIndex(start);
- if (index == 0) {
- //StartTrace (thelastbnd,start,thelevel,4);
- //throw Transfer_TransferFailure("TransferProcess : SetRoot");
- return;
- }
-
- theroots.Add(index);
- if (thetrace > 2) StartTrace (MapItem(index),start,thelevel,3);
-}
-
-
-//=======================================================================
-//function : SetRootManagement
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SetRootManagement(const Standard_Boolean stat)
-{
- therootm = stat;
-}
-
-
-//=======================================================================
-//function : NbRoots
-//purpose :
-//=======================================================================
-
-Standard_Integer Transfer_TransferProcess::NbRoots () const
-{
- return theroots.Extent();
-}
-
-
-//=======================================================================
-//function : Root
-//purpose :
-//=======================================================================
-
-const TheStart& Transfer_TransferProcess::Root(const Standard_Integer num) const
-{
- Standard_Integer ind = 0;
- if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
- return themap.FindKey (ind);
-}
-
-
-//=======================================================================
-//function : RootItem
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Binder) Transfer_TransferProcess::RootItem(const Standard_Integer num) const
-// const Standard_Integer categ) const
-{
- Standard_Integer ind = 0;
- if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
- return themap.FindFromIndex(ind);//->Search(categ);skl
-}
-
-
-//=======================================================================
-//function : RootIndex
-//purpose :
-//=======================================================================
-
-Standard_Integer Transfer_TransferProcess::RootIndex(const TheStart& start) const
-{
- Standard_Integer index = MapIndex(start);
- if (index == 0) return 0;
- return theroots.FindIndex(index);
-}
-
-
-//=======================================================================
-//function : NestingLevel
-//purpose :
-//=======================================================================
-
-Standard_Integer Transfer_TransferProcess::NestingLevel () const
-{
- return thelevel;
-}
-
-
-//=======================================================================
-//function : ResetNestingLevel
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::ResetNestingLevel ()
-{
- thelevel = 0;
-}
-
-
-// ########################################################################
-// .... SCOPE MANAGEMENT ....
-
-
-//======================================================================
-//Purpose : gka TRJ9 for writing SDR for solid
-// Check if binder has already been bound to the result binder.
-//======================================================================
-
-// static Standard_Boolean Contains(const Handle(Transfer_Binder)& resbinder,
-// const Handle(Transfer_Binder)& addbinder)
-// {
-// Handle(Transfer_Binder) tmpbind = resbinder;
-// for ( ; ! tmpbind.IsNull(); tmpbind = tmpbind->NextResult() )
-// if ( tmpbind == addbinder ) return Standard_True;
-// return Standard_False;
-// }
-
-// ########################################################################
-// .... AUTOMATISMES DE TRANSFERT ....
-
-// ## ## ## ## ## Fonctions de Base ## ## ## ## ##
-
-
-//=======================================================================
-//function : Recognize
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::Recognize(const TheStart& start) const
-{
- Handle(Transfer_Actor) actor = theactor;
- // On balaie les Next jusqu a avoir un Resultat
- while (!actor.IsNull()) {
- if (actor->Recognize (start)) return Standard_True;
- actor = actor->Next();
- }
- return Standard_False;
-}
-
-
-//=======================================================================
-//function : Transferring
-//purpose :
-//=======================================================================
-
-Handle(Transfer_Binder) Transfer_TransferProcess::Transferring(const TheStart& start,
- const Message_ProgressRange& theProgress)
-{
- // Map deja alimentee ?
- Handle(Transfer_Binder) former = FindAndMask(start);
-
- // .... Transfert deja effectue avec Resultat ? ....
-
- // On considere que cette nouvelle demande de Transfert correspond donc a une
- // utilisation en plus : noter "AlreadyUsed", donc resultat non modifiable
- if (!former.IsNull()) {
- if (former->HasResult()) {
- former->SetAlreadyUsed();
- return former;
- }
- //}
-
- // .... Etat Initial : peut-etre deja fait ... ou infaisable !
-
- Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
- //if (!former.IsNull()) {
- Transfer_StatusExec statex = former->StatusExec();
- switch (statex) {
- case Transfer_StatusInitial : // Transfert prepare a faire
- break;
- case Transfer_StatusDone : // Transfert deja fait
-//#ifdef TRANSLOG
- aSender << " .. and Transfer done" << std::endl;
-//#endif
-// if (former->HasResult()) former->SetAlreadyUsed();
- return former;
- case Transfer_StatusRun : // ca y est, on boucle
- former->SetStatusExec(Transfer_StatusLoop);
- return former;
- case Transfer_StatusError : // pas propre, ca ...
- if (thetrace) {
- aSender << " *** Transfer in Error Status :" << std::endl;
- StartTrace (former, start, thelevel,0);
-// (*themessenger->Out()) << flush;
- }
- else StartTrace (former, start,thelevel,4);
- throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status");
- case Transfer_StatusLoop : // la boucle est bouclee ...
- if (thetrace) {
- aSender << " *** Transfer Head of Dead Loop :" << std::endl;
- StartTrace (former, start, thelevel,0);
-// (*themessenger->Out()) << flush;
- }
- else StartTrace (former, start,thelevel,4);
- throw Transfer_TransferDeadLoop("TransferProcess : Transfer at Head of a Dead Loop");
- }
-#ifdef TRANSLOG
- std::cout << "Transfer,level "<<thelevel<<Message_Flush;
-#endif
- //}
-
- // .... OK, on peut lancer l Execution
- //if (!former.IsNull())
- former->SetStatusExec(Transfer_StatusRun);
- }
-#ifdef TRANSLOG
- std::cout << " GO .." << std::endl;
-#endif
-
- Handle(Transfer_Binder) binder;
- Standard_Boolean newbind = Standard_False;
- if (theerrh) {
- Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
-
- // Transfert sous protection pour les exceptions (pour notification en fait)
- Standard_Integer oldlev = thelevel;
- try {
- OCC_CATCH_SIGNALS
- binder = TransferProduct(start, theProgress);
- }
-
- // ... Exceptions a Rattraper : elles ne se ressemblent pas toutes ... !
- catch (Transfer_TransferDeadLoop const&) {
- if (binder.IsNull()) {
- aSender << " *** Dead Loop with no Result" << std::endl;
- if (thetrace) StartTrace (binder, start, thelevel-1,0);
- binder = new Transfer_VoidBinder;
- Bind (start,binder); newbind = Standard_True;
- } else if (binder->StatusExec() == Transfer_StatusLoop) {
- if (thetrace) {
- aSender << " *** Dead Loop : Finding head of Loop :" << std::endl;
- StartTrace (binder, start, thelevel-1,0);
- }
- else StartTrace (binder, start,thelevel-1,4);
- throw Transfer_TransferFailure("TransferProcess : Head of Dead Loop");
-// Autrement dit, on change d exception (on est sorti de la boucle)
- } else {
- if (thetrace) {
- aSender << " *** Dead Loop : Actor in Loop :" << std::endl;
- StartTrace (binder, start, thelevel-1,0);
- }
- }
- binder->AddFail("Transfer in dead Loop");
- thelevel = oldlev;
- }
- catch (Standard_Failure const& anException) {
- if (binder.IsNull()) {
- aSender << " *** Exception Raised with no Result" << std::endl;
- binder = new Transfer_VoidBinder;
- Bind (start,binder); newbind = Standard_True;
- }
- binder->AddFail("Transfer stopped by exception raising");
- if (thetrace) {
- aSender << " *** Raised : " << anException.GetMessageString() << std::endl;
- StartTrace (binder, start, thelevel-1,4);
- }
- thelevel = oldlev;
- }
- }
-
-// Transfert non protege (ainsi, dbx a la main en cas de plantage par Raise)
- else binder = TransferProduct(start, theProgress);
-
- if (theProgress.UserBreak())
- return Handle(Transfer_Binder)();
-
-// .... Conclusion : Noter dans la Map ....
-
- if (!newbind && !binder.IsNull()) {
- if (former.IsNull()) {
-// Peut-etre <theactor> a fait lui meme Bind ... verifier sinon le faire
- if (!IsBound(start)) Bind(start,binder); // resultat = categorie 0
- else { // gka TRJ9 for writing SDR for solid
-// Handle(Transfer_Binder) tmpbind = Find(start);
-// if(!Contains(binder,tmpbind))
-// binder->AddResult(tmpbind);
- Rebind(start,binder); // test_pattern.sat
- }
- }
- else Rebind(start,binder);
-// (du coup, <thelastbnd> vaut <binder>)
-#ifdef TRANSLOG
- std::cout << " ... OK" << std::endl;
-#endif
- }
- else {
- //= by ABV: 5 Oct 97: nothing generated, but former can be in run state - drop it
- //= ASK: may be set it to StatusInitial ?
- if ( ! former.IsNull() ) former->SetStatusExec ( Transfer_StatusDone ); //+
- return nulbinder; // Binder Null ... que faire d autre ?
- }
-
-// .... Gerer les Racines (si prevu) ....
-
- if (therootl >= thelevel) {
- therootl = 0;
- if (therootm && binder->Status() != Transfer_StatusVoid) {
- SetRoot (start);
- }
- }
- return thelastbnd;
-}
-
-// ## ## TransferProduct : Action proprement dite ## ##
-
- Handle(Transfer_Binder) Transfer_TransferProcess::TransferProduct
- (const TheStart& start,
- const Message_ProgressRange& theProgress)
-{
- thelevel ++; // si decremente et == 0, transfert racine
- Handle(Transfer_Binder) binder;
- Handle(Transfer_Actor) actor = theactor;
-
-// On balaie les Next jusqu a avoir un Resultat
- Message_ProgressScope aScope (theProgress, NULL, 1, true);
- while (!actor.IsNull()) {
- if (actor->Recognize (start)) binder = actor->Transferring(start,this, aScope.Next());
- else binder.Nullify();
- if (!binder.IsNull()) break;
- actor = actor->Next();
- }
- if (aScope.UserBreak())
- return Handle(Transfer_Binder)();
-
- if (binder.IsNull()) {
-// if (thetrace) {
-// aSender << "Transfer has produced no Result" <<endl;
-// StartTrace (binder, start, thelevel-1,0); sout << flush;
-// }
- if (thelevel > 0) thelevel --;
- return binder;
- }
-// Gestion du niveau racine (.. a regarder de pres ..)
- if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone)
- therootl = thelevel - 1;
-
- if (thelevel > 0) thelevel --;
- return binder;
-}
-
-
-//=======================================================================
-//function : Transfer
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::Transfer(const TheStart& start,
- const Message_ProgressRange& theProgress)
-{
- Handle(Transfer_Binder) binder = Transferring(start, theProgress);
- return (!binder.IsNull());
-}
-
-
-// #########################################################################
-// .... Error Handling + Trace ....
-
-// trace : 1 pour Fail et Exception , 2 pour Root et Warning
-
-
-//=======================================================================
-//function : SetErrorHandle
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::SetErrorHandle(const Standard_Boolean err)
-{
- theerrh = err;
-} // traite par Transferring
-
-
-//=======================================================================
-//function : ErrorHandle
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::ErrorHandle() const
-{
- return theerrh;
-}
-
-//=======================================================================
-//function : StartTrace
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::StartTrace(const Handle(Transfer_Binder)& binder,
- const TheStart& start,
- const Standard_Integer level,
- const Standard_Integer mode) const
-{
- Message_Messenger::StreamBuffer aSender = themessenger->SendInfo();
- // ### Fail (Roots:50) -- Start start->DynamicType()
- // ### Fail (Roots:50) -- Start id:#label.. Type:start->DynamicType()
- if (thetrace > 3) { // Internal to be switch when searching bug (trace >= 4)
- if (mode == 1) aSender << " ### Fail";
- if (mode == 2) aSender << " ### Warning";
- if (mode == 3) aSender << " ### New Root n0 " << theroots.Extent();
- if (mode == 4) aSender << " ### Exception";
- if (mode == 5) aSender << " ### Substitution";
- if (mode == 6) aSender << " ### Information";
- if (level > 1)
- aSender << " (nested)"; // " at nesting Level:"<<level;
- if (mode >= 0 && mode != 3)
- aSender << " at " << theroots.Extent() << " Roots";
- }
- if (!start.IsNull()) PrintTrace (start,aSender);
-//// sout << endl;
-
- if (!binder.IsNull()) { // old: if IsNull sout <<endl<< " --- Not Bound";
- Handle(Transfer_Binder) bnd = binder;
- Standard_Boolean hasres = Standard_False;
- while (!bnd.IsNull()) {
- if (bnd->Status() != Transfer_StatusVoid) {
-// --- Result Type: binder->ResultType() --- Binder : binder->DynamicType();
- if (!hasres)
- aSender << "\n --- Result Type : ";
- else
- aSender << " , ";
- aSender << bnd->ResultTypeName();
-// CKY 9-JAN-1999: waiting for XSTEP Kernel message (not IGES_2075)
-/* Message_Msg Msg2075("IGES_2075");
- Msg2075.AddString(bnd->ResultTypeName());
- Msg2075.TraceEver(); */
- hasres = Standard_True;
- }
- bnd = bnd->NextResult();
- }
- if (!hasres && mode > 2) {
- aSender << "\n --- No Result recorded";
-// CKY 9-JAN-1999 : waiting for XSTEP Kernel message
-// (not IGES_2075, no reference to specifically TopoDS_Shape)
-/* Message_Msg Msg2075("IGES_2075");
- Msg2075.AddString("No TopoDS_Shape");
- Msg2075.TraceEver(); */
- }
-//old if (isused) sout << " -- (Already Used in another Transfer)";
- }
- aSender << std::endl;
-}
-
-
-//=======================================================================
-//function : PrintTrace
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::PrintTrace(const TheStart& start, Standard_OStream& S) const
-{
- if (!start.IsNull()) S <<" Type:" << start->DynamicType()->Name();
-}
-
-
-//=======================================================================
-//function : IsLooping
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::IsLooping
- (const Standard_Integer alevel) const
- { return alevel > NbMapped(); }
-
-
-
-// #########################################################################
-// .... RESULTATS ....
-
-
-// ## ## RootResult : Les Racines ## ##
-
-
-//=======================================================================
-//function : RootResult
-//purpose :
-//=======================================================================
-
-Transfer_Iterator Transfer_TransferProcess::RootResult(const Standard_Boolean withstart) const
-{
- Transfer_Iterator iter(withstart);
- Standard_Integer max = theroots.Extent();
- for (Standard_Integer j = 1; j <= max; j ++) {
- Standard_Integer i = theroots.FindKey(j);
- Handle(Transfer_Binder) binder = MapItem(i);
- if (binder.IsNull()) continue;
- if (withstart) iter.Add (binder,Mapped(i));
- else iter.Add (binder);
- }
- return iter;
-}
-
-
-// ## ## CompleteResult : Tous les Resultats ## ##
-
-//=======================================================================
-//function : CompleteResult
-//purpose :
-//=======================================================================
-
-Transfer_Iterator Transfer_TransferProcess::CompleteResult
- (const Standard_Boolean withstart) const
-{
- Transfer_Iterator iter(withstart);
- Standard_Integer max = NbMapped();
- for (Standard_Integer i = 1; i <= max; i ++) {
- Handle(Transfer_Binder) binder = MapItem(i);
- if (binder.IsNull()) continue;
- if (withstart) iter.Add (binder,Mapped(i));
- else iter.Add (binder);
- }
- return iter;
-}
-
-
-// ## ## AbnormalResult : Transferts a probleme ## ##
-//=======================================================================
-//function : AbnormalResult
-//purpose :
-//=======================================================================
-
-Transfer_Iterator Transfer_TransferProcess::AbnormalResult() const
-{
- Transfer_Iterator iter(Standard_True);
- Standard_Integer max = NbMapped();
- for (Standard_Integer i = 1; i <= max; i ++) {
- Handle(Transfer_Binder) binder = MapItem(i);
- if (binder.IsNull()) continue;
- Transfer_StatusExec statex = binder->StatusExec();
- if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
- iter.Add (binder,Mapped(i)); // on note les cas "pas normaux"
- }
- return iter;
-}
-
-
-// ## ## ## CheckList : les messages ## ## ##
-//=======================================================================
-//function : CheckList
-//purpose :
-//=======================================================================
-
-Interface_CheckIterator Transfer_TransferProcess::CheckList
- (const Standard_Boolean erronly) const
-{
- Interface_CheckIterator list;
- Standard_Integer num, max = NbMapped();
- for (Standard_Integer i = 1; i <= max; i ++) {
- Handle(Transfer_Binder) binder = MapItem(i);
- if (binder.IsNull()) continue;
- Transfer_StatusExec statex = binder->StatusExec();
- Handle(Interface_Check) check = binder->Check();
- if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
- !check->HasFailed())
- check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
- if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
- const TheStart& ent = Mapped(i);
- num = CheckNum(ent);
- if (num == 0) num = i;
- check->SetEntity(ent);
- list.Add(check,num);
- }
- return list;
-}
-
-
-// #########################################################################
-// .... RESULTATS PAR ENTITE ....
-
-//=======================================================================
-//function : ResultOne
-//purpose :
-//=======================================================================
-
-Transfer_Iterator Transfer_TransferProcess::ResultOne(const TheStart& start,
- const Standard_Integer level,
- const Standard_Boolean withstart) const
-{
- Transfer_Iterator iter(withstart);
- Standard_Integer max = NbMapped();
- Standard_Integer ind = MapIndex (start);
- if (ind == 0) return iter;
- Standard_Integer i1 = (level == 0 ? ind : 1);
- Standard_Integer i2 = (level == 0 ? ind : max);
- Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
- //MarkScoped (ind,level,map);
-
- for (Standard_Integer i = i1; i <= i2; i ++) {
- ind = map->Value(i);
- if (ind == 0) continue;
- Handle(Transfer_Binder) binder = MapItem(i);
- if (binder.IsNull()) continue;
- if (withstart) iter.Add (binder,Mapped(ind));
- else iter.Add (binder);
- }
- return iter;
-}
-
-
-//=======================================================================
-//function : CheckListOne
-//purpose :
-//=======================================================================
-
-Interface_CheckIterator Transfer_TransferProcess::CheckListOne
- (const TheStart& start,const Standard_Integer level,
- const Standard_Boolean erronly) const
-{
- Interface_CheckIterator list;
- Standard_Integer max = NbMapped();
- Standard_Integer num, ind = MapIndex (start);
- if (ind == 0) return list;
- Standard_Integer i1 = (level == 0 ? ind : 1);
- Standard_Integer i2 = (level == 0 ? ind : max);
- Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
- //MarkScoped (ind,level,map);
-
- for (Standard_Integer i = i1; i <= i2; i ++) {
- ind = map->Value(i);
- if (ind == 0) continue;
- Handle(Transfer_Binder) binder = MapItem(ind);
- if (binder.IsNull()) continue;
- Transfer_StatusExec statex = binder->StatusExec();
- Handle(Interface_Check) check = binder->Check();
- if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
- !check->HasFailed())
- check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
- if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
- const TheStart& ent = Mapped(ind);
- num = CheckNum(ent); if (num == 0) num = ind;
- check->SetEntity(ent);
- list.Add(check,num);
- }
- return list;
-}
-
-
-//=======================================================================
-//function : IsCheckListEmpty
-//purpose :
-//=======================================================================
-
-Standard_Boolean Transfer_TransferProcess::IsCheckListEmpty
- (const TheStart& start, const Standard_Integer level,
- const Standard_Boolean erronly) const
-{
- Standard_Integer max = NbMapped();
- Standard_Integer ind = MapIndex (start);
- if (ind == 0) return Standard_False;
- Standard_Integer i1 = (level == 0 ? ind : 1);
- Standard_Integer i2 = (level == 0 ? ind : max);
- Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
-// MarkScoped (ind,level,map);
-
- for (Standard_Integer i = i1; i <= i2; i ++) {
- ind = map->Value(i);
- if (ind == 0) continue;
- Handle(Transfer_Binder) binder = MapItem(ind);
- if (binder.IsNull()) continue;
-
- Transfer_StatusExec statex = binder->StatusExec();
- Handle(Interface_Check) check = binder->Check();
- if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
- return Standard_False;
- if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) return Standard_False;
- }
- return Standard_True;
-}
-
-
-//=======================================================================
-//function : RemoveResult
-//purpose :
-//=======================================================================
-
-void Transfer_TransferProcess::RemoveResult(const TheStart& start,
- const Standard_Integer level,
- const Standard_Boolean /*compute*/)
-{
- //if (compute) ComputeScopes();
- Standard_Integer max = NbMapped();
- Standard_Integer ind = MapIndex (start);
- if (ind == 0) return;
- Standard_Integer i1 = (level == 0 ? ind : 1);
- Standard_Integer i2 = (level == 0 ? ind : max);
- Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
-// MarkScoped (ind,level,map);
-
- Standard_Integer i; // svv Jan11 2000 : porting on DEC
- for (i = i1; i <= i2; i ++) {
- ind = map->Value(i);
- if (ind == 0) continue;
- Handle(Transfer_Binder) binder = MapItem(ind);
- if (binder.IsNull()) continue;
-// Standard_Boolean cayest = binder->SetNbUserScopes (-1);
-// if (cayest) themap(ind) = nulbinder; // RAZ !
- }
-
-//pdn commented for (i = NbRoots(); i > 0; i --)
-// if (theroots.Value(i) == ind) theroots.Remove(i);
-}
-
-
-Standard_Integer Transfer_TransferProcess::CheckNum(const TheStart& ) const
-{
- return 0;
-}
-
#include <Standard_Type.hxx>
#include <Transfer_Finder.hxx>
-#include <TColStd_MapTransientHasher.hxx>
class Standard_Transient;
class Transfer_DataInfo;
class Transfer_Finder;
#include <Transfer_TransientMapper.hxx>
#include <Standard_Type.hxx>
-
#include <Standard_Transient.hxx>
#include <Transfer_DataInfo.hxx>
#include <Transfer_Finder.hxx>
-
-
-
-
-
-
+//=======================================================================
+//function : Transfer_TransientMapper
+//purpose :
+//=======================================================================
+Transfer_TransientMapper::Transfer_TransientMapper(const Handle(Standard_Transient)& akey)
+ : theval(akey)
+{
+ SetHashCode(std::hash<Handle(Standard_Transient)>{}(akey));
+}
+//=======================================================================
+//function : Value
+//purpose :
+//=======================================================================
+const Handle(Standard_Transient)& Transfer_TransientMapper::Value() const
+{
+ return theval;
+}
+//=======================================================================
+//function : Equates
+//purpose :
+//=======================================================================
+Standard_Boolean Transfer_TransientMapper::Equates
+(const Handle(Transfer_Finder)& other) const
+{
+ if (other.IsNull()) return Standard_False;
+ if (GetHashCode() != other->GetHashCode()) return Standard_False;
+ if (other->DynamicType() != DynamicType()) return Standard_False;
+ Handle(Transfer_TransientMapper) another = Handle(Transfer_TransientMapper)::DownCast(other);
+ return theval == another->Value();
+}
-#define TheKey Handle(Standard_Transient)
-#define TheKey_hxx <Standard_Transient.hxx>
-#define TheHasher TColStd_MapTransientHasher
-#define TheHasher_hxx <TColStd_MapTransientHasher.hxx>
-#define TheInfo Transfer_DataInfo
-#define TheInfo_hxx <Transfer_DataInfo.hxx>
-#define Transfer_Mapper Transfer_TransientMapper
-#define Transfer_Mapper_hxx <Transfer_TransientMapper.hxx>
-#define Handle_Transfer_Mapper Handle(Transfer_TransientMapper)
-#include <Transfer_Mapper.gxx>
+//=======================================================================
+//function : ValueType
+//purpose :
+//=======================================================================
+Handle(Standard_Type) Transfer_TransientMapper::ValueType() const
+{
+ return Transfer_DataInfo::Type(theval);
+}
+//=======================================================================
+//function : ValueTypeName
+//purpose :
+//=======================================================================
+Standard_CString Transfer_TransientMapper::ValueTypeName() const
+{
+ return Transfer_DataInfo::TypeName(theval);
+}
TransferBRep_BinderOfShape.cxx
TransferBRep_BinderOfShape.hxx
TransferBRep_HSequenceOfTransferResultInfo.hxx
-TransferBRep_OrientedShapeMapper.hxx
-TransferBRep_OrientedShapeMapper_0.cxx
TransferBRep_Reader.cxx
TransferBRep_Reader.hxx
TransferBRep_SequenceOfTransferResultInfo.hxx
+++ /dev/null
-// Created on: 1994-10-03
-// Created by: Christian CAILLET
-// Copyright (c) 1994-1999 Matra Datavision
-// Copyright (c) 1999-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 _TransferBRep_OrientedShapeMapper_HeaderFile
-#define _TransferBRep_OrientedShapeMapper_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <Transfer_Finder.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_CString.hxx>
-class TopoDS_Shape;
-class TopTools_OrientedShapeMapHasher;
-class TransferBRep_ShapeInfo;
-class Transfer_Finder;
-
-
-class TransferBRep_OrientedShapeMapper;
-DEFINE_STANDARD_HANDLE(TransferBRep_OrientedShapeMapper, Transfer_Finder)
-
-
-class TransferBRep_OrientedShapeMapper : public Transfer_Finder
-{
-
-public:
-
-
- //! Creates a Mapper with a Value. This Value can then not be
- //! changed. It is used by the Hasher to compute the HashCode,
- //! which will then be stored for an immediate reading.
- Standard_EXPORT TransferBRep_OrientedShapeMapper(const TopoDS_Shape& akey);
-
- //! Returns the contained value
- Standard_EXPORT const TopoDS_Shape& Value() const;
-
- //! Specific testof equality : defined as False if <other> has
- //! not the same true Type, else contents are compared (by
- //! C++ operator ==)
- Standard_EXPORT Standard_Boolean Equates (const Handle(Transfer_Finder)& other) const Standard_OVERRIDE;
-
- //! Returns the Type of the Value. By default, returns the
- //! DynamicType of <me>, but can be redefined
- Standard_EXPORT virtual Handle(Standard_Type) ValueType() const Standard_OVERRIDE;
-
- //! Returns the name of the Type of the Value. Default is name
- //! of ValueType, unless it is for a non-handled object
- Standard_EXPORT virtual Standard_CString ValueTypeName() const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTI_INLINE(TransferBRep_OrientedShapeMapper,Transfer_Finder)
-
-protected:
-
-
-
-
-private:
-
-
- TopoDS_Shape theval;
-
-
-};
-
-
-
-
-
-
-
-#endif // _TransferBRep_OrientedShapeMapper_HeaderFile
+++ /dev/null
-// Created on: 1994-10-03
-// Created by: Christian CAILLET
-// Copyright (c) 1994-1999 Matra Datavision
-// Copyright (c) 1999-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 <TransferBRep_OrientedShapeMapper.hxx>
-
-#include <Standard_Type.hxx>
-
-#include <TopoDS_Shape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
-#include <TransferBRep_ShapeInfo.hxx>
-#include <Transfer_Finder.hxx>
-
-
-
-
-
-
-
-
-
-
-#define TheKey TopoDS_Shape
-#define TheKey_hxx <TopoDS_Shape.hxx>
-#define TheHasher TopTools_OrientedShapeMapHasher
-#define TheHasher_hxx <TopTools_OrientedShapeMapHasher.hxx>
-#define TheInfo TransferBRep_ShapeInfo
-#define TheInfo_hxx <TransferBRep_ShapeInfo.hxx>
-#define Transfer_Mapper TransferBRep_OrientedShapeMapper
-#define Transfer_Mapper_hxx <TransferBRep_OrientedShapeMapper.hxx>
-#define Handle_Transfer_Mapper Handle(TransferBRep_OrientedShapeMapper)
-#include <Transfer_Mapper.gxx>
-
#include <TransferBRep_ShapeInfo.hxx>
#include <Transfer_Finder.hxx>
-
+//=======================================================================
+//function : TransferBRep_ShapeMapper
+//purpose :
+//=======================================================================
+TransferBRep_ShapeMapper::TransferBRep_ShapeMapper(const TopoDS_Shape& akey)
+ : theval(akey)
+{
+ SetHashCode(TopTools_ShapeMapHasher{}(akey));
+}
+//=======================================================================
+//function : Value
+//purpose :
+//=======================================================================
+const TopoDS_Shape& TransferBRep_ShapeMapper::Value() const
+{
+ return theval;
+}
+//=======================================================================
+//function : Equates
+//purpose :
+//=======================================================================
+Standard_Boolean TransferBRep_ShapeMapper::Equates(const Handle(Transfer_Finder)& other) const
+{
+ if (other.IsNull()) return Standard_False;
+ if (GetHashCode() != other->GetHashCode()) return Standard_False;
+ if (other->DynamicType() != DynamicType()) return Standard_False;
+ Handle(TransferBRep_ShapeMapper) another = Handle(TransferBRep_ShapeMapper)::DownCast(other);
+ return TopTools_ShapeMapHasher{}(theval, another->Value());
+}
+//=======================================================================
+//function : ValueType
+//purpose :
+//=======================================================================
+Handle(Standard_Type) TransferBRep_ShapeMapper::ValueType() const
+{
+ return TransferBRep_ShapeInfo::Type(theval);
+}
-
-
-
-
-#define TheKey TopoDS_Shape
-#define TheKey_hxx <TopoDS_Shape.hxx>
-#define TheHasher TopTools_ShapeMapHasher
-#define TheHasher_hxx <TopTools_ShapeMapHasher.hxx>
-#define TheInfo TransferBRep_ShapeInfo
-#define TheInfo_hxx <TransferBRep_ShapeInfo.hxx>
-#define Transfer_Mapper TransferBRep_ShapeMapper
-#define Transfer_Mapper_hxx <TransferBRep_ShapeMapper.hxx>
-#define Handle_Transfer_Mapper Handle(TransferBRep_ShapeMapper)
-#include <Transfer_Mapper.gxx>
-
+//=======================================================================
+//function : ValueTypeName
+//purpose :
+//=======================================================================
+Standard_CString TransferBRep_ShapeMapper::ValueTypeName() const
+{
+ return TransferBRep_ShapeInfo::TypeName(theval);
+}
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, MyViewer)
for (V3d_ListOfLight::Iterator anIterator (myActiveLights); anIterator.More(); anIterator.Next())
{
- class Handle(Graphic3d_CLight)& anActiveLight = anIterator.Value();
+ class Handle(Graphic3d_CLight)& anActiveLight = anIterator.ChangeValue();
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, anActiveLight)
}
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewAxis)
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DoubleMap.hxx>
class AIS_InteractiveObject;
-typedef NCollection_DoubleMap<Handle(AIS_InteractiveObject),TCollection_AsciiString,TColStd_MapTransientHasher,TCollection_AsciiString> ViewerTest_DoubleMapOfInteractiveAndName;
-typedef NCollection_DoubleMap<Handle(AIS_InteractiveObject),TCollection_AsciiString,TColStd_MapTransientHasher,TCollection_AsciiString>::Iterator ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
+typedef NCollection_DoubleMap<Handle(AIS_InteractiveObject),TCollection_AsciiString> ViewerTest_DoubleMapOfInteractiveAndName;
+typedef NCollection_DoubleMap<Handle(AIS_InteractiveObject),TCollection_AsciiString>::Iterator ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
#endif
}
#endif
-static Handle(ViewerTest_Window)& VT_GetWindow()
+namespace
{
- static Handle(ViewerTest_Window) aWindow;
- return aWindow;
-}
+ static Handle(ViewerTest_Window)& VT_GetWindow()
+ {
+ static Handle(ViewerTest_Window) aWindow;
+ return aWindow;
+ }
-static Handle(Aspect_DisplayConnection)& GetDisplayConnection()
-{
- static Handle(Aspect_DisplayConnection) aDisplayConnection;
- return aDisplayConnection;
-}
+ static Handle(Aspect_DisplayConnection)& GetDisplayConnection()
+ {
+ static Handle(Aspect_DisplayConnection) aDisplayConnection;
+ return aDisplayConnection;
+ }
-static void SetDisplayConnection (const Handle(Aspect_DisplayConnection)& theDisplayConnection)
-{
- GetDisplayConnection() = theDisplayConnection;
-}
+ using ViewerTest_ViewerCommandsViewMap = NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>;
+ using ViewerTest_ViewerCommandsInteractiveContextMap = NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>;
+ using ViewerTest_ViewerCommandsGraphicDriverMap = NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>;
-NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
-static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts;
-static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers;
+ static void SetDisplayConnection(const Handle(Aspect_DisplayConnection)& theDisplayConnection)
+ {
+ GetDisplayConnection() = theDisplayConnection;
+ }
+
+ static ViewerTest_ViewerCommandsViewMap ViewerTest_myViews;
+ static ViewerTest_ViewerCommandsInteractiveContextMap ViewerTest_myContexts;
+ static ViewerTest_ViewerCommandsGraphicDriverMap ViewerTest_myDrivers;
+}
static struct
{
//! Sets the gradient filling for a background in a default viewer.
void SetDefaultGradient()
{
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator aCtxIter (ViewerTest_myContexts);
+ for (ViewerTest_ViewerCommandsInteractiveContextMap::Iterator aCtxIter (ViewerTest_myContexts);
aCtxIter.More(); aCtxIter.Next())
{
- const Handle (V3d_Viewer)& aViewer = aCtxIter.Value()->CurrentViewer();
+ const Handle (V3d_Viewer)& aViewer = aCtxIter.Key2()->CurrentViewer();
aViewer->SetDefaultBgGradientColors (GradientColor1, GradientColor2, FillMethod);
}
}
//! Sets the color used for filling a background in a default viewer.
void SetDefaultColor()
{
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle (AIS_InteractiveContext)>::Iterator aCtxIter (ViewerTest_myContexts);
+ for (ViewerTest_ViewerCommandsInteractiveContextMap::Iterator aCtxIter (ViewerTest_myContexts);
aCtxIter.More(); aCtxIter.Next())
{
- const Handle (V3d_Viewer)& aViewer = aCtxIter.Value()->CurrentViewer();
+ const Handle (V3d_Viewer)& aViewer = aCtxIter.Key2()->CurrentViewer();
aViewer->SetDefaultBackgroundColor (FlatColor);
}
}
{
Handle(AIS_InteractiveContext) anAISContext;
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
+ for (ViewerTest_ViewerCommandsInteractiveContextMap::Iterator
anIter (ViewerTest_myContexts); anIter.More(); anIter.Next())
{
- if (anIter.Value()->CurrentViewer() == theView->Viewer())
+ if (anIter.Key2()->CurrentViewer() == theView->Viewer())
return anIter.Key2();
}
return anAISContext;
const Standard_Integer thePxBottom,
TCollection_AsciiString& theViewId)
{
- for(NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator
+ for(ViewerTest_ViewerCommandsViewMap::Iterator
anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
{
Standard_Integer aTop = 0,
aLeft = 0,
aRight = 0,
aBottom = 0;
- anIter.Value()->Window()->Position(aLeft, aTop, aRight, aBottom);
+ anIter.Key2()->Window()->Position(aLeft, aTop, aRight, aBottom);
if ((thePxLeft >= aLeft && thePxLeft <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
(thePxLeft >= aLeft && thePxLeft <= aRight && thePxBottom >= aTop && thePxBottom <= aBottom) ||
(thePxRight >= aLeft && thePxRight <= aRight && thePxTop >= aTop && thePxTop <= aBottom) ||
// If it's the single view, we first look for empty context
if (ViewerTest_myViews.IsEmpty() && !ViewerTest_myContexts.IsEmpty())
{
- NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
+ ViewerTest_ViewerCommandsInteractiveContextMap::Iterator
anIter(ViewerTest_myContexts);
if (anIter.More())
- ViewerTest::SetAISContext (anIter.Value());
+ ViewerTest::SetAISContext (anIter.Key2());
a3DViewer = ViewerTest::GetAISContext()->CurrentViewer();
}
else if (ViewerTest_myContexts.IsBound1(aViewNames.GetViewerName()))
//==============================================================================
void ViewerTest::RedrawAllViews()
{
- NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
+ ViewerTest_ViewerCommandsViewMap::Iterator aViewIt(ViewerTest_myViews);
for (; aViewIt.More(); aViewIt.Next())
{
const Handle(V3d_View)& aView = aViewIt.Key2();
#if defined(_WIN32) || defined(HAVE_XLIB)
static TCollection_AsciiString FindViewIdByWindowHandle (Aspect_Drawable theWindowHandle)
{
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator
+ for (ViewerTest_ViewerCommandsViewMap::Iterator
anIter(ViewerTest_myViews); anIter.More(); anIter.Next())
{
- Aspect_Drawable aWindowHandle = anIter.Value()->Window()->NativeHandle();
+ Aspect_Drawable aWindowHandle = anIter.Key2()->Window()->NativeHandle();
if (aWindowHandle == theWindowHandle)
return anIter.Key1();
}
{
if (ViewerTest_myViews.Extent() > 1)
{
- for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
+ for (ViewerTest_ViewerCommandsViewMap::Iterator anIter (ViewerTest_myViews);
anIter.More(); anIter.Next())
{
if (anIter.Key1() != theViewName)
{
- ActivateView (anIter.Value(), true);
+ ActivateView (anIter.Key2(), true);
break;
}
}
}
}
- // Delete view
+ // Delete view, name will be removed too
+ const TCollection_AsciiString aCopyString(theViewName);
ViewerTest_myViews.UnBind1(theViewName);
if (!aView->Window().IsNull())
{
{
// Remove driver if there is no viewers that use it
Standard_Boolean isRemoveDriver = Standard_True;
- for(NCollection_DoubleMap<TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
+ for(ViewerTest_ViewerCommandsInteractiveContextMap::Iterator
anIter(ViewerTest_myContexts); anIter.More(); anIter.Next())
{
if (aCurrentContext != anIter.Key2() &&
- aCurrentContext->CurrentViewer()->Driver() == anIter.Value()->CurrentViewer()->Driver())
+ aCurrentContext->CurrentViewer()->Driver() == anIter.Key2()->CurrentViewer()->Driver())
{
isRemoveDriver = Standard_False;
break;
ViewerTest_myContexts.UnBind2(aCurrentContext);
}
}
- Message::SendInfo() << "3D View - " << theViewName << " was deleted.\n";
+ Message::SendInfo() << "3D View - " << aCopyString << " was deleted.\n";
if (ViewerTest_EventManager::ToExitOnCloseView())
{
Draw_Interprete ("exit");
if (anArg.IsEqual ("ALL")
|| anArg.IsEqual ("*"))
{
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
+ for (ViewerTest_ViewerCommandsViewMap::Iterator anIter (ViewerTest_myViews);
anIter.More(); anIter.Next())
{
aViewList.Append (anIter.Key1());
theDi << theArgVec[0] <<":\n";
}
- for (NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator aDriverIter (ViewerTest_myDrivers);
+ for (ViewerTest_ViewerCommandsGraphicDriverMap::Iterator aDriverIter (ViewerTest_myDrivers);
aDriverIter.More(); aDriverIter.Next())
{
if (isTreeView)
theDi << aDriverIter.Key1() << ":\n";
- for (NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)>::Iterator
+ for (ViewerTest_ViewerCommandsInteractiveContextMap::Iterator
aContextIter(ViewerTest_myContexts); aContextIter.More(); aContextIter.Next())
{
if (aContextIter.Key1().Search(aDriverIter.Key1()) != -1)
theDi << " " << aContextName.Split(aDriverIter.Key1().Length() + 1) << ":\n";
}
- for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIter (ViewerTest_myViews);
+ for (ViewerTest_ViewerCommandsViewMap::Iterator aViewIter (ViewerTest_myViews);
aViewIter.More(); aViewIter.Next())
{
if (aViewIter.Key1().Search(aContextIter.Key1()) != -1)
TCollection_AsciiString aViewName(aViewIter.Key1());
if (isTreeView)
{
- if (aViewIter.Value() == ViewerTest::CurrentView())
+ if (aViewIter.Key2() == ViewerTest::CurrentView())
theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "(*)\n";
else
theDi << " " << aViewName.Split(aContextIter.Key1().Length() + 1) << "\n";
{
Display* aDispX = (Display* )theDispX;
Handle(Aspect_DisplayConnection) aDispConn;
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)>::Iterator
+ for (ViewerTest_ViewerCommandsGraphicDriverMap::Iterator
aDriverIter (ViewerTest_myDrivers); aDriverIter.More(); aDriverIter.Next())
{
const Handle(Aspect_DisplayConnection)& aDispConnTmp = aDriverIter.Key2()->GetDisplayConnection();
aPrs->RemoveClipPlane (aClipPlane);
}
- for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
+ for (ViewerTest_ViewerCommandsViewMap::Iterator aViewIt(ViewerTest_myViews);
aViewIt.More(); aViewIt.Next())
{
const Handle(V3d_View)& aView = aViewIt.Key2();
}
if (!aViewAffinity.IsNull())
{
- for (NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
+ for (ViewerTest_ViewerCommandsViewMap::Iterator anIter (ViewerTest_myViews);
anIter.More(); anIter.Next())
{
- ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Value(), false);
+ ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, anIter.Key2(), false);
}
ViewerTest::GetAISContext()->SetViewAffinity (aManipulator, aViewAffinity, true);
}
return aResult;
}
-//=======================================================================
-// function : HashCode
-// purpose : Global method
-//=======================================================================
-Standard_Integer HashCode (const Handle (VrmlData_Node) & theNode, const Standard_Integer theUpperBound)
-{
- return (theNode->Name () == NULL ? 1 : HashCode (theNode->Name (), theUpperBound));
-}
-
//=======================================================================
//function : VrmlData_Node
//purpose :
#include <NCollection_List.hxx>
#include <Standard_Type.hxx>
#include <Standard_TypeDef.hxx>
-#include <TCollection_AsciiString.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <Standard_CStringHasher.hxx>
#include <VrmlData_ErrorStatus.hxx>
#define VRMLDATA_LCOMPARE(aa, bb) \
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (VrmlData_Node, Standard_Transient)
-//! Computes a hash code for the given VRML node, in the range [1, theUpperBound]
-//! @param theNode the VRML node 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]
-Standard_EXPORT Standard_Integer HashCode (const Handle (VrmlData_Node) & theNode, Standard_Integer theUpperBound);
-Standard_EXPORT Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
- const Handle(VrmlData_Node)& theTwo);
+Standard_EXPORT Standard_Boolean IsEqual(const Handle(VrmlData_Node)& theOne,
+ const Handle(VrmlData_Node)& theTwo);
+
+namespace std
+{
+ template <>
+ struct hash<Handle(VrmlData_Node)>
+ {
+ size_t operator()(const Handle(VrmlData_Node)& theNode) const
+ {
+ if (!theNode->Name())
+ {
+ return 1;
+ }
+ return Standard_CStringHasher{}(theNode->Name());
+ }
+ };
+
+ template<>
+ struct equal_to<Handle(VrmlData_Node)>
+ {
+ bool operator()(const Handle(VrmlData_Node)& theNode1,
+ const Handle(VrmlData_Node)& theNode2) const noexcept
+ {
+ return IsEqual(theNode1, theNode2);
+ }
+ };
+}
#endif
#if defined(_WIN32) && !defined(OCCT_UWP)
#include <Aspect_Handle.hxx>
-#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Transient.hxx>
+#include <NCollection_DefineAlloc.hxx>
#include <TCollection_AsciiString.hxx>
//! This class defines a Windows NT window class.
#include <NCollection_DataMap.hxx>
#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
#include <XCAFDimTolObjects_DatumObject.hxx>
-#include <TColStd_MapTransientHasher.hxx>
-typedef NCollection_DataMap<Handle(XCAFDimTolObjects_GeomToleranceObject),Handle(XCAFDimTolObjects_DatumObject),TColStd_MapTransientHasher> XCAFDimTolObjects_DataMapOfToleranceDatum;
+typedef NCollection_DataMap<Handle(XCAFDimTolObjects_GeomToleranceObject),Handle(XCAFDimTolObjects_DatumObject)> XCAFDimTolObjects_DataMapOfToleranceDatum;
#endif
\ No newline at end of file
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
- struct Hasher
+ bool operator==(const XCAFDoc_AssemblyItemId& theOther) const
{
-
- //! Computes a hash code for the given value of the XCAFDoc_AssemblyItemId, in range [1, theUpperBound]
- //! @param theAssemblyItemId the value of the XCAFDoc_AssemblyItemId type 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 range [1, theUpperBound]
- static Standard_Integer HashCode (const XCAFDoc_AssemblyItemId& theAssemblyItemId,
- const Standard_Integer theUpperBound)
- {
- return ::HashCode (theAssemblyItemId.ToString(), theUpperBound);
- }
-
- static int IsEqual(const XCAFDoc_AssemblyItemId& theItem1,
- const XCAFDoc_AssemblyItemId& theItem2)
- {
- return theItem1.IsEqual(theItem2);
- }
- };
+ return IsEqual(theOther);
+ }
private:
};
+namespace std
+{
+
+ template<>
+ struct hash<XCAFDoc_AssemblyItemId>
+ {
+ size_t operator()(const XCAFDoc_AssemblyItemId& theAssemblyItemId) const
+ {
+ return std::hash<TCollection_AsciiString>{}(theAssemblyItemId.ToString());
+ }
+ };
+
+}
#endif // _XCAFDoc_AssemblyItemId_HeaderFile
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::GetGDTPresentations(NCollection_IndexedDataMap<TDF_Label,
- TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToShape) const
+ TopoDS_Shape>& theGDTLabelToShape) const
{
TDF_LabelSequence aGDTs;
GetDimensionLabels(aGDTs);
//function : SetGDTPresentations
//purpose :
//=======================================================================
-void XCAFDoc_DimTolTool::SetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToPrs)
+void XCAFDoc_DimTolTool::SetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape>& theGDTLabelToPrs)
{
for (Standard_Integer i = 1; i <= theGDTLabelToPrs.Extent(); i++)
{
#include <TColStd_HArray1OfReal.hxx>
#include <TopoDS_Shape.hxx>
#include <NCollection_IndexedDataMap.hxx>
-#include <TDF_LabelMapHasher.hxx>
class XCAFDoc_ShapeTool;
class TDF_Label;
Standard_EXPORT void Lock(const TDF_Label& theViewL) const;
//! fill the map GDT label -> shape presentation
- Standard_EXPORT void GetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToShape) const;
+ Standard_EXPORT void GetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape>& theGDTLabelToShape) const;
//! Set shape presentation for GDT labels according to given map (theGDTLabelToPrs)
//! theGDTLabelToPrsName map is an additional argument, can be used to set presentation names.
//! If label is not in the theGDTLabelToPrsName map, the presentation name will be empty
- Standard_EXPORT void SetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToPrs);
+ Standard_EXPORT void SetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape>& theGDTLabelToPrs);
//! Unlock the given GDT.
Standard_EXPORT void Unlock(const TDF_Label& theViewL) const;
// 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())
{
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();
#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
#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
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)
+namespace std
+{
+ template <>
+ struct hash<XCAFPrs_DocumentNode>
{
- return theNode1.Id == theNode2.Id;
- }
-
-};
+ size_t operator()(const XCAFPrs_DocumentNode& theDocumentNode) const
+ {
+ return std::hash<TCollection_AsciiString>{}(theDocumentNode.Id);
+ }
+ };
+}
#endif // _XCAFPrs_DocumentNode_HeaderFile
#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
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;
};
+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
}
private:
- NCollection_Map<TCollection_AsciiString, TCollection_AsciiString>
+ NCollection_Map<TCollection_AsciiString>
myNameMap; //!< names map to handle collisions
Handle(TDocStd_Document) myDoc; //!< document
TCollection_AsciiString myDocName; //!< document name
#define XSDRAWSTLVRML_CoordsMap_HeaderFile
#include <TColStd_DataMapOfIntegerReal.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerReal,TColStd_MapIntegerHasher> XSDRAWSTLVRML_CoordsMap;
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerReal,TColStd_MapIntegerHasher>::Iterator XSDRAWSTLVRML_DataMapIteratorOfCoordsMap;
+typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerReal> XSDRAWSTLVRML_CoordsMap;
+typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerReal>::Iterator XSDRAWSTLVRML_DataMapIteratorOfCoordsMap;
#endif
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <MeshVS_EntityType.hxx>
-#include <Standard_Address.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Poly_Triangulation.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <MeshVS_EntityType.hxx>
#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <Standard_Address.hxx>
#include <TColStd_Array1OfInteger.hxx>
#define XSDRAWSTLVRML_ElemNodesMap_HeaderFile
#include <TColStd_DataMapOfIntegerInteger.hxx>
-#include <TColStd_MapIntegerHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerInteger,TColStd_MapIntegerHasher> XSDRAWSTLVRML_ElemNodesMap;
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerInteger,TColStd_MapIntegerHasher>::Iterator XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap;
+typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerInteger> XSDRAWSTLVRML_ElemNodesMap;
+typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerInteger>::Iterator XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap;
#endif
#include <XmlMDF_ADriver.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(XmlMDF_ADriver),TCollection_AsciiString> XmlMDF_MapOfDriver;
-typedef NCollection_DataMap<TCollection_AsciiString,Handle(XmlMDF_ADriver),TCollection_AsciiString>::Iterator XmlMDF_DataMapIteratorOfMapOfDriver;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(XmlMDF_ADriver)> XmlMDF_MapOfDriver;
+typedef NCollection_DataMap<TCollection_AsciiString,Handle(XmlMDF_ADriver)>::Iterator XmlMDF_DataMapIteratorOfMapOfDriver;
#endif
#include <Standard_Type.hxx>
#include <XmlMDF_ADriver.hxx>
-#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Handle(Standard_Type),Handle(XmlMDF_ADriver),TColStd_MapTransientHasher> XmlMDF_TypeADriverMap;
-typedef NCollection_DataMap<Handle(Standard_Type),Handle(XmlMDF_ADriver),TColStd_MapTransientHasher>::Iterator XmlMDF_DataMapIteratorOfTypeADriverMap;
+typedef NCollection_DataMap<Handle(Standard_Type),Handle(XmlMDF_ADriver)> XmlMDF_TypeADriverMap;
+typedef NCollection_DataMap<Handle(Standard_Type),Handle(XmlMDF_ADriver)>::Iterator XmlMDF_DataMapIteratorOfTypeADriverMap;
#endif
#ifndef XmlTObjDrivers_HeaderFile
#define XmlTObjDrivers_HeaderFile
-#include <TObj_Common.hxx>
#include <Standard_GUID.hxx>
class XmlMDF_ADriverTable;
#ifndef XmlTObjDrivers_DocumentRetrievalDriver_HeaderFile
#define XmlTObjDrivers_DocumentRetrievalDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <XmlLDrivers_DocumentRetrievalDriver.hxx>
#include <XmlMDF_ADriverTable.hxx>
#ifndef XmlTObjDrivers_DocumentStorageDriver_HeaderFile
#define XmlTObjDrivers_DocumentStorageDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <XmlLDrivers_DocumentStorageDriver.hxx>
#include <XmlMDF_ADriverTable.hxx>
#ifndef XmlTObjDrivers_ObjectDriver_HeaderFile
#define XmlTObjDrivers_ObjectDriver_HeaderFile
-#include <TObj_Common.hxx>
#include <XmlMDF_ADriver.hxx>
class XmlTObjDrivers_ObjectDriver : public XmlMDF_ADriver
};
+namespace std
+{
+ template <>
+ struct hash<gp_Pnt>
+ {
+ size_t operator()(const gp_Pnt& thePnt) const noexcept
+ {
+ union
+ {
+ Standard_Real R[3];
+ Standard_Integer I[6];
+ } U;
+
+ thePnt.Coord(U.R[0], U.R[1], U.R[2]);
+
+ return std::hash<double>{}(U.I[0] / 23 + U.I[1] / 19 + U.I[2] / 17 + U.I[3] / 13 + U.I[4] / 11 + U.I[5] / 7);
+ }
+ };
+
+ template<>
+ struct equal_to<gp_Pnt>
+ {
+ bool operator()(const gp_Pnt& thePnt1,
+ const gp_Pnt& thePnt2) const noexcept
+ {
+ if (Abs(thePnt1.X() - thePnt2.X()) > Epsilon(thePnt2.X())) return false;
+ if (Abs(thePnt1.Y() - thePnt2.Y()) > Epsilon(thePnt2.Y())) return false;
+ if (Abs(thePnt1.Z() - thePnt2.Z()) > Epsilon(thePnt2.Z())) return false;
+ return true;
+ }
+ };
+}
+
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
math_Householder.cxx
math_Householder.hxx
math_Householder.lxx
-math_IntegerVector.cxx
math_IntegerVector.hxx
math_Jacobi.cxx
math_Jacobi.hxx
math_Uzawa.hxx
math_Uzawa.lxx
math_ValueAndWeight.hxx
-math_Vector.cxx
+math_VectorBase.hxx
+math_VectorBase.lxx
math_Vector.hxx
+++ /dev/null
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-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 <math_IntegerVector.hxx>
-
-#include <Standard_DimensionError.hxx>
-#include <Standard_RangeError.hxx>
-
-math_IntegerVector::math_IntegerVector(const Standard_Integer theFirst, const Standard_Integer theLast)
-: myLocArray (theLast - theFirst + 1),
- Array (myLocArray[0], theFirst, theLast)
-{
- //
-}
-
-math_IntegerVector::math_IntegerVector(const Standard_Integer theFirst,
- const Standard_Integer theLast,
- const Standard_Integer theInitialValue)
-: myLocArray (theLast - theFirst + 1),
- Array (myLocArray[0], theFirst, theLast)
-{
- Array.Init(theInitialValue);
-}
-
-math_IntegerVector::math_IntegerVector(const Standard_Integer* theTab,
- const Standard_Integer theFirst,
- const Standard_Integer theLast)
-: Array (*theTab, theFirst, theLast)
-{
- Standard_RangeError_Raise_if(theFirst > theLast, " ");
-}
-
-void math_IntegerVector::Init(const Standard_Integer theInitialValue)
-{
- Array.Init(theInitialValue);
-}
-
-math_IntegerVector::math_IntegerVector (const math_IntegerVector& theOther)
-: myLocArray (theOther.Length()),
- Array (myLocArray[0], theOther.Lower(), theOther.Upper())
-{
- memcpy (&myLocArray[0], &theOther.Array.First(), sizeof(Standard_Integer) * theOther.Length());
-}
-
-void math_IntegerVector::SetFirst(const Standard_Integer theFirst)
-{
- Array.Resize (theFirst, Array.Upper() - Array.Lower() + theFirst, Standard_False);
-}
-
-Standard_Real math_IntegerVector::Norm() const
-{
- Standard_Real Result = 0;
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result = Result + Array(Index) * Array(Index);
- }
- return Sqrt(Result);
-}
-
-Standard_Real math_IntegerVector::Norm2() const
-{
- Standard_Real Result = 0;
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result = Result + Array(Index) * Array(Index);
- }
- return Result;
-}
-
-Standard_Integer math_IntegerVector::Max() const
-{
- Standard_Integer I=0;
- Standard_Real X = RealFirst();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- if(Array(Index) > X)
- {
- X = Array(Index);
- I = Index;
- }
- }
- return I;
-}
-
-Standard_Integer math_IntegerVector::Min() const
-{
- Standard_Integer I=0;
- Standard_Real X = RealLast();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- if(Array(Index) < X)
- {
- X = Array(Index);
- I = Index;
- }
- }
- return I;
-}
-
-void math_IntegerVector::Invert()
-{
- Standard_Integer J;
- Standard_Integer Temp;
-
- for(Standard_Integer Index = Lower(); Index <= Lower() + Length() / 2 ; Index++)
- {
- J = Upper() + Lower() - Index;
- Temp = Array(Index);
- Array(Index) = Array(J);
- Array(J) = Temp;
- }
-}
-
-math_IntegerVector math_IntegerVector::Inverse() const
-{
- math_IntegerVector Result = *this;
- Result.Invert();
- return Result;
-}
-
-void math_IntegerVector::Set(const Standard_Integer theI1,
- const Standard_Integer theI2,
- const math_IntegerVector &theV)
-{
- Standard_DimensionError_Raise_if((theI1 < Lower()) || (theI2 > Upper()) ||
- (theI1 > theI2) || (theI2 - theI1 + 1 != theV.Length()), " ");
-
- Standard_Integer I = theV.Lower();
- for(Standard_Integer Index = theI1; Index <= theI2; Index++)
- {
- Array(Index) = theV.Array(I);
- I++;
- }
-}
-
-void math_IntegerVector::Multiply(const Standard_Integer theRight)
-{
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) * theRight;
- }
-}
-
-void math_IntegerVector::Add(const math_IntegerVector& theRight)
-{
- Standard_DimensionError_Raise_if(Length() != theRight.Length(), " ");
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) + theRight.Array(I);
- I++;
- }
-}
-
-void math_IntegerVector::Subtract(const math_IntegerVector& theRight)
-{
- Standard_DimensionError_Raise_if(Length() != theRight.Length(), " ");
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) - theRight.Array(I);
- I++;
- }
-}
-
-math_IntegerVector math_IntegerVector::Slice(const Standard_Integer theI1,
- const Standard_Integer theI2) const
-{
- Standard_DimensionError_Raise_if((theI1 < Lower()) || (theI1 > Upper()) ||
- (theI2 < Lower()) || (theI2 > Upper()), " ");
-
- if(theI2 >= theI1)
- {
- math_IntegerVector Result(theI1, theI2);
- for(Standard_Integer Index = theI1; Index <= theI2; Index++)
- {
- Result.Array(Index) = Array(Index);
- }
- return Result;
- }
- else
- {
- math_IntegerVector Result(theI2, theI1);
- for(Standard_Integer Index = theI1; Index >= theI2; Index--)
- {
- Result.Array(Index) = Array(Index);
- }
- return Result;
- }
-}
-
-Standard_Integer math_IntegerVector::Multiplied (const math_IntegerVector& theRight) const
-{
- Standard_Integer Result = 0;
-
- Standard_DimensionError_Raise_if(Length() != theRight.Length(), " ");
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = 0; Index < Length(); Index++)
- {
- Result = Result + Array(Index) * theRight.Array(I);
- I++;
- }
- return Result;
-}
-
-math_IntegerVector math_IntegerVector::Multiplied (const Standard_Integer theRight)const
-{
- math_IntegerVector Result(Lower(), Upper());
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) * theRight;
- }
- return Result;
-}
-
-math_IntegerVector math_IntegerVector::TMultiplied (const Standard_Integer theRight) const
-{
- math_IntegerVector Result(Lower(), Upper());
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) * theRight;
- }
- return Result;
-}
-
-math_IntegerVector math_IntegerVector::Added (const math_IntegerVector& theRight) const
-{
- Standard_DimensionError_Raise_if(Length() != theRight.Length(), " ");
-
- math_IntegerVector Result(Lower(), Upper());
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) + theRight.Array(I);
- I++;
- }
- return Result;
-}
-
-math_IntegerVector math_IntegerVector::Opposite()
-{
- math_IntegerVector Result(Lower(), Upper());
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = - Array(Index);
- }
- return Result;
-}
-
-math_IntegerVector math_IntegerVector::Subtracted (const math_IntegerVector& theRight) const
-{
- Standard_DimensionError_Raise_if(Length() != theRight.Length(), " ");
-
- math_IntegerVector Result(Lower(), Upper());
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) - theRight.Array(I);
- I++;
- }
- return Result;
-}
-
-void math_IntegerVector::Add (const math_IntegerVector& theLeft, const math_IntegerVector& theRight)
-{
- Standard_DimensionError_Raise_if((Length() != theRight.Length()) ||
- (theRight.Length() != theLeft.Length()), " ");
-
- Standard_Integer I = theLeft.Lower();
- Standard_Integer J = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = theLeft.Array(I) + theRight.Array(J);
- I++;
- J++;
- }
-}
-
-void math_IntegerVector::Subtract (const math_IntegerVector& theLeft,
- const math_IntegerVector& theRight)
-{
- Standard_DimensionError_Raise_if((Length() != theRight.Length()) ||
- (theRight.Length() != theLeft.Length()), " ");
-
- Standard_Integer I = theLeft.Lower();
- Standard_Integer J = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = theLeft.Array(I) - theRight.Array(J);
- I++;
- J++;
- }
-}
-
-void math_IntegerVector::Multiply(const Standard_Integer theLeft, const math_IntegerVector& theRight)
-{
- Standard_DimensionError_Raise_if((Length() != theRight.Length()), " ");
- for(Standard_Integer I = Lower(); I <= Upper(); I++)
- {
- Array(I) = theLeft * theRight.Array(I);
- }
-}
-
-math_IntegerVector& math_IntegerVector::Initialized(const math_IntegerVector& theOther)
-{
- Standard_DimensionError_Raise_if(Length() != theOther.Length(), " ");
- memmove (&Array.ChangeFirst(), &theOther.Array.First(), sizeof(Standard_Integer) * Array.Length());
- return *this;
-}
-
-void math_IntegerVector::Dump(Standard_OStream& theO) const
-{
- theO << "math_IntegerVector of Range = " << Length() << "\n";
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- theO << "math_IntegerVector(" << Index << ") = " << Array(Index) << "\n";
- }
-}
#ifndef _math_IntegerVector_HeaderFile
#define _math_IntegerVector_HeaderFile
-#include <NCollection_Array1.hxx>
-#include <NCollection_LocalArray.hxx>
-
-// resolve name collisions with X11 headers
-#ifdef Opposite
- #undef Opposite
-#endif
+#include <math_VectorBase.hxx>
//! This class implements the real IntegerVector abstract data type.
//! IntegerVectors can have an arbitrary range which must be define at
//! V3 = V1; // --> will raise DimensionError;
//! V1.Add(V3) // --> will raise DimensionError;
//! @endcode
-class math_IntegerVector
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! constructs an IntegerVector in the range [Lower..Upper]
- Standard_EXPORT math_IntegerVector(const Standard_Integer theFirst, const Standard_Integer theLast);
-
- //! constructs an IntegerVector in the range [Lower..Upper]
- //! with all the elements set to theInitialValue.
- Standard_EXPORT math_IntegerVector(const Standard_Integer theFirst, const Standard_Integer theLast, const Standard_Integer theInitialValue);
-
- //! Initialize an IntegerVector with all the elements
- //! set to theInitialValue.
- Standard_EXPORT void Init(const Standard_Integer theInitialValue);
-
- //! constructs an IntegerVector in the range [Lower..Upper]
- //! which share the "c array" theTab.
- Standard_EXPORT math_IntegerVector(const Standard_Integer* theTab, const Standard_Integer theFirst, const Standard_Integer theLast);
-
- //! constructs a copy for initialization.
- //! An exception is raised if the lengths of the IntegerVectors
- //! are different.
- Standard_EXPORT math_IntegerVector(const math_IntegerVector& theOther);
-
- //! returns the length of an IntegerVector
- inline Standard_Integer Length() const
- {
- return Array.Length();
- }
-
- //! returns the value of the Lower index of an IntegerVector.
- inline Standard_Integer Lower() const
- {
- return Array.Lower();
- }
-
- //! returns the value of the Upper index of an IntegerVector.
- inline Standard_Integer Upper() const
- {
- return Array.Upper();
- }
-
- //! returns the value of the norm of an IntegerVector.
- Standard_EXPORT Standard_Real Norm() const;
-
- //! returns the value of the square of the norm of an IntegerVector.
- Standard_EXPORT Standard_Real Norm2() const;
-
- //! returns the value of the Index of the maximum element of an IntegerVector.
- Standard_EXPORT Standard_Integer Max() const;
-
- //! returns the value of the Index of the minimum element of an IntegerVector.
- Standard_EXPORT Standard_Integer Min() const;
-
- //! inverses an IntegerVector.
- Standard_EXPORT void Invert();
-
- //! returns the inverse IntegerVector of an IntegerVector.
- Standard_EXPORT math_IntegerVector Inverse() const;
-
- //! sets an IntegerVector from "theI1" to "theI2" to the IntegerVector "theV";
- //! An exception is raised if "theI1" is less than "LowerIndex" or "theI2" is greater than "UpperIndex" or "theI1" is greater than "theI2".
- //! An exception is raised if "theI2-theI1+1" is different from the Length of "theV".
- Standard_EXPORT void Set(const Standard_Integer theI1, const Standard_Integer theI2, const math_IntegerVector& theV);
-
- //! slices the values of the IntegerVector between "theI1" and "theI2":
- //! Example: [2, 1, 2, 3, 4, 5] becomes [2, 4, 3, 2, 1, 5] between 2 and 5.
- //! An exception is raised if "theI1" is less than "LowerIndex" or "theI2" is greater than "UpperIndex".
- Standard_EXPORT math_IntegerVector Slice(const Standard_Integer theI1, const Standard_Integer theI2) const;
-
- //! returns the product of an IntegerVector by an integer value.
- Standard_EXPORT void Multiply(const Standard_Integer theRight);
-
- void operator *=(const Standard_Integer theRight)
- {
- Multiply(theRight);
- }
-
- //! returns the product of an IntegerVector by an integer value.
- Standard_NODISCARD Standard_EXPORT math_IntegerVector Multiplied(const Standard_Integer theRight) const;
-
- Standard_NODISCARD math_IntegerVector operator*(const Standard_Integer theRight) const
- {
- return Multiplied(theRight);
- }
-
- //! returns the product of a vector and a real value.
- Standard_NODISCARD Standard_EXPORT math_IntegerVector TMultiplied(const Standard_Integer theRight) const;
-
- friend inline math_IntegerVector operator* (const Standard_Integer theLeft, const math_IntegerVector& theRight)
- {
- return theRight.Multiplied(theLeft);
- }
-
- //! adds the IntegerVector "theRight" to an IntegerVector.
- //! An exception is raised if the IntegerVectors have not the same length.
- //! An exception is raised if the lengths are not equal.
- Standard_EXPORT void Add(const math_IntegerVector& theRight);
-
- void operator +=(const math_IntegerVector& theRight)
- {
- Add(theRight);
- }
-
- //! adds the IntegerVector "theRight" to an IntegerVector.
- //! An exception is raised if the IntegerVectors have not the same length.
- //! An exception is raised if the lengths are not equal.
- Standard_NODISCARD Standard_EXPORT math_IntegerVector Added(const math_IntegerVector& theRight) const;
-
- Standard_NODISCARD math_IntegerVector operator+(const math_IntegerVector& theRight) const
- {
- return Added(theRight);
- }
-
- //! sets an IntegerVector to the sum of the IntegerVector
- //! "theLeft" and the IntegerVector "theRight".
- //! An exception is raised if the lengths are different.
- Standard_EXPORT void Add(const math_IntegerVector& theLeft, const math_IntegerVector& theRight);
-
- //! sets an IntegerVector to the substraction of "theRight" from "theLeft".
- //! An exception is raised if the IntegerVectors have not the same length.
- Standard_EXPORT void Subtract(const math_IntegerVector& theLeft, const math_IntegerVector& theRight);
-
- //! accesses the value of index theNum of an IntegerVector.
- const Standard_Integer& Value (const Standard_Integer theNum) const
- {
- return Array(theNum);
- }
-
- //! accesses (in read or write mode) the value of index theNum of an IntegerVector.
- inline Standard_Integer& Value (const Standard_Integer theNum)
- {
- return Array(theNum);
- }
-
- const Standard_Integer& operator()(const Standard_Integer theNum) const
- {
- return Value(theNum);
- }
-
- Standard_Integer& operator()(const Standard_Integer theNum)
- {
- return Value(theNum);
- }
-
- //! Initialises an IntegerVector by copying "theOther".
- //! An exception is raised if the Lengths are different.
- Standard_EXPORT math_IntegerVector& Initialized(const math_IntegerVector& theOther);
-
- math_IntegerVector& operator=(const math_IntegerVector& theOther)
- {
- return Initialized(theOther);
- }
-
- //! returns the inner product of 2 IntegerVectors.
- //! An exception is raised if the lengths are not equal.
- Standard_NODISCARD Standard_EXPORT Standard_Integer Multiplied(const math_IntegerVector& theRight) const;
-
- Standard_NODISCARD Standard_Integer operator*(const math_IntegerVector& theRight) const
- {
- return Multiplied(theRight);
- }
-
- //! returns the opposite of an IntegerVector.
- Standard_EXPORT math_IntegerVector Opposite();
-
- math_IntegerVector operator-()
- {
- return Opposite();
- }
-
- //! returns the subtraction of "theRight" from "me".
- //! An exception is raised if the IntegerVectors have not the same length.
- Standard_EXPORT void Subtract(const math_IntegerVector& theRight);
-
- void operator-=(const math_IntegerVector& theRight)
- {
- Subtract(theRight);
- }
-
- //! returns the subtraction of "theRight" from "me".
- //! An exception is raised if the IntegerVectors have not the same length.
- Standard_NODISCARD Standard_EXPORT math_IntegerVector Subtracted(const math_IntegerVector& theRight) const;
-
- Standard_NODISCARD math_IntegerVector operator-(const math_IntegerVector& theRight) const
- {
- return Subtracted(theRight);
- }
-
- //! returns the multiplication of an integer by an IntegerVector.
- Standard_EXPORT void Multiply(const Standard_Integer theLeft,const math_IntegerVector& theRight);
-
- //! Prints on the stream theO information on the current state of the object.
- //! Is used to redefine the operator <<.
- Standard_EXPORT void Dump(Standard_OStream& theO) const;
-
- friend inline Standard_OStream& operator<<(Standard_OStream& theO, const math_IntegerVector& theVec)
- {
- theVec.Dump(theO);
- return theO;
- }
-
-protected:
-
- //! is used internally to set the Lower value of the IntegerVector.
- void SetFirst(const Standard_Integer theFirst);
-
-private:
-
- NCollection_LocalArray<Standard_Integer, 512> myLocArray;
- NCollection_Array1<Standard_Integer> Array;
-
-};
+using math_IntegerVector = math_VectorBase<int>;
#endif
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <math_Matrix.hxx>
#include <math_Gauss.hxx>
-#include <math_Matrix.hxx>
+#include <math_IntegerVector.hxx>
#include <math_NotSquare.hxx>
#include <math_SingularMatrix.hxx>
#include <math_Vector.hxx>
return Result;
}
+//================================================================
+// Function : operator*
+// Purpose :
+//================================================================
+math_VectorBase<> math_Matrix::operator* (const math_VectorBase<>& Right) const
+{
+ return Multiplied(Right);
+}
+
math_Matrix& math_Matrix::Initialized(const math_Matrix& Other)
{
Standard_DimensionError_Raise_if ((RowNumber() != Other.RowNumber())
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
+#include <NCollection_Allocator.hxx>
#include <math_DoubleTab.hxx>
-#include <math_Vector.hxx>
#include <Standard_OStream.hxx>
// resolve name collisions with X11 headers
#undef Opposite
#endif
+template<typename T = double> class math_VectorBase;
+
//! This class implements the real matrix abstract data type.
//! Matrixes can have an arbitrary range which must be defined
//! at the declaration and cannot be changed after this declaration
DEFINE_STANDARD_ALLOC
+ friend class math_VectorBase<>;
//! Constructs a non-initialized matrix of range [LowerRow..UpperRow,
//! LowerCol..UpperCol]
//! An exception is raised if the dimensions are different.
//! An exception is raises if <Row> is inferior to the lower
//! row of the matrix or <Row> is superior to the upper row.
- Standard_EXPORT void SetRow (const Standard_Integer Row, const math_Vector& V);
+ Standard_EXPORT void SetRow (const Standard_Integer Row, const math_VectorBase<>& V);
//! Sets the column of index Col of a matrix to the vector <V>.
//! An exception is raised if the dimensions are different.
//! An exception is raises if <Col> is inferior to the lower
//! column of the matrix or <Col> is superior to the upper
//! column.
- Standard_EXPORT void SetCol (const Standard_Integer Col, const math_Vector& V);
+ Standard_EXPORT void SetCol (const Standard_Integer Col, const math_VectorBase<>& V);
//! Sets the diagonal of a matrix to the value <Value>.
//! An exception is raised if the matrix is not square.
Standard_EXPORT void SetDiag (const Standard_Real Value);
//! Returns the row of index Row of a matrix.
- Standard_EXPORT math_Vector Row (const Standard_Integer Row) const;
+ Standard_EXPORT math_VectorBase<> Row (const Standard_Integer Row) const;
//! Returns the column of index <Col> of a matrix.
- Standard_EXPORT math_Vector Col (const Standard_Integer Col) const;
+ Standard_EXPORT math_VectorBase<> Col (const Standard_Integer Col) const;
//! Swaps the rows of index Row1 and Row2.
//! An exception is raised if <Row1> or <Row2> is out of range.
//! Computes a matrix as the product of 2 vectors.
//! An exception is raised if the dimensions are different.
//! <me> = <Left> * <Right>.
- Standard_EXPORT void Multiply (const math_Vector& Left, const math_Vector& Right);
+ Standard_EXPORT void Multiply (const math_VectorBase<>& Left, const math_VectorBase<>& Right);
//! Computes a matrix as the product of 2 matrixes.
//! An exception is raised if the dimensions are different.
//! Returns the product of a matrix by a vector.
//! An exception is raised if the dimensions are different.
- Standard_NODISCARD Standard_EXPORT math_Vector Multiplied (const math_Vector& Right) const;
-Standard_NODISCARD math_Vector operator* (const math_Vector& Right) const
-{
- return Multiplied(Right);
-}
+ Standard_NODISCARD Standard_EXPORT math_VectorBase<> Multiplied (const math_VectorBase<>& Right) const;
+ Standard_NODISCARD Standard_EXPORT math_VectorBase<> operator* (const math_VectorBase<>& Right) const;
//! Returns the opposite of a matrix.
//! An exception is raised if the dimensions are different.
//! Is used to redefine the operator <<.
Standard_EXPORT void Dump (Standard_OStream& o) const;
-
-friend class math_Vector;
-
-
protected:
//! The new lower row of the matrix is set to <LowerRow>
//! and the new lower column of the matrix is set to the column
//! of range <LowerCol>.
- void SetLower (const Standard_Integer LowerRow, const Standard_Integer LowerCol);
+ void SetLower (const Standard_Integer LowerRow, const Standard_Integer LowerCol);
// lpa le 29/10/91
#include <Standard_DimensionError.hxx>
-#include <math_Vector.hxx>
inline Standard_OStream& operator<<(Standard_OStream& o,
const math_Matrix& mat)
#include <Message_ProgressRange.hxx>
-class math_IntegerVector;
-class math_Vector;
+#include <NCollection_Allocator.hxx>
+
+template<typename T> class math_VectorBase;
+using math_IntegerVector = math_VectorBase<int>;
+using math_Vector = math_VectorBase<double>;
class math_Matrix;
const Standard_Integer math_Status_UserAborted = -1;
+++ /dev/null
-// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-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 <stdio.h>
-
-#include <math_Vector.hxx>
-#include <math_Matrix.hxx>
-
-#include <Standard_DimensionError.hxx>
-#include <Standard_DivideByZero.hxx>
-#include <Standard_RangeError.hxx>
-#include <Standard_NullValue.hxx>
-
-math_Vector::math_Vector(const Standard_Integer theLower, const Standard_Integer theUpper)
-: myLocArray (theUpper - theLower + 1),
- Array (myLocArray[0], theLower, theUpper)
-{
- //
-}
-
-math_Vector::math_Vector(const Standard_Integer theLower,
- const Standard_Integer theUpper,
- const Standard_Real theInitialValue)
-: myLocArray (theUpper - theLower + 1),
- Array (myLocArray[0], theLower, theUpper)
-{
- Array.Init(theInitialValue);
-}
-
-math_Vector::math_Vector(const Standard_Real* theTab,
- const Standard_Integer theLower,
- const Standard_Integer theUpper)
-: Array (*theTab, theLower, theUpper)
-{
- Standard_RangeError_Raise_if ((theLower > theUpper), "math_Vector() - invalid dimensions");
-}
-
-math_Vector::math_Vector (const gp_XY& theOther)
-: myLocArray (2),
- Array (myLocArray[0], 1,2)
-{
- Array(1) = theOther.X();
- Array(2) = theOther.Y();
-}
-
-math_Vector::math_Vector (const gp_XYZ& theOther)
-: myLocArray (3),
- Array (myLocArray[0], 1, 3)
-{
- Array(1) = theOther.X();
- Array(2) = theOther.Y();
- Array(3) = theOther.Z();
-}
-
-void math_Vector::Init(const Standard_Real theInitialValue)
-{
- Array.Init(theInitialValue);
-}
-
-math_Vector::math_Vector (const math_Vector& theOther)
-: myLocArray (theOther.Length()),
- Array (myLocArray[0], theOther.Lower(), theOther.Upper())
-{
- memcpy (&myLocArray[0], &theOther.Array.First(), sizeof(Standard_Real) * theOther.Length());
-}
-
-void math_Vector::SetLower(const Standard_Integer theLower)
-{
- Array.Resize (theLower, Array.Upper() - Array.Lower() + theLower, Standard_False);
-}
-
-Standard_Real math_Vector::Norm() const
-{
- Standard_Real Result = 0;
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result = Result + Array(Index) * Array(Index);
- }
- return Sqrt(Result);
-}
-
-Standard_Real math_Vector::Norm2() const
-{
- Standard_Real Result = 0;
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result = Result + Array(Index) * Array(Index);
- }
- return Result;
-}
-
-Standard_Integer math_Vector::Max() const
-{
- Standard_Integer I=0;
- Standard_Real X = RealFirst();
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- if(Array(Index) > X)
- {
- X = Array(Index);
- I = Index;
- }
- }
- return I;
-}
-
-Standard_Integer math_Vector::Min() const
-{
- Standard_Integer I=0;
- Standard_Real X = RealLast();
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- if(Array(Index) < X)
- {
- X = Array(Index);
- I = Index;
- }
- }
- return I;
-}
-
-void math_Vector::Set(const Standard_Integer theI1,
- const Standard_Integer theI2,
- const math_Vector &theV)
-{
- Standard_RangeError_Raise_if ((theI1 < Lower()) || (theI2 > Upper())
- || (theI1 > theI2) || (theI2 - theI1 + 1 != theV.Length()),
- "math_Vector::Set() - invalid indices");
-
- Standard_Integer I = theV.Lower();
- for(Standard_Integer Index = theI1; Index <= theI2; Index++)
- {
- Array(Index) = theV.Array(I);
- I++;
- }
-}
-
-void math_Vector::Normalize()
-{
- Standard_Real Result = Norm();
- Standard_NullValue_Raise_if ((Result <= RealEpsilon()),
- "math_Vector::Normalize() - vector has zero norm");
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) / Result;
- }
-}
-
-math_Vector math_Vector::Normalized() const
-{
- math_Vector Result = *this;
-
- Result.Normalize();
- return Result;
-}
-
-void math_Vector::Invert()
-{
- for(Standard_Integer Index = Lower(); Index <= (Lower() + Length()) >> 1 ; Index++)
- {
- Standard_Integer J = Upper() + Lower() - Index;
- Standard_Real aTemp = Array(Index);
- Array(Index) = Array(J);
- Array(J) = aTemp;
- }
-}
-
-math_Vector math_Vector::Inverse() const
-{
- math_Vector Result = *this;
- Result.Invert();
- return Result;
-}
-
-math_Vector math_Vector::Multiplied(const Standard_Real theRight) const
-{
- math_Vector Result (Lower(), Upper());
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) * theRight;
- }
- return Result;
-}
-
-math_Vector math_Vector::TMultiplied(const Standard_Real theRight) const
-{
- math_Vector Result (Lower(), Upper());
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) * theRight;
- }
- return Result;
-}
-
-void math_Vector::Multiply(const Standard_Real theRight)
-{
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) * theRight;
- }
-}
-
-void math_Vector::Divide(const Standard_Real theRight)
-{
- Standard_DivideByZero_Raise_if (Abs(theRight) <= RealEpsilon(),
- "math_Vector::Divide() - devisor is zero");
-
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) / theRight;
- }
-}
-
-math_Vector math_Vector::Divided (const Standard_Real theRight) const
-{
- Standard_DivideByZero_Raise_if (Abs(theRight) <= RealEpsilon(),
- "math_Vector::Divided() - devisor is zero");
- math_Vector temp = Multiplied(1./theRight);
- return temp;
-}
-
-void math_Vector::Add(const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if (Length() != theRight.Length(),
- "math_Vector::Add() - input vector has wrong dimensions");
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) + theRight.Array(I);
- I++;
- }
-}
-
-math_Vector math_Vector::Added(const math_Vector& theRight) const
-{
- Standard_DimensionError_Raise_if (Length() != theRight.Length(),
- "math_Vector::Added() - input vector has wrong dimensions");
-
- math_Vector Result (Lower(), Upper());
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) + theRight.Array(I);
- I++;
- }
- return Result;
-}
-
-void math_Vector::Subtract(const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if (Length() != theRight.Length(),
- "math_Vector::Subtract() - input vector has wrong dimensions");
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = Array(Index) - theRight.Array(I);
- I++;
- }
-}
-
-math_Vector math_Vector::Subtracted (const math_Vector& theRight) const
-{
- Standard_DimensionError_Raise_if (Length() != theRight.Length(),
- "math_Vector::Subtracted() - input vector has wrong dimensions");
-
- math_Vector Result(Lower(), Upper());
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = Array(Index) - theRight.Array(I);
- I++;
- }
- return Result;
-}
-
-math_Vector math_Vector::Slice(const Standard_Integer theI1, const Standard_Integer theI2) const
-{
- Standard_RangeError_Raise_if ((theI1 < Lower()) || (theI1 > Upper()) || (theI2 < Lower()) || (theI2 > Upper()),
- "math_Vector::Slice() - invalid indices");
-
- if(theI2 >= theI1)
- {
- math_Vector Result(theI1, theI2);
- for(Standard_Integer Index = theI1; Index <= theI2; Index++)
- {
- Result.Array(Index) = Array(Index);
- }
- return Result;
- }
- else
- {
- math_Vector Result(theI2, theI1);
- for(Standard_Integer Index = theI1; Index >= theI2; Index--)
- {
- Result.Array(Index) = Array(Index);
- }
- return Result;
- }
-}
-
-void math_Vector::Add (const math_Vector& theLeft, const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theRight.Length()) || (theRight.Length() != theLeft.Length()),
- "math_Vector::Add() - input vectors have wrong dimensions");
-
- Standard_Integer I = theLeft.Lower();
- Standard_Integer J = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = theLeft.Array(I) + theRight.Array(J);
- I++;
- J++;
- }
-}
-
-void math_Vector::Subtract (const math_Vector& theLeft, const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theRight.Length()) || (theRight.Length() != theLeft.Length()),
- "math_Vector::Subtract() - input vectors have wrong dimensions");
-
- Standard_Integer I = theLeft.Lower();
- Standard_Integer J = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Array(Index) = theLeft.Array(I) - theRight.Array(J);
- I++;
- J++;
- }
-}
-
-void math_Vector::Multiply(const math_Matrix& theLeft, const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theLeft.RowNumber())
- || (theLeft.ColNumber() != theRight.Length()),
- "math_Vector::Multiply() - input matrix and/or vector have wrong dimensions");
-
- Standard_Integer Index = Lower();
- for(Standard_Integer I = theLeft.LowerRowIndex; I <= theLeft.UpperRowIndex; I++)
- {
- Array(Index) = 0.0;
- Standard_Integer K = theRight.Lower();
- for(Standard_Integer J = theLeft.LowerColIndex; J <= theLeft.UpperColIndex; J++)
- {
- Array(Index) = Array(Index) + theLeft.Array(I, J) * theRight.Array(K);
- K++;
- }
- Index++;
- }
-}
-
-void math_Vector::Multiply(const math_Vector& theLeft, const math_Matrix& theRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theRight.ColNumber())
- || (theLeft.Length() != theRight.RowNumber()),
- "math_Vector::Multiply() - input matrix and/or vector have wrong dimensions");
-
- Standard_Integer Index = Lower();
- for(Standard_Integer J = theRight.LowerColIndex; J <= theRight.UpperColIndex; J++)
- {
- Array(Index) = 0.0;
- Standard_Integer K = theLeft.Lower();
- for(Standard_Integer I = theRight.LowerRowIndex; I <= theRight.UpperRowIndex; I++)
- {
- Array(Index) = Array(Index) + theLeft.Array(K) * theRight.Array(I, J);
- K++;
- }
- Index++;
- }
-}
-
-void math_Vector::TMultiply(const math_Matrix& theTLeft, const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theTLeft.ColNumber())
- || (theTLeft.RowNumber() != theRight.Length()),
- "math_Vector::TMultiply() - input matrix and/or vector have wrong dimensions");
-
- Standard_Integer Index = Lower();
- for(Standard_Integer I = theTLeft.LowerColIndex; I <= theTLeft.UpperColIndex; I++)
- {
- Array(Index) = 0.0;
- Standard_Integer K = theRight.Lower();
- for(Standard_Integer J = theTLeft.LowerRowIndex; J <= theTLeft.UpperRowIndex; J++)
- {
- Array(Index) = Array(Index) + theTLeft.Array(J, I) * theRight.Array(K);
- K++;
- }
- Index++;
- }
-}
-
-void math_Vector::TMultiply(const math_Vector& theLeft, const math_Matrix& theTRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theTRight.RowNumber())
- || (theLeft.Length() != theTRight.ColNumber()),
- "math_Vector::TMultiply() - input matrix and/or vector have wrong dimensions");
-
- Standard_Integer Index = Lower();
- for(Standard_Integer J = theTRight.LowerRowIndex; J <= theTRight.UpperRowIndex; J++)
- {
- Array(Index) = 0.0;
- Standard_Integer K = theLeft.Lower();
- for(Standard_Integer I = theTRight.LowerColIndex;
- I <= theTRight.UpperColIndex; I++)
- {
- Array(Index) = Array(Index) + theLeft.Array(K) * theTRight.Array(J, I);
- K++;
- }
- Index++;
- }
-}
-
-Standard_Real math_Vector::Multiplied(const math_Vector& theRight) const
-{
- Standard_Real Result = 0;
-
- Standard_DimensionError_Raise_if (Length() != theRight.Length(),
- "math_Vector::Multiplied() - input vector has wrong dimensions");
-
- Standard_Integer I = theRight.Lower();
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result = Result + Array(Index) * theRight.Array(I);
- I++;
- }
- return Result;
-}
-
-math_Vector math_Vector::Opposite()
-{
- math_Vector Result(Lower(), Upper());
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- Result.Array(Index) = - Array(Index);
- }
- return Result;
-}
-
-math_Vector math_Vector::Multiplied(const math_Matrix& theRight)const
-{
- Standard_DimensionError_Raise_if (Length() != theRight.RowNumber(),
- "math_Vector::Multiplied() - input matrix has wrong dimensions");
-
- math_Vector Result(theRight.LowerColIndex, theRight.UpperColIndex);
- for(Standard_Integer J2 = theRight.LowerColIndex; J2 <= theRight.UpperColIndex; J2++)
- {
- Result.Array(J2) = 0.0;
- Standard_Integer theI2 = theRight.LowerRowIndex;
- for(Standard_Integer I = Lower(); I <= Upper(); I++)
- {
- Result.Array(J2) = Result.Array(J2) + Array(I) * theRight.Array(theI2, J2);
- theI2++;
- }
- }
- return Result;
-}
-
-void math_Vector::Multiply(const Standard_Real theLeft, const math_Vector& theRight)
-{
- Standard_DimensionError_Raise_if ((Length() != theRight.Length()),
- "math_Vector::Multiply() - input vector has wrong dimensions");
- for(Standard_Integer I = Lower(); I <= Upper(); I++)
- {
- Array(I) = theLeft * theRight.Array(I);
- }
-}
-
-math_Vector& math_Vector::Initialized(const math_Vector& theOther)
-{
- Standard_DimensionError_Raise_if (Length() != theOther.Length(),
- "math_Vector::Initialized() - input vector has wrong dimensions");
- memmove (&Array.ChangeFirst(), &theOther.Array.First(), sizeof(Standard_Real) * Array.Length());
- return *this;
-}
-
-void math_Vector::Dump(Standard_OStream& theO) const
-{
- theO << "math_Vector of Length = " << Length() << "\n";
- for(Standard_Integer Index = Lower(); Index <= Upper(); Index++)
- {
- theO << "math_Vector(" << Index << ") = " << Array(Index) << "\n";
- }
-}
-
#ifndef _math_Vector_HeaderFile
#define _math_Vector_HeaderFile
-#include <NCollection_Array1.hxx>
-#include <NCollection_LocalArray.hxx>
-#include <gp_XY.hxx>
-#include <gp_XYZ.hxx>
-
-// resolve name collisions with X11 headers
-#ifdef Opposite
- #undef Opposite
-#endif
-
-class math_Matrix;
+#include <math_VectorBase.hxx>
//! This class implements the real vector abstract data type.
//! Vectors can have an arbitrary range which must be defined at
//! V3 = V1; // --> will raise DimensionError;
//! V1.Add(V3) // --> will raise DimensionError;
//! @endcode
-class math_Vector
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Constructs a non-initialized vector in the range [theLower..theUpper]
- //! "theLower" and "theUpper" are the indexes of the lower and upper bounds of the constructed vector.
- Standard_EXPORT math_Vector(const Standard_Integer theLower, const Standard_Integer theUpper);
-
- //! Constructs a vector in the range [theLower..theUpper]
- //! whose values are all initialized with the value "theInitialValue"
- Standard_EXPORT math_Vector(const Standard_Integer theLower, const Standard_Integer theUpper, const Standard_Real theInitialValue);
-
- //! Constructs a vector in the range [theLower..theUpper]
- //! with the "c array" theTab.
- Standard_EXPORT math_Vector(const Standard_Real* theTab, const Standard_Integer theLower, const Standard_Integer theUpper);
-
- //! Constructor for converting gp_XY to math_Vector
- Standard_EXPORT math_Vector(const gp_XY& Other);
-
- //! Constructor for converting gp_XYZ to math_Vector
- Standard_EXPORT math_Vector(const gp_XYZ& Other);
-
- //! Initialize all the elements of a vector with "theInitialValue".
- Standard_EXPORT void Init(const Standard_Real theInitialValue);
-
- //! Constructs a copy for initialization.
- //! An exception is raised if the lengths of the vectors are different.
- Standard_EXPORT math_Vector(const math_Vector& theOther);
-
- //! Returns the length of a vector
- inline Standard_Integer Length() const
- {
- return Array.Length();
- }
-
- //! Returns the value of the theLower index of a vector.
- inline Standard_Integer Lower() const
- {
- return Array.Lower();
- }
-
- //! Returns the value of the theUpper index of a vector.
- inline Standard_Integer Upper() const
- {
- return Array.Upper();
- }
-
- //! Returns the value or the square of the norm of this vector.
- Standard_EXPORT Standard_Real Norm() const;
-
- //! Returns the value of the square of the norm of a vector.
- Standard_EXPORT Standard_Real Norm2() const;
-
- //! Returns the value of the "Index" of the maximum element of a vector.
- Standard_EXPORT Standard_Integer Max() const;
-
- //! Returns the value of the "Index" of the minimum element of a vector.
- Standard_EXPORT Standard_Integer Min() const;
-
- //! Normalizes this vector (the norm of the result
- //! is equal to 1.0) and assigns the result to this vector
- //! Exceptions
- //! Standard_NullValue if this vector is null (i.e. if its norm is
- //! less than or equal to Standard_Real::RealEpsilon().
- Standard_EXPORT void Normalize();
-
- //! Normalizes this vector (the norm of the result
- //! is equal to 1.0) and creates a new vector
- //! Exceptions
- //! Standard_NullValue if this vector is null (i.e. if its norm is
- //! less than or equal to Standard_Real::RealEpsilon().
- Standard_NODISCARD Standard_EXPORT math_Vector Normalized() const;
-
- //! Inverts this vector and assigns the result to this vector.
- Standard_EXPORT void Invert();
-
- //! Inverts this vector and creates a new vector.
- Standard_EXPORT math_Vector Inverse() const;
-
- //! sets a vector from "theI1" to "theI2" to the vector "theV";
- //! An exception is raised if "theI1" is less than "LowerIndex" or "theI2" is greater than "UpperIndex" or "theI1" is greater than "theI2".
- //! An exception is raised if "theI2-theI1+1" is different from the "Length" of "theV".
- Standard_EXPORT void Set(const Standard_Integer theI1, const Standard_Integer theI2, const math_Vector& theV);
-
- //!Creates a new vector by inverting the values of this vector
- //! between indexes "theI1" and "theI2".
- //! If the values of this vector were (1., 2., 3., 4.,5., 6.),
- //! by slicing it between indexes 2 and 5 the values
- //! of the resulting vector are (1., 5., 4., 3., 2., 6.)
- Standard_EXPORT math_Vector Slice(const Standard_Integer theI1, const Standard_Integer theI2) const;
-
- //! returns the product of a vector and a real value.
- Standard_EXPORT void Multiply(const Standard_Real theRight);
-
- void operator *=(const Standard_Real theRight)
- {
- Multiply(theRight);
- }
-
- //! returns the product of a vector and a real value.
- Standard_NODISCARD Standard_EXPORT math_Vector Multiplied(const Standard_Real theRight) const;
-
- Standard_NODISCARD math_Vector operator*(const Standard_Real theRight) const
- {
- return Multiplied(theRight);
- }
-
- //! returns the product of a vector and a real value.
- Standard_NODISCARD Standard_EXPORT math_Vector TMultiplied(const Standard_Real theRight) const;
-
- friend inline math_Vector operator* (const Standard_Real theLeft, const math_Vector& theRight)
- {
- return theRight.Multiplied(theLeft);
- }
-
- //! divides a vector by the value "theRight".
- //! An exception is raised if "theRight" = 0.
- Standard_EXPORT void Divide(const Standard_Real theRight);
-
- void operator /=(const Standard_Real theRight)
- {
- Divide(theRight);
- }
-
- //! divides a vector by the value "theRight".
- //! An exception is raised if "theRight" = 0.
- Standard_NODISCARD Standard_EXPORT math_Vector Divided(const Standard_Real theRight) const;
-
- Standard_NODISCARD math_Vector operator/(const Standard_Real theRight) const
- {
- return Divided(theRight);
- }
-
- //! adds the vector "theRight" to a vector.
- //! An exception is raised if the vectors have not the same length.
- //! Warning
- //! In order to avoid time-consuming copying of vectors, it
- //! is preferable to use operator += or the function Add whenever possible.
- Standard_EXPORT void Add(const math_Vector& theRight);
-
- void operator +=(const math_Vector& theRight)
- {
- Add(theRight);
- }
-
- //! adds the vector theRight to a vector.
- //! An exception is raised if the vectors have not the same length.
- //! An exception is raised if the lengths are not equal.
- Standard_NODISCARD Standard_EXPORT math_Vector Added(const math_Vector& theRight) const;
-
- Standard_NODISCARD math_Vector operator+(const math_Vector& theRight) const
- {
- return Added(theRight);
- }
-
- //! sets a vector to the product of the vector "theLeft"
- //! with the matrix "theRight".
- Standard_EXPORT void Multiply(const math_Vector& theLeft, const math_Matrix& theRight);
-
- //!sets a vector to the product of the matrix "theLeft"
- //! with the vector "theRight".
- Standard_EXPORT void Multiply(const math_Matrix& theLeft, const math_Vector& theRight);
-
- //! sets a vector to the product of the transpose
- //! of the matrix "theTLeft" by the vector "theRight".
- Standard_EXPORT void TMultiply(const math_Matrix& theTLeft, const math_Vector& theRight);
-
- //! sets a vector to the product of the vector
- //! "theLeft" by the transpose of the matrix "theTRight".
- Standard_EXPORT void TMultiply(const math_Vector& theLeft, const math_Matrix& theTRight);
-
- //! sets a vector to the sum of the vector "theLeft"
- //! and the vector "theRight".
- //! An exception is raised if the lengths are different.
- Standard_EXPORT void Add(const math_Vector& theLeft, const math_Vector& theRight);
-
- //! sets a vector to the Subtraction of the
- //! vector theRight from the vector theLeft.
- //! An exception is raised if the vectors have not the same length.
- //! Warning
- //! In order to avoid time-consuming copying of vectors, it
- //! is preferable to use operator -= or the function
- //! Subtract whenever possible.
- Standard_EXPORT void Subtract(const math_Vector& theLeft,const math_Vector& theRight);
-
- //! accesses the value of index "theNum" of a vector.
- const Standard_Real& Value (const Standard_Integer theNum) const
- {
- return Array(theNum);
- }
-
- //! accesses (in read or write mode) the value of index "theNum" of a vector.
- inline Standard_Real& Value (const Standard_Integer theNum)
- {
- return Array(theNum);
- }
-
- const Standard_Real& operator()(const Standard_Integer theNum) const
- {
- return Value(theNum);
- }
-
- Standard_Real& operator()(const Standard_Integer theNum)
- {
- return Value(theNum);
- }
-
- //! Initialises a vector by copying "theOther".
- //! An exception is raised if the Lengths are different.
- Standard_EXPORT math_Vector& Initialized(const math_Vector& theOther);
-
- math_Vector& operator=(const math_Vector& theOther)
- {
- return Initialized(theOther);
- }
-
- //! returns the inner product of 2 vectors.
- //! An exception is raised if the lengths are not equal.
- Standard_NODISCARD Standard_EXPORT Standard_Real Multiplied(const math_Vector& theRight) const;
- Standard_NODISCARD Standard_Real operator*(const math_Vector& theRight) const
- {
- return Multiplied(theRight);
- }
-
- //! returns the product of a vector by a matrix.
- Standard_NODISCARD Standard_EXPORT math_Vector Multiplied(const math_Matrix& theRight) const;
-
- Standard_NODISCARD math_Vector operator*(const math_Matrix& theRight) const
- {
- return Multiplied(theRight);
- }
-
- //! returns the opposite of a vector.
- Standard_EXPORT math_Vector Opposite();
-
- math_Vector operator-()
- {
- return Opposite();
- }
-
- //! returns the subtraction of "theRight" from "me".
- //! An exception is raised if the vectors have not the same length.
- Standard_EXPORT void Subtract(const math_Vector& theRight);
-
- void operator-=(const math_Vector& theRight)
- {
- Subtract(theRight);
- }
-
- //! returns the subtraction of "theRight" from "me".
- //! An exception is raised if the vectors have not the same length.
- Standard_NODISCARD Standard_EXPORT math_Vector Subtracted(const math_Vector& theRight) const;
-
- Standard_NODISCARD math_Vector operator-(const math_Vector& theRight) const
- {
- return Subtracted(theRight);
- }
-
- //! returns the multiplication of a real by a vector.
- //! "me" = "theLeft" * "theRight"
- Standard_EXPORT void Multiply(const Standard_Real theLeft,const math_Vector& theRight);
-
- //! Prints information on the current state of the object.
- //! Is used to redefine the operator <<.
- Standard_EXPORT void Dump(Standard_OStream& theO) const;
-
- friend inline Standard_OStream& operator<<(Standard_OStream& theO, const math_Vector& theVec)
- {
- theVec.Dump(theO);
- return theO;
- }
-
- friend class math_Matrix;
-
-protected:
-
- //! Is used internally to set the "theLower" value of the vector.
- void SetLower(const Standard_Integer theLower);
-
-private:
-
- NCollection_LocalArray<Standard_Real, 512> myLocArray;
- NCollection_Array1<Standard_Real> Array;
-
-};
+using math_Vector = math_VectorBase<double>;
#endif
--- /dev/null
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2023 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 _math_VectorBase_HeaderFile
+#define _math_VectorBase_HeaderFile
+
+#include <NCollection_Array1.hxx>
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
+
+// resolve name collisions with X11 headers
+#ifdef Opposite
+#undef Opposite
+#endif
+
+#include <math_Matrix.hxx>
+
+#include <array>
+
+//! This class implements the real vector abstract data type.
+//! Vectors can have an arbitrary range which must be defined at
+//! the declaration and cannot be changed after this declaration.
+//! @code
+//! math_VectorBase<TheItemType> V1(-3, 5); // a vector with range [-3..5]
+//! @endcode
+//!
+//! Vector are copied through assignment:
+//! @code
+//! math_VectorBase<TheItemType> V2( 1, 9);
+//! ....
+//! V2 = V1;
+//! V1(1) = 2.0; // the vector V2 will not be modified.
+//! @endcode
+//!
+//! The Exception RangeError is raised when trying to access outside
+//! the range of a vector :
+//! @code
+//! V1(11) = 0.0 // --> will raise RangeError;
+//! @endcode
+//!
+//! The Exception DimensionError is raised when the dimensions of two
+//! vectors are not compatible :
+//! @code
+//! math_VectorBase<TheItemType> V3(1, 2);
+//! V3 = V1; // --> will raise DimensionError;
+//! V1.Add(V3) // --> will raise DimensionError;
+//! @endcode
+template<typename TheItemType>
+class math_VectorBase
+{
+ static const int THE_BUFFER_SIZE = 32;
+
+public:
+ //! Memory allocation
+ DEFINE_STANDARD_ALLOC;
+ DEFINE_NCOLLECTION_ALLOC;
+public:
+
+ //! Constructs a non-initialized vector in the range [theLower..theUpper]
+ //! "theLower" and "theUpper" are the indexes of the lower and upper bounds of the constructed vector.
+ inline math_VectorBase(const Standard_Integer theLower, const Standard_Integer theUpper);
+
+ //! Constructs a vector in the range [theLower..theUpper]
+ //! whose values are all initialized with the value "theInitialValue"
+ inline math_VectorBase(const Standard_Integer theLower, const Standard_Integer theUpper, const TheItemType theInitialValue);
+
+ //! Constructs a vector in the range [theLower..theUpper]
+ //! whose values are all initialized with the value "theInitialValue"
+ inline math_VectorBase(const TheItemType* theTab, const Standard_Integer theLower, const Standard_Integer theUpper);
+
+ //! Constructor for converting gp_XY to math_VectorBase
+ inline math_VectorBase(const gp_XY& Other);
+
+ //! Constructor for converting gp_XYZ to math_VectorBase
+ inline math_VectorBase(const gp_XYZ& Other);
+
+ //! Initialize all the elements of a vector with "theInitialValue".
+ void Init(const TheItemType theInitialValue);
+
+ //! Constructs a copy for initialization.
+ //! An exception is raised if the lengths of the vectors are different.
+ inline math_VectorBase(const math_VectorBase& theOther);
+
+ //! Returns the length of a vector
+ inline Standard_Integer Length() const
+ {
+ return Array.Length();
+ }
+
+ //! Returns the lower index of the vector
+ inline Standard_Integer Lower() const
+ {
+ return Array.Lower();
+ }
+
+ //! Returns the upper index of the vector
+ inline Standard_Integer Upper() const
+ {
+ return Array.Upper();
+ }
+
+ //! Returns the value or the square of the norm of this vector.
+ inline Standard_Real Norm() const;
+
+ //! Returns the value of the square of the norm of a vector.
+ inline Standard_Real Norm2() const;
+
+ //! Returns the index of the maximum element of a vector. (first found)
+ inline Standard_Integer Max() const;
+
+ //! Returns the index of the minimum element of a vector. (first found)
+ inline Standard_Integer Min() const;
+
+ //! Normalizes this vector (the norm of the result
+ //! is equal to 1.0) and assigns the result to this vector
+ //! Exceptions
+ //! Standard_NullValue if this vector is null (i.e. if its norm is
+ //! less than or equal to Standard_Real::RealEpsilon().
+ inline void Normalize();
+
+ //! Normalizes this vector (the norm of the result
+ //! is equal to 1.0) and creates a new vector
+ //! Exceptions
+ //! Standard_NullValue if this vector is null (i.e. if its norm is
+ //! less than or equal to Standard_Real::RealEpsilon().
+ Standard_NODISCARD inline math_VectorBase Normalized() const;
+
+ //! Inverts this vector and assigns the result to this vector.
+ inline void Invert();
+
+ //! Inverts this vector and creates a new vector.
+ inline math_VectorBase Inverse() const;
+
+ //! sets a vector from "theI1" to "theI2" to the vector "theV";
+ //! An exception is raised if "theI1" is less than "LowerIndex" or "theI2" is greater than "UpperIndex" or "theI1" is greater than "theI2".
+ //! An exception is raised if "theI2-theI1+1" is different from the "Length" of "theV".
+ inline void Set(const Standard_Integer theI1, const Standard_Integer theI2, const math_VectorBase& theV);
+
+ //!Creates a new vector by inverting the values of this vector
+ //! between indexes "theI1" and "theI2".
+ //! If the values of this vector were (1., 2., 3., 4.,5., 6.),
+ //! by slicing it between indexes 2 and 5 the values
+ //! of the resulting vector are (1., 5., 4., 3., 2., 6.)
+ inline math_VectorBase Slice(const Standard_Integer theI1, const Standard_Integer theI2) const;
+
+ //! Updates current vector by multiplying each element on current value.
+ inline void Multiply(const TheItemType theRight);
+
+ void operator *=(const TheItemType theRight)
+ {
+ Multiply(theRight);
+ }
+
+ //! returns the product of a vector and a real value.
+ Standard_NODISCARD inline math_VectorBase Multiplied(const TheItemType theRight) const;
+
+ Standard_NODISCARD math_VectorBase operator*(const TheItemType theRight) const
+ {
+ return Multiplied(theRight);
+ }
+
+ //! returns the product of a vector and a real value.
+ Standard_NODISCARD inline math_VectorBase TMultiplied(const TheItemType theRight) const;
+
+ friend inline math_VectorBase operator* (const TheItemType theLeft, const math_VectorBase& theRight)
+ {
+ return theRight.Multiplied(theLeft);
+ }
+
+ //! divides a vector by the value "theRight".
+ //! An exception is raised if "theRight" = 0.
+ inline void Divide(const TheItemType theRight);
+
+ void operator /=(const TheItemType theRight)
+ {
+ Divide(theRight);
+ }
+
+ //! Returns new vector as dividing current vector with the value "theRight".
+ //! An exception is raised if "theRight" = 0.
+ Standard_NODISCARD inline math_VectorBase Divided(const TheItemType theRight) const;
+
+ Standard_NODISCARD math_VectorBase operator/(const TheItemType theRight) const
+ {
+ return Divided(theRight);
+ }
+
+ //! adds the vector "theRight" to a vector.
+ //! An exception is raised if the vectors have not the same length.
+ //! Warning
+ //! In order to avoid time-consuming copying of vectors, it
+ //! is preferable to use operator += or the function Add whenever possible.
+ inline void Add(const math_VectorBase& theRight);
+
+ void operator +=(const math_VectorBase& theRight)
+ {
+ Add(theRight);
+ }
+
+ //! Returns new vector as adding curent vector with the value "theRight".
+ //! An exception is raised if the vectors have not the same length.
+ //! An exception is raised if the lengths are not equal.
+ Standard_NODISCARD inline math_VectorBase Added(const math_VectorBase& theRight) const;
+
+ Standard_NODISCARD math_VectorBase operator+(const math_VectorBase& theRight) const
+ {
+ return Added(theRight);
+ }
+
+ //! sets a vector to the product of the vector "theLeft"
+ //! with the matrix "theRight".
+ inline void Multiply(const math_VectorBase& theLeft, const math_Matrix& theRight);
+
+ //!sets a vector to the product of the matrix "theLeft"
+ //! with the vector "theRight".
+ inline void Multiply(const math_Matrix& theLeft, const math_VectorBase& theRight);
+
+ //! sets a vector to the product of the transpose
+ //! of the matrix "theTLeft" by the vector "theRight".
+ inline void TMultiply(const math_Matrix& theTLeft, const math_VectorBase& theRight);
+
+ //! sets a vector to the product of the vector
+ //! "theLeft" by the transpose of the matrix "theTRight".
+ inline void TMultiply(const math_VectorBase& theLeft, const math_Matrix& theTRight);
+
+ //! sets a vector to the sum of the vector "theLeft"
+ //! and the vector "theRight".
+ //! An exception is raised if the lengths are different.
+ inline void Add(const math_VectorBase& theLeft, const math_VectorBase& theRight);
+
+ //! sets a vector to the Subtraction of the
+ //! vector theRight from the vector theLeft.
+ //! An exception is raised if the vectors have not the same length.
+ //! Warning
+ //! In order to avoid time-consuming copying of vectors, it
+ //! is preferable to use operator -= or the function
+ //! Subtract whenever possible.
+ inline void Subtract(const math_VectorBase& theLeft, const math_VectorBase& theRight);
+
+ //! accesses the value of index "theNum" of a vector.
+ const TheItemType& Value(const Standard_Integer theNum) const
+ {
+ return Array(theNum);
+ }
+
+ //! accesses (in read or write mode) the value of index "theNum" of a vector.
+ inline TheItemType& Value(const Standard_Integer theNum)
+ {
+ return Array(theNum);
+ }
+
+ const TheItemType& operator()(const Standard_Integer theNum) const
+ {
+ return Value(theNum);
+ }
+
+ TheItemType& operator()(const Standard_Integer theNum)
+ {
+ return Value(theNum);
+ }
+
+ //! Initialises a vector by copying "theOther".
+ //! An exception is raised if the Lengths are different.
+ inline math_VectorBase& Initialized(const math_VectorBase& theOther);
+
+ math_VectorBase& operator=(const math_VectorBase& theOther)
+ {
+ return Initialized(theOther);
+ }
+
+ //! returns the inner product of 2 vectors.
+ //! An exception is raised if the lengths are not equal.
+ Standard_NODISCARD inline TheItemType Multiplied(const math_VectorBase& theRight) const;
+ Standard_NODISCARD inline TheItemType operator*(const math_VectorBase& theRight) const
+ {
+ return Multiplied(theRight);
+ }
+
+ //! returns the product of a vector by a matrix.
+ Standard_NODISCARD inline math_VectorBase Multiplied(const math_Matrix& theRight) const;
+
+ Standard_NODISCARD math_VectorBase operator*(const math_Matrix& theRight) const
+ {
+ return Multiplied(theRight);
+ }
+
+ //! returns the opposite of a vector.
+ inline math_VectorBase Opposite();
+
+ math_VectorBase operator-()
+ {
+ return Opposite();
+ }
+
+ //! returns the subtraction of "theRight" from "me".
+ //! An exception is raised if the vectors have not the same length.
+ inline void Subtract(const math_VectorBase& theRight);
+
+ void operator-=(const math_VectorBase& theRight)
+ {
+ Subtract(theRight);
+ }
+
+ //! returns the subtraction of "theRight" from "me".
+ //! An exception is raised if the vectors have not the same length.
+ Standard_NODISCARD inline math_VectorBase Subtracted(const math_VectorBase& theRight) const;
+
+ Standard_NODISCARD math_VectorBase operator-(const math_VectorBase& theRight) const
+ {
+ return Subtracted(theRight);
+ }
+
+ //! returns the multiplication of a real by a vector.
+ //! "me" = "theLeft" * "theRight"
+ inline void Multiply(const TheItemType theLeft, const math_VectorBase& theRight);
+
+ //! Prints information on the current state of the object.
+ //! Is used to redefine the operator <<.
+ inline void Dump(Standard_OStream& theO) const;
+
+ friend inline Standard_OStream& operator<<(Standard_OStream& theO, const math_VectorBase& theVec)
+ {
+ theVec.Dump(theO);
+ return theO;
+ }
+
+ friend class math_Matrix;
+
+protected:
+
+ //! Is used internally to set the "theLower" value of the vector.
+ inline void SetLower(const Standard_Integer theLower);
+
+private:
+ std::array<TheItemType, THE_BUFFER_SIZE> myBuffer;
+ NCollection_Array1<TheItemType> Array;
+};
+
+#include <math_VectorBase.lxx>
+
+#endif
--- /dev/null
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2023 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 <Standard_DimensionError.hxx>
+#include <Standard_DivideByZero.hxx>
+#include <Standard_RangeError.hxx>
+#include <Standard_NullValue.hxx>
+
+#include <stdio.h>
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>::math_VectorBase(const Standard_Integer theLower,
+ const Standard_Integer theUpper) :
+ Array(*myBuffer.data(), theLower, theUpper, (theUpper - theLower + 1 <= math_VectorBase::THE_BUFFER_SIZE))
+{}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>::math_VectorBase(const Standard_Integer theLower,
+ const Standard_Integer theUpper,
+ const TheItemType theInitialValue) :
+ Array(*myBuffer.data(), theLower, theUpper, (theUpper - theLower + 1 <= math_VectorBase::THE_BUFFER_SIZE))
+{
+ Array.Init(theInitialValue);
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>::math_VectorBase(const TheItemType* theTab,
+ const Standard_Integer theLower,
+ const Standard_Integer theUpper) :
+ Array(*theTab, theLower, theUpper)
+{}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>::math_VectorBase(const gp_XY& theOther) :
+ Array(*myBuffer.data(), 1, 2)
+{
+ Array(1) = static_cast<TheItemType>(theOther.X());
+ Array(2) = static_cast<TheItemType>(theOther.Y());
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>::math_VectorBase(const gp_XYZ& theOther) :
+ Array(*myBuffer.data(), 1, 3)
+{
+ Array(1) = static_cast<TheItemType>(theOther.X());
+ Array(2) = static_cast<TheItemType>(theOther.Y());
+ Array(3) = static_cast<TheItemType>(theOther.Z());
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Init(const TheItemType theInitialValue)
+{
+ Array.Init(theInitialValue);
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>::math_VectorBase(const math_VectorBase<TheItemType>& theOther) :
+ Array(theOther.Array)
+{}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::SetLower(const Standard_Integer theLower)
+{
+ Array.UpdateLowerBound(theLower);
+}
+
+template<typename TheItemType>
+Standard_Real math_VectorBase<TheItemType>::Norm() const
+{
+ Standard_Real Result = 0;
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result = Result + Array(Index) * Array(Index);
+ }
+ return Sqrt(Result);
+}
+
+template<typename TheItemType>
+Standard_Real math_VectorBase<TheItemType>::Norm2() const
+{
+ Standard_Real Result = 0;
+
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result = Result + Array(Index) * Array(Index);
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+Standard_Integer math_VectorBase<TheItemType>::Max() const
+{
+ Standard_Integer I = 0;
+ Standard_Real X = RealFirst();
+
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ if (Array(Index) > X)
+ {
+ X = Array(Index);
+ I = Index;
+ }
+ }
+ return I;
+}
+
+template<typename TheItemType>
+Standard_Integer math_VectorBase<TheItemType>::Min() const
+{
+ Standard_Integer I = 0;
+ Standard_Real X = RealLast();
+
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ if (Array(Index) < X)
+ {
+ X = Array(Index);
+ I = Index;
+ }
+ }
+ return I;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Set(const Standard_Integer theI1,
+ const Standard_Integer theI2,
+ const math_VectorBase<TheItemType>& theV)
+{
+ Standard_RangeError_Raise_if((theI1 < Lower()) || (theI2 > Upper()) \
+ || (theI1 > theI2) || (theI2 - theI1 + 1 != theV.Length()), \
+ "math_VectorBase::Set() - invalid indices");
+ Standard_Integer I = theV.Lower();
+ for (Standard_Integer Index = theI1; Index <= theI2; Index++)
+ {
+ Array(Index) = theV.Array(I);
+ I++;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Normalize()
+{
+ Standard_Real Result = Norm();
+ Standard_NullValue_Raise_if((Result <= RealEpsilon()), \
+ "math_VectorBase::Normalize() - vector has zero norm");
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = Array(Index) / Result;
+ }
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Normalized() const
+{
+ math_VectorBase Result = *this;
+ Result.Normalize();
+ return Result;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Invert()
+{
+ for (Standard_Integer Index = Lower(); Index <= (Lower() + Length()) >> 1; Index++)
+ {
+ Standard_Integer J = Upper() + Lower() - Index;
+ TheItemType aTemp = Array(Index);
+ Array(Index) = Array(J);
+ Array(J) = aTemp;
+ }
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Inverse() const
+{
+ math_VectorBase Result = *this;
+ Result.Invert();
+ return Result;
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Multiplied(const TheItemType theRight) const
+{
+ math_VectorBase Result(Lower(), Upper());
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result.Array(Index) = Array(Index) * theRight;
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::TMultiplied(const TheItemType theRight) const
+{
+ math_VectorBase Result(Lower(), Upper());
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result.Array(Index) = Array(Index) * theRight;
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Multiply(const TheItemType theRight)
+{
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = Array(Index) * theRight;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Divide(const TheItemType theRight)
+{
+ Standard_DivideByZero_Raise_if(Abs(theRight) <= RealEpsilon(), \
+ "math_VectorBase::Divide() - devisor is zero");
+
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = Array(Index) / theRight;
+ }
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Divided(const TheItemType theRight) const
+{
+ Standard_DivideByZero_Raise_if(Abs(theRight) <= RealEpsilon(), \
+ "math_VectorBase::Divided() - devisor is zero");
+ math_VectorBase temp = Multiplied(1. / theRight);
+ return temp;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Add(const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if(Length() != theRight.Length(), \
+ "math_VectorBase::Add() - input vector has wrong dimensions");
+
+ Standard_Integer I = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = Array(Index) + theRight.Array(I);
+ I++;
+ }
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Added(const math_VectorBase<TheItemType>& theRight) const
+{
+ Standard_DimensionError_Raise_if(Length() != theRight.Length(), \
+ "math_VectorBase::Added() - input vector has wrong dimensions");
+
+ math_VectorBase Result(Lower(), Upper());
+
+ Standard_Integer I = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result.Array(Index) = Array(Index) + theRight.Array(I);
+ I++;
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Subtract(const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if(Length() != theRight.Length(), \
+ "math_VectorBase::Subtract() - input vector has wrong dimensions");
+
+ Standard_Integer I = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = Array(Index) - theRight.Array(I);
+ I++;
+ }
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Subtracted(const math_VectorBase<TheItemType>& theRight) const
+{
+ Standard_DimensionError_Raise_if(Length() != theRight.Length(), \
+ "math_VectorBase::Subtracted() - input vector has wrong dimensions");
+
+ math_VectorBase Result(Lower(), Upper());
+
+ Standard_Integer I = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result.Array(Index) = Array(Index) - theRight.Array(I);
+ I++;
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Slice(const Standard_Integer theI1, const Standard_Integer theI2) const
+{
+ Standard_RangeError_Raise_if((theI1 < Lower()) || (theI1 > Upper()) || (theI2 < Lower()) || (theI2 > Upper()), \
+ "math_VectorBase::Slice() - invalid indices");
+
+ if (theI2 >= theI1)
+ {
+ math_VectorBase Result(theI1, theI2);
+ for (Standard_Integer Index = theI1; Index <= theI2; Index++)
+ {
+ Result.Array(Index) = Array(Index);
+ }
+ return Result;
+ }
+ else
+ {
+ math_VectorBase Result(theI2, theI1);
+ for (Standard_Integer Index = theI1; Index >= theI2; Index--)
+ {
+ Result.Array(Index) = Array(Index);
+ }
+ return Result;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Add(const math_VectorBase<TheItemType>& theLeft, const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theRight.Length()) || (theRight.Length() != theLeft.Length()), \
+ "math_VectorBase::Add() - input vectors have wrong dimensions");
+
+ Standard_Integer I = theLeft.Lower();
+ Standard_Integer J = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = theLeft.Array(I) + theRight.Array(J);
+ I++;
+ J++;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Subtract(const math_VectorBase<TheItemType>& theLeft, const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theRight.Length()) || (theRight.Length() != theLeft.Length()), \
+ "math_VectorBase::Subtract() - input vectors have wrong dimensions");
+
+ Standard_Integer I = theLeft.Lower();
+ Standard_Integer J = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Array(Index) = theLeft.Array(I) - theRight.Array(J);
+ I++;
+ J++;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Multiply(const math_Matrix& theLeft, const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theLeft.RowNumber()) \
+ || (theLeft.ColNumber() != theRight.Length()), \
+ "math_VectorBase::Multiply() - input matrix and /or vector have wrong dimensions");
+
+ Standard_Integer Index = Lower();
+ for (Standard_Integer I = theLeft.LowerRowIndex; I <= theLeft.UpperRowIndex; I++)
+ {
+ Array(Index) = 0.0;
+ Standard_Integer K = theRight.Lower();
+ for (Standard_Integer J = theLeft.LowerColIndex; J <= theLeft.UpperColIndex; J++)
+ {
+ Array(Index) = Array(Index) + theLeft.Array(I, J) * theRight.Array(K);
+ K++;
+ }
+ Index++;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Multiply(const math_VectorBase<TheItemType>& theLeft, const math_Matrix& theRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theRight.ColNumber()) \
+ || (theLeft.Length() != theRight.RowNumber()), \
+ "math_VectorBase::Multiply() - input matrix and /or vector have wrong dimensions");
+
+ Standard_Integer Index = Lower();
+ for (Standard_Integer J = theRight.LowerColIndex; J <= theRight.UpperColIndex; J++)
+ {
+ Array(Index) = 0.0;
+ Standard_Integer K = theLeft.Lower();
+ for (Standard_Integer I = theRight.LowerRowIndex; I <= theRight.UpperRowIndex; I++)
+ {
+ Array(Index) = Array(Index) + theLeft.Array(K) * theRight.Array(I, J);
+ K++;
+ }
+ Index++;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::TMultiply(const math_Matrix& theTLeft, const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theTLeft.ColNumber()) \
+ || (theTLeft.RowNumber() != theRight.Length()), \
+ "math_VectorBase::TMultiply() - input matrix and /or vector have wrong dimensions");
+
+ Standard_Integer Index = Lower();
+ for (Standard_Integer I = theTLeft.LowerColIndex; I <= theTLeft.UpperColIndex; I++)
+ {
+ Array(Index) = 0.0;
+ Standard_Integer K = theRight.Lower();
+ for (Standard_Integer J = theTLeft.LowerRowIndex; J <= theTLeft.UpperRowIndex; J++)
+ {
+ Array(Index) = Array(Index) + theTLeft.Array(J, I) * theRight.Array(K);
+ K++;
+ }
+ Index++;
+ }
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::TMultiply(const math_VectorBase<TheItemType>& theLeft, const math_Matrix& theTRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theTRight.RowNumber()) \
+ || (theLeft.Length() != theTRight.ColNumber()), \
+ "math_VectorBase::TMultiply() - input matrix and /or vector have wrong dimensions");
+
+ Standard_Integer Index = Lower();
+ for (Standard_Integer J = theTRight.LowerRowIndex; J <= theTRight.UpperRowIndex; J++)
+ {
+ Array(Index) = 0.0;
+ Standard_Integer K = theLeft.Lower();
+ for (Standard_Integer I = theTRight.LowerColIndex;
+ I <= theTRight.UpperColIndex; I++)
+ {
+ Array(Index) = Array(Index) + theLeft.Array(K) * theTRight.Array(J, I);
+ K++;
+ }
+ Index++;
+ }
+}
+
+template<typename TheItemType>
+TheItemType math_VectorBase<TheItemType>::Multiplied(const math_VectorBase<TheItemType>& theRight) const
+{
+ Standard_Real Result = 0;
+
+ Standard_DimensionError_Raise_if(Length() != theRight.Length(), \
+ "math_VectorBase::Multiplied() - input vector has wrong dimensions");
+
+ Standard_Integer I = theRight.Lower();
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result = Result + Array(Index) * theRight.Array(I);
+ I++;
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Opposite()
+{
+ math_VectorBase Result(Lower(), Upper());
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ Result.Array(Index) = -Array(Index);
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType> math_VectorBase<TheItemType>::Multiplied(const math_Matrix& theRight)const
+{
+ Standard_DimensionError_Raise_if(Length() != theRight.RowNumber(), \
+ "math_VectorBase::Multiplied() - input matrix has wrong dimensions");
+
+ math_VectorBase Result(theRight.LowerColIndex, theRight.UpperColIndex);
+ for (Standard_Integer J2 = theRight.LowerColIndex; J2 <= theRight.UpperColIndex; J2++)
+ {
+ Result.Array(J2) = 0.0;
+ Standard_Integer theI2 = theRight.LowerRowIndex;
+ for (Standard_Integer I = Lower(); I <= Upper(); I++)
+ {
+ Result.Array(J2) = Result.Array(J2) + Array(I) * theRight.Array(theI2, J2);
+ theI2++;
+ }
+ }
+ return Result;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Multiply(const TheItemType theLeft, const math_VectorBase<TheItemType>& theRight)
+{
+ Standard_DimensionError_Raise_if((Length() != theRight.Length()), \
+ "math_VectorBase::Multiply() - input vector has wrong dimensions");
+ for (Standard_Integer I = Lower(); I <= Upper(); I++)
+ {
+ Array(I) = theLeft * theRight.Array(I);
+ }
+}
+
+template<typename TheItemType>
+math_VectorBase<TheItemType>& math_VectorBase<TheItemType>::Initialized(const math_VectorBase<TheItemType>& theOther)
+{
+ Standard_DimensionError_Raise_if(Length() != theOther.Length(), \
+ "math_VectorBase::Initialized() - input vector has wrong dimensions");
+ memmove(&Array.ChangeFirst(), &theOther.Array.First(), sizeof(TheItemType) * Array.Length());
+ return *this;
+}
+
+template<typename TheItemType>
+void math_VectorBase<TheItemType>::Dump(Standard_OStream& theO) const
+{
+ theO << "math_Vector of Length = " << Length() << "\n";
+ for (Standard_Integer Index = Lower(); Index <= Upper(); Index++)
+ {
+ theO << "math_Vector(" << Index << ") = " << Array(Index) << "\n";
+ }
+}
# make the first open/close iteration before checking memory because some filled structures
# are cleared on start of the next open (like mySections in DocumentRetrievalDriver)
-Open $docname D
-Close D
+for {set i 1} {$i < 3} {incr i} {
+ Open $docname D
+ Close D
+}
puts "Executing Load / Close in cycle to see if allocated heap memory grows"
set listmem {}
-puts "TODO ?CR33225 Linux: Checking trend failed: mean delta per step = 7408.0, sigma = 2737.917456754312, expected delta = 0"
+puts "TODO ?CR33225 Linux: Checking trend failed: mean delta per step ="
puts "TODO ?OCC7287 Linux: Tcl Exception: Memory leak detected"
puts "TODO ?OCC7287 Linux: TEST INCOMPLETE"
puts "TODO ?OCC7287 MacOS: Tcl Exception: Memory leak detected"
set info [param write.surfacecurve.mode]
-set result1 [regexp {\-\-\- Type : Enum \[in 0-1\] 0:Off 1:On , alpha: +(.*):0 +(.*):1 +\n\-\-\-} $info full alpha_0 alpha_1]
+set result1 [regexp {\-\-\- Type : Enum \[in 0-1\] 0:Off 1:On , alpha: +(.*):[0-9] +(.*):[0-9] +\n\-\-\-} $info full alpha_0 alpha_1]
if { ${result1} == 0 } {
puts "Error: bad message or regexp"
if (aRowId == theRowId)
break;
}
- aReportsIt.Value().myReport = theReport;
- aReportsIt.Value().myDescription = theReportDescription;
+ aReportsIt.ChangeValue().myReport = theReport;
+ aReportsIt.ChangeValue().myDescription = theReportDescription;
}
// =======================================================================
#include <inspector/View_Viewer.hxx>
#include <OpenGl_GraphicDriver.hxx>
-#include <Standard_ExtString.hxx>
// =======================================================================
// function : CreateView