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,378 @@
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_MESH_MESH_H_
16
+ #define DRACO_MESH_MESH_H_
17
+
18
+ #include <memory>
19
+ #include <unordered_map>
20
+
21
+ #include "draco/attributes/geometry_indices.h"
22
+ #include "draco/core/hash_utils.h"
23
+ #include "draco/core/macros.h"
24
+ #include "draco/core/status.h"
25
+ #include "draco/draco_features.h"
26
+ #ifdef DRACO_TRANSCODER_SUPPORTED
27
+ #include "draco/material/material_library.h"
28
+ #include "draco/mesh/mesh_features.h"
29
+ #include "draco/mesh/mesh_indices.h"
30
+ #include "draco/metadata/structural_metadata.h"
31
+ #endif
32
+ #include "draco/point_cloud/point_cloud.h"
33
+
34
+ namespace draco {
35
+
36
+ // List of different variants of mesh attributes.
37
+ enum MeshAttributeElementType {
38
+ // All corners attached to a vertex share the same attribute value. A typical
39
+ // example are the vertex positions and often vertex colors.
40
+ MESH_VERTEX_ATTRIBUTE = 0,
41
+ // The most general attribute where every corner of the mesh can have a
42
+ // different attribute value. Often used for texture coordinates or normals.
43
+ MESH_CORNER_ATTRIBUTE,
44
+ // All corners of a single face share the same value.
45
+ MESH_FACE_ATTRIBUTE
46
+ };
47
+
48
+ // Mesh class can be used to represent general triangular meshes. Internally,
49
+ // Mesh is just an extended PointCloud with extra connectivity data that defines
50
+ // what points are connected together in triangles.
51
+ class Mesh : public PointCloud {
52
+ public:
53
+ typedef std::array<PointIndex, 3> Face;
54
+
55
+ Mesh();
56
+
57
+ #ifdef DRACO_TRANSCODER_SUPPORTED
58
+ // Copies all data from the |src| mesh.
59
+ void Copy(const Mesh &src);
60
+ #endif
61
+
62
+ void AddFace(const Face &face) { faces_.push_back(face); }
63
+
64
+ void SetFace(FaceIndex face_id, const Face &face) {
65
+ if (face_id >= static_cast<uint32_t>(faces_.size())) {
66
+ faces_.resize(face_id.value() + 1, Face());
67
+ }
68
+ faces_[face_id] = face;
69
+ }
70
+
71
+ // Sets the total number of faces. Creates new empty faces or deletes
72
+ // existing ones if necessary.
73
+ void SetNumFaces(size_t num_faces) { faces_.resize(num_faces, Face()); }
74
+
75
+ FaceIndex::ValueType num_faces() const {
76
+ return static_cast<uint32_t>(faces_.size());
77
+ }
78
+ const Face &face(FaceIndex face_id) const {
79
+ DRACO_DCHECK_LE(0, face_id.value());
80
+ DRACO_DCHECK_LT(face_id.value(), static_cast<int>(faces_.size()));
81
+ return faces_[face_id];
82
+ }
83
+
84
+ void SetAttribute(int att_id, std::unique_ptr<PointAttribute> pa) override {
85
+ PointCloud::SetAttribute(att_id, std::move(pa));
86
+ if (static_cast<int>(attribute_data_.size()) <= att_id) {
87
+ attribute_data_.resize(att_id + 1);
88
+ }
89
+ }
90
+
91
+ void DeleteAttribute(int att_id) override {
92
+ PointCloud::DeleteAttribute(att_id);
93
+ if (att_id >= 0 && att_id < static_cast<int>(attribute_data_.size())) {
94
+ attribute_data_.erase(attribute_data_.begin() + att_id);
95
+ }
96
+ #ifdef DRACO_TRANSCODER_SUPPORTED
97
+ UpdateMeshFeaturesAfterDeletedAttribute(att_id);
98
+ #endif
99
+ }
100
+
101
+ #ifdef DRACO_TRANSCODER_SUPPORTED
102
+ // Adds a point attribute |att| to the mesh and returns the index of the
103
+ // newly inserted attribute. Attribute connectivity data is specified in
104
+ // |corner_to_value| array that contains mapping between face corners and
105
+ // attribute value indices.
106
+ // The purpose of this function is to allow users to add attributes with
107
+ // arbitrary connectivity to an existing mesh. New points will be
108
+ // automatically created if needed.
109
+ int32_t AddAttributeWithConnectivity(
110
+ std::unique_ptr<PointAttribute> att,
111
+ const IndexTypeVector<CornerIndex, AttributeValueIndex> &corner_to_value);
112
+
113
+ // Adds a point attribute |att| to the mesh and returns the index of the
114
+ // newly inserted attribute. The inserted attribute must have the same
115
+ // connectivity as the position attribute of the mesh (that is, the attribute
116
+ // values are defined per-vertex). Each attribute value entry in |att|
117
+ // corresponds to the corresponding attribute value entry in the position
118
+ // attribute (AttributeValueIndex in both attributes refer to the same
119
+ // spatial vertex).
120
+ // Returns -1 in case of error.
121
+ int32_t AddPerVertexAttribute(std::unique_ptr<PointAttribute> att);
122
+
123
+ // Removes points that are not mapped to any face of the mesh. All attribute
124
+ // values are going to be removed as well.
125
+ void RemoveIsolatedPoints();
126
+
127
+ // Adds a point attribute |att| to the mesh and returns the index of the
128
+ // newly inserted attribute. Attribute values are mapped 1:1 to face indices.
129
+ // Returns -1 in case of error.
130
+ int32_t AddPerFaceAttribute(std::unique_ptr<PointAttribute> att);
131
+ #endif // DRACO_TRANSCODER_SUPPORTED
132
+
133
+ MeshAttributeElementType GetAttributeElementType(int att_id) const {
134
+ return attribute_data_[att_id].element_type;
135
+ }
136
+
137
+ void SetAttributeElementType(int att_id, MeshAttributeElementType et) {
138
+ attribute_data_[att_id].element_type = et;
139
+ }
140
+
141
+ // Returns the point id of for a corner |ci|.
142
+ inline PointIndex CornerToPointId(int ci) const {
143
+ if (ci < 0 || static_cast<uint32_t>(ci) == kInvalidCornerIndex.value()) {
144
+ return kInvalidPointIndex;
145
+ }
146
+ return this->face(FaceIndex(ci / 3))[ci % 3];
147
+ }
148
+
149
+ // Returns the point id of a corner |ci|.
150
+ inline PointIndex CornerToPointId(CornerIndex ci) const {
151
+ return this->CornerToPointId(ci.value());
152
+ }
153
+
154
+ struct AttributeData {
155
+ AttributeData() : element_type(MESH_CORNER_ATTRIBUTE) {}
156
+ MeshAttributeElementType element_type;
157
+ };
158
+
159
+ #ifdef DRACO_TRANSCODER_SUPPORTED
160
+ void SetName(const std::string &name) { name_ = name; }
161
+ const std::string &GetName() const { return name_; }
162
+ const MaterialLibrary &GetMaterialLibrary() const {
163
+ return material_library_;
164
+ }
165
+ MaterialLibrary &GetMaterialLibrary() { return material_library_; }
166
+
167
+ // Removes all materials that are not referenced by any face of the mesh.
168
+ // Optional argument |remove_unused_material_indices| can be used to control
169
+ // whether unusued material indices are removed as well (default = true).
170
+ // If material indices are not removed, the unused material indices will
171
+ // point to empty (default) materials.
172
+ void RemoveUnusedMaterials();
173
+ void RemoveUnusedMaterials(bool remove_unused_material_indices);
174
+
175
+ // Library that contains non-material textures.
176
+ const TextureLibrary &GetNonMaterialTextureLibrary() const {
177
+ return non_material_texture_library_;
178
+ }
179
+ TextureLibrary &GetNonMaterialTextureLibrary() {
180
+ return non_material_texture_library_;
181
+ }
182
+
183
+ // Mesh feature ID sets as defined by EXT_mesh_features glTF extension.
184
+ MeshFeaturesIndex AddMeshFeatures(
185
+ std::unique_ptr<MeshFeatures> mesh_features) {
186
+ mesh_features_.push_back(std::move(mesh_features));
187
+ mesh_features_material_mask_.push_back({});
188
+ return MeshFeaturesIndex(mesh_features_.size() - 1);
189
+ }
190
+ int NumMeshFeatures() const { return mesh_features_.size(); }
191
+ const MeshFeatures &GetMeshFeatures(MeshFeaturesIndex index) const {
192
+ return *mesh_features_[index];
193
+ }
194
+ MeshFeatures &GetMeshFeatures(MeshFeaturesIndex index) {
195
+ return *mesh_features_[index];
196
+ }
197
+
198
+ // Removes mesh features from the mesh. Note that removing a mesh feature does
199
+ // not delete any associated data such as vertex attributes or feature
200
+ // textures.
201
+ void RemoveMeshFeatures(MeshFeaturesIndex index) {
202
+ mesh_features_.erase(mesh_features_.begin() + index.value());
203
+ mesh_features_material_mask_.erase(mesh_features_material_mask_.begin() +
204
+ index.value());
205
+ }
206
+
207
+ // Returns true if an attribute with |att_id| is being used by any mesh
208
+ // features attached to the mesh.
209
+ bool IsAttributeUsedByMeshFeatures(int att_id) const;
210
+
211
+ // Restricts given mesh features to faces mapped to a material with
212
+ // |material_index|. Note that single mesh features can be restricted to
213
+ // multiple materials.
214
+ void AddMeshFeaturesMaterialMask(MeshFeaturesIndex index,
215
+ int material_index) {
216
+ mesh_features_material_mask_[index].push_back(material_index);
217
+ }
218
+
219
+ size_t NumMeshFeaturesMaterialMasks(MeshFeaturesIndex index) const {
220
+ return mesh_features_material_mask_[index].size();
221
+ }
222
+ int GetMeshFeaturesMaterialMask(MeshFeaturesIndex index,
223
+ int mask_index) const {
224
+ return mesh_features_material_mask_[index][mask_index];
225
+ }
226
+
227
+ // Updates mesh features texture pointer to point to a new |texture_library|.
228
+ // The current texture pointer is used to determine the texture index in the
229
+ // new texture library via a given |texture_to_index_map|.
230
+ static void UpdateMeshFeaturesTexturePointer(
231
+ const std::unordered_map<const Texture *, int> &texture_to_index_map,
232
+ TextureLibrary *texture_library, MeshFeatures *mesh_features);
233
+
234
+ // Copies over mesh features from |source_mesh| and stores them in
235
+ // |target_mesh| as long as the mesh features material mask is valid for
236
+ // given |material_index|.
237
+ static void CopyMeshFeaturesForMaterial(const Mesh &source_mesh,
238
+ Mesh *target_mesh,
239
+ int material_index);
240
+
241
+ // Structural metadata.
242
+ const StructuralMetadata &GetStructuralMetadata() const {
243
+ return structural_metadata_;
244
+ }
245
+ StructuralMetadata &GetStructuralMetadata() { return structural_metadata_; }
246
+
247
+ // Property attributes indices as defined by EXT_structural_metadata glTF
248
+ // extension.
249
+ int AddPropertyAttributesIndex(int property_attribute_index) {
250
+ property_attributes_.push_back(property_attribute_index);
251
+ property_attributes_material_mask_.push_back({});
252
+ return property_attributes_.size() - 1;
253
+ }
254
+ int NumPropertyAttributesIndices() const {
255
+ return property_attributes_.size();
256
+ }
257
+ const int &GetPropertyAttributesIndex(int index) const {
258
+ return property_attributes_[index];
259
+ }
260
+ int &GetPropertyAttributesIndex(int index) {
261
+ return property_attributes_[index];
262
+ }
263
+ void RemovePropertyAttributesIndex(int index) {
264
+ property_attributes_.erase(property_attributes_.begin() + index);
265
+ property_attributes_material_mask_.erase(
266
+ property_attributes_material_mask_.begin() + index);
267
+ }
268
+
269
+ // Restricts given property attributes indices to faces mapped to a material
270
+ // with |material_index|. Note that single property attribute can be
271
+ // restricted to multiple materials.
272
+ void AddPropertyAttributesIndexMaterialMask(int index, int material_index) {
273
+ property_attributes_material_mask_[index].push_back(material_index);
274
+ }
275
+
276
+ size_t NumPropertyAttributesIndexMaterialMasks(int index) const {
277
+ return property_attributes_material_mask_[index].size();
278
+ }
279
+ int GetPropertyAttributesIndexMaterialMask(int index, int mask_index) const {
280
+ return property_attributes_material_mask_[index][mask_index];
281
+ }
282
+
283
+ // Copies over property attributes indices from |source_mesh| and stores them
284
+ // in |target_mesh| as long as the property attributes indices material mask
285
+ // is valid for given |material_index|.
286
+ static void CopyPropertyAttributesIndicesForMaterial(const Mesh &source_mesh,
287
+ Mesh *target_mesh,
288
+ int material_index);
289
+ #endif // DRACO_TRANSCODER_SUPPORTED
290
+
291
+ protected:
292
+ #ifdef DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED
293
+ // Extends the point deduplication to face corners. This method is called from
294
+ // the PointCloud::DeduplicatePointIds() and it remaps all point ids stored in
295
+ // |faces_| to the new deduplicated point ids using the map |id_map|.
296
+ void ApplyPointIdDeduplication(
297
+ const IndexTypeVector<PointIndex, PointIndex> &id_map,
298
+ const std::vector<PointIndex> &unique_point_ids) override;
299
+ #endif
300
+
301
+ // Exposes |faces_|. Use |faces_| at your own risk. DO NOT store the
302
+ // reference: the |faces_| object is destroyed with the mesh.
303
+ IndexTypeVector<FaceIndex, Face> &faces() { return faces_; }
304
+
305
+ private:
306
+ #ifdef DRACO_TRANSCODER_SUPPORTED
307
+ // Updates attribute indices associated to all mesh features after a mesh
308
+ // attribute is deleted.
309
+ void UpdateMeshFeaturesAfterDeletedAttribute(int att_id);
310
+ #endif
311
+ // Mesh specific per-attribute data.
312
+ std::vector<AttributeData> attribute_data_;
313
+
314
+ // Vertex indices valid for all attributes. Each attribute has its own map
315
+ // that converts vertex indices into attribute indices.
316
+ IndexTypeVector<FaceIndex, Face> faces_;
317
+
318
+ #ifdef DRACO_TRANSCODER_SUPPORTED
319
+ // Mesh name.
320
+ std::string name_;
321
+
322
+ // Materials applied to to this mesh.
323
+ MaterialLibrary material_library_;
324
+
325
+ // Sets of feature IDs as defined by EXT_mesh_features glTF extension.
326
+ IndexTypeVector<MeshFeaturesIndex, std::unique_ptr<MeshFeatures>>
327
+ mesh_features_;
328
+
329
+ // When the Mesh contains multiple materials, |mesh_features_material_mask_|
330
+ // can be used to limit specific MeshFeaturesIndex to a vector of material
331
+ // indices. If for a given mesh feature index, the material indices are empty,
332
+ // the corresponding mesh features are applied to the entire mesh.
333
+ IndexTypeVector<MeshFeaturesIndex, std::vector<int>>
334
+ mesh_features_material_mask_;
335
+
336
+ // Indices pointing to property attributes in draco::StructuralMetadata.
337
+ std::vector<int> property_attributes_;
338
+
339
+ // When the Mesh contains multiple materials, this mask can be used to limit
340
+ // specific index into |property_attributes_| to a vector of material indices.
341
+ // If for a given property attributes index, the material indices are empty,
342
+ // the corresponding property attributes are applied to the entire mesh.
343
+ std::vector<std::vector<int>> property_attributes_material_mask_;
344
+
345
+ // Texture library for storing non-material textures used by this mesh, e.g.,
346
+ // textures containing mesh feature IDs of EXT_mesh_features glTF extension.
347
+ // If the mesh is part of the scene then the textures are stored in the scene.
348
+ // Note that mesh features contain pointers to non-material textures. It is
349
+ // responsibility of class user to update these pointers when updating the
350
+ // textures. See Mesh::Copy() for example.
351
+ TextureLibrary non_material_texture_library_;
352
+
353
+ // Structural metadata defined by the EXT_structural_metadata glTF extension.
354
+ StructuralMetadata structural_metadata_;
355
+ #endif // DRACO_TRANSCODER_SUPPORTED
356
+ friend struct MeshHasher;
357
+ };
358
+
359
+ // Functor for computing a hash from data stored within a mesh.
360
+ // Note that this can be quite slow. Two meshes will have the same hash only
361
+ // when they have exactly the same connectivity and attribute values.
362
+ struct MeshHasher {
363
+ size_t operator()(const Mesh &mesh) const {
364
+ PointCloudHasher pc_hasher;
365
+ size_t hash = pc_hasher(mesh);
366
+ // Hash faces.
367
+ for (FaceIndex i(0); i < static_cast<uint32_t>(mesh.faces_.size()); ++i) {
368
+ for (int j = 0; j < 3; ++j) {
369
+ hash = HashCombine(mesh.faces_[i][j].value(), hash);
370
+ }
371
+ }
372
+ return hash;
373
+ }
374
+ };
375
+
376
+ } // namespace draco
377
+
378
+ #endif // DRACO_MESH_MESH_H_
@@ -0,0 +1,71 @@
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_MESH_MESH_ARE_EQUIVALENT_H_
16
+ #define DRACO_MESH_MESH_ARE_EQUIVALENT_H_
17
+
18
+ #include "draco/core/vector_d.h"
19
+ #include "draco/mesh/mesh.h"
20
+
21
+ // This file defines a functor to compare two meshes for equivalency up
22
+ // to permutation of the vertices.
23
+ namespace draco {
24
+
25
+ // A functor to compare two meshes for equivalency up to permutation of the
26
+ // vertices.
27
+ class MeshAreEquivalent {
28
+ public:
29
+ // Returns true if both meshes are equivalent up to permutation of
30
+ // the internal order of vertices. This includes all attributes.
31
+ bool operator()(const Mesh &mesh0, const Mesh &mesh1);
32
+
33
+ private:
34
+ // Internal type to keep overview.
35
+ struct MeshInfo {
36
+ explicit MeshInfo(const Mesh &in_mesh) : mesh(in_mesh) {}
37
+ const Mesh &mesh;
38
+ std::vector<FaceIndex> ordered_index_of_face;
39
+ IndexTypeVector<FaceIndex, int> corner_index_of_smallest_vertex;
40
+ };
41
+
42
+ // Prepare functor for actual comparison.
43
+ void Init(const Mesh &mesh0, const Mesh &mesh1);
44
+
45
+ // Get position as Vector3f of corner c of face f.
46
+ static Vector3f GetPosition(const Mesh &mesh, FaceIndex f, int32_t c);
47
+ // Internal helper function mostly for debugging.
48
+ void PrintPosition(const Mesh &mesh, FaceIndex f, int32_t c);
49
+ // Get the corner index of the lex smallest vertex of face f.
50
+ static int32_t ComputeCornerIndexOfSmallestPointXYZ(const Mesh &mesh,
51
+ FaceIndex f);
52
+
53
+ // Less compare functor for two faces (represented by their indices)
54
+ // with respect to their lex order.
55
+ struct FaceIndexLess {
56
+ explicit FaceIndexLess(const MeshInfo &in_mesh_info)
57
+ : mesh_info(in_mesh_info) {}
58
+ bool operator()(FaceIndex f0, FaceIndex f1) const;
59
+ const MeshInfo &mesh_info;
60
+ };
61
+
62
+ void InitCornerIndexOfSmallestPointXYZ();
63
+ void InitOrderedFaceIndex();
64
+
65
+ std::vector<MeshInfo> mesh_infos_;
66
+ int32_t num_faces_;
67
+ };
68
+
69
+ } // namespace draco
70
+
71
+ #endif // DRACO_MESH_MESH_ARE_EQUIVALENT_H_
@@ -0,0 +1,202 @@
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_MESH_MESH_ATTRIBUTE_CORNER_TABLE_H_
16
+ #define DRACO_MESH_MESH_ATTRIBUTE_CORNER_TABLE_H_
17
+
18
+ #include "draco/core/macros.h"
19
+ #include "draco/mesh/corner_table.h"
20
+ #include "draco/mesh/mesh.h"
21
+ #include "draco/mesh/valence_cache.h"
22
+
23
+ namespace draco {
24
+
25
+ // Class for storing connectivity of mesh attributes. The connectivity is stored
26
+ // as a difference from the base mesh's corner table, where the differences are
27
+ // represented by attribute seam edges. This class provides a basic
28
+ // functionality for detecting the seam edges for a given attribute and for
29
+ // traversing the constrained corner table with the seam edges.
30
+ class MeshAttributeCornerTable {
31
+ public:
32
+ MeshAttributeCornerTable();
33
+ bool InitEmpty(const CornerTable *table);
34
+ bool InitFromAttribute(const Mesh *mesh, const CornerTable *table,
35
+ const PointAttribute *att);
36
+
37
+ void AddSeamEdge(CornerIndex opp_corner);
38
+
39
+ // Recomputes vertices using the newly added seam edges (needs to be called
40
+ // whenever the seam edges are updated).
41
+ // |mesh| and |att| can be null, in which case mapping between vertices and
42
+ // attribute value ids is set to identity.
43
+ bool RecomputeVertices(const Mesh *mesh, const PointAttribute *att);
44
+
45
+ inline bool IsCornerOppositeToSeamEdge(CornerIndex corner) const {
46
+ return is_edge_on_seam_[corner.value()];
47
+ }
48
+
49
+ inline CornerIndex Opposite(CornerIndex corner) const {
50
+ if (corner == kInvalidCornerIndex || IsCornerOppositeToSeamEdge(corner)) {
51
+ return kInvalidCornerIndex;
52
+ }
53
+ return corner_table_->Opposite(corner);
54
+ }
55
+
56
+ inline CornerIndex Next(CornerIndex corner) const {
57
+ return corner_table_->Next(corner);
58
+ }
59
+
60
+ inline CornerIndex Previous(CornerIndex corner) const {
61
+ return corner_table_->Previous(corner);
62
+ }
63
+
64
+ // Returns true when a corner is attached to any attribute seam.
65
+ inline bool IsCornerOnSeam(CornerIndex corner) const {
66
+ return is_vertex_on_seam_[corner_table_->Vertex(corner).value()];
67
+ }
68
+
69
+ // Similar to CornerTable::GetLeftCorner and CornerTable::GetRightCorner, but
70
+ // does not go over seam edges.
71
+ inline CornerIndex GetLeftCorner(CornerIndex corner) const {
72
+ return Opposite(Previous(corner));
73
+ }
74
+ inline CornerIndex GetRightCorner(CornerIndex corner) const {
75
+ return Opposite(Next(corner));
76
+ }
77
+
78
+ // Similar to CornerTable::SwingRight, but it does not go over seam edges.
79
+ inline CornerIndex SwingRight(CornerIndex corner) const {
80
+ return Previous(Opposite(Previous(corner)));
81
+ }
82
+
83
+ // Similar to CornerTable::SwingLeft, but it does not go over seam edges.
84
+ inline CornerIndex SwingLeft(CornerIndex corner) const {
85
+ return Next(Opposite(Next(corner)));
86
+ }
87
+
88
+ int num_vertices() const {
89
+ return static_cast<int>(vertex_to_attribute_entry_id_map_.size());
90
+ }
91
+ int num_faces() const { return static_cast<int>(corner_table_->num_faces()); }
92
+ int num_corners() const { return corner_table_->num_corners(); }
93
+
94
+ VertexIndex Vertex(CornerIndex corner) const {
95
+ DRACO_DCHECK_LT(corner.value(), corner_to_vertex_map_.size());
96
+ return ConfidentVertex(corner);
97
+ }
98
+ VertexIndex ConfidentVertex(CornerIndex corner) const {
99
+ return corner_to_vertex_map_[corner.value()];
100
+ }
101
+ // Returns the attribute entry id associated to the given vertex.
102
+ VertexIndex VertexParent(VertexIndex vert) const {
103
+ return VertexIndex(vertex_to_attribute_entry_id_map_[vert.value()].value());
104
+ }
105
+
106
+ inline CornerIndex LeftMostCorner(VertexIndex v) const {
107
+ return vertex_to_left_most_corner_map_[v.value()];
108
+ }
109
+
110
+ inline FaceIndex Face(CornerIndex corner) const {
111
+ return corner_table_->Face(corner);
112
+ }
113
+
114
+ inline CornerIndex FirstCorner(FaceIndex face) const {
115
+ return corner_table_->FirstCorner(face);
116
+ }
117
+
118
+ inline std::array<CornerIndex, 3> AllCorners(FaceIndex face) const {
119
+ return corner_table_->AllCorners(face);
120
+ }
121
+
122
+ inline bool IsOnBoundary(VertexIndex vert) const {
123
+ const CornerIndex corner = LeftMostCorner(vert);
124
+ if (corner == kInvalidCornerIndex) {
125
+ return true;
126
+ }
127
+ if (SwingLeft(corner) == kInvalidCornerIndex) {
128
+ return true;
129
+ }
130
+ return false;
131
+ }
132
+
133
+ bool IsDegenerated(FaceIndex face) const {
134
+ // Introducing seams can't change the degeneracy of the individual faces,
135
+ // therefore we can delegate the check to the original |corner_table_|.
136
+ return corner_table_->IsDegenerated(face);
137
+ }
138
+
139
+ bool no_interior_seams() const { return no_interior_seams_; }
140
+ const CornerTable *corner_table() const { return corner_table_; }
141
+
142
+ // TODO(draco-eng): extract valence functions into a reusable class/object
143
+ // also from 'corner_table.*'
144
+
145
+ // Returns the valence (or degree) of a vertex.
146
+ // Returns -1 if the given vertex index is not valid.
147
+ int Valence(VertexIndex v) const;
148
+ // Same as above but does not check for validity and does not return -1
149
+ int ConfidentValence(VertexIndex v) const;
150
+ // Returns the valence of the vertex at the given corner.
151
+ inline int Valence(CornerIndex c) const {
152
+ DRACO_DCHECK_LT(c.value(), corner_table_->num_corners());
153
+ if (c == kInvalidCornerIndex) {
154
+ return -1;
155
+ }
156
+ return ConfidentValence(c);
157
+ }
158
+ inline int ConfidentValence(CornerIndex c) const {
159
+ DRACO_DCHECK_LT(c.value(), corner_table_->num_corners());
160
+ return ConfidentValence(Vertex(c));
161
+ }
162
+
163
+ // Allows access to an internal object for caching valences. The object can
164
+ // be instructed to cache or uncache all valences and then its interfaces
165
+ // queried directly for valences with differing performance/confidence
166
+ // qualities. If the mesh or table is modified the cache should be discarded
167
+ // and not relied on as it does not automatically update or invalidate for
168
+ // performance reasons.
169
+ const ValenceCache<MeshAttributeCornerTable> &GetValenceCache() const {
170
+ return valence_cache_;
171
+ }
172
+
173
+ private:
174
+ template <bool init_vertex_to_attribute_entry_map>
175
+ bool RecomputeVerticesInternal(const Mesh *mesh, const PointAttribute *att);
176
+
177
+ std::vector<bool> is_edge_on_seam_;
178
+ std::vector<bool> is_vertex_on_seam_;
179
+
180
+ // If this is set to true, it means that there are no attribute seams between
181
+ // two faces. This can be used to speed up some algorithms.
182
+ bool no_interior_seams_;
183
+
184
+ std::vector<VertexIndex> corner_to_vertex_map_;
185
+
186
+ // Map between vertices and their associated left most corners. A left most
187
+ // corner is a corner that is adjacent to a boundary or an attribute seam from
188
+ // right (i.e., SwingLeft from that corner will return an invalid corner). If
189
+ // no such corner exists for a given vertex, then any corner attached to the
190
+ // vertex can be used.
191
+ std::vector<CornerIndex> vertex_to_left_most_corner_map_;
192
+
193
+ // Map between vertex ids and attribute entry ids (i.e. the values stored in
194
+ // the attribute buffer). The attribute entry id can be retrieved using the
195
+ // VertexParent() method.
196
+ std::vector<AttributeValueIndex> vertex_to_attribute_entry_id_map_;
197
+ const CornerTable *corner_table_;
198
+ ValenceCache<MeshAttributeCornerTable> valence_cache_;
199
+ };
200
+
201
+ } // namespace draco
202
+ #endif // DRACO_MESH_MESH_ATTRIBUTE_CORNER_TABLE_H_