Original sources of libE57 reference implementation 1.1.332

This commit is contained in:
Michele Adduci
2020-05-30 15:31:35 +02:00
parent 0a219c61a4
commit 5177e09660
6 changed files with 265 additions and 56 deletions

View File

@@ -1,9 +1,11 @@
2013-01-30
2013-04-03 roland_schwarz
e57unpack now also can handle 2d images
2013-01-30 roland_schwarz
added missing library identifier string to cmake build
2011-10-04
2011-10-04 roland_schwarz
update to use boost version 1.46.1
streamlined cmake files for better static linking
2011-03-14
2011-03-14 roland_schwarz
E57RefImplConfig.cmake added
e57validate tool added to cmake
2010-10-16 roland_schwarz

View File

@@ -1,4 +1,4 @@
# $Id: CMakeLists.txt 326 2013-01-30 07:16:58Z roland_schwarz $
# $Id: CMakeLists.txt 332 2013-04-03 14:24:08Z roland_schwarz $
# This is the CMake project file for the libe57 reference implementation
#
# Copyright 2010-2012 Roland Schwarz, Riegl LMS GmbH
@@ -24,6 +24,18 @@
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# Requirements:
# Xerces library: http://xerces.apache.org/
# Boost library: http://www.boost.org
# Notes:
# Since there is not standard cmake module to find the xerces library
# we provide one with this distribution. It should be able to find
# the library from the XERCES_ROOT cmake variable. Standard layout, as
# with the binary packages from apache is assumed.
# If you find any errors or have suggestion to improve the build script:
# patches are most welcome! Please send them to the development mailing list.
cmake_minimum_required(VERSION 2.8.2)

View File

@@ -1,4 +1,4 @@
# $Id: CMakeLists.txt 298 2012-04-04 14:37:40Z roland_schwarz $
# $Id: CMakeLists.txt 332 2013-04-03 14:24:08Z roland_schwarz $
# This is the CMake project file for the libe57 reference implementation
#
# Copyright 2010 Roland Schwarz, Riegl LMS GmbH
@@ -50,7 +50,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(T_ ${T_}-${${PROJECT_NAME}_MAJOR_VERSION})
set(T_ ${T_}.${${PROJECT_NAME}_MINOR_VERSION})
set(T_ ${T_}.${${PROJECT_NAME}_BUILD_VERSION})
set(T_ ${T_}-${${PROJECT_NAME}_BUILD_TAG})
# set(T_ ${T_}-${${PROJECT_NAME}_BUILD_TAG})
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${T_}
CACHE PATH
"Install path prefix, prepended onto install directories."

View File

@@ -1,4 +1,4 @@
# $Id: CMakeLists.txt 287 2012-04-03 12:17:51Z roland_schwarz $
# $Id: CMakeLists.txt 332 2013-04-03 14:24:08Z roland_schwarz $
# This is the CMake project file for the libe57 reference implementation
#
# Copyright 2010 Roland Schwarz, Riegl LMS GmbH
@@ -69,7 +69,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(T_ ${T_}-${${PROJECT_NAME}_MAJOR_VERSION})
set(T_ ${T_}.${${PROJECT_NAME}_MINOR_VERSION})
set(T_ ${T_}.${${PROJECT_NAME}_BUILD_VERSION})
set(T_ ${T_}-${${PROJECT_NAME}_BUILD_TAG})
# set(T_ ${T_}-${${PROJECT_NAME}_BUILD_TAG})
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${T_}
CACHE PATH
"Install path prefix, prepended onto install directories."

View File

@@ -1,2 +1,11 @@
#define E57_REFIMPL_REVISION_ID "E57RefImpl-@E57RefImpl_MAJOR_VERSION@.@E57RefImpl_MINOR_VERSION@.@E57RefImpl_BUILD_VERSION@-@E57RefImpl_BUILD_TAG@"
#ifndef CONFIG_H
#define CONFIG_H
#ifndef E57_REFIMPL_REVISION_ID
# define E57_REFIMPL_REVISION_ID "E57RefImpl-@E57RefImpl_MAJOR_VERSION@.@E57RefImpl_MINOR_VERSION@.@E57RefImpl_BUILD_VERSION@-@E57RefImpl_BUILD_TAG@"
#endif
#define SVN_VERSION @E57RefImpl_BUILD_VERSION@
#endif /* CONFIG_H */

