home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / oct93 / graphics / graphtal.lha / Graphtal / Polygon.h < prev    next >
C/C++ Source or Header  |  1992-11-17  |  1KB  |  60 lines

  1. /*
  2.  * Polygon.h - class definition for polygon handling.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  *                     University of Berne, Switzerland
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified, and redistributed
  9.  * provided that this copyright notice is preserved on all copies.
  10.  *
  11.  * You may not distribute this software, in whole or in part, as part of
  12.  * any commercial product without the express consent of the authors.
  13.  *
  14.  * There is no warranty or other guarantee of fitness of this software
  15.  * for any purpose.  It is provided solely "as is".
  16.  *
  17.  */
  18.  
  19. #ifndef Polygon_H
  20. # define Polygon_H
  21.  
  22. #include "Vector.h"
  23. #include "TransMatrix.h"
  24. #include "list.h"
  25.  
  26. declareList(VertexList, Vector);
  27.  
  28. class Polygon
  29. {
  30. public:
  31.   Polygon(long size = 100);
  32.   Polygon(const Vector&, const Vector&, const Vector&);
  33.   Polygon(const Vector&, const Vector&, const Vector&, const Vector&);
  34.   Polygon(const Polygon&);
  35.   ~Polygon();
  36.  
  37.   void transform(const TransMatrix&);
  38.   const Vector& normal() const;
  39.   void addVertex(const Vector&);
  40.   void removeVertex(long);
  41.   long numVertices() const;
  42.   const Vector& vertex(long) const;
  43.  
  44. private:
  45.   VertexList* vertices;
  46. };
  47.  
  48. typedef Polygon* PolygonPtr;
  49. declareList(PolygonList, PolygonPtr);
  50.  
  51. inline long Polygon::numVertices() const {
  52.   return vertices->count();
  53. }
  54.  
  55. inline const Vector& Polygon::vertex(long index) const {
  56.   return vertices->item(index);
  57. }
  58.  
  59. #endif // Polygon_H
  60.