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 <math.h>
24 #if defined MOAB_HAVE_ISFINITE
25 #define moab_isfinite(f) isfinite(f)
26 #elif defined MOAB_HAVE_STDISFINITE
27 #include <cmath>
28 #define moab_isfinite(f) std::isfinite(f)
29 #elif defined MOAB_HAVE_FINITE
30 #define moab_isfinite(f) finite(f)
31 #else
32 #define moab_isfinite(f) (!isinf(f) && !isnan(f))
33 #endif
34 
35 namespace moab {
36 
37 /** \class Util
38  *
39  * \brief Utility functions for computational geometry and mathematical calculations
40  */
41 class Util
42 {
43 public:
44 
45   template <typename T>
46   static bool is_finite(T value);
47 
48   static void normal(Interface* MB, EntityHandle handle, double& x, double& y, double& z);
49 
50   static void centroid(Interface *MB, EntityHandle handle,CartVect &coord);
51 
52   //static void edge_centers(Interface *MB, EntityHandle handle, std::vector<CartVect> &coords_list);
53 
54   //static void face_centers(Interface *MB, EntityHandle handle, std::vector<CartVect> &coords_list);
55 
56 private:
57 
Util()58   Util(){}
59 
60 };
61 
62 template <typename T>
63 inline
is_finite(T value)64 bool Util::is_finite(T value)
65 {
66   return moab_isfinite(value);
67 }
68 
69 } // namespace moab
70 
71 #endif
72