#ifndef DreieckListe_H #define DreieckListe_H #include "Array.h" #include "Punkt.h" namespace Framework { template //! A corner of a triangle struct DreieckPunkt { T* punkt; Vec2* textur; //! Constructor //! \param punkt The coordinate of the corner //! \param textur The coordinate in the texture DreieckPunkt(T* punkt, Vec2* textur) { this->punkt = punkt; this->textur = textur; } //! Destructor ~DreieckPunkt() { delete punkt; delete textur; } }; template //! A list of triangles where the last two points of the previous triangle //! together with the next point form a new triangle class DreieckListe : public virtual ReferenceCounter { private: Array*>* punkte; public: //! Constructor DreieckListe() : ReferenceCounter() { punkte = new Array*>(); } //! Destructor ~DreieckListe() { int anz = punkte->getEintragAnzahl(); for (int i = 0; i < anz; i++) delete punkte->get(i); punkte->release(); } //! Adds a point to the list //! \param p The coordinates of the point //! \param textur The coordinates in the texture void addPunkt(T* p, Vec2* textur) { punkte->add(new DreieckPunkt(p, textur)); } //! Deletes the last point void removeLetztenPunkt() { int i = punkte->getEintragAnzahl() - 1; if (!punkte->hat(i)) return; delete punkte->get(i); punkte->remove(i); } //! Deletes all corners void lehren() { int anz = punkte->getEintragAnzahl(); for (int i = 0; i < anz; i++) delete punkte->get(i); punkte->leeren(); } //! Returns the number of triangles int getDreieckAnzahl() const { return punkte->getEintragAnzahl() - 2; } //! Returns whether a texture is used bool hatTextur() const { int anz = punkte->getEintragAnzahl(); bool ret = 1; for (int i = 0; i < anz; i++) { if (punkte->hat(i)) ret &= punkte->get(i)->textur; } return ret; } //! Returns the list of points Array*>* zListe() const { return punkte; } }; } // namespace Framework #endif