X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCK%2Fhexa_utils.cxx;h=058e8a9d590b31145de9dd8418a452953b61c667;hb=f3d5693095483a5028dc812cee8697096159690b;hp=76a039ebaad20ca237c5fa918b1fae96404fbf93;hpb=ab53385205fe062af0e87d4e14296b1492fe3611;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCK/hexa_utils.cxx b/src/HEXABLOCK/hexa_utils.cxx index 76a039e..058e8a9 100755 --- a/src/HEXABLOCK/hexa_utils.cxx +++ b/src/HEXABLOCK/hexa_utils.cxx @@ -1,12 +1,12 @@ // 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 @@ -104,6 +104,13 @@ double calc_distance (double v1[], double v2[]) 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[]) { @@ -269,4 +276,40 @@ 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