face.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Pablo Diaz-Gutierrez   *
00003  *   pablo@ics.uci.edu   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef __FACE_H__
00022 #define __FACE_H__
00023 
00024 
00025 #include "vector3.h"
00026 
00027 namespace HE
00028 {
00029         class HalfEdge;
00030         class Vertex;
00031 
00036         class Face
00037         {
00038                 public:
00040                         class edge_circulator
00041                         {
00042                                 public:
00043                                         edge_circulator(const Face* f, HalfEdge* h) : _base(f), _here(h) {}
00044 
00045                                         HalfEdge* operator*() { return _here; }
00046                                         void operator++();
00047                                         void operator++(int) { ++(*this); }
00048                                         bool operator==(const edge_circulator& e) const { return _base==e._base && _here==e._here; }
00049                                         bool operator!=(const edge_circulator& e) const { return !(e == *this); }
00050                                 protected:
00051                                         const Face* _base;
00052                                         HalfEdge* _here;
00053                         };
00058                         edge_circulator begin() { return edge_circulator(this, _edge); }
00059 
00061                         class const_edge_circulator
00062                         {
00063                                 public:
00064                                         const_edge_circulator(const Face* f, const HalfEdge* h) : _base(f), _here(h) {}
00065 
00066                                         const HalfEdge* operator*() { return _here; }
00067                                         void operator++();
00068                                         void operator++(int) { ++(*this); }
00069                                         bool operator==(const const_edge_circulator& e) const { return _base==e._base && _here==e._here; }
00070                                         bool operator!=(const const_edge_circulator& e) const { return !(e == *this); }
00071                                 protected:
00072                                         const Face* _base;
00073                                         const HalfEdge* _here;
00074                         };
00079                         const_edge_circulator begin() const { return const_edge_circulator(this, _edge); }
00080 
00086                         explicit Face(HalfEdge* e, bool hole=false) : _edge(e), _hole(hole) {}
00087                                                 
00088                         // Set methods
00089                         void hole(bool h) { _hole = h; }       
00090                         void edge(HalfEdge* e) { _edge = e; }  
00091                         
00092                         // Get methods
00093                         bool hole() const { return _hole; }            
00094                         HalfEdge* edge() { return _edge; }             
00095                         const HalfEdge* edge() const { return _edge; } 
00096                         const HalfEdge* fromVertex(int v) const;       
00097                         const HalfEdge* fromVertex(Vertex* v) const;   
00098                         const HalfEdge* toVertex(int v) const;         
00099                         const HalfEdge* toVertex(Vertex* v) const;     
00100 
00101                         // Simple computations
00102                         int size() const;                        
00103                         bool contains(const HalfEdge* he) const; 
00104                         bool contains(const Vertex* v) const;    
00105                         Geometry::Vector3Df normal() const;      
00106                         Geometry::Vector3Df centroid() const;    
00107 
00108                 protected:
00109                         HalfEdge* _edge;
00110                         bool _hole;
00111         };
00112         
00114         std::ostream& operator<< (std::ostream& out, const Face& f);
00115 };
00116 
00117 #endif // __FACE_H__

Generated on Wed Apr 9 19:22:37 2008 for HalfEdge library by  doxygen 1.5.3