home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / polygon.h < prev    next >
C/C++ Source or Header  |  1992-10-19  |  1KB  |  59 lines

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