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,94 @@
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_IO_PLY_PROPERTY_WRITER_H_
16
+ #define DRACO_IO_PLY_PROPERTY_WRITER_H_
17
+
18
+ #include <functional>
19
+
20
+ #include "draco/io/ply_reader.h"
21
+
22
+ namespace draco {
23
+
24
+ // Class for writing PlyProperty with a given type, performing data conversion
25
+ // if necessary.
26
+ template <typename WriteTypeT>
27
+ class PlyPropertyWriter {
28
+ public:
29
+ explicit PlyPropertyWriter(PlyProperty *property) : property_(property) {
30
+ // Find the suitable function for converting values.
31
+ switch (property->data_type()) {
32
+ case DT_UINT8:
33
+ convert_value_func_ = [this](WriteTypeT val) {
34
+ return this->ConvertValue<uint8_t>(val);
35
+ };
36
+ break;
37
+ case DT_INT8:
38
+ convert_value_func_ = [this](WriteTypeT val) {
39
+ return this->ConvertValue<int8_t>(val);
40
+ };
41
+ break;
42
+ case DT_UINT16:
43
+ convert_value_func_ = [this](WriteTypeT val) {
44
+ return this->ConvertValue<uint16_t>(val);
45
+ };
46
+ break;
47
+ case DT_INT16:
48
+ convert_value_func_ = [this](WriteTypeT val) {
49
+ return this->ConvertValue<int16_t>(val);
50
+ };
51
+ break;
52
+ case DT_UINT32:
53
+ convert_value_func_ = [this](WriteTypeT val) {
54
+ return this->ConvertValue<uint32_t>(val);
55
+ };
56
+ break;
57
+ case DT_INT32:
58
+ convert_value_func_ = [this](WriteTypeT val) {
59
+ return this->ConvertValue<int32_t>(val);
60
+ };
61
+ break;
62
+ case DT_FLOAT32:
63
+ convert_value_func_ = [this](WriteTypeT val) {
64
+ return this->ConvertValue<float>(val);
65
+ };
66
+ break;
67
+ case DT_FLOAT64:
68
+ convert_value_func_ = [this](WriteTypeT val) {
69
+ return this->ConvertValue<double>(val);
70
+ };
71
+ break;
72
+ default:
73
+ break;
74
+ }
75
+ }
76
+
77
+ void PushBackValue(WriteTypeT value) const {
78
+ return convert_value_func_(value);
79
+ }
80
+
81
+ private:
82
+ template <typename SourceTypeT>
83
+ void ConvertValue(WriteTypeT value) const {
84
+ const SourceTypeT src_val = static_cast<SourceTypeT>(value);
85
+ property_->push_back_value(&src_val);
86
+ }
87
+
88
+ PlyProperty *property_;
89
+ std::function<void(WriteTypeT)> convert_value_func_;
90
+ };
91
+
92
+ } // namespace draco
93
+
94
+ #endif // DRACO_IO_PLY_PROPERTY_WRITER_H_
@@ -0,0 +1,155 @@
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
+ // File contains helper classes used for parsing of PLY files. The classes are
16
+ // used by the PlyDecoder (ply_decoder.h) to read a point cloud or mesh from a
17
+ // source PLY file.
18
+ // TODO(ostava): Currently, we support only binary PLYs encoded in the little
19
+ // endian format ("format binary_little_endian 1.0").
20
+
21
+ #ifndef DRACO_IO_PLY_READER_H_
22
+ #define DRACO_IO_PLY_READER_H_
23
+
24
+ #include <map>
25
+ #include <vector>
26
+
27
+ #include "draco/core/decoder_buffer.h"
28
+ #include "draco/core/draco_types.h"
29
+ #include "draco/core/status.h"
30
+ #include "draco/core/status_or.h"
31
+
32
+ namespace draco {
33
+
34
+ // A single PLY property of a given PLY element. For "vertex" element this can
35
+ // contain data such as "x", "y", or "z" coordinate of the vertex, while for
36
+ // "face" element this usually contains corner indices.
37
+ class PlyProperty {
38
+ public:
39
+ friend class PlyReader;
40
+
41
+ PlyProperty(const std::string &name, DataType data_type, DataType list_type);
42
+ void ReserveData(int num_entries) {
43
+ data_.reserve(DataTypeLength(data_type_) * num_entries);
44
+ }
45
+
46
+ int64_t GetListEntryOffset(int entry_id) const {
47
+ return list_data_[entry_id * 2];
48
+ }
49
+ int64_t GetListEntryNumValues(int entry_id) const {
50
+ return list_data_[entry_id * 2 + 1];
51
+ }
52
+ const void *GetDataEntryAddress(int entry_id) const {
53
+ return data_.data() + entry_id * data_type_num_bytes_;
54
+ }
55
+ void push_back_value(const void *data) {
56
+ data_.insert(data_.end(), static_cast<const uint8_t *>(data),
57
+ static_cast<const uint8_t *>(data) + data_type_num_bytes_);
58
+ }
59
+
60
+ const std::string &name() const { return name_; }
61
+ bool is_list() const { return list_data_type_ != DT_INVALID; }
62
+ DataType data_type() const { return data_type_; }
63
+ int data_type_num_bytes() const { return data_type_num_bytes_; }
64
+ DataType list_data_type() const { return list_data_type_; }
65
+ int list_data_type_num_bytes() const { return list_data_type_num_bytes_; }
66
+
67
+ private:
68
+ std::string name_;
69
+ std::vector<uint8_t> data_;
70
+ // List data contain pairs of <offset, number_of_values>
71
+ std::vector<int64_t> list_data_;
72
+ DataType data_type_;
73
+ int data_type_num_bytes_;
74
+ DataType list_data_type_;
75
+ int list_data_type_num_bytes_;
76
+ };
77
+
78
+ // A single PLY element such as "vertex" or "face". Each element can store
79
+ // arbitrary properties such as vertex coordinates or face indices.
80
+ class PlyElement {
81
+ public:
82
+ PlyElement(const std::string &name, int64_t num_entries);
83
+ void AddProperty(const PlyProperty &prop) {
84
+ property_index_[prop.name()] = static_cast<int>(properties_.size());
85
+ properties_.emplace_back(prop);
86
+ if (!properties_.back().is_list()) {
87
+ properties_.back().ReserveData(static_cast<int>(num_entries_));
88
+ }
89
+ }
90
+
91
+ const PlyProperty *GetPropertyByName(const std::string &name) const {
92
+ const auto it = property_index_.find(name);
93
+ if (it != property_index_.end()) {
94
+ return &properties_[it->second];
95
+ }
96
+ return nullptr;
97
+ }
98
+
99
+ int num_properties() const { return static_cast<int>(properties_.size()); }
100
+ int num_entries() const { return static_cast<int>(num_entries_); }
101
+ const PlyProperty &property(int prop_index) const {
102
+ return properties_[prop_index];
103
+ }
104
+ PlyProperty &property(int prop_index) { return properties_[prop_index]; }
105
+
106
+ private:
107
+ std::string name_;
108
+ int64_t num_entries_;
109
+ std::vector<PlyProperty> properties_;
110
+ std::map<std::string, int> property_index_;
111
+ };
112
+
113
+ // Class responsible for parsing PLY data. It produces a list of PLY elements
114
+ // and their properties that can be used to construct a mesh or a point cloud.
115
+ class PlyReader {
116
+ public:
117
+ PlyReader();
118
+ Status Read(DecoderBuffer *buffer);
119
+
120
+ const PlyElement *GetElementByName(const std::string &name) const {
121
+ const auto it = element_index_.find(name);
122
+ if (it != element_index_.end()) {
123
+ return &elements_[it->second];
124
+ }
125
+ return nullptr;
126
+ }
127
+
128
+ int num_elements() const { return static_cast<int>(elements_.size()); }
129
+ const PlyElement &element(int element_index) const {
130
+ return elements_[element_index];
131
+ }
132
+
133
+ private:
134
+ enum Format { kLittleEndian = 0, kAscii };
135
+
136
+ Status ParseHeader(DecoderBuffer *buffer);
137
+ StatusOr<bool> ParseEndHeader(DecoderBuffer *buffer);
138
+ bool ParseElement(DecoderBuffer *buffer);
139
+ StatusOr<bool> ParseProperty(DecoderBuffer *buffer);
140
+ bool ParsePropertiesData(DecoderBuffer *buffer);
141
+ bool ParseElementData(DecoderBuffer *buffer, int element_index);
142
+ bool ParseElementDataAscii(DecoderBuffer *buffer, int element_index);
143
+
144
+ // Splits |line| by whitespace characters.
145
+ std::vector<std::string> SplitWords(const std::string &line);
146
+ DataType GetDataTypeFromString(const std::string &name) const;
147
+
148
+ std::vector<PlyElement> elements_;
149
+ std::map<std::string, int> element_index_;
150
+ Format format_;
151
+ };
152
+
153
+ } // namespace draco
154
+
155
+ #endif // DRACO_IO_PLY_READER_H_
@@ -0,0 +1,89 @@
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_IO_POINT_CLOUD_IO_H_
16
+ #define DRACO_IO_POINT_CLOUD_IO_H_
17
+
18
+ #include "draco/compression/config/compression_shared.h"
19
+ #include "draco/compression/decode.h"
20
+ #include "draco/compression/expert_encode.h"
21
+
22
+ namespace draco {
23
+
24
+ template <typename OutStreamT>
25
+ OutStreamT WritePointCloudIntoStream(const PointCloud *pc, OutStreamT &&os,
26
+ PointCloudEncodingMethod method,
27
+ const EncoderOptions &options) {
28
+ EncoderBuffer buffer;
29
+ EncoderOptions local_options = options;
30
+ ExpertEncoder encoder(*pc);
31
+ encoder.Reset(local_options);
32
+ encoder.SetEncodingMethod(method);
33
+ if (!encoder.EncodeToBuffer(&buffer).ok()) {
34
+ os.setstate(std::ios_base::badbit);
35
+ return os;
36
+ }
37
+
38
+ os.write(static_cast<const char *>(buffer.data()), buffer.size());
39
+
40
+ return os;
41
+ }
42
+
43
+ template <typename OutStreamT>
44
+ OutStreamT WritePointCloudIntoStream(const PointCloud *pc, OutStreamT &&os,
45
+ PointCloudEncodingMethod method) {
46
+ const EncoderOptions options = EncoderOptions::CreateDefaultOptions();
47
+ return WritePointCloudIntoStream(pc, os, method, options);
48
+ }
49
+
50
+ template <typename OutStreamT>
51
+ OutStreamT &WritePointCloudIntoStream(const PointCloud *pc, OutStreamT &&os) {
52
+ return WritePointCloudIntoStream(pc, os, POINT_CLOUD_SEQUENTIAL_ENCODING);
53
+ }
54
+
55
+ template <typename InStreamT>
56
+ InStreamT &ReadPointCloudFromStream(std::unique_ptr<PointCloud> *point_cloud,
57
+ InStreamT &&is) {
58
+ // Determine size of stream and write into a vector
59
+ const auto start_pos = is.tellg();
60
+ is.seekg(0, std::ios::end);
61
+ const std::streampos is_size = is.tellg() - start_pos;
62
+ is.seekg(start_pos);
63
+ std::vector<char> data(is_size);
64
+ is.read(&data[0], is_size);
65
+
66
+ // Create a point cloud from that data.
67
+ DecoderBuffer buffer;
68
+ buffer.Init(&data[0], data.size());
69
+ Decoder decoder;
70
+ auto statusor = decoder.DecodePointCloudFromBuffer(&buffer);
71
+ *point_cloud = std::move(statusor).value();
72
+ if (!statusor.ok() || *point_cloud == nullptr) {
73
+ is.setstate(std::ios_base::badbit);
74
+ }
75
+
76
+ return is;
77
+ }
78
+
79
+ // Reads a point cloud from a file. The function automatically chooses the
80
+ // correct decoder based on the extension of the files. Currently, .obj and .ply
81
+ // files are supported. Other file extensions are processed by the default
82
+ // draco::PointCloudDecoder.
83
+ // Returns nullptr with an error status if the decoding failed.
84
+ StatusOr<std::unique_ptr<PointCloud>> ReadPointCloudFromFile(
85
+ const std::string &file_name);
86
+
87
+ } // namespace draco
88
+
89
+ #endif // DRACO_IO_POINT_CLOUD_IO_H_
@@ -0,0 +1,48 @@
1
+ #ifndef DRACO_IO_STDIO_FILE_READER_H_
2
+ #define DRACO_IO_STDIO_FILE_READER_H_
3
+
4
+ #include <cstddef>
5
+ #include <cstdint>
6
+ #include <cstdio>
7
+ #include <memory>
8
+ #include <string>
9
+ #include <vector>
10
+
11
+ #include "draco/io/file_reader_interface.h"
12
+
13
+ namespace draco {
14
+
15
+ class StdioFileReader : public FileReaderInterface {
16
+ public:
17
+ // Creates and returns a StdioFileReader that reads from |file_name|.
18
+ // Returns nullptr when the file does not exist or cannot be read.
19
+ static std::unique_ptr<FileReaderInterface> Open(
20
+ const std::string &file_name);
21
+
22
+ StdioFileReader() = delete;
23
+ StdioFileReader(const StdioFileReader &) = delete;
24
+ StdioFileReader &operator=(const StdioFileReader &) = delete;
25
+
26
+ StdioFileReader(StdioFileReader &&) = default;
27
+ StdioFileReader &operator=(StdioFileReader &&) = default;
28
+
29
+ // Closes |file_|.
30
+ ~StdioFileReader() override;
31
+
32
+ // Reads the entire contents of the input file into |buffer| and returns true.
33
+ bool ReadFileToBuffer(std::vector<char> *buffer) override;
34
+ bool ReadFileToBuffer(std::vector<uint8_t> *buffer) override;
35
+
36
+ // Returns the size of the file.
37
+ size_t GetFileSize() override;
38
+
39
+ private:
40
+ StdioFileReader(FILE *file) : file_(file) {}
41
+
42
+ FILE *file_ = nullptr;
43
+ static bool registered_in_factory_;
44
+ };
45
+
46
+ } // namespace draco
47
+
48
+ #endif // DRACO_IO_STDIO_FILE_READER_H_
@@ -0,0 +1,42 @@
1
+ #ifndef DRACO_IO_STDIO_FILE_WRITER_H_
2
+ #define DRACO_IO_STDIO_FILE_WRITER_H_
3
+
4
+ #include <cstddef>
5
+ #include <cstdio>
6
+ #include <memory>
7
+ #include <string>
8
+
9
+ #include "draco/io/file_writer_interface.h"
10
+
11
+ namespace draco {
12
+
13
+ class StdioFileWriter : public FileWriterInterface {
14
+ public:
15
+ // Creates and returns a StdioFileWriter that writes to |file_name|.
16
+ // Returns nullptr when |file_name| cannot be opened for writing.
17
+ static std::unique_ptr<FileWriterInterface> Open(
18
+ const std::string &file_name);
19
+
20
+ StdioFileWriter() = delete;
21
+ StdioFileWriter(const StdioFileWriter &) = delete;
22
+ StdioFileWriter &operator=(const StdioFileWriter &) = delete;
23
+
24
+ StdioFileWriter(StdioFileWriter &&) = default;
25
+ StdioFileWriter &operator=(StdioFileWriter &&) = default;
26
+
27
+ // Closes |file_|.
28
+ ~StdioFileWriter() override;
29
+
30
+ // Writes |size| bytes to |file_| from |buffer|. Returns true for success.
31
+ bool Write(const char *buffer, size_t size) override;
32
+
33
+ private:
34
+ StdioFileWriter(FILE *file) : file_(file) {}
35
+
36
+ FILE *file_ = nullptr;
37
+ static bool registered_in_factory_;
38
+ };
39
+
40
+ } // namespace draco
41
+
42
+ #endif // DRACO_IO_STDIO_FILE_WRITER_H_
@@ -0,0 +1,38 @@
1
+ // Copyright 2022 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_IO_STL_DECODER_H_
16
+ #define DRACO_IO_STL_DECODER_H_
17
+
18
+ #include <string>
19
+
20
+ #include "draco/core/decoder_buffer.h"
21
+ #include "draco/core/status.h"
22
+ #include "draco/core/status_or.h"
23
+ #include "draco/draco_features.h"
24
+ #include "draco/mesh/mesh.h"
25
+
26
+ namespace draco {
27
+
28
+ // Decodes an STL file into draco::Mesh (or draco::PointCloud if the
29
+ // connectivity data is not needed).
30
+ class StlDecoder {
31
+ public:
32
+ StatusOr<std::unique_ptr<Mesh>> DecodeFromFile(const std::string &file_name);
33
+ StatusOr<std::unique_ptr<Mesh>> DecodeFromBuffer(DecoderBuffer *buffer);
34
+ };
35
+
36
+ } // namespace draco
37
+
38
+ #endif // DRACO_IO_STL_DECODER_H_
@@ -0,0 +1,52 @@
1
+ // Copyright 2022 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_IO_STL_ENCODER_H_
16
+ #define DRACO_IO_STL_ENCODER_H_
17
+
18
+ #include <string>
19
+
20
+ #include "draco/core/encoder_buffer.h"
21
+ #include "draco/draco_features.h"
22
+ #include "draco/mesh/mesh.h"
23
+
24
+ namespace draco {
25
+
26
+ // Class for encoding draco::Mesh into the STL file format.
27
+ class StlEncoder {
28
+ public:
29
+ StlEncoder();
30
+
31
+ // Encodes the mesh and saves it into a file.
32
+ // Returns false when either the encoding failed or when the file couldn't be
33
+ // opened.
34
+ Status EncodeToFile(const Mesh &mesh, const std::string &file_name);
35
+
36
+ // Encodes the mesh into a buffer.
37
+ Status EncodeToBuffer(const Mesh &mesh, EncoderBuffer *out_buffer);
38
+
39
+ protected:
40
+ Status EncodeInternal();
41
+ EncoderBuffer *buffer() const { return out_buffer_; }
42
+
43
+ private:
44
+ EncoderBuffer *out_buffer_;
45
+
46
+ const PointCloud *in_point_cloud_;
47
+ const Mesh *in_mesh_;
48
+ };
49
+
50
+ } // namespace draco
51
+
52
+ #endif // DRACO_IO_STL_ENCODER_H_