proj home

Files   Classes   Functions   Hierarchy  

d3mincircle.cpp

Go to the documentation of this file.
00001 
00002 #include <triangle.h>
00003 #include <d3tess.h>
00004 #include <d3mincircle.h>
00005 
00006 
00007 
00008 
00009 #define SHOW(x) #x << '=' << (x)
00010 
00011 typedef point2<double> pt2;
00012 typedef point3<double> pt3;
00013 typedef point3<double> const pt3c;
00014 
00015 
00016 d3mincircle::d3mincircle(d3tess & tess_)
00017   : d3minoperator(tess_)
00018 {
00019 }
00020 
00021 
00022 boolc d3mincircle::testifinsidetriangle
00023 (
00024   pt3c & x,
00025   pt3c & p0,
00026   pt3c & p1,
00027   pt3c & p2
00028 ) const
00029 {
00030   triangle< pt2, double > t((pt2)p0,(pt2)p1,(pt2)p2);
00031 
00032   pt2 c0;
00033   double radius;
00034   //t.outercircle(c0,radius);
00035   t.outercircle(radius,c0);
00036 
00037   pt2 x2(x);
00038 
00039   if ((c0-x2).dot() > radius*radius )
00040     return false;
00041 
00042   return true;
00043 }
00044 
00045 boolc d3mincircle::eval(uintc a, uintc b)
00046 {
00047   if (tess.isconvex(a,b)==false)
00048     return false;
00049 
00050   simplexD2linked const & A(tess.vi[a]);
00051   simplexD2linked const & B(tess.vi[b]);
00052 
00053   uint ai = A.niInverse(b);
00054   uint bi = B.niInverse(a);
00055 
00056   uint p[4];
00057   p[0] = A.pi[ai];
00058   p[3] = B.pi[bi];
00059   p[1] = A.pi[(ai+1)%3];
00060   p[2] = A.pi[(ai+2)%3];
00061 
00062   vector<pt3> const & pt(tess.pt);
00063 
00064   if ( testifinsidetriangle(pt[p[3]],pt[p[0]],pt[p[1]],pt[p[2]]) )
00065   {
00066     tess.flip(a,b);
00067     return true;
00068   }
00069   
00070   if ( testifinsidetriangle(pt[p[0]],pt[p[1]],pt[p[2]],pt[p[3]]) )
00071   {
00072 cout << "f2 " << SHOW(a) << " " << SHOW(b) << endl;
00073     tess.flip(a,b);
00074     return true;
00075   }
00076 
00077   return false;
00078 }
00079 

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