Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
5.2 KiB

  1. /**
  2. ** File : vsplit.h
  3. ** Description: vsplit implementations
  4. **/
  5. #ifndef _vsplit_h_
  6. #define _vsplit_h_
  7. #include "excptn.h"
  8. typedef float WEDGEATTRD[5]; // wedge attribute delta
  9. /*
  10. * Vertex split record.
  11. * Records the information necessary to split a vertex of the mesh,
  12. * in order to add to the mesh 1 new vertex and 1 or 2 new faces.
  13. */
  14. class Vsplit {
  15. public:
  16. /*
  17. * Default operator=() and copy_constructor are safe.
  18. */
  19. void read(istream& is);
  20. void write(ostream& os) const;
  21. void OK() const { };
  22. int adds_two_faces() const { return 0; };
  23. /*
  24. * This format provides these limits:
  25. * - maximum number of faces: 1<<32
  26. * - maximum vertex valence: 1<<16
  27. * - maximum number of materials: 1<<16
  28. *
  29. * Encoding of vertices vs, vl, vr.
  30. * Face flclw is the face just CLW of vl from vs.
  31. * vs is the vs_index\'th vertex of flclw
  32. * (vl is the (vs_index+2)%3\'th vertex of face flclw)
  33. * vr is the (vlr_offset1-1)\'th vertex when rotating CLW about vs
  34. * from vl
  35. *
  36. * Special cases:
  37. * - vlr_offset1==1 : no_vr and no_fr
  38. * - vlr_offest1==0: no flclw! vspl.flclw is actually flccw.
  39. */
  40. DWORD flclw; // 0..(mesh.numFaces()-1)
  41. WORD vlr_offset1; // 0..(max_vertex_valence) (prob < valence/2)
  42. WORD code; // (vs_index(2),ii(2),ws(3),wt(3),wl(2),wr(2),
  43. // fl_matid>=0(1),fr_matid>=0(1))
  44. enum {
  45. B_STMASK=0x0007,
  46. B_LSAME=0x0001,
  47. B_RSAME=0x0002,
  48. B_CSAME=0x0004,
  49. //
  50. B_LRMASK=0x0003,
  51. B_ABOVE=0x0000,
  52. B_BELOW=0x0001,
  53. B_NEW =0x0002, // must be on separate bit.
  54. };
  55. enum {
  56. VSINDEX_SHIFT=0,
  57. VSINDEX_MASK=(0x0003<<VSINDEX_SHIFT),
  58. //
  59. II_SHIFT=2,
  60. II_MASK=(0x0003<<II_SHIFT),
  61. //
  62. S_SHIFT=4,
  63. S_MASK=(B_STMASK<<S_SHIFT),
  64. S_LSAME=(B_LSAME<<S_SHIFT),
  65. S_RSAME=(B_RSAME<<S_SHIFT),
  66. S_CSAME=(B_CSAME<<S_SHIFT),
  67. //
  68. T_SHIFT=7,
  69. T_MASK=(B_STMASK<<T_SHIFT),
  70. T_LSAME=(B_LSAME<<T_SHIFT),
  71. T_RSAME=(B_RSAME<<T_SHIFT),
  72. T_CSAME=(B_CSAME<<T_SHIFT),
  73. //
  74. L_SHIFT=10,
  75. L_MASK=(B_LRMASK<<L_SHIFT),
  76. L_ABOVE=(B_ABOVE<<L_SHIFT),
  77. L_BELOW=(B_BELOW<<L_SHIFT),
  78. L_NEW =(B_NEW<<L_SHIFT),
  79. //
  80. R_SHIFT=12,
  81. R_MASK=(B_LRMASK<<R_SHIFT),
  82. R_ABOVE=(B_ABOVE<<R_SHIFT),
  83. R_BELOW=(B_BELOW<<R_SHIFT),
  84. R_NEW =(B_NEW<<R_SHIFT),
  85. //
  86. FLN_SHIFT=14,
  87. FLN_MASK=(1<<FLN_SHIFT),
  88. //
  89. FRN_SHIFT=15,
  90. FRN_MASK=(1<<FRN_SHIFT),
  91. };
  92. /*
  93. * Documentation:
  94. * -------------
  95. * vs_index: 0..2: index of vs within flace flclw
  96. * ii: 0..2: == alpha(1.0, 0.5, 0.0)
  97. * ii=2: a=0.0 (old_vs=~new_vs)
  98. * ii=1: a=0.5
  99. * ii=0: a=1.0 (old_vs=~new_vt)
  100. * Inside wedges
  101. * {S,T}{LSAME}: if exists outside left wedge and if same
  102. * {S,T}{RSAME}: if exists outside right wedge and if same
  103. * {S,T}{CSAME}: if inside left and right wedges are same
  104. * (when no_vr, {S,T}RSAME==1, {S,T}CSAME==0)
  105. * Outside wedges
  106. * (when no_vr, RABOVE==1)
  107. * New face material identifiers
  108. * {L,R}NF: if 1, face matids not predicted correctly using ii,
  109. * so included in f{l,r}_matid
  110. * (when no_vr, RNF==0 obviously)
  111. *
  112. * Probabilities:
  113. * vs_index: 0..2 (prob. uniform)
  114. * ii: ii==2 prob. low/med (med if 'MeshSimplify -nominii1')
  115. * ii==0 prob. low/med
  116. * ii==1 prob. high/zero (zero if 'MeshSimplify -monminii1')
  117. * {S,T}LSAME: prob. high
  118. * {S,T}RSAME: prob. high
  119. * {S,T}CSAME: prob. low
  120. * {L,R}ABOVE: prob. high
  121. * {L,R}BELOW: prob. low
  122. * {L,R}NEW: prob. low
  123. * Note: wl, wr, ws, wt are correlated since scalar half-edge
  124. * discontinuities usually match up at both ends of edges.
  125. * -> do entropy coding on (ii,wl,wr,ws,wt) symbol as a whole.
  126. *
  127. * Face attribute values (usually predicted correctly)
  128. * these are defined only if {L,R}NF respectively
  129. * otherwise for now they are set to 0
  130. */
  131. WORD fl_matid;
  132. WORD fr_matid;
  133. /*
  134. * Vertex attribute deltas:
  135. * -----------------------
  136. * for ii==2: vad_large=new_vt-old_vs, vad_small=new_vs-old_vs
  137. * for ii==0: vad_large=new_vs-old_vs, vad_small=new_vt-old_vs
  138. * for ii==1: vad_large=new_vt-new_i, vad_small=new_i-old_vs
  139. * where new_i=interp(new_vt,new_vs)
  140. */
  141. float vad_large[3];
  142. float vad_small[3]; // is zero if "MeshSimplify -nofitgeom"
  143. /*
  144. * Wedge attribute deltas (size 1--6)
  145. * Order: [(wvtfl, wvsfl), [(wvtfr, wvsfr)], wvlfl, [wvrfr]]
  146. * [nx, ny, nz, s, t]
  147. */
  148. float ar_wad[6][5];
  149. /*
  150. * Indicates if the Vsplit has been modified or not
  151. */
  152. BOOL modified;
  153. private:
  154. int expected_wad_num() const;
  155. };
  156. class VsplitArray
  157. {
  158. private:
  159. DWORD m_cRef;
  160. Vsplit* m_vsarr;
  161. DWORD numVS;
  162. public:
  163. void write(ostream& os) const;
  164. ULONG AddRef(void);
  165. ULONG Release(void);
  166. Vsplit& elem(DWORD i) { return m_vsarr[i]; };
  167. VsplitArray(DWORD i);
  168. };
  169. #endif _vsplit_h_