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.
Files changed (214) hide show
  1. bin/draco_decoder.exe +0 -0
  2. bin/draco_encoder.exe +0 -0
  3. dracox/__init__.py +252 -0
  4. dracox/dracox_ext.cp39-win_amd64.pyd +0 -0
  5. dracox-0.0.1.dist-info/METADATA +14 -0
  6. dracox-0.0.1.dist-info/RECORD +214 -0
  7. dracox-0.0.1.dist-info/WHEEL +5 -0
  8. include/draco/animation/keyframe_animation.h +107 -0
  9. include/draco/animation/keyframe_animation_decoder.h +34 -0
  10. include/draco/animation/keyframe_animation_encoder.h +39 -0
  11. include/draco/attributes/attribute_octahedron_transform.h +81 -0
  12. include/draco/attributes/attribute_quantization_transform.h +102 -0
  13. include/draco/attributes/attribute_transform.h +76 -0
  14. include/draco/attributes/attribute_transform_data.h +71 -0
  15. include/draco/attributes/attribute_transform_type.h +30 -0
  16. include/draco/attributes/geometry_attribute.h +541 -0
  17. include/draco/attributes/geometry_indices.h +54 -0
  18. include/draco/attributes/point_attribute.h +196 -0
  19. include/draco/compression/attributes/attributes_decoder.h +97 -0
  20. include/draco/compression/attributes/attributes_decoder_interface.h +62 -0
  21. include/draco/compression/attributes/attributes_encoder.h +154 -0
  22. include/draco/compression/attributes/kd_tree_attributes_decoder.h +50 -0
  23. include/draco/compression/attributes/kd_tree_attributes_encoder.h +51 -0
  24. include/draco/compression/attributes/kd_tree_attributes_shared.h +28 -0
  25. include/draco/compression/attributes/linear_sequencer.h +51 -0
  26. include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h +58 -0
  27. include/draco/compression/attributes/normal_compression_utils.h +372 -0
  28. include/draco/compression/attributes/point_d_vector.h +288 -0
  29. include/draco/compression/attributes/points_sequencer.h +63 -0
  30. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +236 -0
  31. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +413 -0
  32. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h +34 -0
  33. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h +72 -0
  34. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h +46 -0
  35. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h +46 -0
  36. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +176 -0
  37. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +180 -0
  38. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +117 -0
  39. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h +96 -0
  40. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +128 -0
  41. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +133 -0
  42. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +111 -0
  43. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h +78 -0
  44. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +372 -0
  45. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +318 -0
  46. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +143 -0
  47. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +136 -0
  48. include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h +282 -0
  49. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h +90 -0
  50. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h +194 -0
  51. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h +53 -0
  52. include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h +65 -0
  53. include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h +65 -0
  54. include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h +69 -0
  55. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h +90 -0
  56. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h +134 -0
  57. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h +55 -0
  58. include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h +77 -0
  59. include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h +85 -0
  60. include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h +60 -0
  61. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h +118 -0
  62. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h +116 -0
  63. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h +102 -0
  64. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h +115 -0
  65. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h +105 -0
  66. include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h +90 -0
  67. include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h +88 -0
  68. include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h +81 -0
  69. include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h +120 -0
  70. include/draco/compression/attributes/sequential_attribute_decoder.h +86 -0
  71. include/draco/compression/attributes/sequential_attribute_decoders_controller.h +61 -0
  72. include/draco/compression/attributes/sequential_attribute_encoder.h +134 -0
  73. include/draco/compression/attributes/sequential_attribute_encoders_controller.h +115 -0
  74. include/draco/compression/attributes/sequential_integer_attribute_decoder.h +76 -0
  75. include/draco/compression/attributes/sequential_integer_attribute_encoder.h +67 -0
  76. include/draco/compression/attributes/sequential_normal_attribute_decoder.h +83 -0
  77. include/draco/compression/attributes/sequential_normal_attribute_encoder.h +82 -0
  78. include/draco/compression/attributes/sequential_quantization_attribute_decoder.h +52 -0
  79. include/draco/compression/attributes/sequential_quantization_attribute_encoder.h +52 -0
  80. include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h +43 -0
  81. include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h +54 -0
  82. include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h +61 -0
  83. include/draco/compression/bit_coders/direct_bit_decoder.h +89 -0
  84. include/draco/compression/bit_coders/direct_bit_encoder.h +89 -0
  85. include/draco/compression/bit_coders/folded_integer_bit_decoder.h +77 -0
  86. include/draco/compression/bit_coders/folded_integer_bit_encoder.h +82 -0
  87. include/draco/compression/bit_coders/rans_bit_decoder.h +55 -0
  88. include/draco/compression/bit_coders/rans_bit_encoder.h +57 -0
  89. include/draco/compression/bit_coders/symbol_bit_decoder.h +36 -0
  90. include/draco/compression/bit_coders/symbol_bit_encoder.h +36 -0
  91. include/draco/compression/config/compression_shared.h +155 -0
  92. include/draco/compression/config/decoder_options.h +34 -0
  93. include/draco/compression/config/draco_options.h +249 -0
  94. include/draco/compression/config/encoder_options.h +101 -0
  95. include/draco/compression/config/encoding_features.h +39 -0
  96. include/draco/compression/decode.h +80 -0
  97. include/draco/compression/draco_compression_options.h +141 -0
  98. include/draco/compression/encode.h +139 -0
  99. include/draco/compression/encode_base.h +131 -0
  100. include/draco/compression/entropy/ans.h +526 -0
  101. include/draco/compression/entropy/rans_symbol_coding.h +53 -0
  102. include/draco/compression/entropy/rans_symbol_decoder.h +171 -0
  103. include/draco/compression/entropy/rans_symbol_encoder.h +290 -0
  104. include/draco/compression/entropy/shannon_entropy.h +110 -0
  105. include/draco/compression/entropy/symbol_decoding.h +29 -0
  106. include/draco/compression/entropy/symbol_encoding.h +47 -0
  107. include/draco/compression/expert_encode.h +160 -0
  108. include/draco/compression/mesh/mesh_decoder.h +68 -0
  109. include/draco/compression/mesh/mesh_edgebreaker_decoder.h +54 -0
  110. include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +228 -0
  111. include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h +47 -0
  112. include/draco/compression/mesh/mesh_edgebreaker_encoder.h +73 -0
  113. include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h +209 -0
  114. include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h +57 -0
  115. include/draco/compression/mesh/mesh_edgebreaker_shared.h +129 -0
  116. include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +201 -0
  117. include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +139 -0
  118. include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h +134 -0
  119. include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +172 -0
  120. include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +219 -0
  121. include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +226 -0
  122. include/draco/compression/mesh/mesh_encoder.h +84 -0
  123. include/draco/compression/mesh/mesh_sequential_decoder.h +39 -0
  124. include/draco/compression/mesh/mesh_sequential_encoder.h +56 -0
  125. include/draco/compression/mesh/traverser/depth_first_traverser.h +172 -0
  126. include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h +226 -0
  127. include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h +76 -0
  128. include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h +113 -0
  129. include/draco/compression/mesh/traverser/traverser_base.h +87 -0
  130. include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +369 -0
  131. include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +372 -0
  132. include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h +141 -0
  133. include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h +126 -0
  134. include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h +34 -0
  135. include/draco/compression/point_cloud/algorithms/point_cloud_types.h +76 -0
  136. include/draco/compression/point_cloud/algorithms/quantize_points_3.h +84 -0
  137. include/draco/compression/point_cloud/algorithms/queuing_policy.h +75 -0
  138. include/draco/compression/point_cloud/point_cloud_decoder.h +118 -0
  139. include/draco/compression/point_cloud/point_cloud_encoder.h +158 -0
  140. include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h +31 -0
  141. include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h +45 -0
  142. include/draco/compression/point_cloud/point_cloud_sequential_decoder.h +33 -0
  143. include/draco/compression/point_cloud/point_cloud_sequential_encoder.h +43 -0
  144. include/draco/core/bit_utils.h +127 -0
  145. include/draco/core/bounding_box.h +77 -0
  146. include/draco/core/constants.h +6 -0
  147. include/draco/core/cycle_timer.h +51 -0
  148. include/draco/core/data_buffer.h +82 -0
  149. include/draco/core/decoder_buffer.h +216 -0
  150. include/draco/core/divide.h +42 -0
  151. include/draco/core/draco_index_type.h +184 -0
  152. include/draco/core/draco_index_type_vector.h +90 -0
  153. include/draco/core/draco_types.h +52 -0
  154. include/draco/core/draco_version.h +25 -0
  155. include/draco/core/encoder_buffer.h +152 -0
  156. include/draco/core/hash_utils.h +64 -0
  157. include/draco/core/macros.h +124 -0
  158. include/draco/core/math_utils.h +79 -0
  159. include/draco/core/options.h +151 -0
  160. include/draco/core/quantization_utils.h +82 -0
  161. include/draco/core/status.h +83 -0
  162. include/draco/core/status_or.h +81 -0
  163. include/draco/core/varint_decoding.h +81 -0
  164. include/draco/core/varint_encoding.h +61 -0
  165. include/draco/core/vector_d.h +355 -0
  166. include/draco/draco_features.h +25 -0
  167. include/draco/io/file_reader_factory.h +34 -0
  168. include/draco/io/file_reader_interface.h +32 -0
  169. include/draco/io/file_utils.h +86 -0
  170. include/draco/io/file_writer_factory.h +34 -0
  171. include/draco/io/file_writer_interface.h +26 -0
  172. include/draco/io/file_writer_utils.h +38 -0
  173. include/draco/io/mesh_io.h +107 -0
  174. include/draco/io/obj_decoder.h +147 -0
  175. include/draco/io/obj_encoder.h +107 -0
  176. include/draco/io/parser_utils.h +66 -0
  177. include/draco/io/ply_decoder.h +69 -0
  178. include/draco/io/ply_encoder.h +54 -0
  179. include/draco/io/ply_property_reader.h +96 -0
  180. include/draco/io/ply_property_writer.h +94 -0
  181. include/draco/io/ply_reader.h +155 -0
  182. include/draco/io/point_cloud_io.h +89 -0
  183. include/draco/io/stdio_file_reader.h +48 -0
  184. include/draco/io/stdio_file_writer.h +42 -0
  185. include/draco/io/stl_decoder.h +38 -0
  186. include/draco/io/stl_encoder.h +52 -0
  187. include/draco/mesh/corner_table.h +397 -0
  188. include/draco/mesh/corner_table_iterators.h +309 -0
  189. include/draco/mesh/mesh.h +378 -0
  190. include/draco/mesh/mesh_are_equivalent.h +71 -0
  191. include/draco/mesh/mesh_attribute_corner_table.h +202 -0
  192. include/draco/mesh/mesh_cleanup.h +61 -0
  193. include/draco/mesh/mesh_features.h +93 -0
  194. include/draco/mesh/mesh_indices.h +37 -0
  195. include/draco/mesh/mesh_misc_functions.h +105 -0
  196. include/draco/mesh/mesh_stripifier.h +258 -0
  197. include/draco/mesh/triangle_soup_mesh_builder.h +134 -0
  198. include/draco/mesh/valence_cache.h +142 -0
  199. include/draco/metadata/geometry_metadata.h +142 -0
  200. include/draco/metadata/metadata.h +209 -0
  201. include/draco/metadata/metadata_decoder.h +42 -0
  202. include/draco/metadata/metadata_encoder.h +41 -0
  203. include/draco/metadata/property_attribute.h +107 -0
  204. include/draco/metadata/property_table.h +222 -0
  205. include/draco/metadata/structural_metadata.h +78 -0
  206. include/draco/metadata/structural_metadata_schema.h +118 -0
  207. include/draco/point_cloud/point_cloud.h +289 -0
  208. include/draco/point_cloud/point_cloud_builder.h +101 -0
  209. lib/draco.lib +0 -0
  210. lib/pkgconfig/draco.pc +6 -0
  211. share/cmake/draco/draco-config-version.cmake +43 -0
  212. share/cmake/draco/draco-config.cmake +27 -0
  213. share/cmake/draco/draco-targets-release.cmake +19 -0
  214. share/cmake/draco/draco-targets.cmake +107 -0
