//=========================================================================== // SISL - SINTEF Spline Library, version 4.5.0. // Definition and interrogation of NURBS curves and surfaces. // // Copyright (C) 2000-2005, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00029 #ifndef AUX2_H_INCLUDED 00030 00031 #include <vector> 00032 using std::vector; 00033 using std::pair; 00034 00035 #include <iostream> 00036 using std::cout; 00037 using std::endl; 00038 00039 #include <stdio.h> 00040 00041 #include "jonvec.h" 00042 00043 00044 #ifdef MICROSOFT 00045 # define CRIT_ERR(stmnt) \ 00046 printf("\nIn file %s, line %d:\n ", __FILE__, __LINE__), \ 00047 (stmnt), printf("\n%d\n", getchar()), exit(0) 00048 #else 00049 # define CRIT_ERR(stmnt) \ 00050 printf("\nIn file %s, line %d:\n ", __FILE__, __LINE__), \ 00051 (stmnt), exit(0) 00052 #endif 00053 00054 #define ASSERT2(a, b) if (!(a)) CRIT_ERR(b) 00055 00056 #ifndef _ERRORMACROS_H 00057 #define _ERRORMACROS_H 00058 00059 #include <exception> 00060 #include <iostream> 00061 00064 #ifdef NVERBOSE // Not verbose mode 00065 # define REPORT 0 00066 # define MESSAGE(x) 0 00067 #else // Verbose mode 00068 # define REPORT cout << "\nIn file " << __FILE__ << ", line " << __LINE__ << endl 00069 # define MESSAGE(x) cout << "\nIn file " << __FILE__ << ", line " << __LINE__ << ": " << x << endl 00070 #endif 00071 00073 #define THROW(x) MESSAGE(x), throw std::exception() 00074 00078 #ifdef NDEBUG // Not in debug mode 00079 # ifndef QTMODE 00080 // 030916: There is a conflict. Hope I don't use ASSERT for anything... 00081 # define ASSERT(x) 00082 # endif 00083 # define ASSERT3(cond, x) 00084 # define ERROR_IF(cond, x) 00085 #else // Debug mode 00086 # ifndef QTMODE 00087 // 030916: There is a conflict. Hope I don't use ASSERT for anything... 00088 # define ASSERT(cond) if (!(cond)) THROW("Assertation \'" #cond "\' failed.") 00089 # endif 00090 # define ASSERT3(cond, x) if (!(cond)) THROW(x) 00091 # define ERROR_IF(cond, x) if (cond) THROW(x) 00092 #endif 00093 00094 00095 #endif // _ERRORMACROS_H 00096 00097 00098 00099 00100 00101 00102 // 00103 // 030102: There are some routines for this in 'aux1.C', but these macros 00104 // are more in line with what is used in the CoCreate project, 00105 // and in sisl. (Just hope there won't be any conflicts...) 00106 // 030116: Ajajaj... Horrible mistake, forgot the max(..., 1)... 00107 // 040411: Legger inn en egen ikke-sisl-relatert variant med spesifisert 00108 // toleranse. 00109 // 00110 00111 #define DEQUALX(a, b, tol) (fabs((a)-(b))<=(tol) * std::max(std::max(fabs(a), fabs(b)), 1.0)) 00112 00113 #define DEQUAL(a, b) (fabs((a)-(b))<=1e-12 * std::max(std::max(fabs(a), fabs(b)), 1.0)) 00114 #define NDEQUAL(a, b) (!DEQUAL(a, b)) 00115 #define DNEQUAL(a, b) (NDEQUAL(a, b)) 00116 #define DLESS(a, b) (((a)<(b)) && (NDEQUAL((a), (b)))) 00117 #define DGREATER(a, b) (((a)>(b)) && (NDEQUAL((a), (b)))) 00118 #define DLESSEQ(a, b) (((a)<(b)) || (DEQUAL((a), (b)))) 00119 #define DGREATEREQ(a, b) (((a)>(b)) || (DEQUAL((a), (b)))) 00120 00121 // 00122 // 030105: For some reason that I'm not completely sure of, some relatively 00123 // simple computations (angles in triangles, 2nd degree equations, 00124 // not very fancy) seem to be riddled with extreme loss of precision. 00125 // (Geos. project, see 'building2.C', 'split_triangle_corner_edge'. 00126 // 00127 #define DEQUAL2(a, b) (fabs((a)-(b))<=1e-8 * std::max(std::max(fabs(a), fabs(b)), 1.0)) 00128 // 030711: The 3-version for floats... 00129 #define DEQUAL3(a, b) (fabs((a)-(b))<=1e-6 * std::max(std::max(fabs(a), fabs(b)), 1.0)) 00130 #define NDEQUAL2(a, b) (!DEQUAL2(a, b)) 00131 #define DNEQUAL2(a, b) (NDEQUAL2(a, b)) 00132 #define DLESSEQ2(a, b) (((a)<(b)) || (DEQUAL2((a), (b)))) 00133 #define DGREATEREQ2(a, b) (((a)>(b)) || (DEQUAL2((a), (b)))) 00134 00135 00136 #define DEQUAL4(a, b) (fabs((a)-(b))<=1e-14 * std::max(std::max(fabs(a), fabs(b)), 1.0)) 00137 00138 00139 00140 00141 00142 #define SQR(a) ((a)*(a)) 00143 00144 #ifndef PI 00145 # define PI 3.1415926535 00146 #endif 00147 00148 #ifndef MIN 00149 # define MIN(a,b) ((a)<(b)? (a):(b)) 00150 #endif 00151 #ifndef MAX 00152 # define MAX(a,b) ((a)>(b)? (a):(b)) 00153 #endif 00154 00155 00156 00157 00158 00159 00160 int eps_equal(const double &a, const double &b); 00161 int eps_less(const double &a, const double &b); 00162 int eps_greater(const double &a, const double &b); 00163 int eps_less_eq(const double &a, const double &b); 00164 int eps_greater_eq(const double &a, const double &b); 00165 00166 void tic(void); 00167 void toc(void); 00168 00169 00170 00171 00172 00173 00174 #define AUX2_H_INCLUDED 00175 #endif
Generated on Tue Sep 21 17:28:53 2010 for SISL by  doxygen 1.6.3