proj home

Files   Classes   Functions   Hierarchy  

pointtest.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <vector>
00003 #include <fstream>
00004 
00005 using namespace std;
00006 
00007 #include <point.h>
00008 #include <pointtest.h>
00009 
00010 
00011 
00012 void pointtest::test01()
00013 {
00014 
00015   double v[12] = 
00016   { 1.0,2.0,3.0,
00017     4.0,5.0,6.0,
00018     7.0,8.0,9.0,
00019     10.0,11.0,12.5
00020   };
00021 
00022   vector<point3<double> > w;
00023 
00024   point3<double>::readin(w,v,v+sizeof(v)/sizeof(double));
00025 
00026   for (unsigned int i=0; i<w.size(); ++i)
00027     cout << w[i] << endl;
00028 
00029   cout << endl;
00030 }
00031 
00032 typedef point4<double> pt4;
00033 
00034 void pointtest::test02()
00035 {
00036   vector< pt4 > v;
00037 
00038   v.push_back( pt4(.2,.5,.3,.7) );
00039   v.push_back( pt4(.7,.5,.8,.9) );
00040   v.push_back( pt4(.3,.4,.8,.183) );
00041   v.push_back( pt4(.3,.01,.2,.1) );
00042 
00043   cout << "Writing points to file." << endl;
00044 
00045   {
00046     ofstream f1("f1.txt");
00047     f1 << v.size() << endl;
00048     for (uint i=0; i<v.size(); ++i)
00049       f1 << v[i] << endl;
00050   }
00051 
00052   cout << "Reading points in from the file." << endl;
00053   vector< pt4 > v2;
00054   {
00055     ifstream f2("f1.txt");
00056     int sz;
00057     f2 >> sz;
00058     pt4 x;
00059     for (int i=0; i<sz; ++i)
00060     {
00061       f2 >> x;  
00062       cout << x << endl;
00063     }
00064   } 
00065 }
00066 
00067 void pointtest::test03()
00068 {
00069   cout << "Testing string serialization" << endl;
00070 
00071   point2<double> p(.3,.5);
00072   string s = p;
00073   cout << "s=" << s << endl;
00074   cout << "Now the inverse" << endl;
00075   point2<double> p2;
00076   p2.serializeInverse(s);
00077   cout << "p2=" << p2 << endl;
00078 
00079   cout << endl << endl;
00080   point3<int> p3(3,-5,12);
00081   s = p3;
00082   cout << "s=" << s << endl;
00083   cout << "Now the inverse" << endl;
00084   point3<int> p4;
00085   p4.serializeInverse(s);
00086   cout << "p4=" << p4 << endl << endl;
00087 
00088 }
00089 
00090 
00091 

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