Go to Overview over all GrAL packages.
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Gral/IO/complex2d-format-input.h

00001 #ifndef NMWR_GB_BASE_IO_COMPLEX2D_FORMAT_INPUT_H
00002 #define NMWR_GB_BASE_IO_COMPLEX2D_FORMAT_INPUT_H
00003 
00004 // $LICENSE
00005 
00006 #include <vector>
00007 
00008 #include "Gral/IO/complex2d-format-input-base.h"
00009 
00010 #include "Geometry/point.h"
00011 
00012 
00022 class IstreamComplex2DFmt : public IstreamComplex2DFmt_base
00023 {
00024   typedef IstreamComplex2DFmt      self;
00025   typedef IstreamComplex2DFmt_base base;
00026 public:
00027   // typedef coordN<2>       coord_type;
00028   typedef point           coord_type;
00029 private:
00030   unsigned                        spacedim;
00031   mutable std::vector<coord_type> coords;
00032   mutable bool                    coords_read;
00033 public:
00034   IstreamComplex2DFmt() {}
00035   IstreamComplex2DFmt(std::istream      & in, int off = 0) 
00036     : base(in,off), spacedim(2), coords_read(false) 
00037   { }
00038   IstreamComplex2DFmt(std::string  const& fn, int off = 0) 
00039     : base(fn,off), spacedim(2), coords_read(false)
00040   { }
00041 
00042   IstreamComplex2DFmt(self const& rhs) { copy(rhs);}
00043   self& operator=    (self const& rhs) { 
00044     if(this != & rhs)
00045       copy(rhs); 
00046     return *this;
00047   }
00048 
00049   void set_spacedim(unsigned sd) 
00050     { 
00051       REQUIRE(! coords_read, "coords already read!\n",1);
00052       spacedim = sd;
00053     }
00054 protected:
00055   void copy(self const& rhs) 
00056   {
00057     base::copy(rhs);
00058     copy_coords(rhs);
00059   }
00060   virtual void init()        const;
00061   virtual bool initialized() const;
00062   virtual void read_coords() const;
00063   virtual void copy_coords(self const& rhs)
00064   {
00065     coords = rhs.coords;
00066   }
00067 
00068 public:
00069   coord_type const& coord(Vertex const& v) const {
00070     if(! coords_read){
00071       // should not occur, init() should have been called before.
00072       IstreamComplex2DFmt * slf = const_cast<IstreamComplex2DFmt *>(this);
00073       slf->read_coords();
00074       slf->coords_read = true;
00075     }
00076     return coords[v.handle()];}
00077 };
00078 
00079 
00080 template<>
00081 struct grid_types<IstreamComplex2DFmt>
00082   : public grid_types<IstreamComplex2DFmt_base>
00083 {
00084   typedef IstreamComplex2DFmt grid_type;
00085 };
00086 
00087 
00098 class IstreamComplex2DCombFmt : public IstreamComplex2DFmt_base
00099 {
00100   typedef IstreamComplex2DCombFmt  self;
00101   typedef IstreamComplex2DFmt_base base;
00102 public:
00103   IstreamComplex2DCombFmt() {}
00104   IstreamComplex2DCombFmt(std::istream      & in, int off = 0) : base(in,off) 
00105   { }
00106   IstreamComplex2DCombFmt(std::string  const& fn, int off = 0) : base(fn,off)
00107   { }
00108 
00109   IstreamComplex2DCombFmt(self const& rhs) { copy(rhs);}
00110   self& operator=    (self const& rhs) { 
00111     if(this != & rhs)
00112       copy(rhs); 
00113     return *this;
00114   }
00115 };
00116 
00117 
00118 template<>
00119 struct grid_types<IstreamComplex2DCombFmt>
00120   : public grid_types<IstreamComplex2DFmt_base>
00121 {
00122   typedef IstreamComplex2DCombFmt grid_type;
00123 };
00124 
00125 #endif
00126 

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 16:05:46 2002 for GrAL Base by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000