]> OCCT Git - occt.git/commitdiff
0033370: Foundation Classes - Moving into STL and Boost functionality
authordpasukhi <dpasukhi@opencascade.com>
Sat, 5 Aug 2023 16:53:19 +0000 (17:53 +0100)
committerdpasukhi <dpasukhi@opencascade.com>
Mon, 4 Dec 2023 13:37:09 +0000 (13:37 +0000)
NCollection containers update:
  - NCollection_Array1 - updated functionality
  - NCollection_Array2 - NCollection_Array1 as a wrapper for 2array
  - NCollection_Vector -> NCollection_DynamicArray was renamed and reworked.
TCollection:
  - Use static empty string to avoid allocations on empty string
 NCollection allocators update:
  - NCollection_Allocator - allocator that used Standard::Allocate
  - NCollection_OccAllocator - allocator-wrapper that used OCC BaseAllocator objects
  - NCollection_IncAllocator - rework to increase performance
Standard:
  - Rework functionality to use different allocation libs
  - Implement basic of new way to wrap allocations tools
  - Define 4 ways to allocation (defines in configure stage)
 Additional changes:
  - Hash function uses std::hash functionality
   - size_t as a hash value
  - New HashUtils with Murmur and FVN hash algo for x32 and x64
  - Deprecated _0.cxx and .gxx DE classes reorganized
  - Create own utility for std memory
  - Update Standard_Transient to be more platform-independent
 Math TK changes:
  - math_Vector -> match_BaseVector<>
    - Buffer decreased to cash 32 elements instead of 512

649 files changed:
samples/ios/UIKitSample/UIKitSample/CafShapePrs.h
src/AIS/AIS_ColoredShape.hxx
src/AIS/AIS_ConnectedInteractive.cxx
src/AIS/AIS_DataMapOfIOStatus.hxx
src/AIS/AIS_ViewCube.hxx
src/AdvApprox/AdvApprox_ApproxAFunction.hxx
src/AdvApprox/AdvApprox_SimpleApprox.hxx
src/AppCont/AppCont_ContMatrices_4.cxx
src/AppCont/AppCont_LeastSquare.hxx
src/Approx/Approx_ComputeLine.gxx
src/ApproxInt/ApproxInt_KnotTools.hxx
src/Aspect/Aspect_XRAction.hxx
src/Aspect/Aspect_XRActionSet.hxx
src/BOPAlgo/BOPAlgo_BuilderFace.cxx
src/BOPAlgo/BOPAlgo_BuilderSolid.cxx
src/BOPAlgo/BOPAlgo_Builder_2.cxx
src/BOPAlgo/BOPAlgo_MakeConnected.hxx
src/BOPAlgo/BOPAlgo_PaveFiller.hxx
src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BOPAlgo/BOPAlgo_Tools.cxx
src/BOPAlgo/BOPAlgo_Tools.hxx
src/BOPDS/BOPDS_DS.cxx
src/BOPDS/BOPDS_DataMapOfIntegerListOfPaveBlock.hxx
src/BOPDS/BOPDS_DataMapOfPaveBlockCommonBlock.hxx
src/BOPDS/BOPDS_DataMapOfPaveBlockListOfInteger.hxx
src/BOPDS/BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx
src/BOPDS/BOPDS_IndexedDataMapOfPaveBlockListOfInteger.hxx
src/BOPDS/BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock.hxx
src/BOPDS/BOPDS_IndexedMapOfPaveBlock.hxx
src/BOPDS/BOPDS_ListOfPaveBlock.hxx
src/BOPDS/BOPDS_MapOfCommonBlock.hxx
src/BOPDS/BOPDS_MapOfPair.hxx
src/BOPDS/BOPDS_MapOfPave.hxx
src/BOPDS/BOPDS_MapOfPaveBlock.hxx
src/BOPDS/BOPDS_Pair.hxx
src/BOPDS/BOPDS_PairMapHasher.hxx [deleted file]
src/BOPDS/BOPDS_Pave.hxx
src/BOPDS/BOPDS_PaveMapHasher.hxx [deleted file]
src/BOPDS/BOPDS_PaveMapHasher.lxx [deleted file]
src/BOPDS/FILES
src/BOPTools/BOPTools_IndexedDataMapOfSetShape.hxx
src/BOPTools/BOPTools_MapOfSet.hxx
src/BOPTools/BOPTools_Parallel.hxx
src/BOPTools/BOPTools_Set.cxx
src/BOPTools/BOPTools_Set.hxx
src/BOPTools/BOPTools_SetMapHasher.hxx [deleted file]
src/BOPTools/BOPTools_SetMapHasher.lxx [deleted file]
src/BOPTools/FILES
src/BRep/BRep_Builder.cxx
src/BRep/BRep_Tool.cxx
src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx
src/BRepAlgo/BRepAlgo_Loop.cxx
src/BRepApprox/BRepApprox_TheMultiLineOfApprox.hxx
src/BRepBlend/BRepBlend_AppFuncRoot.hxx
src/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx
src/BRepCheck/BRepCheck_Face.cxx
src/BRepCheck/BRepCheck_IndexedDataMapOfShapeResult.hxx
src/BRepCheck/BRepCheck_Shell.cxx
src/BRepClass3d/BRepClass3d_MapOfInter.hxx
src/BRepFill/BRepFill_DataMapOfNodeDataMapOfShapeShape.hxx
src/BRepFill/BRepFill_DataMapOfNodeShape.hxx
src/BRepFill/BRepFill_DataMapOfOrientedShapeListOfShape.hxx
src/BRepFill/BRepFill_Evolved.cxx
src/BRepFill/BRepFill_IndexedDataMapOfOrientedShapeListOfShape.hxx
src/BRepFill/BRepFill_OffsetWire.cxx
src/BRepFill/BRepFill_Sweep.cxx
src/BRepGProp/BRepGProp_Gauss.hxx
src/BRepGProp/BRepGProp_VinertGK.hxx
src/BRepLib/BRepLib.cxx
src/BRepLib/BRepLib_FuseEdges.cxx
src/BRepLib/BRepLib_MakeWire_1.cxx
src/BRepMAT2d/BRepMAT2d_DataMapOfBasicEltShape.hxx
src/BRepMesh/BRepMesh_Edge.hxx
src/BRepMesh/BRepMesh_OrientedEdge.hxx
src/BRepMesh/BRepMesh_Triangle.hxx
src/BRepMesh/BRepMesh_Vertex.hxx
src/BRepMeshData/BRepMeshData_Curve.cxx
src/BRepMeshData/BRepMeshData_Model.cxx
src/BRepMeshData/BRepMeshData_PCurve.cxx
src/BRepOffset/BRepOffset_MakeOffset.cxx
src/BRepOffset/BRepOffset_SimpleOffset.hxx
src/BRepOffset/BRepOffset_Tool.cxx
src/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx
src/BRepOffsetAPI/BRepOffsetAPI_MakeThickSolid.cxx
src/BRepPrimAPI/BRepPrimAPI_MakeRevolution.hxx
src/BSplCLib/BSplCLib.cxx
src/BinMDF/BinMDF_TypeADriverMap.hxx
src/BinMDF/BinMDF_TypeIdMap.hxx
src/BinMNaming/BinMNaming_NamedShapeDriver.cxx
src/BinObjMgt/BinObjMgt_Persistent.hxx
src/BinTObjDrivers/BinTObjDrivers.hxx
src/BinTObjDrivers/BinTObjDrivers_DocumentRetrievalDriver.hxx
src/BinTObjDrivers/BinTObjDrivers_DocumentStorageDriver.hxx
src/BinTObjDrivers/BinTObjDrivers_IntSparseArrayDriver.hxx
src/BinTObjDrivers/BinTObjDrivers_ModelDriver.hxx
src/BinTObjDrivers/BinTObjDrivers_ObjectDriver.hxx
src/BinTObjDrivers/BinTObjDrivers_ReferenceDriver.hxx
src/BinTObjDrivers/BinTObjDrivers_XYZDriver.hxx
src/BinTools/BinTools_ShapeReader.cxx
src/BinTools/BinTools_ShapeReader.hxx
src/BinTools/BinTools_ShapeSet.hxx
src/BinTools/BinTools_ShapeSetBase.hxx
src/BinTools/BinTools_ShapeWriter.hxx
src/Bnd/Bnd_BoundSortBox.hxx
src/BndLib/BndLib_AddSurface.cxx
src/CDF/CDF_FWOSDriver.cxx
src/CDM/CDM_DocumentHasher.hxx [deleted file]
src/CDM/CDM_MapOfDocument.hxx
src/CDM/CDM_MetaDataLookUpTable.hxx
src/CDM/FILES
src/ChFi3d/ChFi3d_Builder.cxx
src/ChFi3d/ChFi3d_Builder_2.cxx
src/ChFi3d/ChFi3d_Builder_C1.cxx
src/ChFi3d/ChFi3d_Builder_C2.cxx
src/ChFi3d/ChFi3d_Builder_CnCrn.cxx
src/ChFi3d/ChFi3d_ChBuilder.cxx
src/ChFi3d/ChFi3d_FilBuilder.cxx
src/ChFiDS/ChFiDS_FilSpine.cxx
src/ChFiKPart/ChFiKPart_RstMap.hxx
src/DBRep/DBRep_DrawableShape.cxx
src/DBRep/DBRep_IsoBuilder.cxx
src/DBRep/DBRep_IsoBuilder.hxx
src/DDF/DDF_Transaction.hxx
src/DDataStd/DDataStd_BasicCommands.cxx
src/DE/DE_ConfigurationContext.hxx
src/DE/DE_Wrapper.cxx
src/DE/DE_Wrapper.hxx
src/DRAWEXE/DRAWEXE.cxx
src/Draft/Draft_VertexInfo.cxx
src/Draw/Draw_Drawable3D.cxx
src/Draw/Draw_MapOfAsciiString.hxx
src/DrawFairCurve/DrawFairCurve_Batten.hxx
src/DrawFairCurve/DrawFairCurve_MinimalVariation.hxx
src/Expr/Expr_MapOfNamedUnknown.hxx
src/Express/Express_DataMapOfAsciiStringItem.hxx
src/Express/Express_Entity.hxx
src/Extrema/Extrema_FuncPSDist.hxx
src/FEmTool/FEmTool_Assembly.cxx
src/Font/Font_FontMgr.cxx
src/Font/Font_FontMgr.hxx
src/Font/Font_SystemFont.hxx
src/Geom2dHatch/Geom2dHatch_Hatchings.hxx
src/Geom2dHatch/Geom2dHatch_MapOfElements.hxx
src/GeomFill/GeomFill_PolynomialConvertor.cxx
src/GeomInt/GeomInt_LineTool.cxx
src/GeomInt/GeomInt_TheMultiLineOfWLApprox.hxx
src/Graphic3d/Graphic3d_CView.hxx
src/Graphic3d/Graphic3d_FrameStatsData.cxx
src/Graphic3d/Graphic3d_FrameStatsData.hxx
src/Graphic3d/Graphic3d_ShaderAttribute.hxx
src/HLRAlgo/HLRAlgo_PolyAlgo.cxx
src/HLRAlgo/HLRAlgo_PolyShellData.cxx
src/HLRBRep/HLRBRep_CurveTool.hxx
src/HLRBRep/HLRBRep_Data.cxx
src/HLRBRep/HLRBRep_Data.hxx
src/HLRBRep/HLRBRep_EdgeFaceTool.hxx
src/HLRBRep/HLRBRep_EdgeIList.cxx
src/HLRBRep/HLRBRep_Hider.cxx
src/HLRBRep/HLRBRep_PolyAlgo.cxx
src/HLRBRep/HLRBRep_ThePolyhedronOfInterCSurf.hxx
src/IFSelect/IFSelect_IntParam.hxx
src/IMeshData/IMeshData_Types.hxx
src/IVtk/IVtk_Types.hxx
src/IVtkDraw/IVtkDraw.cxx
src/Image/Image_Texture.hxx
src/IntPatch/IntPatch_ImpImpIntersection_4.gxx
src/IntPatch/IntPatch_SpecialPoints.hxx
src/IntPatch/IntPatch_WLineTool.cxx
src/IntPolyh/FILES
src/IntPolyh/IntPolyh_Couple.hxx
src/IntPolyh/IntPolyh_CoupleMapHasher.hxx [deleted file]
src/IntPolyh/IntPolyh_Intersection.cxx
src/IntPolyh/IntPolyh_MaillageAffinage.cxx
src/IntPolyh/IntPolyh_SectionLine.hxx
src/IntTools/FILES
src/IntTools/IntTools_BeanFaceIntersector.cxx
src/IntTools/IntTools_Context.cxx
src/IntTools/IntTools_Context.hxx
src/IntTools/IntTools_CurveRangeSample.hxx
src/IntTools/IntTools_CurveRangeSampleMapHasher.hxx [deleted file]
src/IntTools/IntTools_DataMapIteratorOfDataMapOfCurveSampleBox.hxx [deleted file]
src/IntTools/IntTools_DataMapOfCurveSampleBox.hxx
src/IntTools/IntTools_DataMapOfSurfaceSampleBox.hxx
src/IntTools/IntTools_FaceFace.cxx
src/IntTools/IntTools_MapOfCurveSample.hxx
src/IntTools/IntTools_MapOfSurfaceSample.hxx
src/IntTools/IntTools_SurfaceRangeSample.hxx
src/IntTools/IntTools_SurfaceRangeSample.lxx
src/IntTools/IntTools_SurfaceRangeSampleMapHasher.hxx [deleted file]
src/IntWalk/IntWalk_VectorOfInteger.hxx
src/IntWalk/IntWalk_VectorOfWalkingData.hxx
src/Interface/FILES
src/Interface/Interface_DataMapOfTransientInteger.hxx
src/Interface/Interface_IndexedMapOfAsciiString.hxx
src/Interface/Interface_MapAsciiStringHasher.cxx [deleted file]
src/Interface/Interface_MapAsciiStringHasher.hxx [deleted file]
src/Interface/Interface_Static.cxx
src/Interface/Interface_Static.hxx
src/LocOpe/LocOpe_BuildShape.cxx
src/LocOpe/LocOpe_Generator.cxx
src/LocOpe/LocOpe_Pipe.cxx
src/LocOpe/LocOpe_SplitDrafts.cxx
src/LocOpe/LocOpe_SplitShape.cxx
src/LocOpe/LocOpe_Spliter.cxx
src/MAT/MAT_Arc.hxx
src/MAT/MAT_BasicElt.hxx
src/MAT/MAT_DataMapOfIntegerArc.hxx
src/MAT/MAT_DataMapOfIntegerBasicElt.hxx
src/MAT/MAT_DataMapOfIntegerBisector.hxx
src/MAT/MAT_DataMapOfIntegerNode.hxx
src/MAT/MAT_Node.hxx
src/MAT2d/FILES
src/MAT2d/MAT2d_BiInt.hxx
src/MAT2d/MAT2d_DataMapOfBiIntInteger.hxx
src/MAT2d/MAT2d_DataMapOfBiIntSequenceOfInteger.hxx
src/MAT2d/MAT2d_DataMapOfIntegerBisec.hxx
src/MAT2d/MAT2d_DataMapOfIntegerConnexion.hxx
src/MAT2d/MAT2d_DataMapOfIntegerPnt2d.hxx
src/MAT2d/MAT2d_DataMapOfIntegerSequenceOfConnexion.hxx
src/MAT2d/MAT2d_DataMapOfIntegerVec2d.hxx
src/MAT2d/MAT2d_MapBiIntHasher.hxx [deleted file]
src/MAT2d/MAT2d_MapBiIntHasher.lxx [deleted file]
src/MeshVS/FILES
src/MeshVS/MeshVS_DataMapOfColorMapOfInteger.hxx
src/MeshVS/MeshVS_DataMapOfHArray1OfSequenceOfInteger.hxx
src/MeshVS/MeshVS_DataMapOfIntegerAsciiString.hxx
src/MeshVS/MeshVS_DataMapOfIntegerBoolean.hxx
src/MeshVS/MeshVS_DataMapOfIntegerColor.hxx
src/MeshVS/MeshVS_DataMapOfIntegerMaterial.hxx
src/MeshVS/MeshVS_DataMapOfIntegerMeshEntityOwner.hxx
src/MeshVS/MeshVS_DataMapOfIntegerOwner.hxx
src/MeshVS/MeshVS_DataMapOfIntegerTwoColors.hxx
src/MeshVS/MeshVS_DataMapOfIntegerVector.hxx
src/MeshVS/MeshVS_DataMapOfTwoColorsMapOfInteger.hxx
src/MeshVS/MeshVS_DataSource.hxx
src/MeshVS/MeshVS_DeformedDataSource.hxx
src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx
src/MeshVS/MeshVS_MapOfTwoNodes.hxx
src/MeshVS/MeshVS_SymmetricPairHasher.hxx
src/MeshVS/MeshVS_TwoColors.cxx
src/MeshVS/MeshVS_TwoColors.hxx
src/MeshVS/MeshVS_TwoColorsHasher.hxx [deleted file]
src/MeshVS/MeshVS_TwoNodes.hxx
src/MeshVS/MeshVS_TwoNodesHasher.hxx [deleted file]
src/Message/Message_Attribute.hxx
src/Message/Message_AttributeMeter.cxx
src/Message/Message_AttributeObject.hxx
src/Message/Message_PrinterOStream.hxx
src/Message/Message_PrinterToReport.hxx
src/Message/Message_ProgressScope.hxx
src/MoniTool/FILES
src/MoniTool/MoniTool_DataMapOfTimer.hxx
src/MoniTool/MoniTool_ElemHasher.cxx [deleted file]
src/MoniTool/MoniTool_ElemHasher.hxx [deleted file]
src/MoniTool/MoniTool_Element.cxx
src/MoniTool/MoniTool_Element.hxx
src/MoniTool/MoniTool_MTHasher.cxx [deleted file]
src/MoniTool/MoniTool_MTHasher.hxx [deleted file]
src/MoniTool/MoniTool_MTHasher.lxx [deleted file]
src/MoniTool/MoniTool_TransientElem.cxx
src/NCollection/FILES
src/NCollection/NCollection_AccAllocator.cxx
src/NCollection/NCollection_AccAllocator.hxx
src/NCollection/NCollection_AlignedAllocator.hxx
src/NCollection/NCollection_Allocator.hxx [new file with mode: 0644]
src/NCollection/NCollection_Array1.hxx
src/NCollection/NCollection_Array2.hxx
src/NCollection/NCollection_BaseAllocator.cxx
src/NCollection/NCollection_BaseAllocator.hxx
src/NCollection/NCollection_BaseMap.cxx
src/NCollection/NCollection_BaseMap.hxx
src/NCollection/NCollection_BasePointerVector.cxx [new file with mode: 0644]
src/NCollection/NCollection_BasePointerVector.hxx [new file with mode: 0644]
src/NCollection/NCollection_BaseVector.cxx [deleted file]
src/NCollection/NCollection_BaseVector.hxx [deleted file]
src/NCollection/NCollection_CellFilter.hxx
src/NCollection/NCollection_DataMap.hxx
src/NCollection/NCollection_DefaultHasher.hxx
src/NCollection/NCollection_DefineArray1.hxx [deleted file]
src/NCollection/NCollection_DefineArray2.hxx [deleted file]
src/NCollection/NCollection_DefineDataMap.hxx [deleted file]
src/NCollection/NCollection_DefineDoubleMap.hxx [deleted file]
src/NCollection/NCollection_DefineHArray1.hxx
src/NCollection/NCollection_DefineHArray2.hxx
src/NCollection/NCollection_DefineHSequence.hxx
src/NCollection/NCollection_DefineHasher.hxx [new file with mode: 0644]
src/NCollection/NCollection_DefineIndexedDataMap.hxx [deleted file]
src/NCollection/NCollection_DefineIndexedMap.hxx [deleted file]
src/NCollection/NCollection_DefineList.hxx [deleted file]
src/NCollection/NCollection_DefineMap.hxx [deleted file]
src/NCollection/NCollection_DefineSequence.hxx [deleted file]
src/NCollection/NCollection_DefineVector.hxx [deleted file]
src/NCollection/NCollection_DoubleMap.hxx
src/NCollection/NCollection_DynamicArray.hxx [new file with mode: 0644]
src/NCollection/NCollection_EBTree.hxx
src/NCollection/NCollection_HeapAllocator.hxx
src/NCollection/NCollection_IncAllocator.cxx
src/NCollection/NCollection_IncAllocator.hxx
src/NCollection/NCollection_IndexedDataMap.hxx
src/NCollection/NCollection_IndexedIterator.hxx [new file with mode: 0644]
src/NCollection/NCollection_IndexedMap.hxx
src/NCollection/NCollection_Iterator.hxx [new file with mode: 0644]
src/NCollection/NCollection_List.hxx
src/NCollection/NCollection_Map.hxx
src/NCollection/NCollection_OccAllocator.hxx [new file with mode: 0644]
src/NCollection/NCollection_Sequence.hxx
src/NCollection/NCollection_SparseArrayBase.hxx
src/NCollection/NCollection_StdAllocator.hxx [deleted file]
src/NCollection/NCollection_TListNode.hxx
src/NCollection/NCollection_UBTreeFiller.hxx
src/NCollection/NCollection_Vector.hxx
src/NCollection/NCollection_WinHeapAllocator.hxx
src/OSD/OSD.cxx
src/OSD/OSD_FileSystem.hxx
src/OSD/OSD_MemInfo.hxx
src/OSD/OSD_SharedLibrary.cxx
src/OSD/OSD_SharedLibrary.hxx
src/OSD/OSD_ThreadFunction.hxx
src/OpenGl/OpenGl_LayerList.hxx
src/OpenGl/OpenGl_SceneGeometry.cxx
src/OpenGl/OpenGl_SceneGeometry.hxx
src/PCDM/PCDM_ReaderFilter.hxx
src/Plate/Plate_Plate.hxx
src/Plugin/Plugin_MapOfFunctions.hxx
src/Poly/Poly_MakeLoops.cxx
src/Poly/Poly_MakeLoops.hxx
src/Poly/Poly_MergeNodesTool.cxx
src/Poly/Poly_MergeNodesTool.hxx
src/QABugs/QABugs_11.cxx
src/QABugs/QABugs_14.cxx
src/QABugs/QABugs_20.cxx
src/QADNaming/QADNaming.hxx
src/QANCollection/QANCollection_Alloc.cxx
src/QANCollection/QANCollection_DataMapOfRealPnt.hxx
src/QANCollection/QANCollection_DoubleMapOfRealInteger.hxx
src/QANCollection/QANCollection_Handle.cxx
src/QANCollection/QANCollection_IndexedDataMapOfRealPnt.hxx
src/QANCollection/QANCollection_Perf.cxx
src/QANCollection/QANCollection_Test.cxx
src/Quantity/FILES
src/Quantity/Quantity_Color.hxx
src/Quantity/Quantity_ColorHasher.hxx [deleted file]
src/Quantity/Quantity_ColorRGBA.hxx
src/Quantity/Quantity_ColorRGBAHasher.hxx [deleted file]
src/RWGltf/RWGltf_CafWriter.cxx
src/RWGltf/RWGltf_CafWriter.hxx
src/RWGltf/RWGltf_GltfJsonParser.hxx
src/RWGltf/RWGltf_GltfMaterialMap.cxx
src/RWGltf/RWGltf_GltfMaterialMap.hxx
src/RWGltf/RWGltf_GltfSceneNodeMap.hxx
src/RWMesh/RWMesh_MaterialMap.hxx
src/RWObj/RWObj_ObjMaterialMap.hxx
src/RWObj/RWObj_Reader.hxx
src/Resource/Resource_DataMapOfAsciiStringAsciiString.hxx
src/Resource/Resource_DataMapOfAsciiStringExtendedString.hxx
src/Resource/Resource_Manager.hxx
src/STEPCAFControl/STEPCAFControl_DataMapOfLabelExternFile.hxx
src/STEPCAFControl/STEPCAFControl_DataMapOfLabelShape.hxx
src/STEPCAFControl/STEPCAFControl_DataMapOfPDExternFile.hxx
src/STEPCAFControl/STEPCAFControl_DataMapOfSDRExternFile.hxx
src/STEPConstruct/FILES
src/STEPConstruct/STEPConstruct_DataMapOfAsciiStringTransient.hxx
src/STEPConstruct/STEPConstruct_DataMapOfPointTransient.hxx
src/STEPConstruct/STEPConstruct_PointHasher.cxx [deleted file]
src/STEPConstruct/STEPConstruct_PointHasher.hxx [deleted file]
src/STEPConstruct/STEPConstruct_PointHasher.lxx [deleted file]
src/SelectMgr/SelectMgr_BVHThreadPool.hxx
src/SelectMgr/SelectMgr_IndexedDataMapOfOwnerCriterion.hxx
src/SelectMgr/SelectMgr_SelectionImageFiller.hxx
src/ShapeAnalysis/ShapeAnalysis.cxx
src/ShapeExtend/ShapeExtend_DataMapOfTransientListOfMsg.hxx
src/ShapeFix/ShapeFix_EdgeConnect.cxx
src/Standard/FILES
src/Standard/Standard.cxx
src/Standard/Standard.hxx
src/Standard/Standard_Address.hxx [deleted file]
src/Standard/Standard_CString.cxx
src/Standard/Standard_CString.hxx
src/Standard/Standard_CStringHasher.hxx [new file with mode: 0644]
src/Standard/Standard_ExtString.cxx [deleted file]
src/Standard/Standard_ExtString.hxx [deleted file]
src/Standard/Standard_GUID.cxx
src/Standard/Standard_GUID.hxx
src/Standard/Standard_Handle.hxx
src/Standard/Standard_HashUtils.hxx [new file with mode: 0644]
src/Standard/Standard_HashUtils.lxx [new file with mode: 0644]
src/Standard/Standard_Integer.hxx
src/Standard/Standard_MMgrRaw.cxx [deleted file]
src/Standard/Standard_MMgrRaw.hxx [deleted file]
src/Standard/Standard_MMgrTBBalloc.cxx [deleted file]
src/Standard/Standard_MMgrTBBalloc.hxx [deleted file]
src/Standard/Standard_MemoryUtils.hxx [new file with mode: 0644]
src/Standard/Standard_PrimitiveTypes.hxx
src/Standard/Standard_Real.cxx
src/Standard/Standard_Real.hxx
src/Standard/Standard_ShortReal.cxx [deleted file]
src/Standard/Standard_ShortReal.hxx
src/Standard/Standard_Size.hxx [deleted file]
src/Standard/Standard_ThreadId.hxx
src/Standard/Standard_Transient.cxx
src/Standard/Standard_Transient.hxx
src/Standard/Standard_Type.cxx
src/Standard/Standard_Type.hxx
src/Standard/Standard_math.cxx [deleted file]
src/Standard/Standard_math.hxx [deleted file]
src/Standard/Standard_values.h [deleted file]
src/StdObjMgt/StdObjMgt_MapOfInstantiators.hxx
src/StdStorage/StdStorage_MapOfRoots.hxx
src/StdStorage/StdStorage_MapOfTypes.hxx
src/StepData/StepData_FreeFormEntity.cxx
src/StepToTopoDS/FILES
src/StepToTopoDS/StepToTopoDS_CartesianPointHasher.cxx [deleted file]
src/StepToTopoDS/StepToTopoDS_CartesianPointHasher.hxx [deleted file]
src/StepToTopoDS/StepToTopoDS_DataMapOfRI.hxx
src/StepToTopoDS/StepToTopoDS_DataMapOfRINames.hxx
src/StepToTopoDS/StepToTopoDS_DataMapOfTRI.hxx
src/StepToTopoDS/StepToTopoDS_PointEdgeMap.hxx
src/StepToTopoDS/StepToTopoDS_PointPair.cxx
src/StepToTopoDS/StepToTopoDS_PointPair.hxx
src/StepToTopoDS/StepToTopoDS_PointPairHasher.cxx [deleted file]
src/StepToTopoDS/StepToTopoDS_PointPairHasher.hxx [deleted file]
src/StepToTopoDS/StepToTopoDS_PointVertexMap.hxx
src/Storage/Storage_MapOfCallBack.hxx
src/Storage/Storage_MapOfPers.hxx
src/Storage/Storage_PType.hxx
src/Storage/Storage_Schema.cxx
src/TColStd/FILES
src/TColStd/TColStd_DataMapOfAsciiStringInteger.hxx
src/TColStd/TColStd_DataMapOfIntegerInteger.hxx
src/TColStd/TColStd_DataMapOfIntegerListOfInteger.hxx
src/TColStd/TColStd_DataMapOfIntegerReal.hxx
src/TColStd/TColStd_DataMapOfIntegerTransient.hxx
src/TColStd/TColStd_DataMapOfStringInteger.hxx
src/TColStd/TColStd_DataMapOfTransientTransient.hxx
src/TColStd/TColStd_IndexedDataMapOfStringString.hxx
src/TColStd/TColStd_IndexedDataMapOfTransientTransient.hxx
src/TColStd/TColStd_IndexedMapOfInteger.hxx
src/TColStd/TColStd_IndexedMapOfReal.hxx
src/TColStd/TColStd_IndexedMapOfTransient.hxx
src/TColStd/TColStd_MapIntegerHasher.hxx [deleted file]
src/TColStd/TColStd_MapOfAsciiString.hxx
src/TColStd/TColStd_MapOfInteger.hxx
src/TColStd/TColStd_MapOfReal.hxx
src/TColStd/TColStd_MapOfTransient.hxx
src/TColStd/TColStd_MapRealHasher.hxx [deleted file]
src/TColStd/TColStd_MapTransientHasher.hxx [deleted file]
src/TColStd/TColStd_PackedMapOfInteger.cxx
src/TColStd/TColStd_PackedMapOfInteger.hxx
src/TColStd/TColStd_SequenceOfAddress.hxx
src/TCollection/TCollection_AsciiString.cxx
src/TCollection/TCollection_AsciiString.hxx
src/TCollection/TCollection_AsciiString.lxx
src/TCollection/TCollection_ExtendedString.cxx
src/TCollection/TCollection_ExtendedString.hxx
src/TCollection/TCollection_HAsciiString.hxx
src/TCollection/TCollection_HAsciiString.lxx
src/TCollection/TCollection_HExtendedString.hxx
src/TDF/FILES
src/TDF/TDF_AttributeDataMap.hxx
src/TDF/TDF_AttributeDoubleMap.hxx
src/TDF/TDF_AttributeIndexedMap.hxx
src/TDF/TDF_AttributeMap.hxx
src/TDF/TDF_CopyTool.cxx
src/TDF/TDF_DerivedAttribute.cxx
src/TDF/TDF_GUIDProgIDMap.hxx
src/TDF/TDF_IDMap.hxx
src/TDF/TDF_Label.hxx
src/TDF/TDF_Label.lxx
src/TDF/TDF_LabelDataMap.hxx
src/TDF/TDF_LabelDoubleMap.hxx
src/TDF/TDF_LabelIndexedMap.hxx
src/TDF/TDF_LabelIntegerMap.hxx
src/TDF/TDF_LabelMap.hxx
src/TDF/TDF_LabelMapHasher.hxx [deleted file]
src/TDataStd/TDataStd_DataMapOfStringByte.hxx
src/TDataStd/TDataStd_DataMapOfStringHArray1OfInteger.hxx
src/TDataStd/TDataStd_DataMapOfStringHArray1OfReal.hxx
src/TDataStd/TDataStd_DataMapOfStringReal.hxx
src/TDataStd/TDataStd_DataMapOfStringString.hxx
src/TDocStd/TDocStd_Document.hxx
src/TDocStd/TDocStd_LabelIDMapDataMap.hxx
src/TFunction/TFunction_DataMapOfGUIDDriver.hxx
src/TFunction/TFunction_DataMapOfLabelListOfLabel.hxx
src/TFunction/TFunction_DoubleMapOfIntegerLabel.hxx
src/TNaming/FILES
src/TNaming/TNaming_Localizer.cxx
src/TNaming/TNaming_MapOfNamedShape.hxx
src/TNaming/TNaming_NamedShapeHasher.hxx [deleted file]
src/TObj/FILES
src/TObj/TObj_Application.hxx
src/TObj/TObj_Assistant.cxx
src/TObj/TObj_Assistant.hxx
src/TObj/TObj_Common.hxx [deleted file]
src/TObj/TObj_Container.hxx
src/TObj/TObj_Object.hxx
src/TObj/TObj_ObjectIterator.hxx
src/TObj/TObj_TIntSparseArray.hxx
src/TObj/TObj_TObject.hxx
src/TObj/TObj_TReference.hxx
src/TObj/TObj_TXYZ.hxx
src/TPrsStd/TPrsStd_DataMapOfGUIDDriver.hxx
src/TopLoc/FILES
src/TopLoc/TopLoc_IndexedMapOfLocation.hxx
src/TopLoc/TopLoc_Location.cxx
src/TopLoc/TopLoc_Location.hxx
src/TopLoc/TopLoc_Location.lxx
src/TopLoc/TopLoc_MapLocationHasher.hxx [deleted file]
src/TopLoc/TopLoc_MapOfLocation.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Area1dBuilder.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Area1dBuilder.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Area2dBuilder.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Area3dBuilder.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_AreaBuilder.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_AreaBuilder.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_BuildEdges.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_CompositeClassifier.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_CorrectFace2d.hxx
src/TopOpeBRepBuild/TopOpeBRepBuild_End.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_GridFF.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_GridSS.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_HBuilder.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_Section.cxx
src/TopOpeBRepBuild/TopOpeBRepBuild_ShellFaceSet.hxx
src/TopOpeBRepDS/TopOpeBRepDS_Check.cxx
src/TopOpeBRepDS/TopOpeBRepDS_DataMapOfCheckStatus.hxx
src/TopOpeBRepDS/TopOpeBRepDS_DataMapOfIntegerListOfInterference.hxx
src/TopOpeBRepDS/TopOpeBRepDS_DataMapOfInterferenceListOfInterference.hxx
src/TopOpeBRepDS/TopOpeBRepDS_DataMapOfInterferenceShape.hxx
src/TopOpeBRepDS/TopOpeBRepDS_DoubleMapOfIntegerShape.hxx
src/TopOpeBRepDS/TopOpeBRepDS_EIR.cxx
src/TopOpeBRepDS/TopOpeBRepDS_EXPORT.cxx
src/TopOpeBRepDS/TopOpeBRepDS_FIR.cxx
src/TopOpeBRepDS/TopOpeBRepDS_MapOfCurve.hxx
src/TopOpeBRepDS/TopOpeBRepDS_MapOfIntegerShapeData.hxx
src/TopOpeBRepDS/TopOpeBRepDS_MapOfPoint.hxx
src/TopOpeBRepDS/TopOpeBRepDS_MapOfSurface.hxx
src/TopOpeBRepDS/TopOpeBRepDS_Marker.hxx
src/TopOpeBRepDS/TopOpeBRepDS_ProcessEdgeInterferences.cxx
src/TopOpeBRepDS/TopOpeBRepDS_ProcessFaceInterferences.cxx
src/TopOpeBRepDS/TopOpeBRepDS_ProcessInterferencesTool.cxx
src/TopOpeBRepTool/TopOpeBRepTool_DataMapOfOrientedShapeC2DF.hxx
src/TopOpeBRepTool/TopOpeBRepTool_FuseEdges.cxx
src/TopOpeBRepTool/TopOpeBRepTool_IndexedDataMapOfShapeBox.hxx
src/TopOpeBRepTool/TopOpeBRepTool_IndexedDataMapOfShapeBox2d.hxx
src/TopTools/FILES
src/TopTools/TopTools_DataMapOfIntegerListOfShape.hxx
src/TopTools/TopTools_DataMapOfIntegerShape.hxx
src/TopTools/TopTools_DataMapOfOrientedShapeInteger.hxx
src/TopTools/TopTools_DataMapOfOrientedShapeShape.hxx
src/TopTools/TopTools_IndexedDataMapOfShapeAddress.hxx
src/TopTools/TopTools_IndexedMapOfOrientedShape.hxx
src/TopTools/TopTools_MapOfOrientedShape.hxx
src/TopTools/TopTools_OrientedShapeMapHasher.hxx [deleted file]
src/TopTools/TopTools_OrientedShapeMapHasher.lxx [deleted file]
src/TopTools/TopTools_ShapeMapHasher.hxx
src/TopTools/TopTools_ShapeMapHasher.lxx [deleted file]
src/TopoDS/FILES
src/TopoDS/TopoDS_CompSolid.hxx
src/TopoDS/TopoDS_CompSolid.lxx [deleted file]
src/TopoDS/TopoDS_Compound.hxx
src/TopoDS/TopoDS_Compound.lxx [deleted file]
src/TopoDS/TopoDS_Edge.hxx
src/TopoDS/TopoDS_Edge.lxx [deleted file]
src/TopoDS/TopoDS_Face.hxx
src/TopoDS/TopoDS_Face.lxx [deleted file]
src/TopoDS/TopoDS_Shape.cxx
src/TopoDS/TopoDS_Shape.hxx
src/TopoDS/TopoDS_Shell.hxx
src/TopoDS/TopoDS_Shell.lxx [deleted file]
src/TopoDS/TopoDS_Solid.hxx
src/TopoDS/TopoDS_Solid.lxx [deleted file]
src/TopoDS/TopoDS_Vertex.hxx
src/TopoDS/TopoDS_Vertex.lxx [deleted file]
src/TopoDS/TopoDS_Wire.hxx
src/TopoDS/TopoDS_Wire.lxx [deleted file]
src/Transfer/FILES
src/Transfer/Transfer_Actor.gxx [deleted file]
src/Transfer/Transfer_ActorOfProcessForFinder_0.cxx
src/Transfer/Transfer_ActorOfProcessForTransient_0.cxx
src/Transfer/Transfer_FindHasher.cxx [deleted file]
src/Transfer/Transfer_FindHasher.hxx
src/Transfer/Transfer_Finder.cxx
src/Transfer/Transfer_Finder.hxx
src/Transfer/Transfer_Iterator.gxx [deleted file]
src/Transfer/Transfer_IteratorOfProcessForFinder_0.cxx
src/Transfer/Transfer_IteratorOfProcessForTransient_0.cxx
src/Transfer/Transfer_Mapper.gxx [deleted file]
src/Transfer/Transfer_ProcessForFinder_0.cxx
src/Transfer/Transfer_ProcessForTransient_0.cxx
src/Transfer/Transfer_TransferMapOfProcessForTransient.hxx
src/Transfer/Transfer_TransferProcess.gxx [deleted file]
src/Transfer/Transfer_TransientMapper.hxx
src/Transfer/Transfer_TransientMapper_0.cxx
src/TransferBRep/FILES
src/TransferBRep/TransferBRep_OrientedShapeMapper.hxx [deleted file]
src/TransferBRep/TransferBRep_OrientedShapeMapper_0.cxx [deleted file]
src/TransferBRep/TransferBRep_ShapeMapper_0.cxx
src/V3d/V3d_View.cxx
src/ViewerTest/ViewerTest_DoubleMapOfInteractiveAndName.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
src/VrmlData/VrmlData_Node.cxx
src/VrmlData/VrmlData_Node.hxx
src/WNT/WNT_WClass.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DataMapOfToleranceDatum.hxx
src/XCAFDoc/XCAFDoc_AssemblyItemId.hxx
src/XCAFDoc/XCAFDoc_DimTolTool.cxx
src/XCAFDoc/XCAFDoc_DimTolTool.hxx
src/XCAFPrs/XCAFPrs_AISObject.cxx
src/XCAFPrs/XCAFPrs_DataMapOfStyleShape.hxx
src/XCAFPrs/XCAFPrs_DataMapOfStyleTransient.hxx
src/XCAFPrs/XCAFPrs_DocumentNode.hxx
src/XCAFPrs/XCAFPrs_Style.hxx
src/XDEDRAW/XDEDRAW.cxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML_CoordsMap.hxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.hxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.hxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML_ElemNodesMap.hxx
src/XmlMDF/XmlMDF_MapOfDriver.hxx
src/XmlMDF/XmlMDF_TypeADriverMap.hxx
src/XmlTObjDrivers/XmlTObjDrivers.hxx
src/XmlTObjDrivers/XmlTObjDrivers_DocumentRetrievalDriver.hxx
src/XmlTObjDrivers/XmlTObjDrivers_DocumentStorageDriver.hxx
src/XmlTObjDrivers/XmlTObjDrivers_ObjectDriver.hxx
src/gp/gp_Pnt.hxx
src/math/FILES
src/math/math_IntegerVector.cxx [deleted file]
src/math/math_IntegerVector.hxx
src/math/math_Matrix.cxx
src/math/math_Matrix.hxx
src/math/math_Matrix.lxx
src/math/math_Recipes.hxx
src/math/math_Vector.cxx [deleted file]
src/math/math_Vector.hxx
src/math/math_VectorBase.hxx [new file with mode: 0644]
src/math/math_VectorBase.lxx [new file with mode: 0644]
tests/bugs/caf/bug31546
tests/bugs/fclasses/bug7287_6
tests/bugs/xde/bug23570
tools/MessageModel/MessageModel_ItemRoot.cxx
tools/View/View_Viewer.cxx

