Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

LevelSetForces.hh

00001 //=============================================================================
00002 //
00003 //  CLASS LevelSetForces
00004 //
00005 //=============================================================================
00006 
00007 
00008 #ifndef ISOEX_LEVELSETFORCES_HH
00009 #define ISOEX_LEVELSETFORCES_HH
00010 
00011 
00012 //== INCLUDES =================================================================
00013 
00014 #include <float.h>
00015 
00016 //== FORWARDDECLARATIONS ======================================================
00017 
00018 //== NAMESPACES ===============================================================
00019 
00020 namespace IsoEx {
00021 
00022 //== CLASS DEFINITION =========================================================
00023 
00024 
00025 struct Erosion
00026 {
00027   Erosion() {}
00028 
00029   float operator()(unsigned int x, unsigned int y, unsigned int z) const
00030   {
00031     return -1.0;
00032   }
00033 };
00034 
00035 
00036 //== CLASS DEFINITION =========================================================
00037 
00038 
00039 struct Dilation
00040 {
00041   Dilation() {}
00042 
00043   float operator()(unsigned int x, unsigned int y, unsigned int z) const
00044   {
00045     return 1.0;
00046   }
00047 };
00048 
00049 
00050 //== CLASS DEFINITION =========================================================
00051 
00052 
00053 template <class LS>
00054 class MeanCurvature 
00055 {
00056 public:
00057 
00058   MeanCurvature(const LS& _ls) : ls_(_ls) {}
00059 
00060   typedef typename LS::_Scalar Scalar;
00061 
00062   Scalar operator()(unsigned int x, unsigned int y, unsigned int z) const
00063   {
00064     Scalar Px = ls_.Dx(x,y,z);
00065     Scalar Py = ls_.Dy(x,y,z);
00066     Scalar Pz = ls_.Dz(x,y,z);
00067 
00068     Scalar Pxx = ls_.Dxx(x,y,z);
00069     Scalar Pyy = ls_.Dyy(x,y,z);
00070     Scalar Pzz = ls_.Dzz(x,y,z);
00071 
00072     Scalar Pxy = ls_.Dxy(x,y,z);
00073     Scalar Pxz = ls_.Dxz(x,y,z);
00074     Scalar Pyz = ls_.Dyz(x,y,z);
00075 
00076     Scalar PxPx = Px*Px;
00077     Scalar PyPy = Py*Py;
00078     Scalar PzPz = Pz*Pz;
00079 
00080     Scalar nom   = ((Pyy+Pzz)*PxPx + (Pxx+Pzz)*PyPy + (Pxx+Pyy)*PzPz 
00081                     - 2.0*(Px*Py*Pxy + Px*Pz*Pxz + Py*Pz*Pyz)); 
00082                      
00083     Scalar denom = pow(PxPx + PyPy + PzPz, 1.5);
00084 
00085     Scalar result = -nom/denom;
00086 
00087     // damping
00088     if (fabs(result) > 1.0) result /= fabs(result);
00089 
00090     return result;
00091   }
00092   
00093 
00094 private:
00095   const LS& ls_;
00096 };
00097 
00098 
00099 //=============================================================================
00100 } // namespace IsoEx
00101 //=============================================================================
00102 #if defined(INCLUDE_TEMPLATES) && !defined(ISOEX_LEVELSETFORCES_C)
00103 #define ISOEX_LEVELSETFORCES_TEMPLATES
00104 #include "LevelSetForces.cc"
00105 #endif
00106 //=============================================================================
00107 #endif // ISOEX_LEVELSETFORCES_HH defined
00108 //=============================================================================
00109 

Generated on Mon Jul 5 18:07:08 2004 for IsoEx by doxygen 1.3.6-20040222