h o m e d o c u m e n t a t i o n c l a s s h i e r a r c h y

Interface0D.h

00001 //
00002 //  Filename         : Interface0D.h
00003 //  Author(s)        : Emmanuel Turquin
00004 //  Purpose          : Interface to 0D elts
00005 //  Date of creation : 01/07/2003
00006 //
00008 
00009 
00010 //
00011 //  Copyright (C) : Please refer to the COPYRIGHT file distributed 
00012 //   with this source distribution. 
00013 //
00014 //  This program is free software; you can redistribute it and/or
00015 //  modify it under the terms of the GNU General Public License
00016 //  as published by the Free Software Foundation; either version 2
00017 //  of the License, or (at your option) any later version.
00018 //
00019 //  This program is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with this program; if not, write to the Free Software
00026 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 //
00029 
00030 #ifndef  INTERFACE0D_H
00031 # define INTERFACE0D_H
00032 
00033 # include <string>
00034 # include <iostream>
00035 # include "../system/Id.h"
00036 # include "../system/Precision.h"
00037 # include "../winged_edge/Nature.h"
00038 # include "../geometry/Geom.h"
00039 using namespace std;
00040 
00041 //
00042 // Interface0D
00043 //
00045 
00046 class FEdge;
00047 class SVertex;
00048 class ViewVertex;
00049 class NonTVertex;
00050 class TVertex;
00052 class Interface0D
00053 {
00054 public:
00055 
00057   virtual string getExactTypeName() const {
00058     return "Interface0D";
00059   }
00060 
00061   // Data access methods
00062 
00064   virtual real getX() const {
00065     cerr << "Warning: method getX() not implemented" << endl;
00066     return 0;
00067   }
00068 
00070   virtual real getY() const {
00071     cerr << "Warning: method getY() not implemented" << endl;
00072     return 0;
00073   }
00074 
00076   virtual real getZ() const {
00077     cerr << "Warning: method getZ() not implemented" << endl;
00078     return 0;
00079   }
00080 
00082   virtual Geometry::Vec3f getPoint3D() const {
00083     cerr << "Warning: method getPoint3D() not implemented" << endl;
00084     return 0;
00085   }
00086 
00088   virtual real getProjectedX() const {
00089     cerr << "Warning: method getProjectedX() not implemented" << endl;
00090     return 0;
00091   }
00092 
00094   virtual real getProjectedY() const {
00095     cerr << "Warning: method getProjectedY() not implemented" << endl;
00096     return 0;
00097   }
00098 
00100   virtual real getProjectedZ() const {
00101     cerr << "Warning: method getProjectedZ() not implemented" << endl;
00102     return 0;
00103   }
00104 
00106   virtual Geometry::Vec2f getPoint2D() const {
00107     cerr << "Warning: method getPoint2D() not implemented" << endl;
00108     return 0;
00109   }
00110 
00113   virtual FEdge* getFEdge(Interface0D&) {
00114     cerr << "Warning: method getFEdge() not implemented" << endl;
00115     return 0;
00116   }
00117 
00119   virtual Id getId() const {
00120     cerr << "Warning: method getId() not implemented" << endl;
00121     return Id(0, 0);
00122   }
00123 
00125   virtual Nature::VertexNature getNature() const {
00126     cerr << "Warning: method getNature() not implemented" << endl;
00127     return Nature::POINT;
00128   }
00129 
00131   virtual SVertex * castToSVertex(){
00132     cerr << "Warning: can't cast this Interface0D in SVertex" << endl;
00133     return 0;
00134   }
00135 
00137   virtual ViewVertex * castToViewVertex(){
00138     cerr << "Warning: can't cast this Interface0D in ViewVertex" << endl;
00139     return 0;
00140   }
00141 
00143   virtual NonTVertex * castToNonTVertex(){
00144     cerr << "Warning: can't cast this Interface0D in NonTVertex" << endl;
00145     return 0;
00146   }
00147 
00149   virtual TVertex * castToTVertex(){
00150     cerr << "Warning: can't cast this Interface0D in TVertex" << endl;
00151     return 0;
00152   }
00153 };
00154 
00155 
00156 //
00157 // Interface0DIteratorNested
00158 //
00160 
00161 class Interface0DIteratorNested
00162 {
00163 public:
00164 
00165   virtual ~Interface0DIteratorNested() {}
00166 
00167   virtual string getExactTypeName() const {
00168     return "Interface0DIteratorNested";
00169   }
00170 
00171   virtual Interface0D& operator*() = 0;
00172 
00173   virtual Interface0D* operator->() {
00174     return &(operator*());
00175   }
00176 
00177   virtual void increment() = 0;
00178 
00179   virtual void decrement() = 0;
00180 
00181   virtual bool isBegin() const = 0;
00182 
00183   virtual bool isEnd() const = 0;
00184 
00185   virtual bool operator==(const Interface0DIteratorNested& it) const = 0;
00186 
00187   virtual bool operator!=(const Interface0DIteratorNested& it) const {
00188     return !(*this == it);
00189   }
00190 
00192   virtual float t() const = 0;
00194   virtual float u() const = 0;
00195 
00196   virtual Interface0DIteratorNested* copy() const = 0;
00197 };
00198 
00199 
00200 //
00201 // Interface0DIterator
00202 //
00204 
00213 class Interface0DIterator
00214 {
00215 public:
00216 
00217   Interface0DIterator(Interface0DIteratorNested* it = NULL) {
00218     _iterator = it;
00219   }
00220 
00222   Interface0DIterator(const Interface0DIterator& it) {
00223     _iterator = it._iterator->copy();
00224   }
00225 
00227   virtual ~Interface0DIterator() {
00228     if (_iterator)
00229       delete _iterator;
00230   }
00231 
00238   Interface0DIterator& operator=(const Interface0DIterator& it) {
00239     if(_iterator)
00240       delete _iterator;
00241     _iterator = it._iterator->copy();
00242     return *this;
00243   }
00244 
00246   string getExactTypeName() const {
00247     if (!_iterator)
00248       return "Interface0DIterator";
00249     return _iterator->getExactTypeName() + "Proxy";
00250   }
00251 
00252   // FIXME test it != 0 (exceptions ?)
00253 
00258   Interface0D& operator*() {
00259     return _iterator->operator*();
00260   }
00261 
00265   Interface0D* operator->() {
00266     return &(operator*());
00267   }
00268 
00272   Interface0DIterator& operator++() {
00273     _iterator->increment();
00274     return *this;
00275   }
00276 
00280   Interface0DIterator operator++(int) {
00281     Interface0DIterator ret(*this);
00282     _iterator->increment();
00283     return ret;
00284   }
00285 
00289   Interface0DIterator& operator--() {
00290     _iterator->decrement();
00291     return *this;
00292   }
00293 
00297   Interface0DIterator operator--(int) {
00298     Interface0DIterator ret(*this);
00299     _iterator->decrement();
00300     return ret;
00301   }
00302 
00304   void increment() {
00305     _iterator->increment();
00306   }
00307   
00309   void decrement() {
00310     _iterator->decrement();
00311   }
00312 
00317   bool isBegin() const {
00318     return _iterator->isBegin();
00319   }
00320 
00324   bool isEnd() const {
00325     return _iterator->isEnd();
00326   }
00327 
00329   bool operator==(const Interface0DIterator& it) const {
00330     return _iterator->operator==(*(it._iterator));
00331   }
00332 
00334   bool operator!=(const Interface0DIterator& it) const {
00335     return !(*this == it);
00336   }
00337 
00339   inline float t() const {
00340     return _iterator->t();
00341   }
00343   inline float u() const {
00344     return _iterator->u();
00345   }
00346 protected:
00347 
00348   Interface0DIteratorNested* _iterator;
00349 };
00350 
00351 #endif // INTERFACE0D_H