index 3e83986ce366e560ec1d9fcb52b22a78fc99cfc3..1215533609e4137ddfcc0d3f1f8900a57ad63a4c 100644 (file)
 #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
index 570b0c65e13454da773525edb3b63676dbba7228..2eef2c6abef3f521db8c78555a448ccdb844806f 100644 (file)
@@ -21,7 +21,6 @@
 #include <NCollection_IndexedDataMap.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopTools_MapOfShape.hxx>
-#include <TColStd_MapTransientHasher.hxx>
 
 class StdSelect_BRepOwner;
 
@@ -104,7 +103,7 @@ protected: //! @name override presentation computation
 
 protected:
 
-  typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound, TColStd_MapTransientHasher> DataMapOfDrawerCompd;
+  typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound> DataMapOfDrawerCompd;
 
 protected:
 
index 64decc8336268054ecb00770425095cabd8e0993..b5ec89afcbc41b118d82564dea1bcfeef614eaca 100644 (file)
@@ -30,7 +30,6 @@
 #include <StdSelect.hxx>
 #include <StdSelect_BRepOwner.hxx>
 #include <TopoDS_Shape.hxx>
-#include <TopTools_OrientedShapeMapHasher.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive,AIS_InteractiveObject)
 
@@ -241,7 +240,7 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
                                                          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))
index 6451e844c35884514572893c37063bfd1369a48e..07f8b5c90f94f688b432187f9c08a599873028ca 100644 (file)
 
 #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
index 32428cf04f6aac8612020e3f8f204a1ff96ab9ab..4244db55ab64eb9f71be7eb15355eea4b97d232c 100644 (file)
@@ -640,18 +640,9 @@ protected:
 
 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
index 74f58b76ca3e54b62a63414f4dfe62e24b92580b..245cc01b09b9159164cf70c97a1cf3fd07306b31 100644 (file)
@@ -30,7 +30,6 @@
 #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>
index 757db18ef742eafe9971c7064d96bfa8bdef6918..fc014b203b3044484e892d08d1bbd5ffa1e29dcc 100644 (file)
@@ -24,7 +24,6 @@
 #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>
index 7cc15f2dbc79354cf69faae87c6813806445c986..0c5c3dab67c1de5e34bc3618b6b141fdf14171e2 100644 (file)
@@ -1238,7 +1238,7 @@ void VBernstein(const Standard_Integer classe,
   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.);
   
@@ -1248,7 +1248,6 @@ void VBernstein(const Standard_Integer classe,
     for (j = 1; j <= nbpoints; j++) {
       M(i, j) = *tmpVB;
       tmpVB++;
-      k++;
     }
   }
 }
index 51300f2903f4c6e4bec94ce19519fadfdf9c7bc0..67bdfb4830d5e89cf80086267e4733de4653bdb7 100644 (file)
@@ -22,7 +22,7 @@
 #include <math_Matrix.hxx>
 #include <NCollection_Array1.hxx>
 #include <AppParCurves_Constraint.hxx>
-
+#include <math_Vector.hxx>
 
 struct PeriodicityInfo
 {
index 6a6175823c7dbab53d4c498b7127f4e448f44d30..9e63eb95a9a144e8c9adedab0c37d591cafad9b2 100644 (file)
@@ -13,7 +13,6 @@
 // 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>
@@ -1392,7 +1391,7 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
   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);
@@ -1427,11 +1426,6 @@ Standard_Boolean  Approx_ComputeLine::ComputeCurve(const MultiLine& Line,
     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.
index b54e81e2192899fe0522d70d16531dc3057797e2..b2bfa6c6b5804868a700a698f5167eaf172d0f4e 100644 (file)
 #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.
index eb9437f05e6477fc243607f0a3f39bb96d79e3de..84b9299b3dd5267660b8cf94a462683cddac405a 100644 (file)
@@ -53,6 +53,6 @@ protected:
 };
 
 //! 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
index fa5c695dc001221dada4cb02e4909802b1033a39..9bbf8b9704f5d662608657a6992d4a5665da54a8 100644 (file)
@@ -50,6 +50,6 @@ protected:
   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
index 2154b04c30617a3960bf70ed729e7ee295a27994..59efc80e406bccb305636c35757d4be1a71326e5 100644 (file)
@@ -167,7 +167,7 @@ void BOPAlgo_BuilderFace::Perform(const Message_ProgressRange& theRange)
 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;
   //
@@ -175,14 +175,11 @@ void BOPAlgo_BuilderFace::PerformShapesToAvoid(const Message_ProgressRange& theR
   //
   Message_ProgressScope aPS(theRange, NULL, 1);
   //
-  iCnt=0;
   for(;;) {
     if (UserBreak(aPS))
     {
       return;
     }
-
-    ++iCnt;
     bFound=Standard_False;
     //
     // 1. MEF
index 9049bfbcebac386ff6692d45102f863ec106c86b..1f506a9c2adb9af00127fc089a12819e1bb0a782 100644 (file)
@@ -142,7 +142,7 @@ void BOPAlgo_BuilderSolid::Perform(const Message_ProgressRange& theRange)
 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;
@@ -151,12 +151,10 @@ void BOPAlgo_BuilderSolid::PerformShapesToAvoid(const Message_ProgressRange& the
   //
   Message_ProgressScope aPS(theRange, NULL, 1);
   //
-  iCnt=0;
   for(;;) {
     if (UserBreak(aPS)) {
       return;
     }
-    ++iCnt;
     bFound=Standard_False;
     //
     // 1. MEF
index f2ebfef1719f126f278c24355cbc1d1ad32129ce..219f5d9f9acfc0fa6e12c8e7ce53e47136b6e218 100644 (file)
@@ -549,8 +549,7 @@ void BOPAlgo_Builder::BuildSplitFaces(const Message_ProgressRange& theRange)
 //=======================================================================
 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,
@@ -619,8 +618,7 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange)
 
   // 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);
@@ -700,7 +698,7 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange)
         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
@@ -736,14 +734,12 @@ void BOPAlgo_Builder::FillSameDomainFaces(const Message_ProgressRange& theRange)
   {
     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
@@ -1027,7 +1023,7 @@ TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace,
       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))
index d00aa05df6b02379308a6393d895ac349e28d7c1..733b4c70577cc7eb900cf792ce4a8538d68e05e8 100644 (file)
@@ -27,7 +27,6 @@
 
 #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
@@ -321,8 +320,7 @@ protected: //! @name Fields
   // 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)
index cd2275d994bf6b3c7c5e7c8b14869ca2aa060a64..a2fb939abf5caf0cc807398c896961f02cb35473 100644 (file)
@@ -180,13 +180,11 @@ protected:
 
   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,
@@ -658,8 +656,8 @@ protected: //! Fields
                                                 //! 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
 
 };
index 9435f46ec625e112ed483ee1ec4e15cdad2511e5..e1cb9cfb26f4786184e6eb0a492052686145bed1 100644 (file)
@@ -75,7 +75,7 @@ void BOPAlgo_PaveFiller::PerformVV(const Message_ProgressRange& theRange)
     //
     if (myDS->HasInterf(n1, n2))
     {
-      BOPAlgo_Tools::FillMap<Standard_Integer, TColStd_MapIntegerHasher>(n1, n2, aMILI, aAllocator);
+      BOPAlgo_Tools::FillMap(n1, n2, aMILI, aAllocator);
       continue;
     }
 
@@ -91,12 +91,12 @@ void BOPAlgo_PaveFiller::PerformVV(const Message_ProgressRange& theRange)
 
     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);
index eecb0ff9a38de166d91ecfdc46899acbfbb9295a..3678bdf2fe219aec38833ae73137bb7d560f29f7 100644 (file)
@@ -229,7 +229,7 @@ void BOPAlgo_PaveFiller::IntersectVE
   // 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) {
@@ -407,8 +407,7 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const TColStd_MapOfInteger& theMEdges,
   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;
@@ -507,7 +506,7 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const TColStd_MapOfInteger& theMEdges,
     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();
index 0e36f380fb96a327f6ac6d0410a3f79ff7795801..7dd8b3ee418090e2963a1727541626d60c38ac97 100644 (file)
@@ -526,7 +526,7 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
           // 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:
@@ -964,8 +964,7 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange)
   // 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);
 
@@ -1147,7 +1146,7 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange)
 
   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++)
@@ -1221,14 +1220,11 @@ void BOPAlgo_PaveFiller::ForceInterfEE(const Message_ProgressRange& theRange)
         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);
 }
index e39b6276a1312bd2f997cf9ab3deb6cef40d7919..22dcacc2cd48892f086a7ae46997d9323cfa3c8a 100644 (file)
@@ -172,7 +172,7 @@ void BOPAlgo_PaveFiller::PerformVF(const Message_ProgressRange& theRange)
   //
   // 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))
     {
index 0e4c6ed89f29137cf47b98962811daf5d48e7e9e..4602355f31127c39c34fade026db35c4285a66b1 100644 (file)
@@ -573,30 +573,11 @@ Standard_Boolean BOPAlgo_PaveFiller::CheckFacePaves
    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
@@ -1073,7 +1054,7 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
   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++)
index 0a898132274b17718096f20e90bc10dac8902388..5fd7dc82faf65a6a3dcd793ed19e5bfa1c26d48e 100644 (file)
@@ -281,7 +281,7 @@ void BOPAlgo_PaveFiller::PerformFF(const Message_ProgressRange& theRange)
   //
   // 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)
   {
@@ -1198,8 +1198,7 @@ void BOPAlgo_PaveFiller::PostTreatFF
   // 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;
index 13151f8413131bb2575142688c26d8b4fdbb94e8..e39ab55efd905bc0f5ad1432f4cf3ac1b37c9435 100644 (file)
@@ -119,7 +119,7 @@ void BOPAlgo_Tools::PerformCommonBlocks(BOPDS_IndexedDataMapOfPaveBlockListOfPav
   }
   // 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;
@@ -132,7 +132,7 @@ void BOPAlgo_Tools::PerformCommonBlocks(BOPDS_IndexedDataMapOfPaveBlockListOfPav
       continue;
 
     // Reset the allocator
-    anAllocTmp->Reset();
+    anAllocTmp->Reset(false);
     // New common block
     Handle(BOPDS_CommonBlock) aCB;
     // Faces of the common block
@@ -1068,11 +1068,11 @@ void BOPAlgo_Tools::IntersectVertices(const TopTools_IndexedDataMapOfShapeReal&
   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())
index ec6cce7908312fad008f652ffeda6427aaae86f4..465edc273126cfc725f2510c8eb99e2502fab242 100644 (file)
@@ -42,31 +42,31 @@ class BOPAlgo_Tools
 {
 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);
           }
@@ -76,21 +76,21 @@ public:
   }
 
   //! 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);
   }
index 9ad33e6fdd3107ad9d56c89140ba3dfb202fa782..d7d693df86afc9db1c5252acd6c4296354df3cbe 100644 (file)
@@ -965,8 +965,8 @@ void BOPDS_DS::UpdateCommonBlock(const Handle(BOPDS_CommonBlock)& theCB,
   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;
index 6c8a35d70deefa65381b8ec59a07380c7bfc9884..630928f1ed696cc455036b4b9703f4234e3b7b0e 100644 (file)
@@ -18,6 +18,6 @@
 #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
index 0694c8386de2c583b23a32d46b56224b0dd52da2..f805274635a0b60311d2033d4d5eed909a7e8427 100644 (file)
 #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
index 7fc61c0e08ede1da38717aad3e7da73a4a20be3b..96a2cdef8b265e4032fe7d79f0a1a66ae0706636 100644 (file)
 #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
index fa2f68daec2c4663fd59454ab1f8c49ce1a065e8..0d04eb0f54ad4e8ee1980991007eb021ff7bcb04 100644 (file)
 #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
index 2236e4d33cf1a712b49c5a450c98c1e8c827cd3b..a9bdbfe4cb39726da67338fb0c74ec9ce76e0bc0 100644 (file)
 #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
index c8e0382c41c5981b4f01f6ffdf6644f9131d03bd..3ce09a5b22e169d5688fed6310004f136450a099 100644 (file)
 #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
index 8ed5f348581a0b88edc2c52c6950714e37a9b6d3..7b990919bc5107536034fa58ad81b6f460d2e24e 100644 (file)
@@ -16,9 +16,8 @@
 #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
index 8692313da88cbad17efbffcdc48999ecc5cf71f9..501686356fd078fd656f024de261d2c274ab4c89 100644 (file)
 #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;
 
index 6ab02038327586b26680ef129ca9825e712943d1..21dccc1cd59ed6cd6576e70f20574e36938ba824 100644 (file)
 #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
index e9a9e73f236db891cc11f862868ea7094110f0d6..ac9754404533f04758fc8277bd84f0fc715ed494 100644 (file)
 #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
index d445e389436e425360f1d76e794674fdd601cfa7..22f63dd62c979938ed7d66401bbb5b74bfa962a9 100644 (file)
 #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
index 784e101104ed14ed48b6cc508e1a6f7ba82e53b2..fb75669f7aace3e075d9200d96a0f063740696ac 100644 (file)
 #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
index e26a7d3fd02d80f07c911fc527e517764c435e07..0fbd17002b778332bca88f32f6716eac356554ea 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
+#include <Standard_HashUtils.hxx>
 
 //! The class is to provide the pair of indices of interfering shapes.
 
@@ -62,12 +63,9 @@ class BOPDS_Pair {
            (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:
@@ -75,4 +73,23 @@ class BOPDS_Pair {
   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
diff --git a/src/BOPDS/BOPDS_PairMapHasher.hxx b/src/BOPDS/BOPDS_PairMapHasher.hxx
deleted file mode 100644 (file)
index 64d7ec7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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
index 8d5bcc069c93f8bd8185049538cc74f3f43f7b67..6a09d57bccbf82728609a77c866989923702a227 100644 (file)
@@ -103,6 +103,20 @@ private:
 
 };
 
+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>
 
diff --git a/src/BOPDS/BOPDS_PaveMapHasher.hxx b/src/BOPDS/BOPDS_PaveMapHasher.hxx
deleted file mode 100644 (file)
index e64a644..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// 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
diff --git a/src/BOPDS/BOPDS_PaveMapHasher.lxx b/src/BOPDS/BOPDS_PaveMapHasher.lxx
deleted file mode 100644 (file)
index a6fb0b4..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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);
-}
index d66100a5218d709b5f2d6b55ebb61945d908c8d1..f7ce702c13fb4aa7e9b01f91e350b344508d5757 100644 (file)
@@ -35,8 +35,6 @@ BOPDS_Pave.hxx
 BOPDS_Pave.lxx
 BOPDS_PaveBlock.cxx
 BOPDS_PaveBlock.hxx
-BOPDS_PaveMapHasher.hxx
-BOPDS_PaveMapHasher.lxx
 BOPDS_PDS.hxx
 BOPDS_PIterator.hxx
 BOPDS_PIteratorSI.hxx
@@ -67,7 +65,6 @@ BOPDS_VectorOfPave.hxx
 BOPDS_VectorOfPoint.hxx
 BOPDS_VectorOfShapeInfo.hxx
 BOPDS_Pair.hxx
-BOPDS_PairMapHasher.hxx
 BOPDS_MapOfPair.hxx
 BOPDS_VectorOfPair.hxx
 BOPDS_VectorOfVectorOfPair.hxx
index a2857d0744de1e27af1b21eca735c238af22912e..5ad63044fa2ccf3b2810d1ee87b581ac1d984e73 100644 (file)
 #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
index bea5786138b95d3868fe61b80091a279d418461e..0a9e80b0bce9bbeab8037b3c64f3c2c76b413a02 100644 (file)
 #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
index 2f34d7bc4e2a719a2815afe182dbec2af678f474..de87a3a0a5a458a878cca4a778c3e94838c33ee8 100644 (file)
@@ -50,25 +50,6 @@ class BOPTools_Parallel
   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
@@ -116,7 +97,7 @@ class BOPTools_Parallel
 
   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;
   };
 
index d6a146aef0e223f3d9779eb310bcd2b6a8292a6e..1c97deac1cb0c4e5cb87dfa654cc9fda3bd4fe61 100644 (file)
@@ -21,8 +21,8 @@
 #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 : 
@@ -127,15 +127,6 @@ const TopoDS_Shape& BOPTools_Set::Shape()const
   return myShape;
 }
 
-//=======================================================================
-// function : HashCode
-// purpose  :
-//=======================================================================
-Standard_Integer BOPTools_Set::HashCode (const Standard_Integer theUpperBound) const
-{
-  return ::HashCode (mySum, theUpperBound);
-}
-
 //=======================================================================
 //function : IsEqual
 //purpose  : 
@@ -177,7 +168,7 @@ Standard_Boolean BOPTools_Set::IsEqual
 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;
   //
@@ -223,7 +214,7 @@ void BOPTools_Set::Add(const TopoDS_Shape& theS,
   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;
   }
@@ -232,13 +223,13 @@ void BOPTools_Set::Add(const TopoDS_Shape& theS,
 // 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;
index bd6ecd2939cf1830ca1d9f5c81c51e2f232dce08..67cb07d82d3e0e281c356634a66f477424623ee0 100644 (file)
@@ -55,11 +55,12 @@ BOPTools_Set& operator = (const BOPTools_Set& Other)
   
   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:
 
@@ -71,22 +72,20 @@ 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
diff --git a/src/BOPTools/BOPTools_SetMapHasher.hxx b/src/BOPTools/BOPTools_SetMapHasher.hxx
deleted file mode 100644 (file)
index 875f0b0..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// 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
diff --git a/src/BOPTools/BOPTools_SetMapHasher.lxx b/src/BOPTools/BOPTools_SetMapHasher.lxx
deleted file mode 100644 (file)
index 3cdd0c9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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);
-}
index 26ade9a944b3a73969f08dab37de0b3682b6972a..3e6777deae35a02d8779bb312d65b22dc7a62f89 100755 (executable)
@@ -19,5 +19,3 @@ BOPTools_PairSelector.hxx
 BOPTools_Parallel.hxx
 BOPTools_Set.cxx
 BOPTools_Set.hxx
-BOPTools_SetMapHasher.hxx
-BOPTools_SetMapHasher.lxx
index ab78ac8e0ba0ca2b32802cd37e6f83cbf316a3eb..d0759d654069dc001c2d5399f2d5e3f4964c0661 100644 (file)
@@ -356,7 +356,7 @@ static void UpdateCurves(BRep_ListOfCurveRepresentation& lcr,
   }
   
   if (itcr.More()) {
-    Handle(BRep_CurveRepresentation)& cr = itcr.Value();
+    Handle(BRep_CurveRepresentation) cr = itcr.Value();
     cr->Continuity(C);
   }
   else {
@@ -380,7 +380,7 @@ static void UpdatePoints(BRep_ListOfPointRepresentation& lpr,
   }
 
   if (itpr.More()) {
-    Handle(BRep_PointRepresentation)& pr = itpr.Value();
+    Handle(BRep_PointRepresentation) pr = itpr.Value();
     pr->Parameter(p);
   }
   else {
@@ -404,7 +404,7 @@ static void UpdatePoints(BRep_ListOfPointRepresentation& lpr,
   }
 
   if (itpr.More()) {
-    Handle(BRep_PointRepresentation)& pr = itpr.Value();
+    Handle(BRep_PointRepresentation) pr = itpr.Value();
     pr->Parameter(p);
   }
   else {
@@ -430,7 +430,7 @@ static void UpdatePoints(BRep_ListOfPointRepresentation& lpr,
   }
 
   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
index f4d4c59df4590511093b3c1211a62eecf6fb0b4b..57b95f7ef074bfd1aace89e5196bc543a21b16bf 100644 (file)
@@ -1053,7 +1053,7 @@ void  BRep_Tool::SetUVPoints(const TopoDS_Edge& E,
   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)
       {
index 5ed2ab2e70cbf834efa71d869b3561f241814ede..05c849b35342c4dd4dbbba119415ed635c9e3cff 100644 (file)
@@ -384,7 +384,7 @@ void BRepAlgo_FaceRestrictor::PerformWithCorrection()
   // 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());
@@ -402,7 +402,7 @@ void BRepAlgo_FaceRestrictor::PerformWithCorrection()
   // 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)) {
index 828e9f091e6bdc15ea5600d4dd2a22f021a90797..259da53f1d21dfe3443f8a1331759a5a92f99005 100644 (file)
@@ -572,7 +572,7 @@ void BRepAlgo_Loop::Perform()
     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);
@@ -585,7 +585,7 @@ void BRepAlgo_Loop::Perform()
   // => 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);
   }
@@ -900,7 +900,7 @@ void  BRepAlgo_Loop::WiresToFaces()
 //          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();
index a8d89f4fb3e41acf21108c3491c32c576a44c214..1a6fce3bb36372cb86ef42faa7b3e166d30d4858 100644 (file)
@@ -21,7 +21,6 @@
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
 
-#include <Standard_Address.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_Real.hxx>
index ed1c6bd4eb9b272a09fff136cc3e1a5461306b50..abefca5b62749ea2b7c5459fda91a074e30df5ca 100644 (file)
@@ -20,7 +20,6 @@
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
 
-#include <Standard_Address.hxx>
 #include <math_Vector.hxx>
 #include <Blend_Point.hxx>
 #include <gp_Pnt.hxx>
index 8f919bfa6efc7c47450860c2c08bd4e799a1a923..6e0cb4d82297aa8a9de9f676d9cb52d64e6622e0 100644 (file)
@@ -22,6 +22,7 @@
 #include <BRepBuilderAPI_MakeVertex.hxx>
 #include <BRepBuilderAPI_MakeWire.hxx>
 #include <NCollection_IndexedDataMap.hxx>
+#include <Standard_HashUtils.hxx>
 
 namespace
 {
@@ -47,32 +48,30 @@ 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;
-    }
-
   };
 }
 
@@ -115,7 +114,7 @@ void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange
   }
 
   // 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();
index b05003f42fc70f28489cec95faa082d61069cd8b..5e6dbd836d6697bac2bf9cb4b79c5350f2adeb1e 100644 (file)
 #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&,
index 3d0183689fc750d222cdbeae37fa0ce01c37a8dd..8caadefa258e02f0d1fd451c6fda6909c811532d 100644 (file)
 
 #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
index d94e5226ad857ff8c2bbc34746949397daf7ff0d..1b9850abec67a8be3b82a6d853d2475e272b0f95 100644 (file)
@@ -82,9 +82,9 @@ Standard_EXPORT Standard_Integer BRepCheck_Trace(const Standard_Integer phase) {
   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;
   }
index 26658ba4f64398814e08cd318561649f5d173de3..43ae2342364a1ba8e7454ceec9689d941a559f2a 100644 (file)
@@ -18,7 +18,6 @@
 #define BRepClass3d_MapOfInter_HeaderFile
 
 #include <TopoDS_Shape.hxx>
-#include <Standard_Address.hxx>
 #include <TopTools_ShapeMapHasher.hxx>
 #include <NCollection_DataMap.hxx>
 
index 1b6ce78b76bef395e58e1271f82e023b4662d565..b6c63f82ba0c6cfa9e74317b157236f7fd4b8e52 100644 (file)
 
 #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
index de9e30a89d5957e029ada721c3864f7aeac861c4..726165b769eca824c51053f9e288cb4dbde1cf8d 100644 (file)
 
 #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
index d5081a77f98e5a2a7150c3293e1dab337b7b0039..fc02ce704a5def49c1a4e2fa8094690a2e828682 100644 (file)
 
 #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
index 76f7c96aa2a0bf7f92d6e1d4b859478e631d56ca..43ec222fe2d51243c0a07a83832824a1e279bd15 100644 (file)
@@ -1953,7 +1953,7 @@ void BRepFill_Evolved::Transfert(      BRepFill_Evolved&             Vevo,
 
       TopTools_ListIteratorOfListOfShape itl;
       for (itl.Initialize(GenShapes); itl.More(); itl.Next()) {
-        itl.Value().Move(LS);
+        itl.ChangeValue().Move(LS);
       }
 
       if (!myMap.IsBound(InitialSpine)) {
index b1b46e3714e0ffe4a17da6f1c4227fb6a23bc8e9..1c57f67b765a5f066a9a7c2d573477791a177652 100644 (file)
 
 #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
index 6db9e9df4daefdcf566fc827701a96671d5c01c9..befe34193cf7110e03a4822fbcda2a5819d42e79 100644 (file)
@@ -1068,8 +1068,8 @@ void BRepFill_OffsetWire::PerformWithBiLo
         {
           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);
         }
       }
     }
