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,51 @@
|
|
|
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_ATTRIBUTES_LINEAR_SEQUENCER_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_LINEAR_SEQUENCER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/compression/attributes/points_sequencer.h"
|
|
19
|
+
|
|
20
|
+
namespace draco {
|
|
21
|
+
|
|
22
|
+
// A simple sequencer that generates a linear sequence [0, num_points - 1].
|
|
23
|
+
// I.e., the order of the points is preserved for the input data.
|
|
24
|
+
class LinearSequencer : public PointsSequencer {
|
|
25
|
+
public:
|
|
26
|
+
explicit LinearSequencer(int32_t num_points) : num_points_(num_points) {}
|
|
27
|
+
|
|
28
|
+
bool UpdatePointToAttributeIndexMapping(PointAttribute *attribute) override {
|
|
29
|
+
attribute->SetIdentityMapping();
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected:
|
|
34
|
+
bool GenerateSequenceInternal() override {
|
|
35
|
+
if (num_points_ < 0) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
out_point_ids()->resize(num_points_);
|
|
39
|
+
for (int i = 0; i < num_points_; ++i) {
|
|
40
|
+
out_point_ids()->at(i) = PointIndex(i);
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private:
|
|
46
|
+
int32_t num_points_;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace draco
|
|
50
|
+
|
|
51
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_LINEAR_SEQUENCER_H_
|
|
@@ -0,0 +1,58 @@
|
|
|
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_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_
|
|
16
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_
|
|
17
|
+
|
|
18
|
+
#include <inttypes.h>
|
|
19
|
+
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
#include "draco/attributes/geometry_indices.h"
|
|
23
|
+
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// Data used for encoding and decoding of mesh attributes.
|
|
27
|
+
struct MeshAttributeIndicesEncodingData {
|
|
28
|
+
MeshAttributeIndicesEncodingData() : num_values(0) {}
|
|
29
|
+
|
|
30
|
+
void Init(int num_vertices) {
|
|
31
|
+
vertex_to_encoded_attribute_value_index_map.resize(num_vertices);
|
|
32
|
+
|
|
33
|
+
// We expect to store one value for each vertex.
|
|
34
|
+
encoded_attribute_value_index_to_corner_map.reserve(num_vertices);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Array for storing the corner ids in the order their associated attribute
|
|
38
|
+
// entries were encoded/decoded. For every encoded attribute value entry we
|
|
39
|
+
// store exactly one corner. I.e., this is the mapping between an encoded
|
|
40
|
+
// attribute entry ids and corner ids. This map is needed for example by
|
|
41
|
+
// prediction schemes. Note that not all corners are included in this map,
|
|
42
|
+
// e.g., if multiple corners share the same attribute value, only one of these
|
|
43
|
+
// corners will be usually included.
|
|
44
|
+
std::vector<CornerIndex> encoded_attribute_value_index_to_corner_map;
|
|
45
|
+
|
|
46
|
+
// Map for storing encoding order of attribute entries for each vertex.
|
|
47
|
+
// i.e. Mapping between vertices and their corresponding attribute entry ids
|
|
48
|
+
// that are going to be used by the decoder.
|
|
49
|
+
// -1 if an attribute entry hasn't been encoded/decoded yet.
|
|
50
|
+
std::vector<int32_t> vertex_to_encoded_attribute_value_index_map;
|
|
51
|
+
|
|
52
|
+
// Total number of encoded/decoded attribute entries.
|
|
53
|
+
int num_values;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace draco
|
|
57
|
+
|
|
58
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_
|
|
@@ -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
|
+
// Utilities for converting unit vectors to octahedral coordinates and back.
|
|
16
|
+
// For more details about octahedral coordinates, see for example Cigolle
|
|
17
|
+
// et al.'14 “A Survey of Efficient Representations for Independent Unit
|
|
18
|
+
// Vectors”.
|
|
19
|
+
//
|
|
20
|
+
// In short this is motivated by an octahedron inscribed into a sphere. The
|
|
21
|
+
// direction of the normal vector can be defined by a point on the octahedron.
|
|
22
|
+
// On the right hemisphere (x > 0) this point is projected onto the x = 0 plane,
|
|
23
|
+
// that is, the right side of the octahedron forms a diamond like shape. The
|
|
24
|
+
// left side of the octahedron is also projected onto the x = 0 plane, however,
|
|
25
|
+
// in this case we flap the triangles of the diamond outward. Afterwards we
|
|
26
|
+
// shift the resulting square such that all values are positive.
|
|
27
|
+
//
|
|
28
|
+
// Important values in this file:
|
|
29
|
+
// * q: number of quantization bits
|
|
30
|
+
// * max_quantized_value: the max value representable with q bits (odd)
|
|
31
|
+
// * max_value: max value of the diamond = max_quantized_value - 1 (even)
|
|
32
|
+
// * center_value: center of the diamond after shift
|
|
33
|
+
//
|
|
34
|
+
// Note that the parameter space is somewhat periodic, e.g. (0, 0) ==
|
|
35
|
+
// (max_value, max_value), which is also why the diamond is one smaller than the
|
|
36
|
+
// maximal representable value in order to have an odd range of values.
|
|
37
|
+
|
|
38
|
+
#ifndef DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_
|
|
39
|
+
#define DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_
|
|
40
|
+
|
|
41
|
+
#include <inttypes.h>
|
|
42
|
+
|
|
43
|
+
#include <algorithm>
|
|
44
|
+
#include <cmath>
|
|
45
|
+
|
|
46
|
+
#include "draco/core/macros.h"
|
|
47
|
+
|
|
48
|
+
namespace draco {
|
|
49
|
+
|
|
50
|
+
class OctahedronToolBox {
|
|
51
|
+
public:
|
|
52
|
+
OctahedronToolBox()
|
|
53
|
+
: quantization_bits_(-1),
|
|
54
|
+
max_quantized_value_(-1),
|
|
55
|
+
max_value_(-1),
|
|
56
|
+
dequantization_scale_(1.f),
|
|
57
|
+
center_value_(-1) {}
|
|
58
|
+
|
|
59
|
+
bool SetQuantizationBits(int32_t q) {
|
|
60
|
+
if (q < 2 || q > 30) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
quantization_bits_ = q;
|
|
64
|
+
max_quantized_value_ = (1u << quantization_bits_) - 1;
|
|
65
|
+
max_value_ = max_quantized_value_ - 1;
|
|
66
|
+
dequantization_scale_ = 2.f / max_value_;
|
|
67
|
+
center_value_ = max_value_ / 2;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
bool IsInitialized() const { return quantization_bits_ != -1; }
|
|
71
|
+
|
|
72
|
+
// Convert all edge points in the top left and bottom right quadrants to
|
|
73
|
+
// their corresponding position in the bottom left and top right quadrants.
|
|
74
|
+
// Convert all corner edge points to the top right corner.
|
|
75
|
+
inline void CanonicalizeOctahedralCoords(int32_t s, int32_t t, int32_t *out_s,
|
|
76
|
+
int32_t *out_t) const {
|
|
77
|
+
if ((s == 0 && t == 0) || (s == 0 && t == max_value_) ||
|
|
78
|
+
(s == max_value_ && t == 0)) {
|
|
79
|
+
s = max_value_;
|
|
80
|
+
t = max_value_;
|
|
81
|
+
} else if (s == 0 && t > center_value_) {
|
|
82
|
+
t = center_value_ - (t - center_value_);
|
|
83
|
+
} else if (s == max_value_ && t < center_value_) {
|
|
84
|
+
t = center_value_ + (center_value_ - t);
|
|
85
|
+
} else if (t == max_value_ && s < center_value_) {
|
|
86
|
+
s = center_value_ + (center_value_ - s);
|
|
87
|
+
} else if (t == 0 && s > center_value_) {
|
|
88
|
+
s = center_value_ - (s - center_value_);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
*out_s = s;
|
|
92
|
+
*out_t = t;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Converts an integer vector to octahedral coordinates.
|
|
96
|
+
// Precondition: |int_vec| abs sum must equal center value.
|
|
97
|
+
inline void IntegerVectorToQuantizedOctahedralCoords(const int32_t *int_vec,
|
|
98
|
+
int32_t *out_s,
|
|
99
|
+
int32_t *out_t) const {
|
|
100
|
+
DRACO_DCHECK_EQ(
|
|
101
|
+
std::abs(int_vec[0]) + std::abs(int_vec[1]) + std::abs(int_vec[2]),
|
|
102
|
+
center_value_);
|
|
103
|
+
int32_t s, t;
|
|
104
|
+
if (int_vec[0] >= 0) {
|
|
105
|
+
// Right hemisphere.
|
|
106
|
+
s = (int_vec[1] + center_value_);
|
|
107
|
+
t = (int_vec[2] + center_value_);
|
|
108
|
+
} else {
|
|
109
|
+
// Left hemisphere.
|
|
110
|
+
if (int_vec[1] < 0) {
|
|
111
|
+
s = std::abs(int_vec[2]);
|
|
112
|
+
} else {
|
|
113
|
+
s = (max_value_ - std::abs(int_vec[2]));
|
|
114
|
+
}
|
|
115
|
+
if (int_vec[2] < 0) {
|
|
116
|
+
t = std::abs(int_vec[1]);
|
|
117
|
+
} else {
|
|
118
|
+
t = (max_value_ - std::abs(int_vec[1]));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
CanonicalizeOctahedralCoords(s, t, out_s, out_t);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
template <class T>
|
|
125
|
+
void FloatVectorToQuantizedOctahedralCoords(const T *vector, int32_t *out_s,
|
|
126
|
+
int32_t *out_t) const {
|
|
127
|
+
const double abs_sum = std::abs(static_cast<double>(vector[0])) +
|
|
128
|
+
std::abs(static_cast<double>(vector[1])) +
|
|
129
|
+
std::abs(static_cast<double>(vector[2]));
|
|
130
|
+
|
|
131
|
+
// Adjust values such that abs sum equals 1.
|
|
132
|
+
double scaled_vector[3];
|
|
133
|
+
if (abs_sum > 1e-6) {
|
|
134
|
+
// Scale needed to project the vector to the surface of an octahedron.
|
|
135
|
+
const double scale = 1.0 / abs_sum;
|
|
136
|
+
scaled_vector[0] = vector[0] * scale;
|
|
137
|
+
scaled_vector[1] = vector[1] * scale;
|
|
138
|
+
scaled_vector[2] = vector[2] * scale;
|
|
139
|
+
} else {
|
|
140
|
+
scaled_vector[0] = 1.0;
|
|
141
|
+
scaled_vector[1] = 0;
|
|
142
|
+
scaled_vector[2] = 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Scale vector such that the sum equals the center value.
|
|
146
|
+
int32_t int_vec[3];
|
|
147
|
+
int_vec[0] =
|
|
148
|
+
static_cast<int32_t>(floor(scaled_vector[0] * center_value_ + 0.5));
|
|
149
|
+
int_vec[1] =
|
|
150
|
+
static_cast<int32_t>(floor(scaled_vector[1] * center_value_ + 0.5));
|
|
151
|
+
// Make sure the sum is exactly the center value.
|
|
152
|
+
int_vec[2] = center_value_ - std::abs(int_vec[0]) - std::abs(int_vec[1]);
|
|
153
|
+
if (int_vec[2] < 0) {
|
|
154
|
+
// If the sum of first two coordinates is too large, we need to decrease
|
|
155
|
+
// the length of one of the coordinates.
|
|
156
|
+
if (int_vec[1] > 0) {
|
|
157
|
+
int_vec[1] += int_vec[2];
|
|
158
|
+
} else {
|
|
159
|
+
int_vec[1] -= int_vec[2];
|
|
160
|
+
}
|
|
161
|
+
int_vec[2] = 0;
|
|
162
|
+
}
|
|
163
|
+
// Take care of the sign.
|
|
164
|
+
if (scaled_vector[2] < 0) {
|
|
165
|
+
int_vec[2] *= -1;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
IntegerVectorToQuantizedOctahedralCoords(int_vec, out_s, out_t);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Normalize |vec| such that its abs sum is equal to the center value;
|
|
172
|
+
template <class T>
|
|
173
|
+
void CanonicalizeIntegerVector(T *vec) const {
|
|
174
|
+
static_assert(std::is_integral<T>::value, "T must be an integral type.");
|
|
175
|
+
static_assert(std::is_signed<T>::value, "T must be a signed type.");
|
|
176
|
+
const int64_t abs_sum = static_cast<int64_t>(std::abs(vec[0])) +
|
|
177
|
+
static_cast<int64_t>(std::abs(vec[1])) +
|
|
178
|
+
static_cast<int64_t>(std::abs(vec[2]));
|
|
179
|
+
|
|
180
|
+
if (abs_sum == 0) {
|
|
181
|
+
vec[0] = center_value_; // vec[1] == v[2] == 0
|
|
182
|
+
} else {
|
|
183
|
+
vec[0] =
|
|
184
|
+
(static_cast<int64_t>(vec[0]) * static_cast<int64_t>(center_value_)) /
|
|
185
|
+
abs_sum;
|
|
186
|
+
vec[1] =
|
|
187
|
+
(static_cast<int64_t>(vec[1]) * static_cast<int64_t>(center_value_)) /
|
|
188
|
+
abs_sum;
|
|
189
|
+
if (vec[2] >= 0) {
|
|
190
|
+
vec[2] = center_value_ - std::abs(vec[0]) - std::abs(vec[1]);
|
|
191
|
+
} else {
|
|
192
|
+
vec[2] = -(center_value_ - std::abs(vec[0]) - std::abs(vec[1]));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
inline void QuantizedOctahedralCoordsToUnitVector(int32_t in_s, int32_t in_t,
|
|
198
|
+
float *out_vector) const {
|
|
199
|
+
OctahedralCoordsToUnitVector(in_s * dequantization_scale_ - 1.f,
|
|
200
|
+
in_t * dequantization_scale_ - 1.f,
|
|
201
|
+
out_vector);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// |s| and |t| are expected to be signed values.
|
|
205
|
+
inline bool IsInDiamond(const int32_t &s, const int32_t &t) const {
|
|
206
|
+
// Expect center already at origin.
|
|
207
|
+
DRACO_DCHECK_LE(s, center_value_);
|
|
208
|
+
DRACO_DCHECK_LE(t, center_value_);
|
|
209
|
+
DRACO_DCHECK_GE(s, -center_value_);
|
|
210
|
+
DRACO_DCHECK_GE(t, -center_value_);
|
|
211
|
+
const uint32_t st =
|
|
212
|
+
static_cast<uint32_t>(std::abs(s)) + static_cast<uint32_t>(std::abs(t));
|
|
213
|
+
return st <= center_value_;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void InvertDiamond(int32_t *s, int32_t *t) const {
|
|
217
|
+
// Expect center already at origin.
|
|
218
|
+
DRACO_DCHECK_LE(*s, center_value_);
|
|
219
|
+
DRACO_DCHECK_LE(*t, center_value_);
|
|
220
|
+
DRACO_DCHECK_GE(*s, -center_value_);
|
|
221
|
+
DRACO_DCHECK_GE(*t, -center_value_);
|
|
222
|
+
int32_t sign_s = 0;
|
|
223
|
+
int32_t sign_t = 0;
|
|
224
|
+
if (*s >= 0 && *t >= 0) {
|
|
225
|
+
sign_s = 1;
|
|
226
|
+
sign_t = 1;
|
|
227
|
+
} else if (*s <= 0 && *t <= 0) {
|
|
228
|
+
sign_s = -1;
|
|
229
|
+
sign_t = -1;
|
|
230
|
+
} else {
|
|
231
|
+
sign_s = (*s > 0) ? 1 : -1;
|
|
232
|
+
sign_t = (*t > 0) ? 1 : -1;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Perform the addition and subtraction using unsigned integers to avoid
|
|
236
|
+
// signed integer overflows for bad data. Note that the result will be
|
|
237
|
+
// unchanged for non-overflowing cases.
|
|
238
|
+
const uint32_t corner_point_s = sign_s * center_value_;
|
|
239
|
+
const uint32_t corner_point_t = sign_t * center_value_;
|
|
240
|
+
uint32_t us = *s;
|
|
241
|
+
uint32_t ut = *t;
|
|
242
|
+
us = us + us - corner_point_s;
|
|
243
|
+
ut = ut + ut - corner_point_t;
|
|
244
|
+
if (sign_s * sign_t >= 0) {
|
|
245
|
+
uint32_t temp = us;
|
|
246
|
+
us = -ut;
|
|
247
|
+
ut = -temp;
|
|
248
|
+
} else {
|
|
249
|
+
std::swap(us, ut);
|
|
250
|
+
}
|
|
251
|
+
us = us + corner_point_s;
|
|
252
|
+
ut = ut + corner_point_t;
|
|
253
|
+
|
|
254
|
+
*s = us;
|
|
255
|
+
*t = ut;
|
|
256
|
+
*s /= 2;
|
|
257
|
+
*t /= 2;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void InvertDirection(int32_t *s, int32_t *t) const {
|
|
261
|
+
// Expect center already at origin.
|
|
262
|
+
DRACO_DCHECK_LE(*s, center_value_);
|
|
263
|
+
DRACO_DCHECK_LE(*t, center_value_);
|
|
264
|
+
DRACO_DCHECK_GE(*s, -center_value_);
|
|
265
|
+
DRACO_DCHECK_GE(*t, -center_value_);
|
|
266
|
+
*s *= -1;
|
|
267
|
+
*t *= -1;
|
|
268
|
+
this->InvertDiamond(s, t);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// For correction values.
|
|
272
|
+
int32_t ModMax(int32_t x) const {
|
|
273
|
+
if (x > this->center_value()) {
|
|
274
|
+
return x - this->max_quantized_value();
|
|
275
|
+
}
|
|
276
|
+
if (x < -this->center_value()) {
|
|
277
|
+
return x + this->max_quantized_value();
|
|
278
|
+
}
|
|
279
|
+
return x;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// For correction values.
|
|
283
|
+
int32_t MakePositive(int32_t x) const {
|
|
284
|
+
DRACO_DCHECK_LE(x, this->center_value() * 2);
|
|
285
|
+
if (x < 0) {
|
|
286
|
+
return x + this->max_quantized_value();
|
|
287
|
+
}
|
|
288
|
+
return x;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
int32_t quantization_bits() const { return quantization_bits_; }
|
|
292
|
+
int32_t max_quantized_value() const { return max_quantized_value_; }
|
|
293
|
+
int32_t max_value() const { return max_value_; }
|
|
294
|
+
int32_t center_value() const { return center_value_; }
|
|
295
|
+
|
|
296
|
+
private:
|
|
297
|
+
inline void OctahedralCoordsToUnitVector(float in_s_scaled, float in_t_scaled,
|
|
298
|
+
float *out_vector) const {
|
|
299
|
+
// Background about the encoding:
|
|
300
|
+
// A normal is encoded in a normalized space <s, t> depicted below. The
|
|
301
|
+
// encoding correponds to an octahedron that is unwrapped to a 2D plane.
|
|
302
|
+
// During encoding, a normal is projected to the surface of the octahedron
|
|
303
|
+
// and the projection is then unwrapped to the 2D plane. Decoding is the
|
|
304
|
+
// reverse of this process.
|
|
305
|
+
// All points in the central diamond are located on triangles on the
|
|
306
|
+
// right "hemisphere" of the octahedron while all points outside of the
|
|
307
|
+
// diamond are on the left hemisphere (basically, they would have to be
|
|
308
|
+
// wrapped along the diagonal edges to form the octahedron). The central
|
|
309
|
+
// point corresponds to the right most vertex of the octahedron and all
|
|
310
|
+
// corners of the plane correspond to the left most vertex of the
|
|
311
|
+
// octahedron.
|
|
312
|
+
//
|
|
313
|
+
// t
|
|
314
|
+
// ^ *-----*-----*
|
|
315
|
+
// | | /|\ |
|
|
316
|
+
// | / | \ |
|
|
317
|
+
// | / | \ |
|
|
318
|
+
// | / | \ |
|
|
319
|
+
// *-----*---- *
|
|
320
|
+
// | \ | / |
|
|
321
|
+
// | \ | / |
|
|
322
|
+
// | \ | / |
|
|
323
|
+
// | \|/ |
|
|
324
|
+
// *-----*-----* --> s
|
|
325
|
+
|
|
326
|
+
// Note that the input |in_s_scaled| and |in_t_scaled| are already scaled to
|
|
327
|
+
// <-1, 1> range. This way, the central point is at coordinate (0, 0).
|
|
328
|
+
float y = in_s_scaled;
|
|
329
|
+
float z = in_t_scaled;
|
|
330
|
+
|
|
331
|
+
// Remaining coordinate can be computed by projecting the (y, z) values onto
|
|
332
|
+
// the surface of the octahedron.
|
|
333
|
+
const float x = 1.f - std::abs(y) - std::abs(z);
|
|
334
|
+
|
|
335
|
+
// |x| is essentially a signed distance from the diagonal edges of the
|
|
336
|
+
// diamond shown on the figure above. It is positive for all points in the
|
|
337
|
+
// diamond (right hemisphere) and negative for all points outside the
|
|
338
|
+
// diamond (left hemisphere). For all points on the left hemisphere we need
|
|
339
|
+
// to update their (y, z) coordinates to account for the wrapping along
|
|
340
|
+
// the edges of the diamond.
|
|
341
|
+
float x_offset = -x;
|
|
342
|
+
x_offset = x_offset < 0 ? 0 : x_offset;
|
|
343
|
+
|
|
344
|
+
// This will do nothing for the points on the right hemisphere but it will
|
|
345
|
+
// mirror the (y, z) location along the nearest diagonal edge of the
|
|
346
|
+
// diamond.
|
|
347
|
+
y += y < 0 ? x_offset : -x_offset;
|
|
348
|
+
z += z < 0 ? x_offset : -x_offset;
|
|
349
|
+
|
|
350
|
+
// Normalize the computed vector.
|
|
351
|
+
const float norm_squared = x * x + y * y + z * z;
|
|
352
|
+
if (norm_squared < 1e-6) {
|
|
353
|
+
out_vector[0] = 0;
|
|
354
|
+
out_vector[1] = 0;
|
|
355
|
+
out_vector[2] = 0;
|
|
356
|
+
} else {
|
|
357
|
+
const float d = 1.0f / std::sqrt(norm_squared);
|
|
358
|
+
out_vector[0] = x * d;
|
|
359
|
+
out_vector[1] = y * d;
|
|
360
|
+
out_vector[2] = z * d;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
int32_t quantization_bits_;
|
|
365
|
+
int32_t max_quantized_value_;
|
|
366
|
+
int32_t max_value_;
|
|
367
|
+
float dequantization_scale_;
|
|
368
|
+
int32_t center_value_;
|
|
369
|
+
};
|
|
370
|
+
} // namespace draco
|
|
371
|
+
|
|
372
|
+
#endif // DRACO_COMPRESSION_ATTRIBUTES_NORMAL_COMPRESSION_UTILS_H_
|