Skip to content

Commit

Permalink
[space] add isInsideStrict member function to Box class
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Feb 15, 2025
1 parent 3f09cd5 commit 3a60fff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vclib/core/include/vclib/space/complex/grid/abstract_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ class AbstractGrid : public GridType
if (qvv) {
typename GridType::ScalarType maxDist = dist;

const ScalarType cellSize = GridType::length(0);
const ScalarType cellDiagonal = GridType::cellDiagonal();

ScalarType centerDist = cellSize;
ScalarType centerDist = cellDiagonal;
PointType center = boundingBox(*qvv).center();

// we first look just on the cells where the query value lies
Expand All @@ -410,7 +410,7 @@ class AbstractGrid : public GridType
currentIntervalBox.add(GridType::cell(bb.max()));

// looking just on cells where query lies
ScalarType tmp = cellSize;
ScalarType tmp = cellDiagonal;
result = closestInCells(qv, tmp, currentIntervalBox, distFunction);

// we have found (maybe) the closest value contained in the cell(s)
Expand Down Expand Up @@ -451,7 +451,7 @@ class AbstractGrid : public GridType

// update the centerDist for the next loop (after computing the
// end loop condition!!)
centerDist += cellSize;
centerDist += cellDiagonal;
} while (!end);
}

Expand Down Expand Up @@ -803,8 +803,8 @@ class AbstractGrid : public GridType

// for each cell in the interval
for (const KeyType& c :
GridType::cells(interval.min(), interval.max())) {
if (!ignore.isInsideOpenBox(c)) {
GridType::cells(interval.min(), interval.max())) {
if (!ignore.isInsideStrict(c)) {
// p is a pair of iterators
const auto& p =
static_cast<const DerivedGrid*>(this)->valuesInCell(c);
Expand Down
20 changes: 20 additions & 0 deletions vclib/core/include/vclib/space/core/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,26 @@ class Box
return true;
}

/**
* @brief Checks whether a given point is inside the box or not, bounds
* excluded.
*
* A point is considered inside the box if its coordinates are greater than
* the corresponding minimum point and less than the corresponding maximum
* point for each dimension.
*
* @param[in] p: The point to be checked.
* @return True if the point is inside the box, false otherwise.
*/
bool isInsideStrict(const PointT& p) const
{
for (uint i = 0; i < PointT::DIM; ++i) {
if (p[i] <= mMin[i] || p[i] >= mMax[i])
return false;
}
return true;
}

/**
* @brief Checks if a point is inside the open box (max bound excluded);
* e.g. p in [min, max).
Expand Down

0 comments on commit 3a60fff

Please sign in to comment.