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,184 @@
|
|
|
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
|
+
// This files provides a basic framework for strongly typed indices that are
|
|
16
|
+
// used within the Draco library. The motivation of using strongly typed indices
|
|
17
|
+
// is to prevent bugs caused by mixing up incompatible indices, such as indexing
|
|
18
|
+
// mesh faces with point indices and vice versa.
|
|
19
|
+
//
|
|
20
|
+
// Usage:
|
|
21
|
+
// Define strongly typed index using macro:
|
|
22
|
+
//
|
|
23
|
+
// DEFINE_NEW_DRACO_INDEX_TYPE(value_type, name)
|
|
24
|
+
//
|
|
25
|
+
// where |value_type| is the data type of the index value (such as int32_t)
|
|
26
|
+
// and |name| is a unique typename of the new index.
|
|
27
|
+
//
|
|
28
|
+
// E.g., we can define new index types as:
|
|
29
|
+
//
|
|
30
|
+
// DEFINE_NEW_DRACO_INDEX_TYPE(int, PointIndex)
|
|
31
|
+
// DEFINE_NEW_DRACO_INDEX_TYPE(int, FaceIndex)
|
|
32
|
+
//
|
|
33
|
+
// The new types can then be used in the similar way as the regular weakly
|
|
34
|
+
// typed indices (such as int32, int64, ...), but they cannot be
|
|
35
|
+
// accidentally misassigned. E.g.:
|
|
36
|
+
//
|
|
37
|
+
// PointIndex point_index(10);
|
|
38
|
+
// FaceIndex face_index;
|
|
39
|
+
// face_index = point_index; // Compile error!
|
|
40
|
+
//
|
|
41
|
+
// One can still cast one type to another explicitly by accessing the index
|
|
42
|
+
// value directly using the .value() method:
|
|
43
|
+
//
|
|
44
|
+
// face_index = FaceIndex(point_index.value()); // Compiles OK.
|
|
45
|
+
//
|
|
46
|
+
// Strongly typed indices support most of the common binary and unary
|
|
47
|
+
// operators and support for additional operators can be added if
|
|
48
|
+
// necessary.
|
|
49
|
+
|
|
50
|
+
#ifndef DRACO_CORE_DRACO_INDEX_TYPE_H_
|
|
51
|
+
#define DRACO_CORE_DRACO_INDEX_TYPE_H_
|
|
52
|
+
|
|
53
|
+
#include <ostream>
|
|
54
|
+
|
|
55
|
+
#include "draco/draco_features.h"
|
|
56
|
+
|
|
57
|
+
namespace draco {
|
|
58
|
+
|
|
59
|
+
#define DEFINE_NEW_DRACO_INDEX_TYPE(value_type, name) \
|
|
60
|
+
struct name##_tag_type_ {}; \
|
|
61
|
+
typedef IndexType<value_type, name##_tag_type_> name;
|
|
62
|
+
|
|
63
|
+
template <class ValueTypeT, class TagT>
|
|
64
|
+
class IndexType {
|
|
65
|
+
public:
|
|
66
|
+
typedef IndexType<ValueTypeT, TagT> ThisIndexType;
|
|
67
|
+
typedef ValueTypeT ValueType;
|
|
68
|
+
|
|
69
|
+
constexpr IndexType() : value_(ValueTypeT()) {}
|
|
70
|
+
constexpr IndexType(const IndexType &i) : value_(i.value_) {}
|
|
71
|
+
constexpr explicit IndexType(ValueTypeT value) : value_(value) {}
|
|
72
|
+
|
|
73
|
+
constexpr ValueTypeT value() const { return value_; }
|
|
74
|
+
|
|
75
|
+
constexpr bool operator==(const IndexType &i) const {
|
|
76
|
+
return value_ == i.value_;
|
|
77
|
+
}
|
|
78
|
+
constexpr bool operator==(const ValueTypeT &val) const {
|
|
79
|
+
return value_ == val;
|
|
80
|
+
}
|
|
81
|
+
constexpr bool operator!=(const IndexType &i) const {
|
|
82
|
+
return value_ != i.value_;
|
|
83
|
+
}
|
|
84
|
+
constexpr bool operator!=(const ValueTypeT &val) const {
|
|
85
|
+
return value_ != val;
|
|
86
|
+
}
|
|
87
|
+
constexpr bool operator<(const IndexType &i) const {
|
|
88
|
+
return value_ < i.value_;
|
|
89
|
+
}
|
|
90
|
+
constexpr bool operator<(const ValueTypeT &val) const { return value_ < val; }
|
|
91
|
+
constexpr bool operator>(const IndexType &i) const {
|
|
92
|
+
return value_ > i.value_;
|
|
93
|
+
}
|
|
94
|
+
constexpr bool operator>(const ValueTypeT &val) const { return value_ > val; }
|
|
95
|
+
constexpr bool operator>=(const IndexType &i) const {
|
|
96
|
+
return value_ >= i.value_;
|
|
97
|
+
}
|
|
98
|
+
constexpr bool operator>=(const ValueTypeT &val) const {
|
|
99
|
+
return value_ >= val;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
inline ThisIndexType &operator++() {
|
|
103
|
+
++value_;
|
|
104
|
+
return *this;
|
|
105
|
+
}
|
|
106
|
+
inline ThisIndexType operator++(int) {
|
|
107
|
+
const ThisIndexType ret(value_);
|
|
108
|
+
++value_;
|
|
109
|
+
return ret;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
inline ThisIndexType &operator--() {
|
|
113
|
+
--value_;
|
|
114
|
+
return *this;
|
|
115
|
+
}
|
|
116
|
+
inline ThisIndexType operator--(int) {
|
|
117
|
+
const ThisIndexType ret(value_);
|
|
118
|
+
--value_;
|
|
119
|
+
return ret;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
constexpr ThisIndexType operator+(const IndexType &i) const {
|
|
123
|
+
return ThisIndexType(value_ + i.value_);
|
|
124
|
+
}
|
|
125
|
+
constexpr ThisIndexType operator+(const ValueTypeT &val) const {
|
|
126
|
+
return ThisIndexType(value_ + val);
|
|
127
|
+
}
|
|
128
|
+
constexpr ThisIndexType operator-(const IndexType &i) const {
|
|
129
|
+
return ThisIndexType(value_ - i.value_);
|
|
130
|
+
}
|
|
131
|
+
constexpr ThisIndexType operator-(const ValueTypeT &val) const {
|
|
132
|
+
return ThisIndexType(value_ - val);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
inline ThisIndexType &operator+=(const IndexType &i) {
|
|
136
|
+
value_ += i.value_;
|
|
137
|
+
return *this;
|
|
138
|
+
}
|
|
139
|
+
inline ThisIndexType operator+=(const ValueTypeT &val) {
|
|
140
|
+
value_ += val;
|
|
141
|
+
return *this;
|
|
142
|
+
}
|
|
143
|
+
inline ThisIndexType &operator-=(const IndexType &i) {
|
|
144
|
+
value_ -= i.value_;
|
|
145
|
+
return *this;
|
|
146
|
+
}
|
|
147
|
+
inline ThisIndexType operator-=(const ValueTypeT &val) {
|
|
148
|
+
value_ -= val;
|
|
149
|
+
return *this;
|
|
150
|
+
}
|
|
151
|
+
inline ThisIndexType &operator=(const ThisIndexType &i) {
|
|
152
|
+
value_ = i.value_;
|
|
153
|
+
return *this;
|
|
154
|
+
}
|
|
155
|
+
inline ThisIndexType &operator=(const ValueTypeT &val) {
|
|
156
|
+
value_ = val;
|
|
157
|
+
return *this;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private:
|
|
161
|
+
ValueTypeT value_;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// Stream operator << provided for logging purposes.
|
|
165
|
+
template <class ValueTypeT, class TagT>
|
|
166
|
+
std::ostream &operator<<(std::ostream &os, IndexType<ValueTypeT, TagT> index) {
|
|
167
|
+
return os << index.value();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
} // namespace draco
|
|
171
|
+
|
|
172
|
+
// Specialize std::hash for the strongly indexed types.
|
|
173
|
+
namespace std {
|
|
174
|
+
|
|
175
|
+
template <class ValueTypeT, class TagT>
|
|
176
|
+
struct hash<draco::IndexType<ValueTypeT, TagT>> {
|
|
177
|
+
size_t operator()(const draco::IndexType<ValueTypeT, TagT> &i) const {
|
|
178
|
+
return static_cast<size_t>(i.value());
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
} // namespace std
|
|
183
|
+
|
|
184
|
+
#endif // DRACO_CORE_DRACO_INDEX_TYPE_H_
|
|
@@ -0,0 +1,90 @@
|
|
|
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_CORE_DRACO_INDEX_TYPE_VECTOR_H_
|
|
16
|
+
#define DRACO_CORE_DRACO_INDEX_TYPE_VECTOR_H_
|
|
17
|
+
|
|
18
|
+
#include <cstddef>
|
|
19
|
+
#include <utility>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
#include "draco/core/draco_index_type.h"
|
|
23
|
+
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// A wrapper around the standard std::vector that supports indexing of the
|
|
27
|
+
// vector entries using the strongly typed indices as defined in
|
|
28
|
+
// draco_index_type.h.
|
|
29
|
+
// TODO(ostava): Make the interface more complete. It's currently missing some
|
|
30
|
+
// features.
|
|
31
|
+
template <class IndexTypeT, class ValueTypeT>
|
|
32
|
+
class IndexTypeVector {
|
|
33
|
+
public:
|
|
34
|
+
typedef typename std::vector<ValueTypeT>::const_reference const_reference;
|
|
35
|
+
typedef typename std::vector<ValueTypeT>::reference reference;
|
|
36
|
+
typedef typename std::vector<ValueTypeT>::iterator iterator;
|
|
37
|
+
typedef typename std::vector<ValueTypeT>::const_iterator const_iterator;
|
|
38
|
+
|
|
39
|
+
IndexTypeVector() {}
|
|
40
|
+
explicit IndexTypeVector(size_t size) : vector_(size) {}
|
|
41
|
+
IndexTypeVector(size_t size, const ValueTypeT &val) : vector_(size, val) {}
|
|
42
|
+
|
|
43
|
+
iterator begin() { return vector_.begin(); }
|
|
44
|
+
const_iterator begin() const { return vector_.begin(); }
|
|
45
|
+
iterator end() { return vector_.end(); }
|
|
46
|
+
const_iterator end() const { return vector_.end(); }
|
|
47
|
+
|
|
48
|
+
void clear() { vector_.clear(); }
|
|
49
|
+
void reserve(size_t size) { vector_.reserve(size); }
|
|
50
|
+
void resize(size_t size) { vector_.resize(size); }
|
|
51
|
+
void resize(size_t size, const ValueTypeT &val) { vector_.resize(size, val); }
|
|
52
|
+
void assign(size_t size, const ValueTypeT &val) { vector_.assign(size, val); }
|
|
53
|
+
iterator erase(iterator position) { return vector_.erase(position); }
|
|
54
|
+
|
|
55
|
+
void swap(IndexTypeVector<IndexTypeT, ValueTypeT> &arg) {
|
|
56
|
+
vector_.swap(arg.vector_);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
size_t size() const { return vector_.size(); }
|
|
60
|
+
bool empty() const { return vector_.empty(); }
|
|
61
|
+
|
|
62
|
+
void push_back(const ValueTypeT &val) { vector_.push_back(val); }
|
|
63
|
+
void push_back(ValueTypeT &&val) { vector_.push_back(std::move(val)); }
|
|
64
|
+
|
|
65
|
+
template <typename... Args>
|
|
66
|
+
void emplace_back(Args &&...args) {
|
|
67
|
+
vector_.emplace_back(std::forward<Args>(args)...);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
inline reference operator[](const IndexTypeT &index) {
|
|
71
|
+
return vector_[index.value()];
|
|
72
|
+
}
|
|
73
|
+
inline const_reference operator[](const IndexTypeT &index) const {
|
|
74
|
+
return vector_[index.value()];
|
|
75
|
+
}
|
|
76
|
+
inline reference at(const IndexTypeT &index) {
|
|
77
|
+
return vector_[index.value()];
|
|
78
|
+
}
|
|
79
|
+
inline const_reference at(const IndexTypeT &index) const {
|
|
80
|
+
return vector_[index.value()];
|
|
81
|
+
}
|
|
82
|
+
const ValueTypeT *data() const { return vector_.data(); }
|
|
83
|
+
|
|
84
|
+
private:
|
|
85
|
+
std::vector<ValueTypeT> vector_;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace draco
|
|
89
|
+
|
|
90
|
+
#endif // DRACO_CORE_DRACO_INDEX_TYPE_VECTOR_H_
|
|
@@ -0,0 +1,52 @@
|
|
|
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_CORE_DRACO_TYPES_H_
|
|
16
|
+
#define DRACO_CORE_DRACO_TYPES_H_
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
#include "draco/draco_features.h"
|
|
23
|
+
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
enum DataType {
|
|
27
|
+
// Not a legal value for DataType. Used to indicate a field has not been set.
|
|
28
|
+
DT_INVALID = 0,
|
|
29
|
+
DT_INT8,
|
|
30
|
+
DT_UINT8,
|
|
31
|
+
DT_INT16,
|
|
32
|
+
DT_UINT16,
|
|
33
|
+
DT_INT32,
|
|
34
|
+
DT_UINT32,
|
|
35
|
+
DT_INT64,
|
|
36
|
+
DT_UINT64,
|
|
37
|
+
DT_FLOAT32,
|
|
38
|
+
DT_FLOAT64,
|
|
39
|
+
DT_BOOL,
|
|
40
|
+
DT_TYPES_COUNT
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
int32_t DataTypeLength(DataType dt);
|
|
44
|
+
|
|
45
|
+
// Equivalent to std::is_integral for draco::DataType. Returns true for all
|
|
46
|
+
// signed and unsigned integer types (including DT_BOOL). Returns false
|
|
47
|
+
// otherwise.
|
|
48
|
+
bool IsDataTypeIntegral(DataType dt);
|
|
49
|
+
|
|
50
|
+
} // namespace draco
|
|
51
|
+
|
|
52
|
+
#endif // DRACO_CORE_DRACO_TYPES_H_
|
|
@@ -0,0 +1,25 @@
|
|
|
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_CORE_DRACO_VERSION_H_
|
|
16
|
+
#define DRACO_CORE_DRACO_VERSION_H_
|
|
17
|
+
|
|
18
|
+
namespace draco {
|
|
19
|
+
|
|
20
|
+
// Draco version is comprised of <major>.<minor>.<revision>.
|
|
21
|
+
static const char kDracoVersion[] = "1.5.7";
|
|
22
|
+
|
|
23
|
+
} // namespace draco
|
|
24
|
+
|
|
25
|
+
#endif // DRACO_CORE_DRACO_VERSION_H_
|
|
@@ -0,0 +1,152 @@
|
|
|
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_CORE_ENCODER_BUFFER_H_
|
|
16
|
+
#define DRACO_CORE_ENCODER_BUFFER_H_
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "draco/core/bit_utils.h"
|
|
22
|
+
#include "draco/core/macros.h"
|
|
23
|
+
|
|
24
|
+
namespace draco {
|
|
25
|
+
|
|
26
|
+
// Class representing a buffer that can be used for either for byte-aligned
|
|
27
|
+
// encoding of arbitrary data structures or for encoding of variable-length
|
|
28
|
+
// bit data.
|
|
29
|
+
class EncoderBuffer {
|
|
30
|
+
public:
|
|
31
|
+
EncoderBuffer();
|
|
32
|
+
void Clear();
|
|
33
|
+
void Resize(int64_t nbytes);
|
|
34
|
+
|
|
35
|
+
// Start encoding a bit sequence. A maximum size of the sequence needs to
|
|
36
|
+
// be known upfront.
|
|
37
|
+
// If encode_size is true, the size of encoded bit sequence is stored before
|
|
38
|
+
// the sequence. Decoder can then use this size to skip over the bit sequence
|
|
39
|
+
// if needed.
|
|
40
|
+
// Returns false on error.
|
|
41
|
+
bool StartBitEncoding(int64_t required_bits, bool encode_size);
|
|
42
|
+
|
|
43
|
+
// End the encoding of the bit sequence and return to the default byte-aligned
|
|
44
|
+
// encoding.
|
|
45
|
+
void EndBitEncoding();
|
|
46
|
+
|
|
47
|
+
// Encode up to 32 bits into the buffer. Can be called only in between
|
|
48
|
+
// StartBitEncoding and EndBitEncoding. Otherwise returns false.
|
|
49
|
+
bool EncodeLeastSignificantBits32(int nbits, uint32_t value) {
|
|
50
|
+
if (!bit_encoder_active()) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
bit_encoder_->PutBits(value, nbits);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
// Encode an arbitrary data type.
|
|
57
|
+
// Can be used only when we are not encoding a bit-sequence.
|
|
58
|
+
// Returns false when the value couldn't be encoded.
|
|
59
|
+
template <typename T>
|
|
60
|
+
bool Encode(const T &data) {
|
|
61
|
+
if (bit_encoder_active()) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const uint8_t *src_data = reinterpret_cast<const uint8_t *>(&data);
|
|
65
|
+
buffer_.insert(buffer_.end(), src_data, src_data + sizeof(T));
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
bool Encode(const void *data, size_t data_size) {
|
|
69
|
+
if (bit_encoder_active()) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const uint8_t *src_data = reinterpret_cast<const uint8_t *>(data);
|
|
73
|
+
buffer_.insert(buffer_.end(), src_data, src_data + data_size);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
bool bit_encoder_active() const { return bit_encoder_reserved_bytes_ > 0; }
|
|
78
|
+
const char *data() const { return buffer_.data(); }
|
|
79
|
+
size_t size() const { return buffer_.size(); }
|
|
80
|
+
std::vector<char> *buffer() { return &buffer_; }
|
|
81
|
+
|
|
82
|
+
private:
|
|
83
|
+
// Internal helper class to encode bits to a bit buffer.
|
|
84
|
+
class BitEncoder {
|
|
85
|
+
public:
|
|
86
|
+
// |data| is the buffer to write the bits into.
|
|
87
|
+
explicit BitEncoder(char *data) : bit_buffer_(data), bit_offset_(0) {}
|
|
88
|
+
|
|
89
|
+
// Write |nbits| of |data| into the bit buffer.
|
|
90
|
+
void PutBits(uint32_t data, int32_t nbits) {
|
|
91
|
+
DRACO_DCHECK_GE(nbits, 0);
|
|
92
|
+
DRACO_DCHECK_LE(nbits, 32);
|
|
93
|
+
for (int32_t bit = 0; bit < nbits; ++bit) {
|
|
94
|
+
PutBit((data >> bit) & 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Return number of bits encoded so far.
|
|
99
|
+
uint64_t Bits() const { return static_cast<uint64_t>(bit_offset_); }
|
|
100
|
+
|
|
101
|
+
// TODO(fgalligan): Remove this function once we know we do not need the
|
|
102
|
+
// old API anymore.
|
|
103
|
+
// This is a function of an old API, that currently does nothing.
|
|
104
|
+
void Flush(int /* left_over_bit_value */) {}
|
|
105
|
+
|
|
106
|
+
// Return the number of bits required to store the given number
|
|
107
|
+
static uint32_t BitsRequired(uint32_t x) {
|
|
108
|
+
return static_cast<uint32_t>(MostSignificantBit(x));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private:
|
|
112
|
+
void PutBit(uint8_t value) {
|
|
113
|
+
const int byte_size = 8;
|
|
114
|
+
const uint64_t off = static_cast<uint64_t>(bit_offset_);
|
|
115
|
+
const uint64_t byte_offset = off / byte_size;
|
|
116
|
+
const int bit_shift = off % byte_size;
|
|
117
|
+
|
|
118
|
+
// TODO(fgalligan): Check performance if we add a branch and only do one
|
|
119
|
+
// memory write if bit_shift is 7. Also try using a temporary variable to
|
|
120
|
+
// hold the bits before writing to the buffer.
|
|
121
|
+
|
|
122
|
+
bit_buffer_[byte_offset] &= ~(1 << bit_shift);
|
|
123
|
+
bit_buffer_[byte_offset] |= value << bit_shift;
|
|
124
|
+
bit_offset_++;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
char *bit_buffer_;
|
|
128
|
+
size_t bit_offset_;
|
|
129
|
+
};
|
|
130
|
+
friend class BufferBitCodingTest;
|
|
131
|
+
// All data is stored in this vector.
|
|
132
|
+
std::vector<char> buffer_;
|
|
133
|
+
|
|
134
|
+
// Bit encoder is used when encoding variable-length bit data.
|
|
135
|
+
// TODO(ostava): Currently encoder needs to be recreated each time
|
|
136
|
+
// StartBitEncoding method is called. This is not necessary if BitEncoder
|
|
137
|
+
// supported reset function which can easily added but let's leave that for
|
|
138
|
+
// later.
|
|
139
|
+
std::unique_ptr<BitEncoder> bit_encoder_;
|
|
140
|
+
|
|
141
|
+
// The number of bytes reserved for bit encoder.
|
|
142
|
+
// Values > 0 indicate we are in the bit encoding mode.
|
|
143
|
+
int64_t bit_encoder_reserved_bytes_;
|
|
144
|
+
|
|
145
|
+
// Flag used indicating that we need to store the length of the currently
|
|
146
|
+
// processed bit sequence.
|
|
147
|
+
bool encode_bit_sequence_size_;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
} // namespace draco
|
|
151
|
+
|
|
152
|
+
#endif // DRACO_CORE_ENCODER_BUFFER_H_
|
|
@@ -0,0 +1,64 @@
|
|
|
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_CORE_HASH_UTILS_H_
|
|
16
|
+
#define DRACO_CORE_HASH_UTILS_H_
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
#include <cstddef>
|
|
21
|
+
#include <functional>
|
|
22
|
+
|
|
23
|
+
namespace draco {
|
|
24
|
+
|
|
25
|
+
template <typename T1, typename T2>
|
|
26
|
+
size_t HashCombine(T1 a, T2 b) {
|
|
27
|
+
const size_t hash1 = std::hash<T1>()(a);
|
|
28
|
+
const size_t hash2 = std::hash<T2>()(b);
|
|
29
|
+
return (hash1 << 2) ^ (hash2 << 1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
template <typename T>
|
|
33
|
+
size_t HashCombine(T a, size_t hash) {
|
|
34
|
+
const size_t hasha = std::hash<T>()(a);
|
|
35
|
+
return (hash) ^ (hasha + 239);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
inline uint64_t HashCombine(uint64_t a, uint64_t b) {
|
|
39
|
+
return (a + 1013) ^ (b + 107) << 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Will never return 1 or 0.
|
|
43
|
+
uint64_t FingerprintString(const char *s, size_t len);
|
|
44
|
+
|
|
45
|
+
// Hash for std::array.
|
|
46
|
+
template <typename T>
|
|
47
|
+
struct HashArray {
|
|
48
|
+
size_t operator()(const T &a) const {
|
|
49
|
+
size_t hash = 79; // Magic number.
|
|
50
|
+
for (unsigned int i = 0; i < std::tuple_size<T>::value; ++i) {
|
|
51
|
+
hash = HashCombine(hash, ValueHash(a[i]));
|
|
52
|
+
}
|
|
53
|
+
return hash;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
template <typename V>
|
|
57
|
+
size_t ValueHash(const V &val) const {
|
|
58
|
+
return std::hash<V>()(val);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace draco
|
|
63
|
+
|
|
64
|
+
#endif // DRACO_CORE_HASH_UTILS_H_
|
|
@@ -0,0 +1,124 @@
|
|
|
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_CORE_MACROS_H_
|
|
16
|
+
#define DRACO_CORE_MACROS_H_
|
|
17
|
+
|
|
18
|
+
#include <cassert>
|
|
19
|
+
|
|
20
|
+
#include "draco/draco_features.h"
|
|
21
|
+
|
|
22
|
+
#ifdef ANDROID_LOGGING
|
|
23
|
+
#include <android/log.h>
|
|
24
|
+
#define LOG_TAG "draco"
|
|
25
|
+
#define DRACO_LOGI(...) \
|
|
26
|
+
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
|
27
|
+
#define DRACO_LOGE(...) \
|
|
28
|
+
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
|
29
|
+
#else
|
|
30
|
+
#define DRACO_LOGI printf
|
|
31
|
+
#define DRACO_LOGE printf
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#include <iostream>
|
|
35
|
+
namespace draco {
|
|
36
|
+
|
|
37
|
+
#ifndef FALLTHROUGH_INTENDED
|
|
38
|
+
#if defined(__clang__) && defined(__has_warning)
|
|
39
|
+
#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
|
|
40
|
+
#define FALLTHROUGH_INTENDED [[clang::fallthrough]]
|
|
41
|
+
#endif
|
|
42
|
+
#elif defined(__GNUC__) && __GNUC__ >= 7
|
|
43
|
+
#define FALLTHROUGH_INTENDED [[gnu::fallthrough]]
|
|
44
|
+
#endif // FALLTHROUGH_INTENDED
|
|
45
|
+
|
|
46
|
+
// If FALLTHROUGH_INTENDED is still not defined, define it.
|
|
47
|
+
#ifndef FALLTHROUGH_INTENDED
|
|
48
|
+
#define FALLTHROUGH_INTENDED \
|
|
49
|
+
do { \
|
|
50
|
+
} while (0)
|
|
51
|
+
#endif
|
|
52
|
+
#endif // FALLTHROUGH_INTENDED
|
|
53
|
+
|
|
54
|
+
#ifndef LOG
|
|
55
|
+
#define LOG(...) std::cout
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
#ifndef VLOG
|
|
59
|
+
#define VLOG(...) std::cout
|
|
60
|
+
#endif
|
|
61
|
+
|
|
62
|
+
} // namespace draco
|
|
63
|
+
|
|
64
|
+
#ifndef DISALLOW_COPY_AND_ASSIGN
|
|
65
|
+
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
66
|
+
TypeName(const TypeName &) = delete; \
|
|
67
|
+
void operator=(const TypeName &) = delete;
|
|
68
|
+
#endif // DISALLOW_COPY_AND_ASSIGN
|
|
69
|
+
|
|
70
|
+
#ifdef DRACO_DEBUG
|
|
71
|
+
#define DRACO_DCHECK(x) (assert(x));
|
|
72
|
+
#define DRACO_DCHECK_EQ(a, b) assert((a) == (b));
|
|
73
|
+
#define DRACO_DCHECK_NE(a, b) assert((a) != (b));
|
|
74
|
+
#define DRACO_DCHECK_GE(a, b) assert((a) >= (b));
|
|
75
|
+
#define DRACO_DCHECK_GT(a, b) assert((a) > (b));
|
|
76
|
+
#define DRACO_DCHECK_LE(a, b) assert((a) <= (b));
|
|
77
|
+
#define DRACO_DCHECK_LT(a, b) assert((a) < (b));
|
|
78
|
+
#define DRACO_DCHECK_NOTNULL(x) assert((x) != NULL);
|
|
79
|
+
#else
|
|
80
|
+
#define DRACO_DCHECK(x)
|
|
81
|
+
#define DRACO_DCHECK_EQ(a, b)
|
|
82
|
+
#define DRACO_DCHECK_NE(a, b)
|
|
83
|
+
#define DRACO_DCHECK_GE(a, b)
|
|
84
|
+
#define DRACO_DCHECK_GT(a, b)
|
|
85
|
+
#define DRACO_DCHECK_LE(a, b)
|
|
86
|
+
#define DRACO_DCHECK_LT(a, b)
|
|
87
|
+
#define DRACO_DCHECK_NOTNULL(x)
|
|
88
|
+
#endif // DRACO_DEBUG
|
|
89
|
+
|
|
90
|
+
// Helper macros for concatenating macro values.
|
|
91
|
+
#define DRACO_MACROS_IMPL_CONCAT_INNER_(x, y) x##y
|
|
92
|
+
#define DRACO_MACROS_IMPL_CONCAT_(x, y) DRACO_MACROS_IMPL_CONCAT_INNER_(x, y)
|
|
93
|
+
|
|
94
|
+
#define DRACO_MACROS_IMPL_CONCAT_INNER_3_(x, y, z) x##y##z
|
|
95
|
+
#define DRACO_MACROS_IMPL_CONCAT_3_(x, y, z) \
|
|
96
|
+
DRACO_MACROS_IMPL_CONCAT_INNER_3_(x, y, z)
|
|
97
|
+
|
|
98
|
+
// Expand the n-th argument of the macro. Used to select an argument based on
|
|
99
|
+
// the number of entries in a variadic macro argument. Example usage:
|
|
100
|
+
//
|
|
101
|
+
// #define FUNC_1(x) x
|
|
102
|
+
// #define FUNC_2(x, y) x + y
|
|
103
|
+
// #define FUNC_3(x, y, z) x + y + z
|
|
104
|
+
//
|
|
105
|
+
// #define VARIADIC_MACRO(...)
|
|
106
|
+
// DRACO_SELECT_NTH_FROM_3(__VA_ARGS__, FUNC_3, FUNC_2, FUNC_1) __VA_ARGS__
|
|
107
|
+
//
|
|
108
|
+
#define DRACO_SELECT_NTH_FROM_2(_1, _2, NAME, ...) NAME
|
|
109
|
+
#define DRACO_SELECT_NTH_FROM_3(_1, _2, _3, NAME, ...) NAME
|
|
110
|
+
#define DRACO_SELECT_NTH_FROM_4(_1, _2, _3, _4, NAME, ...) NAME
|
|
111
|
+
|
|
112
|
+
// Macro that converts the Draco bit-stream into one uint16_t number.
|
|
113
|
+
// Useful mostly when checking version numbers.
|
|
114
|
+
#define DRACO_BITSTREAM_VERSION(MAJOR, MINOR) \
|
|
115
|
+
((static_cast<uint16_t>(MAJOR) << 8) | MINOR)
|
|
116
|
+
|
|
117
|
+
// Macro that converts the uint16_t Draco bit-stream number into the major
|
|
118
|
+
// and minor components respectively.
|
|
119
|
+
#define DRACO_BISTREAM_VERSION_MAJOR(VERSION) \
|
|
120
|
+
(static_cast<uint8_t>(VERSION >> 8))
|
|
121
|
+
#define DRACO_BISTREAM_VERSION_MINOR(VERSION) \
|
|
122
|
+
(static_cast<uint8_t>(VERSION & 0xFF))
|
|
123
|
+
|
|
124
|
+
#endif // DRACO_CORE_MACROS_H_
|