Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CPoint
- {
- public:
- private:
- };
- class CEdge
- {
- public:
- CEdge* GetNextHorizon();
- void SetNextHorizon(CEdge* next);
- private:
- CEdge* _nextHorizon;
- CPoint* _points[2];
- };
- class CFace
- {
- public:
- CFace* GetNext();
- CFace* GetNextVisible();
- CFace* GetAdjacent(int n);
- void SetNext(CFace* next);
- void SetNextVisible(CFace* next);
- bool IsPointInFront(CPoint* point);
- void SetVisitedFor(CPoint* point);
- bool IsVisitedFor(CPoint* point);
- private:
- CFace* _next;
- CFace* _nextVisible;
- };
- class CHorizon
- {
- public:
- CHorizon(CFace* firstFace, CPoint* point);
- CFace* GetFirstVisible();
- CEdge* GetFirstHorizon();
- private:
- void Traverse(CFace* startFace, CPoint* point);
- CFace* _firstVisible;
- CEdge* _firstHorizon;
- };
- class CPolytop
- {
- public:
- CPolytop(int numPoints);
- private:
- int _numPoints;
- CFace* _firstFace;
- };
- CHorizon::CHorizon(CFace* firstFace, CPoint* point)
- {
- CFace* firstVisibleFace = nullptr;
- CFace* curFace = firstFace;
- while (curFace)
- {
- if (curFace->IsPointInFront(point))
- {
- firstVisibleFace = curFace;
- break;
- }
- curFace = curFace->GetNext();
- }
- if (firstVisibleFace)
- {
- Traverse(firstVisibleFace, point);
- }
- }
- void CHorizon::Traverse(CFace* startFace, CPoint* point)
- {
- startFace->SetNextVisible(_firstVisible);
- _firstVisible = startFace;
- startFace->SetVisitedFor(point);
- for (int i = 0; i < 3; ++i)
- {
- CFace* adjacent = startFace->GetAdjacent(i);
- CEdge* edge = startFace->GetEdge(i);
- if (adjacent->IsVisitedFor(point))
- {
- break;
- }
- if (!adjacent->IsPointInFront(point))
- {
- edge->SetNextHorizon(_firstHorizon);
- _firstHorizon = edge;
- }
- }
- }
- CPolytop::CPolytop(int numPoints)
- {
- _numPoints = numPoints;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement