Skip to content

Commit

Permalink
added defensive code to prevent bad fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
porterbot committed Jan 17, 2024
1 parent 3c4fb0d commit 0b8e84b
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,28 @@ public void initFilter(Collection<BoundingBox3d> boundingBoxes,
}

boxes = new HashMap<>();
int badfrags = 0;
for (BoundingBox3d boundingBox: boundingBoxes) {
count++;
index.addToIndex(boundingBox);
if (checkBoundingBox(boundingBox)) {
index.addToIndex(boundingBox);
} else {
badfrags++;
}
boxes.put(boundingBox.getDomainId(), boundingBox);
}
log.info("Finished building spatial filter");
log.info("Finished building spatial filter with bad frags count {0}",badfrags);
}

private boolean checkBoundingBox (BoundingBox3d box) {
double[] mins = new double[]{box.getMinX(), box.getMinY(), box.getMinZ()};
double[] maxs = new double[]{box.getMaxX(), box.getMaxY(), box.getMaxZ()};
if (mins.length!=maxs.length)
return false;
if (mins[0]>maxs[0] || mins[1]>maxs[1] || mins[2]>maxs[2]) {
return false;
}
return true;
}

@Override
Expand Down

0 comments on commit 0b8e84b

Please sign in to comment.