Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
Util.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 #ifndef MB_UTIL_HPP
17 #define MB_UTIL_HPP
18 
19 #include "moab/MOABConfig.h"
20 #include "moab/Forward.hpp"
21 #include "moab/CartVect.hpp"
22 
23 #include <cmath>
24 #include <limits>
25 //#define moab_isfinite( f ) std::isfinite( f )
26 template<typename T>
27 inline bool moab_isfinite(T x) {
28 #if defined(_MSC_VER) && (_MSC_VER < 1800)
29  // Old MSVC does not support std::isfinite
30  return _finite(static_cast<double>(x)) != 0;
31 #else
32  // Always use the standard C++11 version
33  return std::isfinite(x);
34 #endif
35 }
36 
37 namespace moab
38 {
39 
40 /** \class Util
41  *
42  * \brief Utility functions for computational geometry and mathematical calculations
43  */
44 class Util
45 {
46  public:
47  template < typename T >
48  static bool is_finite( T value );
49 
50  static void normal( Interface* MB, EntityHandle handle, double& x, double& y, double& z );
51 
52  static void centroid( Interface* MB, EntityHandle handle, CartVect& coord );
53 
54  // static void edge_centers(Interface *MB, EntityHandle handle, std::vector<CartVect>
55  // &coords_list);
56 
57  // static void face_centers(Interface *MB, EntityHandle handle, std::vector<CartVect>
58  // &coords_list);
59 
60  private:
61  Util() {}
62 };
63 
64 template < typename T >
65 inline bool Util::is_finite( T value )
66 {
67  return moab_isfinite( (double)value );
68 }
69 
70 } // namespace moab
71 
72 #endif