// C++ : Fonctions utilitaires de Hexa
-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2009-2014 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
Real3 vv = { v2[dir_x]-v1[dir_x], v2[dir_y]-v1[dir_y], v2[dir_z]-v1[dir_z] };
return calc_norme (vv);
}
+// ======================================================== calc_d2
+double calc_d2 (double v1[], double v2[])
+{
+ double dd = carre (v2[dir_x]-v1[dir_x]) + carre (v2[dir_y]-v1[dir_y])
+ + carre (v2[dir_z]-v1[dir_z]);
+ return dd;
+}
// ========================================================= calc_vecteur
void calc_vecteur (double pta[], double ptb[], double vab[])
{
vab [dir_y] = ptb [dir_y] - pta [dir_y];
vab [dir_z] = ptb [dir_z] - pta [dir_z];
}
+// ========================================================= copy_vecteur
+void copy_vecteur (double va[], double vb[])
+{
+ vb [dir_x] = va [dir_x];
+ vb [dir_y] = va [dir_y];
+ vb [dir_z] = va [dir_z];
+}
// ========================================================= calc_milieu
void calc_milieu (double pta[], double ptb[], double milieu[])
{
// ====================================================== same_coords
bool same_coords (double* pa, double* pb, double epsilon2)
{
-
double d2 = carre (pb[dir_x]-pa[dir_x]) + carre (pb[dir_y]-pa[dir_y])
+ carre (pb[dir_z]-pa[dir_z]);
return d2 < epsilon2;
buffer = quand;
return buffer.c_str();
}
+// ======================================================== requals
+bool requals (const double v1, const double v2)
+{
+ static const double Epsilon = 1e-6;
+ return v1 >= v2 - Epsilon && v1 <= v2 + Epsilon;
+}
+// ======================================================== requals
+bool requals (const double* lun, const double* lautre)
+{
+ return lun!=NULL && lautre!=NULL && requals (lun [0], lautre [0])
+ && requals (lun [1], lautre [1]) && requals (lun [2], lautre [2]) ;
+}
+// ======================================================== make_basename
+int make_basename (cpchar filename, string& base)
+{
+ const char slash = '/';
+ const char antis = '\\';
+ int lg = strlen (filename);
+ int ifin = -1;
+ int ideb = 0;
+ bool more = true;
+
+ for (int nc = lg-1 ; more && nc>=0 ; --nc)
+ {
+ char car = filename[nc];
+ if (car==slash || car==antis)
+ {
+ if (ifin >0)
+ {
+ ideb = nc + 1;
+ more = false;
+ }
+ }
+ else if (ifin<0)
+ ifin = nc;
+ }
+
+ if (ifin <0)
+ {
+ base = "undefined";
+ return HERR;
+ }
+
+ base = "";
+ for (int nc=ideb ; nc <= ifin ; ++nc)
+ base += filename[nc];
+ return HOK;
+}
END_NAMESPACE_HEXA