index f275ec69b1c3f18f467402aa52dcb35332fb4d59..bcefa9df555a59f251135ebd724abaa5b364dcec 100644 (file)
@@ -238,7 +238,7 @@ static Handle(Geom2d_Curve) Couture(const TopoDS_Edge& E,
     ((*((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) 
index 825b15f00edc1a538fe6f24aa4a5d293f09f15c5..aeff51845c4f010158352f9f5edecb4bf8f4c7a8 100644 (file)
@@ -17,7 +17,8 @@
 #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
index 1593ace13bde02d91e747f9609898edba4581660..c37dae4a8ebb8b2573ace453512a1b88dc1a40c0 100644 (file)
@@ -20,7 +20,6 @@
 #include <Standard_DefineAlloc.hxx>
 
 #include <GProp_GProps.hxx>
-#include <Standard_Address.hxx>
 class BRepGProp_Face;
 class BRepGProp_Domain;
 class gp_Pln;
index 2466e5dab3e62f6a2820fe466cef2fca0fbf7ecb..e5f5e002cbeccad1163cbf23207fe3e13f5b55cd 100644 (file)
@@ -74,6 +74,7 @@
 #include <BRepTools_ReShape.hxx>
 #include <TopTools_DataMapOfShapeReal.hxx>
 #include <TopoDS_LockedShape.hxx>
+#include <Standard_HashUtils.hxx>
 
 #include <algorithm>
 
@@ -2235,7 +2236,6 @@ static void EncodeRegularity(const TopoDS_Shape&        theShape,
     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())
@@ -2247,7 +2247,7 @@ static void EncodeRegularity(const TopoDS_Shape&        theShape,
           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()); }
@@ -2511,12 +2511,6 @@ namespace
       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
     {
@@ -2530,12 +2524,23 @@ namespace
       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)
@@ -2823,7 +2828,7 @@ void BRepLib::BoundingVertex(const NCollection_List<TopoDS_Shape>& theLV,
     // 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);
index a1b802143c2fb9fa3f4ac14eea85bf9b14c78e99..537c9c318194f96983f9c07cc7a4dfbf401118f1 100644 (file)
@@ -1055,7 +1055,7 @@ Standard_Boolean BRepLib_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOldEdge,
            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);
index 7e3f332ecbb989d157eec41df3f89c2c2176cc6e..e4ad89df93df112a46c7262d945c9612edb13fd3 100644 (file)
@@ -379,7 +379,7 @@ void BRepLib_MakeWire::CreateNewListOfEdges(const TopTools_ListOfShape& theL,
     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));
index 94cf836b5989fdfe0b9c25ce77cd359f0cf44c8f..0e2a8422b6e869a93f6befc09194d465ef2df6a3 100644 (file)
 
 #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
index f0c50b9bf5c847a98e08bbc4c56206390277b847..c5741237555a949ec0f78c37582a70cc4ca02347 100644 (file)
@@ -17,6 +17,7 @@
 #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
@@ -84,13 +85,28 @@ private:
   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
index 0cc32b0707b3607dee623cc559d9781fa85d8aa7..bbe306d48775d8649af227cc2388600793c42bf0 100644 (file)
@@ -15,6 +15,7 @@
 #define _BRepMesh_OrientedEdge_HeaderFile
 
 #include <Standard.hxx>
+#include <Standard_HashUtils.hxx>
 #include <Standard_DefineAlloc.hxx>
 
 //! Light weighted structure representing simple link.
@@ -52,14 +53,6 @@ public:
     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.
@@ -80,13 +73,24 @@ private:
   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
index abc61fd367eab9cf72cf5dc22d4fcc4f4c00e3d3..fefdd456c5f509250bbf6c4b367668ee37cd3076 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
+#include <Standard_HashUtils.hxx>
 
 #include <BRepMesh_DegreeOfFreedom.hxx>
 
@@ -91,14 +92,6 @@ public:
     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.
@@ -142,13 +135,18 @@ public:
   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
index b991817a84938216daeb920967b59db0634af533..838dd3ebcdb17557a059add7e275ecbaed6349bd 100644 (file)
@@ -102,14 +102,6 @@ public:
   {
     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.
@@ -138,13 +130,16 @@ private:
   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
index a1daaf3af7e33465f307e28ffb138dfdebedcfe3..e11da7a380cb199eec5603cb00f7d5b564967dd1 100644 (file)
@@ -24,8 +24,8 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepMeshData_Curve, IMeshData_Curve)
 // 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))
 {
 }
 
index 1731c174e2cfe90c0cca6b0e8e39cdbaf08dbe85..260cfbdc1f58493500429073049ad82d07209028 100644 (file)
@@ -32,7 +32,7 @@ BRepMeshData_Model::BRepMeshData_Model (const TopoDS_Shape& theShape)
     myDFaces (256, myAllocator),
     myDEdges (256, myAllocator)
 {
-  myAllocator->SetThreadSafe();
+  myAllocator->SetThreadSafe(true);
 }
 
 //=======================================================================
@@ -59,8 +59,7 @@ Standard_Integer BRepMeshData_Model::FacesNb () const
 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);
 }
 
 //=======================================================================
@@ -88,8 +87,7 @@ Standard_Integer BRepMeshData_Model::EdgesNb () const
 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);
 }
 
 //=======================================================================
index cff9950e9ac7269a585390f63cf80eb9c368abaf..a3d32bab1447ac481961b1600ac9be8e1f856461 100644 (file)
@@ -29,9 +29,9 @@ BRepMeshData_PCurve::BRepMeshData_PCurve (
   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))
 {
 }
 
index 5eccbe11f56dabf3ef96056451278e45feef178e..df326ec6557d50b163d2627a22da9aabf5853c6c 100644 (file)
@@ -4720,7 +4720,7 @@ Standard_Boolean BuildShellsCompleteInter(const TopTools_ListOfShape& theLF,
     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);
@@ -4739,7 +4739,7 @@ Standard_Boolean BuildShellsCompleteInter(const TopTools_ListOfShape& theLF,
   }
 
   // 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);
@@ -4787,7 +4787,7 @@ Standard_Boolean BuildShellsCompleteInter(const TopTools_ListOfShape& theLF,
   //
   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
@@ -4896,7 +4896,7 @@ const TopTools_ListOfShape& BRepOffset_MakeOffset::Generated (const TopoDS_Shape
           // Useful only for faces without influence on others.
           TopTools_ListIteratorOfListOfShape it(myGenerated);
           for (; it.More(); it.Next())
-            it.Value().Reverse();
+            it.ChangeValue().Reverse();
         }
       }
       break;
@@ -4951,7 +4951,7 @@ const TopTools_ListOfShape& BRepOffset_MakeOffset::Modified (const TopoDS_Shape&
         // Useful only for faces without influence on others.
         TopTools_ListIteratorOfListOfShape it(myGenerated);
         for (; it.More(); it.Next())
-          it.Value().Reverse();
+          it.ChangeValue().Reverse();
       }
     }
   }
index a5c46ba99d1deaef114c7fbb3df46bfb3bc20cbb..a533faecbde8fe1cbf56f6defc71520fbd84555d 100644 (file)
 #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;
index 55c7cd359704d3c085fc6eb2d023d19c74a8e2fc..45ce024999da537adce73fa253f1a6aa123d1ede 100644 (file)
@@ -4016,7 +4016,7 @@ void BRepOffset_Tool::CorrectOrientation(const TopoDS_Shape&        SI,
 //     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);
index 806ae4aa71c1cefa7de46a77492a02cadda3467b..9688969ada7147c9c8aeca47b196fcb72c504abe 100644 (file)
@@ -235,7 +235,7 @@ static void BuildDomains(TopoDS_Face&               myFace,
   //====================================================
   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;
@@ -291,7 +291,7 @@ static void BuildDomains(TopoDS_Face&               myFace,
 //  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); 
 
@@ -299,7 +299,7 @@ static void BuildDomains(TopoDS_Face&               myFace,
 
     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.
       //=======================================================
@@ -409,7 +409,7 @@ void BRepOffsetAPI_MakeOffset::Perform(const Standard_Real Offset,
 
       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())
         {
@@ -432,7 +432,7 @@ void BRepOffsetAPI_MakeOffset::Perform(const Standard_Real Offset,
 
       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())
@@ -494,7 +494,7 @@ const TopTools_ListOfShape& BRepOffsetAPI_MakeOffset::Generated
     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);
index bf8547da4f879ba9a6b31fd313aa2be80f6320fd..47bf68c9608cdc9ce147fef39cff452fa2ee6aef 100644 (file)
@@ -109,7 +109,7 @@ const TopTools_ListOfShape& BRepOffsetAPI_MakeThickSolid::Modified (const TopoDS
       // 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)
index 3a3f1c0293451576ba5dd8447f2dd8f1b41cf88e..9bb891f3a1867050881cea2e1ab52453449a64ad 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <BRepPrim_Revolution.hxx>
 #include <BRepPrimAPI_MakeOneAxis.hxx>
-#include <Standard_Address.hxx>
 class Geom_Curve;
 class gp_Ax2;
 
index 6a2aa5f1122c671fc2ed7c10a7998a6a391e76f5..1414f5008b3b2a79583a0af67e0a05fcd52569cb 100644 (file)
@@ -35,6 +35,7 @@
 #include <PLib.hxx>
 #include <Precision.hxx>
 #include <Standard_NotImplemented.hxx>
+#include <math_Vector.hxx>
 
 typedef gp_Pnt Pnt;
 typedef gp_Vec Vec;
index 5475891c7586b33d4dfe106810dccb3d3f66089a..17ef5b19f06d9236be12cf17ac79fb23817c6f04 100644 (file)
 
 #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
index fac8d35e8d66d6d22c9e94ee1d4d9fca8b4e75f4..4566c2092fa60bef9df04c14b4ed1cc8e32ef3c8 100644 (file)
 
 #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
index 1ee3e46d0b92ea1682cfc80554b9a9fae4fc88b8..a694a8341e1636dbeca018d4a2414b6093a94668 100644 (file)
@@ -276,7 +276,6 @@ void BinMNaming_NamedShapeDriver::Paste (const Handle(TDF_Attribute)& theSource,
   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();
@@ -296,8 +295,6 @@ void BinMNaming_NamedShapeDriver::Paste (const Handle(TDF_Attribute)& theSource,
       else
         TranslateTo (aNewShape, theTarget, static_cast<BinTools_ShapeSet*>(aShapeSet));
     }
-    
-    i++;
   }
 
 }
index 13331a116780c4c42fd9b5aa8ef91f07130d3ff8..de21ea124f04590728dd9dc9f779c5b7fd9fd0e3 100644 (file)
@@ -32,7 +32,6 @@
 #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;
index db1c7383f148fac2281742c0722b1758fd6c309d..7fa8d9e78d22a7eb658c5f48f2e9960837704352 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef BinTObjDrivers_HeaderFile
 #define BinTObjDrivers_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <Standard_GUID.hxx>
 
 class BinMDF_ADriverTable;
index ced6199898f3265c1ecbfd1b23a545a48f30c349..278f4e5030568cdc031156fdf9f2ea8b641431da 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef BinTObjDrivers_DocumentRetrievalDriver_HeaderFile
 #define BinTObjDrivers_DocumentRetrievalDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinLDrivers_DocumentRetrievalDriver.hxx>
 #include <BinMDF_ADriverTable.hxx>
 
index 862732966509f27bbc54dd7233935da39745a09d..3c9ad0bfa8d3941cfca63733fb9b995bfdd7ec5b 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef BinTObjDrivers_DocumentStorageDriver_HeaderFile
 #define BinTObjDrivers_DocumentStorageDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinLDrivers_DocumentStorageDriver.hxx>
 #include <BinMDF_ADriverTable.hxx>
 
index 64805a4d02c9cf8cd5f965de3ab20f0c4b6ee547..5d7027b85ecdf14de74ee54a34b910deb0a0b8f8 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef BinTObjDrivers_IntSparseArrayDriver_HeaderFile
 #define BinTObjDrivers_IntSparseArrayDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinMDF_ADriver.hxx>
 
 class BinTObjDrivers_IntSparseArrayDriver : public BinMDF_ADriver 
index fcb0c7ca038489df34a7c945253c0fd21a512c6e..ade93ebb0b20aa13122fc42f4a6463e5588b4cfb 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef BinTObjDrivers_ModelDriver_HeaderFile
 #define BinTObjDrivers_ModelDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinMDF_ADriver.hxx>
 
 class BinTObjDrivers_ModelDriver : public BinMDF_ADriver 
index 07341da00552bf5c6c24e1e3c5150c7a063ffe7b..769a975e70b4e8fdb54e92074008cabff6435ad7 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef BinTObjDrivers_ObjectDriver_HeaderFile
 #define BinTObjDrivers_ObjectDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinMDF_ADriver.hxx>
 
 class BinTObjDrivers_ObjectDriver : public BinMDF_ADriver 
index a9dec24dec2c5e596055acf08fc64869ee9bd7ef..c5f78ee06373c11dccb0f78ec6ad1ae9fa9b8c3c 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef BinTObjDrivers_ReferenceDriver_HeaderFile
 #define BinTObjDrivers_ReferenceDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinMDF_ADriver.hxx>
 
 class BinTObjDrivers_ReferenceDriver : public BinMDF_ADriver 
index 6e3c315d51676af783b6e48e638cb6d13a6d18d7..448ea586754df1eb6f8725d9659311bb70951047 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef BinTObjDrivers_XYZDriver_HeaderFile
 #define BinTObjDrivers_XYZDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <BinMDF_ADriver.hxx>
 
 class BinTObjDrivers_XYZDriver : public BinMDF_ADriver 
index 336590f90ec5dbbf83949c99956deb4cb59a74cc..8b8ed4dc91d382990cc3286eb7f609d5bcdb70fd 100644 (file)
 // 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
index 190d8a9084480def6ea8436f611f553cd851cf8b..baa44fa447b8c5c7a34a3eaccaa6d45db732f0b9 100644 (file)
 #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;
index 83add9525c801d7f6cda430398421c8dd9a8c620..dff48a8eacb6f9dc29b17609306fc6b7d6f5dd9a 100644 (file)
@@ -183,12 +183,12 @@ private:
   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
index 9782195bbabf9a40afced191bac13f617d2a8887..24adf243b3af3f0835fb896cec8e4c9725b61b94 100644 (file)
@@ -29,12 +29,6 @@ class gp_Pnt;
 //! 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
 {
index f9dc241fa06bc311c5a3ac7136e03deb298a8866..0daddae4e693d00eb7b2b9423143ac50cb533e63 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <BinTools_ShapeSetBase.hxx>
 #include <BinTools_OStream.hxx>
-#include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
 #include <TopTools_ShapeMapHasher.hxx>
 
 class Geom_Curve;
index b83e4f566355e5ff354a340f4b1f5a076a3d9424..6db19f130ecedb15fe2931d09a64aeaa5a953605 100644 (file)
@@ -26,7 +26,6 @@
 #include <Standard_Integer.hxx>
 #include <TColStd_DataMapOfIntegerInteger.hxx>
 #include <TColStd_ListOfInteger.hxx>
-#include <Standard_Address.hxx>
 class gp_Pln;
 
 
index b1ba162eac8164e91a94d180b479deb99b6da6ff..a5c2c05cfec54df1cb8690c7e45fa55617dfdad4 100644 (file)
@@ -720,7 +720,8 @@ public:
   myVMin(VMin),
   myVMax(VMax),
   myCoordIndx(CoordIndx),
-  mySign(Sign)
+  mySign(Sign),
+  myPenalty(0.)
   {
     math_Vector X(1,2);
     X(1) = UMin;
index 2b28131c5d03d50a4bb1177498f656d2b3192d52..3e5351d118c2e9e5abae4cf831ff6416d8317938 100644 (file)
@@ -157,8 +157,6 @@ TCollection_ExtendedString CDF_FWOSDriver::Concatenate(const TCollection_Extende
                                                           const TCollection_ExtendedString& aName)
 {
   TCollection_ExtendedString ff(aFolder);
-  ff = "";
-  ff += aFolder;
   PutSlash(ff);
   ff+=aName;
   return ff;
diff --git a/src/CDM/CDM_DocumentHasher.hxx b/src/CDM/CDM_DocumentHasher.hxx
deleted file mode 100644 (file)
index bf0edcf..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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
index 613ed2642dad9ccc610d2ffda6a23331c08503d2..d6fd8e4ab48296b107c574e3ec7595d3fe1f8868 100644 (file)
 #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
index b925bad765153180c7459f1c439191d4415b1d01..2877b5852fa843b63e04b9612f97511fbbcf79e5 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 769a0835b51bd26d5a752dfb4d3b94dd6a66631f..694470edb82e5595f6bc538f87778075edfbe254 100644 (file)
@@ -4,7 +4,6 @@ CDM_CanCloseStatus.hxx
 CDM_DataMapIteratorOfMetaDataLookUpTable.hxx
 CDM_Document.cxx
 CDM_Document.hxx
-CDM_DocumentHasher.hxx
 CDM_DocumentPointer.hxx
 CDM_ListIteratorOfListOfDocument.hxx
 CDM_ListIteratorOfListOfReferences.hxx
index f41848269652830407ea24da5162228e89472a9d..3159d94e5fe654eaac4b400d76a3fe3f4faac143 100644 (file)
@@ -236,7 +236,7 @@ void  ChFi3d_Builder::Compute()
     itel.Value()->Spine()->SetErrorStatus(ChFiDS_Ok);
     try {
       OCC_CATCH_SIGNALS
-      PerformSetOfSurf(itel.Value());
+      PerformSetOfSurf(itel.ChangeValue());
     }
     catch(Standard_Failure const& anException) {
 #ifdef OCCT_DEBUG
@@ -412,7 +412,7 @@ void  ChFi3d_Builder::Compute()
       }
       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 
@@ -440,7 +440,7 @@ void  ChFi3d_Builder::Compute()
       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 
index 2d92b13d23568ef960e503eca3f4578c6b463fc5..2f4764c9f0a73d099f946f4d099339ad9c1d084e 100644 (file)
@@ -2550,7 +2550,7 @@ void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe,
 #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
@@ -2559,7 +2559,7 @@ void ChFi3d_Builder::PerformSetOfKPart(Handle(ChFiDS_Stripe)& Stripe,
   {
     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);
 }
index edad09233a84d9f5ad0b33da203b66921ab9888e..b1d2cc32b759c981a7afddd358eb8ca2e04f1046 100644 (file)
@@ -3673,7 +3673,7 @@ Standard_Boolean ChFi3d_Builder::MoreSurfdata(const Standard_Integer Index) cons
 
   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);
index 3892b686bc952657411203c9d40656ce088a7dfa..be9864c9a3a6632c44e1445c3ada849373cbf9fd 100644 (file)
@@ -119,7 +119,7 @@ Standard_Boolean ChFi3d_Builder::PerformTwoCornerbyInter(const Standard_Integer
   //----------
   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);
@@ -130,7 +130,7 @@ Standard_Boolean ChFi3d_Builder::PerformTwoCornerbyInter(const Standard_Integer
   //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) {
@@ -649,7 +649,7 @@ void ChFi3d_Builder::UpdateTolesp()
   // 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)
index bc85cab5575923b31dcf3e9d7b838ae0a2847467..8383bad9b6ef23ef71e27bf288cabb2ab5b2392f 100644 (file)
@@ -843,7 +843,7 @@ static void RemoveSurfData (const ChFiDS_StripeMap & myVDataMap,
          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;
@@ -854,7 +854,7 @@ static void RemoveSurfData (const ChFiDS_StripeMap & myVDataMap,
          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);
       }
     }
   }
index 999cfae0c33a26cae39a970a37684a7b1dd3138e..237fd058f57fbd2c37f1bc45b8f7c8551a65b5f6 100644 (file)
@@ -590,7 +590,7 @@ void ChFi3d_ChBuilder::Simulate (const Standard_Integer IC)
   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;
     }
   }
index d893460feaba3fae5a7a584fe12cd462681f45d2..27e1af2ba410d4f0c818c08e0e3454e6b1f550d4 100644 (file)
@@ -453,7 +453,7 @@ void ChFi3d_FilBuilder::Simulate (const Standard_Integer IC)
   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;
     }
   }
index bfd3538257868aa9e1e8484755bf3000036bd346..39e7b582e5cf179ceb028db4e1348306525e8c42 100644 (file)
@@ -186,14 +186,14 @@ void  ChFiDS_FilSpine::SetRadius(const gp_XY&           UandR,
     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);
        }
       }  
     }
index 094a46cf5cee9fbb29f998245923cbfb73071c24..db7e47c5f0161c3ce89306f8644216e233c9e9b4 100644 (file)
 
 #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
index 95308e8ee919eb624e24a92fb6c9d1d9406b416f..55efde50a78b58b1fd653a003791c971bea8fa2a 100644 (file)
@@ -853,7 +853,7 @@ void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis)
       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();
index 03e442b57465544b528504927bfe394bccd47881..5912ca35c51b5ce8c323ad0ac7c9b089693f5c3b 100644 (file)
@@ -37,9 +37,6 @@
 #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();
index b9a2018d60fcb9cce3fc893dba772db7e73cbc07..3bdc9b75e6cfab625ade4a5d65058ae048f4ec0a 100644 (file)
@@ -28,7 +28,6 @@
 #include <NCollection_IndexedDataMap.hxx>
 class TopoDS_Face;
 class DBRep_Face;
-class TopTools_OrientedShapeMapHasher;
 
 //! Creation of isoparametric curves.
 class DBRep_IsoBuilder  : public Geom2dHatch_Hatcher
@@ -54,7 +53,7 @@ public:
 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
index 2e33afa2f2f87325ebf9dec7bf400e677d3ca5fb..ac86f34261bb21fc75bc143cf0a71a3dc23c98c4 100644 (file)
@@ -21,6 +21,7 @@
 #include <TDF_Transaction.hxx>
 #include <Standard_Transient.hxx>
 #include <Standard_Integer.hxx>
+#include <NCollection_DefineAlloc.hxx>
 class TDF_Data;
 class TDF_Delta;
 
index 44d5e01bbd143941fbcb7f4060a3e608ba22166b..d2f467ee1754e7b15ec427c16749386e3964c96a 100644 (file)
@@ -208,7 +208,7 @@ static Standard_Integer DDataStd_GetInteger (Draw_Interpretor& di,
         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();
       }
@@ -253,7 +253,7 @@ static Standard_Integer DDataStd_GetReal (Draw_Interpretor& di,
         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();
       }
@@ -1478,6 +1478,7 @@ static Standard_Integer DDataStd_GetUTFtoFile (Draw_Interpretor& di,
     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";
index d7abb18196d746f9710e9e92934ab0b24bf73c90..ad8ad8ac661592801e7aa19f856f207f8b564910 100644 (file)
@@ -17,7 +17,7 @@
 #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' 
index 16281c2e28edd9d9db7e8d68c880a5f6e6240814..bd9c6c7cacecd5613f9f7e24be96fe69b61aa84f 100644 (file)
@@ -574,7 +574,6 @@ Standard_EXPORT void DE_Wrapper::UpdateLoad(const Standard_Boolean theToForceUpd
 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())
   {
index eb5fedb91e9e2256737c9b680656fae0e7f05d96..02af4150d8a7d3e0dd7b1b34197904f12acfdb1d 100644 (file)
@@ -24,8 +24,8 @@ class TopoDS_Shape;
 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.
index 401e47d09db61c37d363685215da1c0d355cd4dd..12c5dec9435ed13bbed4610369e4d8a8ce8ffa0e 100644 (file)
@@ -167,7 +167,7 @@ static Standard_Integer Pload (Draw_Interpretor& theDI,
                                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]);
@@ -222,7 +222,7 @@ static Standard_Integer Pload (Draw_Interpretor& theDI,
     }
   }
 
-  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();
index 87f2dac252f6e676fd9ac21dd96a7810f06d1ba2..b63d48df0730e3306fc8f031e87764dadd70a67f 100644 (file)
@@ -98,7 +98,7 @@ Standard_Real& Draft_VertexInfo::ChangeParameter (const TopoDS_Edge& E)
   myItEd.Initialize(myEdges);
   for (; myItEd.More(); myItEd.Next(),itp.Next()) {
     if (myItEd.Value().IsSame(E)) {
-      return itp.Value();
+      return itp.ChangeValue();
     }
   }
   throw Standard_DomainError();
index cd6fe7e166bda245c460a637348cc0adf393c3e4..b25b18c32e83d2e20ae0abb58b79eeb4cadc22ed 100644 (file)
 
 #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;
 }
 
index 1e8504cbeb53d0379f8dfd8af9f6841f65f8eb6e..5b89c76bdf195a68caf4424c18b7429cbf2810d8 100644 (file)
@@ -20,7 +20,7 @@
 #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
index 47157efcdf256dd217336f8a78143a6a9bd14057..5acc95be61f36f044f05c1b541cb5a4605f4fdfa 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <Standard.hxx>
 
-#include <Standard_Address.hxx>
 #include <DrawTrSurf_BSplineCurve2d.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Real.hxx>
index 9a7ee328047fb20d68aba98b210eef975a9e98ab..d922af6d35aeb0c8c46ea2b0055dbad4c5e50715 100644 (file)
@@ -20,7 +20,6 @@
 #include <Standard.hxx>
 
 #include <DrawFairCurve_Batten.hxx>
-#include <Standard_Address.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Real.hxx>
 
index 088e78d6b88fb3b0c81b40e9a7097cdececccd04..a66989d29f190eaff09a3775506b977a7f1f4f78 100644 (file)
 #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
index 8d2683f46764ae771445707c3bf9aff1fbd93c8e..9a428d686f11997d8ed2fa74133a9cc5e4f86244 100644 (file)
@@ -18,7 +18,6 @@
 #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
index 76e4043f23c84a7106bf807d7d660e916e3e7199..48d8f21a5fee892c28fccad0edf5c56308d398e5 100644 (file)
@@ -65,7 +65,7 @@ protected:
 
 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;
index b29931ce62b3c9498207a809405bfbc961bcd79d..e418ac060b479d758176f021497331716658da47 100644 (file)
@@ -25,7 +25,8 @@
 
 #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).
index 699698212f822ad0bbe7efbcf4364deebaabfec8..e862c27dea387b244f3b2ee5c178a6ba639a0e91 100644 (file)
@@ -541,7 +541,7 @@ void FEmTool_Assembly::AddConstraint(const Standard_Integer IndexofConstraint,
        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
@@ -550,7 +550,7 @@ void FEmTool_Assembly::AddConstraint(const Standard_Integer IndexofConstraint,
        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
@@ -568,7 +568,7 @@ void FEmTool_Assembly::AddConstraint(const Standard_Integer IndexofConstraint,
        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);
       }
index 4bceb727a0826241cd5fabde62585f5f5e50880f..0e1a3ecbcd8e0db6d622dcba77e8e7f4437f6d51 100644 (file)
@@ -942,7 +942,7 @@ void Font_FontMgr::InitFontDataBase()
 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();
@@ -1138,17 +1138,11 @@ Handle(Font_SystemFont) Font_FontMgr::Font_FontMap::Find (const TCollection_Asci
   {
     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)();
 }
index 137f1db1ce33fdd90897c6c82ddfb22ba9ee190b..410a6769b7242ecfd41d29db31e88cff6abeac16 100644 (file)
@@ -209,8 +209,22 @@ private:
 
 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.
@@ -220,26 +234,6 @@ private:
     //! @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.
index ac3c6fca8be9257c46424e969cac61d7c4b26ba8..0736553be30cf56ba06dddcd1a594121c7de5dd0 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <Font_FontAspect.hxx>
 #include <Standard.hxx>
+#include <NCollection_DefineAlloc.hxx>
 #include <Standard_Transient.hxx>
 #include <TCollection_AsciiString.hxx>
 
@@ -122,21 +123,10 @@ public:
   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:
@@ -149,6 +139,19 @@ 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
index 8718dd065d316ecc8a5ff9594b7bc80179f11492..ec9f02b97574960cbb846eda5e69a4ca1adecdf1 100644 (file)
 
 #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
index 8d9911077c5b375bb37d915170193f1c652297c0..334b72319425848e0d080487f698d7e8bb5281d9 100644 (file)
 #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
index 8bbb524127b06fc9ec050646340c5b092f41f54b..d0f85b8db73eb60b3c2da32a12caa3e4c26a5a8a 100644 (file)
@@ -25,6 +25,7 @@
 #include <TColStd_HArray1OfInteger.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 #include <TColStd_HArray2OfReal.hxx>
+#include <math_Vector.hxx>
 
 GeomFill_PolynomialConvertor::GeomFill_PolynomialConvertor(): 
                    Ordre(8),
index f33fedb3f9fb93e5c157aeaf11d79db45c21de65..81b0c0959890f28b0a31da2376694cbba7cca06f 100644 (file)
@@ -26,7 +26,7 @@
 #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>
@@ -418,7 +418,7 @@ Standard_Boolean GeomInt_LineTool::
   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;
@@ -445,7 +445,7 @@ Standard_Boolean GeomInt_LineTool::
   }
   //
   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);
 
index 619598d0961934d6e6768fcffbf06dcd429771e6..f990f4ef4d1884dc2be2aa334e0fa67f8c3263e5 100644 (file)
@@ -21,7 +21,6 @@
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
 
-#include <Standard_Address.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_Real.hxx>
index 143b50f4c485bf61a2129e44115a5f3b71e7f588..5fe56d44677ac8313f6229f37303f7bdd88ff520 100644 (file)
@@ -36,7 +36,6 @@
 #include <Graphic3d_ZLayerId.hxx>
 #include <Graphic3d_ZLayerSettings.hxx>
 #include <Image_PixMap.hxx>
-#include <Standard_Address.hxx>
 #include <Standard_Transient.hxx>
 #include <TColStd_IndexedDataMapOfStringString.hxx>
 
index 8c46a42aee4b677a601199161a8dc1b175a8dc2c..512d02bc89b0c882d0622d7d27276ee4b123c3c6 100644 (file)
@@ -30,12 +30,46 @@ Graphic3d_FrameStatsData::Graphic3d_FrameStatsData()
   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;
@@ -47,6 +81,27 @@ Graphic3d_FrameStatsData& Graphic3d_FrameStatsData::operator= (const Graphic3d_F
   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  :
index 27db098b6614fc656b576df9729a5a6492e0a075..2337037bb582610a6c7bfb7d40f2ddce72bdde1a 100644 (file)
@@ -61,9 +61,18 @@ public:
   //! 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();
 
index 786458d360084f61e8036a15e59eaa842bca61c0..5b2b8f3c09b90d2354f970fd7de90c2f97e3a530 100644 (file)
@@ -17,6 +17,7 @@
 #define _Graphic3d_ShaderAttribute_HeaderFile
 
 #include <Standard_Transient.hxx>
+#include <NCollection_DefineAlloc.hxx>
 #include <TCollection_AsciiString.hxx>
 
 //! Describes custom vertex shader attribute.
index 31cd6e4dd70aca33057b851ae80410bf017f46de..09756abcd67d12c3937c3657f3faaa74e91e2644 100644 (file)
@@ -115,7 +115,7 @@ void HLRAlgo_PolyAlgo::Update ()
 
     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(); }
