meshmorph.h

Go to the documentation of this file.
00001 // Author: Justin Kinney
00002 // Date: Sep 2008
00003 
00004 #ifndef MESHMORPH_H
00005 #define MESHMORPH_H 1
00006 
00007 #include <cmath>
00008 #include <iostream>
00009 
00010 #include <ext/hash_map>
00011 #include <ext/hash_set>
00012 #include <map>
00013 #include <set>
00014 #include <string>
00015 #include <vector>
00016 
00017 class Log;
00018 class Face;
00019 class Edge;
00020 class Nice;
00021 class State;
00022 class Object;
00023 class Vertex;
00024 class Container;
00025 class Controls;
00026 class Refractory;
00027 class Virtual_Disp;
00028 class Gain_Schedule;
00029 class Vertex_Schedule;
00030 class Intersecting_Faces;
00031 
00032 typedef  unsigned long int  u4;   /* unsigned 4-byte type */
00033 typedef  unsigned     char  u1;   /* unsigned 1-byte type */
00034 
00035 struct f_hash
00036 {
00037   u4 operator () (Face* i) const { return (u4) i; }
00038 };
00039 
00040 struct v_hash
00041 {
00042   u4 operator () (Vertex* i) const { return (u4) i; }
00043 };
00044 
00045 struct e_hash
00046 {
00047   u4 operator () (Edge* i) const { return (u4) i; }
00048 };
00049 
00050 typedef std::equal_to<const Face *>     eqf;
00051 typedef std::equal_to<const Edge *>     eqe;
00052 typedef std::equal_to<const Vertex *>   eqv;
00053 
00054 typedef std::less<const Edge *>         lte;
00055 typedef std::less<const Object *>       lto;
00056 typedef std::less<const Vertex *>       ltv;
00057 typedef std::less<const Face *>         ltf;
00058 typedef std::less<const std::string>    lts;
00059 typedef std::less<const double>         ltd;
00060 
00061 typedef std::vector<Vertex>                  vec_v;
00062 typedef std::vector<Vertex>::iterator        v_it;
00063 typedef std::vector<Vertex>::const_iterator  v_cit;
00064 typedef std::vector<Face>                    vec_f;
00065 typedef std::vector<Face>::iterator          f_it;
00066 typedef std::vector<Face>::const_iterator    f_cit;
00067 typedef std::vector<Edge>                    vec_e;
00068 typedef std::vector<Edge>::iterator          e_it;
00069 typedef std::vector<Edge>::const_iterator    e_cit;
00070 typedef std::vector<Object>                  vec_o;
00071 typedef std::vector<Object>::iterator        o_it;
00072 typedef std::vector<Object>::const_iterator  o_cit;
00073 
00074 typedef std::vector<Vertex*>                 vec_vp;
00075 typedef std::vector<Vertex*>::iterator       vp_it;
00076 typedef std::vector<Vertex*>::const_iterator vp_cit;
00077 typedef std::vector<Face*>                   vec_fp;
00078 typedef std::vector<Face*>::iterator         fp_it;
00079 typedef std::vector<Face*>::const_iterator   fp_cit;
00080 typedef std::vector<Edge*>                   vec_ep;
00081 typedef std::vector<Edge*>::iterator         ep_it;
00082 typedef std::vector<Edge*>::const_iterator   ep_cit;
00083 typedef std::vector<Object*>                 vec_op;
00084 typedef std::vector<Object*>::iterator       op_it;
00085 
00086 typedef std::vector<int>                     vec_i;
00087 typedef std::vector<int>::iterator           i_it;
00088 typedef std::vector<double>                  vec_d;
00089 typedef std::vector<double>::iterator        d_it;
00090 typedef std::vector<double>::const_iterator  d_cit;
00091 typedef std::vector<std::string>             vec_s;
00092 
00093 typedef std::set<std::string,lts>            s_set;
00094 typedef std::set<std::string,lts>::iterator  ss_it;
00095 typedef std::set<Edge*,lte>                  e_set;
00096 typedef std::set<Edge*,lte>::iterator        es_it;
00097 typedef std::set<Vertex*,ltv>                v_set;
00098 typedef std::set<Vertex*,ltv>::iterator      vs_it;
00099 typedef std::set<Face*,ltf>                  f_set;
00100 typedef std::set<Face*,ltf>::iterator        fs_it;
00101 
00102 typedef __gnu_cxx::hash_set<Vertex*,v_hash,eqv>                      hashset_v;
00103 typedef std::map<std::string,Edge*,lts>                              map_s_ep;
00104 typedef __gnu_cxx::hash_map<Vertex*,int,v_hash,eqv>                  hmap_v;
00105 typedef __gnu_cxx::hash_map<Vertex*,int,v_hash,eqv>::const_iterator  vhm_cit;
00106 
00107 struct vector3
00108 {
00109   double p[3];
00110   vector3 (void)
00111   {
00112     p[0] = 0.0;
00113     p[1] = 0.0;
00114     p[2] = 0.0;
00115   }
00116   vector3 ( double x, double y, double z)
00117   {
00118     p[0] = x;
00119     p[1] = y;
00120     p[2] = z;
00121   }
00122   vector3& operator= ( const vector3 & v)
00123   {
00124     if (&v != this)
00125     {
00126       p[0] = v.p[0];
00127       p[1] = v.p[1];
00128       p[2] = v.p[2];
00129     }
00130     return *this;
00131   }
00132   vector3& operator+= ( double a )
00133   {
00134     p[0] += a;
00135     p[1] += a;
00136     p[2] += a;
00137     return *this;
00138   }
00139   vector3& operator-= ( double a )
00140   {
00141     p[0] -= a;
00142     p[1] -= a;
00143     p[2] -= a;
00144     return *this;
00145   }
00146   vector3& operator+= ( const vector3 & v )
00147   {
00148     if (&v != this)
00149     {
00150       p[0] += v.p[0];
00151       p[1] += v.p[1];
00152       p[2] += v.p[2];
00153     }
00154     return *this;
00155   }
00156   vector3& operator*= ( double a )
00157   {
00158     p[0] *= a;
00159     p[1] *= a;
00160     p[2] *= a;
00161     return *this;
00162   }
00163   vector3 operator- ( const vector3 & v) const
00164   {
00165     return vector3( p[0] - v.p[0],
00166                     p[1] - v.p[1],
00167                     p[2] - v.p[2] );
00168   }
00169   vector3 operator* ( double a) const
00170   {
00171     return vector3( p[0] * a,
00172                     p[1] * a,
00173                     p[2] * a );
00174   }
00175   vector3 operator+ ( double a) const
00176   {
00177     return vector3( p[0] + a,
00178                     p[1] + a,
00179                     p[2] + a );
00180   }
00181   vector3 operator+ ( const vector3 & v) const
00182   {
00183     return vector3( p[0] + v.p[0],
00184                     p[1] + v.p[1],
00185                     p[2] + v.p[2] );
00186   }
00187   vector3 operator/ ( double a) const
00188   {
00189     vector3 kQuot;
00190 
00191     if (a != 0.0)
00192     {
00193       double fInvScalar = 1.0/a;
00194       kQuot.p[0] = fInvScalar*p[0];
00195       kQuot.p[1] = fInvScalar*p[1];
00196       kQuot.p[2] = fInvScalar*p[2];
00197     }
00198     else
00199     {
00200       kQuot.p[0] = 1E300;
00201       kQuot.p[1] = 1E300;
00202       kQuot.p[2] = 1E300;
00203     }
00204 
00205     return kQuot;
00206   }
00207   double dot ( const vector3 & v) const
00208   {
00209     return p[0]*v.p[0]+p[1]*v.p[1]+p[2]*v.p[2];
00210   }
00211   double length (void) const
00212   {
00213     return sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
00214   }
00215   vector3 cross ( const vector3 & v) const
00216   {
00217     return vector3(p[1]*v.p[2]-p[2]*v.p[1],
00218                    p[2]*v.p[0]-p[0]*v.p[2],
00219                    p[0]*v.p[1]-p[1]*v.p[0]);
00220   }
00221   void print ( std::ostream & target) const
00222   {
00223     target << "["
00224           << p[0] << " "
00225           << p[1] << " "
00226           << p[2] << "]";
00227   }
00228 };
00229 
00230 struct Minmax
00231 {
00232   double const * min;
00233   double const * max;
00234   Minmax (double const * a,double const * b,double const * c)
00235         :min(NULL),max(NULL)
00236   {
00237     if ( *a < *b )
00238     {
00239       // a < b
00240       if ( *a < *c )
00241       {
00242         // a < b
00243         // a < c
00244         if (*b < *c)
00245         {
00246           // a < b
00247           // b < c
00248           // a is smallest
00249           // c is largest
00250           min=a;
00251           max=c;
00252           return;
00253         }
00254         else
00255         {
00256           // a < b
00257           // c <= b
00258           // a is smallest
00259           // b is largest or tied with c
00260           min=a;
00261           max=b;
00262           return;
00263         }
00264       }
00265       else
00266       {
00267         // a < b
00268         // c <= a
00269         // c is smallest or tied with a
00270         // b is largest
00271         min=c;
00272         max=b;
00273         return;
00274       }
00275     }
00276     else
00277     {
00278       // b <= a
00279       if ( *a < *c )
00280       {
00281         // b <= a
00282         // a < c
00283         // b is smallest or tied with a
00284         // c is largest
00285         min=b;
00286         max=c;
00287         return;
00288       }
00289       else
00290       {
00291         // b <= a
00292         // c <= a
00293         if (*b < *c)
00294         {
00295           // b < c
00296           // c <= a
00297           // b is smallest
00298           // a is largest
00299           min=b;
00300           max=a;
00301           return;
00302         }
00303         else
00304         {
00305           // b <= a
00306           // c <= b
00307           // c is smallest
00308           // a is largest
00309           min=c;
00310           max=a;
00311           return;
00312         }
00313       }
00314     }
00315   }
00316 };
00317 
00318 struct result
00319 {
00320   bool line_flag;
00321   bool poly_flag;
00322   bool poly_edge_flag;
00323   result (void)
00324         :line_flag(false),poly_flag(false),poly_edge_flag(false)
00325   {
00326   }
00327 };
00328 
00329 bool distinguishable (double a,double b,double epsilon);
00330 bool distinguishable (double a,double b);
00331 bool checkIntSize   (void);
00332 
00333 #endif

Generated on Fri Feb 13 13:58:10 2009 for meshmorph by  doxygen 1.5.1