From ad05c5681f6be4605b9d2eb8b5d1f7de9c22ee3d Mon Sep 17 00:00:00 2001 From: mschuetz Date: Sun, 28 Dec 2014 22:12:05 +0100 Subject: [PATCH 1/5] saving coordinates as integers instead of floats; made *.bin the default extension --- PotreeConverter/include/BINPointReader.hpp | 3 ++- PotreeConverter/include/BINPointWriter.hpp | 14 +++++++++++--- PotreeConverter/include/CloudJS.hpp | 11 ++++++++++- PotreeConverter/include/PotreeWriter.h | 16 +++++++--------- PotreeConverter/src/BINPointReader.cpp | 12 +++++++----- PotreeConverter/src/PotreeWriter.cpp | 4 ++-- 6 files changed, 39 insertions(+), 21 deletions(-) diff --git a/PotreeConverter/include/BINPointReader.hpp b/PotreeConverter/include/BINPointReader.hpp index c63cf6d4..5901a1e5 100644 --- a/PotreeConverter/include/BINPointReader.hpp +++ b/PotreeConverter/include/BINPointReader.hpp @@ -21,6 +21,7 @@ using std::vector; class BINPointReader : public PointReader{ private: AABB aabb; + double scale; string path; vector files; vector::iterator currentFile; @@ -30,7 +31,7 @@ class BINPointReader : public PointReader{ public: - BINPointReader(string path); + BINPointReader(string path, AABB aabb, double scale); ~BINPointReader(); diff --git a/PotreeConverter/include/BINPointWriter.hpp b/PotreeConverter/include/BINPointWriter.hpp index 263cea04..8b94d0ad 100644 --- a/PotreeConverter/include/BINPointWriter.hpp +++ b/PotreeConverter/include/BINPointWriter.hpp @@ -25,9 +25,13 @@ class BINPointWriter : public PointWriter{ int numPoints; PointAttributes attributes; ofstream *writer; + AABB aabb; + double scale; - BINPointWriter(string file) { + BINPointWriter(string file, AABB aabb, double scale) { this->file = file; + this->aabb = aabb; + this->scale = scale; numPoints = 0; attributes.add(PointAttribute::POSITION_CARTESIAN); attributes.add(PointAttribute::COLOR_PACKED); @@ -51,8 +55,12 @@ class BINPointWriter : public PointWriter{ for(int i = 0; i < attributes.size(); i++){ PointAttribute attribute = attributes[i]; if(attribute == PointAttribute::POSITION_CARTESIAN){ - float pos[3] = {(float) point.x,(float) point.y,(float) point.z}; - writer->write((const char*)pos, 3*sizeof(float)); + //float pos[3] = {(float) point.x,(float) point.y,(float) point.z}; + int x = (point.x - aabb.min.x) / scale; + int y = (point.y - aabb.min.y) / scale; + int z = (point.z - aabb.min.z) / scale; + int pos[3] = {x, y, z}; + writer->write((const char*)pos, 3*sizeof(int)); }else if(attribute == PointAttribute::COLOR_PACKED){ unsigned char rgba[4] = {point.r, point.g, point.b, 255}; writer->write((const char*)rgba, 4*sizeof(unsigned char)); diff --git a/PotreeConverter/include/CloudJS.hpp b/PotreeConverter/include/CloudJS.hpp index 51116fcc..a5eaecc5 100644 --- a/PotreeConverter/include/CloudJS.hpp +++ b/PotreeConverter/include/CloudJS.hpp @@ -34,13 +34,14 @@ class CloudJS{ string version; string octreeDir; AABB boundingBox; + AABB tightBoundingBox; OutputFormat outputFormat; double spacing; vector hierarchy; double scale; CloudJS(){ - version = "1.3"; + version = "1.4"; } string getString(){ @@ -58,6 +59,14 @@ class CloudJS{ cloudJs << "\t\t" << "\"uy\": " << boundingBox.max.y << "," << endl; cloudJs << "\t\t" << "\"uz\": " << boundingBox.max.z << endl; cloudJs << "\t" << "}," << endl; + cloudJs << "\t" << "\"tightBoundingBox\": {" << endl; + cloudJs << "\t\t" << "\"lx\": " << tightBoundingBox.min.x << "," << endl; + cloudJs << "\t\t" << "\"ly\": " << tightBoundingBox.min.y << "," << endl; + cloudJs << "\t\t" << "\"lz\": " << tightBoundingBox.min.z << "," << endl; + cloudJs << "\t\t" << "\"ux\": " << tightBoundingBox.max.x << "," << endl; + cloudJs << "\t\t" << "\"uy\": " << tightBoundingBox.max.y << "," << endl; + cloudJs << "\t\t" << "\"uz\": " << tightBoundingBox.max.z << endl; + cloudJs << "\t" << "}," << endl; if(outputFormat == OutputFormat::BINARY){ cloudJs << "\t" << "\"pointAttributes\": [" << endl; cloudJs << "\t\t" << "\"POSITION_CARTESIAN\"," << endl; diff --git a/PotreeConverter/include/PotreeWriter.h b/PotreeConverter/include/PotreeWriter.h index f0aca4bd..0857e045 100644 --- a/PotreeConverter/include/PotreeWriter.h +++ b/PotreeConverter/include/PotreeWriter.h @@ -82,6 +82,7 @@ class PotreeWriter{ public: AABB aabb; + AABB tightAABB; string path; float spacing; int maxLevel; @@ -115,12 +116,9 @@ class PotreeWriter{ cloudjs.boundingBox = aabb; cloudjs.octreeDir = "data"; cloudjs.spacing = spacing; - cloudjs.version = "1.3"; + cloudjs.version = "1.4"; cloudjs.scale = scale; - // make bin the default extension but wait until people downloaded the latest potree code - //cloudjs.version = "1.3"; - root = new PotreeWriterNode(this, "r", path, aabb, spacing, 0, maxLevel, scale); } @@ -135,12 +133,9 @@ class PotreeWriter{ return ".las"; }else if(outputFormat == OutputFormat::LAZ){ return ".laz"; + }else if(outputFormat == OutputFormat::BINARY){ + return ".bin"; } - - // make bin the default extension but wait until people downloaded the latest potree code - //else if(outputFormat == OutputFormat::BINARY){ - // return ".bin"; - //} return ""; } @@ -151,6 +146,8 @@ class PotreeWriter{ if(acceptedBy != NULL){ pointsInMemory++; numAccepted++; + + tightAABB.update(p.position()); } } @@ -167,6 +164,7 @@ class PotreeWriter{ long long numPointsInMemory = 0; long long numPointsInHierarchy = 0; cloudjs.hierarchy = vector(); + cloudjs.tightBoundingBox = tightAABB; list stack; stack.push_back(root); while(!stack.empty()){ diff --git a/PotreeConverter/src/BINPointReader.cpp b/PotreeConverter/src/BINPointReader.cpp index 6a9a9167..cf46b9ab 100644 --- a/PotreeConverter/src/BINPointReader.cpp +++ b/PotreeConverter/src/BINPointReader.cpp @@ -19,8 +19,10 @@ using boost::iequals; using std::ios; -BINPointReader::BINPointReader(string path){ +BINPointReader::BINPointReader(string path, AABB aabb, double scale){ this->path = path; + this->aabb = aabb; + this->scale = scale; if(fs::is_directory(path)){ // if directory is specified, find all las and laz files inside directory @@ -89,10 +91,10 @@ bool BINPointReader::readNextPoint(){ for(int i = 0; i < attributes.size(); i++){ const PointAttribute attribute = attributes[i]; if(attribute == PointAttribute::POSITION_CARTESIAN){ - float* fBuffer = reinterpret_cast(buffer+offset); - point.x = fBuffer[0]; - point.y = fBuffer[1]; - point.z = fBuffer[2]; + int* iBuffer = reinterpret_cast(buffer+offset); + point.x = (iBuffer[0] * scale) + aabb.min.x; + point.y = (iBuffer[1] * scale) + aabb.min.y; + point.z = (iBuffer[2] * scale) + aabb.min.z; }else if(attribute == PointAttribute::COLOR_PACKED){ unsigned char* ucBuffer = reinterpret_cast(buffer+offset); point.r = ucBuffer[0]; diff --git a/PotreeConverter/src/PotreeWriter.cpp b/PotreeConverter/src/PotreeWriter.cpp index 30115a20..7a4734dd 100644 --- a/PotreeConverter/src/PotreeWriter.cpp +++ b/PotreeConverter/src/PotreeWriter.cpp @@ -38,7 +38,7 @@ PointReader *PotreeWriterNode::createReader(string path){ if(outputFormat == OutputFormat::LAS || outputFormat == OutputFormat::LAZ){ reader = new LASPointReader(path); }else if(outputFormat == OutputFormat::BINARY){ - reader = new BINPointReader(path); + reader = new BINPointReader(path, aabb, scale); } return reader; @@ -50,7 +50,7 @@ PointWriter *PotreeWriterNode::createWriter(string path, double scale){ if(outputFormat == OutputFormat::LAS || outputFormat == OutputFormat::LAZ){ writer = new LASPointWriter(path, aabb, scale); }else if(outputFormat == OutputFormat::BINARY){ - writer = new BINPointWriter(path); + writer = new BINPointWriter(path, aabb, scale); } return writer; From d5855935f55a67fc3127610835ee191e1741b83d Mon Sep 17 00:00:00 2001 From: Federico Russo Date: Mon, 29 Dec 2014 22:25:09 +0100 Subject: [PATCH 2/5] Fixed a compiler issue in OSX. --- PotreeConverter/include/PotreeWriter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PotreeConverter/include/PotreeWriter.h b/PotreeConverter/include/PotreeWriter.h index 0857e045..da189e95 100644 --- a/PotreeConverter/include/PotreeWriter.h +++ b/PotreeConverter/include/PotreeWriter.h @@ -147,7 +147,8 @@ class PotreeWriter{ pointsInMemory++; numAccepted++; - tightAABB.update(p.position()); + Vector3 position = p.position(); + tightAABB.update(position); } } From 823168f99a4bd4d99eb634d711879479d16f4f23 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Tue, 30 Dec 2014 20:13:24 +0100 Subject: [PATCH 3/5] updated readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed063111..3386bc08 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ Builds a potree octree from las, laz or binary ply files. ## Downloads -* [Windows 64bit binary 2014.12.17 (newest)](http://potree.org/downloads/PotreeConverter/PotreeConverter_2014.12.17.zip) +* [Windows 64bit binary 2014.12.30 (newest)](http://potree.org/downloads/PotreeConverter/PotreeConverter_2014.12.30.zip) +* [Windows 64bit binary 2014.12.17](http://potree.org/downloads/PotreeConverter/PotreeConverter_2014.12.17.zip) * [Windows 64bit binary 2014.11.30](http://potree.org/downloads/PotreeConverter/PotreeConverter_2014.11.30.zip) * [Windows 64bit binary 2014.11.18](http://potree.org/downloads/PotreeConverter/PotreeConverter_2014.11.18.zip) * [Windows 64bit binary 2014.08.31](http://potree.org/downloads/PotreeConverter/PotreeConverter_2014.08.31.zip) From cc9abc324fdfe8af6c7375a8f30ed2d16535d6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=BCtz?= Date: Tue, 30 Dec 2014 20:17:19 +0100 Subject: [PATCH 4/5] Update changelog.md --- docs/changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 7b54b4c4..3e73052c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,4 +1,9 @@ +## 2014.12.30 + +* Updated BINARY format to version 1.4. Coordinates are now stored as integers, rather than floats. Additionaly, a tightBoundingBox is also saved in the cloud.js file. The normal boundingBox specifies the cubic octree bounds whereas the tightBoundingBox specifies the extent of the actual data. + + ## 2014.12.17 ### features From e4213f4f13ec8d065a5cc615b725e3a9dd62e253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=BCtz?= Date: Tue, 30 Dec 2014 20:17:42 +0100 Subject: [PATCH 5/5] Update changelog.md --- docs/changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index 3e73052c..dd07c76f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,8 +1,9 @@ ## 2014.12.30 -* Updated BINARY format to version 1.4. Coordinates are now stored as integers, rather than floats. Additionaly, a tightBoundingBox is also saved in the cloud.js file. The normal boundingBox specifies the cubic octree bounds whereas the tightBoundingBox specifies the extent of the actual data. +### features +* Updated BINARY format to version 1.4. Coordinates are now stored as integers, rather than floats. Additionaly, a tightBoundingBox is also saved in the cloud.js file. The normal boundingBox specifies the cubic octree bounds whereas the tightBoundingBox specifies the extent of the actual data. ## 2014.12.17