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,61 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_MESH_MESH_CLEANUP_H_
|
|
16
|
+
#define DRACO_MESH_MESH_CLEANUP_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/core/status.h"
|
|
19
|
+
#include "draco/draco_features.h"
|
|
20
|
+
#include "draco/mesh/mesh.h"
|
|
21
|
+
|
|
22
|
+
namespace draco {
|
|
23
|
+
|
|
24
|
+
// Options used by the MeshCleanup class.
|
|
25
|
+
struct MeshCleanupOptions {
|
|
26
|
+
// If true, the cleanup tool removes any face where two or more vertices
|
|
27
|
+
// share the same position index.
|
|
28
|
+
bool remove_degenerated_faces = true;
|
|
29
|
+
|
|
30
|
+
// If true, the cleanup tool removes all duplicate faces. A pair of faces is
|
|
31
|
+
// duplicate if both faces share the same position indices on all vertices
|
|
32
|
+
// (that is, position values have to be duduplicated). Note that all
|
|
33
|
+
// non-position properties are currently ignored.
|
|
34
|
+
bool remove_duplicate_faces = true;
|
|
35
|
+
|
|
36
|
+
// If true, the cleanup tool removes any unused attribute value or unused
|
|
37
|
+
// point id. For example, it can be used to remove isolated vertices.
|
|
38
|
+
bool remove_unused_attributes = true;
|
|
39
|
+
|
|
40
|
+
// If true, the cleanup tool splits vertices along non-manifold edges and
|
|
41
|
+
// vertices. This ensures that the connectivity defined by position indices
|
|
42
|
+
// is manifold.
|
|
43
|
+
bool make_geometry_manifold = false;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Tool that can be used for removing bad or unused data from draco::Meshes.
|
|
47
|
+
class MeshCleanup {
|
|
48
|
+
public:
|
|
49
|
+
// Performs in-place cleanup of the input mesh according to the input options.
|
|
50
|
+
static Status Cleanup(Mesh *mesh, const MeshCleanupOptions &options);
|
|
51
|
+
|
|
52
|
+
private:
|
|
53
|
+
static void RemoveDegeneratedFaces(Mesh *mesh);
|
|
54
|
+
static void RemoveDuplicateFaces(Mesh *mesh);
|
|
55
|
+
static void RemoveUnusedAttributes(Mesh *mesh);
|
|
56
|
+
static Status MakeGeometryManifold(Mesh *mesh);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace draco
|
|
60
|
+
|
|
61
|
+
#endif // DRACO_MESH_MESH_CLEANUP_H_
|
|
@@ -0,0 +1,93 @@
|
|
|
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_MESH_MESH_FEATURES_H_
|
|
16
|
+
#define DRACO_MESH_MESH_FEATURES_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/draco_features.h"
|
|
19
|
+
|
|
20
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
21
|
+
#include <string>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
#include "draco/texture/texture_library.h"
|
|
25
|
+
#include "draco/texture/texture_map.h"
|
|
26
|
+
|
|
27
|
+
namespace draco {
|
|
28
|
+
|
|
29
|
+
// Describes a mesh feature ID set according to the EXT_mesh_features glTF
|
|
30
|
+
// extension. Feature IDs are either associated with geometry vertices or with
|
|
31
|
+
// texture pixels and stored in a geometry attribute or in texture channels,
|
|
32
|
+
// respectively. Optionally, the feature ID set may be associated with a
|
|
33
|
+
// property table defined in the EXT_structural_metadata glTF extension.
|
|
34
|
+
class MeshFeatures {
|
|
35
|
+
public:
|
|
36
|
+
// Creates an empty feature ID set that is associated neither with vertices,
|
|
37
|
+
// nor with texture pixels, nor with property tables.
|
|
38
|
+
MeshFeatures();
|
|
39
|
+
|
|
40
|
+
// Copies all data from |src| mesh feature ID set.
|
|
41
|
+
void Copy(const MeshFeatures &src);
|
|
42
|
+
|
|
43
|
+
// Label assigned to this feature ID set.
|
|
44
|
+
void SetLabel(const std::string &label);
|
|
45
|
+
const std::string &GetLabel() const;
|
|
46
|
+
|
|
47
|
+
// The number of unique features in this feature ID set.
|
|
48
|
+
void SetFeatureCount(int feature_count);
|
|
49
|
+
int GetFeatureCount() const;
|
|
50
|
+
|
|
51
|
+
// Non-negative null feature ID value indicating the absence of an associated
|
|
52
|
+
// feature. The value of -1 indicates that the null feature ID is not set.
|
|
53
|
+
void SetNullFeatureId(int null_feature_id);
|
|
54
|
+
int GetNullFeatureId() const;
|
|
55
|
+
|
|
56
|
+
// Index of the feature ID vertex attribute in draco::Mesh or -1 if the
|
|
57
|
+
// feature ID is not associated with vertices.
|
|
58
|
+
void SetAttributeIndex(int attribute_index);
|
|
59
|
+
int GetAttributeIndex() const;
|
|
60
|
+
|
|
61
|
+
// Feature ID texture map and texture channels containing feature IDs
|
|
62
|
+
// associated with texture pixels. Only used when |attribute_index_| is -1.
|
|
63
|
+
// The RGBA channels are numbered from 0 to 3. See the glTF extension
|
|
64
|
+
// documentation for reconstruction of feature ID from the channel values.
|
|
65
|
+
void SetTextureMap(const TextureMap &texture_map);
|
|
66
|
+
void SetTextureMap(Texture *texture, int tex_coord_index);
|
|
67
|
+
const TextureMap &GetTextureMap() const;
|
|
68
|
+
TextureMap &GetTextureMap();
|
|
69
|
+
void SetTextureChannels(const std::vector<int> &texture_channels);
|
|
70
|
+
const std::vector<int> &GetTextureChannels() const;
|
|
71
|
+
std::vector<int> &GetTextureChannels();
|
|
72
|
+
|
|
73
|
+
// Non-negative index of the property table this feature ID set is associated
|
|
74
|
+
// with. Property tables are defined in the EXT_structural_metadata glTF
|
|
75
|
+
// extension. The value of -1 indicates that this feature ID set is not
|
|
76
|
+
// associated with any property tables.
|
|
77
|
+
void SetPropertyTableIndex(int property_table_index);
|
|
78
|
+
int GetPropertyTableIndex() const;
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
std::string label_;
|
|
82
|
+
int feature_count_;
|
|
83
|
+
int null_feature_id_;
|
|
84
|
+
int attribute_index_;
|
|
85
|
+
TextureMap texture_map_;
|
|
86
|
+
std::vector<int> texture_channels_;
|
|
87
|
+
int property_table_index_;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
} // namespace draco
|
|
91
|
+
|
|
92
|
+
#endif // DRACO_TRANSCODER_SUPPORTED
|
|
93
|
+
#endif // DRACO_MESH_MESH_FEATURES_H_
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
16
|
+
#ifndef DRACO_MESH_MESH_INDICES_H_
|
|
17
|
+
#define DRACO_MESH_MESH_INDICES_H_
|
|
18
|
+
|
|
19
|
+
#include <inttypes.h>
|
|
20
|
+
|
|
21
|
+
#include <limits>
|
|
22
|
+
|
|
23
|
+
#include "draco/core/draco_index_type.h"
|
|
24
|
+
|
|
25
|
+
namespace draco {
|
|
26
|
+
|
|
27
|
+
// Index of a mesh feature ID set.
|
|
28
|
+
DEFINE_NEW_DRACO_INDEX_TYPE(uint32_t, MeshFeaturesIndex)
|
|
29
|
+
|
|
30
|
+
// Constants denoting invalid indices.
|
|
31
|
+
static constexpr MeshFeaturesIndex kInvalidMeshFeaturesIndex(
|
|
32
|
+
std::numeric_limits<uint32_t>::max());
|
|
33
|
+
|
|
34
|
+
} // namespace draco
|
|
35
|
+
|
|
36
|
+
#endif // DRACO_MESH_MESH_INDICES_H_
|
|
37
|
+
#endif // DRACO_TRANSCODER_SUPPORTED
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
// This file contains misc functions that are needed by several mesh related
|
|
16
|
+
// algorithms.
|
|
17
|
+
|
|
18
|
+
#ifndef DRACO_MESH_MESH_MISC_FUNCTIONS_H_
|
|
19
|
+
#define DRACO_MESH_MESH_MISC_FUNCTIONS_H_
|
|
20
|
+
|
|
21
|
+
#include <array>
|
|
22
|
+
#include <cmath>
|
|
23
|
+
#include <memory>
|
|
24
|
+
|
|
25
|
+
#include "draco/mesh/corner_table.h"
|
|
26
|
+
#include "draco/mesh/mesh.h"
|
|
27
|
+
|
|
28
|
+
// The file contains functions that use both Mesh and CornerTable as inputs.
|
|
29
|
+
namespace draco {
|
|
30
|
+
|
|
31
|
+
// Creates a CornerTable from the position attribute of |mesh|. Returns nullptr
|
|
32
|
+
// on error.
|
|
33
|
+
std::unique_ptr<CornerTable> CreateCornerTableFromPositionAttribute(
|
|
34
|
+
const Mesh *mesh);
|
|
35
|
+
|
|
36
|
+
// Creates a CornerTable from the first named attribute of |mesh| with a given
|
|
37
|
+
// type. Returns nullptr on error.
|
|
38
|
+
std::unique_ptr<CornerTable> CreateCornerTableFromAttribute(
|
|
39
|
+
const Mesh *mesh, GeometryAttribute::Type type);
|
|
40
|
+
|
|
41
|
+
// Creates a CornerTable from all attributes of |mesh|. Boundaries are
|
|
42
|
+
// automatically introduced on all attribute seams. Returns nullptr on error.
|
|
43
|
+
std::unique_ptr<CornerTable> CreateCornerTableFromAllAttributes(
|
|
44
|
+
const Mesh *mesh);
|
|
45
|
+
|
|
46
|
+
// Returns true when the given corner lies opposite to an attribute seam.
|
|
47
|
+
inline bool IsCornerOppositeToAttributeSeam(CornerIndex ci,
|
|
48
|
+
const PointAttribute &att,
|
|
49
|
+
const Mesh &mesh,
|
|
50
|
+
const CornerTable &ct) {
|
|
51
|
+
const CornerIndex opp_ci = ct.Opposite(ci);
|
|
52
|
+
if (opp_ci == kInvalidCornerIndex) {
|
|
53
|
+
return false; // No opposite corner == no attribute seam.
|
|
54
|
+
}
|
|
55
|
+
// Compare attribute value indices on both ends of the opposite edge.
|
|
56
|
+
CornerIndex c0 = ct.Next(ci);
|
|
57
|
+
CornerIndex c1 = ct.Previous(opp_ci);
|
|
58
|
+
if (att.mapped_index(mesh.CornerToPointId(c0)) !=
|
|
59
|
+
att.mapped_index(mesh.CornerToPointId(c1))) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
c0 = ct.Previous(ci);
|
|
63
|
+
c1 = ct.Next(opp_ci);
|
|
64
|
+
if (att.mapped_index(mesh.CornerToPointId(c0)) !=
|
|
65
|
+
att.mapped_index(mesh.CornerToPointId(c1))) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Interpolates an attribute value on a face using given barycentric
|
|
72
|
+
// coordinates. InterpolatedVectorT should be a VectorD that corresponds to the
|
|
73
|
+
// values stored in the attribute.
|
|
74
|
+
template <typename InterpolatedVectorT>
|
|
75
|
+
InterpolatedVectorT ComputeInterpolatedAttributeValueOnMeshFace(
|
|
76
|
+
const Mesh &mesh, const PointAttribute &attribute, FaceIndex fi,
|
|
77
|
+
const std::array<float, 3> &barycentric_coord) {
|
|
78
|
+
const Mesh::Face &face = mesh.face(fi);
|
|
79
|
+
// Get values for all three corners of the face.
|
|
80
|
+
InterpolatedVectorT val[3];
|
|
81
|
+
for (int c = 0; c < 3; ++c) {
|
|
82
|
+
attribute.GetMappedValue(face[c], &(val[c][0]));
|
|
83
|
+
}
|
|
84
|
+
if (val[1] == val[0] && val[2] == val[0]) {
|
|
85
|
+
// No need to interpolate anything if all values are the same.
|
|
86
|
+
return val[0];
|
|
87
|
+
}
|
|
88
|
+
// Return an interpolated value.
|
|
89
|
+
InterpolatedVectorT res;
|
|
90
|
+
for (int d = 0; d < InterpolatedVectorT::dimension; ++d) {
|
|
91
|
+
const float interpolated_component = barycentric_coord[0] * val[0][d] +
|
|
92
|
+
barycentric_coord[1] * val[1][d] +
|
|
93
|
+
barycentric_coord[2] * val[2][d];
|
|
94
|
+
if (std::is_integral<typename InterpolatedVectorT::Scalar>::value) {
|
|
95
|
+
res[d] = std::floor(interpolated_component + 0.5f);
|
|
96
|
+
} else {
|
|
97
|
+
res[d] = interpolated_component;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
} // namespace draco
|
|
104
|
+
|
|
105
|
+
#endif // DRACO_MESH_MESH_MISC_FUNCTIONS_H_
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// Copyright 2017 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_MESH_MESH_STRIPIFIER_H_
|
|
16
|
+
#define DRACO_MESH_MESH_STRIPIFIER_H_
|
|
17
|
+
|
|
18
|
+
#include "draco/mesh/mesh_misc_functions.h"
|
|
19
|
+
|
|
20
|
+
namespace draco {
|
|
21
|
+
|
|
22
|
+
// Class that generates triangle strips from a provided draco::Mesh data
|
|
23
|
+
// structure. The strips represent a more memory efficient storage of triangle
|
|
24
|
+
// connectivity that can be used directly on the GPU (see
|
|
25
|
+
// https://en.wikipedia.org/wiki/Triangle_strip ). In general, a mesh needs to
|
|
26
|
+
// be represented by several triangle strips and it has been proven that finding
|
|
27
|
+
// the optimal set of triangle strips is an NP-complete problem. The algorithm
|
|
28
|
+
// implemented by this class finds this set of triangle strips based on a greedy
|
|
29
|
+
// heuristic that always selects the longest available strip that covers the
|
|
30
|
+
// next unprocessed face. The longest strip is found by analyzing all strips
|
|
31
|
+
// that can cover the given face (three strips corresponding to three
|
|
32
|
+
// directions).
|
|
33
|
+
class MeshStripifier {
|
|
34
|
+
public:
|
|
35
|
+
MeshStripifier()
|
|
36
|
+
: mesh_(nullptr),
|
|
37
|
+
num_strips_(0),
|
|
38
|
+
num_encoded_faces_(0),
|
|
39
|
+
last_encoded_point_(kInvalidPointIndex) {}
|
|
40
|
+
|
|
41
|
+
// Generate triangle strips for a given mesh and output them to the output
|
|
42
|
+
// iterator |out_it|. In most cases |out_it| stores the values in a buffer
|
|
43
|
+
// that can be used directly on the GPU. Note that the algorithm can generate
|
|
44
|
+
// multiple strips to represent the whole mesh. In such cases multiple strips
|
|
45
|
+
// are separated using a so called primitive restart index that is specified
|
|
46
|
+
// by the |primitive_restart_index| (usually defined as the maximum allowed
|
|
47
|
+
// value for the given type).
|
|
48
|
+
// https://www.khronos.org/opengl/wiki/Vertex_Rendering#Primitive_Restart
|
|
49
|
+
template <typename OutputIteratorT, typename IndexTypeT>
|
|
50
|
+
bool GenerateTriangleStripsWithPrimitiveRestart(
|
|
51
|
+
const Mesh &mesh, IndexTypeT primitive_restart_index,
|
|
52
|
+
OutputIteratorT out_it);
|
|
53
|
+
|
|
54
|
+
// The same as above but disjoint triangle strips are separated by degenerate
|
|
55
|
+
// triangles instead of the primitive restart index. Degenerate triangles are
|
|
56
|
+
// zero area triangles that are automatically discarded by the GPU. Using
|
|
57
|
+
// degenerate triangles usually results in a slightly longer output indices
|
|
58
|
+
// array compared to the similar triangle strips that use primitive restart
|
|
59
|
+
// index. The advantage of this method is that it is supported by all hardware
|
|
60
|
+
// and all relevant APIs (including WebGL 1.0).
|
|
61
|
+
template <typename OutputIteratorT>
|
|
62
|
+
bool GenerateTriangleStripsWithDegenerateTriangles(const Mesh &mesh,
|
|
63
|
+
OutputIteratorT out_it);
|
|
64
|
+
|
|
65
|
+
// Returns the number of strips generated by the last call of the
|
|
66
|
+
// GenerateTriangleStrips() method.
|
|
67
|
+
int num_strips() const { return num_strips_; }
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
bool Prepare(const Mesh &mesh) {
|
|
71
|
+
mesh_ = &mesh;
|
|
72
|
+
num_strips_ = 0;
|
|
73
|
+
num_encoded_faces_ = 0;
|
|
74
|
+
corner_table_ = CreateCornerTableFromPositionAttribute(mesh_);
|
|
75
|
+
if (corner_table_ == nullptr) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Mark all faces as unvisited.
|
|
80
|
+
is_face_visited_.assign(mesh.num_faces(), false);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Returns local id of the longest strip that can be created from the given
|
|
85
|
+
// face |fi|.
|
|
86
|
+
int FindLongestStripFromFace(FaceIndex fi) {
|
|
87
|
+
// There are three possible strip directions that can contain the provided
|
|
88
|
+
// input face. We try all of them and select the direction that result in
|
|
89
|
+
// the longest strip.
|
|
90
|
+
const CornerIndex first_ci = corner_table_->FirstCorner(fi);
|
|
91
|
+
int longest_strip_id = -1;
|
|
92
|
+
int longest_strip_length = 0;
|
|
93
|
+
for (int i = 0; i < 3; ++i) {
|
|
94
|
+
GenerateStripsFromCorner(i, first_ci + i);
|
|
95
|
+
if (strip_faces_[i].size() > longest_strip_length) {
|
|
96
|
+
longest_strip_length = static_cast<int>(strip_faces_[i].size());
|
|
97
|
+
longest_strip_id = i;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return longest_strip_id;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Generates strip from the data stored in |strip_faces_| and
|
|
104
|
+
// |strip_start_start_corners_| and stores it to |out_it|.
|
|
105
|
+
template <typename OutputIteratorT>
|
|
106
|
+
void StoreStrip(int local_strip_id, OutputIteratorT out_it) {
|
|
107
|
+
++num_strips_;
|
|
108
|
+
|
|
109
|
+
const int num_strip_faces = strip_faces_[local_strip_id].size();
|
|
110
|
+
CornerIndex ci = strip_start_corners_[local_strip_id];
|
|
111
|
+
for (int i = 0; i < num_strip_faces; ++i) {
|
|
112
|
+
const FaceIndex fi = corner_table_->Face(ci);
|
|
113
|
+
is_face_visited_[fi] = true;
|
|
114
|
+
++num_encoded_faces_;
|
|
115
|
+
|
|
116
|
+
if (i == 0) {
|
|
117
|
+
// Add the start face (three indices).
|
|
118
|
+
*out_it++ = CornerToPointIndex(ci).value();
|
|
119
|
+
*out_it++ = CornerToPointIndex(corner_table_->Next(ci)).value();
|
|
120
|
+
last_encoded_point_ = CornerToPointIndex(corner_table_->Previous(ci));
|
|
121
|
+
*out_it++ = last_encoded_point_.value();
|
|
122
|
+
} else {
|
|
123
|
+
// Store the point on the newly reached corner.
|
|
124
|
+
last_encoded_point_ = CornerToPointIndex(ci);
|
|
125
|
+
*out_it++ = last_encoded_point_.value();
|
|
126
|
+
|
|
127
|
+
// Go to the correct source corner to proceed to the next face.
|
|
128
|
+
if (i & 1) {
|
|
129
|
+
ci = corner_table_->Previous(ci);
|
|
130
|
+
} else {
|
|
131
|
+
ci = corner_table_->Next(ci);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
ci = corner_table_->Opposite(ci);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
PointIndex CornerToPointIndex(CornerIndex ci) const {
|
|
139
|
+
return mesh_->CornerToPointId(ci);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Returns the opposite corner in case the opposite triangle does not lie
|
|
143
|
+
// across an attribute seam. Otherwise return kInvalidCornerIndex.
|
|
144
|
+
CornerIndex GetOppositeCorner(CornerIndex ci) const {
|
|
145
|
+
const CornerIndex oci = corner_table_->Opposite(ci);
|
|
146
|
+
if (oci < 0) {
|
|
147
|
+
return kInvalidCornerIndex;
|
|
148
|
+
}
|
|
149
|
+
// Ensure the point ids are same on both sides of the shared edge between
|
|
150
|
+
// the triangles.
|
|
151
|
+
if (CornerToPointIndex(corner_table_->Next(ci)) !=
|
|
152
|
+
CornerToPointIndex(corner_table_->Previous(oci))) {
|
|
153
|
+
return kInvalidCornerIndex;
|
|
154
|
+
}
|
|
155
|
+
if (CornerToPointIndex(corner_table_->Previous(ci)) !=
|
|
156
|
+
CornerToPointIndex(corner_table_->Next(oci))) {
|
|
157
|
+
return kInvalidCornerIndex;
|
|
158
|
+
}
|
|
159
|
+
return oci;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void GenerateStripsFromCorner(int local_strip_id, CornerIndex ci);
|
|
163
|
+
|
|
164
|
+
const Mesh *mesh_;
|
|
165
|
+
std::unique_ptr<CornerTable> corner_table_;
|
|
166
|
+
|
|
167
|
+
// Store strip faces for each of three possible directions from a given face.
|
|
168
|
+
std::vector<FaceIndex> strip_faces_[3];
|
|
169
|
+
// Start corner for each direction of the strip containing the processed face.
|
|
170
|
+
CornerIndex strip_start_corners_[3];
|
|
171
|
+
IndexTypeVector<FaceIndex, bool> is_face_visited_;
|
|
172
|
+
// The number of strips generated by this method.
|
|
173
|
+
int num_strips_;
|
|
174
|
+
// The number of encoded triangles.
|
|
175
|
+
int num_encoded_faces_;
|
|
176
|
+
// Last encoded point.
|
|
177
|
+
PointIndex last_encoded_point_;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
template <typename OutputIteratorT, typename IndexTypeT>
|
|
181
|
+
bool MeshStripifier::GenerateTriangleStripsWithPrimitiveRestart(
|
|
182
|
+
const Mesh &mesh, IndexTypeT primitive_restart_index,
|
|
183
|
+
OutputIteratorT out_it) {
|
|
184
|
+
if (!Prepare(mesh)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Go over all faces and generate strips from the first unvisited one.
|
|
189
|
+
for (FaceIndex fi(0); fi < mesh.num_faces(); ++fi) {
|
|
190
|
+
if (is_face_visited_[fi]) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const int longest_strip_id = FindLongestStripFromFace(fi);
|
|
195
|
+
|
|
196
|
+
// Separate triangle strips with the primitive restart index.
|
|
197
|
+
if (num_strips_ > 0) {
|
|
198
|
+
*out_it++ = primitive_restart_index;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
StoreStrip(longest_strip_id, out_it);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
template <typename OutputIteratorT>
|
|
208
|
+
bool MeshStripifier::GenerateTriangleStripsWithDegenerateTriangles(
|
|
209
|
+
const Mesh &mesh, OutputIteratorT out_it) {
|
|
210
|
+
if (!Prepare(mesh)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Go over all faces and generate strips from the first unvisited one.
|
|
215
|
+
for (FaceIndex fi(0); fi < mesh.num_faces(); ++fi) {
|
|
216
|
+
if (is_face_visited_[fi]) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const int longest_strip_id = FindLongestStripFromFace(fi);
|
|
221
|
+
|
|
222
|
+
// Separate triangle strips by degenerate triangles. There will be either
|
|
223
|
+
// three or four degenerate triangles inserted based on the number of
|
|
224
|
+
// triangles that are already encoded in the output strip (three degenerate
|
|
225
|
+
// triangles for even number of existing triangles, four degenerate
|
|
226
|
+
// triangles for odd number of triangles).
|
|
227
|
+
if (num_strips_ > 0) {
|
|
228
|
+
// Duplicate last encoded index (first degenerate face).
|
|
229
|
+
*out_it++ = last_encoded_point_.value();
|
|
230
|
+
|
|
231
|
+
// Connect it to the start point of the new triangle strip (second
|
|
232
|
+
// degenerate face).
|
|
233
|
+
const CornerIndex new_start_corner =
|
|
234
|
+
strip_start_corners_[longest_strip_id];
|
|
235
|
+
const PointIndex new_start_point = CornerToPointIndex(new_start_corner);
|
|
236
|
+
*out_it++ = new_start_point.value();
|
|
237
|
+
num_encoded_faces_ += 2;
|
|
238
|
+
// If we have previously encoded number of faces we need to duplicate the
|
|
239
|
+
// point one more time to preserve the correct orientation of the next
|
|
240
|
+
// strip.
|
|
241
|
+
if (num_encoded_faces_ & 1) {
|
|
242
|
+
*out_it++ = new_start_point.value();
|
|
243
|
+
num_encoded_faces_ += 1;
|
|
244
|
+
}
|
|
245
|
+
// The last degenerate face will be added implicitly in the StoreStrip()
|
|
246
|
+
// function below as the first point index is going to be encoded there
|
|
247
|
+
// again.
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
StoreStrip(longest_strip_id, out_it);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
} // namespace draco
|
|
257
|
+
|
|
258
|
+
#endif // DRACO_MESH_MESH_STRIPIFIER_H_
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright 2016 The Draco Authors.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
#ifndef DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_
|
|
16
|
+
#define DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_
|
|
17
|
+
|
|
18
|
+
#include <utility>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "draco/draco_features.h"
|
|
22
|
+
|
|
23
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
24
|
+
#include "draco/core/status.h"
|
|
25
|
+
#endif
|
|
26
|
+
#include "draco/mesh/mesh.h"
|
|
27
|
+
|
|
28
|
+
namespace draco {
|
|
29
|
+
|
|
30
|
+
// Class for building meshes directly from attribute values that can be
|
|
31
|
+
// specified for each face corner. All attributes are automatically
|
|
32
|
+
// deduplicated.
|
|
33
|
+
class TriangleSoupMeshBuilder {
|
|
34
|
+
public:
|
|
35
|
+
// Index type of the inserted element.
|
|
36
|
+
typedef FaceIndex ElementIndex;
|
|
37
|
+
|
|
38
|
+
// Starts mesh building for a given number of faces.
|
|
39
|
+
// TODO(ostava): Currently it's necessary to select the correct number of
|
|
40
|
+
// faces upfront. This should be generalized, but it will require us to
|
|
41
|
+
// rewrite our attribute resizing functions.
|
|
42
|
+
void Start(int num_faces);
|
|
43
|
+
|
|
44
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
45
|
+
// Sets mesh name.
|
|
46
|
+
void SetName(const std::string &name);
|
|
47
|
+
#endif // DRACO_TRANSCODER_SUPPORTED
|
|
48
|
+
|
|
49
|
+
// Adds an empty attribute to the mesh. Returns the new attribute's id.
|
|
50
|
+
int AddAttribute(GeometryAttribute::Type attribute_type,
|
|
51
|
+
int8_t num_components, DataType data_type);
|
|
52
|
+
int AddAttribute(GeometryAttribute::Type attribute_type,
|
|
53
|
+
int8_t num_components, DataType data_type, bool normalized);
|
|
54
|
+
|
|
55
|
+
// Sets values for a given attribute on all corners of a given face.
|
|
56
|
+
void SetAttributeValuesForFace(int att_id, FaceIndex face_id,
|
|
57
|
+
const void *corner_value_0,
|
|
58
|
+
const void *corner_value_1,
|
|
59
|
+
const void *corner_value_2);
|
|
60
|
+
|
|
61
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
62
|
+
// Converts input values of type T into internal representation used by
|
|
63
|
+
// |att_id|. Each input value needs to have |input_num_components| entries.
|
|
64
|
+
template <typename T>
|
|
65
|
+
Status ConvertAndSetAttributeValuesForFace(int att_id, FaceIndex face_id,
|
|
66
|
+
int input_num_components,
|
|
67
|
+
const T *corner_value_0,
|
|
68
|
+
const T *corner_value_1,
|
|
69
|
+
const T *corner_value_2);
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
// Sets value for a per-face attribute. If all faces of a given attribute are
|
|
73
|
+
// set with this method, the attribute will be marked as per-face, otherwise
|
|
74
|
+
// it will be marked as per-corner attribute.
|
|
75
|
+
void SetPerFaceAttributeValueForFace(int att_id, FaceIndex face_id,
|
|
76
|
+
const void *value);
|
|
77
|
+
|
|
78
|
+
// Add metadata.
|
|
79
|
+
void AddMetadata(std::unique_ptr<GeometryMetadata> metadata) {
|
|
80
|
+
mesh_->AddMetadata(std::move(metadata));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Sets the unique ID for an attribute created with AddAttribute().
|
|
84
|
+
void SetAttributeUniqueId(int att_id, uint32_t unique_id);
|
|
85
|
+
|
|
86
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
87
|
+
// Sets attribute name.
|
|
88
|
+
void SetAttributeName(int att_id, const std::string &name);
|
|
89
|
+
#endif // DRACO_TRANSCODER_SUPPORTED
|
|
90
|
+
|
|
91
|
+
// Add metadata for an attribute.
|
|
92
|
+
void AddAttributeMetadata(int32_t att_id,
|
|
93
|
+
std::unique_ptr<AttributeMetadata> metadata) {
|
|
94
|
+
mesh_->AddAttributeMetadata(att_id, std::move(metadata));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Finalizes the mesh or returns nullptr on error.
|
|
98
|
+
// Once this function is called, the builder becomes invalid and cannot be
|
|
99
|
+
// used until the method Start() is called again.
|
|
100
|
+
std::unique_ptr<Mesh> Finalize();
|
|
101
|
+
|
|
102
|
+
private:
|
|
103
|
+
std::vector<int8_t> attribute_element_types_;
|
|
104
|
+
|
|
105
|
+
std::unique_ptr<Mesh> mesh_;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
#ifdef DRACO_TRANSCODER_SUPPORTED
|
|
109
|
+
template <typename T>
|
|
110
|
+
Status TriangleSoupMeshBuilder::ConvertAndSetAttributeValuesForFace(
|
|
111
|
+
int att_id, FaceIndex face_id, int input_num_components,
|
|
112
|
+
const T *corner_value_0, const T *corner_value_1, const T *corner_value_2) {
|
|
113
|
+
const int start_index = 3 * face_id.value();
|
|
114
|
+
PointAttribute *const att = mesh_->attribute(att_id);
|
|
115
|
+
DRACO_RETURN_IF_ERROR(
|
|
116
|
+
att->ConvertAndSetAttributeValue(AttributeValueIndex(start_index + 0),
|
|
117
|
+
input_num_components, corner_value_0));
|
|
118
|
+
DRACO_RETURN_IF_ERROR(
|
|
119
|
+
att->ConvertAndSetAttributeValue(AttributeValueIndex(start_index + 1),
|
|
120
|
+
input_num_components, corner_value_1));
|
|
121
|
+
DRACO_RETURN_IF_ERROR(
|
|
122
|
+
att->ConvertAndSetAttributeValue(AttributeValueIndex(start_index + 2),
|
|
123
|
+
input_num_components, corner_value_2));
|
|
124
|
+
mesh_->SetFace(face_id,
|
|
125
|
+
{{PointIndex(start_index), PointIndex(start_index + 1),
|
|
126
|
+
PointIndex(start_index + 2)}});
|
|
127
|
+
attribute_element_types_[att_id] = MESH_CORNER_ATTRIBUTE;
|
|
128
|
+
return OkStatus();
|
|
129
|
+
}
|
|
130
|
+
#endif // DRACO_TRANSCODER_SUPPORTED
|
|
131
|
+
|
|
132
|
+
} // namespace draco
|
|
133
|
+
|
|
134
|
+
#endif // DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_
|