VR-Forces 4.8 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 }
IntersectProperties
The IntersectProperties enum is a flag set that indicates the.
Definition: DtIntersector.h:135
bool operator!=(const DtIntersectorCacheKey &rhs) const
Definition: DtIntersectorCacheKey.h:66
DynamicOceanProperties
Definition: DtIntersector.h:146
Class that will be used to translate positions into a quick lookup key for cached intersections...
Definition: DtIntersectorCacheKey.h:27
std::size_t myHashValue
Definition: DtIntersectorCacheKey.h:99
Contains makVrv:DtIntersector, makVrv:DtIntersectorLineSegment, and makVrv:DtIntersectorResult classe...
std::size_t hash(const unsigned char *p, int n)
Turn key into single hash value.
Definition: DtIntersectorCacheKey.h:72
bool operator==(const DtIntersectorCacheKey &rhs) const
Equality operator.
Definition: DtIntersectorCacheKey.h:61
DtIntersectorCacheKey(const DtIntersectorCacheKey &k)
Copy CTOR.
Definition: DtIntersectorCacheKey.h:54
std::size_t hashValue() const
Return calculated hash value.
Definition: DtIntersectorCacheKey.h:87
DtIntersectorCacheKey(DtIntersector::IntersectProperties p, DtIntersector::DynamicOceanProperties op, double x, double y, double z, double end_x, double end_y, double end_z)
CTOR for start and end point (line)
Definition: DtIntersectorCacheKey.h:42
double myVals[8]
Definition: DtIntersectorCacheKey.h:98
DtIntersectorCacheKey(DtIntersector::IntersectProperties p, DtIntersector::DynamicOceanProperties op, double x, double y, double z)
CTOR for single point intersection.
Definition: DtIntersectorCacheKey.h:31
Contains DLL export macros.

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)