vtf-logo

functor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_mesh_simplex_functor_h__)
00009 #define __geom_mesh_simplex_functor_h__
00010 
00011 #include "SimplexJac.h"
00012 
00013 
00014 BEGIN_NAMESPACE_GEOM
00015 
00016 //---------------------------------------------------------------------------
00017 // Determinant.
00018 //---------------------------------------------------------------------------
00019 
00021 template<int N, int M = N, typename T = double>
00022 class SimplexDeterminant : 
00023   public std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> {
00024 private:
00025 
00026   //
00027   // Private types.
00028   //
00029 
00030   typedef std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> Base;
00031 
00032 public:
00033 
00034   //
00035   // Public types.
00036   //
00037 
00039   typedef typename Base::argument_type argument_type;
00041   typedef typename Base::result_type result_type;
00042 
00043 private:
00044 
00045   //
00046   // Member data.
00047   //
00048 
00050   mutable SimplexJac<N,T> _simplexJacobian;
00051 
00052   //
00053   // Constructors.
00054   //
00055 
00056 public:
00057 
00058   // Since the member data is mutable, the constructor, copy constructor,
00059   // and assignment operator are trivial.
00060 
00062   SimplexDeterminant()
00063   {}
00064   
00066   SimplexDeterminant(const SimplexDeterminant& x)
00067   {}
00068 
00070   SimplexDeterminant&
00071   operator=(const SimplexDeterminant& other) {
00072     return *this;
00073   }
00074 
00076   ~SimplexDeterminant()
00077   {}
00078 
00079   //
00080   // Functor.
00081   //
00082 
00084   result_type
00085   operator()(const argument_type& x) const {
00086     _simplexJacobian.setFunction(x);
00087     return _simplexJacobian.getDeterminant();
00088   }
00089 
00090 };
00091 
00092 
00094 template<int N, int M, typename T>
00095 inline
00096 SimplexDeterminant<N,M,T>
00097 simplexDeterminant() {
00098   return SimplexDeterminant<N,M,T>();
00099 }
00100 
00101 
00102 
00103 
00104 //---------------------------------------------------------------------------
00105 // Content.
00106 //---------------------------------------------------------------------------
00107 
00109 template<int N, int M = N, typename T = double>
00110 class SimplexContent : 
00111   public std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> {
00112 private:
00113 
00114   //
00115   // Private types.
00116   //
00117 
00118   typedef std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> Base;
00119 
00120 public:
00121 
00122   //
00123   // Public types.
00124   //
00125 
00127   typedef typename Base::argument_type argument_type;
00129   typedef typename Base::result_type result_type;
00130 
00131 private:
00132 
00133   //
00134   // Member data.
00135   //
00136 
00138   mutable SimplexJac<N,T> _simplexJacobian;
00139 
00140   //
00141   // Constructors.
00142   //
00143 
00144 public:
00145 
00146   // Since the member data is mutable, the constructor, copy constructor,
00147   // and assignment operator are trivial.
00148 
00150   SimplexContent()
00151   {}
00152   
00154   SimplexContent(const SimplexContent& x)
00155   {}
00156 
00158   SimplexContent&
00159   operator=(const SimplexContent& other) {
00160     return *this;
00161   }
00162 
00164   ~SimplexContent()
00165   {}
00166 
00167   //
00168   // Functor.
00169   //
00170 
00172   result_type
00173   operator()(const argument_type& x) const {
00174     _simplexJacobian.setFunction(x);
00175     return _simplexJacobian.computeContent();
00176   }
00177 
00178 };
00179 
00180 
00182 template<int N, int M, typename T>
00183 inline
00184 SimplexContent<N,M,T>
00185 simplexContent() {
00186   return SimplexContent<N,M,T>();
00187 }
00188 
00189 
00190 
00191 
00192 //---------------------------------------------------------------------------
00193 // Minimum edge length.
00194 //---------------------------------------------------------------------------
00195 
00197 template<int N, int M = N, typename T = double>
00198 class SimplexMinimumEdgeLength : 
00199   public std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> {
00200 private:
00201 
00202   //
00203   // Private types.
00204   //
00205 
00206   typedef std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> Base;
00207 
00208 public:
00209 
00210   //
00211   // Public types.
00212   //
00213 
00215   typedef typename Base::argument_type argument_type;
00217   typedef typename Base::result_type result_type;
00218 
00219   //
00220   // Constructors.
00221   //
00222 
00223 public:
00224 
00225   // Since there is no member data, the default constructor, destructor, 
00226   // copy constructor, and assignment operator are sufficient.
00227 
00228   //
00229   // Functor.
00230   //
00231 
00233   result_type
00234   operator()(const argument_type& x) const {
00235     result_type d, minimum = std::numeric_limits<result_type>::max();
00236     // For each edge (pair of vertices).
00237     for (int i = 0; i != M; ++i) {
00238       for (int j = i + 1; j != M + 1; ++j) {
00239         d = geom::computeDistance(x[i], x[j]);
00240         if (d < minimum) {
00241           minimum = d;
00242         }
00243       }
00244     }
00245     return minimum;
00246   }
00247 
00248 };
00249 
00250 
00252 template<int N, int M, typename T>
00253 inline
00254 SimplexMinimumEdgeLength<N,M,T>
00255 simplexMinimumEdgeLength() {
00256   return SimplexMinimumEdgeLength<N,M,T>();
00257 }
00258 
00259 
00260 
00261 
00262 //---------------------------------------------------------------------------
00263 // Maximum edge length.
00264 //---------------------------------------------------------------------------
00265 
00267 template<int N, int M = N, typename T = double>
00268 class SimplexMaximumEdgeLength : 
00269   public std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> {
00270 private:
00271 
00272   //
00273   // Private types.
00274   //
00275 
00276   typedef std::unary_function<geom::Simplex<M, ads::FixedArray<N,T> >, T> Base;
00277 
00278 public:
00279 
00280   //
00281   // Public types.
00282   //
00283 
00285   typedef typename Base::argument_type argument_type;
00287   typedef typename Base::result_type result_type;
00288 
00289   //
00290   // Constructors.
00291   //
00292 
00293 public:
00294 
00295   // Since there is no member data, the default constructor, destructor, 
00296   // copy constructor, and assignment operator are sufficient.
00297 
00298   //
00299   // Functor.
00300   //
00301 
00303   result_type
00304   operator()(const argument_type& x) const {
00305     result_type d, maximum = -std::numeric_limits<result_type>::max();
00306     // For each edge (pair of vertices).
00307     for (int i = 0; i != M; ++i) {
00308       for (int j = i + 1; j != M + 1; ++j) {
00309         d = geom::computeDistance(x[i], x[j]);
00310         if (d > maximum) {
00311           maximum = d;
00312         }
00313       }
00314     }
00315     return maximum;
00316   }
00317 
00318 };
00319 
00320 
00322 template<int N, int M, typename T>
00323 inline
00324 SimplexMaximumEdgeLength<N,M,T>
00325 simplexMaximumEdgeLength() {
00326   return SimplexMaximumEdgeLength<N,M,T>();
00327 }
00328 
00329 END_NAMESPACE_GEOM
00330 
00331 #define __geom_mesh_simplex_functor_ipp__
00332 #include "functor.ipp"
00333 #undef __geom_mesh_simplex_functor_ipp__
00334 
00335 #endif

Generated on Fri Aug 24 12:55:53 2007 for Computational Geometry Package by  doxygen 1.4.7