diff --git a/doc/stages/readers.draco.rst b/doc/stages/readers.draco.rst new file mode 100644 index 0000000000..8749488df2 --- /dev/null +++ b/doc/stages/readers.draco.rst @@ -0,0 +1,31 @@ +.. _readers.draco: + +readers.draco +============= + +`Draco`_ is a library for compressing and decompressing 3D geometric meshes and +point clouds and was designed and built for compression efficiency and speed. +The code supports compressing points, connectivity information, texture coordinates, +color information, normals, and any other generic attributes associated with geometry. + +Example +-------------------------------------------------------------------------------- + +.. code-block:: json + +[ + { + "type": "readers.draco", + "filename": "color.las" + } +] + +Options +------- + +filename + Input file name. [Required] + +.. include:: reader_opts.rst + +.. _Draco: https://github.com/google/draco \ No newline at end of file diff --git a/doc/stages/writers.draco.rst b/doc/stages/writers.draco.rst new file mode 100644 index 0000000000..bd17dbd1a4 --- /dev/null +++ b/doc/stages/writers.draco.rst @@ -0,0 +1,70 @@ +.. _writers.draco: + +writers.draco +============= + +`Draco`_ is a library for compressing and decompressing 3D geometric meshes and +point clouds and was designed and built for compression efficiency and speed. +The code supports compressing points, connectivity information, texture coordinates, +color information, normals, and any other generic attributes associated with geometry. + +This writer aims to use the encoding feature of the Draco library to compress and +output Draco files. + +Example +-------------------------------------------------------------------------------- + +This example will read in a las file and output a Draco encoded file, with options +to include PDAL dimensions X, Y, and Z as double, and explicitly setting quantization +levels of some of the Draco attributes. + +.. code-block:: json + +[ + { + "type": "readers.las", + "filename": "color.las" + }, + { + "type": "writers.draco", + "filename": "draco.drc", + "dimensions": { + "X": "double", + "Y": "double", + "Z": "double" + }, + "quantization": { + "NORMAL": 8, + "TEX_COORD": 7, + "GENERIC": 6 + } + } +] + +Options +------- + +filename + Output file name. [Required] + +dimensions + A json map of PDAL dimensions to desired data types. Data types must be string + and must be available in `PDAL's Type specification`_. + +quantization + A json map of Draco attributes to desired quantization levels. These levels + must be integers. Default quantization levels are below, and will be + overridden by any values placed in the options. + +..code-block:: json +{ + "POSITION": 11, + "NORMAL": 7, + "TEX_COORD": 10, + "COLOR": 8, + "GENERIC": 8 +} + + + +_PDAL's Type specification: https://github.com/PDAL/PDAL/blob/master/pdal/DimUtil.hpp \ No newline at end of file diff --git a/plugins/draco/io/DracoReader.cpp b/plugins/draco/io/DracoReader.cpp index b83bd1c10a..e8f40af874 100644 --- a/plugins/draco/io/DracoReader.cpp +++ b/plugins/draco/io/DracoReader.cpp @@ -131,10 +131,9 @@ void DracoReader::initialize() void DracoReader::addOneDimension(Dimension::Id id, const draco::PointAttribute* attr, PointLayoutPtr layout, int index, int attNum) { + //find corresponding pdal data type draco::DataType dt = attr->data_type(); - draco::GeometryAttribute::Type dracoAtt = attr->attribute_type(); Dimension::Type pdalType = getPdalType(dt); - int offset = draco::DataTypeLength(dt); //add to pdal layout and dim vector layout->registerDim(id); @@ -146,31 +145,32 @@ void DracoReader::addDimensions(PointLayoutPtr layout) { using namespace draco; - log()->get(LogLevel::Debug) << "draco pc num_attributes: " + log()->get(LogLevel::Debug) << "Number of attributes in point cloud: " << m_pc->num_attributes() << std::endl;; - const GeometryMetadata *metadata = m_pc->GetMetadata(); + //iterate and collect information on draco attributes for (int i=0; i < m_pc->num_attributes(); ++i) { const PointAttribute* attr = m_pc->GetAttributeByUniqueId(i); if (attr == nullptr) throw new pdal_error("Invalid draco attribute configuration"); const AttributeMetadata* attr_metadata = m_pc->GetAttributeMetadataByAttributeId(i); + + //get types DataType dt = attr->data_type(); + Dimension::Type pt = getPdalType(dt); GeometryAttribute::Type at = attr->attribute_type(); int8_t nc = attr->num_components(); - log()->get(LogLevel::Debug) << "named component: " + log()->get(LogLevel::Debug) << "Dimension read: " << GeometryAttribute::TypeToString(at) - << " subcomponents: " << (int)nc << std::endl;; + << ", Data type: " << Dimension::interpretationName(pt) + << std::endl;; std::string name; if (attr_metadata) { - log()->get(LogLevel::Debug) << "number of metadata entries: " - << attr_metadata->num_entries() - << std::endl; attr_metadata->GetEntryString("name", &name); - log()->get(LogLevel::Debug) << "metadata name: " + log()->get(LogLevel::Debug) << " Generic type name: " << name << std::endl; } diff --git a/plugins/draco/io/DracoWriter.cpp b/plugins/draco/io/DracoWriter.cpp index 16868e1e51..45741719b7 100644 --- a/plugins/draco/io/DracoWriter.cpp +++ b/plugins/draco/io/DracoWriter.cpp @@ -210,7 +210,6 @@ void DracoWriter::parseDimensions() void DracoWriter::ready(pdal::BasePointTable &table) { - *m_stream << std::fixed; auto layout = table.layout(); pdal::Dimension::IdList dimensions = layout->dims(); @@ -293,6 +292,7 @@ void DracoWriter::initPointCloud(point_count_t size) { addAttribute(dim.first, dim.second); } + //do the same for generic attributes for (auto &dim: m_genericDims) { addGeneric(dim, 1); @@ -427,6 +427,7 @@ void DracoWriter::write(const PointViewPtr view) draco::Encoder encoder; encoder.SetEncodingMethod(draco::POINT_CLOUD_SEQUENTIAL_ENCODING); + //set quantization levels based on either defaults or user specifications encoder.SetAttributeQuantization(draco::GeometryAttribute::POSITION, m_quant.at("POSITION")); encoder.SetAttributeQuantization(draco::GeometryAttribute::COLOR, m_quant.at("NORMAL")); encoder.SetAttributeQuantization(draco::GeometryAttribute::NORMAL, m_quant.at("TEX_COORD")); diff --git a/scripts/ci/linux/cmake.sh b/scripts/ci/linux/cmake.sh index effe76bcce..ecf56671cf 100755 --- a/scripts/ci/linux/cmake.sh +++ b/scripts/ci/linux/cmake.sh @@ -8,7 +8,7 @@ LDFLAGS="$LDFLAGS -Wl,-rpath-link,$CONDA_PREFIX/lib" cmake .. \ -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \ -DBUILD_PLUGIN_I3S=ON \ -DBUILD_PLUGIN_NITF=ON \ - -DBUILD_PLUGIN_TILEDB=OFF \ + -DBUILD_PLUGIN_TILEDB=ON \ -DBUILD_PLUGIN_ICEBRIDGE=ON \ -DBUILD_PLUGIN_DRACO=ON \ -DBUILD_PLUGIN_HDF=ON \