Skip to content

Commit

Permalink
abort and show error if a point outside bounding box is encountered.
Browse files Browse the repository at this point in the history
  • Loading branch information
potree committed Oct 5, 2020
1 parent 23fe618 commit da93ec2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
17 changes: 17 additions & 0 deletions Converter/src/chunker_countsort_laszip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,23 @@ namespace chunker_countsort_laszip {
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;

if (!inBox) {
stringstream ss;
ss << "encountered point outside bounding box." << endl;
ss << "box.min: " << min.toString() << endl;
ss << "box.max: " << max.toString() << endl;
ss << "point: " << Vector3(x, y, z).toString() << endl;
ss << "file: " << path << endl;
ss << "PotreeConverter requires a valid bounding box to operate." << endl;
ss << "Please try to repair the bounding box, e.g. using lasinfo with the -repair_bb argument." << endl;
logger::ERROR(ss.str());

exit(123);
}

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
37 changes: 18 additions & 19 deletions Converter/src/indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,36 +1052,35 @@ SoA toStructOfArrays(Node* node, Attributes attributes) {
auto mc_l = mortonEncode_magicbits(mx_l, my_l, mz_l);
auto mc_h = mortonEncode_magicbits(mx_h, my_h, mz_h);

{ // try decode and compare
//{ // try decode and compare

uint32_t x_decoded = 0;
uint32_t y_decoded = 0;
uint32_t z_decoded = 0;
// uint32_t x_decoded = 0;
// uint32_t y_decoded = 0;
// uint32_t z_decoded = 0;

for (int i = 0; i < 21; i++) {
// for (int i = 0; i < 21; i++) {

uint64_t mask = (mc_l >> (3 * i)) & 0b111;
// uint64_t mask = (mc_l >> (3 * i)) & 0b111;

x_decoded = x_decoded | (((mask >> 0) & 0b001) << i);
y_decoded = y_decoded | (((mask >> 1) & 0b001) << i);
z_decoded = z_decoded | (((mask >> 2) & 0b001) << i);
// x_decoded = x_decoded | (((mask >> 0) & 0b001) << i);
// y_decoded = y_decoded | (((mask >> 1) & 0b001) << i);
// z_decoded = z_decoded | (((mask >> 2) & 0b001) << i);


}
// }

bool okayX = x_decoded == mx_l;
bool okayY = y_decoded == my_l;
bool okayZ = z_decoded == mz_l;
// bool okayX = x_decoded == mx_l;
// bool okayY = y_decoded == my_l;
// bool okayZ = z_decoded == mz_l;

if (!okayX || !okayY || !okayZ) {
int a = 10;
// if (!okayX || !okayY || !okayZ) {

cout << "could not revert morton code!!!" << endl;
// cout << "could not revert morton code!!!" << endl;

exit(123);
}
// exit(123);
// }

}
//}


MortonCode mc;
Expand Down
9 changes: 8 additions & 1 deletion testing/testing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ let easyCases = [
input: ["D:/dev/pointclouds/testdata/heidentor.laz"],
output: "D:/temp/test/heidentor.laz",
arguments: [],
},{
input: ["D:/dev/pointclouds/testdata/heidentor_out_of_bounds.laz"],
output: "D:/temp/test/heidentor_out_of_bounds.laz",
arguments: [],
},{
input: ["D:/dev/pointclouds/testdata/heidentor.laz"],
output: "D:/temp/test/heidentor.laz_only_rgb",
Expand Down Expand Up @@ -94,6 +98,7 @@ async function runTestcase(testcase){
testcase.input,
"-o", testcase.output,
...testcase.arguments,
"--encoding", "BROTLI",
];

let strArgs = args.join(" ");
Expand All @@ -103,6 +108,7 @@ async function runTestcase(testcase){

return new Promise(resolve => {

let tStart = Date.now() / 1000.0;
let process = spawn(cmd, args);

process.stdout.on('data', (data) => {
Expand All @@ -115,9 +121,10 @@ async function runTestcase(testcase){

process.on('close', (code) => {
// console.log(`child process exited with code ${code}`);
let duration = Date.now() / 1000.0 - tStart;

if(code === 0){
console.log("SUCCESS!");
console.log(`SUCCESS! duration: ${duration.toFixed(1)}s`);
}else if(code !== 0){
console.error(`ERROR: exited with code ${code}`);
}
Expand Down

0 comments on commit da93ec2

Please sign in to comment.