Warning, /include/opencascade/TopLoc_Location.lxx is written in an unsupported language. File is not indexed.
0001 // Created on: 1993-01-11
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016
0017 #include <Standard_HashUtils.hxx>
0018 #include <TopLoc_SListOfItemLocation.hxx>
0019 #include <TopLoc_Datum3D.hxx>
0020 #include <TopLoc_ItemLocation.hxx>
0021
0022 //=======================================================================
0023 // function : IsIdentity
0024 // purpose :
0025 //=======================================================================
0026
0027 inline Standard_Boolean TopLoc_Location::IsIdentity() const
0028 {
0029 return myItems.IsEmpty();
0030 }
0031
0032 //=======================================================================
0033 // function : Identity
0034 // purpose :
0035 //=======================================================================
0036
0037 inline void TopLoc_Location::Identity()
0038 {
0039 myItems.Clear();
0040 }
0041
0042 //=======================================================================
0043 // function : FirstDatum
0044 // purpose :
0045 //=======================================================================
0046
0047 inline const Handle(TopLoc_Datum3D)& TopLoc_Location::FirstDatum() const
0048 {
0049 return myItems.Value().myDatum;
0050 }
0051
0052 //=======================================================================
0053 // function : FirstPower
0054 // purpose :
0055 //=======================================================================
0056
0057 inline Standard_Integer TopLoc_Location::FirstPower() const
0058 {
0059 return myItems.Value().myPower;
0060 }
0061
0062 //=======================================================================
0063 // function : NextLocation
0064 // purpose :
0065 //=======================================================================
0066
0067 inline const TopLoc_Location& TopLoc_Location::NextLocation() const
0068 {
0069 return (*(TopLoc_Location*)&(myItems.Tail()));
0070 }
0071
0072 //=======================================================================
0073 // function : HashCode
0074 // purpose :
0075 //=======================================================================
0076 inline size_t TopLoc_Location::HashCode() const
0077 {
0078 // Hashing base on IsEqual function
0079 if (myItems.IsEmpty())
0080 {
0081 return 0;
0082 }
0083 size_t aHash = opencascade::MurmurHash::optimalSeed<size_t>();
0084 TopLoc_SListOfItemLocation items = myItems;
0085 size_t aCombined[3];
0086 while (items.More())
0087 {
0088 aCombined[0] = std::hash<Handle(TopLoc_Datum3D)>{}(items.Value().myDatum);
0089 aCombined[1] = opencascade::hash(items.Value().myPower);
0090 aCombined[2] = aHash;
0091 aHash = opencascade::hashBytes(aCombined, sizeof(aCombined));
0092 items.Next();
0093 }
0094 return aHash;
0095 }
0096
0097 //=======================================================================
0098 // function : ShallowDump
0099 // purpose :
0100 //=======================================================================
0101 inline void ShallowDump(const TopLoc_Location& me, Standard_OStream& S)
0102 {
0103 me.ShallowDump(S);
0104 }
0105
0106 namespace std
0107 {
0108 template <>
0109 struct hash<TopLoc_Location>
0110 {
0111 size_t operator()(const TopLoc_Location& theLocation) const { return theLocation.HashCode(); }
0112 };
0113 } // namespace std