Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 55 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.  
  2. class CPoint
  3. {
  4. public:
  5.  
  6. private:
  7.  
  8. };
  9.  
  10. class CEdge
  11. {
  12. public:
  13.     CEdge* GetNextHorizon();
  14.     void SetNextHorizon(CEdge* next);
  15. private:
  16.     CEdge* _nextHorizon;
  17.     CPoint* _points[2];
  18. };
  19.  
  20. class CFace
  21. {
  22. public:
  23.     CFace* GetNext();
  24.     CFace* GetNextVisible();
  25.     CFace* GetAdjacent(int n);
  26.     void SetNext(CFace* next);
  27.     void SetNextVisible(CFace* next);
  28.     bool IsPointInFront(CPoint* point);
  29.     void SetVisitedFor(CPoint* point);
  30.     bool IsVisitedFor(CPoint* point);
  31. private:
  32.     CFace* _next;
  33.     CFace* _nextVisible;
  34. };
  35.  
  36. class CHorizon
  37. {
  38. public:
  39.     CHorizon(CFace* firstFace, CPoint* point);
  40.     CFace* GetFirstVisible();
  41.     CEdge* GetFirstHorizon();
  42. private:
  43.     void Traverse(CFace* startFace, CPoint* point);
  44.     CFace* _firstVisible;
  45.     CEdge* _firstHorizon;
  46. };
  47.  
  48. class CPolytop
  49. {
  50. public:
  51.     CPolytop(int numPoints);
  52. private:
  53.     int _numPoints;
  54.     CFace* _firstFace;
  55. };
  56.  
  57. CHorizon::CHorizon(CFace* firstFace, CPoint* point)
  58. {
  59.     CFace* firstVisibleFace = nullptr;
  60.  
  61.     CFace* curFace = firstFace;
  62.     while (curFace)
  63.     {
  64.         if (curFace->IsPointInFront(point))
  65.         {
  66.             firstVisibleFace = curFace;
  67.             break;
  68.         }
  69.  
  70.         curFace = curFace->GetNext();
  71.     }
  72.  
  73.     if (firstVisibleFace)
  74.     {
  75.         Traverse(firstVisibleFace, point);
  76.     }
  77. }
  78.  
  79. void CHorizon::Traverse(CFace* startFace, CPoint* point)
  80. {
  81.     startFace->SetNextVisible(_firstVisible);
  82.     _firstVisible = startFace;
  83.  
  84.     startFace->SetVisitedFor(point);
  85.  
  86.     for (int i = 0; i < 3; ++i)
  87.     {
  88.         CFace* adjacent = startFace->GetAdjacent(i);
  89.         CEdge* edge = startFace->GetEdge(i);
  90.  
  91.         if (adjacent->IsVisitedFor(point))
  92.         {
  93.             break;
  94.         }
  95.  
  96.         if (!adjacent->IsPointInFront(point))
  97.         {
  98.             edge->SetNextHorizon(_firstHorizon);
  99.             _firstHorizon = edge;
  100.         }
  101.     }
  102. }
  103.  
  104. CPolytop::CPolytop(int numPoints)
  105. {
  106.     _numPoints = numPoints;
  107. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top