Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HIndexManager.h
1 /*
2  * Copyright (c) 2006 by Tech Soft 3D, LLC.
3  * The information contained herein is confidential and proprietary to
4  * Tech Soft America, LLC., and considered a trade secret as defined under
5  * civil and criminal statutes. Tech Soft America shall pursue its civil
6  * and criminal remedies in the event of unauthorized use or misappropriation
7  * of its trade secrets. Use of this information by anyone other than
8  * authorized employees of Tech Soft America, LLC. is granted only under a
9  * written non-disclosure agreement, expressly prescribing the scope and
10  * manner of such use.
11  *
12  *$Id: bf819e8c935a8ec0ff350bf4bae2ec2a5d846aeb $
13  */
14 
15 
16 
17 #ifndef _HIO_INDEX_MANAGER_
18 #define _HIO_INDEX_MANAGER_
19 
20 #ifdef H_PACK_8
21 #pragma pack(push)
22 #pragma pack(8)
23 #endif
24 
25 #include "HTools.h"
26 
27 #define VI_BITS (16) //number of bits per section of vertex indices
28 #define VI_MASK ((1<<VI_BITS)-1)
29 #define MAX_SI_INDEX ((0x1 << (31-VI_BITS))-1)
30 
31 
32 typedef struct {
33  HC_KEY key;
34  MVO_POINTER_SIZED_INT offset; //pointer-sized to maintain alignment
35 } ShellInfo;
36 
37 
38 typedef struct {
39  HC_KEY key;
40  int *bigIndices;
41 } PairToIndex;
42 
43 
44 #define UNUSED_INDEX_TO_PAIR 0xffffffff
45 /* interpretation of IndexToPair (stored as unsigned int) values:
46  if (HIGHBIT)
47  if (0xffffffff)
48  unused entry
49  else
50  use the remaining 31 bits as an index into m_SharedVertices
51  else
52  use the remaining upper 31-VI_INDEX bits as in index into the m_ShellLookup
53  add the ShellInfo.offset to the lower VI_INDEX bits to form the shell's vertex index
54  grab the shell's key out of the ShellInfo
55 */
56 
57 
58 typedef struct {
59  //first int is the count, subsequent ints are interpreted as IndexToPair
60  unsigned int *IndexToPair;
61 } SharedVertex;
62 
63 /* STORAGE REQUIREMENTS:
64  IndexToPair:
65  1 int per unshared vertex
66  1 ptr + (2+N) ints for a vertex shared N times
67  1 ptr + 1 int per shell
68 
69  PairToIndex
70  1 ptr per shell
71  1 int per shell vertex
72 
73  RESTRICTIONS:
74  there can be no more than 2^15 ShellInfo structures. Thus there can be
75  no more than 32k shells. For these purposes, a shell with more than 2^VI_BITS
76  vertices counts as point_count >> VI_BITS.
77 */
78 
79 
80 class MVO_API HIndexManager
81 {
82  private:
83  void ExpandSharedVertices();
84  void ExpandShellLookup(int count);
85  void ExpandPairToIndices();
86 
87  HPoint const *m_OldPoints; //needed for AddOneTrnslation
88  HPoint * m_NewPoints; //temporary scratch space
89 
90  protected:
91  bool m_p2i;
92  bool m_i2p;
93 
94  unsigned int *m_IndexToPairs;
95  int m_IndexToPairsAllocated;
96  int m_IndexToPairsUsed;
97 
98  SharedVertex *m_SharedVertices;
99  int m_SharedVerticesAllocated;
100  int m_SharedVerticesUsed;
101 
102  ShellInfo *m_ShellLookup;
103  int m_ShellLookupAllocated;
104  int m_ShellLookupUsed;
105 
106  PairToIndex *m_PairToIndex;
107  int m_PairToIndexAllocated;
108  int m_PairToIndexUsed;
109 
110  void AddOneIndexToPair (int bigIndex, int littleIndex);
111  void RemoveOneTranslation (HC_KEY key, int littleIndex);
112  void RemoveTranslations (HC_KEY key, int face_list_length, const int *face_list);
113 
114  static void AddOneTranslation (void *arg1, void *arg2, void *arg3);
115  public:
116  HIndexManager (bool needPairToIndex, bool needIndexToPair);
117  virtual ~HIndexManager ();
118 
128  HC_KEY KInsertShell (int point_count, const HPoint *points, int face_list_length, const int *face_list);
129 
134  void DeleteByKey (HC_KEY key);
135 
136  void EditShellPoints (HC_KEY key, int littleIndexOffset, int ndelete, int insert, const HPoint *points);
137 
140  void EditShellFaces (HC_KEY key, int ioffset, int ndelete, int insert_list_length, const int *insert_list) {
141  HC_Edit_Shell_Faces (key, ioffset, ndelete, insert_list_length, insert_list);
142  }
143 
145  int GetPairCount (int bigIndex) const;
152  bool GetPair (int bigIndex, int n, HC_KEY *key, int *littleIndex) const;
158  bool GetPairs (int bigIndex, HC_KEY *keys, int *littleIndices) const;
160  bool GetIndex (HC_KEY key, int littleIndex, int *bigIndex) const;
161 };
162 
163 
164 
165 #ifdef H_PACK_8
166 #pragma pack(pop)
167 #endif
168 
169 #endif
170 
171 
172 
173 
174 
175 
Definition: HIndexManager.h:80
Definition: HIndexManager.h:58
#define HC_KEY
void EditShellFaces(HC_KEY key, int ioffset, int ndelete, int insert_list_length, const int *insert_list)
Definition: HIndexManager.h:140
void HC_Edit_Shell_Faces(HC_KEY key, int offset, int ndelete, int ilist_length, const int *insert_list)
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
Definition: HIndexManager.h:38
Definition: HIndexManager.h:32