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,107 @@
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_MESH_IO_H_
16
+ #define DRACO_IO_MESH_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
+ #include "draco/core/options.h"
22
+
23
+ namespace draco {
24
+
25
+ template <typename OutStreamT>
26
+ OutStreamT WriteMeshIntoStream(const Mesh *mesh, OutStreamT &&os,
27
+ MeshEncoderMethod method,
28
+ const EncoderOptions &options) {
29
+ EncoderBuffer buffer;
30
+ EncoderOptions local_options = options;
31
+ ExpertEncoder encoder(*mesh);
32
+ encoder.Reset(local_options);
33
+ encoder.SetEncodingMethod(method);
34
+ if (!encoder.EncodeToBuffer(&buffer).ok()) {
35
+ os.setstate(std::ios_base::badbit);
36
+ return os;
37
+ }
38
+
39
+ os.write(static_cast<const char *>(buffer.data()), buffer.size());
40
+
41
+ return os;
42
+ }
43
+
44
+ template <typename OutStreamT>
45
+ OutStreamT WriteMeshIntoStream(const Mesh *mesh, OutStreamT &&os,
46
+ MeshEncoderMethod method) {
47
+ const EncoderOptions options = EncoderOptions::CreateDefaultOptions();
48
+ return WriteMeshIntoStream(mesh, os, method, options);
49
+ }
50
+
51
+ template <typename OutStreamT>
52
+ OutStreamT &WriteMeshIntoStream(const Mesh *mesh, OutStreamT &&os) {
53
+ return WriteMeshIntoStream(mesh, os, MESH_EDGEBREAKER_ENCODING);
54
+ }
55
+
56
+ template <typename InStreamT>
57
+ InStreamT &ReadMeshFromStream(std::unique_ptr<Mesh> *mesh, 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 mesh from that data.
67
+ DecoderBuffer buffer;
68
+ buffer.Init(&data[0], data.size());
69
+ Decoder decoder;
70
+ auto statusor = decoder.DecodeMeshFromBuffer(&buffer);
71
+ *mesh = std::move(statusor).value();
72
+ if (!statusor.ok() || *mesh == nullptr) {
73
+ is.setstate(std::ios_base::badbit);
74
+ }
75
+
76
+ return is;
77
+ }
78
+
79
+ // Reads a mesh from a file. The function automatically chooses the correct
80
+ // decoder based on the extension of the files. Currently, .obj and .ply files
81
+ // are supported. Other file extensions are processed by the default
82
+ // draco::MeshDecoder.
83
+ // Returns nullptr with an error status if the decoding failed.
84
+ StatusOr<std::unique_ptr<Mesh>> ReadMeshFromFile(const std::string &file_name);
85
+
86
+ // Reads a mesh from a file. The function does the same thing as the previous
87
+ // one except using metadata to encode additional information when
88
+ // |use_metadata| is set to true.
89
+ // Returns nullptr with an error status if the decoding failed.
90
+ StatusOr<std::unique_ptr<Mesh>> ReadMeshFromFile(const std::string &file_name,
91
+ bool use_metadata);
92
+
93
+ // Reads a mesh from a file. Reading is configured with |options|:
94
+ // use_metadata : Read obj file info like material names and object names into
95
+ // metadata. Default is false.
96
+ // The second form returns the files associated with the mesh via the
97
+ // |mesh_files| argument.
98
+ // Returns nullptr with an error status if the decoding failed.
99
+ StatusOr<std::unique_ptr<Mesh>> ReadMeshFromFile(const std::string &file_name,
100
+ const Options &options);
101
+ StatusOr<std::unique_ptr<Mesh>> ReadMeshFromFile(
102
+ const std::string &file_name, const Options &options,
103
+ std::vector<std::string> *mesh_files);
104
+
105
+ } // namespace draco
106
+
107
+ #endif // DRACO_IO_MESH_IO_H_
@@ -0,0 +1,147 @@
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_OBJ_DECODER_H_
16
+ #define DRACO_IO_OBJ_DECODER_H_
17
+
18
+ #include <string>
19
+ #include <unordered_map>
20
+
21
+ #include "draco/core/decoder_buffer.h"
22
+ #include "draco/core/status.h"
23
+ #include "draco/draco_features.h"
24
+ #include "draco/mesh/mesh.h"
25
+
26
+ namespace draco {
27
+
28
+ // Decodes a Wavefront OBJ file into draco::Mesh (or draco::PointCloud if the
29
+ // connectivity data is not needed).. This decoder can handle decoding of
30
+ // positions, texture coordinates, normals and triangular faces.
31
+ // All other geometry properties are ignored.
32
+ class ObjDecoder {
33
+ public:
34
+ ObjDecoder();
35
+
36
+ // Decodes an obj file stored in the input file.
37
+ // Optional argument |mesh_files| will be populated with all paths to files
38
+ // relevant to the loaded mesh.
39
+ Status DecodeFromFile(const std::string &file_name, Mesh *out_mesh);
40
+ Status DecodeFromFile(const std::string &file_name, Mesh *out_mesh,
41
+ std::vector<std::string> *mesh_files);
42
+
43
+ Status DecodeFromFile(const std::string &file_name,
44
+ PointCloud *out_point_cloud);
45
+
46
+ Status DecodeFromBuffer(DecoderBuffer *buffer, Mesh *out_mesh);
47
+ Status DecodeFromBuffer(DecoderBuffer *buffer, PointCloud *out_point_cloud);
48
+
49
+ // Flag that can be used to turn on/off deduplication of input values.
50
+ // This should be disabled only when we are sure that the input data does not
51
+ // contain any duplicate entries.
52
+ // Default: true
53
+ void set_deduplicate_input_values(bool v) { deduplicate_input_values_ = v; }
54
+ // Flag for whether using metadata to record other information in the obj
55
+ // file, e.g. material names, object names.
56
+ void set_use_metadata(bool flag) { use_metadata_ = flag; }
57
+ // Enables preservation of polygons.
58
+ void set_preserve_polygons(bool flag) { preserve_polygons_ = flag; }
59
+
60
+ protected:
61
+ Status DecodeInternal();
62
+ DecoderBuffer *buffer() { return &buffer_; }
63
+
64
+ private:
65
+ // Resets internal counters for attributes and faces.
66
+ void ResetCounters();
67
+
68
+ // Parses the next mesh property definition (position, tex coord, normal, or
69
+ // face). If the parsed data is unrecognized, it will be skipped.
70
+ // Returns false when the end of file was reached.
71
+ bool ParseDefinition(Status *status);
72
+
73
+ // Attempts to parse definition of position, normal, tex coord, or face
74
+ // respectively.
75
+ // Returns false when the parsed data didn't contain the given definition.
76
+ bool ParseVertexPosition(Status *status);
77
+ bool ParseNormal(Status *status);
78
+ bool ParseTexCoord(Status *status);
79
+ bool ParseFace(Status *status);
80
+ bool ParseMaterialLib(Status *status);
81
+ bool ParseMaterial(Status *status);
82
+ bool ParseObject(Status *status);
83
+
84
+ // Parses triplet of position, tex coords and normal indices.
85
+ // Returns false on error.
86
+ bool ParseVertexIndices(std::array<int32_t, 3> *out_indices);
87
+
88
+ // Maps specified point index to the parsed vertex indices (triplet of
89
+ // position, texture coordinate, and normal indices) .
90
+ void MapPointToVertexIndices(PointIndex vert_id,
91
+ const std::array<int32_t, 3> &indices);
92
+
93
+ // Parses material file definitions from a separate file.
94
+ bool ParseMaterialFile(const std::string &file_name, Status *status);
95
+ bool ParseMaterialFileDefinition(Status *status);
96
+
97
+ // Methods related to polygon triangulation and preservation.
98
+ static int Triangulate(int tri_index, int tri_corner);
99
+ static bool IsNewEdge(int tri_count, int tri_index, int tri_corner);
100
+
101
+ private:
102
+ // If set to true, the parser will count the number of various definitions
103
+ // but it will not parse the actual data or add any new entries to the mesh.
104
+ bool counting_mode_;
105
+ int num_obj_faces_;
106
+ int num_positions_;
107
+ int num_tex_coords_;
108
+ int num_normals_;
109
+ int num_materials_;
110
+ int last_sub_obj_id_;
111
+
112
+ int pos_att_id_;
113
+ int tex_att_id_;
114
+ int norm_att_id_;
115
+ int material_att_id_;
116
+ int sub_obj_att_id_; // Attribute id for storing sub-objects.
117
+ int added_edge_att_id_; // Attribute id for polygon reconstruction.
118
+
119
+ bool deduplicate_input_values_;
120
+
121
+ int last_material_id_;
122
+ std::string material_file_name_;
123
+
124
+ std::string input_file_name_;
125
+
126
+ std::unordered_map<std::string, int> material_name_to_id_;
127
+ std::unordered_map<std::string, int> obj_name_to_id_;
128
+
129
+ bool use_metadata_;
130
+
131
+ // Polygon preservation flags.
132
+ bool preserve_polygons_;
133
+ bool has_polygons_;
134
+
135
+ std::vector<std::string> *mesh_files_;
136
+
137
+ DecoderBuffer buffer_;
138
+
139
+ // Data structure that stores the decoded data. |out_point_cloud_| must be
140
+ // always set but |out_mesh_| is optional.
141
+ Mesh *out_mesh_;
142
+ PointCloud *out_point_cloud_;
143
+ };
144
+
145
+ } // namespace draco
146
+
147
+ #endif // DRACO_IO_OBJ_DECODER_H_
@@ -0,0 +1,107 @@
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_OBJ_ENCODER_H_
16
+ #define DRACO_IO_OBJ_ENCODER_H_
17
+
18
+ #include <unordered_map>
19
+
20
+ #include "draco/core/encoder_buffer.h"
21
+ #include "draco/mesh/corner_table.h"
22
+ #include "draco/mesh/mesh.h"
23
+
24
+ namespace draco {
25
+
26
+ // Class for encoding input draco::Mesh or draco::PointCloud into the Wavefront
27
+ // OBJ format.
28
+ class ObjEncoder {
29
+ public:
30
+ ObjEncoder();
31
+
32
+ // Encodes the mesh or a point cloud and saves it into a file.
33
+ // Returns false when either the encoding failed or when the file couldn't be
34
+ // opened.
35
+ bool EncodeToFile(const PointCloud &pc, const std::string &file_name);
36
+ bool EncodeToFile(const Mesh &mesh, const std::string &file_name);
37
+
38
+ // Encodes the mesh or the point cloud into a buffer.
39
+ bool EncodeToBuffer(const PointCloud &pc, EncoderBuffer *out_buffer);
40
+ bool EncodeToBuffer(const Mesh &mesh, EncoderBuffer *out_buffer);
41
+
42
+ protected:
43
+ bool EncodeInternal();
44
+ EncoderBuffer *buffer() const { return out_buffer_; }
45
+ bool ExitAndCleanup(bool return_value);
46
+
47
+ private:
48
+ typedef AttributeValueIndex PositionIndex;
49
+ typedef std::map<PositionIndex, PointIndex> PolygonEdges;
50
+ bool GetAddedEdges();
51
+ bool GetSubObjects();
52
+ bool EncodeMaterialFileName();
53
+ bool EncodePositions();
54
+ bool EncodeTextureCoordinates();
55
+ bool EncodeNormals();
56
+ bool EncodeFaces();
57
+ bool EncodePolygonalFaces();
58
+ bool EncodeFaceAttributes(FaceIndex face_id);
59
+ bool EncodeSubObject(FaceIndex face_id);
60
+ bool EncodeMaterial(FaceIndex face_id);
61
+ bool EncodeFaceCorner(FaceIndex face_id, int local_corner_id);
62
+ bool EncodeFaceCorner(PointIndex vert_index);
63
+
64
+ void EncodeFloat(float val);
65
+ void EncodeFloatList(float *vals, int num_vals);
66
+ void EncodeInt(int32_t val);
67
+ bool IsNewEdge(const CornerTable &ct, CornerIndex ci) const;
68
+ void FindOriginalFaceEdges(FaceIndex face_index,
69
+ const CornerTable &corner_table,
70
+ std::vector<bool> *triangle_visited,
71
+ PolygonEdges *polygon_edges);
72
+
73
+ // Various attributes used by the encoder. If an attribute is not used, it is
74
+ // set to nullptr.
75
+ const PointAttribute *pos_att_;
76
+ const PointAttribute *tex_coord_att_;
77
+ const PointAttribute *normal_att_;
78
+ const PointAttribute *material_att_;
79
+ const PointAttribute *sub_obj_att_;
80
+
81
+ // Stores per-corner triangulation information for polygon reconstruction.
82
+ const PointAttribute *added_edges_att_;
83
+
84
+ // Buffer used for encoding float/int numbers.
85
+ char num_buffer_[20];
86
+
87
+ EncoderBuffer *out_buffer_;
88
+
89
+ const PointCloud *in_point_cloud_;
90
+ const Mesh *in_mesh_;
91
+
92
+ // Store sub object name for each value.
93
+ std::unordered_map<int, std::string> sub_obj_id_to_name_;
94
+ // Current sub object id of faces.
95
+ int current_sub_obj_id_;
96
+
97
+ // Store material name for each value in material attribute.
98
+ std::unordered_map<int, std::string> material_id_to_name_;
99
+ // Current material id of faces.
100
+ int current_material_id_;
101
+
102
+ std::string file_name_;
103
+ };
104
+
105
+ } // namespace draco
106
+
107
+ #endif // DRACO_IO_OBJ_ENCODER_H_
@@ -0,0 +1,66 @@
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_PARSER_UTILS_H_
16
+ #define DRACO_IO_PARSER_UTILS_H_
17
+
18
+ #include "draco/core/decoder_buffer.h"
19
+
20
+ namespace draco {
21
+ namespace parser {
22
+
23
+ // Skips to first character not included in |skip_chars|.
24
+ void SkipCharacters(DecoderBuffer *buffer, const char *skip_chars);
25
+
26
+ // Skips any whitespace until a regular character is reached.
27
+ void SkipWhitespace(DecoderBuffer *buffer);
28
+
29
+ // Returns true if the next character is a whitespace.
30
+ // |end_reached| is set to true when the end of the stream is reached.
31
+ bool PeekWhitespace(DecoderBuffer *buffer, bool *end_reached);
32
+
33
+ // Skips all characters until the end of the line.
34
+ void SkipLine(DecoderBuffer *buffer);
35
+
36
+ // Parses signed floating point number or returns false on error.
37
+ bool ParseFloat(DecoderBuffer *buffer, float *value);
38
+
39
+ // Parses a signed integer (can be preceded by '-' or '+' characters.
40
+ bool ParseSignedInt(DecoderBuffer *buffer, int32_t *value);
41
+
42
+ // Parses an unsigned integer. It cannot be preceded by '-' or '+'
43
+ // characters.
44
+ bool ParseUnsignedInt(DecoderBuffer *buffer, uint32_t *value);
45
+
46
+ // Returns -1 if c == '-'.
47
+ // Returns +1 if c == '+'.
48
+ // Returns 0 otherwise.
49
+ int GetSignValue(char c);
50
+
51
+ // Parses a string until a whitespace or end of file is reached.
52
+ bool ParseString(DecoderBuffer *buffer, std::string *out_string);
53
+
54
+ // Parses the entire line into the buffer (excluding the new line characters).
55
+ void ParseLine(DecoderBuffer *buffer, std::string *out_string);
56
+
57
+ // Parses line and stores into a new decoder buffer.
58
+ DecoderBuffer ParseLineIntoDecoderBuffer(DecoderBuffer *buffer);
59
+
60
+ // Returns a string with all characters converted to lower case.
61
+ std::string ToLower(const std::string &str);
62
+
63
+ } // namespace parser
64
+ } // namespace draco
65
+
66
+ #endif // DRACO_IO_PARSER_UTILS_H_
@@ -0,0 +1,69 @@
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_DECODER_H_
16
+ #define DRACO_IO_PLY_DECODER_H_
17
+
18
+ #include <string>
19
+
20
+ #include "draco/core/decoder_buffer.h"
21
+ #include "draco/core/status.h"
22
+ #include "draco/draco_features.h"
23
+ #include "draco/io/ply_reader.h"
24
+ #include "draco/mesh/mesh.h"
25
+
26
+ namespace draco {
27
+
28
+ // Decodes a PLY file into draco::Mesh (or draco::PointCloud if the
29
+ // connectivity data is not needed).
30
+ // TODO(b/34330853): The current implementation assumes that the input vertices
31
+ // are defined with x, y, z properties. The decoder also reads uint8 red, green,
32
+ // blue, alpha color information, float32 defined as nx, ny, nz properties, but
33
+ // all other attributes are ignored for now.
34
+ class PlyDecoder {
35
+ public:
36
+ PlyDecoder();
37
+
38
+ // Decodes an obj file stored in the input file.
39
+ Status DecodeFromFile(const std::string &file_name, Mesh *out_mesh);
40
+ Status DecodeFromFile(const std::string &file_name,
41
+ PointCloud *out_point_cloud);
42
+
43
+ Status DecodeFromBuffer(DecoderBuffer *buffer, Mesh *out_mesh);
44
+ Status DecodeFromBuffer(DecoderBuffer *buffer, PointCloud *out_point_cloud);
45
+
46
+ protected:
47
+ Status DecodeInternal();
48
+ DecoderBuffer *buffer() { return &buffer_; }
49
+
50
+ private:
51
+ Status DecodeFaceData(const PlyElement *face_element);
52
+ Status DecodeVertexData(const PlyElement *vertex_element);
53
+
54
+ template <typename DataTypeT>
55
+ bool ReadPropertiesToAttribute(
56
+ const std::vector<const PlyProperty *> &properties,
57
+ PointAttribute *attribute, int num_vertices);
58
+
59
+ DecoderBuffer buffer_;
60
+
61
+ // Data structure that stores the decoded data. |out_point_cloud_| must be
62
+ // always set but |out_mesh_| is optional.
63
+ Mesh *out_mesh_;
64
+ PointCloud *out_point_cloud_;
65
+ };
66
+
67
+ } // namespace draco
68
+
69
+ #endif // DRACO_IO_PLY_DECODER_H_
@@ -0,0 +1,54 @@
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_ENCODER_H_
16
+ #define DRACO_IO_PLY_ENCODER_H_
17
+
18
+ #include "draco/core/encoder_buffer.h"
19
+ #include "draco/mesh/mesh.h"
20
+
21
+ namespace draco {
22
+
23
+ // Class for encoding draco::Mesh or draco::PointCloud into the PLY file format.
24
+ class PlyEncoder {
25
+ public:
26
+ PlyEncoder();
27
+
28
+ // Encodes the mesh or a point cloud and saves it into a file.
29
+ // Returns false when either the encoding failed or when the file couldn't be
30
+ // opened.
31
+ bool EncodeToFile(const PointCloud &pc, const std::string &file_name);
32
+ bool EncodeToFile(const Mesh &mesh, const std::string &file_name);
33
+
34
+ // Encodes the mesh or the point cloud into a buffer.
35
+ bool EncodeToBuffer(const PointCloud &pc, EncoderBuffer *out_buffer);
36
+ bool EncodeToBuffer(const Mesh &mesh, EncoderBuffer *out_buffer);
37
+
38
+ protected:
39
+ bool EncodeInternal();
40
+ EncoderBuffer *buffer() const { return out_buffer_; }
41
+ bool ExitAndCleanup(bool return_value);
42
+
43
+ private:
44
+ const char *GetAttributeDataType(int attribute);
45
+
46
+ EncoderBuffer *out_buffer_;
47
+
48
+ const PointCloud *in_point_cloud_;
49
+ const Mesh *in_mesh_;
50
+ };
51
+
52
+ } // namespace draco
53
+
54
+ #endif // DRACO_IO_PLY_ENCODER_H_
@@ -0,0 +1,96 @@
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_READER_H_
16
+ #define DRACO_IO_PLY_PROPERTY_READER_H_
17
+
18
+ #include <functional>
19
+
20
+ #include "draco/io/ply_reader.h"
21
+
22
+ namespace draco {
23
+
24
+ // Class for reading PlyProperty with a given type, performing data conversion
25
+ // if necessary.
26
+ template <typename ReadTypeT>
27
+ class PlyPropertyReader {
28
+ public:
29
+ explicit PlyPropertyReader(const PlyProperty *property)
30
+ : property_(property) {
31
+ // Find the suitable function for converting values.
32
+ switch (property->data_type()) {
33
+ case DT_UINT8:
34
+ convert_value_func_ = [this](int val_id) {
35
+ return this->ConvertValue<uint8_t>(val_id);
36
+ };
37
+ break;
38
+ case DT_INT8:
39
+ convert_value_func_ = [this](int val_id) {
40
+ return this->ConvertValue<int8_t>(val_id);
41
+ };
42
+ break;
43
+ case DT_UINT16:
44
+ convert_value_func_ = [this](int val_id) {
45
+ return this->ConvertValue<uint16_t>(val_id);
46
+ };
47
+ break;
48
+ case DT_INT16:
49
+ convert_value_func_ = [this](int val_id) {
50
+ return this->ConvertValue<int16_t>(val_id);
51
+ };
52
+ break;
53
+ case DT_UINT32:
54
+ convert_value_func_ = [this](int val_id) {
55
+ return this->ConvertValue<uint32_t>(val_id);
56
+ };
57
+ break;
58
+ case DT_INT32:
59
+ convert_value_func_ = [this](int val_id) {
60
+ return this->ConvertValue<int32_t>(val_id);
61
+ };
62
+ break;
63
+ case DT_FLOAT32:
64
+ convert_value_func_ = [this](int val_id) {
65
+ return this->ConvertValue<float>(val_id);
66
+ };
67
+ break;
68
+ case DT_FLOAT64:
69
+ convert_value_func_ = [this](int val_id) {
70
+ return this->ConvertValue<double>(val_id);
71
+ };
72
+ break;
73
+ default:
74
+ break;
75
+ }
76
+ }
77
+
78
+ ReadTypeT ReadValue(int value_id) const {
79
+ return convert_value_func_(value_id);
80
+ }
81
+
82
+ private:
83
+ template <typename SourceTypeT>
84
+ ReadTypeT ConvertValue(int value_id) const {
85
+ const void *const address = property_->GetDataEntryAddress(value_id);
86
+ const SourceTypeT src_val = *reinterpret_cast<const SourceTypeT *>(address);
87
+ return static_cast<ReadTypeT>(src_val);
88
+ }
89
+
90
+ const PlyProperty *property_;
91
+ std::function<ReadTypeT(int)> convert_value_func_;
92
+ };
93
+
94
+ } // namespace draco
95
+
96
+ #endif // DRACO_IO_PLY_PROPERTY_READER_H_