View File

@@ -1,6 +1,8 @@
// $Id: e57unpack.cpp 246 2011-10-06 08:01:00Z roland_schwarz $
// $Id: e57unpack.cpp 332 2013-04-03 14:24:08Z roland_schwarz $
#include <config.h>
#define PROGRAM_NAME "e57unpack"
#define PROGRAM_VERSION "0.1"
#define PROGRAM_VERSION "1.0"
#ifndef SVN_VERSION
#define SVN_VERSION unknown
#endif
@@ -8,7 +10,6 @@
#define STRING_HELPER1(a) STRING_HELPER2(a)
#define BUILD_VERSION STRING_HELPER1(SVN_VERSION)
#include <E57Foundation.h>
using e57::Node;
using e57::ImageFile;
@@ -28,12 +29,15 @@ using e57::SourceDestBuffer;
using e57::CompressedVectorReader;
using e57::int64_t;
using e57::uint64_t;
using e57::uint8_t;
#include <iostream>
using std::cout;
using std::cerr;
using std::endl;
using std::ostream;
using std::ios_base;
using std::streamsize;
#include <exception>
using std::exception;
@@ -54,6 +58,9 @@ using std::string;
#include <vector>
using std::vector;
#include <limits>
using std::numeric_limits;
#include <boost/config.hpp>
#include <boost/program_options.hpp>
@@ -83,6 +90,9 @@ using boost::format;
using boost::io::too_many_args_bit;
using boost::io::all_error_bits;
#include <boost/lexical_cast.hpp>
using boost::lexical_cast;
variables_map opt;
void
@@ -110,7 +120,7 @@ print_help(
) {
cout
<< "Usage:\n"
<< PROGRAM_NAME" [options] e57-file\n"
<< PROGRAM_NAME" [options] e57-file [unpack-directory]\n"
<< " The purpose of this program is to break the e57 file into\n"
<< " parts.\n"
<< endl
@@ -132,20 +142,6 @@ public:
};
path
path_from_guid(
string guid
) {
string name;
for (string::iterator s = guid.begin(); s != guid.end(); ++s) {
if (portable_directory_name(string(1,*s)))
name += *s;
else
name += "_";
}
return path(name);
}
int
main(
int argc
@@ -180,6 +176,14 @@ main(
, "the destination directory\n"
" (--dst may be omitted)"
)
(
"no-images"
, "supress image output"
)
(
"no-points"
, "supress pointcloud output"
)
;
positional_options_description positional;
@@ -214,16 +218,38 @@ main(
path dst;
if (opt.count("dst"))
dst = path_from_guid(opt["dst"].as<string>());
else
dst = path_from_guid(StringNode(root.get("guid")).value());
dst = path(opt["dst"].as<string>());
else {
dst = path(opt["src"].as<string>());
dst.replace_extension();
}
create_directories(dst);
if (root.isDefined("data3D")) {
ofstream root_inf(dst/"root.inf");
root_inf << "formatName = " << StringNode(root.get("formatName")).value() << endl;
root_inf << "guid = " << StringNode(root.get("guid")).value() << endl;
root_inf << "versionMajor = " << IntegerNode(root.get("versionMajor")).value() << endl;
root_inf << "versionMinor = " << IntegerNode(root.get("versionMinor")).value() << endl;
if (root.isDefined("e57LibraryVersion")) {
root_inf << "e57LibraryVersion = " << StringNode(root.get("e57LibraryVersion")).value() << endl;
}
if (root.isDefined("coordinateMetadata")) {
root_inf << "coordinateMetadata = " << StringNode(root.get("coordinateMetadata")).value() << endl;
}
if (root.isDefined("creationDateTime")) {
StructureNode t(root.get("creationDateTime"));
root_inf << format("creationDateTime.dateTimeValue = %.15g\n") % FloatNode(t.get("dateTimeValue")).value();
if (t.isDefined("isAtomicClockReferenced")) {
root_inf << "creationDateTime.isAtomicClockReferenced = " << IntegerNode(t.get("isAtomicClockReferenced")).value() << endl;
}
}
root_inf.close();
if (root.isDefined("data3D") && !opt.count("no-points")) {
VectorNode data3D(root.get("data3D"));
for (int64_t i=0; i<data3D.childCount(); ++i) {
StructureNode scan(data3D.get(i));
for (int64_t child=0; child<data3D.childCount(); ++child) {
StructureNode scan(data3D.get(child));
CompressedVectorNode points(scan.get("points"));
StructureNode prototype(points.prototype());
vector<SourceDestBuffer> sdb;
@@ -232,25 +258,27 @@ main(
string pointrecord;
string comma;
for (int64_t i=0; i<prototype.childCount(); ++i) {
switch(prototype.get(i).type()) {
case e57::E57_FLOAT:
case e57::E57_SCALED_INTEGER:
buf.push_back(vector<double>(buf_size));
if (!opt.count("format"))
fmt += comma +"%g";
break;
case e57::E57_INTEGER:
buf.push_back(vector<int64_t>(buf_size));
if (!opt.count("format"))
fmt += comma +"%d";
break;
if (!opt.count("format")) {
fmt.clear();
for (int64_t i=0; i<prototype.childCount(); ++i) {
switch(prototype.get(i).type()) {
case e57::E57_FLOAT:
case e57::E57_SCALED_INTEGER:
buf.push_back(vector<double>(buf_size));
if (!opt.count("format"))
fmt += comma +"%."+lexical_cast<string>(numeric_limits<double>::digits10)+"g";
break;
case e57::E57_INTEGER:
buf.push_back(vector<int64_t>(buf_size));
if (!opt.count("format"))
fmt += comma +"%d";
break;
}
if (comma.empty()) comma = ",";
}
if (comma.empty()) comma = ",";
}
comma.clear();
for (size_t i=0; i<prototype.childCount(); ++i) {
for (int i=0; i<prototype.childCount(); ++i) {
Node n(prototype.get(i));
pointrecord += comma + n.elementName();
if (comma.empty()) comma = ",";
@@ -288,14 +316,74 @@ main(
}
ofstream inf(
dst/path_from_guid(StringNode(scan.get("guid")).value()+".inf")
dst/path(string("image3d-")+lexical_cast<string>(child)+".inf")
);
inf << "pointrecord: " << pointrecord << endl;
inf << "format: " << fmt << endl;
inf << "pointrecord = " << pointrecord << endl; // can be used as a header line for the csv file
inf << "pointrecord.format = " << fmt << endl;
if (scan.isDefined("name")) {
inf << "name = " << StringNode(scan.get("name")).value() << endl;
}
inf << "guid = " << StringNode(scan.get("guid")).value() << endl;
if (scan.isDefined("description")) {
inf << "description = " << StringNode(scan.get("description")).value() << endl;
}
if (scan.isDefined("pose")) {
StructureNode pose(scan.get("pose"));
StructureNode translation(pose.get("translation"));
StructureNode rotation(pose.get("rotation"));
inf << "pose.translation.x = " << FloatNode(translation.get("x")).value() << endl;
inf << "pose.translation.y = " << FloatNode(translation.get("y")).value() << endl;
inf << "pose.translation.z = " << FloatNode(translation.get("z")).value() << endl;
inf << "pose.rotation.w = " << FloatNode(rotation.get("w")).value() << endl;
inf << "pose.rotation.x = " << FloatNode(rotation.get("x")).value() << endl;
inf << "pose.rotation.y = " << FloatNode(rotation.get("y")).value() << endl;
inf << "pose.rotation.z = " << FloatNode(rotation.get("z")).value() << endl;
}
if (scan.isDefined("acquisitionStart")) {
StructureNode t(scan.get("acquisitionStart"));
inf << format("acquisitionStart.dateTimeValue = %.15g\n") % FloatNode(t.get("dateTimeValue")).value();
if (t.isDefined("isAtomicClockReferenced")) {
inf << "acquisitionStart.isAtomicClockReferenced = " << IntegerNode(t.get("isAtomicClockReferenced")).value() << endl;
}
}
if (scan.isDefined("acquisitionEnd")) {
StructureNode t(scan.get("acquisitionEnd"));
inf << format("acquisitionEnd.dateTimeValue = %.15g\n") % FloatNode(t.get("dateTimeValue")).value();
if (t.isDefined("isAtomicClockReferenced")) {
inf << "acquisitionEnd.isAtomicClockReferenced = " << IntegerNode(t.get("isAtomicClockReferenced")).value() << endl;
}
}
if (scan.isDefined("sensorVendor")) {
inf << "sensorVendor = " << StringNode(scan.get("sensorVendor")).value() << endl;
}
if (scan.isDefined("sensorModel")) {
inf << "sensorModel = " << StringNode(scan.get("sensorModel")).value() << endl;
}
if (scan.isDefined("sensorSerialNumber")) {
inf << "sensorSerialNumber = " << StringNode(scan.get("sensorSerialNumber")).value() << endl;
}
if (scan.isDefined("HardwareVersion")) {
inf << "HardwareVersion = " << StringNode(scan.get("HardwareVersion")).value() << endl;
}
if (scan.isDefined("SoftwareVersion")) {
inf << "SoftwareVersion = " << StringNode(scan.get("SoftwareVersion")).value() << endl;
}
if (scan.isDefined("FirmwareVersion")) {
inf << "FirmwareVersion = " << StringNode(scan.get("FirmwareVersion")).value() << endl;
}
if (scan.isDefined("temperature")) {
inf << "temperature = " << FloatNode(scan.get("temperature")).value() << endl;
}
if (scan.isDefined("relativeHumidity")) {
inf << "relativeHumidity = " << FloatNode(scan.get("relativeHumidity")).value() << endl;
}
if (scan.isDefined("atmosphericPressure")) {
inf << "atmosphericPressure = " << FloatNode(scan.get("atmosphericPressure")).value() << endl;
}
inf.close();
CompressedVectorReader rd(points.reader(sdb));
path csvname(path_from_guid(StringNode(scan.get("guid")).value()+".csv"));
path csvname(string("image3d-")+lexical_cast<string>(child)+".csv");
ofstream ocsv(dst/csvname);
ostream& out(ocsv); // needed to fix ambiguity for << operator on msvc
cout << "unpacking: " << dst/csvname << " ... ";
@@ -318,9 +406,107 @@ main(
}
}
if (root.isDefined("cameraImages")) {
VectorNode cameraImages(root.get("cameraImages"));
cout << "unpacking of cameraImages not supported yet." << endl;
if (root.isDefined("images2D") && !opt.count("no-images")) {
VectorNode images2D(root.get("images2D"));
for (int64_t child=0; child<images2D.childCount(); ++child) {
StructureNode image(images2D.get(child));
path inf_path = dst/path(string("image2d-")+lexical_cast<string>(child)+".inf");
ofstream inf(inf_path);
string reptype;
if (image.isDefined("visualReferenceRepresentation"))
reptype = "visualReferenceRepresentation";
else if (image.isDefined("pinholeRepresentation"))
reptype = "pinholeRepresentation";
else if (image.isDefined("sphericalRepresentation"))
reptype = "sphericalRepresentation";
else if (image.isDefined("cylindricalRepresentation"))
reptype = "cylindricalRepresentation";
StructureNode rep(image.get(reptype));
string imgtype;
path img_path(dst/path(string("image2d-")+lexical_cast<string>(child)+".img"));
if (rep.isDefined("jpegImage")) {
img_path.replace_extension(".jpg");
imgtype = "jpegImage";
}
else if (rep.isDefined("pngImage")) {
img_path.replace_extension(".png");
imgtype = "pngImage";
}
// extract image blob
BlobNode blob(rep.get(imgtype));
ofstream img(img_path, ios_base::out|ios_base::binary);
const streamsize buffer_size = 1024*1024;
vector<uint8_t> buffer(buffer_size);
int64_t offset = 0;
int64_t remaining = blob.byteCount();
size_t get;
cout << "unpacking: " << img_path << " ... ";
while(img && remaining > 0) {
get = (remaining > buffer_size)?buffer_size:remaining;
blob.read(&buffer[0], offset, get);
img.write(reinterpret_cast<char*>(&buffer[0]), get);
offset += get;
remaining -= get;
}
img.close();
// extract meta data
inf << "guid = " << StringNode(image.get("guid")).value() << endl;
if (image.isDefined("name")) {
inf << "name = " << StringNode(image.get("name")).value() << endl;
}
if (image.isDefined("description")) {
inf << "description = " << StringNode(image.get("description")).value() << endl;
}
if (image.isDefined("sensorVendor")) {
inf << "sensorVendor = " << StringNode(image.get("sensorVendor")).value() << endl;
}
if (image.isDefined("sensorModel")) {
inf << "sensorModel = " << StringNode(image.get("sensorModel")).value() << endl;
}
if (image.isDefined("sensorSerialNumber")) {
inf << "sensorSerialNumber = " << StringNode(image.get("sensorSerialNumber")).value() << endl;
}
if (image.isDefined("pose")) {
StructureNode pose(image.get("pose"));
StructureNode translation(pose.get("translation"));
StructureNode rotation(pose.get("rotation"));
inf << "pose.translation.x = " << FloatNode(translation.get("x")).value() << endl;
inf << "pose.translation.y = " << FloatNode(translation.get("y")).value() << endl;
inf << "pose.translation.z = " << FloatNode(translation.get("z")).value() << endl;
inf << "pose.rotation.w = " << FloatNode(rotation.get("w")).value() << endl;
inf << "pose.rotation.x = " << FloatNode(rotation.get("x")).value() << endl;
inf << "pose.rotation.y = " << FloatNode(rotation.get("y")).value() << endl;
inf << "pose.rotation.z = " << FloatNode(rotation.get("z")).value() << endl;
}
if (rep.isDefined("imageHeight")) {
inf << reptype+".imageHeight = " << IntegerNode(rep.get("imageHeight")).value() << endl;
cout << IntegerNode(rep.get("imageHeight")).value() << " x ";
}
if (rep.isDefined("imageWidth")) {
inf << reptype+".imageWidth = " << IntegerNode(rep.get("imageWidth")).value() << endl;
cout << IntegerNode(rep.get("imageWidth")).value() << " pixels" << endl;
}
if (rep.isDefined("focalLength")) {
inf << reptype+".focalLength = " << FloatNode(rep.get("focalLength")).value() << endl;
}
if (rep.isDefined("pixelWidth")) {
inf << reptype+".pixelWidth = " << FloatNode(rep.get("pixelWidth")).value() << endl;
}
if (rep.isDefined("pixelHeight")) {
inf << reptype+".pixelHeight = " << FloatNode(rep.get("pixelHeight")).value() << endl;
}
if (rep.isDefined("principalPointX")) {
inf << reptype+".principalPointX = " << FloatNode(rep.get("principalPointX")).value() << endl;
}
if (rep.isDefined("principalPointY")) {
inf << reptype+".principalPointY = " << FloatNode(rep.get("principalPointY")).value() << endl;
}
if (rep.isDefined("radius")) {
inf << reptype+".radius = " << FloatNode(rep.get("radius")).value() << endl;
}
inf.close();
}
}
return 0;