Salome HOME
Copyright update 2022
[modules/smesh.git] / src / SMESHUtils / SMESH_Octree.cxx
index 483fcf37aa6f5aa3b3d17e1bca5a3a31055d4eef..a9dff0976f34f438ba84d747919dad66206604c4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // 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
@@ -28,6 +28,9 @@
 //
 #include "SMESH_Octree.hxx"
 
+#include <Precision.hxx>
+#include <limits>
+
 //===========================================================================
 /*!
  * Constructor. limit must be provided at tree root construction.
@@ -77,3 +80,25 @@ double SMESH_Octree::maxSize() const
   }
   return 0.;
 }
+
+//================================================================================
+/*!
+ * \brief Change size of a box by a factor; each dimension changes independently of others
+ */
+//================================================================================
+
+void SMESH_Octree::enlargeByFactor( Bnd_B3d* box, double factor ) const
+{
+  if ( !box->IsVoid() )
+  {
+    gp_XYZ halfSize = 0.5 * ( box->CornerMax() - box->CornerMin() );
+    for ( int iDim = 1; iDim <= 3; ++iDim )
+    {
+      double newHSize = factor * halfSize.Coord( iDim );
+      if ( newHSize < std::numeric_limits<double>::min() )
+        newHSize = Precision::Confusion(); // 1.e-7
+      halfSize.SetCoord( iDim, newHSize );
+    }
+    box->SetHSize( halfSize );
+  }
+}