@@ -349,7 +349,7 @@ HLRAlgo_BiPoint::PointsT& HLRAlgo_PolyAlgo::Hide (HLRAlgo_EdgeStatus& theStatus,
                                                   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,
@@ -431,7 +431,7 @@ HLRAlgo_BiPoint::PointsT& HLRAlgo_PolyAlgo::Show (
                             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;
index 773cb84a224c4222c449524d39523875741248b7..b5d6ba2836670355264288bd2c21885d7feaa12f 100644 (file)
@@ -38,7 +38,7 @@ void HLRAlgo_PolyShellData::UpdateGlobalMinMax(HLRAlgo_PolyData::Box& theBox)
   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();
index 147b8659d8f6261c63e425f201ae0855aab8cf4f..170af95419064956581011f8db1a69b651f6cff7 100644 (file)
@@ -22,7 +22,6 @@
 #include <Standard_Handle.hxx>
 
 #include <Standard_Real.hxx>
-#include <Standard_Address.hxx>
 #include <GeomAbs_Shape.hxx>
 #include <Standard_Integer.hxx>
 #include <TColStd_Array1OfReal.hxx>
index 2cebfec692b71eff29bbc45f8987aff85dacd149..4507728bd2d100d44d42c2d35c7f59c9fc0bf566 100644 (file)
@@ -1443,7 +1443,7 @@ HLRBRep_Data::HidingStartLevel (const Standard_Integer E,
   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()) {
index 121ec30824e3ffe48fec857c4681b9a9bc1c2ef6..e701d2f3f210271f8fde61300af72f8388ea6f28 100644 (file)
@@ -31,7 +31,6 @@
 #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>
index cd7feae0d1bd499bf74da4e3b34178988671b936..5c0c34be02f8fdc80362e367c10eebeddcbb4fd2 100644 (file)
@@ -20,7 +20,6 @@
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
 
-#include <Standard_Address.hxx>
 class gp_Dir;
 
 
index b416ea7fe16fbfe440a6583b13ff01ff6c045597..9a852e17078f1993a36173ac981db9053109e092 100644 (file)
@@ -116,8 +116,8 @@ ProcessComplex(HLRAlgo_InterferenceList& IL,
          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();
index b97392a3f1f19c261ff41fa53d912db43ec0c103..54ce4e0e9df4aab14b8c68e5684367eb053b891e 100644 (file)
@@ -141,12 +141,12 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI,
        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);
@@ -216,7 +216,7 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI,
        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);      // ******************
 
@@ -401,7 +401,7 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI,
          while(It.More()) {           // suppress multi-inside Intersections
                                       // ***********************************
          
-           HLRAlgo_Interference& Int = It.Value();
+           const HLRAlgo_Interference& Int = It.Value();
            switch (Int.Transition()) {
              
            case TopAbs_FORWARD  :
@@ -585,7 +585,7 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI,
            while(It.More()) {         // suppress multi-inside Intersections
                                       // ***********************************
              
-             HLRAlgo_Interference& Int = It.Value();
+             const HLRAlgo_Interference& Int = It.Value();
              switch (Int.Transition()) {
                
              case TopAbs_FORWARD  :
index ebcc46fd3afcdb2a400b1f00c145a42c5d09e0e2..f7dc633b9d6b8dfe1dac5558f1c378ef95482ed2 100644 (file)
@@ -2412,7 +2412,7 @@ void HLRBRep_PolyAlgo::CheckFrBackTriangles (HLRAlgo_ListOfBPoint& theList,
     {
       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)
         {
@@ -3440,7 +3440,7 @@ TopoDS_Shape HLRBRep_PolyAlgo::OutLinedShape (const TopoDS_Shape& theShape) cons
     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();
index 3c43944fb79af5a93b42f22ae761626a4937e657..6900c0c029dc1fca4ecf31f427ce2dca7f8444bd 100644 (file)
@@ -24,7 +24,6 @@
 #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;
index 4d48a064d9da083988822e3512ee12f06d3402dc..0bd3d56c98ef0f452d11d6df5977249b331ce8d7 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <Standard_Integer.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <NCollection_DefineAlloc.hxx>
 #include <Standard_Transient.hxx>
 
 class IFSelect_IntParam;
index 5e82a2f12b86c80e11c782413c598171d78b621b..dfa716dab789e0aa9db7b4e5f5318918f5e8a790 100644 (file)
@@ -22,7 +22,7 @@
 #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>
@@ -108,10 +108,10 @@ namespace IMeshData
 
   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
@@ -125,40 +125,20 @@ namespace IMeshData
   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
index 5ae46834d9dbec4f7ece05db4f988ee91224641e..b1e00f5300fcf01fb84999336f7a7a2b8cf5a414 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <gp_XY.hxx>
 #include <NCollection_List.hxx>
-#include <NCollection_TListIterator.hxx>
 #include <NCollection_DataMap.hxx>
 #include <NCollection_Map.hxx>
 #include <Standard_Boolean.hxx>
index a81e03b64bdd7e900662dd274401f8609fe5a575..aedfc709a36fb4dd7aade7b893a6d18077036a38 100644 (file)
 //================================================================
 // 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;
 
index 57575a52831acd01d51fca8eba190d8ba6bc907b..3b3e98517100505d5b74fb6a3a3975a9cd92d94e 100644 (file)
@@ -76,29 +76,6 @@ public:
                                                        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;
@@ -127,4 +104,36 @@ protected:
 
 };
 
+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
index c956e6c6cf9c7f4f4d8f43e6b151d3c7cfd287bc..369d6334e96fa5b55ab84aa3ee5e1de933d6214a 100644 (file)
@@ -20,6 +20,7 @@
 #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;
@@ -3845,7 +3846,7 @@ IntPatch_ImpImpIntersection::IntStatus IntCyCy(const IntSurf_Quadric& theQuad1,
   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]);
@@ -3860,7 +3861,7 @@ IntPatch_ImpImpIntersection::IntStatus IntCyCy(const IntSurf_Quadric& theQuad1,
       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);
       }
     }
@@ -3868,7 +3869,7 @@ IntPatch_ImpImpIntersection::IntStatus IntCyCy(const IntSurf_Quadric& theQuad1,
     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]);
@@ -4300,7 +4301,7 @@ Standard_Boolean IntCyCo(const IntSurf_Quadric& Quad1,
        //
        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();
index 485adf9e8f46740ced61c6626d1413cce3db64f9..eb7674aeb1b5c35d5fcdf5bd4ff5960a294bb737 100644 (file)
@@ -28,7 +28,9 @@ class gp_Vec;
 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
 {
index 9132bf33e04f397c36a8db3052a94f02e19fb22c..6530d7d4b355d49347d63537da31562483d5b153 100644 (file)
@@ -1544,7 +1544,7 @@ void IntPatch_WLineTool::JoinWLines(IntPatch_SequenceOfLine& theSlin,
       }
     }
 
-    anAlloc->Reset();
+    anAlloc->Reset(false);
     NCollection_List<Standard_Integer> aListFC(anAlloc),
                                        aListLC(anAlloc);
     
index d586b0593d24ca46d72945c8b862824b77875db9..f1641e81518f3f9df5b1c7089cdabb9cf93a1f14 100755 (executable)
@@ -7,7 +7,6 @@ IntPolyh_ArrayOfTangentZones.hxx
 IntPolyh_ArrayOfTriangles.hxx
 IntPolyh_Couple.cxx
 IntPolyh_Couple.hxx
-IntPolyh_CoupleMapHasher.hxx
 IntPolyh_Edge.cxx
 IntPolyh_Edge.hxx
 IntPolyh_Intersection.cxx
@@ -26,4 +25,4 @@ IntPolyh_StartPoint.hxx
 IntPolyh_Tools.cxx
 IntPolyh_Tools.hxx
 IntPolyh_Triangle.cxx
-IntPolyh_Triangle.hxx
\ No newline at end of file
+IntPolyh_Triangle.hxx
index 24770ef677d03826181b215da6bb55328c911f29..bb9480d99344adaec7e0a8a875d1343552996fcd 100644 (file)
@@ -23,6 +23,7 @@
 
 #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>
@@ -93,12 +94,10 @@ public:
            (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
@@ -115,4 +114,22 @@ private:
 
 };
 
+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
diff --git a/src/IntPolyh/IntPolyh_CoupleMapHasher.hxx b/src/IntPolyh/IntPolyh_CoupleMapHasher.hxx
deleted file mode 100644 (file)
index fa40687..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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
index 0c8b2d59cde84e426373780a3fe22136092bf244..8e26bf0a800f637b36a72f6c42125b0af53eb8e2 100644 (file)
@@ -20,7 +20,6 @@
 #include <Adaptor3d_Surface.hxx>
 
 #include <IntPolyh_Couple.hxx>
-#include <IntPolyh_CoupleMapHasher.hxx>
 #include <IntPolyh_MaillageAffinage.hxx>
 #include <IntPolyh_SectionLine.hxx>
 #include <IntPolyh_StartPoint.hxx>
@@ -419,7 +418,7 @@ void IntPolyh_Intersection::MergeCouples(IntPolyh_ListOfCouples &anArrayFF,
                                          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) {
index 1e2300416b9116e87dbbc0a15cf7e25ecbd47b3e..776921378fa1de5b886d48707ee48a98aba3498f 100644 (file)
@@ -47,8 +47,7 @@
 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;
index 6ceed6368e240af588b410d69c0d95119215edf6..c4f03c787c3118a48d79f9307459129b56541a60 100644 (file)
@@ -36,6 +36,11 @@ public:
   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);
   
index 0bd06c732f3b577f0fb9cab105171d6a18ad4538..abcaf104f5b1d7fcba265d03936e94d4402b0c14 100644 (file)
@@ -17,8 +17,6 @@ IntTools_CurveRangeLocalizeData.cxx
 IntTools_CurveRangeLocalizeData.hxx
 IntTools_CurveRangeSample.cxx
 IntTools_CurveRangeSample.hxx
-IntTools_CurveRangeSampleMapHasher.hxx
-IntTools_DataMapIteratorOfDataMapOfCurveSampleBox.hxx
 IntTools_DataMapIteratorOfDataMapOfSurfaceSampleBox.hxx
 IntTools_DataMapOfCurveSampleBox.hxx
 IntTools_DataMapOfSurfaceSampleBox.hxx
@@ -64,7 +62,6 @@ IntTools_SurfaceRangeLocalizeData.lxx
 IntTools_SurfaceRangeSample.cxx
 IntTools_SurfaceRangeSample.hxx
 IntTools_SurfaceRangeSample.lxx
-IntTools_SurfaceRangeSampleMapHasher.hxx
 IntTools_Tools.cxx
 IntTools_Tools.hxx
 IntTools_TopolTool.cxx
index b5095096ebafa3376ecaca96335f482f61a6b84f..aa0318de9943c2cefa1c866e3cc07bb2b80301ad 100644 (file)
@@ -2334,7 +2334,7 @@ static void MergeSolutions(const IntTools_ListOfCurveRangeSample& theListCurveRa
                            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;
index 6c4deb277708650979482561b0071bcb5238d7e1..4116dc34368f8089292b20a5354aa8cf1548d7d9 100644 (file)
@@ -125,7 +125,7 @@ IntTools_Context::~IntTools_Context()
   }
   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();
index eebffed2cb2b793f1685c0bb15ff70187fcb2028..a39b8299b5ee164d1a521325fd693a346e19125b 100644 (file)
@@ -26,7 +26,6 @@
 #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;
@@ -247,7 +246,7 @@ protected:
   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;
index 5375015feb0a157b79e6059b16e9b9ec61899f6a..c3e0d0b11660aee51fb57297f7ce0ae89a559f0a 100644 (file)
@@ -21,6 +21,7 @@
 #include <Standard_Handle.hxx>
 
 #include <IntTools_BaseRangeSample.hxx>
+#include <Standard_HashUtils.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_Real.hxx>
 
@@ -47,6 +48,11 @@ public:
     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
@@ -60,4 +66,18 @@ private:
 
 };
 
+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
diff --git a/src/IntTools/IntTools_CurveRangeSampleMapHasher.hxx b/src/IntTools/IntTools_CurveRangeSampleMapHasher.hxx
deleted file mode 100644 (file)
index 0a3ca35..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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
diff --git a/src/IntTools/IntTools_DataMapIteratorOfDataMapOfCurveSampleBox.hxx b/src/IntTools/IntTools_DataMapIteratorOfDataMapOfCurveSampleBox.hxx
deleted file mode 100644 (file)
index e8f1708..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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
index b7a66ed19383f7fc409583777c6a197d826ed4fb..ca789167ecdd38ab78f7cb8fbcffb3826f6b2fee 100644 (file)
 
 #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
index d716633d6057eff4831ee9a9342c29e50f661275..c6f7c2a8d4580c7b5a55572571a4a8159e0390aa 100644 (file)
 
 #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
index b95022f00bcd376f90b6b59e079a58753fd556ef..d2c99d7acbe9df8799121c2e6fee14c2b316ff7f 100644 (file)
@@ -391,7 +391,7 @@ void IntTools_FaceFace::Perform (const TopoDS_Face& aF1,
       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);
       }
index 9377d9a9009f0bc692e616c37962a213f8a77925..434aab2df84de18f7dc0a15fa8c71bc0fcc7ee3d 100644 (file)
 #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
index e7ffe2fbfc24ac3491936d17b71d5ae29d4c9601..8dd517833625fcfb502da9524d6281a2829dbac9 100644 (file)
 #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
index 15f86977ff62f89e2d11bfd59da98f14c8df688a..ce930e70f36b343615a4dbdd96d2846595845e49 100644 (file)
@@ -90,6 +90,10 @@ IntTools_SurfaceRangeSample& operator = (const IntTools_SurfaceRangeSample& Othe
   
     Standard_Integer GetRangeIndexVDeeper (const Standard_Integer theNbSampleV) const;
 
+    bool operator==(const IntTools_SurfaceRangeSample& theOther) const
+    {
+      return IsEqual(theOther);
+    }
 
 
 
index b962fe737474224ad8f5c198a3391558c1610943..9bbec91d10897b3f4d419cbed6a1e10559cfad36 100644 (file)
@@ -13,6 +13,8 @@
 // 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) 
 {
@@ -138,3 +140,18 @@ inline Standard_Integer IntTools_SurfaceRangeSample::GetRangeIndexVDeeper(const
 {
   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));
+    }
+  };
+}
diff --git a/src/IntTools/IntTools_SurfaceRangeSampleMapHasher.hxx b/src/IntTools/IntTools_SurfaceRangeSampleMapHasher.hxx
deleted file mode 100644 (file)
index ae8a35b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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
index 4de3a4dcdfc6769d4275517efb81a11902f63dde..fc9a6a528901f7e07210c7feea3f9bfbf61a35bb 100755 (executable)
 #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
index ec973df27e9a05146274d464e8a2ebdc43acaf46..bcb1a04dcb4421fc12ef14cbe27b407427acb064 100755 (executable)
@@ -17,7 +17,7 @@
 #define IntWalk_VectorOfWalkingData_HeaderFile
 
 #include <vector>
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
 
 // Defines a dynamic vector of work data.
 
@@ -28,7 +28,7 @@ struct IntWalk_WalkingData
     Standard_Integer etat;
 };
 
-typedef std::vector<IntWalk_WalkingData, NCollection_StdAllocator<IntWalk_WalkingData> >
+typedef std::vector<IntWalk_WalkingData, NCollection_OccAllocator<IntWalk_WalkingData> >
     IntWalk_VectorOfWalkingData;
 
 #endif
index ca32e3abdb817290082142cf77c5424d15e23381..ac3bf215e2b31b8fb53a186cef266b3bd9d5b098 100755 (executable)
@@ -66,8 +66,6 @@ Interface_JaggedArray.gxx
 Interface_LineBuffer.cxx
 Interface_LineBuffer.hxx
 Interface_Macros.hxx
-Interface_MapAsciiStringHasher.cxx
-Interface_MapAsciiStringHasher.hxx
 Interface_MSG.cxx
 Interface_MSG.hxx
 Interface_NodeOfGeneralLib.hxx
index 3f543997bc74aff580d843298f2030e1f50d768f..edf7f57fc810f5f05229946ebe9840a5ee4efadf 100644 (file)
 
 #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
index af8352569c347b3e14a4f149664dad4bd8ac2e0f..3b64b0cc139bd09ca4234b41fbf306a1a8339487 100644 (file)
 #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
diff --git a/src/Interface/Interface_MapAsciiStringHasher.cxx b/src/Interface/Interface_MapAsciiStringHasher.cxx
deleted file mode 100644 (file)
index e7a24f3..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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);
-}
diff --git a/src/Interface/Interface_MapAsciiStringHasher.hxx b/src/Interface/Interface_MapAsciiStringHasher.hxx
deleted file mode 100644 (file)
index ee0d52e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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
index afa597d56e1277e9da4eeac006ef6031fc77e7af..84082f7ae5f878259c6ac8cfb862214c3a2c38a9 100644 (file)
@@ -412,7 +412,7 @@ Handle(TColStd_HSequenceOfHAsciiString)  Interface_Static::Items
 // 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();
 
index 7069c5f3615b123260f8b2a82463d124d37cf3b3..a6de9ce27aa571cee6028c2f343ea2a918afd8eb 100644 (file)
@@ -246,7 +246,7 @@ public:
   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)
 
index 1d0baf901205948f100197e4bca0b2096c63ed2b..9e02f13b1af97bfb10ebff07c20217590b7eacab 100644 (file)
@@ -243,7 +243,7 @@ void LocOpe_BuildShape::Perform(const TopTools_ListOfShape& L)
       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());
index b572dd188584bdb16103dd0a9aa0651b64aabe94..0c242f62ebec62d3694fbb4f4407405c66565b24 100644 (file)
@@ -137,7 +137,6 @@ void LocOpe_Generator::Perform(const Handle(LocOpe_GeneratedShape)& G)
   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()) {
@@ -158,7 +157,7 @@ void LocOpe_Generator::Perform(const Handle(LocOpe_GeneratedShape)& G)
       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;
          }
@@ -204,8 +203,8 @@ void LocOpe_Generator::Perform(const Handle(LocOpe_GeneratedShape)& G)
   // 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());
@@ -234,7 +233,8 @@ void LocOpe_Generator::Perform(const Handle(LocOpe_GeneratedShape)& G)
   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());
@@ -445,7 +445,8 @@ void LocOpe_Generator::Perform(const Handle(LocOpe_GeneratedShape)& G)
   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;
index bd6def2638aa82997fb7597e3952aea641279507..9e1613cb00fffa60a20a3bd70f64bd8feff0fea2 100644 (file)
@@ -109,7 +109,7 @@ LocOpe_Pipe::LocOpe_Pipe(const TopoDS_Wire& Spine,
       }
       
       while (MapFac.Extent() >= 2) {
-       itm.Reset();
+       itm = TopTools_MapIteratorOfMapOfShape(MapFac);
        TopTools_ListOfShape FacFuse;
        TopoDS_Face FaceRef = TopoDS::Face(itm.Key());
        FacFuse.Append(FaceRef);
index edce77fcf6ed883e479c2dcc3c843610fa323603..cf0829b849c96eb3d7705f7d9bb69d448417575d 100644 (file)
@@ -1401,7 +1401,7 @@ static void MakeFace(TopoDS_Face& F,
 //  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);
@@ -1528,7 +1528,7 @@ static void MakeFace(TopoDS_Face& F,
     GProp_GProps GP;
     BRepGProp::SurfaceProperties(NewFace,GP);
     if (GP.Mass() < 0) {
-      itl.Value().Reverse();
+      itl.ChangeValue().Reverse();
     }
   }
   if (lwires.Extent() == 1) {
index 69228961859e9ff6db4d50d7622cf0e5ef936296..72ed0729f5722307dbe701c35c8411f3e279c42d 100644 (file)
@@ -515,7 +515,7 @@ Standard_Boolean LocOpe_SplitShape::Add(const TopTools_ListOfShape& Lwires,
     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);
index 5f282ddf6587a38b57ebfc7b0c7116e9b527dd56..ee5e5d881183ddcbffdef5990361ffa6b1528afc 100644 (file)
@@ -112,11 +112,11 @@ void LocOpe_Spliter::Perform(const Handle(LocOpe_WiresOnShape)& PW)
   }
 
   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
@@ -193,7 +193,8 @@ void LocOpe_Spliter::Perform(const Handle(LocOpe_WiresOnShape)& PW)
 
   // 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);
@@ -294,7 +295,8 @@ void LocOpe_Spliter::Perform(const Handle(LocOpe_WiresOnShape)& PW)
 
   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()) {
@@ -471,7 +473,7 @@ void LocOpe_Spliter::Perform(const Handle(LocOpe_WiresOnShape)& PW)
       }
     }
     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());
index da7558aae1f89e01b2a3fd93ba32d0a01cf8ee7f..8725fdfeada359cf8b93e4d47c00c12e43be0b82 100644 (file)
@@ -21,7 +21,6 @@
 #include <Standard_Type.hxx>
 
 #include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
 #include <Standard_Transient.hxx>
 #include <MAT_Side.hxx>
 class MAT_BasicElt;
index 63372345c8f5ad6fc9550dd6d0e480f2b42f258e..37d2980499845ddb5a2ad12ea2ffe5ae52da8565 100644 (file)
@@ -20,7 +20,6 @@
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
 
-#include <Standard_Address.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Transient.hxx>
 class MAT_Arc;
index b889ac3a5ce575b7b299a24376941fd542c6ae02..343429574ee1dd09356f8416b181fa3ded70f62e 100644 (file)
 
 #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
index adc053a0a30038cb4f56dbbc8145a08706d0e634..5b8143f847519cef8ce848e1880d6b17935ca8c1 100644 (file)
 
 #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
index d4d990c43965a7beb610db05eee0bc1060073f64..b2f4dda8a91413ecc86cb8a6ffefe392f0f7dd72 100644 (file)
 
 #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
index 5bfd7d82271d55acb26c32a2250a8d9224532097..d11a4c14be379fa4b22d0c558eaebee18c6c4897 100644 (file)
 
 #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
index 74527243efa13a9405aff3caa753b5c03e38ae22..fc68f7096b8c81d763046f5602f99d43bae36e69 100644 (file)
@@ -21,7 +21,6 @@
 #include <Standard_Type.hxx>
 
 #include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
 #include <Standard_Real.hxx>
 #include <Standard_Transient.hxx>
 #include <MAT_SequenceOfArc.hxx>
index b342dfc4d9f3340eccb8a06a6eb989139c215f13..531a6d12d826eaefc132264621bbf33a8d02a401 100644 (file)
@@ -21,8 +21,6 @@ MAT2d_DataMapOfIntegerConnexion.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
index 9e8d45315ead042e6c89dbc8fa219bd3c6ba3aa4..5f16ec3dfa4ddf926efa6aff08cada719aab7004 100644 (file)
@@ -22,7 +22,7 @@
 #include <Standard_Handle.hxx>
 
 #include <Standard_Boolean.hxx>
-
+#include <Standard_HashUtils.hxx>
 
 //! BiInt is a set of two integers.
 class MAT2d_BiInt 
@@ -67,6 +67,19 @@ private:
 
 };
 
+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));
+    }
+  };
+}
 
 
 
index e67f52c6d020b9b8dd93af2cfcfc9dd1f44d9014..30083e4ff9899a29415ced14378938705b489f95 100644 (file)
 #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
index a7307fa1619e71b5a9260e03d9df7252a9851da8..1a4e3f01a484863707d8560cbca06826b70f142c 100644 (file)
 
 #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
index 94df70c20624b3478fd769e55b81518d08b53cdd..03ab1562620c20d6f46739af48e217f0a72eb868 100644 (file)
 #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
index c45622ab78d830c874d2776e352c23f8fec27972..8924e2a3326e9e337f3c78cfa0cb9fbaab565475 100644 (file)
 
 #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
index 69f0fe8b3038e4f956d5e8f78345954d40ba5fe7..0ec2bab133a66680bb81ed66af256947e9822a7d 100644 (file)
 #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
index 2da50d1d1f700e17c1bf08f09151832a8c653255..6072e216a4e406bbb8ae435c42b088d00716f2a0 100644 (file)
 
 #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
index 217b08bb69b01b01d4a4c7aa9b005602a83a3ffd..f26bc01fe44b706863874040f05e70d47dc6c6e0 100644 (file)
 
 #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
diff --git a/src/MAT2d/MAT2d_MapBiIntHasher.hxx b/src/MAT2d/MAT2d_MapBiIntHasher.hxx
deleted file mode 100644 (file)
index 2678b33..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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
diff --git a/src/MAT2d/MAT2d_MapBiIntHasher.lxx b/src/MAT2d/MAT2d_MapBiIntHasher.lxx
deleted file mode 100644 (file)
index 1192c2a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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);
-}
index 594baa595b24b60e90c9016980719f0ddb45be44..ee5825391510d6e2df0598111423827621524abe 100755 (executable)
@@ -77,8 +77,6 @@ MeshVS_Tool.cxx
 MeshVS_Tool.hxx
 MeshVS_TwoColors.cxx
 MeshVS_TwoColors.hxx
-MeshVS_TwoColorsHasher.hxx
 MeshVS_TwoNodes.hxx
-MeshVS_TwoNodesHasher.hxx
 MeshVS_VectorPrsBuilder.cxx
 MeshVS_VectorPrsBuilder.hxx
index 6ae3a5ecd9c9d57c5d859bcb7a5c015c39b3a200..cdee765cfa9c5fbec7dc444c3c1cb41e5fdcbba8 100644 (file)
 #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
index 37bfd1d8e3fc36062ef48ba46cde2bd3651393a2..a82242d2f819c316bfe0923b7c0aab31aeddf46d 100644 (file)
 
 #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
index 4bbe2209534e040c0af0c41252ceec6b4a4ac365..24375e365b1608cfdd4d68a3af7685d0da7a31fc 100644 (file)
 
 #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
index 8a7a4b7cbe07c030aa0d9f1e7a7b3a8f150ea861..299aa3d163b9ba4e80faabdd38260ffbb0db7bdf 100644 (file)
 #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
index 9e60b666942129971ec7da8037d5a3d1218e0b8f..c771b7c56329926fd7f40ca8c5a5138c6627a2c1 100644 (file)
 
 #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
index 207d05441a5bf63c6a6120ff391fb7554be3ab93..e5c73d25a53e40be500a7625093df929856727fc 100644 (file)
 
 #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
index 000fe8ac0c2587b43513ef8d48a00112a61f8ec3..a48dce07ba6fca8bf68e0995edc22ac2650b346b 100644 (file)
 
 #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
index a43a7a50d56f1546fd31e2bad9b0569e2e99137c..f344dd26333cd7705d3f45f623ad73d2d0ff4b04 100644 (file)
 
 #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
index b634e8393da98315f9d0cfbde1977f38b6ce1d73..bc5cdd318d20322452a031584b47943056d31882 100644 (file)
 
 #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
index 0478b4dc911429acf605846503fcbdc807ab5b8e..34bd103854382c30f6784ff489fdda4cde10d3c6 100644 (file)
 
 #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
index 1f0a426f60b1ea887cd7df2b2200f4295195cfc1..0206ce1dba01cb5a3392faa3f4deb04cba3192af 100644 (file)
 #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
index 7e9828e5e39934fb01d36fc2692b02edc6a528ed..8c877c639e1324e32ad99046024559f63bc6dd6e 100644 (file)
@@ -23,7 +23,6 @@
 #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>
index f0c04c93c28c74acd27f207b3c6ea04f960b534a..0d7549d39d56059b04f3ed5437f85e9a8e8ae22b 100644 (file)
@@ -25,7 +25,6 @@
 #include <TColStd_Array1OfReal.hxx>
 #include <MeshVS_EntityType.hxx>
 #include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <Standard_Address.hxx>
 #include <TColStd_Array1OfInteger.hxx>
 class gp_Vec;
 
index 27cad1e550fb0ca31df3cbcc824e6fb0f2245428..b5aa0ed895ffecc5b0cd23f40b78d2959d4fda66 100644 (file)
@@ -151,7 +151,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
     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 );
index c22e349bdf010b0a6019cff8102970bfd7cee3c6..e9a5b77090977c5f30028096a8c61836702ebd19 100644 (file)
 #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
index 3b3435b9162634225312ae93836f03dab92cfb03..5058997a8bb2476b546bec2085603865cabe17a0 100644 (file)
 #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);
   }
 };
 
index ae37617848bd0d6fc4fbc4efbe79e2ac625641d8..ae80b15fd9cba424beade0bf164429b94ec83e5c 100644 (file)
 
 #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  :
index 8dfa4e067ee7f70cd5ead9cc0f6b4ca1fd8b0691..1ec5a0af0ce3e1433c17410987906a650fca87c3 100644 (file)
 
 #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 );
diff --git a/src/MeshVS/MeshVS_TwoColorsHasher.hxx b/src/MeshVS/MeshVS_TwoColorsHasher.hxx
deleted file mode 100644 (file)
index 32f527e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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
index d581d901f37c84d444496f36affb34f5148f98d0..b838459ea3e94648baa4549ab418daeb0b74ba33 100644 (file)
 #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)
@@ -30,29 +27,30 @@ struct MeshVS_TwoNodes
 
   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
diff --git a/src/MeshVS/MeshVS_TwoNodesHasher.hxx b/src/MeshVS/MeshVS_TwoNodesHasher.hxx
deleted file mode 100644 (file)
index 3a92e54..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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
index e1c2aaaf80ac467272832a934e68014a28c9f19d..7433654763bf0be75765b567695f893a7c7a7c6a 100644 (file)
@@ -15,6 +15,7 @@
 #define _Message_Attribute_HeaderFile
 
 #include <Standard_Transient.hxx>
+#include <NCollection_DefineAlloc.hxx>
 #include <TCollection_AsciiString.hxx>
 
 DEFINE_STANDARD_HANDLE(Message_Attribute, Standard_Transient)
index e50976c91043c81bd548dca804df5d6ba8117ef3..d6be5057ef92bb95f910d4d2d8d026c0e5d70b6c 100644 (file)
@@ -253,6 +253,6 @@ void Message_AttributeMeter::DumpJson (Standard_OStream& theOStream,
        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())
   }
 }
index 86c94b6e410da27dc1dd60ec60fbf012a961b2cb..dbb185be1cc033247c9426f52c3a77916e7edd9f 100644 (file)
@@ -15,6 +15,7 @@
 #define _Message_AttributeObject_HeaderFile
 
 #include <Message_Attribute.hxx>
+#include <NCollection_DefineAlloc.hxx>
 
 
 //! Alert object storing a transient object
index fe69d4ff8691b09b3b0dbac987d0b537a007923e..2579d1e21dff067c1ff477b901885c609c314bf0 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <Message_ConsoleColor.hxx>
 #include <Message_Printer.hxx>
-#include <Standard_Address.hxx>
 #include <Standard_OStream.hxx>
 
 class Message_PrinterOStream;
index eb05a606380e81b0d21d077ff73d373fede73eae..9722cfee83a0f8f68dc75b3cd6be2cdc2bcfe732 100644 (file)
@@ -15,7 +15,6 @@
 #define _Message_PrinterToReport_HeaderFile
 
 #include <Message_Printer.hxx>
-#include <Standard_Address.hxx>
 #include <TCollection_AsciiString.hxx>
 
 class Message_Report;
index 1041f401d1005324394c814b03805a9f01c20560..f1167bf0a6ada57443b4687b28dce814ba38fa8f 100644 (file)
@@ -271,7 +271,7 @@ public: //! @name Preparation methods
     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';
index 8e1579ecf9e7f85d1905d1afac075a5678a6d3b3..c11833f9c0c06b79dae05ec9af89ba4281c11856 100755 (executable)
@@ -10,16 +10,11 @@ MoniTool_DataMapOfShapeTransient.hxx
 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
index 5d246c2b44e9f7f804c7f427522c1de860ee2fa6..7c407a03ac347acdf82462758ee65085b7ea462f 100644 (file)
 #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
diff --git a/src/MoniTool/MoniTool_ElemHasher.cxx b/src/MoniTool/MoniTool_ElemHasher.cxx
deleted file mode 100644 (file)
index fa203e6..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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);
-}
diff --git a/src/MoniTool/MoniTool_ElemHasher.hxx b/src/MoniTool/MoniTool_ElemHasher.hxx
deleted file mode 100644 (file)
index 694533c..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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
index 12f09f0a2150dbb09c08da7c1379753ebdfcabe7..1f14ed09be57e69921a65812e782b323e99639cf 100644 (file)
 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
index d24b134c0774d5cc9eda95e19226ed7ff3702e53..77d34402b8fa73dbbe3a98bb07cf0e9593ba241d 100644 (file)
@@ -45,7 +45,7 @@ public:
   //! 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
@@ -76,14 +76,14 @@ protected:
   
   //! 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;
 
 
diff --git a/src/MoniTool/MoniTool_MTHasher.cxx b/src/MoniTool/MoniTool_MTHasher.cxx
deleted file mode 100644 (file)
index 104769e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// 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.
diff --git a/src/MoniTool/MoniTool_MTHasher.hxx b/src/MoniTool/MoniTool_MTHasher.hxx
deleted file mode 100644 (file)
index b314702..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-// 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
diff --git a/src/MoniTool/MoniTool_MTHasher.lxx b/src/MoniTool/MoniTool_MTHasher.lxx
deleted file mode 100644 (file)
index a39f1c6..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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);
-}
-
-
index 57da02ce0853f834a16b4875f573c4ea3ca6339b..20aeadee417683c9502e4071757dd1bbd5593b4f 100644 (file)
 #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
@@ -37,7 +36,7 @@ MoniTool_TransientElem::MoniTool_TransientElem (const Handle(Standard_Transient)
   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
index 6e92b94898ff68854cda10eae43db39150d1d1c7..d93ebc08fbe36aaa5db3fabcfbfa3c23d52a8c57 100755 (executable)
@@ -3,6 +3,7 @@ NCollection_AccAllocator.hxx
 NCollection_AliasedArray.hxx
 NCollection_AlignedAllocator.cxx
 NCollection_AlignedAllocator.hxx
+NCollection_Allocator.hxx
 NCollection_Array1.hxx
 NCollection_Array2.hxx
 NCollection_BaseAllocator.cxx
@@ -11,29 +12,21 @@ NCollection_BaseList.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
@@ -45,7 +38,9 @@ NCollection_HSequence.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
@@ -53,12 +48,12 @@ NCollection_LocalArray.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
index e7172ccff735c5a9ab01c7be367de60956841308..634223a9587121702b454dc190f641f88fae6021 100644 (file)
@@ -127,8 +127,9 @@ void NCollection_AccAllocator::Free(void* theAddress)
     // 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
@@ -196,7 +197,8 @@ NCollection_AccAllocator::findBlock(const Standard_Address theAddress, Key& theK
 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),
index 239ba351c2aad16b59ed110dcd1b8edac9d2ea21..b9aff7b7060421c54cb9815e606673c8c69ba1ff 100644 (file)
@@ -64,6 +64,12 @@ public:
   //! 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;
@@ -108,17 +114,18 @@ protected:
   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
index 1e3187ffeec7436c6f22f9b7c9ae3cc4b86aeb5d..5ab553a638cd6afd55a6acc25dd8587eb935c9c1 100644 (file)
@@ -32,6 +32,12 @@ public:
   //! 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;
 
diff --git a/src/NCollection/NCollection_Allocator.hxx b/src/NCollection/NCollection_Allocator.hxx
new file mode 100644 (file)
index 0000000..5d116c4
--- /dev/null
@@ -0,0 +1,151 @@
+// 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
index 473f050b640569ec9ae59cc356b9e62a2dd59b91..4dcabc29f5cf8a38566d5d763067a3d40619e3c6 100644 (file)
@@ -1,6 +1,4 @@
-// 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.
@@ -49,231 +55,218 @@ template <class TheItemType>
 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;
   }
 
@@ -281,98 +274,134 @@ public:
   //! 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.
@@ -381,61 +410,157 @@ public:
   //! @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
index a06d435c74d40ccb2fa42a2f4e24ecf28c43e7b3..3071eb93a42b2eae6eea944ba3c4b51a106988dc 100644 (file)
 
 #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.
@@ -306,131 +316,56 @@ public:
   //! @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;
 
 };
 
index d536b0b7b800547a424d4d040b5a9d0293d9919e..d7f3be1781e5cd10746ea34c978773fb08c3a145 100644 (file)
@@ -1,6 +1,4 @@
-// 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;
 }
index 7d6448e4d851b179ea649e4a5d2effbb8d0b7282..0bc0f40804a06fe5eaa313ccc4eb9d39528b74a0 100644 (file)
@@ -1,6 +1,6 @@
 // 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
@@ -58,29 +57,18 @@ class NCollection_BaseAllocator : public Standard_Transient
   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
index c18c219fcbe3720f2f06759ae1f910b88e4863ae..7f32f332b30ce79cd057588bd7577b9bca353a1a 100644 (file)
@@ -39,13 +39,11 @@ Standard_Boolean  NCollection_BaseMap::BeginResize
       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;
