smesh/src/SMESHUtils/SMESH_Octree.cxx

80 lines
2.7 KiB
C++
Raw Normal View History

2014-02-20 18:25:37 +06:00
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
2012-08-09 16:03:55 +06:00
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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
2014-02-20 18:25:37 +06:00
// version 2.1 of the License, or (at your option) any later version.
2012-08-09 16:03:55 +06:00
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
2012-12-13 17:41:29 +06:00
// SMESH SMESH_Octree : Octree implementation
2012-08-09 16:03:55 +06:00
// File : SMESH_Octree.cxx
// Created : Tue Jan 16 16:00:00 2007
// Author : Nicolas Geimer & Aur<75>lien Motteux(OCC)
// Module : SMESH
//
#include "SMESH_Octree.hxx"
//===========================================================================
/*!
* Constructor. limit must be provided at tree root construction.
* limit will be deleted by SMESH_Octree.
*/
//===========================================================================
2012-12-13 17:41:29 +06:00
SMESH_Octree::SMESH_Octree (SMESH_TreeLimit* limit): TBaseTree( limit )
2012-08-09 16:03:55 +06:00
{
}
//=================================================================
/*!
2012-12-13 17:41:29 +06:00
* \brief Allocate a bndbox according to childIndex. childIndex is zero based
2012-08-09 16:03:55 +06:00
*/
//=================================================================
2012-12-13 17:41:29 +06:00
Bnd_B3d* SMESH_Octree::newChildBox(int childIndex) const
2012-08-09 16:03:55 +06:00
{
2012-12-13 17:41:29 +06:00
gp_XYZ min = getBox()->CornerMin();
gp_XYZ max = getBox()->CornerMax();
2012-08-09 16:03:55 +06:00
gp_XYZ HSize = (max - min)/2.;
gp_XYZ childHsize = HSize/2.;
2012-12-13 17:41:29 +06:00
gp_XYZ minChild( min.X() + childIndex%2 * HSize.X(),
min.Y() + (childIndex%4)/2 * HSize.Y(),
min.Z() + ( childIndex>=4 ) * HSize.Z());
2012-08-09 16:03:55 +06:00
2012-12-13 17:41:29 +06:00
return new Bnd_B3d(minChild+childHsize,childHsize);
2012-08-09 16:03:55 +06:00
}
//===========================================================================
/*!
* \brief Compute the bigger dimension of my box
*/
//===========================================================================
double SMESH_Octree::maxSize() const
{
2012-12-13 17:41:29 +06:00
if ( getBox() && !getBox()->IsVoid() )
2012-08-09 16:03:55 +06:00
{
2012-12-13 17:41:29 +06:00
gp_XYZ min = getBox()->CornerMin();
gp_XYZ max = getBox()->CornerMax();
2012-08-09 16:03:55 +06:00
gp_XYZ Size = (max - min);
double returnVal = (Size.X()>Size.Y())?Size.X():Size.Y();
return (returnVal>Size.Z())?returnVal:Size.Z();
}
return 0.;
}