IceTriList.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Contains code for a triangle container.
  4. * \file IceTrilist.h
  5. * \author Pierre Terdiman
  6. * \date April, 4, 2000
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // Include Guard
  11. #ifndef __ICETRILIST_H__
  12. #define __ICETRILIST_H__
  13. class ICEMATHS_API TriList : public OPC_Container
  14. {
  15. public:
  16. // Constructor / Destructor
  17. TriList() {}
  18. ~TriList() {}
  19. inline_ udword GetNbTriangles() const { return GetNbEntries()/9; }
  20. inline_ Triangle* GetTriangles() const { return (Triangle*)GetEntries(); }
  21. void AddTri(const Triangle& tri)
  22. {
  23. Add(tri.mVerts[0].x).Add(tri.mVerts[0].y).Add(tri.mVerts[0].z);
  24. Add(tri.mVerts[1].x).Add(tri.mVerts[1].y).Add(tri.mVerts[1].z);
  25. Add(tri.mVerts[2].x).Add(tri.mVerts[2].y).Add(tri.mVerts[2].z);
  26. }
  27. void AddTri(const Point& p0, const Point& p1, const Point& p2)
  28. {
  29. Add(p0.x).Add(p0.y).Add(p0.z);
  30. Add(p1.x).Add(p1.y).Add(p1.z);
  31. Add(p2.x).Add(p2.y).Add(p2.z);
  32. }
  33. };
  34. class ICEMATHS_API TriangleList : public OPC_Container
  35. {
  36. public:
  37. // Constructor / Destructor
  38. TriangleList() {}
  39. ~TriangleList() {}
  40. inline_ udword GetNbTriangles() const { return GetNbEntries()/3; }
  41. inline_ IndexedTriangle* GetTriangles() const { return (IndexedTriangle*)GetEntries();}
  42. void AddTriangle(const IndexedTriangle& tri)
  43. {
  44. Add(tri.mVRef[0]).Add(tri.mVRef[1]).Add(tri.mVRef[2]);
  45. }
  46. void AddTriangle(udword vref0, udword vref1, udword vref2)
  47. {
  48. Add(vref0).Add(vref1).Add(vref2);
  49. }
  50. };
  51. #endif //__ICETRILIST_H__