VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIntersectorCacheKey.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtCachedIntersectorKey.h,v $ $Revision: 1.9 $ $State: Exp $
7 ******************************************************************************/
8 
15 
16 #pragma once
17 
18 #include <vrvCore/vrvCore.h>
19 #include <vrvCore/DtIntersector.h>
20 
21 #include <string.h>
22 
23 namespace makVrv
24 {
28  {
29  public:
32  DtIntersector::DynamicOceanProperties op, double x, double y, double z)
33  {
34  myVals[0] = x; myVals[1] = y; myVals[2] = z;
35  myVals[3] = 99999999.99999999; myVals[4] = 99999999.99999999; myVals[5] = 99999999.99999999;
36  myVals[6] = p;
37  myVals[7] = op;
38  myHashValue = hash((const unsigned char*)&myVals[0], sizeof(myVals));
39  }
40 
43  DtIntersector::DynamicOceanProperties op, double x, double y, double z,
44  double end_x, double end_y, double end_z)
45  {
46  myVals[0] = x; myVals[1] = y; myVals[2] = z;
47  myVals[3] = end_x; myVals[4] = end_y; myVals[5] = end_z;
48  myVals[6] = p;
49  myVals[7] = op;
50  myHashValue = hash((const unsigned char*)&myVals[0], sizeof(myVals));
51  }
52 
55  {
56  memcpy(myVals, k.myVals, sizeof(myVals));
58  }
59 
61  bool operator==(const DtIntersectorCacheKey& rhs) const
62  {
63  return (myHashValue == rhs.myHashValue);
64  }
65 
66  bool operator!=(const DtIntersectorCacheKey& rhs) const
67  {
68  return !(*this == rhs);
69  }
70 
72  std::size_t hash(const unsigned char *p, int n)
73  {
74  std::size_t h = 0;
75  std::size_t g;
76 
77  while (n--) {
78  h = (h << 4) + *p++;
79  if ((g = (h & 0xf0000000)) != 0)
80  h ^= g >> 23;
81  h &= ~g;
82  }
83  return h;
84  }
85 
87  inline std::size_t hashValue() const
88  {
89  return myHashValue;
90  }
91 
92  inline operator std::size_t() const
93  {
94  return myHashValue;
95  }
96 
97  protected:
98  double myVals[8];
99  std::size_t myHashValue;
100  };
101 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)