Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bounding box check using min/max, not scaled value in [0,1] #634

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions Converter/src/chunker_countsort_laszip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,25 @@ namespace chunker_countsort_laszip {
auto posScale = outputAttributes.posScale;
auto posOffset = outputAttributes.posOffset;

// Scale is the resolution of the point coordinates, and LAZ round coordinates toward closest integer during quantization.
// Half of scale is used as the tolerance value to check if point in the bounding box.
auto tol = posScale / 2.0;

for (int i = 0; i < numToRead; i++) {
int64_t pointOffset = i * bpp;

laszip_read_point(laszip_reader);
laszip_get_coordinates(laszip_reader, coordinates);

{
// transfer las integer coordinates to new scale/offset/box values
double x = coordinates[0];
double y = coordinates[1];
double z = coordinates[2];

int32_t X = int32_t((x - posOffset.x) / posScale.x);
int32_t Y = int32_t((y - posOffset.y) / posScale.y);
int32_t Z = int32_t((z - posOffset.z) / posScale.z);

double ux = (double(X) * posScale.x + posOffset.x - min.x) / size.x;
double uy = (double(Y) * posScale.y + posOffset.y - min.y) / size.y;
double uz = (double(Z) * posScale.z + posOffset.z - min.z) / size.z;

bool inBox = ux >= 0.0 && uy >= 0.0 && uz >= 0.0;
inBox = inBox && ux <= 1.0 && uy <= 1.0 && uz <= 1.0;
const bool inBox =
x > (min.x - tol.x) && x < (max.x + tol.x) &&
y > (min.y - tol.y) && y < (max.y + tol.y) &&
z > (min.z - tol.z) && z < (max.z + tol.z);

if (!inBox) {
stringstream ss;
Expand All @@ -250,6 +247,15 @@ namespace chunker_countsort_laszip {
exit(123);
}

// transfer las integer coordinates to new scale/offset/box values
int32_t X = int32_t((x - posOffset.x) / posScale.x);
int32_t Y = int32_t((y - posOffset.y) / posScale.y);
int32_t Z = int32_t((z - posOffset.z) / posScale.z);

double ux = (double(X) * posScale.x + posOffset.x - min.x) / size.x;
double uy = (double(Y) * posScale.y + posOffset.y - min.y) / size.y;
double uz = (double(Z) * posScale.z + posOffset.z - min.z) / size.z;

int64_t ix = int64_t(std::min(dGridSize * ux, dGridSize - 1.0));
int64_t iy = int64_t(std::min(dGridSize * uy, dGridSize - 1.0));
int64_t iz = int64_t(std::min(dGridSize * uz, dGridSize - 1.0));
Expand Down