@@ -65,9 +63,9 @@ void  NCollection_BaseMap::EndResize
 {
   (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;
@@ -84,32 +82,34 @@ void  NCollection_BaseMap::Destroy (NCollection_DelMapNode fDel,
 {
   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;
   }
 }
index 62b34536b25caded9587ca8b4d6ece1ec5ca2df1..2e6b7f4471dbe9cf4a52ba130c5de1bb93475511 100644 (file)
@@ -159,14 +159,28 @@ public:
   //! 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
@@ -212,9 +226,17 @@ public:
     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;
@@ -225,7 +247,7 @@ public:
   // ---------- PRIVATE FIELDS ------------
   Standard_Integer myNbBuckets;
   Standard_Integer mySize;
-  Standard_Boolean isDouble;
+  const Standard_Boolean isDouble;
 
   // ---------- FRIEND CLASSES ------------
   friend class Iterator;
diff --git a/src/NCollection/NCollection_BasePointerVector.cxx b/src/NCollection/NCollection_BasePointerVector.cxx
new file mode 100644 (file)
index 0000000..55a3439
--- /dev/null
@@ -0,0 +1,145 @@
+// 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
diff --git a/src/NCollection/NCollection_BasePointerVector.hxx b/src/NCollection/NCollection_BasePointerVector.hxx
new file mode 100644 (file)
index 0000000..866eb73
--- /dev/null
@@ -0,0 +1,107 @@
+// 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
diff --git a/src/NCollection/NCollection_BaseVector.cxx b/src/NCollection/NCollection_BaseVector.cxx
deleted file mode 100755 (executable)
index ba7f790..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-// 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);
-}
diff --git a/src/NCollection/NCollection_BaseVector.hxx b/src/NCollection/NCollection_BaseVector.hxx
deleted file mode 100755 (executable)
index 26a41c7..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-// 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
index f57a94273a8dccd44b93f398b9bf5d8a198da10b..1663456b038134fcc8a6d0861ab3e74cbad2e023 100644 (file)
@@ -18,9 +18,9 @@
 
 #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 
@@ -112,8 +112,8 @@ 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:
 
@@ -317,40 +317,33 @@ protected:
       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:
 
@@ -498,7 +491,7 @@ protected:
 protected:
   Standard_Integer myDim;
   Handle(NCollection_BaseAllocator) myAllocator;
-  NCollection_Map<Cell>             myCells;
+  CellMap                           myCells;
   NCollection_Array1<Standard_Real> myCellSize;
 };
 
index ba22e36d429f1d899358da2c054277b8152aba71..37463820a3cc24194b6a1d6fd26821aa1f2202d4 100644 (file)
@@ -23,6 +23,9 @@
 
 #include <Standard_TypeMismatch.hxx>
 #include <Standard_NoSuchObject.hxx>
+#include <utility>
+
+#include <Message.hxx>
 
 /**
 * Purpose:     The DataMap is a Map to store keys with associated
@@ -65,6 +68,27 @@ public:
       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
@@ -151,7 +175,19 @@ public:
   //! 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!
@@ -185,6 +221,15 @@ public:
     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)
   {
@@ -197,15 +242,14 @@ public:
       {
         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;
@@ -220,49 +264,172 @@ public:
 
   //! 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
@@ -278,12 +445,12 @@ public:
     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) 
@@ -361,20 +528,20 @@ public:
 
   //! 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
@@ -382,23 +549,60 @@ public:
 
   
  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
index 6cbbf90de080d76fea49d8956f9a65e54a4ae210..4007ea2739816e488bb77495d487fa19f98eac93 100644 (file)
 #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;
   }
 };
 
diff --git a/src/NCollection/NCollection_DefineArray1.hxx b/src/NCollection/NCollection_DefineArray1.hxx
deleted file mode 100644 (file)
index 7463694..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineArray2.hxx b/src/NCollection/NCollection_DefineArray2.hxx
deleted file mode 100644 (file)
index 00d32af..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineDataMap.hxx b/src/NCollection/NCollection_DefineDataMap.hxx
deleted file mode 100644 (file)
index 4c90ecb..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineDoubleMap.hxx b/src/NCollection/NCollection_DefineDoubleMap.hxx
deleted file mode 100644 (file)
index e6a1188..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
index d1da5ee2f87dbe3927dbe36f84ae4b6aa601e36b..3ce18913dc9cd6a84bf2cfaa739f8e65529737b3 100644 (file)
 #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                                                    \
@@ -37,15 +36,18 @@ class HClassName : public _Array1Type_, public Standard_Transient {
                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
index 1f35b90c0c194b753266834aebe8b9fa3ea0d2c5..17123daaaeb896a8dd4f2b15e22ea52a394775c9 100644 (file)
@@ -19,7 +19,6 @@
 #define NCollection_DefineHArray2_HeaderFile
 
 #include <Standard_Type.hxx>
-#include <NCollection_DefineArray2.hxx>
 #include <Standard_Transient.hxx>
 
 //      Declaration of Array2 class managed by Handle
index 9973d9b866416c4d6c8cad803db48b2154e214ea..05aa83ed9db846f3beb07e9483fba82b8d2322c0 100644 (file)
@@ -19,7 +19,6 @@
 #define NCollection_DefineHSequence_HeaderFile
 
 #include <Standard_Type.hxx>
-#include <NCollection_DefineSequence.hxx>
 #include <Standard_Transient.hxx>
 
 //      Declaration of Sequence class managed by Handle
diff --git a/src/NCollection/NCollection_DefineHasher.hxx b/src/NCollection/NCollection_DefineHasher.hxx
new file mode 100644 (file)
index 0000000..23e518d
--- /dev/null
@@ -0,0 +1,32 @@
+// 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
diff --git a/src/NCollection/NCollection_DefineIndexedDataMap.hxx b/src/NCollection/NCollection_DefineIndexedDataMap.hxx
deleted file mode 100644 (file)
index aa75b38..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineIndexedMap.hxx b/src/NCollection/NCollection_DefineIndexedMap.hxx
deleted file mode 100644 (file)
index 77c4050..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineList.hxx b/src/NCollection/NCollection_DefineList.hxx
deleted file mode 100644 (file)
index ab6c281..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineMap.hxx b/src/NCollection/NCollection_DefineMap.hxx
deleted file mode 100644 (file)
index d4ecbb5..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineSequence.hxx b/src/NCollection/NCollection_DefineSequence.hxx
deleted file mode 100644 (file)
index 3d7414e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
diff --git a/src/NCollection/NCollection_DefineVector.hxx b/src/NCollection/NCollection_DefineVector.hxx
deleted file mode 100644 (file)
index 7d8cafc..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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
index 397d675be5f240da427d550a9bc26e69102c1749..28404c47a0fd3ad037e386e150715204d8175c60 100644 (file)
@@ -157,8 +157,8 @@ public:
       {
         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]);
@@ -187,16 +187,15 @@ public:
       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];
@@ -216,20 +215,20 @@ public:
   {
     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();
     }
@@ -246,13 +245,13 @@ public:
   {
     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();
     }
@@ -261,7 +260,7 @@ public:
     pNode2 = (DoubleMapNode *) myData2[iK2];
     while (pNode2) 
     {
-      if (Hasher2::IsEqual(pNode2->Key2(), theKey2)) 
+      if (IsEqual2(pNode2->Key2(), theKey2)) 
         break;
       pNode2 = (DoubleMapNode *) pNode2->Next();
     }
@@ -276,12 +275,12 @@ public:
   {
     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();
     }
@@ -293,12 +292,12 @@ public:
   {
     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();
     }
@@ -310,20 +309,20 @@ public:
   {
     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)
         {
@@ -355,20 +354,22 @@ public:
   {
     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)
         {
@@ -426,10 +427,10 @@ public:
   //! @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();
       }
@@ -468,10 +469,10 @@ public:
   //! @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();
       }
@@ -481,24 +482,54 @@ public:
 
   //! 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
diff --git a/src/NCollection/NCollection_DynamicArray.hxx b/src/NCollection/NCollection_DynamicArray.hxx
new file mode 100644 (file)
index 0000000..5c7ebc6
--- /dev/null
@@ -0,0 +1,510 @@
+// 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
index 5e10239a19eb24a439bdfab9b779ec38fdba17a5..9b631d3cd000d34d120b9aeef9d65c27a471364c 100644 (file)
@@ -38,7 +38,7 @@ template <class TheObjType, class TheBndType> class NCollection_EBTree
 {
  public:
   typedef NCollection_UBTree <TheObjType, TheBndType> UBTree;
-  typedef TYPENAME UBTree::TreeNode TreeNode;
+  typedef typename UBTree::TreeNode TreeNode;
   // ---------- PUBLIC METHODS ----------
 
   /**
index d18c726df9396cd47ef2c7498cef007a1282b392..947e772b226fbb96323591be4e8d0cff1e8e2eb6 100644 (file)
@@ -28,6 +28,7 @@ class NCollection_HeapAllocator : public NCollection_BaseAllocator
  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)&
index 35ce1f62482a00bd493a04676ab25aa52ebb6a5c..c4d12ca98f9b7c8e40c6806dd93dfb8576de6fe2 100644 (file)
@@ -1,6 +1,4 @@
-// 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)
+{}
index 7dfe560af565035f05d77da52caae95be7648458..0993d552a6a3ead070c284ef6c5f403935c96e23 100644 (file)
@@ -1,6 +1,4 @@
-// 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;
 
@@ -46,11 +48,7 @@ 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,
@@ -61,84 +59,97 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator
   //! 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
index c3a7f4b0dce55c9f7fb6caacf51b9b16a111899b..eb3052d6293d9bf93fc67d91e048651063a3c304 100644 (file)
@@ -24,6 +24,7 @@
 #include <NCollection_DefaultHasher.hxx>
 
 #include <Standard_OutOfRange.hxx>
+#include <utility>
 
 /**
  * Purpose:     An indexed map is used  to store keys and to  bind
@@ -54,6 +55,7 @@ public:
   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
@@ -68,8 +70,34 @@ private:
     : 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
@@ -165,18 +193,23 @@ private:
   // ---------- 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)
@@ -200,7 +233,7 @@ private:
       {
         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;
@@ -216,6 +249,15 @@ private:
     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)
   {
@@ -226,7 +268,6 @@ private:
     {
       if (myData1) 
       {
-        memcpy (ppNewData2, myData2, sizeof(IndexedDataMapNode*) * Extent());
         for (Standard_Integer aBucketIter = 0; aBucketIter <= NbBuckets(); ++aBucketIter)
         {
           if (myData1[aBucketIter])
@@ -234,7 +275,7 @@ private:
             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;
@@ -243,7 +284,8 @@ private:
           }
         }
       }
-      EndResize (N, newBuck, ppNewData1, ppNewData2);
+      EndResize (N, newBuck, ppNewData1, (NCollection_ListNode**)
+        Standard::Reallocate(myData2, (newBuck + 1) * sizeof(NCollection_ListNode*)));
     }
   }
 
@@ -257,40 +299,98 @@ private:
     {
       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
@@ -303,44 +403,40 @@ private:
                                   "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.
@@ -373,7 +469,7 @@ private:
     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();
@@ -444,15 +540,10 @@ private:
   //! 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;
   }
@@ -461,15 +552,10 @@ private:
   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");
   }
@@ -478,15 +564,10 @@ private:
   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");
   }
@@ -496,27 +577,18 @@ private:
   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.
@@ -524,46 +596,91 @@ private:
   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
diff --git a/src/NCollection/NCollection_IndexedIterator.hxx b/src/NCollection/NCollection_IndexedIterator.hxx
new file mode 100644 (file)
index 0000000..fbc6bbd
--- /dev/null
@@ -0,0 +1,232 @@
+// 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
index 875068d83c5c3bda49f636134f4017251148e323..83d28baec3ee4311ca5d46fe3520442b7ba6ed28 100644 (file)
@@ -55,8 +55,14 @@ protected:
                     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(); }
 
@@ -125,18 +131,23 @@ protected:
   // ---------- 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)
@@ -159,7 +170,7 @@ protected:
       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;
@@ -175,6 +186,15 @@ protected:
     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)
   {
@@ -185,7 +205,6 @@ protected:
     {
       if (myData1) 
       {
-        memcpy (ppNewData2, myData2, sizeof(IndexedMapNode*) * Extent());
         for (Standard_Integer aBucketIter = 0; aBucketIter <= NbBuckets(); ++aBucketIter)
         {
           if (myData1[aBucketIter])
@@ -193,7 +212,7 @@ protected:
             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;
@@ -202,7 +221,8 @@ protected:
           }
         }
       }
-      EndResize (theExtent, newBuck, ppNewData1, ppNewData2);
+      EndResize (theExtent, newBuck, ppNewData1, (NCollection_ListNode**)
+        Standard::Reallocate(myData2, (newBuck + 1) * sizeof(NCollection_ListNode*)));
     }
   }
 
@@ -213,40 +233,45 @@ protected:
     {
       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
@@ -258,42 +283,37 @@ protected:
                                   "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.
@@ -326,7 +346,7 @@ protected:
     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();
@@ -383,39 +403,90 @@ protected:
   //! 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
diff --git a/src/NCollection/NCollection_Iterator.hxx b/src/NCollection/NCollection_Iterator.hxx
new file mode 100644 (file)
index 0000000..ec4481a
--- /dev/null
@@ -0,0 +1,127 @@
+// 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
index 418d65eaae40934dffc51f5205c79d2a320ebce1..ceb220b0b415ae6b509731fecf276542830f9020 100644 (file)
@@ -68,7 +68,14 @@ public:
   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
@@ -92,6 +99,22 @@ public:
     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)
   {
@@ -136,6 +159,14 @@ public:
     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)
@@ -144,6 +175,14 @@ public:
     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)
@@ -172,6 +211,14 @@ public:
     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)
   { 
@@ -227,6 +274,15 @@ public:
     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) 
@@ -257,6 +313,15 @@ public:
     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) 
index 339f1da6a7fa67594c7c913cb0f81bee63385fa2..ca7f0135b33cdc89eefd1d43b01a1a035abd0e52 100644 (file)
@@ -22,6 +22,7 @@
 #include <NCollection_DefaultHasher.hxx>
 
 #include <Standard_NoSuchObject.hxx>
+#include <utility>
 
 /**
  * Purpose:     Single hashed Map. This  Map is used  to store and
@@ -58,6 +59,7 @@ class NCollection_Map : public NCollection_BaseMap
 public:
   //! STL-compliant typedef for key type
   typedef TheKeyType key_type;
+  typedef Hasher hasher;
 
 public:
   //!   Adaptation of the TListNode to the map notations
@@ -68,6 +70,10 @@ public:
     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(); }
@@ -127,9 +133,21 @@ public:
   : 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!
@@ -163,6 +181,15 @@ public:
     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)
   {
@@ -175,15 +202,14 @@ public:
       {
         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;
@@ -197,58 +223,80 @@ public:
   }
 
   //! 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
@@ -257,12 +305,12 @@ public:
     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) 
@@ -281,20 +329,20 @@ public:
 
   //! 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
@@ -590,7 +638,60 @@ public:
     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
diff --git a/src/NCollection/NCollection_OccAllocator.hxx b/src/NCollection/NCollection_OccAllocator.hxx
new file mode 100644 (file)
index 0000000..3d5e674
--- /dev/null
@@ -0,0 +1,215 @@
+// 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
index 55ef23b88c091453d5a99df713cf4a71c3d1dd35..de95374fb6f3a9637c0d10087b5c07338bd60546 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <Standard_OutOfRange.hxx>
 #include <Standard_NoSuchObject.hxx>
+#include <utility>
 
 /**
  * Purpose:     Definition of a sequence of elements indexed by
@@ -42,6 +43,10 @@ public:
     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
@@ -118,7 +123,14 @@ public:
   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
@@ -190,6 +202,28 @@ public:
     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); }
@@ -207,6 +241,10 @@ public:
   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)
   {
@@ -230,6 +268,10 @@ public:
   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)
   {
@@ -254,6 +296,11 @@ public:
                      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)
@@ -264,6 +311,11 @@ public:
                      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)
@@ -292,6 +344,14 @@ public:
     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)
   {
index ce5087d63bf5a6fd2545d672798a30d4cb14b497..b5308bfcbec1ab159f3f618669b944fc37e34e24 100644 (file)
@@ -72,7 +72,7 @@ private:
     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:
 
diff --git a/src/NCollection/NCollection_StdAllocator.hxx b/src/NCollection/NCollection_StdAllocator.hxx
deleted file mode 100755 (executable)
index 4aea7f2..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-// 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
index 2bbe687fa3fc6eba8e05bb7d4c3edc6547cceed3..4a0ef6072a8eec172cd10ca89cdbb54924c50d54 100644 (file)
@@ -17,6 +17,7 @@
 #define NCollection_TListNode_HeaderFile
 
 #include <NCollection_ListNode.hxx>
+#include <utility>
 
 /**
  * Purpose:     Abstract list node class. Used by BaseList
@@ -30,6 +31,9 @@ template <class TheItemType> class NCollection_TListNode
   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
index 04e7b39c155435d6abde800fd4718a18bc974f56..d2ad00555e8e07e9c9aa32386b3b60ad0649c4e6 100644 (file)
@@ -48,7 +48,7 @@ template <class TheObjType, class TheBndType> class NCollection_UBTreeFiller
 
   //! UBTree algorithm
   typedef NCollection_UBTree<TheObjType, TheBndType>    UBTree;
-  typedef TYPENAME UBTree::TreeNode                     UBTreeNode;
+  typedef typename UBTree::TreeNode                     UBTreeNode;
 
 
   // ---------- PUBLIC METHODS ----------
@@ -198,7 +198,7 @@ Standard_Integer NCollection_UBTreeFiller<TheObjType,TheBndType>::CheckTree
 
 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)
 {
index 6ef85c74ac80918ee0dc0cdf5887264829a0649d..6386b03b525ade21310b81edf64062b831f59a5a 100755 (executable)
 #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
index 3a10fd226e3b39b7d877b510dc6fb9dd96358a70..ed76f281c36db4826c3bb182a4b5dce90eb0aa78 100644 (file)
@@ -44,6 +44,9 @@ public:
   //! 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;
 
index c150fe7e87aae79476d32897d47b53ee86281057..a2fbb7d05b54db97f5e78def872827dc7ca0ce13 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <OSD.hxx>
 
+#include <Standard_CString.hxx>
+
 //=======================================================================
 //function : RealToCString
 //purpose  :
index d88f91f74df0357db2c652a346b4b85aff16d88e..6bf4c38c56f44b82b7c9aa6b13e5196cc6b1ad3b 100644 (file)
@@ -16,6 +16,7 @@
 
 #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.
index 6545ade300e25caa3d1ce7134ce5c7cef4c8f3d7..ea2c4e48cbc2785f508802ee37000f6590304dbe 100644 (file)
@@ -16,7 +16,6 @@
 #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.
index b4adda843d97f2092451e7714e8aeecabfcfed74..9748d00049f3a9482949ed135f48f2af1a4e708b 100644 (file)
@@ -20,6 +20,8 @@
 #include <OSD_SharedLibrary.hxx>
 
 #include <stdio.h>
+#include <cstring>
+
 #ifdef __some_crappy_system__
 /*
  * Values for 'mode' argument in dlopen().
index 212d25766b4cdb3e2d04796dbbe67bb1db1733f6..eb5fd6c9b303ffc5050e01cb8e15b844ba7241bc 100644 (file)
@@ -20,7 +20,6 @@
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
 
-#include <Standard_Address.hxx>
 #include <Standard_PCharacter.hxx>
 #include <OSD_LoadMode.hxx>
 #include <OSD_Function.hxx>
index 9b30d160b2adf9ea93b8f32ae07f293a480d1fe1..e327183e730f32c5fb86df837b02cfd722c3ee8e 100644 (file)
@@ -16,7 +16,6 @@
 #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.
 //!
index db90dc0bf7efef25004e7b59352146d0453a2986..442364334dd1c2b9ac5cd2fcc8041473cba1c1e6 100644 (file)
@@ -134,6 +134,7 @@ protected:
   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.
@@ -148,7 +149,7 @@ protected:
       else
       {
         NCollection_Array1<const Graphic3d_Layer*> aDummy;
-        myStackSpace.Move (aDummy);
+        myStackSpace.Move (std::move(aDummy));
         myBackPtr = iterator();
       }
     }
@@ -164,11 +165,14 @@ protected:
     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(); }
 
index a8ceb444b2776a15ae323b67c6f5a64199f5c843..9586e35e8ad4346294a81490d3b82edd71ec86f5 100644 (file)
@@ -156,12 +156,12 @@ void OpenGl_RaytraceGeometry::Clear()
   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);
 }
index 05705962f5c6570fa5a6075f5ec96c45035eff2c..35298bf60d9f0489addfd90c0618531f70a39a1e 100644 (file)
@@ -19,7 +19,7 @@
 #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>
 
@@ -187,11 +187,11 @@ public:
 
   //! 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;
@@ -217,7 +217,7 @@ public:
   void ClearMaterials()
   {
     std::vector<OpenGl_RaytraceMaterial,
-      NCollection_StdAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
+      NCollection_OccAllocator<OpenGl_RaytraceMaterial> > anEmptyMaterials;
 
     Materials.swap (anEmptyMaterials);
 
index 38ee609ff46de75b056a1b5e3695a5dd16638b3e..fc64068e4cd65794d61234ac97b8070a2d294066 100644 (file)
@@ -17,6 +17,7 @@
 #include <Standard_Transient.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <NCollection_Map.hxx>
+#include <NCollection_DataMap.hxx>
 #include <NCollection_List.hxx>
 
 class PCDM_ReaderFilter;
index 0a0594836cc0c4c16c03c16356f5a7c90563aa61..dcee5a5012dc9475ff1cdd10632f8272b1f7948e 100644 (file)
@@ -22,7 +22,6 @@
 #include <Standard_Handle.hxx>
 
 #include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
 #include <Plate_SequenceOfPinpointConstraint.hxx>
 #include <Plate_SequenceOfLinearXYZConstraint.hxx>
 #include <Plate_SequenceOfLinearScalarConstraint.hxx>
index b863b6197bab6c1fdb32dac98f1bc28cd27aecbf..cd8b9ddaaa6c72718787b9a1facc5af3dc4c72fc 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 8bf6c3e2821efdfba9e06551021da483a4add290..471c73aefeaaeeff00032599491e341e18b74876 100644 (file)
@@ -171,7 +171,7 @@ Standard_Integer Poly_MakeLoops::Perform()
     {
       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
@@ -264,7 +264,7 @@ Standard_Integer Poly_MakeLoops::findContour
 
     // 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);
index 25f6539cf966572569227f36752288a0a91975a5..337ae8192711d2bfcb15d5465f77c4b065000edb 100644 (file)
@@ -21,6 +21,8 @@
 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
 #include <NCollection_IncAllocator.hxx>
 #include <NCollection_List.hxx>
+#include <NCollection_OccAllocator.hxx>
+#include <Standard_HashUtils.hxx>
 
 
 /**
@@ -70,6 +72,31 @@ public:
     {
       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
@@ -242,32 +269,13 @@ private:
 
   // 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
  */
@@ -357,4 +365,27 @@ private:
   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
index 40778ad17f75e1249b77c28a219aaa91e48aa27f..ce4423479bc94ecfb087d9efde9c50bdcd5c4ee1 100644 (file)
@@ -14,6 +14,7 @@
 #include <Poly_MergeNodesTool.hxx>
 
 #include <NCollection_IncAllocator.hxx>
+#include <Standard_CStringHasher.hxx>
 
 #include <algorithm>
 
@@ -87,30 +88,38 @@ void Poly_MergeNodesTool::MergedNodesMap::SetMergeTolerance (double theTolerance
 // 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);
@@ -190,7 +199,7 @@ inline bool Poly_MergeNodesTool::MergedNodesMap::Bind (int& theIndex,
   }
 
   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())
   {
@@ -214,7 +223,7 @@ inline bool Poly_MergeNodesTool::MergedNodesMap::Bind (int& theIndex,
     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())
       {
@@ -249,7 +258,7 @@ inline void Poly_MergeNodesTool::MergedNodesMap::ReSize (const int theSize)
       {
         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;
index 20f1c83f535be021a2234bc3b6991f93dd7baf8c..4bc807a7e078557ebbe3335622bbeee920103210 100644 (file)
@@ -16,6 +16,7 @@
 
 #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.
@@ -280,16 +281,16 @@ private:
     }
 
     //! 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);
     }
@@ -317,17 +318,12 @@ private:
   //! 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);
     }
index 56fd7ad0677ff5111c7805cda1e6fd538293205d..7c95a8b9e033852c0aedbbad0098cc65d1191710 100644 (file)
@@ -1188,6 +1188,7 @@ static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, cons
 }
 
 #include <math_Matrix.hxx>
+#include <math_Vector.hxx>
 static Standard_Integer OCC524 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
 {
   if(argc != 9){
index 2db1f5baf4331e1c6626ce6cfbfe2c73bf855156..59efb0ec7db05705c38848d30714edcaecd12888 100644 (file)
@@ -845,7 +845,6 @@ static Standard_Integer OCC1919_set (Draw_Interpretor& di, Standard_Integer argc
 }
 #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) {
index b5e84f0ed270981a830989479f8cfc99f87c302c..cd3769d07406c341265d4edffe830bbd2d098779 100644 (file)
@@ -2624,7 +2624,7 @@ static Standard_Integer OCC29289(Draw_Interpretor&, Standard_Integer , const cha
 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 {
index e814905c8fe57a429365511db1463c3b2370d85a..81a20db8989a8bd766dff80dd6fa41c5ef1ca0f5 100644 (file)
@@ -24,7 +24,6 @@
 #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;
index 13ab7f28b21c703e6b94625bf48220881cc01f3d..64bb06da0dec1074b3191a7d7a0bb70ea680cb5c 100644 (file)
@@ -16,7 +16,7 @@
 #include <QANCollection.hxx>
 #include <Draw_Interpretor.hxx>
 
-#include <NCollection_StdAllocator.hxx>
+#include <NCollection_OccAllocator.hxx>
 #include <NCollection_IncAllocator.hxx>
 #include <Standard_Assert.hxx>
 
@@ -36,7 +36,7 @@ static Standard_Integer QANColStdAllocator1(Draw_Interpretor& di, Standard_Integ
 
   //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*));
@@ -71,8 +71,8 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
 
   {
     //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";
@@ -81,8 +81,8 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
     }
 
     //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";
@@ -91,8 +91,8 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
     }
 
     //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);
@@ -108,7 +108,7 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ
     } else {
       di << "Test4 : Error\n";
     }
-    NCollection_StdAllocator<int> anIAlloc (anIncAlloc);
+    NCollection_OccAllocator<int> anIAlloc (anIncAlloc);
     if ( aSAlloc == anIAlloc ) {
       di << "Test5 : OK\n";
     } else {
index d521cac8fd081f03593b857cfab2dce4adf085bf..b201176b4118bcd29b8781f690ae204941a85b88 100644 (file)
 #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
index 23d8ab5f78688c860a3c1d0842c3d9ea466e98fb..07736ee0d9326e2a3696d753eaf4f5e2efc9a938 100644 (file)
 #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
index b77bea8f784b5c6423b940a0dbc01d722f192a19..89c593e63dd750ab6f9feef1bd388b0cc5cc12bc 100644 (file)
@@ -16,7 +16,7 @@
 #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>
index ce0500d9e1c9c415d0c8d18df69d16d312b16e69..33c03c6828a56ab23f6615c7ded0fbdf707278d4 100644 (file)
 #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
index 95b08578ad334db7b7501b2ad38b2fcc18a64a05..4803ec82b1b942f494d8b482b93987b6c214ad61 100644 (file)
 // 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)
index b484cafb13e5eda97536636e199bbb228367e202..40cc1f261a17e6f11a5b14d37bdd3c72061e475d 100644 (file)
 
 #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)
index a566c8fe02966a1879fc52c28b6a6bb2ae632ca0..ff72f3eafc2b1b248a4c897e973071d497b35e81 100755 (executable)
@@ -2,10 +2,8 @@ Quantity_Array1OfColor.hxx
 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
index 15451507b34b3bf475f8ca30de6e5264ff7c3213..7cc6b58653f07915c024dcddbc6f41efc6c3fd57 100644 (file)
@@ -19,6 +19,7 @@
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
+#include <Standard_HashUtils.hxx>
 #include <Standard_ShortReal.hxx>
 
 #include <Quantity_NameOfColor.hxx>
@@ -379,4 +380,19 @@ private:
 
 };
 
+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
diff --git a/src/Quantity/Quantity_ColorHasher.hxx b/src/Quantity/Quantity_ColorHasher.hxx
deleted file mode 100644 (file)
index 87010e6..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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
index ccdc6e6b3702a5d6978d1741c89af59a17fa0011..85ad4a49511e5a972460cecfa393709b967da4f5 100644 (file)
@@ -173,4 +173,20 @@ private:
 
 };
 
+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
diff --git a/src/Quantity/Quantity_ColorRGBAHasher.hxx b/src/Quantity/Quantity_ColorRGBAHasher.hxx
deleted file mode 100644 (file)
index c7c776c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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
index 24b0e35b3fb40a39d39292e33577bb670113087f..aa86708d3906bc8a4697ccb82485f6268f0168e3 100644 (file)
@@ -626,7 +626,7 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
   };
 
   // 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())
   {
index be5d05f6375393ced1dc7b842ebea1b127f95904..b2cfa9ba91bb90b1b2109205024eebd8a3da73d4 100644 (file)
@@ -357,25 +357,35 @@ protected:
     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:
 
index 5cd3fd2e995ddf913418deda5ba1610305cd9590..0d26a027178e3e2ef592e556c291f3037af7c966 100644 (file)
@@ -399,7 +399,7 @@ protected:
 
   private:
 
-    NCollection_DataMap<TCollection_AsciiString, const RWGltf_JsonValue*, TCollection_AsciiString> myChildren;
+    NCollection_DataMap<TCollection_AsciiString, const RWGltf_JsonValue*> myChildren;
     const RWGltf_JsonValue* myRoot;
 
   };
index d3c8cee6c7e87895fdcd223da1b91c4a23d13426..e6361982e87765868ef3145ca1a79f12a285fbdd 100644 (file)
@@ -207,7 +207,7 @@ void RWGltf_GltfMaterialMap::FlushGlbBufferViews (RWGltf_GltfOStreamWriter* theW
                                                   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();
@@ -241,7 +241,7 @@ void RWGltf_GltfMaterialMap::FlushGlbImages (RWGltf_GltfOStreamWriter* theWriter
 {
 #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();
index 357d5586b78bf2ef2cc45b678b9701a67230d904..fe86036d09601b061fa0f67f4cbdbf917c5e6868 100644 (file)
@@ -105,8 +105,8 @@ protected:
 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;
 
index c6743fe2b2d2033ce98b0ee5f4114d7d9e10ea62..abb548be5bd26c5d678b6f043420f67c1c8b2941 100644 (file)
@@ -18,7 +18,7 @@
 #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:
 
@@ -32,15 +32,9 @@ 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);
   }
 
 };
index 13aea517b3251a70095c9b2092ee0ee30ae5d14d..397cab564f8a88104352657b5bac3693c367b6da 100644 (file)
@@ -87,10 +87,9 @@ protected:
   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
index fd9df2e218ebbe1c9faa0e6c08b53623c9d42ce5..359a3403d0b68b0adf87abd1f29b2e69f4eee74a 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef _RWObj_ObjMaterialMap_HeaderFiler
 #define _RWObj_ObjMaterialMap_HeaderFiler
 
+#include <NCollection_DataMap.hxx>
 #include <RWMesh_MaterialMap.hxx>
 
 //! Material MTL file writer for OBJ export.
@@ -39,7 +40,7 @@ public:
 private:
 
   FILE* myFile;
-  NCollection_DataMap<Handle(Image_Texture), TCollection_AsciiString, Image_Texture> myImageMap;
+  NCollection_DataMap<Handle(Image_Texture), TCollection_AsciiString> myImageMap;
 
 };
 
index 920cb73cd34f0d13743e8b9af3c99bd597464aa4..4b91d68bd2321ad00ffc20c60bd57935e84d491f 100644 (file)
@@ -29,6 +29,7 @@
 #include <RWObj_SubMesh.hxx>
 #include <RWObj_SubMeshReason.hxx>
 #include <RWObj_Tools.hxx>
+#include <Standard_HashUtils.hxx>
 
 #include <vector>
 
@@ -241,14 +242,13 @@ protected:
   //! 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]
index 9cd00eaebfc8cf0e3ea43d696b480a562f644af9..264c45b40a1bb5f2229ba5c18deca15b63ea1d80 100644 (file)
@@ -20,8 +20,8 @@
 #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
index 7b1e3b672dd5bc55c3bf2f9b44640cbc89341233..7bcc2458d434f0983d7c442e843c97929c1b210c 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 64bf32abc37120f333608b81c9803c94509d6e47..0072a4c71fb89337b253f8473c9f91ef65033bfc 100644 (file)
@@ -28,7 +28,6 @@
 #include <Standard_CString.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Real.hxx>
-#include <Standard_ExtString.hxx>
 
 
 class Resource_Manager;
index 42156faf4a18cb2ec9e32646e1e0eacda2d475fb..01739107160dbd8edea3e480d81d7a4d07a54bc8 100644 (file)
 
 #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
index 22e1b2a81e3b13c1ce1a6bb36f0e95c1b07121b7..c84b8b9756ec9ee063095da66952cf5abf88c941 100644 (file)
 #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
index c995f867b590d9cbdb39f920094b6524e8828fea..c7a275f156895c3b229d1a72e99d88f24117ae60 100644 (file)
 
 #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
index 0ebb2725e44d8e24747e4e5f20cac92ae9a057f3..7b786b5ec06eb2b76ef799076db5d25aa7778818 100644 (file)
 
 #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
index 95b83dc3f4635822ef982678e39f6dafaf0f8c13..8395ba5ff6ca036b98a5ffced80535439b756a24 100755 (executable)
@@ -14,9 +14,6 @@ STEPConstruct_ExternRefs.cxx
 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
index d4b3fe232bf45c4fcfaa9e78d7db16ee72f9535e..6cfa8739e36fac76b401a80cd0523cbc66f8cc36 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 029bcb40b877bd9a1b8e0a32123c35a2ad807240..6a538693f516a030ba7738602af6a76ace4aead0 100644 (file)
 
 #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