@@ -0,0 +1,79 @@
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_MATH_UTILS_H_
16
+ #define DRACO_CORE_MATH_UTILS_H_
17
+
18
+ #include <inttypes.h>
19
+
20
+ #include "draco/core/vector_d.h"
21
+
22
+ namespace draco {
23
+
24
+ #define DRACO_INCREMENT_MOD(I, M) (((I) == ((M)-1)) ? 0 : ((I) + 1))
25
+
26
+ // Returns floor(sqrt(x)) where x is an integer number. The main intend of this
27
+ // function is to provide a cross platform and deterministic implementation of
28
+ // square root for integer numbers. This function is not intended to be a
29
+ // replacement for std::sqrt() for general cases. IntSqrt is in fact about 3X
30
+ // slower compared to most implementation of std::sqrt().
31
+ inline uint64_t IntSqrt(uint64_t number) {
32
+ if (number == 0) {
33
+ return 0;
34
+ }
35
+ // First estimate good initial value of the square root as log2(number).
36
+ uint64_t act_number = number;
37
+ uint64_t square_root = 1;
38
+ while (act_number >= 2) {
39
+ // Double the square root until |square_root * square_root > number|.
40
+ square_root *= 2;
41
+ act_number /= 4;
42
+ }
43
+ // Perform Newton's (or Babylonian) method to find the true floor(sqrt()).
44
+ do {
45
+ // New |square_root| estimate is computed as the average between
46
+ // |square_root| and |number / square_root|.
47
+ square_root = (square_root + number / square_root) / 2;
48
+
49
+ // Note that after the first iteration, the estimate is always going to be
50
+ // larger or equal to the true square root value. Therefore to check
51
+ // convergence, we can simply detect condition when the square of the
52
+ // estimated square root is larger than the input.
53
+ } while (square_root * square_root > number);
54
+ return square_root;
55
+ }
56
+
57
+ // Performs the addition in unsigned type to avoid signed integer overflow. Note
58
+ // that the result will be the same (for non-overflowing values).
59
+ template <
60
+ typename DataTypeT,
61
+ typename std::enable_if<std::is_integral<DataTypeT>::value &&
62
+ std::is_signed<DataTypeT>::value>::type * = nullptr>
63
+ inline DataTypeT AddAsUnsigned(DataTypeT a, DataTypeT b) {
64
+ typedef typename std::make_unsigned<DataTypeT>::type DataTypeUT;
65
+ return static_cast<DataTypeT>(static_cast<DataTypeUT>(a) +
66
+ static_cast<DataTypeUT>(b));
67
+ }
68
+
69
+ template <typename DataTypeT,
70
+ typename std::enable_if<!std::is_integral<DataTypeT>::value ||
71
+ !std::is_signed<DataTypeT>::value>::type * =
72
+ nullptr>
73
+ inline DataTypeT AddAsUnsigned(DataTypeT a, DataTypeT b) {
74
+ return a + b;
75
+ }
76
+
77
+ } // namespace draco
78
+
79
+ #endif // DRACO_CORE_MATH_UTILS_H_
@@ -0,0 +1,151 @@
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_OPTIONS_H_
16
+ #define DRACO_CORE_OPTIONS_H_
17
+
18
+ #include <cstdlib>
19
+ #include <map>
20
+ #include <string>
21
+
22
+ #include "draco/draco_features.h"
23
+
24
+ namespace draco {
25
+
26
+ // Class for storing generic options as a <name, value> pair in a string map.
27
+ // The API provides helper methods for directly storing values of various types
28
+ // such as ints and bools. One named option should be set with only a single
29
+ // data type.
30
+ class Options {
31
+ public:
32
+ Options() = default;
33
+ ~Options() = default;
34
+
35
+ // Merges |other_options| on top of the existing options of this instance
36
+ // replacing all entries that are present in both options instances.
37
+ void MergeAndReplace(const Options &other_options);
38
+
39
+ void SetInt(const std::string &name, int val);
40
+ void SetFloat(const std::string &name, float val);
41
+ void SetBool(const std::string &name, bool val);
42
+ void SetString(const std::string &name, const std::string &val);
43
+ template <class VectorT>
44
+ void SetVector(const std::string &name, const VectorT &vec) {
45
+ SetVector(name, &vec[0], VectorT::dimension);
46
+ }
47
+ template <typename DataTypeT>
48
+ void SetVector(const std::string &name, const DataTypeT *vec, int num_dims);
49
+
50
+ // Getters will return a default value if the entry is not found. The default
51
+ // value can be specified in the overloaded version of each function.
52
+ int GetInt(const std::string &name) const;
53
+ int GetInt(const std::string &name, int default_val) const;
54
+ float GetFloat(const std::string &name) const;
55
+ float GetFloat(const std::string &name, float default_val) const;
56
+ bool GetBool(const std::string &name) const;
57
+ bool GetBool(const std::string &name, bool default_val) const;
58
+ std::string GetString(const std::string &name) const;
59
+ std::string GetString(const std::string &name,
60
+ const std::string &default_val) const;
61
+ template <class VectorT>
62
+ VectorT GetVector(const std::string &name, const VectorT &default_val) const;
63
+ // Unlike other Get functions, this function returns false if the option does
64
+ // not exist, otherwise it fills |out_val| with the vector values. If a
65
+ // default value is needed, it can be set in |out_val|.
66
+ template <typename DataTypeT>
67
+ bool GetVector(const std::string &name, int num_dims,
68
+ DataTypeT *out_val) const;
69
+
70
+ bool IsOptionSet(const std::string &name) const {
71
+ return options_.count(name) > 0;
72
+ }
73
+
74
+ private:
75
+ // All entries are internally stored as strings and converted to the desired
76
+ // return type based on the used Get* method.
77
+ std::map<std::string, std::string> options_;
78
+ };
79
+
80
+ template <typename DataTypeT>
81
+ void Options::SetVector(const std::string &name, const DataTypeT *vec,
82
+ int num_dims) {
83
+ std::string out;
84
+ for (int i = 0; i < num_dims; ++i) {
85
+ if (i > 0) {
86
+ out += " ";
87
+ }
88
+
89
+ // GNU STL on android doesn't include a proper std::to_string, but the libc++
90
+ // version does
91
+ #if defined(ANDROID) && !defined(_LIBCPP_VERSION)
92
+ out += to_string(vec[i]);
93
+ #else
94
+ out += std::to_string(vec[i]);
95
+ #endif
96
+ }
97
+ options_[name] = out;
98
+ }
99
+
100
+ template <class VectorT>
101
+ VectorT Options::GetVector(const std::string &name,
102
+ const VectorT &default_val) const {
103
+ VectorT ret = default_val;
104
+ GetVector(name, VectorT::dimension, &ret[0]);
105
+ return ret;
106
+ }
107
+
108
+ template <typename DataTypeT>
109
+ bool Options::GetVector(const std::string &name, int num_dims,
110
+ DataTypeT *out_val) const {
111
+ const auto it = options_.find(name);
112
+ if (it == options_.end()) {
113
+ return false;
114
+ }
115
+ const std::string value = it->second;
116
+ if (value.length() == 0) {
117
+ return true; // Option set but no data is present
118
+ }
119
+ const char *act_str = value.c_str();
120
+ char *next_str;
121
+ for (int i = 0; i < num_dims; ++i) {
122
+ if (std::is_integral<DataTypeT>::value) {
123
+ #ifdef ANDROID
124
+ const int val = strtol(act_str, &next_str, 10);
125
+ #else
126
+ const int val = static_cast<int>(std::strtol(act_str, &next_str, 10));
127
+ #endif
128
+ if (act_str == next_str) {
129
+ return true; // End reached.
130
+ }
131
+ act_str = next_str;
132
+ out_val[i] = static_cast<DataTypeT>(val);
133
+ } else {
134
+ #ifdef ANDROID
135
+ const float val = strtof(act_str, &next_str);
136
+ #else
137
+ const float val = std::strtof(act_str, &next_str);
138
+ #endif
139
+ if (act_str == next_str) {
140
+ return true; // End reached.
141
+ }
142
+ act_str = next_str;
143
+ out_val[i] = static_cast<DataTypeT>(val);
144
+ }
145
+ }
146
+ return true;
147
+ }
148
+
149
+ } // namespace draco
150
+
151
+ #endif // DRACO_CORE_OPTIONS_H_
@@ -0,0 +1,82 @@
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
+ // A set of classes for quantizing and dequantizing of floating point values
16
+ // into integers.
17
+ // The quantization works on all floating point numbers within (-range, +range)
18
+ // interval producing integers in range
19
+ // (-max_quantized_value, +max_quantized_value).
20
+
21
+ #ifndef DRACO_CORE_QUANTIZATION_UTILS_H_
22
+ #define DRACO_CORE_QUANTIZATION_UTILS_H_
23
+
24
+ #include <stdint.h>
25
+
26
+ #include <cmath>
27
+
28
+ #include "draco/core/macros.h"
29
+
30
+ namespace draco {
31
+
32
+ // Class for quantizing single precision floating point values. The values
33
+ // should be centered around zero and be within interval (-range, +range), where
34
+ // the range is specified in the Init() method. Alternatively, the quantization
35
+ // can be defined by |delta| that specifies the distance between two quantized
36
+ // values. Note that the quantizer always snaps the values to the nearest
37
+ // integer value. E.g. for |delta| == 1.f, values -0.4f and 0.4f would be
38
+ // both quantized to 0 while value 0.6f would be quantized to 1. If a value
39
+ // lies exactly between two quantized states, it is always rounded up. E.g.,
40
+ // for |delta| == 1.f, value -0.5f would be quantized to 0 while 0.5f would be
41
+ // quantized to 1.
42
+ class Quantizer {
43
+ public:
44
+ Quantizer();
45
+ void Init(float range, int32_t max_quantized_value);
46
+ void Init(float delta);
47
+ inline int32_t QuantizeFloat(float val) const {
48
+ val *= inverse_delta_;
49
+ return static_cast<int32_t>(floor(val + 0.5f));
50
+ }
51
+ inline int32_t operator()(float val) const { return QuantizeFloat(val); }
52
+
53
+ private:
54
+ float inverse_delta_;
55
+ };
56
+
57
+ // Class for dequantizing values that were previously quantized using the
58
+ // Quantizer class.
59
+ class Dequantizer {
60
+ public:
61
+ Dequantizer();
62
+
63
+ // Initializes the dequantizer. Both parameters must correspond to the values
64
+ // provided to the initializer of the Quantizer class.
65
+ // Returns false when the initialization fails.
66
+ bool Init(float range, int32_t max_quantized_value);
67
+
68
+ // Initializes the dequantizer using the |delta| between two quantized values.
69
+ bool Init(float delta);
70
+
71
+ inline float DequantizeFloat(int32_t val) const {
72
+ return static_cast<float>(val) * delta_;
73
+ }
74
+ inline float operator()(int32_t val) const { return DequantizeFloat(val); }
75
+
76
+ private:
77
+ float delta_;
78
+ };
79
+
80
+ } // namespace draco
81
+
82
+ #endif // DRACO_CORE_QUANTIZATION_UTILS_H_
@@ -0,0 +1,83 @@
1
+ // Copyright 2017 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_STATUS_H_
16
+ #define DRACO_CORE_STATUS_H_
17
+
18
+ #include <ostream>
19
+ #include <string>
20
+
21
+ namespace draco {
22
+
23
+ // Class encapsulating a return status of an operation with an optional error
24
+ // message. Intended to be used as a return type for functions instead of bool.
25
+ class Status {
26
+ public:
27
+ enum Code {
28
+ OK = 0,
29
+ DRACO_ERROR = -1, // Used for general errors.
30
+ IO_ERROR = -2, // Error when handling input or output stream.
31
+ INVALID_PARAMETER = -3, // Invalid parameter passed to a function.
32
+ UNSUPPORTED_VERSION = -4, // Input not compatible with the current version.
33
+ UNKNOWN_VERSION = -5, // Input was created with an unknown version of
34
+ // the library.
35
+ UNSUPPORTED_FEATURE = -6, // Input contains feature that is not supported.
36
+ };
37
+
38
+ Status() : code_(OK) {}
39
+ Status(const Status &status) = default;
40
+ Status(Status &&status) = default;
41
+ explicit Status(Code code) : code_(code) {}
42
+ Status(Code code, const std::string &error_msg)
43
+ : code_(code), error_msg_(error_msg) {}
44
+
45
+ Code code() const { return code_; }
46
+ const std::string &error_msg_string() const { return error_msg_; }
47
+ const char *error_msg() const { return error_msg_.c_str(); }
48
+ std::string code_string() const;
49
+ std::string code_and_error_string() const;
50
+
51
+ bool operator==(Code code) const { return code == code_; }
52
+ bool ok() const { return code_ == OK; }
53
+
54
+ Status &operator=(const Status &) = default;
55
+
56
+ private:
57
+ Code code_;
58
+ std::string error_msg_;
59
+ };
60
+
61
+ inline std::ostream &operator<<(std::ostream &os, const Status &status) {
62
+ os << status.error_msg_string();
63
+ return os;
64
+ }
65
+
66
+ inline Status OkStatus() { return Status(Status::OK); }
67
+ inline Status ErrorStatus(const std::string &msg) {
68
+ return Status(Status::DRACO_ERROR, msg);
69
+ }
70
+
71
+ // Evaluates an expression that returns draco::Status. If the status is not OK,
72
+ // the macro returns the status object.
73
+ #define DRACO_RETURN_IF_ERROR(expression) \
74
+ { \
75
+ const draco::Status _local_status = (expression); \
76
+ if (!_local_status.ok()) { \
77
+ return _local_status; \
78
+ } \
79
+ }
80
+
81
+ } // namespace draco
82
+
83
+ #endif // DRACO_CORE_STATUS_H_
@@ -0,0 +1,81 @@
1
+ // Copyright 2017 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_STATUS_OR_H_
16
+ #define DRACO_CORE_STATUS_OR_H_
17
+
18
+ #include "draco/core/macros.h"
19
+ #include "draco/core/status.h"
20
+
21
+ namespace draco {
22
+
23
+ // Class StatusOr is used to wrap a Status along with a value of a specified
24
+ // type |T|. StatusOr is intended to be returned from functions in situations
25
+ // where it is desirable to carry over more information about the potential
26
+ // errors encountered during the function execution. If there are not errors,
27
+ // the caller can simply use the return value, otherwise the Status object
28
+ // provides more info about the encountered problem.
29
+ template <class T>
30
+ class StatusOr {
31
+ public:
32
+ StatusOr() {}
33
+ // Note: Constructors are intentionally not explicit to allow returning
34
+ // Status or the return value directly from functions.
35
+ StatusOr(const StatusOr &) = default;
36
+ StatusOr(StatusOr &&) = default;
37
+ StatusOr(const Status &status) : status_(status) {}
38
+ StatusOr(const T &value) : status_(OkStatus()), value_(value) {}
39
+ StatusOr(T &&value) : status_(OkStatus()), value_(std::move(value)) {}
40
+ StatusOr(const Status &status, const T &value)
41
+ : status_(status), value_(value) {}
42
+
43
+ const Status &status() const { return status_; }
44
+ const T &value() const & { return value_; }
45
+ const T &&value() const && { return std::move(value_); }
46
+ T &&value() && { return std::move(value_); }
47
+
48
+ // For consistency with existing Google StatusOr API we also include
49
+ // ValueOrDie() that currently returns the value().
50
+ const T &ValueOrDie() const & { return value(); }
51
+ T &&ValueOrDie() && { return std::move(value()); }
52
+
53
+ bool ok() const { return status_.ok(); }
54
+
55
+ private:
56
+ Status status_;
57
+ T value_;
58
+ };
59
+
60
+ // In case StatusOr<T> is ok(), this macro assigns value stored in StatusOr<T>
61
+ // to |lhs|, otherwise it returns the error Status.
62
+ //
63
+ // DRACO_ASSIGN_OR_RETURN(lhs, expression)
64
+ //
65
+ #define DRACO_ASSIGN_OR_RETURN(lhs, expression) \
66
+ DRACO_ASSIGN_OR_RETURN_IMPL_(DRACO_MACROS_IMPL_CONCAT_(_statusor, __LINE__), \
67
+ lhs, expression, _status)
68
+
69
+ // The actual implementation of the above macro.
70
+ #define DRACO_ASSIGN_OR_RETURN_IMPL_(statusor, lhs, expression, error_expr) \
71
+ auto statusor = (expression); \
72
+ if (!statusor.ok()) { \
73
+ auto _status = std::move(statusor.status()); \
74
+ (void)_status; /* error_expression may not use it */ \
75
+ return error_expr; \
76
+ } \
77
+ lhs = std::move(statusor).value();
78
+
79
+ } // namespace draco
80
+
81
+ #endif // DRACO_CORE_STATUS_OR_H_
@@ -0,0 +1,81 @@
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_VARINT_DECODING_H_
16
+ #define DRACO_CORE_VARINT_DECODING_H_
17
+
18
+ #include <type_traits>
19
+
20
+ #include "draco/core/bit_utils.h"
21
+ #include "draco/core/decoder_buffer.h"
22
+
23
+ namespace draco {
24
+
25
+ namespace {
26
+
27
+ // Decodes a specified unsigned integer as varint. |depth| is the current
28
+ // recursion call depth. The first call to the function must be 1.
29
+ template <typename IntTypeT>
30
+ bool DecodeVarintUnsigned(int depth, IntTypeT *out_val, DecoderBuffer *buffer) {
31
+ constexpr IntTypeT max_depth = sizeof(IntTypeT) + 1 + (sizeof(IntTypeT) >> 3);
32
+ if (depth > max_depth) {
33
+ return false;
34
+ }
35
+ // Coding of unsigned values.
36
+ // 0-6 bit - data
37
+ // 7 bit - next byte?
38
+ uint8_t in;
39
+ if (!buffer->Decode(&in)) {
40
+ return false;
41
+ }
42
+ if (in & (1 << 7)) {
43
+ // Next byte is available, decode it first.
44
+ if (!DecodeVarintUnsigned<IntTypeT>(depth + 1, out_val, buffer)) {
45
+ return false;
46
+ }
47
+ // Append decoded info from this byte.
48
+ *out_val <<= 7;
49
+ *out_val |= in & ((1 << 7) - 1);
50
+ } else {
51
+ // Last byte reached
52
+ *out_val = in;
53
+ }
54
+ return true;
55
+ }
56
+
57
+ } // namespace
58
+
59
+ // Decodes a specified integer as varint. Note that the IntTypeT must be the
60
+ // same as the one used in the corresponding EncodeVarint() call.
61
+ // out_val is undefined if this returns false.
62
+ template <typename IntTypeT>
63
+ bool DecodeVarint(IntTypeT *out_val, DecoderBuffer *buffer) {
64
+ if (std::is_unsigned<IntTypeT>::value) {
65
+ if (!DecodeVarintUnsigned<IntTypeT>(1, out_val, buffer)) {
66
+ return false;
67
+ }
68
+ } else {
69
+ // IntTypeT is a signed value. Decode the symbol and convert to signed.
70
+ typename std::make_unsigned<IntTypeT>::type symbol;
71
+ if (!DecodeVarintUnsigned(1, &symbol, buffer)) {
72
+ return false;
73
+ }
74
+ *out_val = ConvertSymbolToSignedInt(symbol);
75
+ }
76
+ return true;
77
+ }
78
+
79
+ } // namespace draco
80
+
81
+ #endif // DRACO_CORE_VARINT_DECODING_H_
@@ -0,0 +1,61 @@
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_VARINT_ENCODING_H_
16
+ #define DRACO_CORE_VARINT_ENCODING_H_
17
+
18
+ #include <type_traits>
19
+
20
+ #include "draco/core/bit_utils.h"
21
+ #include "draco/core/encoder_buffer.h"
22
+
23
+ namespace draco {
24
+
25
+ // Encodes a specified integer as varint. Note that different coding is used
26
+ // when IntTypeT is an unsigned data type.
27
+ template <typename IntTypeT>
28
+ bool EncodeVarint(IntTypeT val, EncoderBuffer *out_buffer) {
29
+ if (std::is_unsigned<IntTypeT>::value) {
30
+ // Coding of unsigned values.
31
+ // 0-6 bit - data
32
+ // 7 bit - next byte?
33
+ uint8_t out = 0;
34
+ out |= val & ((1 << 7) - 1);
35
+ if (val >= (1 << 7)) {
36
+ out |= (1 << 7);
37
+ if (!out_buffer->Encode(out)) {
38
+ return false;
39
+ }
40
+ if (!EncodeVarint<IntTypeT>(val >> 7, out_buffer)) {
41
+ return false;
42
+ }
43
+ return true;
44
+ }
45
+ if (!out_buffer->Encode(out)) {
46
+ return false;
47
+ }
48
+ } else {
49
+ // IntTypeT is a signed value. Convert to unsigned symbol and encode.
50
+ const typename std::make_unsigned<IntTypeT>::type symbol =
51
+ ConvertSignedIntToSymbol(val);
52
+ if (!EncodeVarint(symbol, out_buffer)) {
53
+ return false;
54
+ }
55
+ }
56
+ return true;
57
+ }
58
+
59
+ } // namespace draco
60
+
61
+ #endif // DRACO_CORE_VARINT_ENCODING_H_