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