diff --git a/src/STEPConstruct/STEPConstruct_PointHasher.cxx b/src/STEPConstruct/STEPConstruct_PointHasher.cxx
deleted file mode 100644 (file)
index a01480f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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;
-}
diff --git a/src/STEPConstruct/STEPConstruct_PointHasher.hxx b/src/STEPConstruct/STEPConstruct_PointHasher.hxx
deleted file mode 100644 (file)
index 6713485..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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
diff --git a/src/STEPConstruct/STEPConstruct_PointHasher.lxx b/src/STEPConstruct/STEPConstruct_PointHasher.lxx
deleted file mode 100644 (file)
index 1e2e907..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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);
-}
index 3dd7afd0ad9b0543e86c7285032aca0c9b29282b..c96c1f8c60f59bcedc7331813d6b31284b875ecc 100644 (file)
@@ -45,9 +45,15 @@ public:
       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()
index fbb8a344af167004dbf57ff11ae68f92b9ca78ef..fbd8f99dd1049aaddf847635f96de47e808e5295 100644 (file)
@@ -19,9 +19,8 @@
 
 #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
index 90a7277ec1faf59d98687b4478871427944898f3..9fc46d28498e36c7b9fc347bba37a76bdbaaf207 100644 (file)
@@ -18,7 +18,6 @@
 #include <math_BullardGenerator.hxx>
 #include <NCollection_Map.hxx>
 #include <StdSelect_TypeOfSelectionImage.hxx>
-#include <Quantity_ColorHasher.hxx>
 
 class SelectMgr_ViewerSelector;
 
@@ -76,7 +75,7 @@ protected:
   Image_PixMap*             myImage;
   SelectMgr_ViewerSelector* myMainSel;
   math_BullardGenerator     myBullardGenerator;
-  NCollection_Map<Quantity_Color, Quantity_ColorHasher> myUniqueColors;
+  NCollection_Map<Quantity_Color> myUniqueColors;
 };
 
 #endif
index 5517a17b35236230569675b4a7ef7238761dff3f..2b88674808e99d3d4f0aa20e25096d4a39a25c04 100644 (file)
@@ -111,12 +111,7 @@ Standard_Real ShapeAnalysis::AdjustToPeriod(const Standard_Real Val,
 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
index cf6f27caff878688be303a44fd043d1eabf760b9..5e3e2a29bff499224d8bff5d5c6c34665b9915ae 100644 (file)
 
 #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
index fbabd618b09c442a45ae8772a86921ac39ca786c..e2ff4a7033e06d061f3a4946dbb71bd64c26640d 100644 (file)
@@ -165,9 +165,9 @@ void ShapeFix_EdgeConnect::Build ()
     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;
@@ -240,9 +240,9 @@ void ShapeFix_EdgeConnect::Build ()
     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;
index e6e14a2f427d59d18cac216c9b753dfe2ace2159..e3465f7568266064ff079a68d7489233d75b32dd 100755 (executable)
@@ -1,7 +1,6 @@
 Standard.cxx
 Standard.hxx
 Standard_AbortiveTransaction.hxx
-Standard_Address.hxx
 Standard_ArrayStreamBuffer.hxx
 Standard_ArrayStreamBuffer.cxx
 Standard_Assert.hxx
@@ -17,6 +16,7 @@ Standard_ConstructionError.hxx
 Standard_Copy.tcl
 Standard_CString.cxx
 Standard_CString.hxx
+Standard_CStringHasher.hxx
 Standard_DefineAlloc.hxx
 Standard_DefineException.hxx
 Standard_DefineHandle.hxx
@@ -29,8 +29,6 @@ Standard_Dump.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
@@ -38,6 +36,8 @@ Standard_GUID.cxx
 Standard_GUID.hxx
 Standard_Handle.hxx
 Standard_HandlerStatus.hxx
+Standard_HashUtils.hxx
+Standard_HashUtils.lxx
 Standard_ImmutableObject.hxx
 Standard_Integer.hxx
 Standard_IStream.hxx
@@ -45,16 +45,11 @@ Standard_JmpBuf.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
@@ -83,9 +78,7 @@ Standard_ReadBuffer.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
@@ -101,7 +94,6 @@ Standard_TypeDef.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
index bc601165c6f5cde1f41ea00e9eeec6f5d2e6285a..49bafea57d9f0348de5aea9a2d487da70f725e7c 100644 (file)
@@ -1,7 +1,4 @@
-// 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
 }
index 8d0fb3a1a6caf1aea466f49bc89fd4c20c16ff38..c9671f68ffddf81456847d6b208dcfc07a46bd8e 100644 (file)
 #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.
 
@@ -32,10 +29,25 @@ public:
 
   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
@@ -51,9 +63,9 @@ public:
   }
   
   //! 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.
@@ -104,8 +116,4 @@ public:
 
 };
 
-// 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
diff --git a/src/Standard/Standard_Address.hxx b/src/Standard/Standard_Address.hxx
deleted file mode 100644 (file)
index 2919d45..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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
index f73d6b6940520c2d120da36d425fa393e644d469..c62acd7a53e9cfb2f6cb70e341c7ed7f8157ccc1 100755 (executable)
 #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
@@ -89,13 +59,6 @@ Standard_Integer HashCodes (const Standard_CString theString, const Standard_Int
   #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);
index 4f5b353618f5efa40e5d6472564875744ef25626..0b05b7899b2ccc2e0aa670e95bd304eab21d2b6e 100644 (file)
 // 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)
diff --git a/src/Standard/Standard_CStringHasher.hxx b/src/Standard/Standard_CStringHasher.hxx
new file mode 100644 (file)
index 0000000..893e8d3
--- /dev/null
@@ -0,0 +1,45 @@
+// 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
diff --git a/src/Standard/Standard_ExtString.cxx b/src/Standard/Standard_ExtString.cxx
deleted file mode 100644 (file)
index 94ca59f..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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);
-}
diff --git a/src/Standard/Standard_ExtString.hxx b/src/Standard/Standard_ExtString.hxx
deleted file mode 100644 (file)
index 2953de8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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
index 6383445f8880eaf09583fe15fb5e43b776f22195..1f158e83c2c5ea571ea3ba15c6c03b8c8c3c9234 100644 (file)
@@ -387,30 +387,3 @@ void Standard_GUID::ShallowDump(Standard_OStream& aStream) const
   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);
-}
-
index 148e51116130b9e162316de24c0b03f9f1eb295b..2d5a6109f2df7280c14e534e474acbfca0b8fbce 100644 (file)
@@ -104,32 +104,12 @@ void operator = (const Standard_UUID& uid)
   //! 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;
@@ -140,12 +120,38 @@ private:
   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));
+    }
+  };
+}
 
 
 
index 6c212951b3c3c5c6afa085c4dd8c7c65f2efa57a..db2d94319a76996e7c35dad257f891b64b5ffc8b 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef _Standard_Handle_HeaderFile
 #define _Standard_Handle_HeaderFile
 
-#include <Standard_Address.hxx>
 #include <Standard_Std.hxx>
 #include <Standard_Stream.hxx>
 #include <Standard_Transient.hxx>
@@ -399,14 +398,18 @@ namespace opencascade {
 //! 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>.
diff --git a/src/Standard/Standard_HashUtils.hxx b/src/Standard/Standard_HashUtils.hxx
new file mode 100644 (file)
index 0000000..40b613f
--- /dev/null
@@ -0,0 +1,120 @@
+// 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
diff --git a/src/Standard/Standard_HashUtils.lxx b/src/Standard/Standard_HashUtils.lxx
new file mode 100644 (file)
index 0000000..4983498
--- /dev/null
@@ -0,0 +1,159 @@
+// 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
index 9858ce7f41b17ddfcb569ecab06f39fee8df5194..d629b87c06e45cc2f7fc2501ec4653ca6442c12e 100755 (executable)
@@ -17,7 +17,8 @@
 
 #include <Standard_Std.hxx>
 #include <Standard_TypeDef.hxx>
-#include <Standard_values.h>
+
+#include <climits>
 
 // ===============
 // Inline methods
@@ -78,102 +79,19 @@ inline Standard_Integer Square(const Standard_Integer Value)
 // ------------------------------------------------------------------
 // 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
diff --git a/src/Standard/Standard_MMgrRaw.cxx b/src/Standard/Standard_MMgrRaw.cxx
deleted file mode 100644 (file)
index 83ec139..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// 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;
-}
diff --git a/src/Standard/Standard_MMgrRaw.hxx b/src/Standard/Standard_MMgrRaw.hxx
deleted file mode 100644 (file)
index f301372..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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
diff --git a/src/Standard/Standard_MMgrTBBalloc.cxx b/src/Standard/Standard_MMgrTBBalloc.cxx
deleted file mode 100644 (file)
index 8c7a2df..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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;
-}
diff --git a/src/Standard/Standard_MMgrTBBalloc.hxx b/src/Standard/Standard_MMgrTBBalloc.hxx
deleted file mode 100644 (file)
index 3c6ce08..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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
diff --git a/src/Standard/Standard_MemoryUtils.hxx b/src/Standard/Standard_MemoryUtils.hxx
new file mode 100644 (file)
index 0000000..21a5622
--- /dev/null
@@ -0,0 +1,62 @@
+// 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
index 96393da3b2e2eceababc50a78c85e1ac993e22a4..bef7be90993c62b81d121eba9a8b06f8a0443ee0 100644 (file)
@@ -26,7 +26,5 @@
 #include <Standard_Character.hxx>
 #include <Standard_ExtCharacter.hxx>
 #include <Standard_CString.hxx>
-#include <Standard_ExtString.hxx>
-#include <Standard_Address.hxx>
 
 #endif
index f43762aeed2e8ea00f4e4a4a5885fef63077db32..51721d48d7c7b0637b91a248d4d39bb05b075f9c 100644 (file)
 
 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
 //-------------------------------------------------------------------
index 43a95d717db702798f2670334f86e8f7e9e57172..f185568f515fd9a82f1a992cddc900afc128d313 100644 (file)
 #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 );
@@ -56,7 +57,7 @@ Standard_EXPORT Standard_Real    Sqrt        (const Standard_Real );
 //-------------------------------------------------------------------
 // RealSmall : Returns the smallest positive real
 //-------------------------------------------------------------------
-inline Standard_Real     RealSmall() 
+constexpr Standard_Real     RealSmall()
 { return DBL_MIN; }
 
 //-------------------------------------------------------------------
@@ -84,60 +85,60 @@ inline Standard_Boolean  IsEqual (const Standard_Real Value1,
 //-------------------------------------------------------------------
 // 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); }
 
 
 
diff --git a/src/Standard/Standard_ShortReal.cxx b/src/Standard/Standard_ShortReal.cxx
deleted file mode 100644 (file)
index f3c123e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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);
-}
index 81d07405ebed68effa6cbfa94fddc68cddf058f5..34230ca46983d139616363b4d49470f048bdef56 100644 (file)
@@ -16,9 +16,9 @@
 #define _Standard_ShortReal_HeaderFile
 
 #include <cmath>
+#include <climits>
 #include <float.h>
 
-#include <Standard_values.h>
 #include <Standard_TypeDef.hxx>
 
          //  *********************************** //
@@ -31,7 +31,7 @@
 //-------------------------------------------------------------------
 // ShortRealSmall : Returns the smallest positive ShortReal
 //-------------------------------------------------------------------
-inline Standard_ShortReal     ShortRealSmall() 
+constexpr Standard_ShortReal   ShortRealSmall()
 { return FLT_MIN; }
 
 //-------------------------------------------------------------------
@@ -47,14 +47,14 @@ inline Standard_ShortReal     Abs(const Standard_ShortReal Value)
 //-------------------------------------------------------------------
 // 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; }
 
 //-------------------------------------------------------------------
@@ -68,40 +68,40 @@ inline Standard_ShortReal     ShortRealFirst()
 // 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
@@ -129,29 +129,6 @@ inline Standard_ShortReal     Min (const Standard_ShortReal Val1,
   }
 }
 
-// ===============================================
-// 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
 
 
diff --git a/src/Standard/Standard_Size.hxx b/src/Standard/Standard_Size.hxx
deleted file mode 100644 (file)
index e8d8e8d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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
index b4d06260ee3d2307e5f0166fadd07456904b6d6a..9cdd9a47652571a2c8b4243a198cd6b3a0ffed0b 100644 (file)
@@ -16,7 +16,6 @@
 #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;
index 09455a92785282e26c0f42792adce8804777e88a..fa71956bfa8e1e8daef38d6090e246ad129c9720 100644 (file)
@@ -1,5 +1,5 @@
 // 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();
@@ -71,15 +66,3 @@ Standard_Transient* Standard_Transient::This() const
     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_);
-}
index dd0f58dad1ab37ad3c7cd6700a6ab7d129f72c5a..024c631d2751f630302162dffcab432638c0d146 100644 (file)
@@ -1,5 +1,5 @@
 // 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;
 }
 
@@ -48,15 +51,12 @@ public:
   //! 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 ();
@@ -90,34 +90,35 @@ public:
   //!@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;
 
index 546cbafa855f61c54aad629d3e277d101e183343..6321deab29b078fa75bc1b62757f9efc7371624a 100644 (file)
 
 #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)
 {
@@ -70,25 +61,8 @@ void Standard_Type::Print (Standard_OStream& AStream) const
 //============================================================================
 
 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
@@ -102,7 +76,7 @@ namespace {
   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
@@ -113,17 +87,15 @@ Standard_Type* Standard_Type::Register (const char* theSystemName, const char* t
   // 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;
 }
 
@@ -131,9 +103,5 @@ Standard_Type::~Standard_Type ()
 {
   // 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",);
 }
index 65b6826a81a459ea7c531642965a3a35e745ece5..6608b757e995c71d57b326dbfef7b463be12a431 100644 (file)
@@ -21,6 +21,7 @@
 #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.
@@ -146,7 +147,7 @@ class Standard_Type : public Standard_Transient
 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; }
@@ -181,14 +182,14 @@ public:
 
   //! 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
@@ -200,11 +201,11 @@ public:
 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
@@ -252,7 +253,7 @@ namespace opencascade {
     // 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;
   }
diff --git a/src/Standard/Standard_math.cxx b/src/Standard/Standard_math.cxx
deleted file mode 100644 (file)
index c711d4a..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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
diff --git a/src/Standard/Standard_math.hxx b/src/Standard/Standard_math.hxx
deleted file mode 100644 (file)
index a2eb979..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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
diff --git a/src/Standard/Standard_values.h b/src/Standard/Standard_values.h
deleted file mode 100644 (file)
index 8d397dd..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- 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
-
index 87142c0003cdd060e3846dba3fc19e87f6f4d791..619d5fd12f4c00967cb27691f73a2452d0a2ea4a 100644 (file)
 
 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>);
   }
 
index 89401fd5a70f68f1a5e21da00f54466c34bc1401..ccd8ec19d173ced77eb963b6730f726ec09c6cef 100644 (file)
@@ -19,7 +19,7 @@
 #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
index b6acbe346bb8adb9a6193a17fcc664a33b67ca0e..d52a5e444d0f5115d8bd2dc68620c60d5107019d 100644 (file)
@@ -21,7 +21,7 @@
 #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
index 04acffa1b45cfecfa80acf261fa90e567ee86da5..56c8395d0271dafef2dba9511d30920aaa0c6bfd 100644 (file)
@@ -86,14 +86,15 @@ void StepData_FreeFormEntity::SetStepType (const Standard_CString typenam)
     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;
index 26c27041ad038158e7de1d7f179cc5bef23f4e33..5d6ef2b87e99a4f0be544f20fcd474ebf7fc1ea9 100644 (file)
@@ -3,8 +3,6 @@ StepToTopoDS.hxx
 StepToTopoDS_Builder.cxx
 StepToTopoDS_Builder.hxx
 StepToTopoDS_BuilderError.hxx
-StepToTopoDS_CartesianPointHasher.cxx
-StepToTopoDS_CartesianPointHasher.hxx
 StepToTopoDS_DataMapIteratorOfDataMapOfRI.hxx
 StepToTopoDS_DataMapIteratorOfDataMapOfRINames.hxx
 StepToTopoDS_DataMapIteratorOfDataMapOfTRI.hxx
@@ -23,8 +21,6 @@ StepToTopoDS_NMTool.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
diff --git a/src/StepToTopoDS/StepToTopoDS_CartesianPointHasher.cxx b/src/StepToTopoDS/StepToTopoDS_CartesianPointHasher.cxx
deleted file mode 100644 (file)
index 6deba88..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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);
-}
diff --git a/src/StepToTopoDS/StepToTopoDS_CartesianPointHasher.hxx b/src/StepToTopoDS/StepToTopoDS_CartesianPointHasher.hxx
deleted file mode 100644 (file)
index 4c8a8bb..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-// 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
index 064fc50aa78957e76a3d8744e222d37253451602..68837f6d990ac757b7326e35af23105a6a079b7c 100644 (file)
 
 #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
index b9cf81456256884ed94597855666b4408e93a7fc..3510dbfa0eaea4496d2e2f2bea55c813160d11ec 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 5b001f442531c5021dc44d23263501e9eb29fc4e..f473281b2e8313fada7135c6dbccd8cf33f640fe 100644 (file)
 
 #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
index d5f1784166a24bef43732167c502c257884ae84f..1c32a82e1ee1122b8c4c230261826c8026fad0cf 100644 (file)
 
 #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
index add5804ed386d642d4e14b780ffe0e9bcffbc7ae..65cafd86172f2dfbe7647edf1bd569c0b40422b4 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <StepGeom_CartesianPoint.hxx>
 #include <StepToTopoDS_PointPair.hxx>
-#include <StepToTopoDS_PointPairHasher.hxx>
 
 //=======================================================================
 //function : StepToTopoDS_PointPair
index ecbbc0bd917e1a2647d1eaeaed8793c216f897b6..a4dbdcb118f77802d1c3424f142146777bcbcb2d 100644 (file)
@@ -23,7 +23,6 @@
 
 class StepGeom_CartesianPoint;
 
-
 //! Stores a pair of Points from step
 class StepToTopoDS_PointPair 
 {
@@ -34,9 +33,21 @@ public:
   
   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:
 
@@ -54,6 +65,25 @@ private:
 
 };
 
+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));
+    }
+  };
+}
 
 
 
diff --git a/src/StepToTopoDS/StepToTopoDS_PointPairHasher.cxx b/src/StepToTopoDS/StepToTopoDS_PointPairHasher.cxx
deleted file mode 100644 (file)
index 22324ec..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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)));
-}
diff --git a/src/StepToTopoDS/StepToTopoDS_PointPairHasher.hxx b/src/StepToTopoDS/StepToTopoDS_PointPairHasher.hxx
deleted file mode 100644 (file)
index efc515a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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
index 75cba0c08c93fd2c009e30a3922c0da4b0289264..024fb765dae5581f805c37d47b9adb4c4a8983a3 100644 (file)
 
 #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
index 079eba5f66bb6d3f10deec69f0f82dceb995edf6..3d67aea0079d06bd3bedf45f9abce18e5c678334 100644 (file)
@@ -21,8 +21,8 @@
 #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
index cbde1b89a9e16d39022eed92769d542d82dc6ab3..412561bb0bb31ddb7b7f259019fad9f048c1f2e8 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 9a90b69cbfab2e83ee800203deaea0cdc4c59fb0..ccf8b21127ce5d8b93d5523d6910fc4ea2ea8732 100644 (file)
@@ -21,7 +21,7 @@
 #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
index bb617809b06b831f8d2044fc674022ecfd9671cd..06fc5c067055d212169accd49911e6cf6fe6aceb 100644 (file)
@@ -718,75 +718,80 @@ void Storage_Schema::Clear() const
 // 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;
@@ -794,7 +799,7 @@ Standard_Boolean Storage_Schema::CheckTypeMigration(
       std::cout << " newName = " << newName << std::endl;
 #endif
     }
-  } 
+  }
   return aMigration;
 }
 #endif
index ee75061d79eb3d9fc972257b51e80e33fbbfcd0d..97e9f8355ce68a8a84b22f0291a03d826a2487a4 100755 (executable)
@@ -63,7 +63,6 @@ TColStd_ListOfAsciiString.hxx
 TColStd_ListOfInteger.hxx
 TColStd_ListOfReal.hxx
 TColStd_ListOfTransient.hxx
-TColStd_MapIntegerHasher.hxx
 TColStd_MapIteratorOfMapOfAsciiString.hxx
 TColStd_MapIteratorOfMapOfInteger.hxx
 TColStd_MapIteratorOfMapOfReal.hxx
@@ -73,8 +72,6 @@ TColStd_MapOfAsciiString.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
index eeb07c31b97c57dd4fd126b684378784f54f4c0b..89ac373453b7919c757dc7ac9801036d693c4769 100644 (file)
@@ -19,8 +19,8 @@
 #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
index ce0297b28bd3386724de8d6b60f543643838e971..b67ecd254d135ee70fdfe836a1b4d6cb8834681d 100644 (file)
 #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
index 6fe3efb5405aee7d53e813c18d64f9975a9371bd..4e5c61f83c72e438c12c690debc14b5bfc866d11 100644 (file)
 
 #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
index 35d806363ad7b53b2c9ee8809d782090cd6430f4..a618980f61ca5a01226bf110a4dba5eff750e3d0 100644 (file)
 #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
index ea1f44dd83558b4f2435c66394d432555b84fc73..2d18542e4ad62047db81eedf12aacc0116464961 100644 (file)
 
 #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
index e6566aa60371c834112abe87dcfc2bdc995d327b..ef92f8ba71ff627b55e81bcecf221f916b3ed657 100644 (file)
@@ -18,8 +18,8 @@
 #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
index 35beea3c0ccc2c1a7ea2d7de8effd3d2b799f912..562c1f6546cbfdba95ec3d4ccdc150716260c749 100644 (file)
 #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
index 7468a0f9d86acf22df0d4d19956c799b92b28afc..baad76dfe1adbc6deb45047f73fa3b626079c411 100644 (file)
@@ -17,6 +17,6 @@
 #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
index c7c26546802513402929744cef92404cf0557150..abaf3eb81cc759fbd6731f4e650fbf17e33b2128 100644 (file)
 #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
index b15c0d3bb1e8dd0563f5cb13f20e92a38182fd41..6cc252ce82b0f79bcdc87714b0fab5cd5255691c 100644 (file)
 #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
index bc5e8601c8260d9a585437ac172574e21846b3af..7ab05592703f62a3439238a95bc2f6a7a872e1e2 100644 (file)
 #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
index ecd46b8fe9db535920f1b565a04346e9d18a546b..24d54709a4ab99c4763642529284ec1505ca6291 100644 (file)
 #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
diff --git a/src/TColStd/TColStd_MapIntegerHasher.hxx b/src/TColStd/TColStd_MapIntegerHasher.hxx
deleted file mode 100644 (file)
index 268c6a0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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
index 05e287750dfd48deb7245cb4da5f3cbdbd2c9490..bc639f0c8769d96c5ef9a70e290846a8fac5e055 100644 (file)
@@ -18,8 +18,8 @@
 #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
index edd24505ace3828071fd9f3d3cce0b2504ec7ee3..bd5f90bf64607d34275e7c6014e28e55071e4565 100644 (file)
 #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
index 0fb8a509306009ab1ae3ec896e2c2553c4820c65..249cfa2b304fdec4bddf0242f39f5ea177ad1b61 100644 (file)
 #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
index 308225a4e00850efed444511d77a6d13f267e7a1..8dc0f1b443fe6fd150715336f95cd4d4439db15e 100644 (file)
 #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
diff --git a/src/TColStd/TColStd_MapRealHasher.hxx b/src/TColStd/TColStd_MapRealHasher.hxx
deleted file mode 100644 (file)
index df075d0..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
diff --git a/src/TColStd/TColStd_MapTransientHasher.hxx b/src/TColStd/TColStd_MapTransientHasher.hxx
deleted file mode 100644 (file)
index a040d5b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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
index 07650da631eeda539174d73fcae6818728ddef18..55fa98ad8ab1ee604636256f2738feb0c9593a50 100644 (file)
 #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  :
@@ -122,7 +131,7 @@ TColStd_PackedMapOfInteger& TColStd_PackedMapOfInteger::Assign
       {
         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();
@@ -154,7 +163,7 @@ void TColStd_PackedMapOfInteger::ReSize (const Standard_Integer theNbBuckets)
     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)
   {
@@ -163,7 +172,7 @@ void TColStd_PackedMapOfInteger::ReSize (const Standard_Integer theNbBuckets)
     {
       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;
@@ -219,7 +228,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Add (const Standard_Integer aKey)
   }
 
   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())
   {
@@ -426,7 +435,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap
         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;
@@ -459,7 +468,7 @@ void TColStd_PackedMapOfInteger::Union (const TColStd_PackedMapOfInteger& theMap
           {
             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;
@@ -498,7 +507,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Unite(const TColStd_PackedMapOfInte
       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)
       {
@@ -594,7 +603,7 @@ void TColStd_PackedMapOfInteger::Intersection
               {
                 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,
@@ -739,7 +748,7 @@ void TColStd_PackedMapOfInteger::Subtraction
           {
             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;
@@ -877,7 +886,7 @@ void TColStd_PackedMapOfInteger::Difference  (const TColStd_PackedMapOfInteger&
           {
             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;
@@ -912,7 +921,7 @@ void TColStd_PackedMapOfInteger::Difference  (const TColStd_PackedMapOfInteger&
           {
             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;
@@ -992,7 +1001,7 @@ Standard_Boolean TColStd_PackedMapOfInteger::Differ(const TColStd_PackedMapOfInt
         {
           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;
index 50e9e659b216098a64696a7252c4252cfa95c846..190a54baea002efb0c382bd44390a047950ac40e 100644 (file)
@@ -17,7 +17,6 @@
 #define TColStd_PackedMapOfInteger_HeaderFile
 
 #include <Standard.hxx>
-#include <Standard_Address.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Integer.hxx>
@@ -125,7 +124,7 @@ private:
     //! 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.
index 51b7a2d871d3afd9ee86a3574b2d70981322c9f6..446f09c9b9cdb1b833bdaf082e416a86cbafcfbb 100644 (file)
@@ -15,7 +15,6 @@
 #ifndef TColStd_SequenceOfAddress_HeaderFile
 #define TColStd_SequenceOfAddress_HeaderFile
 
-#include <Standard_Address.hxx>
 #include <NCollection_Sequence.hxx>
 
 typedef NCollection_Sequence<Standard_Address> TColStd_SequenceOfAddress;
index 3234a888bdc4af4dde1af84e8b3bdc69499bc4cc..e6006855e727c4a11b8ef0e68369ca92fc1e6ff5 100644 (file)
 #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'};
 }
 
 // ----------------------------------------------------------------------------
@@ -48,10 +37,7 @@ static inline void Free (Standard_PCharacter aAddr)
 // ----------------------------------------------------------------------------
 TCollection_AsciiString::TCollection_AsciiString()
 {
-  mylength = 0;
-  
-  mystring = Allocate(mylength+1);
-  mystring[mylength] = '\0';
+  allocate(0);
 }
 
 
@@ -59,18 +45,13 @@ TCollection_AsciiString::TCollection_AsciiString()
 // 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';
 }
 
 
@@ -79,36 +60,28 @@ TCollection_AsciiString::TCollection_AsciiString (const Standard_CString theStri
 // ----------------------------------------------------------------------------
 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);
   }
 }
 
@@ -118,50 +91,59 @@ TCollection_AsciiString::TCollection_AsciiString(const Standard_Character aChar)
 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;
 }
 
 // ----------------------------------------------------------------------------
@@ -169,16 +151,13 @@ TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString&
 // ----------------------------------------------------------------------------
 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';
 }
 
 // ----------------------------------------------------------------------------
@@ -186,11 +165,9 @@ TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString&
 // ----------------------------------------------------------------------------
 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);
@@ -199,7 +176,6 @@ TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString&
   {
     memcpy (mystring + theString1.mylength, theString2, aStr2Len);
   }
-  mystring[mylength] = '\0';
 }
 
 // ----------------------------------------------------------------------------
@@ -207,10 +183,8 @@ TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString&
 // ----------------------------------------------------------------------------
 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);
@@ -219,30 +193,25 @@ TCollection_AsciiString::TCollection_AsciiString (const TCollection_AsciiString&
   {
     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);
   }
 }
@@ -251,16 +220,13 @@ TCollection_AsciiString::TCollection_AsciiString(const TCollection_ExtendedStrin
 //  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)
   {
@@ -294,10 +260,8 @@ void TCollection_AsciiString::AssignCat(const Standard_Real other)
 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;
   }
 }
 
@@ -314,10 +278,9 @@ void TCollection_AsciiString::AssignCat (const Standard_CString theOther)
   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);
   }
 }
 
@@ -328,10 +291,9 @@ void TCollection_AsciiString::AssignCat (const TCollection_AsciiString& theOther
 {
   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);
   }
 }
 
@@ -384,13 +346,7 @@ void TCollection_AsciiString::ChangeAll(const Standard_Character aChar,
 // ----------------------------------------------------------------------------
 void TCollection_AsciiString::Clear()
 {
-  if ( mylength > 0 )
-  {
-    Free (mystring);
-    mylength = 0;
-    mystring = Allocate(mylength+1);
-    mystring[mylength] = '\0';
-  }
+  deallocate();
 }
 
 // ----------------------------------------------------------------------------
@@ -398,14 +354,19 @@ void TCollection_AsciiString::Clear()
 // ----------------------------------------------------------------------------
 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;
   }
 }
 
@@ -414,22 +375,51 @@ void TCollection_AsciiString::Copy(const Standard_CString fromwhere)
 // ----------------------------------------------------------------------------
 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);
 }
@@ -439,9 +429,7 @@ void TCollection_AsciiString::Swap (TCollection_AsciiString& theOther)
 // ----------------------------------------------------------------------------
 TCollection_AsciiString::~TCollection_AsciiString()
 {
-  if (mystring) 
-    Free (mystring);
-  mystring = 0L;
+  deallocate ();
 }
 
 // ----------------------------------------------------------------------------
@@ -493,14 +481,13 @@ void TCollection_AsciiString::Insert(const Standard_Integer where,
   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';
 }
 
 // ----------------------------------------------------------------------------
@@ -511,19 +498,15 @@ void TCollection_AsciiString::Insert(const Standard_Integer where,
 {
   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 {
@@ -540,21 +523,17 @@ void TCollection_AsciiString::Insert(const Standard_Integer where,
 {
   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 {
@@ -805,10 +784,9 @@ void TCollection_AsciiString::LeftJustify(const Standard_Integer Width,
                                           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();
@@ -910,10 +888,8 @@ void TCollection_AsciiString::Read(Standard_IStream& astream)
   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';
 }
 
 
@@ -962,7 +938,6 @@ void TCollection_AsciiString::RemoveAll(const Standard_Character what,
     }
   }
   mylength = c;
-  mystring[mylength] = '\0';
 }
 
 // ----------------------------------------------------------------------------
@@ -975,7 +950,6 @@ void TCollection_AsciiString::RemoveAll(const Standard_Character what)
   for (int i=0; i < mylength; i++)
     if (mystring[i] != what) mystring[c++] = mystring[i];
   mylength = c;
-  mystring[mylength] = '\0';
 }
 
 // ----------------------------------------------------------------------------
@@ -1017,16 +991,13 @@ void TCollection_AsciiString::RightAdjust ()
 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();
@@ -1145,12 +1116,10 @@ void TCollection_AsciiString::SetValue(const Standard_Integer where,
    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 : "
@@ -1169,12 +1138,10 @@ void TCollection_AsciiString::SetValue(const Standard_Integer where,
    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 : "
@@ -1182,21 +1149,6 @@ void TCollection_AsciiString::SetValue(const Standard_Integer where,
  }
 }
 
-// ----------------------------------------------------------------------------
-// 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
@@ -1212,39 +1164,6 @@ TCollection_AsciiString TCollection_AsciiString::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
 // ----------------------------------------------------------------------------
@@ -1344,3 +1263,65 @@ Standard_Character TCollection_AsciiString::Value
  }
  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;
+}
index 0e5d2ff82a10e76f19ffaea64f89887d145d58e9..b017ef48578414359f9a9b34f8a387f0d18aed12 100644 (file)
@@ -75,13 +75,7 @@ public:
   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.
@@ -268,16 +262,26 @@ void operator = (const Standard_CString fromwhere)
   //! 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();
@@ -670,12 +674,10 @@ friend Standard_EXPORT Standard_IStream& operator >> (Standard_IStream& astream,
   //! 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)
@@ -694,17 +696,19 @@ friend class TCollection_HAsciiString;
 
 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>
index 2eef2fd1556a9a0d7f31fee6e5c2d1f1706f4d6e..056e24382c3209de3096f9b633a996f7878b60fb 100644 (file)
 
 #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
 //------------------------------------------------------------------------
@@ -36,8 +40,6 @@ inline Standard_Boolean IsEqual(const TCollection_AsciiString& string1,
   return TCollection_AsciiString::IsEqual(string1,string2);
 }
 
-
-
 // ----------------------------------------------------------------------------
 // ToCString
 // ----------------------------------------------------------------------------
@@ -83,10 +85,13 @@ inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Real
 // 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);
 }
 
 
index 2a83bab60312cbdd224ff19c91ba349c5dccce20..c87bedcdfd78534e125ac572cf512fc23b83ebee 100644 (file)
 
 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>
@@ -57,7 +44,12 @@ namespace
                                                                 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)
     {
@@ -73,7 +65,12 @@ namespace
                                                                                                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;
@@ -86,10 +83,8 @@ namespace
 // Create an empty ExtendedString
 // ----------------------------------------------------------------------------
 TCollection_ExtendedString::TCollection_ExtendedString()
-: mystring (allocateExtChars (0)),
-  mylength (0)
 {
-  mystring[0] = 0;
+  allocate(0);
 }
 
 //----------------------------------------------------------------------------
@@ -97,9 +92,7 @@ TCollection_ExtendedString::TCollection_ExtendedString()
 //----------------------------------------------------------------------------
 TCollection_ExtendedString::TCollection_ExtendedString
                                           (const Standard_CString theString,
-                                           const Standard_Boolean isMultiByte) 
-: mystring (NULL),
-  mylength (0)
+                                           const Standard_Boolean isMultiByte)
 {
   if (theString == NULL)
   {
@@ -108,30 +101,28 @@ TCollection_ExtendedString::TCollection_ExtendedString
 
   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)
   {
@@ -139,18 +130,14 @@ TCollection_ExtendedString::TCollection_ExtendedString (const Standard_ExtString
   }
 
   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)
   {
@@ -166,17 +153,14 @@ TCollection_ExtendedString::TCollection_ExtendedString (const Standard_WideChar*
 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);
   }
 }
 
@@ -186,10 +170,8 @@ TCollection_ExtendedString::TCollection_ExtendedString
 TCollection_ExtendedString::TCollection_ExtendedString
                                         (const Standard_ExtCharacter aChar)
 {
-  mylength    = 1;
-  mystring    = allocateExtChars (1);
+  allocate(1);
   mystring[0] = aChar;
-  mystring[1] = 0;
 }
 
 // ----------------------------------------------------------------------------
@@ -199,10 +181,8 @@ TCollection_ExtendedString::TCollection_ExtendedString
                                         (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;
 }
 
 // ----------------------------------------------------------------------------
@@ -214,10 +194,8 @@ TCollection_ExtendedString::TCollection_ExtendedString
   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;
 }
 
 // ----------------------------------------------------------------------------
