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.
- bin/draco_decoder.exe +0 -0
- bin/draco_encoder.exe +0 -0
- dracox/__init__.py +252 -0
- dracox/dracox_ext.cp39-win_amd64.pyd +0 -0
- dracox-0.0.1.dist-info/METADATA +14 -0
- dracox-0.0.1.dist-info/RECORD +214 -0
- dracox-0.0.1.dist-info/WHEEL +5 -0
- include/draco/animation/keyframe_animation.h +107 -0
- include/draco/animation/keyframe_animation_decoder.h +34 -0
- include/draco/animation/keyframe_animation_encoder.h +39 -0
- include/draco/attributes/attribute_octahedron_transform.h +81 -0
- include/draco/attributes/attribute_quantization_transform.h +102 -0
- include/draco/attributes/attribute_transform.h +76 -0
- include/draco/attributes/attribute_transform_data.h +71 -0
- include/draco/attributes/attribute_transform_type.h +30 -0
- include/draco/attributes/geometry_attribute.h +541 -0
- include/draco/attributes/geometry_indices.h +54 -0
- include/draco/attributes/point_attribute.h +196 -0
- include/draco/compression/attributes/attributes_decoder.h +97 -0
- include/draco/compression/attributes/attributes_decoder_interface.h +62 -0
- include/draco/compression/attributes/attributes_encoder.h +154 -0
- include/draco/compression/attributes/kd_tree_attributes_decoder.h +50 -0
- include/draco/compression/attributes/kd_tree_attributes_encoder.h +51 -0
- include/draco/compression/attributes/kd_tree_attributes_shared.h +28 -0
- include/draco/compression/attributes/linear_sequencer.h +51 -0
- include/draco/compression/attributes/mesh_attribute_indices_encoding_data.h +58 -0
- include/draco/compression/attributes/normal_compression_utils.h +372 -0
- include/draco/compression/attributes/point_d_vector.h +288 -0
- include/draco/compression/attributes/points_sequencer.h +63 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h +236 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h +413 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h +34 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h +72 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h +46 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h +46 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h +176 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h +180 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h +117 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h +96 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h +128 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h +133 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h +111 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h +78 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h +372 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h +318 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h +143 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h +136 -0
- include/draco/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h +282 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h +194 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h +53 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h +65 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h +65 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h +69 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h +134 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h +55 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h +77 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_factory.h +85 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_interface.h +60 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h +118 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h +116 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h +102 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h +115 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h +105 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h +90 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h +88 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h +81 -0
- include/draco/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h +120 -0
- include/draco/compression/attributes/sequential_attribute_decoder.h +86 -0
- include/draco/compression/attributes/sequential_attribute_decoders_controller.h +61 -0
- include/draco/compression/attributes/sequential_attribute_encoder.h +134 -0
- include/draco/compression/attributes/sequential_attribute_encoders_controller.h +115 -0
- include/draco/compression/attributes/sequential_integer_attribute_decoder.h +76 -0
- include/draco/compression/attributes/sequential_integer_attribute_encoder.h +67 -0
- include/draco/compression/attributes/sequential_normal_attribute_decoder.h +83 -0
- include/draco/compression/attributes/sequential_normal_attribute_encoder.h +82 -0
- include/draco/compression/attributes/sequential_quantization_attribute_decoder.h +52 -0
- include/draco/compression/attributes/sequential_quantization_attribute_encoder.h +52 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_coding_shared.h +43 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_decoder.h +54 -0
- include/draco/compression/bit_coders/adaptive_rans_bit_encoder.h +61 -0
- include/draco/compression/bit_coders/direct_bit_decoder.h +89 -0
- include/draco/compression/bit_coders/direct_bit_encoder.h +89 -0
- include/draco/compression/bit_coders/folded_integer_bit_decoder.h +77 -0
- include/draco/compression/bit_coders/folded_integer_bit_encoder.h +82 -0
- include/draco/compression/bit_coders/rans_bit_decoder.h +55 -0
- include/draco/compression/bit_coders/rans_bit_encoder.h +57 -0
- include/draco/compression/bit_coders/symbol_bit_decoder.h +36 -0
- include/draco/compression/bit_coders/symbol_bit_encoder.h +36 -0
- include/draco/compression/config/compression_shared.h +155 -0
- include/draco/compression/config/decoder_options.h +34 -0
- include/draco/compression/config/draco_options.h +249 -0
- include/draco/compression/config/encoder_options.h +101 -0
- include/draco/compression/config/encoding_features.h +39 -0
- include/draco/compression/decode.h +80 -0
- include/draco/compression/draco_compression_options.h +141 -0
- include/draco/compression/encode.h +139 -0
- include/draco/compression/encode_base.h +131 -0
- include/draco/compression/entropy/ans.h +526 -0
- include/draco/compression/entropy/rans_symbol_coding.h +53 -0
- include/draco/compression/entropy/rans_symbol_decoder.h +171 -0
- include/draco/compression/entropy/rans_symbol_encoder.h +290 -0
- include/draco/compression/entropy/shannon_entropy.h +110 -0
- include/draco/compression/entropy/symbol_decoding.h +29 -0
- include/draco/compression/entropy/symbol_encoding.h +47 -0
- include/draco/compression/expert_encode.h +160 -0
- include/draco/compression/mesh/mesh_decoder.h +68 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder.h +54 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder_impl.h +228 -0
- include/draco/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h +47 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder.h +73 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder_impl.h +209 -0
- include/draco/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h +57 -0
- include/draco/compression/mesh/mesh_edgebreaker_shared.h +129 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_decoder.h +201 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_encoder.h +139 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h +134 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h +172 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h +219 -0
- include/draco/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h +226 -0
- include/draco/compression/mesh/mesh_encoder.h +84 -0
- include/draco/compression/mesh/mesh_sequential_decoder.h +39 -0
- include/draco/compression/mesh/mesh_sequential_encoder.h +56 -0
- include/draco/compression/mesh/traverser/depth_first_traverser.h +172 -0
- include/draco/compression/mesh/traverser/max_prediction_degree_traverser.h +226 -0
- include/draco/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h +76 -0
- include/draco/compression/mesh/traverser/mesh_traversal_sequencer.h +113 -0
- include/draco/compression/mesh/traverser/traverser_base.h +87 -0
- include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h +369 -0
- include/draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h +372 -0
- include/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h +141 -0
- include/draco/compression/point_cloud/algorithms/float_points_tree_encoder.h +126 -0
- include/draco/compression/point_cloud/algorithms/point_cloud_compression_method.h +34 -0
- include/draco/compression/point_cloud/algorithms/point_cloud_types.h +76 -0
- include/draco/compression/point_cloud/algorithms/quantize_points_3.h +84 -0
- include/draco/compression/point_cloud/algorithms/queuing_policy.h +75 -0
- include/draco/compression/point_cloud/point_cloud_decoder.h +118 -0
- include/draco/compression/point_cloud/point_cloud_encoder.h +158 -0
- include/draco/compression/point_cloud/point_cloud_kd_tree_decoder.h +31 -0
- include/draco/compression/point_cloud/point_cloud_kd_tree_encoder.h +45 -0
- include/draco/compression/point_cloud/point_cloud_sequential_decoder.h +33 -0
- include/draco/compression/point_cloud/point_cloud_sequential_encoder.h +43 -0
- include/draco/core/bit_utils.h +127 -0
- include/draco/core/bounding_box.h +77 -0
- include/draco/core/constants.h +6 -0
- include/draco/core/cycle_timer.h +51 -0
- include/draco/core/data_buffer.h +82 -0
- include/draco/core/decoder_buffer.h +216 -0
- include/draco/core/divide.h +42 -0
- include/draco/core/draco_index_type.h +184 -0
- include/draco/core/draco_index_type_vector.h +90 -0
- include/draco/core/draco_types.h +52 -0
- include/draco/core/draco_version.h +25 -0
- include/draco/core/encoder_buffer.h +152 -0
- include/draco/core/hash_utils.h +64 -0
- include/draco/core/macros.h +124 -0
- include/draco/core/math_utils.h +79 -0
- include/draco/core/options.h +151 -0
- include/draco/core/quantization_utils.h +82 -0
- include/draco/core/status.h +83 -0
- include/draco/core/status_or.h +81 -0
- include/draco/core/varint_decoding.h +81 -0
- include/draco/core/varint_encoding.h +61 -0
- include/draco/core/vector_d.h +355 -0
- include/draco/draco_features.h +25 -0
- include/draco/io/file_reader_factory.h +34 -0
- include/draco/io/file_reader_interface.h +32 -0
- include/draco/io/file_utils.h +86 -0
- include/draco/io/file_writer_factory.h +34 -0
- include/draco/io/file_writer_interface.h +26 -0
- include/draco/io/file_writer_utils.h +38 -0
- include/draco/io/mesh_io.h +107 -0
- include/draco/io/obj_decoder.h +147 -0
- include/draco/io/obj_encoder.h +107 -0
- include/draco/io/parser_utils.h +66 -0
- include/draco/io/ply_decoder.h +69 -0
- include/draco/io/ply_encoder.h +54 -0
- include/draco/io/ply_property_reader.h +96 -0
- include/draco/io/ply_property_writer.h +94 -0
- include/draco/io/ply_reader.h +155 -0
- include/draco/io/point_cloud_io.h +89 -0
- include/draco/io/stdio_file_reader.h +48 -0
- include/draco/io/stdio_file_writer.h +42 -0
- include/draco/io/stl_decoder.h +38 -0
- include/draco/io/stl_encoder.h +52 -0
- include/draco/mesh/corner_table.h +397 -0
- include/draco/mesh/corner_table_iterators.h +309 -0
- include/draco/mesh/mesh.h +378 -0
- include/draco/mesh/mesh_are_equivalent.h +71 -0
- include/draco/mesh/mesh_attribute_corner_table.h +202 -0
- include/draco/mesh/mesh_cleanup.h +61 -0
- include/draco/mesh/mesh_features.h +93 -0
- include/draco/mesh/mesh_indices.h +37 -0
- include/draco/mesh/mesh_misc_functions.h +105 -0
- include/draco/mesh/mesh_stripifier.h +258 -0
- include/draco/mesh/triangle_soup_mesh_builder.h +134 -0
- include/draco/mesh/valence_cache.h +142 -0
- include/draco/metadata/geometry_metadata.h +142 -0
- include/draco/metadata/metadata.h +209 -0
- include/draco/metadata/metadata_decoder.h +42 -0
- include/draco/metadata/metadata_encoder.h +41 -0
- include/draco/metadata/property_attribute.h +107 -0
- include/draco/metadata/property_table.h +222 -0
- include/draco/metadata/structural_metadata.h +78 -0
- include/draco/metadata/structural_metadata_schema.h +118 -0
- include/draco/point_cloud/point_cloud.h +289 -0
- include/draco/point_cloud/point_cloud_builder.h +101 -0
- lib/draco.lib +0 -0
- lib/pkgconfig/draco.pc +6 -0
- share/cmake/draco/draco-config-version.cmake +43 -0
- share/cmake/draco/draco-config.cmake +27 -0
- share/cmake/draco/draco-targets-release.cmake +19 -0
- share/cmake/draco/draco-targets.cmake +107 -0
|
@@ -0,0 +1,355 @@
|
|
|
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_CORE_VECTOR_D_H_
|
|
16
|
+
#define DRACO_CORE_VECTOR_D_H_
|
|
17
|
+
|
|
18
|
+
#include <inttypes.h>
|
|
19
|
+
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <array>
|
|
22
|
+
#include <cmath>
|
|
23
|
+
#include <limits>
|
|
24
|
+
|
|
25
|
+
#include "draco/core/macros.h"
|
|
26
|
+
|
|
27
|
+
namespace draco {
|
|
28
|
+
// D-dimensional vector class with basic operations.
|
|
29
|
+
template <class ScalarT, int dimension_t>
|
|
30
|
+
class VectorD {
|
|
31
|
+
public:
|
|
32
|
+
static constexpr int dimension = dimension_t;
|
|
33
|
+
|
|
34
|
+
typedef ScalarT Scalar;
|
|
35
|
+
typedef VectorD<Scalar, dimension_t> Self;
|
|
36
|
+
|
|
37
|
+
// TODO(b/199760123): Deprecate.
|
|
38
|
+
typedef ScalarT CoefficientType;
|
|
39
|
+
|
|
40
|
+
VectorD() {
|
|
41
|
+
for (int i = 0; i < dimension; ++i) {
|
|
42
|
+
(*this)[i] = Scalar(0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The following constructor does not compile in opt mode, which for now led
|
|
47
|
+
// to the constructors further down, which is not ideal.
|
|
48
|
+
// TODO(b/199760123): Fix constructor below and remove others.
|
|
49
|
+
// template <typename... Args>
|
|
50
|
+
// explicit VectorD(Args... args) : v_({args...}) {}
|
|
51
|
+
|
|
52
|
+
VectorD(const Scalar &c0, const Scalar &c1) : v_({{c0, c1}}) {
|
|
53
|
+
DRACO_DCHECK_EQ(dimension, 2);
|
|
54
|
+
v_[0] = c0;
|
|
55
|
+
v_[1] = c1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2)
|
|
59
|
+
: v_({{c0, c1, c2}}) {
|
|
60
|
+
DRACO_DCHECK_EQ(dimension, 3);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2,
|
|
64
|
+
const Scalar &c3)
|
|
65
|
+
: v_({{c0, c1, c2, c3}}) {
|
|
66
|
+
DRACO_DCHECK_EQ(dimension, 4);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2,
|
|
70
|
+
const Scalar &c3, const Scalar &c4)
|
|
71
|
+
: v_({{c0, c1, c2, c3, c4}}) {
|
|
72
|
+
DRACO_DCHECK_EQ(dimension, 5);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2,
|
|
76
|
+
const Scalar &c3, const Scalar &c4, const Scalar &c5)
|
|
77
|
+
: v_({{c0, c1, c2, c3, c4, c5}}) {
|
|
78
|
+
DRACO_DCHECK_EQ(dimension, 6);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
VectorD(const Scalar &c0, const Scalar &c1, const Scalar &c2,
|
|
82
|
+
const Scalar &c3, const Scalar &c4, const Scalar &c5,
|
|
83
|
+
const Scalar &c6)
|
|
84
|
+
: v_({{c0, c1, c2, c3, c4, c5, c6}}) {
|
|
85
|
+
DRACO_DCHECK_EQ(dimension, 7);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
VectorD(const Self &o) {
|
|
89
|
+
for (int i = 0; i < dimension; ++i) {
|
|
90
|
+
(*this)[i] = o[i];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Constructs the vector from another vector with a different data type or a
|
|
95
|
+
// different number of components. If the |src_vector| has more components
|
|
96
|
+
// than |this| vector, the excess components are truncated. If the
|
|
97
|
+
// |src_vector| has fewer components than |this| vector, the remaining
|
|
98
|
+
// components are padded with 0.
|
|
99
|
+
// Note that the constructor is intentionally explicit to avoid accidental
|
|
100
|
+
// conversions between different vector types.
|
|
101
|
+
template <class OtherScalarT, int other_dimension_t>
|
|
102
|
+
explicit VectorD(const VectorD<OtherScalarT, other_dimension_t> &src_vector) {
|
|
103
|
+
for (int i = 0; i < dimension; ++i) {
|
|
104
|
+
if (i < other_dimension_t) {
|
|
105
|
+
v_[i] = Scalar(src_vector[i]);
|
|
106
|
+
} else {
|
|
107
|
+
v_[i] = Scalar(0);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
Scalar &operator[](int i) { return v_[i]; }
|
|
113
|
+
const Scalar &operator[](int i) const { return v_[i]; }
|
|
114
|
+
// TODO(b/199760123): Remove.
|
|
115
|
+
// Similar to interface of Eigen library.
|
|
116
|
+
Scalar &operator()(int i) { return v_[i]; }
|
|
117
|
+
const Scalar &operator()(int i) const { return v_[i]; }
|
|
118
|
+
|
|
119
|
+
// Unary operators.
|
|
120
|
+
Self operator-() const {
|
|
121
|
+
Self ret;
|
|
122
|
+
for (int i = 0; i < dimension; ++i) {
|
|
123
|
+
ret[i] = -(*this)[i];
|
|
124
|
+
}
|
|
125
|
+
return ret;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Binary operators.
|
|
129
|
+
Self operator+(const Self &o) const {
|
|
130
|
+
Self ret;
|
|
131
|
+
for (int i = 0; i < dimension; ++i) {
|
|
132
|
+
ret[i] = (*this)[i] + o[i];
|
|
133
|
+
}
|
|
134
|
+
return ret;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
Self operator-(const Self &o) const {
|
|
138
|
+
Self ret;
|
|
139
|
+
for (int i = 0; i < dimension; ++i) {
|
|
140
|
+
ret[i] = (*this)[i] - o[i];
|
|
141
|
+
}
|
|
142
|
+
return ret;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Self operator*(const Self &o) const {
|
|
146
|
+
Self ret;
|
|
147
|
+
for (int i = 0; i < dimension; ++i) {
|
|
148
|
+
ret[i] = (*this)[i] * o[i];
|
|
149
|
+
}
|
|
150
|
+
return ret;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
Self &operator+=(const Self &o) {
|
|
154
|
+
for (int i = 0; i < dimension; ++i) {
|
|
155
|
+
(*this)[i] += o[i];
|
|
156
|
+
}
|
|
157
|
+
return *this;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Self &operator-=(const Self &o) {
|
|
161
|
+
for (int i = 0; i < dimension; ++i) {
|
|
162
|
+
(*this)[i] -= o[i];
|
|
163
|
+
}
|
|
164
|
+
return *this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
Self &operator*=(const Self &o) {
|
|
168
|
+
for (int i = 0; i < dimension; ++i) {
|
|
169
|
+
(*this)[i] *= o[i];
|
|
170
|
+
}
|
|
171
|
+
return *this;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Self operator*(const Scalar &o) const {
|
|
175
|
+
Self ret;
|
|
176
|
+
for (int i = 0; i < dimension; ++i) {
|
|
177
|
+
ret[i] = (*this)[i] * o;
|
|
178
|
+
}
|
|
179
|
+
return ret;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
Self operator/(const Scalar &o) const {
|
|
183
|
+
Self ret;
|
|
184
|
+
for (int i = 0; i < dimension; ++i) {
|
|
185
|
+
ret[i] = (*this)[i] / o;
|
|
186
|
+
}
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
Self operator+(const Scalar &o) const {
|
|
191
|
+
Self ret;
|
|
192
|
+
for (int i = 0; i < dimension; ++i) {
|
|
193
|
+
ret[i] = (*this)[i] + o;
|
|
194
|
+
}
|
|
195
|
+
return ret;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
Self operator-(const Scalar &o) const {
|
|
199
|
+
Self ret;
|
|
200
|
+
for (int i = 0; i < dimension; ++i) {
|
|
201
|
+
ret[i] = (*this)[i] - o;
|
|
202
|
+
}
|
|
203
|
+
return ret;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
bool operator==(const Self &o) const {
|
|
207
|
+
for (int i = 0; i < dimension; ++i) {
|
|
208
|
+
if ((*this)[i] != o[i]) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
bool operator!=(const Self &x) const { return !((*this) == x); }
|
|
216
|
+
|
|
217
|
+
bool operator<(const Self &x) const {
|
|
218
|
+
for (int i = 0; i < dimension - 1; ++i) {
|
|
219
|
+
if (v_[i] < x.v_[i]) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (v_[i] > x.v_[i]) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Only one check needed for the last dimension.
|
|
227
|
+
if (v_[dimension - 1] < x.v_[dimension - 1]) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Functions.
|
|
234
|
+
Scalar SquaredNorm() const { return this->Dot(*this); }
|
|
235
|
+
|
|
236
|
+
// Computes L1, the sum of absolute values of all entries.
|
|
237
|
+
Scalar AbsSum() const {
|
|
238
|
+
Scalar result(0);
|
|
239
|
+
for (int i = 0; i < dimension; ++i) {
|
|
240
|
+
Scalar next_value = std::abs(v_[i]);
|
|
241
|
+
if (result > std::numeric_limits<Scalar>::max() - next_value) {
|
|
242
|
+
// Return the max if adding would have caused an overflow.
|
|
243
|
+
return std::numeric_limits<Scalar>::max();
|
|
244
|
+
}
|
|
245
|
+
result += next_value;
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
Scalar Dot(const Self &o) const {
|
|
251
|
+
Scalar ret(0);
|
|
252
|
+
for (int i = 0; i < dimension; ++i) {
|
|
253
|
+
ret += (*this)[i] * o[i];
|
|
254
|
+
}
|
|
255
|
+
return ret;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void Normalize() {
|
|
259
|
+
const Scalar magnitude = std::sqrt(this->SquaredNorm());
|
|
260
|
+
if (magnitude == 0) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
for (int i = 0; i < dimension; ++i) {
|
|
264
|
+
(*this)[i] /= magnitude;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
Self GetNormalized() const {
|
|
269
|
+
Self ret(*this);
|
|
270
|
+
ret.Normalize();
|
|
271
|
+
return ret;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const Scalar &MaxCoeff() const {
|
|
275
|
+
return *std::max_element(v_.begin(), v_.end());
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const Scalar &MinCoeff() const {
|
|
279
|
+
return *std::min_element(v_.begin(), v_.end());
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
Scalar *data() { return &(v_[0]); }
|
|
283
|
+
const Scalar *data() const { return &(v_[0]); }
|
|
284
|
+
|
|
285
|
+
private:
|
|
286
|
+
std::array<Scalar, dimension> v_;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// Scalar multiplication from the other side too.
|
|
290
|
+
template <class ScalarT, int dimension_t>
|
|
291
|
+
VectorD<ScalarT, dimension_t> operator*(
|
|
292
|
+
const ScalarT &o, const VectorD<ScalarT, dimension_t> &v) {
|
|
293
|
+
return v * o;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Calculates the squared distance between two points.
|
|
297
|
+
template <class ScalarT, int dimension_t>
|
|
298
|
+
ScalarT SquaredDistance(const VectorD<ScalarT, dimension_t> &v1,
|
|
299
|
+
const VectorD<ScalarT, dimension_t> &v2) {
|
|
300
|
+
ScalarT difference;
|
|
301
|
+
ScalarT squared_distance = 0;
|
|
302
|
+
// Check each index separately so difference is never negative and underflow
|
|
303
|
+
// is avoided for unsigned types.
|
|
304
|
+
for (int i = 0; i < dimension_t; ++i) {
|
|
305
|
+
if (v1[i] >= v2[i]) {
|
|
306
|
+
difference = v1[i] - v2[i];
|
|
307
|
+
} else {
|
|
308
|
+
difference = v2[i] - v1[i];
|
|
309
|
+
}
|
|
310
|
+
squared_distance += (difference * difference);
|
|
311
|
+
}
|
|
312
|
+
return squared_distance;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Global function computing the cross product of two 3D vectors.
|
|
316
|
+
template <class ScalarT>
|
|
317
|
+
VectorD<ScalarT, 3> CrossProduct(const VectorD<ScalarT, 3> &u,
|
|
318
|
+
const VectorD<ScalarT, 3> &v) {
|
|
319
|
+
// Preventing accidental use with uint32_t and the like.
|
|
320
|
+
static_assert(std::is_signed<ScalarT>::value,
|
|
321
|
+
"ScalarT must be a signed type. ");
|
|
322
|
+
VectorD<ScalarT, 3> r;
|
|
323
|
+
r[0] = (u[1] * v[2]) - (u[2] * v[1]);
|
|
324
|
+
r[1] = (u[2] * v[0]) - (u[0] * v[2]);
|
|
325
|
+
r[2] = (u[0] * v[1]) - (u[1] * v[0]);
|
|
326
|
+
return r;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
template <class ScalarT, int dimension_t>
|
|
330
|
+
inline std::ostream &operator<<(
|
|
331
|
+
std::ostream &out, const draco::VectorD<ScalarT, dimension_t> &vec) {
|
|
332
|
+
for (int i = 0; i < dimension_t - 1; ++i) {
|
|
333
|
+
out << vec[i] << " ";
|
|
334
|
+
}
|
|
335
|
+
out << vec[dimension_t - 1];
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
typedef VectorD<float, 2> Vector2f;
|
|
340
|
+
typedef VectorD<float, 3> Vector3f;
|
|
341
|
+
typedef VectorD<float, 4> Vector4f;
|
|
342
|
+
typedef VectorD<float, 5> Vector5f;
|
|
343
|
+
typedef VectorD<float, 6> Vector6f;
|
|
344
|
+
typedef VectorD<float, 7> Vector7f;
|
|
345
|
+
|
|
346
|
+
typedef VectorD<uint32_t, 2> Vector2ui;
|
|
347
|
+
typedef VectorD<uint32_t, 3> Vector3ui;
|
|
348
|
+
typedef VectorD<uint32_t, 4> Vector4ui;
|
|
349
|
+
typedef VectorD<uint32_t, 5> Vector5ui;
|
|
350
|
+
typedef VectorD<uint32_t, 6> Vector6ui;
|
|
351
|
+
typedef VectorD<uint32_t, 7> Vector7ui;
|
|
352
|
+
|
|
353
|
+
} // namespace draco
|
|
354
|
+
|
|
355
|
+
#endif // DRACO_CORE_VECTOR_D_H_
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// GENERATED FILE -- DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
#ifndef DRACO_FEATURES_H_
|
|
4
|
+
#define DRACO_FEATURES_H_
|
|
5
|
+
|
|
6
|
+
#define DRACO_POINT_CLOUD_COMPRESSION_SUPPORTED
|
|
7
|
+
#define DRACO_MESH_COMPRESSION_SUPPORTED
|
|
8
|
+
#define DRACO_NORMAL_ENCODING_SUPPORTED
|
|
9
|
+
#define DRACO_STANDARD_EDGEBREAKER_SUPPORTED
|
|
10
|
+
#define DRACO_PREDICTIVE_EDGEBREAKER_SUPPORTED
|
|
11
|
+
#define DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED
|
|
12
|
+
#define DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED
|
|
13
|
+
#define DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED
|
|
14
|
+
// Enable DRACO_DEBUG_COMPILER_WARNINGS at CMake generation
|
|
15
|
+
// time to remove these pragmas.
|
|
16
|
+
#pragma warning(disable:4018)
|
|
17
|
+
#pragma warning(disable:4146)
|
|
18
|
+
#pragma warning(disable:4244)
|
|
19
|
+
#pragma warning(disable:4267)
|
|
20
|
+
#pragma warning(disable:4305)
|
|
21
|
+
#pragma warning(disable:4661)
|
|
22
|
+
#pragma warning(disable:4800)
|
|
23
|
+
#pragma warning(disable:4804)
|
|
24
|
+
|
|
25
|
+
#endif // DRACO_FEATURES_H_
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#ifndef DRACO_IO_FILE_READER_FACTORY_H_
|
|
2
|
+
#define DRACO_IO_FILE_READER_FACTORY_H_
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "draco/io/file_reader_interface.h"
|
|
8
|
+
|
|
9
|
+
namespace draco {
|
|
10
|
+
|
|
11
|
+
class FileReaderFactory {
|
|
12
|
+
public:
|
|
13
|
+
using OpenFunction =
|
|
14
|
+
std::unique_ptr<FileReaderInterface> (*)(const std::string &file_name);
|
|
15
|
+
|
|
16
|
+
FileReaderFactory() = delete;
|
|
17
|
+
FileReaderFactory(const FileReaderFactory &) = delete;
|
|
18
|
+
FileReaderFactory &operator=(const FileReaderFactory &) = delete;
|
|
19
|
+
~FileReaderFactory() = default;
|
|
20
|
+
|
|
21
|
+
// Registers the OpenFunction for a FileReaderInterface and returns true when
|
|
22
|
+
// registration succeeds.
|
|
23
|
+
static bool RegisterReader(OpenFunction open_function);
|
|
24
|
+
|
|
25
|
+
// Passes |file_name| to each OpenFunction until one succeeds. Returns nullptr
|
|
26
|
+
// when no reader is found for |file_name|. Otherwise a FileReaderInterface is
|
|
27
|
+
// returned.
|
|
28
|
+
static std::unique_ptr<FileReaderInterface> OpenReader(
|
|
29
|
+
const std::string &file_name);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace draco
|
|
33
|
+
|
|
34
|
+
#endif // DRACO_IO_FILE_READER_FACTORY_H_
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#ifndef DRACO_IO_FILE_READER_INTERFACE_H_
|
|
2
|
+
#define DRACO_IO_FILE_READER_INTERFACE_H_
|
|
3
|
+
|
|
4
|
+
#include <cstddef>
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
namespace draco {
|
|
9
|
+
|
|
10
|
+
class FileReaderInterface {
|
|
11
|
+
public:
|
|
12
|
+
FileReaderInterface() = default;
|
|
13
|
+
FileReaderInterface(const FileReaderInterface &) = delete;
|
|
14
|
+
FileReaderInterface &operator=(const FileReaderInterface &) = delete;
|
|
15
|
+
|
|
16
|
+
FileReaderInterface(FileReaderInterface &&) = default;
|
|
17
|
+
FileReaderInterface &operator=(FileReaderInterface &&) = default;
|
|
18
|
+
|
|
19
|
+
// Closes the file.
|
|
20
|
+
virtual ~FileReaderInterface() = default;
|
|
21
|
+
|
|
22
|
+
// Reads the entire contents of the input file into |buffer| and returns true.
|
|
23
|
+
virtual bool ReadFileToBuffer(std::vector<char> *buffer) = 0;
|
|
24
|
+
virtual bool ReadFileToBuffer(std::vector<uint8_t> *buffer) = 0;
|
|
25
|
+
|
|
26
|
+
// Returns the size of the file.
|
|
27
|
+
virtual size_t GetFileSize() = 0;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace draco
|
|
31
|
+
|
|
32
|
+
#endif // DRACO_IO_FILE_READER_INTERFACE_H_
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright 2018 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_FILE_UTILS_H_
|
|
16
|
+
#define DRACO_IO_FILE_UTILS_H_
|
|
17
|
+
|
|
18
|
+
#include <cstdint>
|
|
19
|
+
#include <string>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
namespace draco {
|
|
23
|
+
|
|
24
|
+
// Splits full path to a file into a folder path + file name.
|
|
25
|
+
// |out_folder_path| will contain the path to the folder containing the file
|
|
26
|
+
// excluding the final slash. If no folder is specified in the |full_path|, then
|
|
27
|
+
// |out_folder_path| is set to "."
|
|
28
|
+
void SplitPath(const std::string &full_path, std::string *out_folder_path,
|
|
29
|
+
std::string *out_file_name);
|
|
30
|
+
|
|
31
|
+
// Replaces file extension in |in_file_name| with |new_extension|.
|
|
32
|
+
// If |in_file_name| does not have any extension, the extension is appended.
|
|
33
|
+
std::string ReplaceFileExtension(const std::string &in_file_name,
|
|
34
|
+
const std::string &new_extension);
|
|
35
|
+
|
|
36
|
+
// Returns the file extension in lowercase if present, else "". Extension is
|
|
37
|
+
// defined as the string after the last '.' character. If the file starts with
|
|
38
|
+
// '.' (e.g. Linux hidden files), the first delimiter is ignored.
|
|
39
|
+
std::string LowercaseFileExtension(const std::string &filename);
|
|
40
|
+
|
|
41
|
+
// Returns the mime type extension in lowercase if present, else "". Extension
|
|
42
|
+
// is defined as the string after the last '/ character.
|
|
43
|
+
std::string LowercaseMimeTypeExtension(const std::string &mime_type);
|
|
44
|
+
|
|
45
|
+
// Returns the file name without extension.
|
|
46
|
+
std::string RemoveFileExtension(const std::string &filename);
|
|
47
|
+
|
|
48
|
+
// Given a path of the input file |input_file_relative_path| relative to the
|
|
49
|
+
// parent directory of |sibling_file_full_path|, this function returns full path
|
|
50
|
+
// to the input file. If |sibling_file_full_path| has no directory, the relative
|
|
51
|
+
// path itself |input_file_relative_path| is returned. A common use case is for
|
|
52
|
+
// the |input_file_relative_path| to be just a file name. See usage examples in
|
|
53
|
+
// the unit test.
|
|
54
|
+
std::string GetFullPath(const std::string &input_file_relative_path,
|
|
55
|
+
const std::string &sibling_file_full_path);
|
|
56
|
+
|
|
57
|
+
// Convenience methods. Uses draco::FileReaderFactory internally. Reads contents
|
|
58
|
+
// of file referenced by |file_name| into |buffer| and returns true upon
|
|
59
|
+
// success.
|
|
60
|
+
bool ReadFileToBuffer(const std::string &file_name, std::vector<char> *buffer);
|
|
61
|
+
bool ReadFileToBuffer(const std::string &file_name,
|
|
62
|
+
std::vector<uint8_t> *buffer);
|
|
63
|
+
|
|
64
|
+
// Convenience method for reading a file into a std::string. Reads contents
|
|
65
|
+
// of file referenced by |file_name| into |contents| and returns true upon
|
|
66
|
+
// success.
|
|
67
|
+
bool ReadFileToString(const std::string &file_name, std::string *contents);
|
|
68
|
+
|
|
69
|
+
// Convenience method. Uses draco::FileWriterFactory internally. Writes contents
|
|
70
|
+
// of |buffer| to file referred to by |file_name|. File is overwritten if it
|
|
71
|
+
// exists. Returns true after successful write.
|
|
72
|
+
bool WriteBufferToFile(const char *buffer, size_t buffer_size,
|
|
73
|
+
const std::string &file_name);
|
|
74
|
+
bool WriteBufferToFile(const unsigned char *buffer, size_t buffer_size,
|
|
75
|
+
const std::string &file_name);
|
|
76
|
+
bool WriteBufferToFile(const void *buffer, size_t buffer_size,
|
|
77
|
+
const std::string &file_name);
|
|
78
|
+
|
|
79
|
+
// Convenience method. Uses draco::FileReaderFactory internally. Returns size of
|
|
80
|
+
// file referenced by |file_name|. Returns 0 when referenced file is empty or
|
|
81
|
+
// does not exist.
|
|
82
|
+
size_t GetFileSize(const std::string &file_name);
|
|
83
|
+
|
|
84
|
+
} // namespace draco
|
|
85
|
+
|
|
86
|
+
#endif // DRACO_IO_FILE_UTILS_H_
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#ifndef DRACO_IO_FILE_WRITER_FACTORY_H_
|
|
2
|
+
#define DRACO_IO_FILE_WRITER_FACTORY_H_
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include "draco/io/file_writer_interface.h"
|
|
8
|
+
|
|
9
|
+
namespace draco {
|
|
10
|
+
|
|
11
|
+
class FileWriterFactory {
|
|
12
|
+
public:
|
|
13
|
+
using OpenFunction =
|
|
14
|
+
std::unique_ptr<FileWriterInterface> (*)(const std::string &file_name);
|
|
15
|
+
|
|
16
|
+
FileWriterFactory() = delete;
|
|
17
|
+
FileWriterFactory(const FileWriterFactory &) = delete;
|
|
18
|
+
FileWriterFactory &operator=(const FileWriterFactory &) = delete;
|
|
19
|
+
~FileWriterFactory() = default;
|
|
20
|
+
|
|
21
|
+
// Registers the OpenFunction for a FileWriterInterface and returns true when
|
|
22
|
+
// registration succeeds.
|
|
23
|
+
static bool RegisterWriter(OpenFunction open_function);
|
|
24
|
+
|
|
25
|
+
// Passes |file_name| to each OpenFunction until one succeeds. Returns nullptr
|
|
26
|
+
// when no writer is found for |file_name|. Otherwise a FileWriterInterface is
|
|
27
|
+
// returned.
|
|
28
|
+
static std::unique_ptr<FileWriterInterface> OpenWriter(
|
|
29
|
+
const std::string &file_name);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace draco
|
|
33
|
+
|
|
34
|
+
#endif // DRACO_IO_FILE_WRITER_FACTORY_H_
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef DRACO_IO_FILE_WRITER_INTERFACE_H_
|
|
2
|
+
#define DRACO_IO_FILE_WRITER_INTERFACE_H_
|
|
3
|
+
|
|
4
|
+
#include <cstddef>
|
|
5
|
+
|
|
6
|
+
namespace draco {
|
|
7
|
+
|
|
8
|
+
class FileWriterInterface {
|
|
9
|
+
public:
|
|
10
|
+
FileWriterInterface() = default;
|
|
11
|
+
FileWriterInterface(const FileWriterInterface &) = delete;
|
|
12
|
+
FileWriterInterface &operator=(const FileWriterInterface &) = delete;
|
|
13
|
+
|
|
14
|
+
FileWriterInterface(FileWriterInterface &&) = default;
|
|
15
|
+
FileWriterInterface &operator=(FileWriterInterface &&) = default;
|
|
16
|
+
|
|
17
|
+
// Closes the file.
|
|
18
|
+
virtual ~FileWriterInterface() = default;
|
|
19
|
+
|
|
20
|
+
// Writes |size| bytes from |buffer| to file.
|
|
21
|
+
virtual bool Write(const char *buffer, size_t size) = 0;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} // namespace draco
|
|
25
|
+
|
|
26
|
+
#endif // DRACO_IO_FILE_WRITER_INTERFACE_H_
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright 2020 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_FILE_WRITER_UTILS_H_
|
|
16
|
+
#define DRACO_IO_FILE_WRITER_UTILS_H_
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace draco {
|
|
21
|
+
|
|
22
|
+
// Splits full path to a file into a folder path + file name.
|
|
23
|
+
// |out_folder_path| will contain the path to the folder containing the file
|
|
24
|
+
// excluding the final slash. If no folder is specified in the |full_path|, then
|
|
25
|
+
// |out_folder_path| is set to "."
|
|
26
|
+
void SplitPathPrivate(const std::string &full_path,
|
|
27
|
+
std::string *out_folder_path, std::string *out_file_name);
|
|
28
|
+
|
|
29
|
+
// Checks is |path| exists and if it is a directory.
|
|
30
|
+
bool DirectoryExists(const std::string &path);
|
|
31
|
+
|
|
32
|
+
// Checks if the path for file is valid. If not this function will try and
|
|
33
|
+
// create the path. Returns false on error.
|
|
34
|
+
bool CheckAndCreatePathForFile(const std::string &filename);
|
|
35
|
+
|
|
36
|
+
} // namespace draco
|
|
37
|
+
|
|
38
|
+
#endif // DRACO_IO_FILE_WRITER_UTILS_H_
|