Skip to content

Commit

Permalink
Merge pull request #84 from potree/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
m-schuetz committed Dec 30, 2014
2 parents bce135f + e4213f4 commit ded9074
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 22 deletions.
3 changes: 2 additions & 1 deletion PotreeConverter/include/BINPointReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using std::vector;
class BINPointReader : public PointReader{
private:
AABB aabb;
double scale;
string path;
vector<string> files;
vector<string>::iterator currentFile;
Expand All @@ -30,7 +31,7 @@ class BINPointReader : public PointReader{

public:

BINPointReader(string path);
BINPointReader(string path, AABB aabb, double scale);

~BINPointReader();

Expand Down
14 changes: 11 additions & 3 deletions PotreeConverter/include/BINPointWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down
11 changes: 10 additions & 1 deletion PotreeConverter/include/CloudJS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ class CloudJS{
string version;
string octreeDir;
AABB boundingBox;
AABB tightBoundingBox;
OutputFormat outputFormat;
double spacing;
vector<Node> hierarchy;
double scale;

CloudJS(){
version = "1.3";
version = "1.4";
}

string getString(){
Expand All @@ -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;
Expand Down
17 changes: 8 additions & 9 deletions PotreeConverter/include/PotreeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class PotreeWriter{
public:

AABB aabb;
AABB tightAABB;
string path;
float spacing;
int maxLevel;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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 "";
}
Expand All @@ -151,6 +146,9 @@ class PotreeWriter{
if(acceptedBy != NULL){
pointsInMemory++;
numAccepted++;

Vector3<double> position = p.position();
tightAABB.update(position);
}
}

Expand All @@ -167,6 +165,7 @@ class PotreeWriter{
long long numPointsInMemory = 0;
long long numPointsInHierarchy = 0;
cloudjs.hierarchy = vector<CloudJS::Node>();
cloudjs.tightBoundingBox = tightAABB;
list<PotreeWriterNode*> stack;
stack.push_back(root);
while(!stack.empty()){
Expand Down
12 changes: 7 additions & 5 deletions PotreeConverter/src/BINPointReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<float*>(buffer+offset);
point.x = fBuffer[0];
point.y = fBuffer[1];
point.z = fBuffer[2];
int* iBuffer = reinterpret_cast<int*>(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<unsigned char*>(buffer+offset);
point.r = ucBuffer[0];
Expand Down
4 changes: 2 additions & 2 deletions PotreeConverter/src/PotreeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

## 2014.12.30

### 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

### features
Expand Down

0 comments on commit ded9074

Please sign in to comment.