@@ -229,23 +207,37 @@ TCollection_ExtendedString::TCollection_ExtendedString
   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;
 }
 
 //---------------------------------------------------------------------------
@@ -255,22 +247,17 @@ TCollection_ExtendedString::TCollection_ExtendedString
                                 (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;
 }
 
 // ----------------------------------------------------------------------------
@@ -284,19 +271,9 @@ void TCollection_ExtendedString::AssignCat (const TCollection_ExtendedString& th
   }
 
   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));
 }
 
 // ----------------------------------------------------------------------------
@@ -306,10 +283,8 @@ void TCollection_ExtendedString::AssignCat(const Standard_Utf16Char theChar)
 {
   if (theChar != '\0')
   {
-    mystring = reallocateExtChars(mystring, mylength + 1);
-    mystring[mylength] = theChar;
-    mylength += 1;
-    mystring[mylength] = '\0';
+    reallocate(mylength + 1);
+    mystring[mylength - 1] = theChar;
   }  
 }
 
@@ -342,45 +317,55 @@ void TCollection_ExtendedString::ChangeAll(const Standard_ExtCharacter aChar,
 // ----------------------------------------------------------------------------
 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;
 }
 
 // ----------------------------------------------------------------------------
@@ -388,7 +373,11 @@ void TCollection_ExtendedString::Copy (const TCollection_ExtendedString& fromwhe
 // ----------------------------------------------------------------------------
 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);
 }
 
@@ -397,8 +386,7 @@ void TCollection_ExtendedString::Swap (TCollection_ExtendedString& theOther)
 // ----------------------------------------------------------------------------
 TCollection_ExtendedString::~TCollection_ExtendedString()
 {
-  if (mystring) Standard::Free(mystring);
-  mystring = 0L;
+  deallocate ();
 }
 
 //----------------------------------------------------------------------------
@@ -413,21 +401,12 @@ void TCollection_ExtendedString::Insert(const Standard_Integer where,
   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;
 }
 
 // ----------------------------------------------------------------------------
@@ -440,23 +419,14 @@ void TCollection_ExtendedString::Insert(const Standard_Integer            where,
   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 {
@@ -728,17 +698,10 @@ void TCollection_ExtendedString::SetValue
     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 : "
@@ -766,13 +729,17 @@ TCollection_ExtendedString TCollection_ExtendedString::Token
                                       (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;
@@ -823,13 +790,13 @@ TCollection_ExtendedString TCollection_ExtendedString::Token
     }
   }
   
-  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';
   }
@@ -841,8 +808,7 @@ TCollection_ExtendedString TCollection_ExtendedString::Token
 // ----------------------------------------------------------------------------
 Standard_ExtString TCollection_ExtendedString::ToExtString() const
 {
-  if(mystring) return mystring;
-  return NULL_EXTSTRING;
+  return mystring;
 }
 
 // ----------------------------------------------------------------------------
@@ -931,3 +897,64 @@ Standard_Integer TCollection_ExtendedString::ToUTF8CString(Standard_PCharacter&
   *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;
+}
index f71869ac6f245cb44c13f31c909a17ece0202a9d..d23d2983ac9b1c811f6c75794a934ac56d2d5825 100644 (file)
@@ -25,7 +25,6 @@
 #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>
@@ -99,13 +98,7 @@ public:
   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.
@@ -145,16 +138,26 @@ TCollection_ExtendedString operator + (const TCollection_ExtendedString& other)
   //! 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();
@@ -331,16 +334,18 @@ friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,
   //! 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
@@ -365,23 +370,33 @@ friend Standard_EXPORT Standard_OStream& operator << (Standard_OStream& astream,
 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
index 51ef876ef7f8eda17599b5ac9830cfa85299cec9..ed66eec3e661ebf8e73bac65b394b1b813f907fd 100644 (file)
@@ -66,6 +66,11 @@ public:
   
   //! 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);
index f097751cf48a508637b873c7e98a8227af4c0817..e5a92d89ce20bf99f0fdb03547b006bb4d691e45 100644 (file)
@@ -41,3 +41,27 @@ inline const TCollection_AsciiString& TCollection_HAsciiString::String() const
 // ----------------------------------------------------------------------------
 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());
+    }
+  };
+}
index 6c5a7a3460b6e3840ec9f07640a69b57327e793d..a1527b218a911bbd7dfb973dc81131f17fe3b122 100644 (file)
@@ -64,8 +64,13 @@ public:
   //! 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);
@@ -218,10 +223,29 @@ private:
 
 };
 
-
-
-
-
-
+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
index b6f97ecf00b8636a7e04b72ef3a0b6bef985b45b..61744e34794b78597feff08998c254afb963c676 100755 (executable)
@@ -82,7 +82,6 @@ TDF_LabelIndexedMap.hxx
 TDF_LabelIntegerMap.hxx
 TDF_LabelList.hxx
 TDF_LabelMap.hxx
-TDF_LabelMapHasher.hxx
 TDF_LabelNode.cxx
 TDF_LabelNode.hxx
 TDF_LabelNodePtr.hxx
index b679eea2e1aee77bbc1f999d19d526482169a6a7..49630919b286fa14145da548165601be5b3441d2 100644 (file)
 #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
index acbc467847f043df3eeaa4082315607feab5a2b6..6338f07100c468afd30171b2add2a2b7bf409dcc 100644 (file)
 
 #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
index 3f785b6dfb6bc8e3e183c53b649afe9a86370627..4be5d176f400184f82abe204e457fbbfcd4a27d8 100644 (file)
 #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
index 2046c845e7b8aa0ec0fcefa11a8328f735a9ae60..b6c8d781b4586afe69c685454ac912d94e108cd0 100644 (file)
 #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
index c355d3a97f1f3a4fa8c5dbd4b31a8e29b50cb117..7ed56a2c10d1041bea127a530786ad5c1037c78d 100644 (file)
@@ -28,6 +28,7 @@
 #include <TDF_LabelMap.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
 #include <TDF_RelocationTable.hxx>
+#include <Standard_TypeMismatch.hxx>
 
 //=======================================================================
 //function : Copy
index 1a852bcc5f3c2d02f006893183ff4f8d9e43ad3d..93deb07ea0397cfed130aa18a427a979215826a4 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <NCollection_DataMap.hxx>
 #include <Standard_Mutex.hxx>
+#include <Standard_CStringHasher.hxx>
 #include <TCollection_AsciiString.hxx>
 
 namespace TDF_DerivedAttributeGlobals
@@ -35,16 +36,16 @@ 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;
   }
 
@@ -154,7 +155,7 @@ void TDF_DerivedAttribute::Attributes (NCollection_List<Handle(TDF_Attribute)>&
 {
   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());
index ebb4be6ceea64f83a1e29029049113926cc835f4..ded17627dc0dcbcb09e6ff5d2de08357df3909e3 100644 (file)
@@ -20,8 +20,8 @@
 #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
index 51f3f2ad532d49278bf9e7d6998119b078fcc4c1..905210fa14b93b4027b1409898ad0322bd03da45 100644 (file)
@@ -19,8 +19,8 @@
 #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
index 0cadd9d69f682af9fdd449b6948159ea7938a780..fc0a6d66e90e172b53d1ba1b5c7834c39ce9e25b 100644 (file)
@@ -259,8 +259,9 @@ friend class TDF_ChildIterator;
 friend class TDF_Attribute;
 friend class TDF_AttributeIterator;
 friend class TDF_Data;
-friend class TDF_LabelMapHasher;
 
+template<class T>
+friend struct std::hash;
 
 protected:
 
index befb84940b50fe3fd71fd047954abea4e8d27b3c..118ea23cb85900f5c3859f8ad3ff3ab88637dce1 100644 (file)
 #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)
 {}
index d428d85b651c2b4819e4c9edef7e69d72d4fa628..10462f131c7f675d8bba812dfc5f8694adb2acb5 100644 (file)
 #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
index 1c6213b3b7de0797de7fb7df8d664e8fc6edfd23..eed89a6a1c12d0af73a1da17ce517bb63f098aec 100644 (file)
 #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
index 8aba7f2dffd25e5c288f2b77fc4d5c752b80139d..53554bfc41ea3ed6424b57c4aa973fe894ae9e88 100644 (file)
 #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
index 2b16c742c70175455c0e0427b6af271c1a9c123e..a9f31c691ca233aaddcad8362ddb3345dfce3b79 100644 (file)
 
 #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
index cf928d1285e99033a62198270722c52e2adb66b7..aeb1ff73bb7bdeafea4d63e564e4cad413e90d07 100644 (file)
 #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
diff --git a/src/TDF/TDF_LabelMapHasher.hxx b/src/TDF/TDF_LabelMapHasher.hxx
deleted file mode 100644 (file)
index 9084d15..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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
index cca3c899b608177552e0f7a790f1cf0178799e0b..94575850f45d309dbc0e50196decb97f317227a2 100644 (file)
@@ -20,8 +20,8 @@
 #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
index ece7a882752cfc502dc1af6e57e7fa1d8037254c..522350d7f903df978aa32538652885a5e5e768d2 100644 (file)
@@ -21,8 +21,8 @@
 #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
index c6c702a5e1d793614892c59a481ab535c10686d4..d090a80383b452f0c3fbebc010d528904d955c5b 100644 (file)
@@ -21,8 +21,8 @@
 #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
index 942e20040c19581ca61ca1ee12a11a93fe6aeeaa..b6fccc40bc4c01ab1a9a569237429c4311aa6d65 100644 (file)
@@ -20,8 +20,8 @@
 #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
index 7738b8cc5fea0cb32a34ff680c31b32710125707..64b79d328518ccdab67a9e03cbb3816114349595 100644 (file)
@@ -20,8 +20,8 @@
 #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
index 4e0c752b31297882457a7ee1cb0fd52988cc62d1..3e025c7ebf049646f5abeb5bc687c0ed043b2dc0 100644 (file)
@@ -24,7 +24,6 @@
 #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;
index 1d3029a7fc119f337fefe6e8a3f5558edbcc6101..bbfa7c6411f4a0691b09b2f9c44b7e3cbcd02122 100644 (file)
 
 #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
index 44b0da4e420035def8cade3602ddee2f847ddc64..5ef65c958a979cb9c1d42f7d1de7b5812fa53945 100644 (file)
@@ -21,8 +21,8 @@
 #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
index c542ad488dd7b4a3f8e8ec60e1c35f68769b6149..3b5f6a921af1177ba6716634219e8943746b8afe 100644 (file)
 #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
index 6bc3969967f585b48ea938ba8af6ca0bfe997b52..81b674854362f8a8fae3fec3e754c297c8b47f84 100644 (file)
 
 #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
index 36aa6d0e573d65987428fb0696d8151de43d5415..f81ec9c88c87e4235b43676899ddce6d6afe6d52 100644 (file)
@@ -33,7 +33,6 @@ TNaming_Name.hxx
 TNaming_NamedShape.cxx
 TNaming_NamedShape.hxx
 TNaming_NamedShape.lxx
-TNaming_NamedShapeHasher.hxx
 TNaming_NameType.hxx
 TNaming_Naming.cxx
 TNaming_Naming.hxx
index 5f789a0ead9f8074325efe3392761d9317a8d05d..d969d0ce3bd6de18ea3e47d8e0f4203063f90543 100644 (file)
@@ -156,7 +156,7 @@ const TopTools_MapOfShape& TNaming_Localizer::SubShapes (const TopoDS_Shape&
 //  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)) {
@@ -201,7 +201,7 @@ const TopTools_IndexedDataMapOfShapeListOfShape& TNaming_Localizer::Ancestors
       //-----------------------
       // Ancetres existent.
       //-----------------------
-      TopTools_IndexedDataMapOfShapeListOfShape& Anc = itA.Value();
+      TopTools_IndexedDataMapOfShapeListOfShape& Anc = itA.ChangeValue();
 
       TopExp_Explorer exp(In,TS);
 #ifdef OCCT_DEBUG
index 490512b3e9f93e1ecc30c0dd197130b9d0b39c47..5f7ce92dc80f036907f5311102b28bb333b2ca3e 100644 (file)
 #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
diff --git a/src/TNaming/TNaming_NamedShapeHasher.hxx b/src/TNaming/TNaming_NamedShapeHasher.hxx
deleted file mode 100644 (file)
index 1c2dcc6..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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
index 7203231057699f36ecfe0310dcb34ff38b6cee01..f6f9f643e6fd63f99600b823357b3436ff283091 100755 (executable)
@@ -5,7 +5,6 @@ TObj_Assistant.cxx
 TObj_Assistant.hxx
 TObj_CheckModel.cxx
 TObj_CheckModel.hxx
-TObj_Common.hxx
 TObj_Container.hxx
 TObj_DeletingMode.hxx
 TObj_HiddenPartition.cxx
index 933ee7e5a96548232484c3bd7cf89cbf441b79de..096ae58ea0fdfe3c74d1be3e4a538612ea366959 100644 (file)
@@ -19,7 +19,6 @@
 #define TObj_Application_HeaderFile
 
 #include <TDocStd_Application.hxx>
-#include <TObj_Common.hxx>
 #include <Message_Gravity.hxx>
 #include <Message_Messenger.hxx>
 
index d4ad4136b640ec41eb68decd6bd1d55317d70bb6..b8565a2c2532579bc5fcc5c85ab78cde1ac4504b 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <TObj_Assistant.hxx>
 
-#include <TObj_Common.hxx>
 #include <TObj_Model.hxx>
 #include <TColStd_SequenceOfTransient.hxx>
 #include <TColStd_SequenceOfAsciiString.hxx>
index 702cc1c4ddc19c9403ff49690dc9ea548f6c17d2..b26bb7772fc2ac5c3d7eb984eee7ca2a6def5849 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef TObj_Assistant_HeaderFile
 #define TObj_Assistant_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <TColStd_SequenceOfTransient.hxx>
 #include <TColStd_IndexedMapOfTransient.hxx>
 
diff --git a/src/TObj/TObj_Common.hxx b/src/TObj/TObj_Common.hxx
deleted file mode 100644 (file)
index 3f6a057..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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
index 6deb360d768bdaf9f43c8c98dd1d5fcfbf9476a5..f87f293348b8cba7d9c5333673cbb346e529f06d 100644 (file)
@@ -23,7 +23,6 @@
 #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;
index 9807246962a2f966651965578dc9c1fb6eaf0ba6..2a54499227326c76f2d5b90d8db0f3caf915f0f4 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef TObj_Object_HeaderFile
 #define TObj_Object_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <TObj_DeletingMode.hxx>
 #include <TObj_SequenceOfObject.hxx>
 
@@ -30,6 +29,8 @@ class TObj_Persistence;
 class TObj_ObjectIterator;
 class TObj_TNameContainer;
 class TCollection_HExtendedString;
+class TCollection_HAsciiString;
+
 #include <TColStd_HArray1OfInteger.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 #include <TColStd_HArray1OfExtendedString.hxx>
index 129dfbfa2b0a39a4e93c1684937bc76078593013..4cbdf7fb16bf4a28fe86543b9b90be7c79b063dc 100644 (file)
@@ -18,7 +18,8 @@
 #ifndef TObj_ObjectIterator_HeaderFile
 #define TObj_ObjectIterator_HeaderFile
 
-#include <TObj_Common.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_DefineHandle.hxx>
 
 class TObj_Object;
 
index 49d0017b38bc27988b7d408c938fe1ff46ade032..f45c6d758ba19ecde7891c991398167e685c4912 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef TObj_TIntSparseArray_HeaderFile
 #define TObj_TIntSparseArray_HeaderFile
 
-#include <TObj_Common.hxx>
 
 #include <NCollection_SparseArray.hxx>
 #include <TDF_Label.hxx>
index 0ce7c8c7852feafef53693445fea76e15b0594d0..286f479007ee03a200b511622987872d16f2fea9 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef TObj_TObject_HeaderFile
 #define TObj_TObject_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <TObj_Object.hxx>
 
 #include <TDF_Attribute.hxx>
index cd1c32e5945f38ac367beafea8126d1e6f294318..abdf0e8516645b63fab0d21474c3c5384e084b63 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef TObj_TReference_HeaderFile
 #define TObj_TReference_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <TDF_Attribute.hxx>
 #include <TDF_Label.hxx>
 
index 341b6913ccacf3b6f21e698c65952763b87941d2..234411808d366d9e062a4bdee2a285f32af81d5b 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef TObj_TXYZ_HeaderFile
 #define TObj_TXYZ_HeaderFile
 
-#include <TObj_Common.hxx>
 
 #include <gp_XYZ.hxx>
 #include <TDF_Attribute.hxx>
index faea7db1b5eda6d87d6a30efa40724b2c5c6117a..13e4833fd585763eaae6b49d98ad93e96d78c37b 100644 (file)
@@ -21,8 +21,8 @@
 #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
index febf3afb81bf8b2ea3059206280bc1682468f547..3df6b5b0af1e9617cb53940440d2acc13ff5836c 100644 (file)
@@ -7,7 +7,6 @@ TopLoc_Location.cxx
 TopLoc_Location.hxx
 TopLoc_Location.lxx
 TopLoc_MapIteratorOfMapOfLocation.hxx
-TopLoc_MapLocationHasher.hxx
 TopLoc_MapOfLocation.hxx
 TopLoc_SListNodeOfItemLocation.cxx
 TopLoc_SListNodeOfItemLocation.hxx
index 44c10c32395f6f1b286869eb39094c3869c314e4..b604ad092350b96619c9f7b51a701a75a5230e5a 100644 (file)
 #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
index 7949e4708c9bbb4e91587b55542af68a4dc31037..29ec3bee28803e9bb05c0d9e5fb1ea9b32dcb109 100644 (file)
@@ -23,8 +23,6 @@
 #include <TopLoc_Location.hxx>
 #include <TopLoc_SListOfItemLocation.hxx>
 
-static const gp_Trsf TheIdentity;
-
 //=======================================================================
 //function : TopLoc_Location
 //purpose  : constructor Identity
@@ -51,7 +49,7 @@ TopLoc_Location::TopLoc_Location (const Handle(TopLoc_Datum3D)& D)
 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));
 }
 
 //=======================================================================
@@ -61,8 +59,9 @@ TopLoc_Location::TopLoc_Location(const gp_Trsf& T)
 
 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;
 }
@@ -166,39 +165,6 @@ TopLoc_Location TopLoc_Location::Powered (const Standard_Integer pwr) const
   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 ==
index 7bab1f9630549e894a2fccfcf5ed9e0acc0667f6..8cb2c4a9d06981442c171638637efd081c780073 100644 (file)
@@ -114,10 +114,9 @@ Standard_NODISCARD TopLoc_Location operator/ (const TopLoc_Location& Other) cons
   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
@@ -172,23 +171,6 @@ private:
 
 };
 
-
 #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
index 894a8e96f4704d31bddb30f1322135d44ead328f..f228dea0243a54140e9c7ee7363482a2259fdfd2 100644 (file)
@@ -15,6 +15,7 @@
 // commercial license or contractual agreement.
 
 #include <TopLoc_SListOfItemLocation.hxx>
+#include <TopLoc_Datum3D.hxx>
 #include <TopLoc_ItemLocation.hxx>
 
 //=======================================================================
@@ -68,4 +69,48 @@ inline const Handle(TopLoc_Datum3D)&  TopLoc_Location::FirstDatum()const
   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();
+    }
+  };
+}
diff --git a/src/TopLoc/TopLoc_MapLocationHasher.hxx b/src/TopLoc/TopLoc_MapLocationHasher.hxx
deleted file mode 100644 (file)
index f751a67..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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
index 9d9873b8b0f1523fc7aafaa747f6acaea94c7863..38f4b9b7c73f35e24f49c08e5893602afde9f24a 100644 (file)
 #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
index 6d04335a6e85225a42a82033907314ff91536479..56732fa7b33a1d6aaa3b221286fd77e0f5caa8c3 100644 (file)
@@ -118,7 +118,7 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder
 
         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);
@@ -127,7 +127,7 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder
        } // 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 ) {
@@ -150,7 +150,7 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder
       
       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);
@@ -159,7 +159,7 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder
       } // 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);
@@ -175,7 +175,7 @@ void TopOpeBRepBuild_Area1dBuilder::InitAreaBuilder
 
            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();
index ebdb57325b77fea71d2ca1e457ef81eeafbc829d..ee701ef6e0ecd39b4d793f9d4d3c74589ac31ad3 100644 (file)
@@ -24,7 +24,6 @@
 #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;
index 6cd9cef09e538da8cbbf0364bfe1fa861d8e21e0..f44a6fe83108d5ed183fdcf4c2716baa91aadf13 100644 (file)
@@ -85,7 +85,7 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder
 
       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);
@@ -94,7 +94,7 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder
       } // 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 ) {
@@ -117,7 +117,7 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder
       
       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);
@@ -126,7 +126,7 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder
       } // 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);
@@ -142,7 +142,7 @@ void TopOpeBRepBuild_Area2dBuilder::InitAreaBuilder
            
            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();
index 3d13659941afc94cc6604fe29e613cb706f71edc..fbcd3bac78a7935dadb3e53df647a9eec38f059d 100644 (file)
@@ -80,7 +80,7 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder
 
       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);
@@ -89,7 +89,7 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder
       } // 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 ) {
@@ -112,7 +112,7 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder
       
       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);
@@ -121,7 +121,7 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder
       } // 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);
@@ -138,7 +138,7 @@ void TopOpeBRepBuild_Area3dBuilder::InitAreaBuilder
            
            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();
index ff352553c047dc7ef608c7c5975bf747f96e93c5..0340722828e10d3066ce1220c733dabf39cd3380 100644 (file)
@@ -154,7 +154,7 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder
 
       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);
@@ -163,7 +163,7 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder
       } // 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 ) {
@@ -186,7 +186,7 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder
       
       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);
@@ -195,7 +195,7 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder
       } // 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);
@@ -211,7 +211,7 @@ void TopOpeBRepBuild_AreaBuilder::InitAreaBuilder
            
            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();
index b57c66b30e93f7f9944598496395c765e76d4edb..61f239f2de834e87b18f0b69407318f5b7e7b03d 100644 (file)
@@ -28,7 +28,6 @@
 #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;
index 5bdb16126495ed3eb3f9c4101f0cf24b806fefde..a0dbf89c820c76855e5d52371c6d8ce18aa44ce4 100644 (file)
@@ -71,7 +71,7 @@ void TopOpeBRepBuild_Builder::BuildEdges(const Standard_Integer iC,const Handle(
   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);
   }
@@ -80,7 +80,7 @@ void TopOpeBRepBuild_Builder::BuildEdges(const Standard_Integer iC,const Handle(
   }
   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);
     }
   }
index 4125bdbb154ab65a28f791ecc568906ade21b2cc..5a8fa32eb47d67663ed97a6632e22a11f3ee0a37 100644 (file)
@@ -669,7 +669,7 @@ Standard_Boolean TopOpeBRepBuild_Builder::IsShapeOf(const TopoDS_Shape& s,const
 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;
   }
index 43e21a2228b3b2231b6187b76e11315ea21c4509..5b0efdb3799c1e241941f83a71cda01fdd9d77d1 100644 (file)
@@ -46,7 +46,6 @@
 #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;
index 20d732fbd20c4be004ad17c0c910818cb449b8a1..7e9ab79f5d1eaf0796e79dd74463035903691fee 100644 (file)
@@ -181,7 +181,7 @@ void TopOpeBRepBuild_Builder1::MergeKPart()
    
     TopTools_ListIteratorOfListOfShape its(Merged(myShape1,myState1));
     for (; its.More(); its.Next()) {
-      CorrectResult2d(its.Value());
+      CorrectResult2d(its.ChangeValue());
     }
   }
     
@@ -1369,7 +1369,7 @@ Standard_Integer TopOpeBRepBuild_Builder1::PerformPieceOn2D (const TopoDS_Shape&
            // 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;
index 344f90aea5c838a7c642e197cb64e3d834cd81d6..48c8e310f40b748f0f0ceccdbbab66d57c6332b3 100644 (file)
@@ -132,7 +132,7 @@ private:
   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;
index cbf0d031c87179dd2d81bb90ce69056dd92df14c..9ee30b050a1ff5b84b27f4e9af80f5aaf371ee68 100644 (file)
@@ -21,7 +21,6 @@
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
 
-#include <Standard_Address.hxx>
 #include <TopOpeBRepBuild_LoopClassifier.hxx>
 #include <TopAbs_State.hxx>
 class TopOpeBRepBuild_BlockBuilder;
index 4f3534007e8d29579b21439900f88f72153f18c4..214c934f400ac347c28f50dea46cd4640624332c 100644 (file)
@@ -25,7 +25,6 @@
 #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;
index 871ef9b26142ac267077f6b46e45b37be7ad05c3..4d85cce540e8d38f197f135902a9d527e2f513bb 100644 (file)
@@ -258,7 +258,7 @@ void TopOpeBRepBuild_Builder::End()
 //    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
index 7112add40f2982dc4c4abbe24ea5f403c6f5f2a7..2e012b6ae6f3b0352776ca1c800397e351736387 100644 (file)
@@ -474,7 +474,7 @@ static Standard_Boolean FUN_validF1edge(const TopoDS_Shape& F)
 
   // 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()) {
index 59250b94fb96a599dfb91daf82ede61205201620..d95807c9d55bef9d133a9c57d7dc0a4a6ddbb84c 100644 (file)
@@ -620,7 +620,7 @@ Standard_EXPORT void FUNBUILD_ORIENTLOFS(TopOpeBRepBuild_Builder& B,
                                          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);
index a5b37062a2111d5af464dca39b297cf915bc7021..bb2c046bd803f2b7b77bcc9271b245c67e6f5091 100644 (file)
@@ -353,13 +353,13 @@ void TopOpeBRepBuild_HBuilder::MakeEdgeAncestorMap()
     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);
       }
index 020074919f7176801671250ed22c6014e78d8b97..f37edb72b264ab8bd096db91027039956a3039a8 100644 (file)
@@ -506,7 +506,7 @@ void TopOpeBRepBuild_Builder::SplitSectionEdges()
       }
       
       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
index c4af95cdb6408b45e2fd69a80f845268c2be288d..00a7618fa4ac5b44fb33ce465c1dd0b1fc3f3aa3 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <TopoDS_Solid.hxx>
 #include <TopOpeBRepBuild_ShapeSet.hxx>
-#include <Standard_Address.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TopTools_ListOfShape.hxx>
 class TopoDS_Shape;
index 0302e68634c33928673f34bc8c5c10400823c00e..1f48dcfef7244c309b83fc02aaaa15bd0ffb02f6 100644 (file)
@@ -119,7 +119,7 @@ Standard_Boolean TopOpeBRepDS_Check::ChkIntgInterf
   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();
