| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #ifndef DreieckListe_H
- #define DreieckListe_H
- #include "Array.h"
- #include "Point.h"
- namespace Framework
- {
- template<typename T>
- //! A corner of a triangle
- struct DreieckPunkt
- {
- T* punkt;
- Vec2<float>* textur;
- //! Constructor
- //! \param punkt The coordinate of the corner
- //! \param textur The coordinate in the texture
- DreieckPunkt(T* punkt, Vec2<float>* textur)
- {
- this->punkt = punkt;
- this->textur = textur;
- }
- //! Destructor
- ~DreieckPunkt()
- {
- delete punkt;
- delete textur;
- }
- };
- template<typename T>
- //! 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<DreieckPunkt<T>*>* punkte;
- public:
- //! Constructor
- DreieckListe()
- : ReferenceCounter()
- {
- punkte = new Array<DreieckPunkt<T>*>();
- }
- //! 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<float>* textur)
- {
- punkte->add(new DreieckPunkt<T>(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<DreieckPunkt<T>*>* zListe() const
- {
- return punkte;
- }
- };
- } // namespace Framework
- #endif
|