00001 /* $Id: IGPolygon.h,v 1.1 2001/05/27 15:25:28 formella Exp $ */ 00002 00003 /* 00004 * Copyright (C) 2001, Dr. Arno Formella 00005 * Universidade de Vigo 00006 * Departamento de Informatica 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License 00017 * http://www.gnu.ai.mit.edu/copyleft/gpl.html 00018 * for more details. 00019 */ 00020 00021 #ifndef IGPOLYGON_H 00022 #define IGPOLYGON_H 00023 00024 #include <fstream.h> 00025 00026 #include "IGPoint.h" 00027 00028 class IGPolygon { 00029 private: 00031 list<IGPoint> corners; 00033 d3_point center; 00035 vector normal; 00038 bool okForOpenGL; 00039 00040 public: 00041 IGPolygon(); 00042 IGPolygon(const IGPolygon& P); 00043 ~IGPolygon(); 00044 IGPolygon& operator=(const IGPolygon& P); 00045 private: 00054 void CheckForOpenGL(void); 00056 double ComputeArea(const list<point>& L) const; 00058 void ComputeCenter(void); 00061 bool ComputeNormal(void); 00062 public: 00064 void Draw(void) const; 00065 private: 00067 bool IsBitonic(const list<double>& L) const; 00070 bool IsSimpleAndConvex(const list<point>& L) const; 00071 public: 00073 bool IsOkForOpenGL(void) const { return okForOpenGL; } 00075 vector Normal(void) const { return normal; } 00076 private: 00079 bool PointsInPlane(void) const; 00080 public: 00083 friend istream& operator>>(istream& in, IGPolygon& P); 00086 friend ostream& operator<<(ostream& out, const IGPolygon& P); 00087 }; 00088 00089 #endif