@@ -375,7 +375,7 @@ Standard_Boolean CheckEdgeParameter(const Handle(TopOpeBRepDS_HDataStructure)& m
     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()) {
@@ -425,11 +425,11 @@ Standard_OStream& TopOpeBRepDS_Check::PrintIntg(Standard_OStream& OS)
   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()) {
@@ -485,12 +485,13 @@ Standard_OStream& TopOpeBRepDS_Check::PrintElts(TopOpeBRepDS_DataMapOfCheckStatu
                                                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) {
index 49b58f388b2b140ae97cf008c3a23c991744993e..51cddc616e53b04e58824b5dfdda602abeccfa0a 100644 (file)
 
 #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
index 227b4c883989d7f380577daac083e376a7e070b7..ca0af039ea830108ccd74a4837547bd3bcfd285a 100644 (file)
 
 #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
index 3a504ee62d70a8c3d931609f375d60669ff6541d..964e3cd54371d89769a52f5d9aea4510299f7997 100644 (file)
 #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
index 721ed280bda81f977d0655842ee25e59ee223950..0e958f9d0f0074cc8e7cbea996a152e39400a63f 100644 (file)
 
 #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
index 559a973f6f70eda49db9ca1aa7292499b25cf9ba..e45bb5508840db4623472cf9e14665970bbae824 100644 (file)
 #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
index 278bd8723cba964562e84dcbcd50261bc8629f2e..4e66fa56a8a40346428b94705158dfa1969b9c34 100644 (file)
@@ -54,7 +54,7 @@ static void FDS_reduceONFACEinterferences(TopOpeBRepDS_ListOfInterference& LI,
   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);
@@ -66,7 +66,7 @@ static void FDS_reduceONFACEinterferences(TopOpeBRepDS_ListOfInterference& LI,
     // 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);
index cb67638f1c507a73aa873aab166cba54e34783a0..c36ce2dc2cbd780be6a19e5ceea93470e40508d8 100644 (file)
@@ -1718,7 +1718,7 @@ Standard_EXPORT void FUN_ds_completeforSE8(const Handle(TopOpeBRepDS_HDataStruct
       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);
index f3e7f76686b636733cf05b16cddb1822c241db41..0e578f4959fd8408c52ab44d6bb0b5121d0f853c 100644 (file)
@@ -39,7 +39,7 @@ Standard_Boolean FUN_isPonF(const TopOpeBRepDS_ListOfInterference& LIF,const gp_
 
   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;
@@ -70,7 +70,7 @@ Standard_Boolean FUN_findPonF(const TopoDS_Edge& E,const TopOpeBRepDS_DataStruct
   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()) {
@@ -216,7 +216,7 @@ void FUN_GmapS(TopOpeBRepDS_ListOfInterference& LI, const TopOpeBRepDS_DataStruc
   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;
index 1206864a9c5f80979ce9e84c0790330db452eb69..ad1799c73fe8b6f969232ea35e1f14644dc168e1 100644 (file)
 
 #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
index 6dd5be6afda29b54b6beb01621901f9de59bd6d8..92a4c038aec1baee0663bed6a4f2f57d06cbbb4c 100644 (file)
 #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
index 939735ed4f9c333aa377e3c6917d973e76a3ca78..cf768bae5bfa5c9e58a8060090214016e824d4da 100644 (file)
 
 #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
index aa7404a33da7f48abcda737990b9a8240022f963..a73c04045bb208e8ccfa0caf96ffbb9821201042 100644 (file)
 
 #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
index e1b9ae3086a5471779dfd60ef35c40732ec843aa..90a735722d41b0d9c58c7e5cdde998cc10bc6bef 100644 (file)
@@ -23,7 +23,6 @@
 #include <TColStd_HArray1OfBoolean.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Transient.hxx>
-#include <Standard_Address.hxx>
 
 
 class TopOpeBRepDS_Marker;
index c217ab605d2b5bb9893c52332c5defed6df8c4c9..5190c9f175b3d267881795f7f0538cd434145192 100644 (file)
@@ -125,7 +125,7 @@ Standard_EXPORT Standard_Integer FUN_unkeepEinterferences
   
   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);
@@ -234,7 +234,7 @@ Standard_EXPORT void FUN_unkeepEsymetrictransitions
   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();
@@ -304,7 +304,7 @@ Standard_EXPORT void FUN_orderFFsamedomain
   
   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();
@@ -346,7 +346,7 @@ Standard_EXPORT void FUN_orderSTATETRANSonG
   
   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();
@@ -404,7 +404,7 @@ Standard_EXPORT void FUN_resolveEUNKNOWN
   // 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;
index c4011210c74adc512bbc8c58e83540f4a652ecfa..06f4565127e9f4e497e67c761fa3babc0d6f849b 100644 (file)
@@ -152,7 +152,7 @@ Standard_EXPORT void FUN_unkeepFdoubleGBoundinterferences
   
   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();
@@ -217,7 +217,7 @@ Standard_EXPORT void FUN_resolveFUNKNOWN
   // 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;
index 068670c4a981fe01cfb85c6e069002b45e229dce..b01351798b9e118a2f5e1b260231bffe748fbaa2 100644 (file)
@@ -329,7 +329,7 @@ Standard_EXPORT void FUN_reducedoublons
   // 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;
@@ -403,7 +403,7 @@ Standard_EXPORT void FUN_unkeepUNKNOWN
   
   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();
 
@@ -541,7 +541,7 @@ static Standard_Boolean FUN_find3dISEsameISF(const Handle(TopOpeBRepDS_Interfere
   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);
index 166bd70ebcabd1aee58364f5dd9b25b6bff3a98b..bda4096b0a4341e8b6514a2a70f012ddcc449738 100644 (file)
 
 #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
index 9b9b8a202d901c8da80f883d0f0a625fd9016c95..fef60f4ae2f0f72372268e292345e1d1fa635da6 100644 (file)
@@ -904,7 +904,7 @@ Standard_Boolean TopOpeBRepTool_FuseEdges::UpdatePCurve(const TopoDS_Edge& theOl
            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);
index bb6417f5b9eb27af794a7f2bef0233e194f6ed3b..7570e991add6dd27994c63d6da0ef534a4ef4194 100644 (file)
 
 #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
index 1fc2e23f991b3d68779a7957062e449304ae588a..d03a486f8f2e5cec199630726f92883c287ea901 100644 (file)
 
 #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
index 747e21c1fdde1658a75d850a191e43e23c63a936..cc01db47cc4dc428db9c3d1480b6af473c18f8b6 100644 (file)
@@ -47,10 +47,7 @@ TopTools_MapOfOrientedShape.hxx
 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
index 5813ef773f3f8b3e05467dcc0ee1de086af17d26..4c57ef42dbf7d1ce194c7bb2fe4a5e5daff05031 100644 (file)
 
 #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
index d6503c6df41fa04725b2c37d295e095172c21098..666312ac8f9a9bb68c62a5b5386e18ee541a7ebc 100644 (file)
 
 #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
index ff7325c2078bf2828987facd3c82509df8d2031e..0220b044f0aaab75d14c374edfe89999d9f65e64 100644 (file)
 
 #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
index 7ac0f777bd9040936b07ca9ee621041300cb34a0..dfd145d005eb52a14b90f29c423f411315c74a08 100644 (file)
 #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
index bbe20a935f613b78c017f37c587362f235e4f342..570a6b190bb96366c090a8df8d39b0f032e21fd6 100644 (file)
@@ -18,7 +18,6 @@
 #define TopTools_IndexedDataMapOfShapeAddress_HeaderFile
 
 #include <TopoDS_Shape.hxx>
-#include <Standard_Address.hxx>
 #include <TopTools_ShapeMapHasher.hxx>
 #include <NCollection_IndexedDataMap.hxx>
 
index bd5ea4c3e5575f080f0f5b412468fd4d37e46c5f..ff3974f35e3e07e553b91fa83e82f6585687b33b 100644 (file)
 #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
index 44071c9672fa76bfd11584fbd3df58a6649bda61..b8987c9f2ea6297fb7929cdb49f25a23d3ad7546 100644 (file)
 #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
diff --git a/src/TopTools/TopTools_OrientedShapeMapHasher.hxx b/src/TopTools/TopTools_OrientedShapeMapHasher.hxx
deleted file mode 100644 (file)
index e4dfca9..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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
diff --git a/src/TopTools/TopTools_OrientedShapeMapHasher.lxx b/src/TopTools/TopTools_OrientedShapeMapHasher.lxx
deleted file mode 100644 (file)
index 6fb4710..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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);
-}
index ba47758975bd08100664125a962637a09da36be7..7899e32a315364d58c5c6d4635f310dcf81eae11 100644 (file)
 #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
diff --git a/src/TopTools/TopTools_ShapeMapHasher.lxx b/src/TopTools/TopTools_ShapeMapHasher.lxx
deleted file mode 100644 (file)
index a3789d0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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);
-}
index 1fd91a9eea9c58eca8f95ba47c44a6ba9347c5c3..cc0d9a6ae4aaac571460b970392537de833099ee 100644 (file)
@@ -6,13 +6,9 @@ TopoDS_Builder.cxx
 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
@@ -25,9 +21,7 @@ TopoDS_LockedShape.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
@@ -56,8 +50,6 @@ TopoDS_TWire.hxx
 TopoDS_TWire.lxx
 TopoDS_UnCompatibleShapes.hxx
 TopoDS_Vertex.hxx
-TopoDS_Vertex.lxx
 TopoDS_Wire.hxx
-TopoDS_Wire.lxx
 TopoDS_AlertWithShape.cxx
 TopoDS_AlertWithShape.hxx
index e042fdaffbb22f198791147f576b3d8602b4b8e9..92a7a728a07006149284e4d1535295429d83d710 100644 (file)
 #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
@@ -38,32 +34,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_CompSolid.lxx b/src/TopoDS/TopoDS_CompSolid.lxx
deleted file mode 100644 (file)
index e4d4a88..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index 639ddd731162e62157a757dfc3463bc0f9b11a51..3aa0148a366c6006bb622cfe7138a30f4af48813 100644 (file)
 #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
@@ -38,32 +34,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Compound.lxx b/src/TopoDS/TopoDS_Compound.lxx
deleted file mode 100644 (file)
index 687ded5..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index 934dbd141bec47d4cd26a7ffcb2a90829d8adc87..0454c01f4c6129eb4b017026e19444d7ec551f7c 100644 (file)
 #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
@@ -37,32 +33,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Edge.lxx b/src/TopoDS/TopoDS_Edge.lxx
deleted file mode 100644 (file)
index 2453028..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index 6ed9083c5308229f7b8d6da77dfc7043d4053e25..127284c42455771c0e51fe0e997a2e92dbe2b32f 100644 (file)
 #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
@@ -36,32 +32,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Face.lxx b/src/TopoDS/TopoDS_Face.lxx
deleted file mode 100644 (file)
index ed77a8e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index c78121649b8818b1ca8e64f5856fe257214c56fb..deda205a8bedd5d2b7280adc412a7dbcface8e0f 100644 (file)
 #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  : 
index 12b5918cc75b5a3734ebb68ad00271bda95a39a3..4933134650bf7b67d649904b7e9fafd0f2b10706 100644 (file)
@@ -20,6 +20,7 @@
 #include <Standard_Handle.hxx>
 #include <TopLoc_Location.hxx>
 #include <TopoDS_TShape.hxx>
+#include <Standard_HashUtils.hxx>
 
 // resolve name collisions with X11 headers
 #ifdef Convex
@@ -279,12 +280,6 @@ public:
   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.
@@ -313,13 +308,18 @@ private:
 
 };
 
-//! 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
index a422f2c355f4770ff38d6e75160b464d949c0903..e6d443973f61b7c56400554bfeb57699946dd113 100644 (file)
 #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
@@ -36,32 +32,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Shell.lxx b/src/TopoDS/TopoDS_Shell.lxx
deleted file mode 100644 (file)
index f357a45..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index c21397c448e7eb6d5a36be8932747a3b7f9ca733..3ddc46bc2ffa4aa8f82858d3d1cda448c8479594 100644 (file)
 #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
@@ -37,32 +33,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Solid.lxx b/src/TopoDS/TopoDS_Solid.lxx
deleted file mode 100644 (file)
index cf2e324..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index fdc778db02992029d094e29caae3a1203ec40579..361990ec1aee9a228ebb22d249990cb3c2ffdbdb 100644 (file)
 #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
@@ -37,32 +33,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Vertex.lxx b/src/TopoDS/TopoDS_Vertex.lxx
deleted file mode 100644 (file)
index b7c1cee..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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()
-{
-}
index 73c973822e7c8d52fbeea9ee592c06848a5636b6..a2d2c3667a0e6551487e0e791ab3dea6be076ff5 100644 (file)
 #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
@@ -36,32 +32,20 @@ public:
 
   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
diff --git a/src/TopoDS/TopoDS_Wire.lxx b/src/TopoDS/TopoDS_Wire.lxx
deleted file mode 100644 (file)
index 485597d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 ()
-{
-}
index 2fff748cd38d5c77d354842f9ee773056e74dde2..8f8f66a948b479497788f92f19be1babe171e841 100644 (file)
@@ -1,4 +1,3 @@
-Transfer_Actor.gxx
 Transfer_ActorDispatch.cxx
 Transfer_ActorDispatch.hxx
 Transfer_ActorOfFinderProcess.cxx
@@ -21,18 +20,15 @@ Transfer_Finder.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
@@ -61,7 +57,6 @@ Transfer_TransferMapOfProcessForFinder.hxx
 Transfer_TransferMapOfProcessForTransient.hxx
 Transfer_TransferOutput.cxx
 Transfer_TransferOutput.hxx
-Transfer_TransferProcess.gxx
 Transfer_TransientListBinder.cxx
 Transfer_TransientListBinder.hxx
 Transfer_TransientMapper.hxx
diff --git a/src/Transfer/Transfer_Actor.gxx b/src/Transfer/Transfer_Actor.gxx
deleted file mode 100644 (file)
index 8d08e7e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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;  }
index 74f6e4285dd7ade5a4fb9ced3e208b027bb48d1e..e9140b1d8034feb95effe3ab43e6ba97dedb1e4f 100644 (file)
 
 #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;
+}
index d69b1f1bfa40379edd96bb9d41fa91df33d48840..5c476b7a059a08aec021ecccd1d476294e1dab60 100644 (file)
 
 #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;
+}
 
diff --git a/src/Transfer/Transfer_FindHasher.cxx b/src/Transfer/Transfer_FindHasher.cxx
deleted file mode 100644 (file)
index 1bcf614..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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);
-}
index f217c3180d0418263bad637dfc254e3eb93e8919..e210c1e9bea94586744d09dffa1ca4cb305cff94 100644 (file)
 
 #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
index 1fba56d936f1110e0ff191d57669a23bca834565..515da7c968193019dfe1cd54b77541e0dbf68cbb 100644 (file)
 
 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
index 5ced95799e5cb011dec6c193dcfe914ae098ee6f..8fc07fade44c3d174ebf0dd2bf85229918fc94e4 100644 (file)
@@ -45,7 +45,7 @@ public:
   //! 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
@@ -151,14 +151,14 @@ protected:
   
   //! 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;
 
 
diff --git a/src/Transfer/Transfer_Iterator.gxx b/src/Transfer/Transfer_Iterator.gxx
deleted file mode 100644 (file)
index 04c8d1b..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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);
-}
index a985812876a7c65a74dc2ac43905823cc60029ec..24abf1ffcc87f03f7d41e7a148733ce84ed67328 100644 (file)
 #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);
+}
 
index 49332227d93172e0e7a7c834a7a1993be3325c2d..67c4a5d25d6c82fd06e190eb5af3e10d5d838662 100644 (file)
 #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);
+}
diff --git a/src/Transfer/Transfer_Mapper.gxx b/src/Transfer/Transfer_Mapper.gxx
deleted file mode 100644 (file)
index f446f0e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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);  }
index 12e7a379c63cac6c0a3c19215d0ba5ca515e2842..0cc4e32e88085da95046f27a405db1a6678366e0 100644 (file)
 
 #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;
+}
index 9b3049527dd71ac7617f147bf6268875a4a82d8e..4611b276424a87a71227a32cce267d424cd92a97 100644 (file)
 
 #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>
 
index 94128b57ccc229db675c50cf5b487a0b375a44fe..4d26530b609d49da8a359a89b40b1fc5d9fd1daf 100644 (file)
@@ -18,9 +18,8 @@
 #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
diff --git a/src/Transfer/Transfer_TransferProcess.gxx b/src/Transfer/Transfer_TransferProcess.gxx
deleted file mode 100644 (file)
index 80ce908..0000000
+++ /dev/null
@@ -1,1556 +0,0 @@
-// 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;
-}
-
index 0910523fc5b16fa7c2e9cee195036f2a419cb081..acd99d2b7a5c558355af9430244928278af36fd9 100644 (file)
@@ -21,7 +21,6 @@
 #include <Standard_Type.hxx>
 
 #include <Transfer_Finder.hxx>
-#include <TColStd_MapTransientHasher.hxx>
 class Standard_Transient;
 class Transfer_DataInfo;
 class Transfer_Finder;
index c323d31bd0161ef8d830575b60d1fc57383575ef..6b0f6436f89bb72489109d57d01c21af3171d835 100644 (file)
 #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);
+}
index 039db07c1dd2f2ff29bebff40e8465a319ead8f8..9a470b5a4fca22cd391f70df78d6ffcab6cf4ff0 100644 (file)
@@ -3,8 +3,6 @@ TransferBRep.hxx
 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
diff --git a/src/TransferBRep/TransferBRep_OrientedShapeMapper.hxx b/src/TransferBRep/TransferBRep_OrientedShapeMapper.hxx
deleted file mode 100644 (file)
index 03f5b22..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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
diff --git a/src/TransferBRep/TransferBRep_OrientedShapeMapper_0.cxx b/src/TransferBRep/TransferBRep_OrientedShapeMapper_0.cxx
deleted file mode 100644 (file)
index 84cb6c2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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>
-
index a7e4c0060914724bfda91900c565bc09523fb39b..2174ee8fde7c65b98a96cbd3196079cfa8c7a9bc 100644 (file)
 #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);
+}
index 8497cfc596b0c398cb940ddf8c79c1d3692c3330..7658ea79842fcff2bbafee0c277ebbb36d22cf72 100644 (file)
@@ -3801,7 +3801,7 @@ void V3d_View::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth
   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)
index 44522f932bb4c5665c08f314968cedcd31af4212..d04acedc47fcccb82641b33befdebe53cb24df61 100644 (file)
 
 #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
index 83a3fbabc791b883bd38016693a24268e76af81f..2124453e2096b66a108a5452a266b8946bf4c329 100644 (file)
@@ -153,26 +153,33 @@ static TCollection_AsciiString getModuleCanvasId()
 }
 #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
 {
@@ -184,10 +191,10 @@ 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);
     }
   }
@@ -195,10 +202,10 @@ static struct
   //! 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);
     }
   }
@@ -404,10 +411,10 @@ Handle(AIS_InteractiveContext) FindContextByView (const Handle(V3d_View)& theVie
 {
   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;
@@ -424,14 +431,14 @@ Standard_Boolean IsWindowOverlapped (const Standard_Integer thePxLeft,
                                      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) ||
@@ -653,10 +660,10 @@ TCollection_AsciiString ViewerTest::ViewerInit (const ViewerTest_VinitParams& th
   // 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()))
@@ -805,7 +812,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const ViewerTest_VinitParams& th
 //==============================================================================
 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();
@@ -1455,10 +1462,10 @@ static int VHLRType (Draw_Interpretor& , Standard_Integer argc, const char** arg
 #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();
   }
@@ -1572,12 +1579,12 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
   {
     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;
         }
       }
@@ -1594,7 +1601,8 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
     }
   }
 
-  // Delete view
+  // Delete view, name will be removed too
+  const TCollection_AsciiString aCopyString(theViewName);
   ViewerTest_myViews.UnBind1(theViewName);
   if (!aView->Window().IsNull())
   {
@@ -1616,11 +1624,11 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
     {
       // 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;
@@ -1639,7 +1647,7 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
       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");
@@ -1663,7 +1671,7 @@ static int VClose (Draw_Interpretor& /*theDi*/,
     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());
@@ -1808,13 +1816,13 @@ static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const
     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)
@@ -1825,7 +1833,7 @@ static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const
           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)
@@ -1833,7 +1841,7 @@ static int VViewList (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const
             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";
@@ -2370,7 +2378,7 @@ static void VProcessEvents (ClientData theDispX, int)
 {
   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();
@@ -8277,7 +8285,7 @@ namespace
       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();
@@ -12755,10 +12763,10 @@ static int VManipulator (Draw_Interpretor& theDi,
   }
   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);
   }
index d4a85824aaa193a16368751cc7d344e7701191ed..31a48c21514c526ca01b94fd2304ac6272a4fb46 100644 (file)
@@ -48,15 +48,6 @@ Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
   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  : 
index fed5337283ebb51dae6f7726c21f8892a3d05136..695633d04ce64b698c76ab3d030dd2b09b8b9aab 100644 (file)
@@ -19,7 +19,8 @@
 #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) \
@@ -198,13 +199,34 @@ class VrmlData_Node : public Standard_Transient
 // 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
index 55808add07253de6fc3d8e8efe309329e04856bf..e7d1e4d6c82dca90e45beee3fee1164e244965a9 100644 (file)
@@ -22,9 +22,9 @@
 #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.
index 0a8fe8a6d7689e5017031046d798f5c947c93dd1..af71e9449d23b9a55ad2da60fb7ddcbd14cff519 100644 (file)
@@ -19,8 +19,7 @@
 #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
index 2d30806f021d15e3adde8060ac87ffc1d7a7a3c4..ef3036ea60d3809fd507698033954cf9938b0fcf 100644 (file)
@@ -80,25 +80,10 @@ public:
   //! 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:
 
@@ -106,4 +91,17 @@ 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
index b396f408dde7038e848eb72306283f648ecf8efb..4ad3778ed6f263461991f54531dbaaa112cdaa87 100644 (file)
@@ -965,7 +965,7 @@ const Standard_GUID& XCAFDoc_DimTolTool::ID() const
 //purpose  : 
 //=======================================================================
 void XCAFDoc_DimTolTool::GetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, 
-  TopoDS_Shape, TDF_LabelMapHasher>& theGDTLabelToShape) const
+  TopoDS_Shape>& theGDTLabelToShape) const
 {
   TDF_LabelSequence aGDTs;
   GetDimensionLabels(aGDTs);
@@ -1017,7 +1017,7 @@ void XCAFDoc_DimTolTool::GetGDTPresentations(NCollection_IndexedDataMap<TDF_Labe
 //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++)
   {    
index 78380f08532fe20f747aaca513a2e81bedc44bb4..ea4b34436f50dbde7f2b89700b1bd5395e43fbf8 100644 (file)
@@ -26,7 +26,6 @@
 #include <TColStd_HArray1OfReal.hxx>
 #include <TopoDS_Shape.hxx>
 #include <NCollection_IndexedDataMap.hxx>
-#include <TDF_LabelMapHasher.hxx>
 
 class XCAFDoc_ShapeTool;
 class TDF_Label;
@@ -237,12 +236,12 @@ public:
   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;
index e8906659882d9c9e247583153eae7c277c3f9b3d..1e05ac79f4637e244baf283b8dcb45c33e8d69ea 100644 (file)
@@ -138,7 +138,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
 
   // collect sub-shapes with the same style into compounds
   BRep_Builder aBuilder;
-  NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style> aStyleGroups;
+  NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound> aStyleGroups;
   for (XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle aStyledShapeIter (aSettings);
        aStyledShapeIter.More(); aStyledShapeIter.Next())
   {
@@ -160,7 +160,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
   aSettings.Clear();
 
   // assign custom aspects
-  for (NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style>::Iterator aStyleGroupIter (aStyleGroups);
+  for (NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound>::Iterator aStyleGroupIter (aStyleGroups);
        aStyleGroupIter.More(); aStyleGroupIter.Next())
   {
     const TopoDS_Compound& aComp = aStyleGroupIter.Value();
index 7576a7985a76ebc22b43e2bfb94c3b091593e7af..ceecaa7b23d81c507b35160ecfd63043f6b7678d 100644 (file)
@@ -20,8 +20,8 @@
 #include <XCAFPrs_Style.hxx>
 #include <NCollection_DataMap.hxx>
 
-typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape,XCAFPrs_Style> XCAFPrs_DataMapOfStyleShape;
-typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape,XCAFPrs_Style>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleShape;
+typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape> XCAFPrs_DataMapOfStyleShape;
+typedef NCollection_DataMap<XCAFPrs_Style,TopoDS_Shape>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleShape;
 
 
 #endif
index 6520c85f42376bfed5fddca65756e873f9825eb9..b901e619b0fd26a4aed79d84cd4ba88b3661cde3 100644 (file)
@@ -20,8 +20,8 @@
 #include <Standard_Transient.hxx>
 #include <NCollection_DataMap.hxx>
 
-typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient),XCAFPrs_Style> XCAFPrs_DataMapOfStyleTransient;
-typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient),XCAFPrs_Style>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleTransient;
+typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient)> XCAFPrs_DataMapOfStyleTransient;
+typedef NCollection_DataMap<XCAFPrs_Style,Handle(Standard_Transient)>::Iterator XCAFPrs_DataMapIteratorOfDataMapOfStyleTransient;
 
 
 #endif
index 68bf1dfe1567ea9e36627344be3f9998851f63bb..b8789e031e93fe1db46ffb20ea022549e8b73a84 100644 (file)
@@ -37,20 +37,22 @@ struct XCAFPrs_DocumentNode
 
 public: // Methods for hash map
 
-  //! Return hash code based on node string identifier.
-  static Standard_Integer HashCode (const XCAFPrs_DocumentNode& theNode,
-                                    const Standard_Integer theN)
+  bool operator==(const XCAFPrs_DocumentNode& theOther) const
   {
-    return ::HashCode (theNode.Id, theN);
+    return Id == theOther.Id;
   }
+};
 
-  //! Return TRUE if two document nodes has the same string identifier.
-  static Standard_Boolean IsEqual (const XCAFPrs_DocumentNode& theNode1,
-                                   const XCAFPrs_DocumentNode& theNode2)
+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
index 22c96645480fe988fda62bcac616c04d5d64cc6f..ac3f8e549eacefe99bab10771c4e1daa711d0b9b 100644 (file)
@@ -19,8 +19,8 @@
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
-#include <Quantity_ColorRGBAHasher.hxx>
 #include <XCAFDoc_VisMaterial.hxx>
+#include <Standard_HashUtils.hxx>
 
 //! Represents a set of styling settings applicable to a (sub)shape
 class XCAFPrs_Style 
@@ -130,38 +130,8 @@ public:
     return IsEqual (theOther);
   }
 
-  //! Computes a hash code for the given set of styling settings, in the range [1, theUpperBound]
-  //! @param theStyle the set of styling settings which hash code is to be computed
-  //! @param theUpperBound the upper bound of the range a computing hash code must be within
-  //! @return a computed hash code, in the range [1, theUpperBound]
-  static Standard_Integer HashCode (const XCAFPrs_Style& theStyle, const Standard_Integer theUpperBound)
-  {
-    if (!theStyle.myIsVisible)
-    {
-      return 1;
-    }
-
-    Standard_Integer aHashCode = 0;
-    if (theStyle.myHasColorSurf)
-    {
-      aHashCode = aHashCode ^ Quantity_ColorRGBAHasher::HashCode (theStyle.myColorSurf, theUpperBound);
-    }
-    if (theStyle.myHasColorCurv)
-    {
-      aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorCurv, theUpperBound);
-    }
-    if (!theStyle.myMaterial.IsNull())
-    {
-      aHashCode = aHashCode ^ ::HashCode (theStyle.myMaterial, theUpperBound);
-    }
-    return ::HashCode (aHashCode, theUpperBound);
-  }
-
-  //! Returns True when the two keys are the same.
-  static Standard_Boolean IsEqual (const XCAFPrs_Style& theS1, const XCAFPrs_Style& theS2)
-  {
-    return theS1.IsEqual (theS2);
-  }
+  template<class T>
+  friend struct std::hash;
 
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
@@ -177,4 +147,34 @@ protected:
 
 };
 
+namespace std
+{
+  template <>
+  struct hash<XCAFPrs_Style>
+  {
+    size_t operator()(const XCAFPrs_Style& theStyle) const
+    {
+      if (!theStyle.myIsVisible)
+      {
+        return 1;
+      }
+      size_t aCombination[3];
+      int aCount = 0;
+      if (theStyle.myHasColorSurf)
+      {
+        aCombination[aCount++] = std::hash<Quantity_ColorRGBA>{}(theStyle.myColorSurf);
+      }
+      if (theStyle.myHasColorCurv)
+      {
+        aCombination[aCount++] = std::hash<Quantity_Color>{}(theStyle.myColorCurv);
+      }
+      if (!theStyle.myMaterial.IsNull())
+      {
+        aCombination[aCount++] = std::hash<Handle(XCAFDoc_VisMaterial)>{}(theStyle.myMaterial);
+      }
+      return aCount > 0 ? opencascade::hashBytes(aCombination, sizeof(size_t) * aCount) : 0;
+    }
+  };
+}
+
 #endif // _XCAFPrs_Style_HeaderFile
index 71561d359e326e01f81c09a88ea14eeec566cbf2..df4c0a2da99a5fba659ed6bd7b7a5ee3b355bcda 100644 (file)
@@ -944,7 +944,7 @@ private:
   }
 
 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
index 05f130df44ee561742afd2ac366fa68b8421cf58..509d05936fafced2a08d4bcfb4d3165ae370d707 100644 (file)
 #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
index 656d0dce07bb4b77a63cc451887813b6ffdfb4ca..ca59eac4868ee537cc0c2554e18d64336c73f994 100644 (file)
@@ -24,7 +24,6 @@
 #include <Standard_Integer.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <MeshVS_EntityType.hxx>
-#include <Standard_Address.hxx>
 #include <TColStd_Array1OfInteger.hxx>
 #include <Poly_Triangulation.hxx>
 
index 13b7b3877b359c5a3f4ae883cefe6e3dd5341ab9..aac3345e6772a6b40f0e0181891ba6c59620b1cb 100644 (file)
@@ -27,7 +27,6 @@
 #include <TColStd_Array1OfReal.hxx>
 #include <MeshVS_EntityType.hxx>
 #include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <Standard_Address.hxx>
 #include <TColStd_Array1OfInteger.hxx>
 
 
index c1f3c6e574985a810966a03cd2a61719fb0630ba..65445ec08141f532b424c416fbb08c2eacce22b1 100644 (file)
 #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
index de6ebd1ae22e7f8ce57a7bbc927a9b8214d9e1b1..a60f8ee14bc4c15c2a87e6b1dd4e699a0b985ea7 100644 (file)
@@ -20,8 +20,8 @@
 #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
index 028473053a4430ec427c477c8492262543270bed..b4ddd1cb5efec165605c6021e897711d123a8bea 100644 (file)
 
 #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
index af3d4b060f1c8b1f6cefa349df94930553c18175..9f816b21f6e991ff134218fd07552375f99a508a 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef XmlTObjDrivers_HeaderFile
 #define XmlTObjDrivers_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <Standard_GUID.hxx>
 
 class XmlMDF_ADriverTable;
index 43fb21757de71a5d1d0f1443413910ff55a56965..291b22da42f3a2e6f3313243c3956e0e8cd5b341 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef XmlTObjDrivers_DocumentRetrievalDriver_HeaderFile
 #define XmlTObjDrivers_DocumentRetrievalDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <XmlLDrivers_DocumentRetrievalDriver.hxx>
 #include <XmlMDF_ADriverTable.hxx>
 
index 544bb4d4dcf7fe59e0d555ba8c5fd39f9522046e..39cea7bcf276952c8dd71570fe0cdf0d203b372a 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef XmlTObjDrivers_DocumentStorageDriver_HeaderFile
 #define XmlTObjDrivers_DocumentStorageDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <XmlLDrivers_DocumentStorageDriver.hxx>
 #include <XmlMDF_ADriverTable.hxx>
 
index 4a04cfb2a342570eddf3543fbf201454d09ebb51..a2bced0c6c1c5611ac2e942645841c16d388c84e 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef XmlTObjDrivers_ObjectDriver_HeaderFile
 #define XmlTObjDrivers_ObjectDriver_HeaderFile
 
-#include <TObj_Common.hxx>
 #include <XmlMDF_ADriver.hxx>
 
 class XmlTObjDrivers_ObjectDriver : public XmlMDF_ADriver 
index 09667d182dd03f98e5924d2b0a2e2baf4e9b26b1..f16c906e9e1f9bcbde5e8d6773b3f42de956b9d3 100644 (file)
@@ -214,6 +214,39 @@ private:
 
 };
 
+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>
index c37125313528ac54f8d13e58c5d892e8373266a8..d1c626a2ba27276d9e0f82c4d929d9d923dbfe85 100755 (executable)
@@ -74,7 +74,6 @@ math_GlobOptMin.hxx
 math_Householder.cxx
 math_Householder.hxx
 math_Householder.lxx
-math_IntegerVector.cxx
 math_IntegerVector.hxx
 math_Jacobi.cxx
 math_Jacobi.hxx
@@ -122,5 +121,6 @@ math_Uzawa.cxx
 math_Uzawa.hxx
 math_Uzawa.lxx
 math_ValueAndWeight.hxx
-math_Vector.cxx
+math_VectorBase.hxx
+math_VectorBase.lxx
 math_Vector.hxx
diff --git a/src/math/math_IntegerVector.cxx b/src/math/math_IntegerVector.cxx
deleted file mode 100644 (file)
index 60541a3..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-// 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";
-  }
-}
index 3ff5d0f0172fa95efc37926ff2708282a394bc80..d7b3f2c37ada957fbf4d6c441d72264deacc9ff5 100644 (file)
 #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
 
index 5fa865e74774edf60aedf1fec50caa446fb7e883..9d05df42512a20d13bbe8e964a5ee98ec9ed1300 100644 (file)
 // 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>
@@ -644,6 +645,15 @@ math_Vector math_Matrix::Multiplied(const math_Vector& Right)const
   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())
index 3373a44a46232f01201df37999a2bdd8fdc9ad93..d3d6feeba88b4f095b2df24da6fa51603c9c389e 100644 (file)
@@ -19,9 +19,9 @@
 
 #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
@@ -29,6 +29,8 @@
   #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
@@ -74,6 +76,7 @@ public:
 
   DEFINE_STANDARD_ALLOC
 
+  friend class math_VectorBase<>;
 
   //! Constructs a non-initialized  matrix of range [LowerRow..UpperRow,
   //! LowerCol..UpperCol]
@@ -278,24 +281,24 @@ Standard_NODISCARD math_Matrix operator- (const math_Matrix& Right) const
   //! 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.
@@ -322,7 +325,7 @@ Standard_NODISCARD math_Matrix operator- (const math_Matrix& Right) const
   //! 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.
@@ -374,11 +377,8 @@ Standard_NODISCARD math_Matrix operator* (const math_Matrix& Right) const
 
   //! 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.
@@ -392,10 +392,6 @@ math_Matrix operator-()
   //! Is used to redefine the operator <<.
   Standard_EXPORT void Dump (Standard_OStream& o) const;
 
-
-friend class math_Vector;
-
-
 protected:
 
 
@@ -409,7 +405,7 @@ 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);
 
 
 
index e61b206eefec82478dd95facdb5f568453eb71ec..a5397716ebcc49c2aa5229bed69810a23a547e4c 100644 (file)
@@ -15,7 +15,6 @@
 // lpa le 29/10/91
 
 #include <Standard_DimensionError.hxx>
-#include <math_Vector.hxx>
 
 inline Standard_OStream& operator<<(Standard_OStream& o,
                                    const math_Matrix& mat)
index 50a79acb97a7b44c9a852f3bc9718b2d41cc29c1..8c6a100f035508ff7ad33f2451064a74025c37c5 100644 (file)
 
 #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;
diff --git a/src/math/math_Vector.cxx b/src/math/math_Vector.cxx
deleted file mode 100644 (file)
index b57bbe3..0000000
+++ /dev/null
@@ -1,502 +0,0 @@
-// 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";
-  }
-}
-
index 15b86ccd34b55003e7be0c5506b65bddc86aa1a9..7e19a1f2d44c36e1edb81773e715b1dbb0cb23d8 100644 (file)
 #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
@@ -55,292 +45,6 @@ class math_Matrix;
 //!    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
diff --git a/src/math/math_VectorBase.hxx b/src/math/math_VectorBase.hxx
new file mode 100644 (file)
index 0000000..cdb20ca
--- /dev/null
@@ -0,0 +1,352 @@
+// 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
diff --git a/src/math/math_VectorBase.lxx b/src/math/math_VectorBase.lxx
new file mode 100644 (file)
index 0000000..5d010f6
--- /dev/null
@@ -0,0 +1,524 @@
+// 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";
+  }
+}
index bf12fa13ebebb149b6354d5bb1035087c4f2358c..527efefeae7b9f8a03718f225f2aef0ff7ece4f5 100644 (file)
@@ -10,8 +10,10 @@ Close D
 
 # 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 {}
index 25588729d32dbf02305ac601d0168408a6fb599e..67bfe294962eb635ca96395b73ad79ebe3742228 100755 (executable)
@@ -1,4 +1,4 @@
-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"
index 30a302b9a4b4734fbf77180340641d13ce3c7321..b189eba23412434d57bc663dc297d6aff8a0f1f6 100644 (file)
@@ -8,7 +8,7 @@ puts ""
 
 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"
index 7f424e4c1bf315d4ce79ee58659600ea95a5c391..96a2313b832242f0449f25ba53dc6c0e64caf667 100644 (file)
@@ -29,8 +29,8 @@ void MessageModel_ItemRoot::SetReport (const int theRowId, const Handle(Message_
     if (aRowId == theRowId)
       break;
   }
-  aReportsIt.Value().myReport = theReport;
-  aReportsIt.Value().myDescription = theReportDescription;
+  aReportsIt.ChangeValue().myReport = theReport;
+  aReportsIt.ChangeValue().myDescription = theReportDescription;
 }
 
 // =======================================================================
index f2d8dac73cf960bafd6f2446264cb1fb5763fa6f..5ba225ad8e4b105cd1b0c69ce648df0e3f9a95d5 100644 (file)
@@ -16,7 +16,6 @@
 #include <inspector/View_Viewer.hxx>
 
 #include <OpenGl_GraphicDriver.hxx>
-#include <Standard_ExtString.hxx>
 
 // =======================================================================
 // function : CreateView