proj home

Files   Classes   Functions   Hierarchy  

simplexD1tessindexed.h

Go to the documentation of this file.
00001 #ifndef SIMPLEXD1TESSINDEXED_H
00002 #define SIMPLEXD1TESSINDEXED_H
00003 
00004 
00005 #include <vector>
00006 #include <sstream>
00007 using namespace std;
00008 
00009 #include <print.h>
00010 #include <simplexD1indexed.h>
00011 #include <tokenizer.h>
00012 #include <typedefs.h>
00013 #include <vectorreadin.h>
00014 
00030 template< typename PT, typename PD, typename INDX > 
00031 class simplexD1tessindexed
00032 {
00033 public:
00034 
00036   vector< PT > pts;
00038   vector< simplexD1indexed<INDX> > vi;
00039 
00041   simplexD1tessindexed();
00042 
00044   void construct
00045   ( 
00046     PD const * points,
00047     INDX const pointsize,
00048     INDX const * lines,
00049     INDX const linessize
00050   );
00051     
00053   operator stringc () const;
00054 
00056   void serializeInverse(stringc & s);
00057 
00058   boolc operator == (simplexD1tessindexed<PT,PD,INDX> const & s2 ) const
00059   {
00060 //cout << "Tesing sizes" << endl;
00061 //cout << SHOW(pts.size()) << endl;
00062 //cout << SHOW(s2.pts.size()) << endl;
00063     if (pts.size()!=s2.pts.size())
00064       return false;
00065 
00066     if (vi.size()!=s2.vi.size())
00067       return false;
00068 
00069 //cout << "Checking points" << endl;
00070     for (uint i=0; i<pts.size(); ++i)
00071     {
00072       if (pts[i]!=s2.pts[i])
00073         return false;
00074     }
00075 //cout << "Checking indexes" << endl;
00076     for (uint i=0; i<vi.size(); ++i)
00077     {
00078       if (!(vi[i]==s2.vi[i]))
00079         return false;
00080     }
00081  
00082     return true;
00083   }
00084 
00085 
00086 
00087 
00088 
00089 
00090 };
00091 
00092 
00093 //---------------------------------------------------------
00094 // Implementation
00095 
00096 template< typename PT, typename PD, typename INDX >
00097 simplexD1tessindexed<PT,PD,INDX>::simplexD1tessindexed()
00098 {
00099   pts.push_back(PT());
00100   vi.push_back( simplexD1indexed<INDX>() );
00101 }
00102 
00103 
00104 template< typename PT, typename PD, typename INDX > 
00105 void simplexD1tessindexed<PT,PD,INDX>::serializeInverse(stringc & s)
00106 {
00107   pts.clear();
00108   vi.clear();
00109 
00110   tokenizer tokenstream;
00111   tokenstream.readaslinesgeneral(s);
00112 
00113   tokenstream.reset();
00114   uint ptssize;
00115   stringstream(tokenstream()) >> ptssize;
00116   ++tokenstream;
00117 //cout << "ptssize=" << ptssize << endl;
00118 
00119   PD x,y;
00120   for (uint i=0; i<ptssize; ++i)
00121   {
00122     stringstream(tokenstream()) >> x;
00123     ++tokenstream;
00124     stringstream(tokenstream()) >> y;
00125     ++tokenstream;
00126 //cout << "x=" << x << " y=" << y << endl;
00127     pts.push_back( PT(x,y) );
00128   }
00129 
00130   uint visize;
00131   stringstream(tokenstream()) >> visize;
00132   ++tokenstream;
00133 //cout << "visize=" << visize << endl;
00134   INDX a,b;
00135   for (uint i=0; i<visize; ++i)
00136   {
00137     stringstream(tokenstream()) >> a;
00138     ++tokenstream;
00139     stringstream(tokenstream()) >> b;
00140     ++tokenstream;
00141 //cout << "a=" << a << " b=" << b << " c=" << c << endl;
00142 
00143     vi.push_back( simplexD1indexed<INDX>(a,b) );
00144   }
00145 
00146 }
00147 
00148 
00149 template< typename PT, typename PD, typename INDX >
00150 simplexD1tessindexed<PT,PD,INDX>::operator stringc () const
00151 {
00152   stringstream ss;
00153   
00154   uint imax = pts.size();
00155   ss << imax << "\n";
00156   for (uint i=0; i<imax; ++i)
00157     ss << pts[i] << "\n";
00158   imax = vi.size();
00159   ss << imax << "\n";
00160   for (uint i=0; i<imax; ++i)
00161     ss << vi[i] << "\n";
00162 
00163   return ss.str();
00164 }
00165 
00166 
00167 template< typename PT, typename PD, typename INDX >
00168 void simplexD1tessindexed<PT,PD,INDX>::construct
00169 ( 
00170   PD const * points,
00171   INDX const pointsize,
00172   INDX const * lines,
00173   INDX const linessize
00174 )
00175 {
00176   vectorreadingD2(pts,points,pointsize);
00177   vectorreadingD2(vi,lines,linessize);
00178 }
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 #endif
00188 

Generated on Fri Mar 4 00:49:31 2011 for Chelton Evans Source by  doxygen 1.5.8