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,226 @@
1
+ // Copyright 2016 The Draco Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ #ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MAX_PREDICTION_DEGREE_TRAVERSER_H_
16
+ #define DRACO_COMPRESSION_MESH_TRAVERSER_MAX_PREDICTION_DEGREE_TRAVERSER_H_
17
+
18
+ #include <vector>
19
+
20
+ #include "draco/compression/mesh/traverser/traverser_base.h"
21
+ #include "draco/mesh/corner_table.h"
22
+
23
+ namespace draco {
24
+
25
+ // PredictionDegreeTraverser provides framework for traversal over a corner
26
+ // table data structure following paper "Multi-way Geometry Encoding" by
27
+ // Cohen-or at al.'02. The traversal is implicitly guided by prediction degree
28
+ // of the destination vertices. A prediction degree is computed as the number of
29
+ // possible faces that can be used as source points for traversal to the given
30
+ // destination vertex (see image below, where faces F1 and F2 are already
31
+ // traversed and face F0 is not traversed yet. The prediction degree of vertex
32
+ // V is then equal to two).
33
+ //
34
+ // X-----V-----o
35
+ // / \ / \ / \
36
+ // / F0\ / \ / F2\
37
+ // X-----o-----o-----B
38
+ // \ F1/
39
+ // \ /
40
+ // A
41
+ //
42
+ // The class implements the same interface as the DepthFirstTraverser
43
+ // (depth_first_traverser.h) and it can be controlled via the same template
44
+ // trait classes |CornerTableT| and |TraversalObserverT|, that are used
45
+ // for controlling and monitoring of the traversal respectively. For details,
46
+ // please see depth_first_traverser.h.
47
+ template <class CornerTableT, class TraversalObserverT>
48
+ class MaxPredictionDegreeTraverser
49
+ : public TraverserBase<CornerTable, TraversalObserverT> {
50
+ public:
51
+ typedef CornerTableT CornerTable;
52
+ typedef TraversalObserverT TraversalObserver;
53
+ typedef TraverserBase<CornerTable, TraversalObserver> Base;
54
+
55
+ MaxPredictionDegreeTraverser() {}
56
+
57
+ // Called before any traversing starts.
58
+ void OnTraversalStart() {
59
+ prediction_degree_.resize(this->corner_table()->num_vertices(), 0);
60
+ }
61
+
62
+ // Called when all the traversing is done.
63
+ void OnTraversalEnd() {}
64
+
65
+ bool TraverseFromCorner(CornerIndex corner_id) {
66
+ if (prediction_degree_.size() == 0) {
67
+ return true;
68
+ }
69
+
70
+ // Traversal starts from the |corner_id|. It's going to follow either the
71
+ // right or the left neighboring faces to |corner_id| based on their
72
+ // prediction degree.
73
+ traversal_stacks_[0].push_back(corner_id);
74
+ best_priority_ = 0;
75
+ // For the first face, check the remaining corners as they may not be
76
+ // processed yet.
77
+ const VertexIndex next_vert =
78
+ this->corner_table()->Vertex(this->corner_table()->Next(corner_id));
79
+ const VertexIndex prev_vert =
80
+ this->corner_table()->Vertex(this->corner_table()->Previous(corner_id));
81
+ if (!this->IsVertexVisited(next_vert)) {
82
+ this->MarkVertexVisited(next_vert);
83
+ this->traversal_observer().OnNewVertexVisited(
84
+ next_vert, this->corner_table()->Next(corner_id));
85
+ }
86
+ if (!this->IsVertexVisited(prev_vert)) {
87
+ this->MarkVertexVisited(prev_vert);
88
+ this->traversal_observer().OnNewVertexVisited(
89
+ prev_vert, this->corner_table()->Previous(corner_id));
90
+ }
91
+ const VertexIndex tip_vertex = this->corner_table()->Vertex(corner_id);
92
+ if (!this->IsVertexVisited(tip_vertex)) {
93
+ this->MarkVertexVisited(tip_vertex);
94
+ this->traversal_observer().OnNewVertexVisited(tip_vertex, corner_id);
95
+ }
96
+ // Start the actual traversal.
97
+ while ((corner_id = PopNextCornerToTraverse()) != kInvalidCornerIndex) {
98
+ FaceIndex face_id(corner_id.value() / 3);
99
+ // Make sure the face hasn't been visited yet.
100
+ if (this->IsFaceVisited(face_id)) {
101
+ // This face has been already traversed.
102
+ continue;
103
+ }
104
+
105
+ while (true) {
106
+ face_id = FaceIndex(corner_id.value() / 3);
107
+ this->MarkFaceVisited(face_id);
108
+ this->traversal_observer().OnNewFaceVisited(face_id);
109
+
110
+ // If the newly reached vertex hasn't been visited, mark it and notify
111
+ // the observer.
112
+ const VertexIndex vert_id = this->corner_table()->Vertex(corner_id);
113
+ if (!this->IsVertexVisited(vert_id)) {
114
+ this->MarkVertexVisited(vert_id);
115
+ this->traversal_observer().OnNewVertexVisited(vert_id, corner_id);
116
+ }
117
+
118
+ // Check whether we can traverse to the right and left neighboring
119
+ // faces.
120
+ const CornerIndex right_corner_id =
121
+ this->corner_table()->GetRightCorner(corner_id);
122
+ const CornerIndex left_corner_id =
123
+ this->corner_table()->GetLeftCorner(corner_id);
124
+ const FaceIndex right_face_id(
125
+ (right_corner_id == kInvalidCornerIndex
126
+ ? kInvalidFaceIndex
127
+ : FaceIndex(right_corner_id.value() / 3)));
128
+ const FaceIndex left_face_id(
129
+ (left_corner_id == kInvalidCornerIndex
130
+ ? kInvalidFaceIndex
131
+ : FaceIndex(left_corner_id.value() / 3)));
132
+ const bool is_right_face_visited = this->IsFaceVisited(right_face_id);
133
+ const bool is_left_face_visited = this->IsFaceVisited(left_face_id);
134
+
135
+ if (!is_left_face_visited) {
136
+ // We can go to the left face.
137
+ const int priority = ComputePriority(left_corner_id);
138
+ if (is_right_face_visited && priority <= best_priority_) {
139
+ // Right face has been already visited and the priority is equal or
140
+ // better than the best priority. We are sure that the left face
141
+ // would be traversed next so there is no need to put it onto the
142
+ // stack.
143
+ corner_id = left_corner_id;
144
+ continue;
145
+ } else {
146
+ AddCornerToTraversalStack(left_corner_id, priority);
147
+ }
148
+ }
149
+ if (!is_right_face_visited) {
150
+ // Go to the right face.
151
+ const int priority = ComputePriority(right_corner_id);
152
+ if (priority <= best_priority_) {
153
+ // We are sure that the right face would be traversed next so there
154
+ // is no need to put it onto the stack.
155
+ corner_id = right_corner_id;
156
+ continue;
157
+ } else {
158
+ AddCornerToTraversalStack(right_corner_id, priority);
159
+ }
160
+ }
161
+
162
+ // Couldn't proceed directly to the next corner
163
+ break;
164
+ }
165
+ }
166
+ return true;
167
+ }
168
+
169
+ private:
170
+ // Retrieves the next available corner (edge) to traverse. Edges are processed
171
+ // based on their priorities.
172
+ // Returns kInvalidCornerIndex when there is no edge available.
173
+ CornerIndex PopNextCornerToTraverse() {
174
+ for (int i = best_priority_; i < kMaxPriority; ++i) {
175
+ if (!traversal_stacks_[i].empty()) {
176
+ const CornerIndex ret = traversal_stacks_[i].back();
177
+ traversal_stacks_[i].pop_back();
178
+ best_priority_ = i;
179
+ return ret;
180
+ }
181
+ }
182
+ return kInvalidCornerIndex;
183
+ }
184
+
185
+ inline void AddCornerToTraversalStack(CornerIndex ci, int priority) {
186
+ traversal_stacks_[priority].push_back(ci);
187
+ // Make sure that the best available priority is up to date.
188
+ if (priority < best_priority_) {
189
+ best_priority_ = priority;
190
+ }
191
+ }
192
+
193
+ // Returns the priority of traversing edge leading to |corner_id|.
194
+ inline int ComputePriority(CornerIndex corner_id) {
195
+ const VertexIndex v_tip = this->corner_table()->Vertex(corner_id);
196
+ // Priority 0 when traversing to already visited vertices.
197
+ int priority = 0;
198
+ if (!this->IsVertexVisited(v_tip)) {
199
+ const int degree = ++prediction_degree_[v_tip];
200
+ // Priority 1 when prediction degree > 1, otherwise 2.
201
+ priority = (degree > 1 ? 1 : 2);
202
+ }
203
+ // Clamp the priority to the maximum number of buckets.
204
+ if (priority >= kMaxPriority) {
205
+ priority = kMaxPriority - 1;
206
+ }
207
+ return priority;
208
+ }
209
+
210
+ // For efficiency reasons, the priority traversal is implemented using buckets
211
+ // where each buckets represent a stack of available corners for a given
212
+ // priority. Corners with the highest priority are always processed first.
213
+ static constexpr int kMaxPriority = 3;
214
+ std::vector<CornerIndex> traversal_stacks_[kMaxPriority];
215
+
216
+ // Keep the track of the best available priority to improve the performance
217
+ // of PopNextCornerToTraverse() method.
218
+ int best_priority_;
219
+
220
+ // Prediction degree available for each vertex.
221
+ IndexTypeVector<VertexIndex, int> prediction_degree_;
222
+ };
223
+
224
+ } // namespace draco
225
+
226
+ #endif // DRACO_COMPRESSION_MESH_TRAVERSER_MAX_PREDICTION_DEGREE_TRAVERSER_H_
@@ -0,0 +1,76 @@
1
+ // Copyright 2016 The Draco Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ #ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
16
+ #define DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
17
+
18
+ #include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h"
19
+ #include "draco/compression/attributes/points_sequencer.h"
20
+ #include "draco/mesh/mesh.h"
21
+
22
+ namespace draco {
23
+
24
+ // Class that can be used to generate encoding (and decoding) order of attribute
25
+ // values based on the traversal of the encoded mesh. The class should be used
26
+ // as the TraversalObserverT member of a Traverser class such as the
27
+ // DepthFirstTraverser (depth_first_traverser.h).
28
+ // TODO(b/199760123): Rename to AttributeIndicesCodingTraverserObserver.
29
+ template <class CornerTableT>
30
+ class MeshAttributeIndicesEncodingObserver {
31
+ public:
32
+ MeshAttributeIndicesEncodingObserver()
33
+ : att_connectivity_(nullptr),
34
+ encoding_data_(nullptr),
35
+ mesh_(nullptr),
36
+ sequencer_(nullptr) {}
37
+ MeshAttributeIndicesEncodingObserver(
38
+ const CornerTableT *connectivity, const Mesh *mesh,
39
+ PointsSequencer *sequencer,
40
+ MeshAttributeIndicesEncodingData *encoding_data)
41
+ : att_connectivity_(connectivity),
42
+ encoding_data_(encoding_data),
43
+ mesh_(mesh),
44
+ sequencer_(sequencer) {}
45
+
46
+ // Interface for TraversalObserverT
47
+
48
+ void OnNewFaceVisited(FaceIndex /* face */) {}
49
+
50
+ inline void OnNewVertexVisited(VertexIndex vertex, CornerIndex corner) {
51
+ const PointIndex point_id =
52
+ mesh_->face(FaceIndex(corner.value() / 3))[corner.value() % 3];
53
+ // Append the visited attribute to the encoding order.
54
+ sequencer_->AddPointId(point_id);
55
+
56
+ // Keep track of visited corners.
57
+ encoding_data_->encoded_attribute_value_index_to_corner_map.push_back(
58
+ corner);
59
+
60
+ encoding_data_
61
+ ->vertex_to_encoded_attribute_value_index_map[vertex.value()] =
62
+ encoding_data_->num_values;
63
+
64
+ encoding_data_->num_values++;
65
+ }
66
+
67
+ private:
68
+ const CornerTableT *att_connectivity_;
69
+ MeshAttributeIndicesEncodingData *encoding_data_;
70
+ const Mesh *mesh_;
71
+ PointsSequencer *sequencer_;
72
+ };
73
+
74
+ } // namespace draco
75
+
76
+ #endif // DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
@@ -0,0 +1,113 @@
1
+ // Copyright 2016 The Draco Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ #ifndef DRACO_COMPRESSION_MESH_TRAVERSER_MESH_TRAVERSAL_SEQUENCER_H_
16
+ #define DRACO_COMPRESSION_MESH_TRAVERSER_MESH_TRAVERSAL_SEQUENCER_H_
17
+
18
+ #include "draco/attributes/geometry_indices.h"
19
+ #include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h"
20
+ #include "draco/compression/attributes/points_sequencer.h"
21
+ #include "draco/mesh/mesh.h"
22
+
23
+ namespace draco {
24
+
25
+ // Sequencer that generates point sequence in an order given by a deterministic
26
+ // traversal on the mesh surface. Note that all attributes encoded with this
27
+ // sequence must share the same connectivity.
28
+ // TODO(b/199760123): Consider refactoring such that this is an observer.
29
+ template <class TraverserT>
30
+ class MeshTraversalSequencer : public PointsSequencer {
31
+ public:
32
+ MeshTraversalSequencer(const Mesh *mesh,
33
+ const MeshAttributeIndicesEncodingData *encoding_data)
34
+ : mesh_(mesh), encoding_data_(encoding_data), corner_order_(nullptr) {}
35
+ void SetTraverser(const TraverserT &t) { traverser_ = t; }
36
+
37
+ // Function that can be used to set an order in which the mesh corners should
38
+ // be processed. This is an optional flag used usually only by the encoder
39
+ // to match the same corner order that is going to be used by the decoder.
40
+ // Note that |corner_order| should contain only one corner per face (it can
41
+ // have all corners but only the first encountered corner for each face is
42
+ // going to be used to start a traversal). If the corner order is not set, the
43
+ // corners are processed sequentially based on their ids.
44
+ void SetCornerOrder(const std::vector<CornerIndex> &corner_order) {
45
+ corner_order_ = &corner_order;
46
+ }
47
+
48
+ bool UpdatePointToAttributeIndexMapping(PointAttribute *attribute) override {
49
+ const auto *corner_table = traverser_.corner_table();
50
+ attribute->SetExplicitMapping(mesh_->num_points());
51
+ const size_t num_faces = mesh_->num_faces();
52
+ const size_t num_points = mesh_->num_points();
53
+ for (FaceIndex f(0); f < static_cast<uint32_t>(num_faces); ++f) {
54
+ const auto &face = mesh_->face(f);
55
+ for (int p = 0; p < 3; ++p) {
56
+ const PointIndex point_id = face[p];
57
+ const VertexIndex vert_id =
58
+ corner_table->Vertex(CornerIndex(3 * f.value() + p));
59
+ if (vert_id == kInvalidVertexIndex) {
60
+ return false;
61
+ }
62
+ const AttributeValueIndex att_entry_id(
63
+ encoding_data_
64
+ ->vertex_to_encoded_attribute_value_index_map[vert_id.value()]);
65
+ if (point_id >= num_points || att_entry_id.value() >= num_points) {
66
+ // There cannot be more attribute values than the number of points.
67
+ return false;
68
+ }
69
+ attribute->SetPointMapEntry(point_id, att_entry_id);
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+
75
+ protected:
76
+ bool GenerateSequenceInternal() override {
77
+ // Preallocate memory for storing point indices. We expect the number of
78
+ // points to be the same as the number of corner table vertices.
79
+ out_point_ids()->reserve(traverser_.corner_table()->num_vertices());
80
+
81
+ traverser_.OnTraversalStart();
82
+ if (corner_order_) {
83
+ for (uint32_t i = 0; i < corner_order_->size(); ++i) {
84
+ if (!ProcessCorner(corner_order_->at(i))) {
85
+ return false;
86
+ }
87
+ }
88
+ } else {
89
+ const int32_t num_faces = traverser_.corner_table()->num_faces();
90
+ for (int i = 0; i < num_faces; ++i) {
91
+ if (!ProcessCorner(CornerIndex(3 * i))) {
92
+ return false;
93
+ }
94
+ }
95
+ }
96
+ traverser_.OnTraversalEnd();
97
+ return true;
98
+ }
99
+
100
+ private:
101
+ bool ProcessCorner(CornerIndex corner_id) {
102
+ return traverser_.TraverseFromCorner(corner_id);
103
+ }
104
+
105
+ TraverserT traverser_;
106
+ const Mesh *mesh_;
107
+ const MeshAttributeIndicesEncodingData *encoding_data_;
108
+ const std::vector<CornerIndex> *corner_order_;
109
+ };
110
+
111
+ } // namespace draco
112
+
113
+ #endif // DRACO_COMPRESSION_MESH_TRAVERSER_MESH_TRAVERSAL_SEQUENCER_H_
@@ -0,0 +1,87 @@
1
+ // Copyright 2016 The Draco Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ #ifndef DRACO_COMPRESSION_MESH_TRAVERSER_TRAVERSER_BASE_H_
16
+ #define DRACO_COMPRESSION_MESH_TRAVERSER_TRAVERSER_BASE_H_
17
+
18
+ #include "draco/mesh/corner_table.h"
19
+
20
+ namespace draco {
21
+
22
+ // Class providing the basic traversal functionality needed by traversers (such
23
+ // as the DepthFirstTraverser, see depth_first_traverser.h). It keeps a pointer
24
+ // to the corner table that is used for the traversal, plus it provides a basic
25
+ // bookkeeping of visited faces and vertices during the traversal.
26
+ template <class CornerTableT, class TraversalObserverT>
27
+ class TraverserBase {
28
+ public:
29
+ typedef CornerTableT CornerTable;
30
+ typedef TraversalObserverT TraversalObserver;
31
+
32
+ TraverserBase() : corner_table_(nullptr) {}
33
+ virtual ~TraverserBase() = default;
34
+
35
+ virtual void Init(const CornerTable *corner_table,
36
+ TraversalObserver traversal_observer) {
37
+ corner_table_ = corner_table;
38
+ is_face_visited_.assign(corner_table->num_faces(), false);
39
+ is_vertex_visited_.assign(corner_table_->num_vertices(), false);
40
+ traversal_observer_ = traversal_observer;
41
+ }
42
+
43
+ const CornerTable &GetCornerTable() const { return *corner_table_; }
44
+
45
+ inline bool IsFaceVisited(FaceIndex face_id) const {
46
+ if (face_id == kInvalidFaceIndex) {
47
+ return true; // Invalid faces are always considered as visited.
48
+ }
49
+ return is_face_visited_[face_id.value()];
50
+ }
51
+
52
+ // Returns true if the face containing the given corner was visited.
53
+ inline bool IsFaceVisited(CornerIndex corner_id) const {
54
+ if (corner_id == kInvalidCornerIndex) {
55
+ return true; // Invalid faces are always considered as visited.
56
+ }
57
+ return is_face_visited_[corner_id.value() / 3];
58
+ }
59
+
60
+ inline void MarkFaceVisited(FaceIndex face_id) {
61
+ is_face_visited_[face_id.value()] = true;
62
+ }
63
+ inline bool IsVertexVisited(VertexIndex vert_id) const {
64
+ return is_vertex_visited_[vert_id.value()];
65
+ }
66
+ inline void MarkVertexVisited(VertexIndex vert_id) {
67
+ is_vertex_visited_[vert_id.value()] = true;
68
+ }
69
+
70
+ inline const CornerTable *corner_table() const { return corner_table_; }
71
+ inline const TraversalObserverT &traversal_observer() const {
72
+ return traversal_observer_;
73
+ }
74
+ inline TraversalObserverT &traversal_observer() {
75
+ return traversal_observer_;
76
+ }
77
+
78
+ private:
79
+ const CornerTable *corner_table_;
80
+ TraversalObserverT traversal_observer_;
81
+ std::vector<bool> is_face_visited_;
82
+ std::vector<bool> is_vertex_visited_;
83
+ };
84
+
85
+ } // namespace draco
86
+
87
+ #endif // DRACO_COMPRESSION_MESH_TRAVERSER_TRAVERSER_BASE_H_