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.

107 lines
2.9 KiB

  1. /**
  2. ** File : aglmesh.h
  3. ** Description: Augmented Mesh definition
  4. ** mesh augmented with adjacency data.
  5. **/
  6. #ifndef _aglmesh_h_
  7. #define _aglmesh_h_
  8. #include "global.h"
  9. #include "sglmesh.h"
  10. #include "vsplit.h"
  11. #include "hash.h"
  12. class CAugGlMesh : public CSimpGlMesh
  13. {
  14. protected:
  15. public:
  16. WORD* m_facemap; // Array remapping the face numbers
  17. WORD (*m_fnei)[3]; // face neightbour information table
  18. void HashAdd(WORD va, WORD vb, WORD f);
  19. WORD HashFind(WORD va, WORD vb);
  20. void apply_vsplit(Vsplit& vspl);
  21. void undo_vsplit(const Vsplit& vspl);
  22. /*
  23. * get index of vertex v in face f
  24. */
  25. inline WORD get_jvf(WORD v, WORD f) const;
  26. /*
  27. * gather functions
  28. */
  29. void gather_vf_jw (WORD v, WORD f, int& j, WORD& w) const;
  30. void gather_vf_j0j2pw (WORD v, WORD f, int& j0, int& j2, WORD*& w);
  31. void gather_vf_j2w (WORD v, WORD f, int& j2, WORD& w) const;
  32. void gather_vf_j1w (WORD v, WORD f, int& j1, WORD& w) const;
  33. void gather_vf_jpw (WORD v, WORD f, int& j, WORD*& pw);
  34. WORD MatidOfFace (WORD f);
  35. inline WORD face_prediction (WORD fa, WORD fb, WORD ii);
  36. inline void WedgeListDelete (WORD w);
  37. inline void add_zero (WORD a, const WEDGEATTRD& ad);
  38. inline void add (WORD a, const GLwedgeAttrib& a1, const WEDGEATTRD& ad);
  39. void sub_reflect (WORD a, const GLwedgeAttrib& abase,
  40. const WEDGEATTRD& ad);
  41. void sub_noreflect (WORD a, WORD abase, const WEDGEATTRD& ad);
  42. public:
  43. CAugGlMesh();
  44. virtual ~CAugGlMesh();
  45. void ComputeAdjacency(void);
  46. };
  47. /*************************************************************************
  48. Inlines
  49. *************************************************************************/
  50. inline WORD CAugGlMesh::get_jvf (WORD v, WORD f) const
  51. {
  52. WORD *w = m_farray[f].w;
  53. if (FindVertexIndex(w[0]) == v)
  54. return 0;
  55. else if (FindVertexIndex(w[1]) == v)
  56. return 1;
  57. else if (FindVertexIndex(w[2]) == v)
  58. return 2;
  59. else
  60. throw CVertexNotFound();
  61. return 0; // Never! To make compiler happy
  62. }
  63. inline WORD CAugGlMesh::face_prediction(WORD fa, WORD fb, WORD ii)
  64. {
  65. return (ii == 0 ? (fb != UNDEF ? fb : fa) : (fa != UNDEF ? fa : fb));
  66. }
  67. inline void CAugGlMesh::WedgeListDelete(WORD w)
  68. {
  69. for (WORD p = w; m_wedgelist[p] != w;
  70. p = m_wedgelist[p]);
  71. m_wedgelist[p] = m_wedgelist[m_wedgelist[p]];
  72. }
  73. inline void CAugGlMesh::add_zero(WORD a, const WEDGEATTRD& ad)
  74. {
  75. m_narray[a].x = ad[0];
  76. m_narray[a].y = ad[1];
  77. m_narray[a].z = ad[2];
  78. m_tarray[a].s = ad[3];
  79. m_tarray[a].t = ad[4];
  80. }
  81. inline void CAugGlMesh::add(WORD a, const GLwedgeAttrib& a1,
  82. const WEDGEATTRD& ad)
  83. {
  84. m_narray[a].x = a1.n.x + ad[0];
  85. m_narray[a].y = a1.n.y + ad[1];
  86. m_narray[a].z = a1.n.z + ad[2];
  87. m_tarray[a].s = a1.t.s + ad[3];
  88. m_tarray[a].t = a1.t.t + ad[4];
  89. }
  90. #endif //_aglmesh_h_