VR-Forces 4.10 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 
12 
13 #pragma once
14 
15 #include <vrvCore/vrvCore.h>
16 #include <vrvCore/DtIntersector.h>
17 
18 #include <string.h>
19 
20 namespace makVrv
21 {
25  {
26  public:
29  DtIntersector::DynamicOceanProperties op, double x, double y, double z)
30  {
31  myVals[0] = x; myVals[1] = y; myVals[2] = z;
32  myVals[3] = 99999999.99999999; myVals[4] = 99999999.99999999; myVals[5] = 99999999.99999999;
33  myVals[6] = p;
34  myVals[7] = op;
35  myHashValue = hash((const unsigned char*)&myVals[0], sizeof(myVals));
36  }
37 
40  DtIntersector::DynamicOceanProperties op, double x, double y, double z,
41  double end_x, double end_y, double end_z)
42  {
43  myVals[0] = x; myVals[1] = y; myVals[2] = z;
44  myVals[3] = end_x; myVals[4] = end_y; myVals[5] = end_z;
45  myVals[6] = p;
46  myVals[7] = op;
47  myHashValue = hash((const unsigned char*)&myVals[0], sizeof(myVals));
48  }
49 
52  {
53  memcpy(myVals, k.myVals, sizeof(myVals));
55  }
56 
58  bool operator==(const DtIntersectorCacheKey& rhs) const
59  {
60  return (myHashValue == rhs.myHashValue);
61  }
62 
63  bool operator!=(const DtIntersectorCacheKey& rhs) const
64  {
65  return !(*this == rhs);
66  }
67 
69  std::size_t hash(const unsigned char *p, int n)
70  {
71  std::size_t h = 0;
72  std::size_t g;
73 
74  while (n--) {
75  h = (h << 4) + *p++;
76  if ((g = (h & 0xf0000000)) != 0)
77  h ^= g >> 23;
78  h &= ~g;
79  }
80  return h;
81  }
82 
84  inline std::size_t hashValue() const
85  {
86  return myHashValue;
87  }
88 
89  inline operator std::size_t() const
90  {
91  return myHashValue;
92  }
93 
94  protected:
95  double myVals[8];
96  std::size_t myHashValue;
97  };
98 }
IntersectProperties
The IntersectProperties enum is a flag set that indicates the.
Definition: DtIntersector.h:135
bool operator!=(const DtIntersectorCacheKey &rhs) const
Definition: DtIntersectorCacheKey.h:63
DynamicOceanProperties
Definition: DtIntersector.h:146
Class that will be used to translate positions into a quick lookup key for cached intersections...
Definition: DtIntersectorCacheKey.h:24
std::size_t myHashValue
Definition: DtIntersectorCacheKey.h:96
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:69
bool operator==(const DtIntersectorCacheKey &rhs) const
Equality operator.
Definition: DtIntersectorCacheKey.h:58
DtIntersectorCacheKey(const DtIntersectorCacheKey &k)
Copy CTOR.
Definition: DtIntersectorCacheKey.h:51
std::size_t hashValue() const
Return calculated hash value.
Definition: DtIntersectorCacheKey.h:84
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:39
double myVals[8]
Definition: DtIntersectorCacheKey.h:95
DtIntersectorCacheKey(DtIntersector::IntersectProperties p, DtIntersector::DynamicOceanProperties op, double x, double y, double z)
CTOR for single point intersection.
Definition: DtIntersectorCacheKey.h:28
Contains DLL export macros.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)