SphereUnion.h
Go to the documentation of this file.
00001 #ifndef __VCGTEST_SPHEREUNION
00002 #define __VCGTEST_SPHEREUNION
00003 
00004 class SphereUnion
00005 {
00006 public:
00007         SphereUnion()
00008         {};
00009 
00010         SphereUnion(const ImplicitSphere &sphere1, const ImplicitSphere &sphere2)
00011         {
00012                 _sphere1 = sphere1; 
00013                 _sphere2 = sphere2;
00014         };
00015 
00016         SphereUnion(const SphereUnion &sphere_union)
00017         {
00018                 _sphere1 = sphere_union._sphere1;
00019                 _sphere2 = sphere_union._sphere2;
00020         }
00021 
00022         SphereUnion& operator=(const SphereUnion &sphere_union)
00023         {
00024                 if (this != &sphere_union)
00025                 {
00026                         _sphere1 = sphere_union._sphere1;
00027                         _sphere2 = sphere_union._sphere2;
00028                 }
00029                 return *this;
00030         }
00031 
00032         bool operator!=(const SphereUnion &sphere_union)
00033         {
00034                 bool comp1 = _sphere1 != sphere_union._sphere1;
00035                 bool comp2 = _sphere2 != sphere_union._sphere2;
00036                 return (comp1 && comp2);
00037         }
00038 
00039         float V(int x, int y, int z)
00040         {
00041                 return vcg::math::Min<float>(_sphere1.V(x, y, z), _sphere2.V(x, y, z));
00042         };
00043 
00044         bool DirectedDistance(const vcg::Point3i &p1, const vcg::Point3i &p2, vcg::Point3f &v, vcg::Point3f &n, float &d)
00045         {
00046                 vcg::Point3f v1, n1;
00047                 vcg::Point3f v2, n2;
00048                 float                            d1, d2;
00049 
00050                 bool ok1 = _sphere1.DirectedDistance(p1, p2, v1, n1, d1);
00051                 bool ok2 = _sphere2.DirectedDistance(p1, p2, v2, n2, d2);
00052 
00053                 if (ok1 && ok2)
00054                 { 
00055                         if (d1 < d2) 
00056                                 ok2 = false; 
00057                         else 
00058                                 ok1 = false; 
00059                 }
00060                 
00061                 if (ok1)
00062                 {
00063                         v = v1;
00064                         n = n1;
00065                         d = d1;
00066                         return true;
00067                 }
00068                 else if (ok2)
00069                 {
00070                         v = v2;
00071                         n = n2;
00072                         d = d2;
00073                         return true;
00074                 }
00075                 else
00076                         return false;
00077         };
00078 
00079 private:
00080         ImplicitSphere _sphere1;
00081         ImplicitSphere _sphere2;
00082 };
00083 
00084 #endif // __VCGTEST_SPHEREUNION


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:36:31