Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HUtilitySparseShell.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: 567ee401809eed584189ff2d7ae4e46b8daec586 $
13  */
14 
15 
16 #ifndef _HUTILITYSPARSE_SHELL_H
17 #define _HUTILITYSPARSE_SHELL_H
18 
19 #ifdef H_PACK_8
20 #pragma pack(push)
21 #pragma pack(8)
22 #endif
23 
24 #include "HTools.h"
25 
26 #define VI_BITS (16) //number of bits per section of vertex indices
27 #define VI_MASK ((1<<VI_BITS)-1)
28 #define MAX_SI_INDEX ((0x1 << (31-VI_BITS))-1)
29 
30 
31 typedef struct {
32  HC_KEY key;
33  MVO_POINTER_SIZED_INT offset; //pointer-sized to maintain alignment
34 } ShellInfo;
35 
36 
37 typedef struct {
38  HC_KEY key;
39  int *bigIndices;
40 } PairToIndex;
41 
42 
43 #define UNUSED_INDEX_TO_PAIR 0xffffffff
44 /* interpretation of IndexToPair (stored as unsigned int) values:
45  if (HIGHBIT)
46  if (0xffffffff)
47  unused entry
48  else
49  use the remaining 31 bits as an index into m_SharedVertices
50  else
51  use the remaining upper 31-VI_INDEX bits as in index into the m_ShellLookup
52  add the ShellInfo.offset to the lower VI_INDEX bits to form the shell's vertex index
53  grab the shell's key out of the ShellInfo
54 */
55 
56 
57 typedef struct {
58  //first int is the count, subsequent ints are interpreted as IndexToPair
59  unsigned int *IndexToPair;
60 } SharedVertex;
61 
62 /* STORAGE REQUIREMENTS:
63  IndexToPair:
64  1 int per unshared vertex
65  1 ptr + (2+N) ints for a vertex shared N times
66  1 ptr + 1 int per shell
67 
68  PairToIndex
69  1 ptr per shell
70  1 int per shell vertex
71 
72  RESTRICTIONS:
73  there can be no more than 2^15 ShellInfo structures. Thus there can be
74  no more than 32k shells. For these purposes, a shell with more than 2^VI_BITS
75  vertices counts as point_count >> VI_BITS.
76 */
77 
78 
79 class MVO_API HUtilitySparseShell
80 {
81  private:
82  void ExpandSharedVertices();
83  void ExpandShellLookup(int count);
84  void ExpandPairToIndices();
85 
86  HPoint const *m_OldPoints; //needed for AddOneTrnslation
87  HPoint * m_NewPoints; //temporary scratch space
88 
89  protected:
90  bool m_p2i;
91  bool m_i2p;
92 
93  unsigned int *m_IndexToPairs;
94  int m_IndexToPairsAllocated;
95  int m_IndexToPairsUsed;
96 
97  SharedVertex *m_SharedVertices;
98  int m_SharedVerticesAllocated;
99  int m_SharedVerticesUsed;
100 
101  ShellInfo *m_ShellLookup;
102  int m_ShellLookupAllocated;
103  int m_ShellLookupUsed;
104 
105  PairToIndex *m_PairToIndex;
106  int m_PairToIndexAllocated;
107  int m_PairToIndexUsed;
108 
109  void AddOneIndexToPair (int bigIndex, int littleIndex);
110  void RemoveOneTranslation (HC_KEY key, int littleIndex);
111  void RemoveTranslations (HC_KEY key, int face_list_length, const int *face_list);
112 
113  static void AddOneTranslation (void *arg1, void *arg2, void *arg3);
114  public:
115  HUtilitySparseShell (bool needPairToIndex, bool needIndexToPair);
116  virtual ~HUtilitySparseShell ();
117 
127  HC_KEY KInsertShell (int point_count, const HPoint *points, int face_list_length, const int *face_list);
128 
133  void DeleteByKey (HC_KEY key);
134 
135  void EditShellPoints (HC_KEY key, int littleIndexOffset, int ndelete, int insert, const HPoint *points);
136 
139  void EditShellFaces (HC_KEY key, int ioffset, int ndelete, int insert_list_length, const int *insert_list) {
140  HC_Edit_Shell_Faces (key, ioffset, ndelete, insert_list_length, insert_list);
141  }
142 
144  int GetPairCount (int bigIndex) const;
151  bool GetPair (int bigIndex, int n, HC_KEY *key, int *littleIndex) const;
157  bool GetPairs (int bigIndex, HC_KEY *keys, int *littleIndices) const;
159  bool GetIndex (HC_KEY key, int littleIndex, int *bigIndex) const;
160 };
161 
162 
163 #ifdef H_PACK_8
164 #pragma pack(pop)
165 #endif
166 
167 #endif
168 
169 
170 
171 
172 
Definition: HIndexManager.h:58
#define HC_KEY
void HC_Edit_Shell_Faces(HC_KEY key, int offset, int ndelete, int ilist_length, const int *insert_list)
Definition: HUtilitySparseShell.h:79
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
Definition: HIndexManager.h:38
Definition: HIndexManager.h:32
void EditShellFaces(HC_KEY key, int ioffset, int ndelete, int insert_list_length, const int *insert_list)
Definition: HUtilitySparseShell.h:139