Definitions.cpp
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2015.
2 // Distributed under the GNU General Public License and under the
3 // BSD 3-Clause License (See accompanying file LICENSE.txt).
4 
5 /** @file */
6 
7 
8 #include <string>
9 #include <cstdlib>
10 #include <iostream>
11 #include <limits>
12 #include <unistd.h>
13 #include <nuklei/Common.h>
14 #include <nuklei/Math.h>
15 
16 namespace nuklei {
17 
18  const std::string INFOSTRING =
19  std::string("Built on " __DATE__ " at " __TIME__) +
20  " with `" + NUKLEI_BUILDTYPE + "' flags.\n"
21  "This application is part of Nuklei http://renaud-detry.net/nuklei\n"
22  "To contact the author, see email at http://renaud-detry.net\n";
23 
24  template<typename T>
25  static T initConst(const char *envVar, T def)
26  {
27  const char * envVal = getenv(envVar);
28  if (envVal != NULL)
29  {
30  T val = numify<T>(envVal);
31 
32  const char * log = getenv("NUKLEI_LOG_LEVEL");
33  if (log != NULL && numify<unsigned>(log) >= Log::INFO)
34  std::cout << "export " << envVar << "=" << val
35  << " #(def: " << def << ").\n";
36  return val;
37  }
38  else
39  return def;
40  }
41 
42 #define defConst(TYPE, VAR, VAL) \
43 const TYPE VAR = initConst<TYPE>("NUKLEI_" #VAR, VAL)
44 
45  const coord_t FLOATTOL = 1e-12;
46 
47  // Default precision in text files.
48  const int PRECISION = std::numeric_limits<double>::digits10 + 2;
49 
50  defConst(bool, KDTREE_DENSITY_EVAL, true);
51  defConst(bool, KDTREE_NANOFLANN, true);
52 
53  defConst(unsigned int, KDE_KTH_NEAREST_NEIGHBOR, 8);
54 
55  // Remember that hue/saturation are projected on a disk of diameter 2.
56  // A value of 1.0 for the following constant already quite lowers its
57  // importance.
58  // Rangoe is [0,1].
59  defConst(appear_t, HSV_METRIC_VALUE_WEIGHT, .6);
60 
61  const int NICEINC = std::numeric_limits<int>::max();
62 
63  defConst(std::string, SERIALIZATION_DEFAULT_OUTPUT_TYPE, "serial");
64  defConst(std::string, SERIALIZATION_DEFAULT_BOOST_ARCHIVE, "bbinc");
65 
66  defConst(unsigned, IMAGE_PROJECTION_RADIUS, 3);
67 
68 #ifdef __APPLE__
69  defConst(std::string, PARALLELIZATION, "single");
70 #else
71  defConst(std::string, PARALLELIZATION, "openmp");
72 #endif
73 
74  defConst(bool, ENABLE_CONSOLE_BACKSPACE, true);
75 
76  defConst(unsigned, LOG_LEVEL, 0);
77 
78  // Should be moved to Log and protected by a mutex, when
79  // ProgressIndicator is used in mt contexts.
80  bool LAST_OUTPUT_LINE_IS_PROGRESS = false;
81 
82  const bool INTERACTIVE_SHELL =
83  isatty(STDIN_FILENO) && isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) &&
84  (getenv("TERM") != NULL) &&
85  (std::string(getenv("TERM")) != "dumb");
86 
87  bool hasOpenMP()
88  {
89 #ifdef _OPENMP
90  return true;
91 #else
92  return false;
93 #endif
94  }
95 
96 #ifdef NDEBUG
97 #warning Compiling with NDEBUG set.
98 #endif
99 }
Public namespace.
Definition: Color.cpp:9
double coord_t
Type for point coordinates.
Definition: Definitions.h:25
double appear_t
Type for appearance-related values (e.g., color)
Definition: Definitions.h:29
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:06.