dracox 0.0.1__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bin/draco_decoder.exe +0 -0
- bin/draco_encoder.exe +0 -0
- dracox/__init__.py +252 -0
- dracox/dracox_ext.cp39-win_amd64.pyd +0 -0
- dracox-0.0.1.dist-info/METADATA +14 -0
- dracox-0.0.1.dist-info/RECORD +214 -0
- dracox-0.0.1.dist-info/WHEEL +5 -0
- include/draco/animation/keyframe_animation.h +107 -0
- include/draco/animation/keyframe_animation_decoder.h +34 -0
- include/draco/animation/keyframe_animation_encoder.h +39 -0
- include/draco/attributes/attribute_octahedron_transform.h +81 -0
- include/draco/attributes/attribute_quantization_transform.h +102 -0
- include/draco/attributes/attribute_transform.h +76 -0
- include/draco/attributes/attribute_transform_data.h +71 -0
- include/draco/attributes/attribute_transform_type.h +30 -0
- include/draco/attributes/geometry_attribute.h +541 -0
- include/draco/attributes/geometry_indices.h +54 -0
- include/draco/attributes/point_attribute.h +196 -0
- include/draco/compression/attributes/attributes_decoder.h +97 -0
- include/draco/compression/attributes/attributes_decoder_interface.h +62 -0
- include/draco/compression/attributes/attributes_encoder.h +154 -0
- include/draco/compression/attributes/kd_tree_attributes_decoder.h +50 -0
- include/draco/compression/attributes/kd_tree_attributes_encoder.h +51 -0
- include/draco/compression/attributes/kd_tree_attributes_shared.h +28 -0
- include/draco/compression/attributes/linear_sequencer.h +51 -0
- include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h +58 -0
- include/draco/compression/attributes/normal_compression_utils.h +372 -0
- include/draco/compression/attributes/point_d_vector.h +288 -0
- include/draco/compression/attributes/points_sequencer.h +63 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +236 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +413 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h +34 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h +72 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h +46 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h +46 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +176 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +180 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +117 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h +96 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +128 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +133 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +111 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h +78 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +372 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +318 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +143 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +136 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h +282 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h +194 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h +53 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h +65 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h +65 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h +69 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h +134 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h +55 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h +77 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h +85 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h +60 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h +118 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h +116 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h +102 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h +115 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h +105 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h +88 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h +81 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h +120 -0
- include/draco/compression/attributes/sequential_attribute_decoder.h +86 -0
- include/draco/compression/attributes/sequential_attribute_decoders_controller.h +61 -0
- include/draco/compression/attributes/sequential_attribute_encoder.h +134 -0
- include/draco/compression/attributes/sequential_attribute_encoders_controller.h +115 -0
- include/draco/compression/attributes/sequential_integer_attribute_decoder.h +76 -0
- include/draco/compression/attributes/sequential_integer_attribute_encoder.h +67 -0
- include/draco/compression/attributes/sequential_normal_attribute_decoder.h +83 -0
- include/draco/compression/attributes/sequential_normal_attribute_encoder.h +82 -0
- include/draco/compression/attributes/sequential_quantization_attribute_decoder.h +52 -0
- include/draco/compression/attributes/sequential_quantization_attribute_encoder.h +52 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h +43 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h +54 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h +61 -0
- include/draco/compression/bit_coders/direct_bit_decoder.h +89 -0
- include/draco/compression/bit_coders/direct_bit_encoder.h +89 -0
- include/draco/compression/bit_coders/folded_integer_bit_decoder.h +77 -0
- include/draco/compression/bit_coders/folded_integer_bit_encoder.h +82 -0
- include/draco/compression/bit_coders/rans_bit_decoder.h +55 -0
- include/draco/compression/bit_coders/rans_bit_encoder.h +57 -0
- include/draco/compression/bit_coders/symbol_bit_decoder.h +36 -0
- include/draco/compression/bit_coders/symbol_bit_encoder.h +36 -0
- include/draco/compression/config/compression_shared.h +155 -0
- include/draco/compression/config/decoder_options.h +34 -0
- include/draco/compression/config/draco_options.h +249 -0
- include/draco/compression/config/encoder_options.h +101 -0
- include/draco/compression/config/encoding_features.h +39 -0
- include/draco/compression/decode.h +80 -0
- include/draco/compression/draco_compression_options.h +141 -0
- include/draco/compression/encode.h +139 -0
- include/draco/compression/encode_base.h +131 -0
- include/draco/compression/entropy/ans.h +526 -0
- include/draco/compression/entropy/rans_symbol_coding.h +53 -0
- include/draco/compression/entropy/rans_symbol_decoder.h +171 -0
- include/draco/compression/entropy/rans_symbol_encoder.h +290 -0
- include/draco/compression/entropy/shannon_entropy.h +110 -0
- include/draco/compression/entropy/symbol_decoding.h +29 -0
- include/draco/compression/entropy/symbol_encoding.h +47 -0
- include/draco/compression/expert_encode.h +160 -0
- include/draco/compression/mesh/mesh_decoder.h +68 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder.h +54 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +228 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h +47 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder.h +73 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h +209 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h +57 -0
- include/draco/compression/mesh/mesh_edgebreaker_shared.h +129 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +201 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +139 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h +134 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +172 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +219 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +226 -0
- include/draco/compression/mesh/mesh_encoder.h +84 -0
- include/draco/compression/mesh/mesh_sequential_decoder.h +39 -0
- include/draco/compression/mesh/mesh_sequential_encoder.h +56 -0
- include/draco/compression/mesh/traverser/depth_first_traverser.h +172 -0
- include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h +226 -0
- include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h +76 -0
- include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h +113 -0
- include/draco/compression/mesh/traverser/traverser_base.h +87 -0
- include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +369 -0
- include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +372 -0
- include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h +141 -0
- include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h +126 -0
- include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h +34 -0
- include/draco/compression/point_cloud/algorithms/point_cloud_types.h +76 -0
- include/draco/compression/point_cloud/algorithms/quantize_points_3.h +84 -0
- include/draco/compression/point_cloud/algorithms/queuing_policy.h +75 -0
- include/draco/compression/point_cloud/point_cloud_decoder.h +118 -0
- include/draco/compression/point_cloud/point_cloud_encoder.h +158 -0
- include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h +31 -0
- include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h +45 -0
- include/draco/compression/point_cloud/point_cloud_sequential_decoder.h +33 -0
- include/draco/compression/point_cloud/point_cloud_sequential_encoder.h +43 -0
- include/draco/core/bit_utils.h +127 -0
- include/draco/core/bounding_box.h +77 -0
- include/draco/core/constants.h +6 -0
- include/draco/core/cycle_timer.h +51 -0
- include/draco/core/data_buffer.h +82 -0
- include/draco/core/decoder_buffer.h +216 -0
- include/draco/core/divide.h +42 -0
- include/draco/core/draco_index_type.h +184 -0
- include/draco/core/draco_index_type_vector.h +90 -0
- include/draco/core/draco_types.h +52 -0
- include/draco/core/draco_version.h +25 -0
- include/draco/core/encoder_buffer.h +152 -0
- include/draco/core/hash_utils.h +64 -0
- include/draco/core/macros.h +124 -0
- include/draco/core/math_utils.h +79 -0
- include/draco/core/options.h +151 -0
- include/draco/core/quantization_utils.h +82 -0
- include/draco/core/status.h +83 -0
- include/draco/core/status_or.h +81 -0
- include/draco/core/varint_decoding.h +81 -0
- include/draco/core/varint_encoding.h +61 -0
- include/draco/core/vector_d.h +355 -0
- include/draco/draco_features.h +25 -0
- include/draco/io/file_reader_factory.h +34 -0
- include/draco/io/file_reader_interface.h +32 -0
- include/draco/io/file_utils.h +86 -0
- include/draco/io/file_writer_factory.h +34 -0
- include/draco/io/file_writer_interface.h +26 -0
- include/draco/io/file_writer_utils.h +38 -0
- include/draco/io/mesh_io.h +107 -0
- include/draco/io/obj_decoder.h +147 -0
- include/draco/io/obj_encoder.h +107 -0
- include/draco/io/parser_utils.h +66 -0
- include/draco/io/ply_decoder.h +69 -0
- include/draco/io/ply_encoder.h +54 -0
- include/draco/io/ply_property_reader.h +96 -0
- include/draco/io/ply_property_writer.h +94 -0
- include/draco/io/ply_reader.h +155 -0
- include/draco/io/point_cloud_io.h +89 -0
- include/draco/io/stdio_file_reader.h +48 -0
- include/draco/io/stdio_file_writer.h +42 -0
- include/draco/io/stl_decoder.h +38 -0
- include/draco/io/stl_encoder.h +52 -0
- include/draco/mesh/corner_table.h +397 -0
- include/draco/mesh/corner_table_iterators.h +309 -0
- include/draco/mesh/mesh.h +378 -0
- include/draco/mesh/mesh_are_equivalent.h +71 -0
- include/draco/mesh/mesh_attribute_corner_table.h +202 -0
- include/draco/mesh/mesh_cleanup.h +61 -0
- include/draco/mesh/mesh_features.h +93 -0
- include/draco/mesh/mesh_indices.h +37 -0
- include/draco/mesh/mesh_misc_functions.h +105 -0
- include/draco/mesh/mesh_stripifier.h +258 -0
- include/draco/mesh/triangle_soup_mesh_builder.h +134 -0
- include/draco/mesh/valence_cache.h +142 -0
- include/draco/metadata/geometry_metadata.h +142 -0
- include/draco/metadata/metadata.h +209 -0
- include/draco/metadata/metadata_decoder.h +42 -0
- include/draco/metadata/metadata_encoder.h +41 -0
- include/draco/metadata/property_attribute.h +107 -0
- include/draco/metadata/property_table.h +222 -0
- include/draco/metadata/structural_metadata.h +78 -0
- include/draco/metadata/structural_metadata_schema.h +118 -0
- include/draco/point_cloud/point_cloud.h +289 -0
- include/draco/point_cloud/point_cloud_builder.h +101 -0
- lib/draco.lib +0 -0
- lib/pkgconfig/draco.pc +6 -0
- share/cmake/draco/draco-config-version.cmake +43 -0
- share/cmake/draco/draco-config.cmake +27 -0
- share/cmake/draco/draco-targets-release.cmake +19 -0
- share/cmake/draco/draco-targets.cmake +107 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_H_
|
|
17
|
+
|
|
18
|
+
#include <algorithm>
|
|
19
|
+
#include <array>
|
|
20
|
+
#include <memory>
|
|
21
|
+
#include <stack>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
#include "draco/compression/bit_coders/adaptive_rans_bit_encoder.h"
|
|
25
|
+
#include "draco/compression/bit_coders/direct_bit_encoder.h"
|
|
26
|
+
#include "draco/compression/bit_coders/folded_integer_bit_encoder.h"
|
|
27
|
+
#include "draco/compression/bit_coders/rans_bit_encoder.h"
|
|
28
|
+
#include "draco/compression/point_cloud/algorithms/point_cloud_types.h"
|
|
29
|
+
#include "draco/core/bit_utils.h"
|
|
30
|
+
#include "draco/core/encoder_buffer.h"
|
|
31
|
+
#include "draco/core/math_utils.h"
|
|
32
|
+
|
|
33
|
+
namespace draco {
|
|
34
|
+
|
|
35
|
+
// This policy class provides several configurations for the encoder that allow
|
|
36
|
+
// to trade speed vs compression rate. Level 0 is fastest while 6 is the best
|
|
37
|
+
// compression rate. The decoder must select the same level.
|
|
38
|
+
template <int compression_level_t>
|
|
39
|
+
struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy
|
|
40
|
+
: public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<
|
|
41
|
+
compression_level_t - 1> {};
|
|
42
|
+
|
|
43
|
+
template <>
|
|
44
|
+
struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<0> {
|
|
45
|
+
typedef DirectBitEncoder NumbersEncoder;
|
|
46
|
+
typedef DirectBitEncoder AxisEncoder;
|
|
47
|
+
typedef DirectBitEncoder HalfEncoder;
|
|
48
|
+
typedef DirectBitEncoder RemainingBitsEncoder;
|
|
49
|
+
static constexpr bool select_axis = false;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
template <>
|
|
53
|
+
struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<2>
|
|
54
|
+
: public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<1> {
|
|
55
|
+
typedef RAnsBitEncoder NumbersEncoder;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
template <>
|
|
59
|
+
struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<4>
|
|
60
|
+
: public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<3> {
|
|
61
|
+
typedef FoldedBit32Encoder<RAnsBitEncoder> NumbersEncoder;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
template <>
|
|
65
|
+
struct DynamicIntegerPointsKdTreeEncoderCompressionPolicy<6>
|
|
66
|
+
: public DynamicIntegerPointsKdTreeEncoderCompressionPolicy<5> {
|
|
67
|
+
static constexpr bool select_axis = true;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// This class encodes a given integer point cloud based on the point cloud
|
|
71
|
+
// compression algorithm in:
|
|
72
|
+
// Olivier Devillers and Pierre-Marie Gandoin
|
|
73
|
+
// "Geometric compression for interactive transmission"
|
|
74
|
+
//
|
|
75
|
+
// In principle the algorithm keeps on splitting the point cloud in the middle
|
|
76
|
+
// while alternating the axes. In 3D this results in an Octree like structure.
|
|
77
|
+
// In each step we encode the number of points in the first half.
|
|
78
|
+
// The algorithm does not preserve the order of points.
|
|
79
|
+
//
|
|
80
|
+
// However, the algorithm here differs from the original as follows:
|
|
81
|
+
// The algorithm keeps on splitting the point cloud in the middle of the axis
|
|
82
|
+
// that keeps the point cloud as clustered as possible, which gives a better
|
|
83
|
+
// compression rate.
|
|
84
|
+
// The number of points is encode by the deviation from the half of the points
|
|
85
|
+
// in the smaller half of the two. This results in a better compression rate as
|
|
86
|
+
// there are more leading zeros, which is then compressed better by the
|
|
87
|
+
// arithmetic encoding.
|
|
88
|
+
template <int compression_level_t>
|
|
89
|
+
class DynamicIntegerPointsKdTreeEncoder {
|
|
90
|
+
static_assert(compression_level_t >= 0, "Compression level must in [0..6].");
|
|
91
|
+
static_assert(compression_level_t <= 6, "Compression level must in [0..6].");
|
|
92
|
+
typedef DynamicIntegerPointsKdTreeEncoderCompressionPolicy<
|
|
93
|
+
compression_level_t>
|
|
94
|
+
Policy;
|
|
95
|
+
typedef typename Policy::NumbersEncoder NumbersEncoder;
|
|
96
|
+
typedef typename Policy::AxisEncoder AxisEncoder;
|
|
97
|
+
typedef typename Policy::HalfEncoder HalfEncoder;
|
|
98
|
+
typedef typename Policy::RemainingBitsEncoder RemainingBitsEncoder;
|
|
99
|
+
typedef std::vector<uint32_t> VectorUint32;
|
|
100
|
+
|
|
101
|
+
public:
|
|
102
|
+
explicit DynamicIntegerPointsKdTreeEncoder(uint32_t dimension)
|
|
103
|
+
: bit_length_(0),
|
|
104
|
+
dimension_(dimension),
|
|
105
|
+
deviations_(dimension, 0),
|
|
106
|
+
num_remaining_bits_(dimension, 0),
|
|
107
|
+
axes_(dimension, 0),
|
|
108
|
+
base_stack_(32 * dimension + 1, VectorUint32(dimension, 0)),
|
|
109
|
+
levels_stack_(32 * dimension + 1, VectorUint32(dimension, 0)) {}
|
|
110
|
+
|
|
111
|
+
// Encodes an integer point cloud given by [begin,end) into buffer.
|
|
112
|
+
// |bit_length| gives the highest bit used for all coordinates.
|
|
113
|
+
template <class RandomAccessIteratorT>
|
|
114
|
+
bool EncodePoints(RandomAccessIteratorT begin, RandomAccessIteratorT end,
|
|
115
|
+
const uint32_t &bit_length, EncoderBuffer *buffer);
|
|
116
|
+
|
|
117
|
+
// Encodes an integer point cloud given by [begin,end) into buffer.
|
|
118
|
+
template <class RandomAccessIteratorT>
|
|
119
|
+
bool EncodePoints(RandomAccessIteratorT begin, RandomAccessIteratorT end,
|
|
120
|
+
EncoderBuffer *buffer) {
|
|
121
|
+
return EncodePoints(begin, end, 32, buffer);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const uint32_t dimension() const { return dimension_; }
|
|
125
|
+
|
|
126
|
+
private:
|
|
127
|
+
template <class RandomAccessIteratorT>
|
|
128
|
+
uint32_t GetAndEncodeAxis(RandomAccessIteratorT begin,
|
|
129
|
+
RandomAccessIteratorT end,
|
|
130
|
+
const VectorUint32 &old_base,
|
|
131
|
+
const VectorUint32 &levels, uint32_t last_axis);
|
|
132
|
+
template <class RandomAccessIteratorT>
|
|
133
|
+
void EncodeInternal(RandomAccessIteratorT begin, RandomAccessIteratorT end);
|
|
134
|
+
|
|
135
|
+
class Splitter {
|
|
136
|
+
public:
|
|
137
|
+
Splitter(uint32_t axis, uint32_t value) : axis_(axis), value_(value) {}
|
|
138
|
+
template <class PointT>
|
|
139
|
+
bool operator()(const PointT &a) const {
|
|
140
|
+
return a[axis_] < value_;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private:
|
|
144
|
+
const uint32_t axis_;
|
|
145
|
+
const uint32_t value_;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
void EncodeNumber(int nbits, uint32_t value) {
|
|
149
|
+
numbers_encoder_.EncodeLeastSignificantBits32(nbits, value);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
template <class RandomAccessIteratorT>
|
|
153
|
+
struct EncodingStatus {
|
|
154
|
+
EncodingStatus(RandomAccessIteratorT begin_, RandomAccessIteratorT end_,
|
|
155
|
+
uint32_t last_axis_, uint32_t stack_pos_)
|
|
156
|
+
: begin(begin_),
|
|
157
|
+
end(end_),
|
|
158
|
+
last_axis(last_axis_),
|
|
159
|
+
stack_pos(stack_pos_) {
|
|
160
|
+
num_remaining_points = static_cast<uint32_t>(end - begin);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
RandomAccessIteratorT begin;
|
|
164
|
+
RandomAccessIteratorT end;
|
|
165
|
+
uint32_t last_axis;
|
|
166
|
+
uint32_t num_remaining_points;
|
|
167
|
+
uint32_t stack_pos; // used to get base and levels
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
uint32_t bit_length_;
|
|
171
|
+
uint32_t num_points_;
|
|
172
|
+
uint32_t dimension_;
|
|
173
|
+
NumbersEncoder numbers_encoder_;
|
|
174
|
+
RemainingBitsEncoder remaining_bits_encoder_;
|
|
175
|
+
AxisEncoder axis_encoder_;
|
|
176
|
+
HalfEncoder half_encoder_;
|
|
177
|
+
VectorUint32 deviations_;
|
|
178
|
+
VectorUint32 num_remaining_bits_;
|
|
179
|
+
VectorUint32 axes_;
|
|
180
|
+
std::vector<VectorUint32> base_stack_;
|
|
181
|
+
std::vector<VectorUint32> levels_stack_;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
template <int compression_level_t>
|
|
185
|
+
template <class RandomAccessIteratorT>
|
|
186
|
+
bool DynamicIntegerPointsKdTreeEncoder<compression_level_t>::EncodePoints(
|
|
187
|
+
RandomAccessIteratorT begin, RandomAccessIteratorT end,
|
|
188
|
+
const uint32_t &bit_length, EncoderBuffer *buffer) {
|
|
189
|
+
bit_length_ = bit_length;
|
|
190
|
+
num_points_ = static_cast<uint32_t>(end - begin);
|
|
191
|
+
|
|
192
|
+
buffer->Encode(bit_length_);
|
|
193
|
+
buffer->Encode(num_points_);
|
|
194
|
+
if (num_points_ == 0) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
numbers_encoder_.StartEncoding();
|
|
199
|
+
remaining_bits_encoder_.StartEncoding();
|
|
200
|
+
axis_encoder_.StartEncoding();
|
|
201
|
+
half_encoder_.StartEncoding();
|
|
202
|
+
|
|
203
|
+
EncodeInternal(begin, end);
|
|
204
|
+
|
|
205
|
+
numbers_encoder_.EndEncoding(buffer);
|
|
206
|
+
remaining_bits_encoder_.EndEncoding(buffer);
|
|
207
|
+
axis_encoder_.EndEncoding(buffer);
|
|
208
|
+
half_encoder_.EndEncoding(buffer);
|
|
209
|
+
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
template <int compression_level_t>
|
|
213
|
+
template <class RandomAccessIteratorT>
|
|
214
|
+
uint32_t
|
|
215
|
+
DynamicIntegerPointsKdTreeEncoder<compression_level_t>::GetAndEncodeAxis(
|
|
216
|
+
RandomAccessIteratorT begin, RandomAccessIteratorT end,
|
|
217
|
+
const VectorUint32 &old_base, const VectorUint32 &levels,
|
|
218
|
+
uint32_t last_axis) {
|
|
219
|
+
if (!Policy::select_axis) {
|
|
220
|
+
return DRACO_INCREMENT_MOD(last_axis, dimension_);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// For many points this function selects the axis that should be used
|
|
224
|
+
// for the split by keeping as many points as possible bundled.
|
|
225
|
+
// In the best case we do not split the point cloud at all.
|
|
226
|
+
// For lower number of points, we simply choose the axis that is refined the
|
|
227
|
+
// least so far.
|
|
228
|
+
|
|
229
|
+
DRACO_DCHECK_EQ(true, end - begin != 0);
|
|
230
|
+
|
|
231
|
+
uint32_t best_axis = 0;
|
|
232
|
+
if (end - begin < 64) {
|
|
233
|
+
for (uint32_t axis = 1; axis < dimension_; ++axis) {
|
|
234
|
+
if (levels[best_axis] > levels[axis]) {
|
|
235
|
+
best_axis = axis;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
const uint32_t size = static_cast<uint32_t>(end - begin);
|
|
240
|
+
for (uint32_t i = 0; i < dimension_; i++) {
|
|
241
|
+
deviations_[i] = 0;
|
|
242
|
+
num_remaining_bits_[i] = bit_length_ - levels[i];
|
|
243
|
+
if (num_remaining_bits_[i] > 0) {
|
|
244
|
+
const uint32_t split =
|
|
245
|
+
old_base[i] + (1 << (num_remaining_bits_[i] - 1));
|
|
246
|
+
for (auto it = begin; it != end; ++it) {
|
|
247
|
+
deviations_[i] += ((*it)[i] < split);
|
|
248
|
+
}
|
|
249
|
+
deviations_[i] = std::max(size - deviations_[i], deviations_[i]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
uint32_t max_value = 0;
|
|
254
|
+
best_axis = 0;
|
|
255
|
+
for (uint32_t i = 0; i < dimension_; i++) {
|
|
256
|
+
// If axis can be subdivided.
|
|
257
|
+
if (num_remaining_bits_[i]) {
|
|
258
|
+
// Check if this is the better axis.
|
|
259
|
+
if (max_value < deviations_[i]) {
|
|
260
|
+
max_value = deviations_[i];
|
|
261
|
+
best_axis = i;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
axis_encoder_.EncodeLeastSignificantBits32(4, best_axis);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return best_axis;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
template <int compression_level_t>
|
|
272
|
+
template <class RandomAccessIteratorT>
|
|
273
|
+
void DynamicIntegerPointsKdTreeEncoder<compression_level_t>::EncodeInternal(
|
|
274
|
+
RandomAccessIteratorT begin, RandomAccessIteratorT end) {
|
|
275
|
+
typedef EncodingStatus<RandomAccessIteratorT> Status;
|
|
276
|
+
|
|
277
|
+
base_stack_[0] = VectorUint32(dimension_, 0);
|
|
278
|
+
levels_stack_[0] = VectorUint32(dimension_, 0);
|
|
279
|
+
Status init_status(begin, end, 0, 0);
|
|
280
|
+
std::stack<Status> status_stack;
|
|
281
|
+
status_stack.push(init_status);
|
|
282
|
+
|
|
283
|
+
// TODO(b/199760123): Use preallocated vector instead of stack.
|
|
284
|
+
while (!status_stack.empty()) {
|
|
285
|
+
Status status = status_stack.top();
|
|
286
|
+
status_stack.pop();
|
|
287
|
+
|
|
288
|
+
begin = status.begin;
|
|
289
|
+
end = status.end;
|
|
290
|
+
const uint32_t last_axis = status.last_axis;
|
|
291
|
+
const uint32_t stack_pos = status.stack_pos;
|
|
292
|
+
const VectorUint32 &old_base = base_stack_[stack_pos];
|
|
293
|
+
const VectorUint32 &levels = levels_stack_[stack_pos];
|
|
294
|
+
|
|
295
|
+
const uint32_t axis =
|
|
296
|
+
GetAndEncodeAxis(begin, end, old_base, levels, last_axis);
|
|
297
|
+
const uint32_t level = levels[axis];
|
|
298
|
+
const uint32_t num_remaining_points = static_cast<uint32_t>(end - begin);
|
|
299
|
+
|
|
300
|
+
// If this happens all axis are subdivided to the end.
|
|
301
|
+
if ((bit_length_ - level) == 0) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Fast encoding of remaining bits if number of points is 1 or 2.
|
|
306
|
+
// Doing this also for 2 gives a slight additional speed up.
|
|
307
|
+
if (num_remaining_points <= 2) {
|
|
308
|
+
// TODO(b/199760123): |axes_| not necessary, remove would change
|
|
309
|
+
// bitstream!
|
|
310
|
+
axes_[0] = axis;
|
|
311
|
+
for (uint32_t i = 1; i < dimension_; i++) {
|
|
312
|
+
axes_[i] = DRACO_INCREMENT_MOD(axes_[i - 1], dimension_);
|
|
313
|
+
}
|
|
314
|
+
for (uint32_t i = 0; i < num_remaining_points; ++i) {
|
|
315
|
+
const auto &p = *(begin + i);
|
|
316
|
+
for (uint32_t j = 0; j < dimension_; j++) {
|
|
317
|
+
const uint32_t num_remaining_bits = bit_length_ - levels[axes_[j]];
|
|
318
|
+
if (num_remaining_bits) {
|
|
319
|
+
remaining_bits_encoder_.EncodeLeastSignificantBits32(
|
|
320
|
+
num_remaining_bits, p[axes_[j]]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const uint32_t num_remaining_bits = bit_length_ - level;
|
|
328
|
+
const uint32_t modifier = 1 << (num_remaining_bits - 1);
|
|
329
|
+
base_stack_[stack_pos + 1] = old_base; // copy
|
|
330
|
+
base_stack_[stack_pos + 1][axis] += modifier;
|
|
331
|
+
const VectorUint32 &new_base = base_stack_[stack_pos + 1];
|
|
332
|
+
|
|
333
|
+
const RandomAccessIteratorT split =
|
|
334
|
+
std::partition(begin, end, Splitter(axis, new_base[axis]));
|
|
335
|
+
|
|
336
|
+
DRACO_DCHECK_EQ(true, (end - begin) > 0);
|
|
337
|
+
|
|
338
|
+
// Encode number of points in first and second half.
|
|
339
|
+
const int required_bits = MostSignificantBit(num_remaining_points);
|
|
340
|
+
|
|
341
|
+
const uint32_t first_half = static_cast<uint32_t>(split - begin);
|
|
342
|
+
const uint32_t second_half = static_cast<uint32_t>(end - split);
|
|
343
|
+
const bool left = first_half < second_half;
|
|
344
|
+
|
|
345
|
+
if (first_half != second_half) {
|
|
346
|
+
half_encoder_.EncodeBit(left);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (left) {
|
|
350
|
+
EncodeNumber(required_bits, num_remaining_points / 2 - first_half);
|
|
351
|
+
} else {
|
|
352
|
+
EncodeNumber(required_bits, num_remaining_points / 2 - second_half);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
levels_stack_[stack_pos][axis] += 1;
|
|
356
|
+
levels_stack_[stack_pos + 1] = levels_stack_[stack_pos]; // copy
|
|
357
|
+
if (split != begin) {
|
|
358
|
+
status_stack.push(Status(begin, split, axis, stack_pos));
|
|
359
|
+
}
|
|
360
|
+
if (split != end) {
|
|
361
|
+
status_stack.push(Status(split, end, axis, stack_pos + 1));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
extern template class DynamicIntegerPointsKdTreeEncoder<0>;
|
|
366
|
+
extern template class DynamicIntegerPointsKdTreeEncoder<2>;
|
|
367
|
+
extern template class DynamicIntegerPointsKdTreeEncoder<4>;
|
|
368
|
+
extern template class DynamicIntegerPointsKdTreeEncoder<6>;
|
|
369
|
+
|
|
370
|
+
} // namespace draco
|
|
371
|
+
|
|
372
|
+
#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_DYNAMIC_INTEGER_POINTS_KD_TREE_ENCODER_H_
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
|
|
20
|
+
#include "draco/compression/config/compression_shared.h"
|
|
21
|
+
#include "draco/compression/point_cloud/algorithms/point_cloud_compression_method.h"
|
|
22
|
+
#include "draco/compression/point_cloud/algorithms/point_cloud_types.h"
|
|
23
|
+
#include "draco/compression/point_cloud/algorithms/quantize_points_3.h"
|
|
24
|
+
#include "draco/core/decoder_buffer.h"
|
|
25
|
+
|
|
26
|
+
namespace draco {
|
|
27
|
+
|
|
28
|
+
// Decodes a point cloud encoded by PointCloudTreeEncoder.
|
|
29
|
+
class FloatPointsTreeDecoder {
|
|
30
|
+
public:
|
|
31
|
+
FloatPointsTreeDecoder();
|
|
32
|
+
|
|
33
|
+
// Decodes a point cloud from |buffer|.
|
|
34
|
+
template <class OutputIteratorT>
|
|
35
|
+
bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &out);
|
|
36
|
+
|
|
37
|
+
#ifndef DRACO_OLD_GCC
|
|
38
|
+
template <class OutputIteratorT>
|
|
39
|
+
bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &&out);
|
|
40
|
+
#endif // DRACO_OLD_GCC
|
|
41
|
+
|
|
42
|
+
// Initializes a DecoderBuffer from |data|, and calls function above.
|
|
43
|
+
template <class OutputIteratorT>
|
|
44
|
+
bool DecodePointCloud(const char *data, size_t data_size,
|
|
45
|
+
OutputIteratorT out) {
|
|
46
|
+
if (data == 0 || data_size <= 0) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
DecoderBuffer buffer;
|
|
51
|
+
buffer.Init(data, data_size);
|
|
52
|
+
buffer.set_bitstream_version(kDracoPointCloudBitstreamVersion);
|
|
53
|
+
return DecodePointCloud(&buffer, out);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
uint32_t quantization_bits() const { return qinfo_.quantization_bits; }
|
|
57
|
+
uint32_t compression_level() const { return compression_level_; }
|
|
58
|
+
float range() const { return qinfo_.range; }
|
|
59
|
+
uint32_t num_points() const { return num_points_; }
|
|
60
|
+
uint32_t version() const { return version_; }
|
|
61
|
+
std::string identification_string() const {
|
|
62
|
+
if (method_ == KDTREE) {
|
|
63
|
+
return "FloatPointsTreeDecoder: IntegerPointsKDTreeDecoder";
|
|
64
|
+
} else {
|
|
65
|
+
return "FloatPointsTreeDecoder: Unsupported Method";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void set_num_points_from_header(uint32_t num_points) {
|
|
70
|
+
num_points_from_header_ = num_points;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
bool DecodePointCloudKdTreeInternal(DecoderBuffer *buffer,
|
|
75
|
+
std::vector<Point3ui> *qpoints);
|
|
76
|
+
|
|
77
|
+
static const uint32_t version_ = 3;
|
|
78
|
+
QuantizationInfo qinfo_;
|
|
79
|
+
int8_t method_;
|
|
80
|
+
uint32_t num_points_;
|
|
81
|
+
uint32_t compression_level_;
|
|
82
|
+
|
|
83
|
+
// Member variable to check if the number of points from the file header
|
|
84
|
+
// matches the number of points in the compression header. If
|
|
85
|
+
// |num_points_from_header_| is 0, do not perform the check. Defaults to 0.
|
|
86
|
+
uint32_t num_points_from_header_;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
#ifndef DRACO_OLD_GCC
|
|
90
|
+
// TODO(vytyaz): Reenable once USD migrates from GCC 4.8 to a higher version
|
|
91
|
+
// that can disambiguate calls to overloaded methods taking rvalue reference.
|
|
92
|
+
template <class OutputIteratorT>
|
|
93
|
+
bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer,
|
|
94
|
+
OutputIteratorT &&out) {
|
|
95
|
+
OutputIteratorT local = std::forward<OutputIteratorT>(out);
|
|
96
|
+
return DecodePointCloud(buffer, local);
|
|
97
|
+
}
|
|
98
|
+
#endif // DRACO_OLD_GCC
|
|
99
|
+
|
|
100
|
+
template <class OutputIteratorT>
|
|
101
|
+
bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer,
|
|
102
|
+
OutputIteratorT &out) {
|
|
103
|
+
std::vector<Point3ui> qpoints;
|
|
104
|
+
|
|
105
|
+
uint32_t decoded_version;
|
|
106
|
+
if (!buffer->Decode(&decoded_version)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (decoded_version == 3) {
|
|
111
|
+
int8_t method_number;
|
|
112
|
+
if (!buffer->Decode(&method_number)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
method_ = method_number;
|
|
117
|
+
|
|
118
|
+
if (method_ == KDTREE) {
|
|
119
|
+
if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
} else { // Unsupported method.
|
|
123
|
+
fprintf(stderr, "Method not supported. \n");
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
} else if (decoded_version == 2) { // Version 2 only uses KDTREE method.
|
|
127
|
+
if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
} else { // Unsupported version.
|
|
131
|
+
fprintf(stderr, "Version not supported. \n");
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
DequantizePoints3(qpoints.begin(), qpoints.end(), qinfo_, out);
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
} // namespace draco
|
|
140
|
+
|
|
141
|
+
#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_ENCODER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_ENCODER_H_
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "draco/compression/point_cloud/algorithms/point_cloud_compression_method.h"
|
|
22
|
+
#include "draco/compression/point_cloud/algorithms/point_cloud_types.h"
|
|
23
|
+
#include "draco/compression/point_cloud/algorithms/quantize_points_3.h"
|
|
24
|
+
#include "draco/core/encoder_buffer.h"
|
|
25
|
+
|
|
26
|
+
namespace draco {
|
|
27
|
+
|
|
28
|
+
// This class encodes a given point cloud based on the point cloud compression
|
|
29
|
+
// algorithm in:
|
|
30
|
+
// Olivier Devillers and Pierre-Marie Gandoin
|
|
31
|
+
// "Geometric compression for interactive transmission"
|
|
32
|
+
//
|
|
33
|
+
// In principle the algorithm keeps on splitting the point cloud in the middle
|
|
34
|
+
// while alternating the axes. For 3D this results in an Octree like structure.
|
|
35
|
+
// In each step we encode the number of points in the first half.
|
|
36
|
+
// The algorithm uses quantization and does not preserve the order of points.
|
|
37
|
+
//
|
|
38
|
+
// However, the algorithm here differs from the original as follows:
|
|
39
|
+
// The algorithm keeps on splitting the point cloud in the middle of the axis
|
|
40
|
+
// that keeps the point cloud as clustered as possible, which gives a better
|
|
41
|
+
// compression rate.
|
|
42
|
+
// The number of points is encode by the deviation from the half of the points
|
|
43
|
+
// in the smaller half of the two. This results in a better compression rate as
|
|
44
|
+
// there are more leading zeros, which is then compressed better by the
|
|
45
|
+
// arithmetic encoding.
|
|
46
|
+
|
|
47
|
+
// TODO(b/199760123): Remove class because it duplicates quantization code.
|
|
48
|
+
class FloatPointsTreeEncoder {
|
|
49
|
+
public:
|
|
50
|
+
explicit FloatPointsTreeEncoder(PointCloudCompressionMethod method);
|
|
51
|
+
explicit FloatPointsTreeEncoder(PointCloudCompressionMethod method,
|
|
52
|
+
uint32_t quantization_bits,
|
|
53
|
+
uint32_t compression_level);
|
|
54
|
+
|
|
55
|
+
template <class InputIteratorT>
|
|
56
|
+
bool EncodePointCloud(InputIteratorT points_begin, InputIteratorT points_end);
|
|
57
|
+
EncoderBuffer *buffer() { return &buffer_; }
|
|
58
|
+
|
|
59
|
+
uint32_t version() const { return version_; }
|
|
60
|
+
uint32_t quantization_bits() const { return qinfo_.quantization_bits; }
|
|
61
|
+
uint32_t &quantization_bits() { return qinfo_.quantization_bits; }
|
|
62
|
+
uint32_t compression_level() const { return compression_level_; }
|
|
63
|
+
uint32_t &compression_level() { return compression_level_; }
|
|
64
|
+
float range() const { return qinfo_.range; }
|
|
65
|
+
uint32_t num_points() const { return num_points_; }
|
|
66
|
+
std::string identification_string() const {
|
|
67
|
+
if (method_ == KDTREE) {
|
|
68
|
+
return "FloatPointsTreeEncoder: IntegerPointsKDTreeEncoder";
|
|
69
|
+
} else {
|
|
70
|
+
return "FloatPointsTreeEncoder: Unsupported Method";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
void Clear() { buffer_.Clear(); }
|
|
76
|
+
bool EncodePointCloudKdTreeInternal(std::vector<Point3ui> *qpoints);
|
|
77
|
+
|
|
78
|
+
static const uint32_t version_;
|
|
79
|
+
QuantizationInfo qinfo_;
|
|
80
|
+
PointCloudCompressionMethod method_;
|
|
81
|
+
uint32_t num_points_;
|
|
82
|
+
EncoderBuffer buffer_;
|
|
83
|
+
uint32_t compression_level_;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
template <class InputIteratorT>
|
|
87
|
+
bool FloatPointsTreeEncoder::EncodePointCloud(InputIteratorT points_begin,
|
|
88
|
+
InputIteratorT points_end) {
|
|
89
|
+
Clear();
|
|
90
|
+
|
|
91
|
+
// Collect necessary data for encoding.
|
|
92
|
+
num_points_ = std::distance(points_begin, points_end);
|
|
93
|
+
|
|
94
|
+
// TODO(b/199760123): Extend quantization tools to make this more automatic.
|
|
95
|
+
// Compute range of points for quantization
|
|
96
|
+
std::vector<Point3ui> qpoints;
|
|
97
|
+
qpoints.reserve(num_points_);
|
|
98
|
+
QuantizePoints3(points_begin, points_end, &qinfo_,
|
|
99
|
+
std::back_inserter(qpoints));
|
|
100
|
+
|
|
101
|
+
// Encode header.
|
|
102
|
+
buffer()->Encode(version_);
|
|
103
|
+
buffer()->Encode(static_cast<int8_t>(method_));
|
|
104
|
+
buffer()->Encode(qinfo_.quantization_bits);
|
|
105
|
+
buffer()->Encode(qinfo_.range);
|
|
106
|
+
buffer()->Encode(num_points_);
|
|
107
|
+
|
|
108
|
+
if (method_ == KDTREE) {
|
|
109
|
+
buffer()->Encode(compression_level_);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (num_points_ == 0) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (method_ == KDTREE) {
|
|
117
|
+
return EncodePointCloudKdTreeInternal(&qpoints);
|
|
118
|
+
} else { // Unsupported method.
|
|
119
|
+
fprintf(stderr, "Method not supported. \n");
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
} // namespace draco
|
|
125
|
+
|
|
126
|
+
#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_ENCODER_H_
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_COMPRESSION_METHOD_H_
|
|
16
|
+
#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_COMPRESSION_METHOD_H_
|
|
17
|
+
|
|
18
|
+
namespace draco {
|
|
19
|
+
|
|
20
|
+
// Enum indicating the used compression method, used by Encoder and Decoder.
|
|
21
|
+
enum PointCloudCompressionMethod {
|
|
22
|
+
RESERVED_POINT_CLOUD_METHOD_0 = 0, // Reserved for internal use.
|
|
23
|
+
// Generalized version of Encoding using the Octree method by Olivier
|
|
24
|
+
// Devillers to d dimensions.
|
|
25
|
+
// "Progressive lossless compression of arbitrary simplicial complexes"
|
|
26
|
+
// https://doi.org/10.1145/566570.566591
|
|
27
|
+
KDTREE = 1,
|
|
28
|
+
RESERVED_POINT_CLOUD_METHOD_2 = 2, // Reserved for internal use.
|
|
29
|
+
RESERVED_POINT_CLOUD_METHOD_3 = 0, // Reserved for internal use.
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace draco
|
|
33
|
+
|
|
34
|
+
#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_POINT_CLOUD_COMPRESSION_METHOD_H_
|