Salome HOME
Switch development flag to 1
[modules/hexablock.git] / src / HEXABLOCK / HexVertex.cxx
index 795c9f0c6870894c2e54a4fe008de9f76cd03589..2a6c778471cb7436b6b0545f8d3a6aa2f72c2bda 100755 (executable)
@@ -1,12 +1,12 @@
 
 //  C++ Les noeuds
 
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2016  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
@@ -30,6 +30,8 @@
 #include "HexVertexShape.hxx"
 #include "HexKas_functions.hxx"
 
+#include <algorithm>
+
 BEGIN_NAMESPACE_HEXA
 
 static bool db =  on_debug ();  // == getenv ("HEXA_DB") > 0
@@ -268,4 +270,32 @@ double Vertex::dist2 (Vertex* other)
                                         + carre (v_z-other->v_z);
    return dist;
 }
+// ========================================================= anaVertices
+void Vertex::anaVertices (Vertices& cont, double pmin[], double pmax[], 
+                                                         double center[])
+{
+    Real3 point;
+    int nbre = cont.size();
+    if (nbre==0)
+       {
+       for (int nc=0 ; nc<DIM3 ; nc++)
+            pmin [nc] = pmax[nc] =  center[nc] = 0;
+       return;
+       }
+
+    cont[0]->getPoint (pmin);
+    cont[0]->getPoint (pmax);
+    for (int nro=1 ; nro<nbre ; ++nro)
+        {
+        cont[nro]->getPoint (point);
+        for (int nc=0 ; nc<DIM3 ; nc++)
+            {
+            pmin [nc] = std::min (pmin[nc], point[nc]);
+            pmax [nc] = std::max (pmax[nc], point[nc]);
+            }
+        }
+
+    for (int nc=0 ; nc<DIM3 ; nc++)
+        center [nc] = (pmin[nc] + pmax[nc])/2;
+}
 END_NAMESPACE_HEXA