VR-Forces 4.1 Class Documentation
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  {
33  myVals[0] = x; myVals[1] = y; myVals[2] = z;
34  myVals[3] = 99999999.99999999; myVals[4] = 99999999.99999999; myVals[5] = 99999999.99999999;
35  myVals[6] = p;
36  myHashValue = hash((const unsigned char*)&myVals[0], sizeof(myVals));
37  }
38 
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  myHashValue = hash((const unsigned char*)&myVals[0], sizeof(myVals));
47  }
48 
51  {
52  memcpy(myVals, k.myVals, sizeof(myVals));
54  }
55 
57  bool operator==(const DtIntersectorCacheKey& rhs) const
58  {
59  return (myHashValue == rhs.myHashValue);
60  }
61 
62  bool operator!=(const DtIntersectorCacheKey& rhs) const
63  {
64  return !(*this == rhs);
65  }
66 
68  std::size_t hash(const unsigned char *p, int n)
69  {
70  std::size_t h = 0;
71  std::size_t g;
72 
73  while (n--) {
74  h = (h << 4) + *p++;
75  if ((g = (h & 0xf0000000)) != 0)
76  h ^= g >> 23;
77  h &= ~g;
78  }
79  return h;
80  }
81 
83  inline std::size_t hashValue() const
84  {
85  return myHashValue;
86  }
87 
88  inline operator std::size_t() const
89  {
90  return myHashValue;
91  }
92 
93  protected:
94  double myVals[7];
95  std::size_t myHashValue;
96  };
97 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)