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,176 @@
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_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_
17
+
18
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h"
19
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h"
20
+ #include "draco/compression/bit_coders/rans_bit_decoder.h"
21
+ #include "draco/draco_features.h"
22
+
23
+ namespace draco {
24
+
25
+ // See MeshPredictionSchemeGeometricNormalEncoder for documentation.
26
+ template <typename DataTypeT, class TransformT, class MeshDataT>
27
+ class MeshPredictionSchemeGeometricNormalDecoder
28
+ : public MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT> {
29
+ public:
30
+ using CorrType = typename MeshPredictionSchemeDecoder<DataTypeT, TransformT,
31
+ MeshDataT>::CorrType;
32
+ MeshPredictionSchemeGeometricNormalDecoder(const PointAttribute *attribute,
33
+ const TransformT &transform,
34
+ const MeshDataT &mesh_data)
35
+ : MeshPredictionSchemeDecoder<DataTypeT, TransformT, MeshDataT>(
36
+ attribute, transform, mesh_data),
37
+ predictor_(mesh_data) {}
38
+
39
+ private:
40
+ MeshPredictionSchemeGeometricNormalDecoder() {}
41
+
42
+ public:
43
+ bool ComputeOriginalValues(const CorrType *in_corr, DataTypeT *out_data,
44
+ int size, int num_components,
45
+ const PointIndex *entry_to_point_id_map) override;
46
+
47
+ bool DecodePredictionData(DecoderBuffer *buffer) override;
48
+
49
+ PredictionSchemeMethod GetPredictionMethod() const override {
50
+ return MESH_PREDICTION_GEOMETRIC_NORMAL;
51
+ }
52
+
53
+ bool IsInitialized() const override {
54
+ if (!predictor_.IsInitialized()) {
55
+ return false;
56
+ }
57
+ if (!this->mesh_data().IsInitialized()) {
58
+ return false;
59
+ }
60
+ if (!octahedron_tool_box_.IsInitialized()) {
61
+ return false;
62
+ }
63
+ return true;
64
+ }
65
+
66
+ int GetNumParentAttributes() const override { return 1; }
67
+
68
+ GeometryAttribute::Type GetParentAttributeType(int i) const override {
69
+ DRACO_DCHECK_EQ(i, 0);
70
+ (void)i;
71
+ return GeometryAttribute::POSITION;
72
+ }
73
+
74
+ bool SetParentAttribute(const PointAttribute *att) override {
75
+ if (att->attribute_type() != GeometryAttribute::POSITION) {
76
+ return false; // Invalid attribute type.
77
+ }
78
+ if (att->num_components() != 3) {
79
+ return false; // Currently works only for 3 component positions.
80
+ }
81
+ predictor_.SetPositionAttribute(*att);
82
+ return true;
83
+ }
84
+ void SetQuantizationBits(int q) {
85
+ octahedron_tool_box_.SetQuantizationBits(q);
86
+ }
87
+
88
+ private:
89
+ MeshPredictionSchemeGeometricNormalPredictorArea<DataTypeT, TransformT,
90
+ MeshDataT>
91
+ predictor_;
92
+ OctahedronToolBox octahedron_tool_box_;
93
+ RAnsBitDecoder flip_normal_bit_decoder_;
94
+ };
95
+
96
+ template <typename DataTypeT, class TransformT, class MeshDataT>
97
+ bool MeshPredictionSchemeGeometricNormalDecoder<
98
+ DataTypeT, TransformT,
99
+ MeshDataT>::ComputeOriginalValues(const CorrType *in_corr,
100
+ DataTypeT *out_data, int /* size */,
101
+ int num_components,
102
+ const PointIndex *entry_to_point_id_map) {
103
+ this->SetQuantizationBits(this->transform().quantization_bits());
104
+ predictor_.SetEntryToPointIdMap(entry_to_point_id_map);
105
+ DRACO_DCHECK(this->IsInitialized());
106
+
107
+ // Expecting in_data in octahedral coordinates, i.e., portable attribute.
108
+ DRACO_DCHECK_EQ(num_components, 2);
109
+
110
+ const int corner_map_size =
111
+ static_cast<int>(this->mesh_data().data_to_corner_map()->size());
112
+
113
+ VectorD<int32_t, 3> pred_normal_3d;
114
+ int32_t pred_normal_oct[2];
115
+
116
+ for (int data_id = 0; data_id < corner_map_size; ++data_id) {
117
+ const CornerIndex corner_id =
118
+ this->mesh_data().data_to_corner_map()->at(data_id);
119
+ predictor_.ComputePredictedValue(corner_id, pred_normal_3d.data());
120
+
121
+ // Compute predicted octahedral coordinates.
122
+ octahedron_tool_box_.CanonicalizeIntegerVector(pred_normal_3d.data());
123
+ DRACO_DCHECK_EQ(pred_normal_3d.AbsSum(),
124
+ octahedron_tool_box_.center_value());
125
+ if (flip_normal_bit_decoder_.DecodeNextBit()) {
126
+ pred_normal_3d = -pred_normal_3d;
127
+ }
128
+ octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords(
129
+ pred_normal_3d.data(), pred_normal_oct, pred_normal_oct + 1);
130
+
131
+ const int data_offset = data_id * 2;
132
+ this->transform().ComputeOriginalValue(
133
+ pred_normal_oct, in_corr + data_offset, out_data + data_offset);
134
+ }
135
+ flip_normal_bit_decoder_.EndDecoding();
136
+ return true;
137
+ }
138
+
139
+ template <typename DataTypeT, class TransformT, class MeshDataT>
140
+ bool MeshPredictionSchemeGeometricNormalDecoder<
141
+ DataTypeT, TransformT, MeshDataT>::DecodePredictionData(DecoderBuffer
142
+ *buffer) {
143
+ // Get data needed for transform
144
+ if (!this->transform().DecodeTransformData(buffer)) {
145
+ return false;
146
+ }
147
+
148
+ #ifdef DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
149
+ if (buffer->bitstream_version() < DRACO_BITSTREAM_VERSION(2, 2)) {
150
+ uint8_t prediction_mode;
151
+ if (!buffer->Decode(&prediction_mode)) {
152
+ return false;
153
+ }
154
+ if (prediction_mode > TRIANGLE_AREA) {
155
+ // Invalid prediction mode.
156
+ return false;
157
+ }
158
+
159
+ if (!predictor_.SetNormalPredictionMode(
160
+ NormalPredictionMode(prediction_mode))) {
161
+ return false;
162
+ }
163
+ }
164
+ #endif
165
+
166
+ // Init normal flips.
167
+ if (!flip_normal_bit_decoder_.StartDecoding(buffer)) {
168
+ return false;
169
+ }
170
+
171
+ return true;
172
+ }
173
+
174
+ } // namespace draco
175
+
176
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_DECODER_H_
@@ -0,0 +1,180 @@
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_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_
17
+
18
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h"
19
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h"
20
+ #include "draco/compression/bit_coders/rans_bit_encoder.h"
21
+ #include "draco/compression/config/compression_shared.h"
22
+
23
+ namespace draco {
24
+
25
+ // Prediction scheme for normals based on the underlying geometry.
26
+ // At a smooth vertices normals are computed by weighting the normals of
27
+ // adjacent faces with the area of these faces. At seams, the same approach
28
+ // applies for seam corners.
29
+ template <typename DataTypeT, class TransformT, class MeshDataT>
30
+ class MeshPredictionSchemeGeometricNormalEncoder
31
+ : public MeshPredictionSchemeEncoder<DataTypeT, TransformT, MeshDataT> {
32
+ public:
33
+ using CorrType = typename MeshPredictionSchemeEncoder<DataTypeT, TransformT,
34
+ MeshDataT>::CorrType;
35
+ MeshPredictionSchemeGeometricNormalEncoder(const PointAttribute *attribute,
36
+ const TransformT &transform,
37
+ const MeshDataT &mesh_data)
38
+ : MeshPredictionSchemeEncoder<DataTypeT, TransformT, MeshDataT>(
39
+ attribute, transform, mesh_data),
40
+ predictor_(mesh_data) {}
41
+
42
+ bool ComputeCorrectionValues(
43
+ const DataTypeT *in_data, CorrType *out_corr, int size,
44
+ int num_components, const PointIndex *entry_to_point_id_map) override;
45
+
46
+ bool EncodePredictionData(EncoderBuffer *buffer) override;
47
+
48
+ PredictionSchemeMethod GetPredictionMethod() const override {
49
+ return MESH_PREDICTION_GEOMETRIC_NORMAL;
50
+ }
51
+
52
+ bool IsInitialized() const override {
53
+ if (!predictor_.IsInitialized()) {
54
+ return false;
55
+ }
56
+ if (!this->mesh_data().IsInitialized()) {
57
+ return false;
58
+ }
59
+ return true;
60
+ }
61
+
62
+ int GetNumParentAttributes() const override { return 1; }
63
+
64
+ GeometryAttribute::Type GetParentAttributeType(int i) const override {
65
+ DRACO_DCHECK_EQ(i, 0);
66
+ (void)i;
67
+ return GeometryAttribute::POSITION;
68
+ }
69
+
70
+ bool SetParentAttribute(const PointAttribute *att) override {
71
+ if (att->attribute_type() != GeometryAttribute::POSITION) {
72
+ return false; // Invalid attribute type.
73
+ }
74
+ if (att->num_components() != 3) {
75
+ return false; // Currently works only for 3 component positions.
76
+ }
77
+ predictor_.SetPositionAttribute(*att);
78
+ return true;
79
+ }
80
+
81
+ private:
82
+ void SetQuantizationBits(int q) {
83
+ DRACO_DCHECK_GE(q, 2);
84
+ DRACO_DCHECK_LE(q, 30);
85
+ octahedron_tool_box_.SetQuantizationBits(q);
86
+ }
87
+ MeshPredictionSchemeGeometricNormalPredictorArea<DataTypeT, TransformT,
88
+ MeshDataT>
89
+ predictor_;
90
+
91
+ OctahedronToolBox octahedron_tool_box_;
92
+ RAnsBitEncoder flip_normal_bit_encoder_;
93
+ };
94
+
95
+ template <typename DataTypeT, class TransformT, class MeshDataT>
96
+ bool MeshPredictionSchemeGeometricNormalEncoder<DataTypeT, TransformT,
97
+ MeshDataT>::
98
+ ComputeCorrectionValues(const DataTypeT *in_data, CorrType *out_corr,
99
+ int size, int num_components,
100
+ const PointIndex *entry_to_point_id_map) {
101
+ this->SetQuantizationBits(this->transform().quantization_bits());
102
+ predictor_.SetEntryToPointIdMap(entry_to_point_id_map);
103
+ DRACO_DCHECK(this->IsInitialized());
104
+ // Expecting in_data in octahedral coordinates, i.e., portable attribute.
105
+ DRACO_DCHECK_EQ(num_components, 2);
106
+
107
+ flip_normal_bit_encoder_.StartEncoding();
108
+
109
+ const int corner_map_size =
110
+ static_cast<int>(this->mesh_data().data_to_corner_map()->size());
111
+
112
+ VectorD<int32_t, 3> pred_normal_3d;
113
+ VectorD<int32_t, 2> pos_pred_normal_oct;
114
+ VectorD<int32_t, 2> neg_pred_normal_oct;
115
+ VectorD<int32_t, 2> pos_correction;
116
+ VectorD<int32_t, 2> neg_correction;
117
+ for (int data_id = 0; data_id < corner_map_size; ++data_id) {
118
+ const CornerIndex corner_id =
119
+ this->mesh_data().data_to_corner_map()->at(data_id);
120
+ predictor_.ComputePredictedValue(corner_id, pred_normal_3d.data());
121
+
122
+ // Compute predicted octahedral coordinates.
123
+ octahedron_tool_box_.CanonicalizeIntegerVector(pred_normal_3d.data());
124
+ DRACO_DCHECK_EQ(pred_normal_3d.AbsSum(),
125
+ octahedron_tool_box_.center_value());
126
+
127
+ // Compute octahedral coordinates for both possible directions.
128
+ octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords(
129
+ pred_normal_3d.data(), pos_pred_normal_oct.data(),
130
+ pos_pred_normal_oct.data() + 1);
131
+ pred_normal_3d = -pred_normal_3d;
132
+ octahedron_tool_box_.IntegerVectorToQuantizedOctahedralCoords(
133
+ pred_normal_3d.data(), neg_pred_normal_oct.data(),
134
+ neg_pred_normal_oct.data() + 1);
135
+
136
+ // Choose the one with the best correction value.
137
+ const int data_offset = data_id * 2;
138
+ this->transform().ComputeCorrection(in_data + data_offset,
139
+ pos_pred_normal_oct.data(),
140
+ pos_correction.data());
141
+ this->transform().ComputeCorrection(in_data + data_offset,
142
+ neg_pred_normal_oct.data(),
143
+ neg_correction.data());
144
+ pos_correction[0] = octahedron_tool_box_.ModMax(pos_correction[0]);
145
+ pos_correction[1] = octahedron_tool_box_.ModMax(pos_correction[1]);
146
+ neg_correction[0] = octahedron_tool_box_.ModMax(neg_correction[0]);
147
+ neg_correction[1] = octahedron_tool_box_.ModMax(neg_correction[1]);
148
+ if (pos_correction.AbsSum() < neg_correction.AbsSum()) {
149
+ flip_normal_bit_encoder_.EncodeBit(false);
150
+ (out_corr + data_offset)[0] =
151
+ octahedron_tool_box_.MakePositive(pos_correction[0]);
152
+ (out_corr + data_offset)[1] =
153
+ octahedron_tool_box_.MakePositive(pos_correction[1]);
154
+ } else {
155
+ flip_normal_bit_encoder_.EncodeBit(true);
156
+ (out_corr + data_offset)[0] =
157
+ octahedron_tool_box_.MakePositive(neg_correction[0]);
158
+ (out_corr + data_offset)[1] =
159
+ octahedron_tool_box_.MakePositive(neg_correction[1]);
160
+ }
161
+ }
162
+ return true;
163
+ }
164
+
165
+ template <typename DataTypeT, class TransformT, class MeshDataT>
166
+ bool MeshPredictionSchemeGeometricNormalEncoder<
167
+ DataTypeT, TransformT, MeshDataT>::EncodePredictionData(EncoderBuffer
168
+ *buffer) {
169
+ if (!this->transform().EncodeTransformData(buffer)) {
170
+ return false;
171
+ }
172
+
173
+ // Encode normal flips.
174
+ flip_normal_bit_encoder_.EndEncoding(buffer);
175
+ return true;
176
+ }
177
+
178
+ } // namespace draco
179
+
180
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_ENCODER_H_
@@ -0,0 +1,117 @@
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_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_AREA_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_AREA_H_
17
+
18
+ #include "draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h"
19
+
20
+ namespace draco {
21
+
22
+ // This predictor estimates the normal via the surrounding triangles of the
23
+ // given corner. Triangles are weighted according to their area.
24
+ template <typename DataTypeT, class TransformT, class MeshDataT>
25
+ class MeshPredictionSchemeGeometricNormalPredictorArea
26
+ : public MeshPredictionSchemeGeometricNormalPredictorBase<
27
+ DataTypeT, TransformT, MeshDataT> {
28
+ typedef MeshPredictionSchemeGeometricNormalPredictorBase<
29
+ DataTypeT, TransformT, MeshDataT>
30
+ Base;
31
+
32
+ public:
33
+ explicit MeshPredictionSchemeGeometricNormalPredictorArea(const MeshDataT &md)
34
+ : Base(md) {
35
+ this->SetNormalPredictionMode(TRIANGLE_AREA);
36
+ };
37
+ virtual ~MeshPredictionSchemeGeometricNormalPredictorArea() {}
38
+
39
+ // Computes predicted octahedral coordinates on a given corner.
40
+ void ComputePredictedValue(CornerIndex corner_id,
41
+ DataTypeT *prediction) override {
42
+ DRACO_DCHECK(this->IsInitialized());
43
+ typedef typename MeshDataT::CornerTable CornerTable;
44
+ const CornerTable *const corner_table = this->mesh_data_.corner_table();
45
+ // Going to compute the predicted normal from the surrounding triangles
46
+ // according to the connectivity of the given corner table.
47
+ VertexCornersIterator<CornerTable> cit(corner_table, corner_id);
48
+ // Position of central vertex does not change in loop.
49
+ const VectorD<int64_t, 3> pos_cent = this->GetPositionForCorner(corner_id);
50
+ // Computing normals for triangles and adding them up.
51
+
52
+ VectorD<int64_t, 3> normal;
53
+ CornerIndex c_next, c_prev;
54
+ while (!cit.End()) {
55
+ // Getting corners.
56
+ if (this->normal_prediction_mode_ == ONE_TRIANGLE) {
57
+ c_next = corner_table->Next(corner_id);
58
+ c_prev = corner_table->Previous(corner_id);
59
+ } else {
60
+ c_next = corner_table->Next(cit.Corner());
61
+ c_prev = corner_table->Previous(cit.Corner());
62
+ }
63
+ const VectorD<int64_t, 3> pos_next = this->GetPositionForCorner(c_next);
64
+ const VectorD<int64_t, 3> pos_prev = this->GetPositionForCorner(c_prev);
65
+
66
+ // Computing delta vectors to next and prev.
67
+ const VectorD<int64_t, 3> delta_next = pos_next - pos_cent;
68
+ const VectorD<int64_t, 3> delta_prev = pos_prev - pos_cent;
69
+
70
+ // Computing cross product.
71
+ const VectorD<int64_t, 3> cross = CrossProduct(delta_next, delta_prev);
72
+
73
+ // Prevent signed integer overflows by doing math as unsigned.
74
+ auto normal_data = reinterpret_cast<uint64_t *>(normal.data());
75
+ auto cross_data = reinterpret_cast<const uint64_t *>(cross.data());
76
+ normal_data[0] = normal_data[0] + cross_data[0];
77
+ normal_data[1] = normal_data[1] + cross_data[1];
78
+ normal_data[2] = normal_data[2] + cross_data[2];
79
+
80
+ cit.Next();
81
+ }
82
+
83
+ // Convert to int32_t, make sure entries are not too large.
84
+ constexpr int64_t upper_bound = 1 << 29;
85
+ if (this->normal_prediction_mode_ == ONE_TRIANGLE) {
86
+ const int32_t abs_sum = static_cast<int32_t>(normal.AbsSum());
87
+ if (abs_sum > upper_bound) {
88
+ const int64_t quotient = abs_sum / upper_bound;
89
+ normal = normal / quotient;
90
+ }
91
+ } else {
92
+ const int64_t abs_sum = normal.AbsSum();
93
+ if (abs_sum > upper_bound) {
94
+ const int64_t quotient = abs_sum / upper_bound;
95
+ normal = normal / quotient;
96
+ }
97
+ }
98
+ DRACO_DCHECK_LE(normal.AbsSum(), upper_bound);
99
+ prediction[0] = static_cast<int32_t>(normal[0]);
100
+ prediction[1] = static_cast<int32_t>(normal[1]);
101
+ prediction[2] = static_cast<int32_t>(normal[2]);
102
+ }
103
+ bool SetNormalPredictionMode(NormalPredictionMode mode) override {
104
+ if (mode == ONE_TRIANGLE) {
105
+ this->normal_prediction_mode_ = mode;
106
+ return true;
107
+ } else if (mode == TRIANGLE_AREA) {
108
+ this->normal_prediction_mode_ = mode;
109
+ return true;
110
+ }
111
+ return false;
112
+ }
113
+ };
114
+
115
+ } // namespace draco
116
+
117
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_AREA_H_
@@ -0,0 +1,96 @@
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_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_
16
+ #define DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_
17
+
18
+ #include <math.h>
19
+
20
+ #include "draco/attributes/point_attribute.h"
21
+ #include "draco/compression/attributes/normal_compression_utils.h"
22
+ #include "draco/compression/config/compression_shared.h"
23
+ #include "draco/core/math_utils.h"
24
+ #include "draco/core/vector_d.h"
25
+ #include "draco/mesh/corner_table.h"
26
+ #include "draco/mesh/corner_table_iterators.h"
27
+
28
+ namespace draco {
29
+
30
+ // Base class for geometric normal predictors using position attribute.
31
+ template <typename DataTypeT, class TransformT, class MeshDataT>
32
+ class MeshPredictionSchemeGeometricNormalPredictorBase {
33
+ protected:
34
+ explicit MeshPredictionSchemeGeometricNormalPredictorBase(const MeshDataT &md)
35
+ : pos_attribute_(nullptr),
36
+ entry_to_point_id_map_(nullptr),
37
+ mesh_data_(md) {}
38
+ virtual ~MeshPredictionSchemeGeometricNormalPredictorBase() {}
39
+
40
+ public:
41
+ void SetPositionAttribute(const PointAttribute &position_attribute) {
42
+ pos_attribute_ = &position_attribute;
43
+ }
44
+ void SetEntryToPointIdMap(const PointIndex *map) {
45
+ entry_to_point_id_map_ = map;
46
+ }
47
+ bool IsInitialized() const {
48
+ if (pos_attribute_ == nullptr) {
49
+ return false;
50
+ }
51
+ if (entry_to_point_id_map_ == nullptr) {
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+
57
+ virtual bool SetNormalPredictionMode(NormalPredictionMode mode) = 0;
58
+ virtual NormalPredictionMode GetNormalPredictionMode() const {
59
+ return normal_prediction_mode_;
60
+ }
61
+
62
+ protected:
63
+ VectorD<int64_t, 3> GetPositionForDataId(int data_id) const {
64
+ DRACO_DCHECK(this->IsInitialized());
65
+ const auto point_id = entry_to_point_id_map_[data_id];
66
+ const auto pos_val_id = pos_attribute_->mapped_index(point_id);
67
+ VectorD<int64_t, 3> pos;
68
+ pos_attribute_->ConvertValue(pos_val_id, &pos[0]);
69
+ return pos;
70
+ }
71
+ VectorD<int64_t, 3> GetPositionForCorner(CornerIndex ci) const {
72
+ DRACO_DCHECK(this->IsInitialized());
73
+ const auto corner_table = mesh_data_.corner_table();
74
+ const auto vert_id = corner_table->Vertex(ci).value();
75
+ const auto data_id = mesh_data_.vertex_to_data_map()->at(vert_id);
76
+ return GetPositionForDataId(data_id);
77
+ }
78
+ VectorD<int32_t, 2> GetOctahedralCoordForDataId(int data_id,
79
+ const DataTypeT *data) const {
80
+ DRACO_DCHECK(this->IsInitialized());
81
+ const int data_offset = data_id * 2;
82
+ return VectorD<int32_t, 2>(data[data_offset], data[data_offset + 1]);
83
+ }
84
+ // Computes predicted octahedral coordinates on a given corner.
85
+ virtual void ComputePredictedValue(CornerIndex corner_id,
86
+ DataTypeT *prediction) = 0;
87
+
88
+ const PointAttribute *pos_attribute_;
89
+ const PointIndex *entry_to_point_id_map_;
90
+ MeshDataT mesh_data_;
91
+ NormalPredictionMode normal_prediction_mode_;
92
+ };
93
+
94
+ } // namespace draco
95
+
96
+ #endif // DRACO_COMPRESSION_ATTRIBUTES_PREDICTION_SCHEMES_MESH_PREDICTION_SCHEME_GEOMETRIC_NORMAL_PREDICTOR_BASE_H_