00001 /* 00002 * Copyright (c) 2006 by Tech Soft 3D, LLC. 00003 * The information contained herein is confidential and proprietary to 00004 * Tech Soft America, LLC., and considered a trade secret as defined under 00005 * civil and criminal statutes. Tech Soft America shall pursue its civil 00006 * and criminal remedies in the event of unauthorized use or misappropriation 00007 * of its trade secrets. Use of this information by anyone other than 00008 * authorized employees of Tech Soft America, LLC. is granted only under a 00009 * written non-disclosure agreement, expressly prescribing the scope and 00010 * manner of such use. 00011 * 00012 *$Id: 567ee401809eed584189ff2d7ae4e46b8daec586 $ 00013 */ 00014 00015 00016 #ifndef _HUTILITYSPARSE_SHELL_H 00017 #define _HUTILITYSPARSE_SHELL_H 00018 00019 #ifdef H_PACK_8 00020 #pragma pack(push) 00021 #pragma pack(8) 00022 #endif 00023 00024 #include "HTools.h" 00025 00026 #define VI_BITS (16) //number of bits per section of vertex indices 00027 #define VI_MASK ((1<<VI_BITS)-1) 00028 #define MAX_SI_INDEX ((0x1 << (31-VI_BITS))-1) 00029 00030 00031 typedef struct { 00032 HC_KEY key; 00033 MVO_POINTER_SIZED_INT offset; //pointer-sized to maintain alignment 00034 } ShellInfo; 00035 00036 00037 typedef struct { 00038 HC_KEY key; 00039 int *bigIndices; 00040 } PairToIndex; 00041 00042 00043 #define UNUSED_INDEX_TO_PAIR 0xffffffff 00044 /* interpretation of IndexToPair (stored as unsigned int) values: 00045 if (HIGHBIT) 00046 if (0xffffffff) 00047 unused entry 00048 else 00049 use the remaining 31 bits as an index into m_SharedVertices 00050 else 00051 use the remaining upper 31-VI_INDEX bits as in index into the m_ShellLookup 00052 add the ShellInfo.offset to the lower VI_INDEX bits to form the shell's vertex index 00053 grab the shell's key out of the ShellInfo 00054 */ 00055 00056 00057 typedef struct { 00058 //first int is the count, subsequent ints are interpreted as IndexToPair 00059 unsigned int *IndexToPair; 00060 } SharedVertex; 00061 00062 /* STORAGE REQUIREMENTS: 00063 IndexToPair: 00064 1 int per unshared vertex 00065 1 ptr + (2+N) ints for a vertex shared N times 00066 1 ptr + 1 int per shell 00067 00068 PairToIndex 00069 1 ptr per shell 00070 1 int per shell vertex 00071 00072 RESTRICTIONS: 00073 there can be no more than 2^15 ShellInfo structures. Thus there can be 00074 no more than 32k shells. For these purposes, a shell with more than 2^VI_BITS 00075 vertices counts as point_count >> VI_BITS. 00076 */ 00077 00078 00079 class MVO_API HUtilitySparseShell 00080 { 00081 private: 00082 void ExpandSharedVertices(); 00083 void ExpandShellLookup(int count); 00084 void ExpandPairToIndices(); 00085 00086 HPoint const *m_OldPoints; //needed for AddOneTrnslation 00087 HPoint * m_NewPoints; //temporary scratch space 00088 00089 protected: 00090 bool m_p2i; 00091 bool m_i2p; 00092 00093 unsigned int *m_IndexToPairs; 00094 int m_IndexToPairsAllocated; 00095 int m_IndexToPairsUsed; 00096 00097 SharedVertex *m_SharedVertices; 00098 int m_SharedVerticesAllocated; 00099 int m_SharedVerticesUsed; 00100 00101 ShellInfo *m_ShellLookup; 00102 int m_ShellLookupAllocated; 00103 int m_ShellLookupUsed; 00104 00105 PairToIndex *m_PairToIndex; 00106 int m_PairToIndexAllocated; 00107 int m_PairToIndexUsed; 00108 00109 void AddOneIndexToPair (int bigIndex, int littleIndex); 00110 void RemoveOneTranslation (HC_KEY key, int littleIndex); 00111 void RemoveTranslations (HC_KEY key, int face_list_length, const int *face_list); 00112 00113 static void AddOneTranslation (void *arg1, void *arg2, void *arg3); 00114 public: 00115 HUtilitySparseShell (bool needPairToIndex, bool needIndexToPair); 00116 virtual ~HUtilitySparseShell (); 00117 00127 HC_KEY KInsertShell (int point_count, const HPoint *points, int face_list_length, const int *face_list); 00128 00133 void DeleteByKey (HC_KEY key); 00134 00135 void EditShellPoints (HC_KEY key, int littleIndexOffset, int ndelete, int insert, const HPoint *points); 00136 00139 void EditShellFaces (HC_KEY key, int ioffset, int ndelete, int insert_list_length, const int *insert_list) { 00140 HC_Edit_Shell_Faces (key, ioffset, ndelete, insert_list_length, insert_list); 00141 } 00142 00144 int GetPairCount (int bigIndex) const; 00151 bool GetPair (int bigIndex, int n, HC_KEY *key, int *littleIndex) const; 00157 bool GetPairs (int bigIndex, HC_KEY *keys, int *littleIndices) const; 00159 bool GetIndex (HC_KEY key, int littleIndex, int *bigIndex) const; 00160 }; 00161 00162 00163 #ifdef H_PACK_8 00164 #pragma pack(pop) 00165 #endif 00166 00167 #endif 00168 00169 00170 00171 00172