-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
// 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
new_elems_right.reserve(nbelems/2+1);
double max_left = -std::numeric_limits<double>::max();
double min_right= std::numeric_limits<double>::max();
- for(int i=0;i<nbelems;i++)
+ for(ConnType i=0;i<nbelems;i++)
{
- int elem;
+ ConnType elem;
if(elems!=0)
elem= elems[i];
else
tmp=0;
if(!new_elems_left.empty())
tmp=&(new_elems_left[0]);
- _left=new BBTreePts(pts, tmp, level+1, (int)new_elems_left.size(),_epsilon);
+ _left=new BBTreePts(pts, tmp, level+1, (ConnType)new_elems_left.size(),_epsilon);
tmp=0;
if(!new_elems_right.empty())
tmp=&(new_elems_right[0]);
- _right=new BBTreePts(pts, tmp, level+1, (int)new_elems_right.size(),_epsilon);
+ _right=new BBTreePts(pts, tmp, level+1, (ConnType)new_elems_right.size(),_epsilon);
}
delete _right;
}
- /*! returns in \a elems the list of elements potentially containing the point pointed to by \a xx
+ /*! returns in \a elem an element potentially containing the point pointed to by \a xx
Contrary to BBTreePts::getElementsAroundPoint the norm 2 is used here.
- \param [in] xx pointer to query point coords
- \param [in] threshold
- \param elems list of elements (given in 0-indexing) intersecting the bounding box
+ \param[in] xx pointer to query point coords
+ \param[in] threshold detection precision
+ \param[out] elem the element intersecting the bounding box
\sa BBTreePts::getElementsAroundPoint
*/
double getElementsAroundPoint2(const double *xx, double threshold, ConnType& elem) const
return _left->getElementsAroundPoint2(xx,threshold,elem);
if(xx[_level%dim]-s>_max_left)
return _right->getElementsAroundPoint2(xx,threshold,elem);
- int eleml,elemr;
+ ConnType eleml,elemr;
double retl=_left->getElementsAroundPoint2(xx,threshold,eleml);
double retr=_right->getElementsAroundPoint2(xx,threshold,elemr);
if(retl<retr)
}
/*! returns in \a elems the list of elements potentially containing the point pointed to by \a xx
- \param xx pointer to query point coords
- \param elems list of elements (given in 0-indexing) intersecting the bounding box
- \sa BBTreePts::getElementsAroundPoint2
- */
+ * ** Infinite norm is used here not norm 2 ! ***
+ *
+ * \param xx pointer to query point coords
+ * \param elems list of elements (given in 0-indexing) intersecting the bounding box
+ * \sa BBTreePts::getElementsAroundPoint2
+ */
void getElementsAroundPoint(const double* xx, std::vector<ConnType>& elems) const
{
// terminal node : return list of elements intersecting bb
const double* const bb_ptr=_pts+_elems[i]*dim;
bool intersects = true;
for(int idim=0;idim<dim;idim++)
- if(std::abs(bb_ptr[idim]-xx[idim])>_epsilon)
- intersects=false;
+ intersects=intersects && (std::abs(bb_ptr[idim]-xx[idim])<=_epsilon);
if(intersects)
elems.push_back(_elems[i]);
}
_right->getElementsAroundPoint(xx,elems);
}
- int size() const
+ ConnType size() const
{
if(_terminal)
return _nbelems;