GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
float_points_tree_decoder.h
Go to the documentation of this file.
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_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_
16#define DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_
17
18#include <memory>
19
25
26namespace draco {
27
28// Decodes a point cloud encoded by PointCloudTreeEncoder.
30 public:
32
33 // Decodes a point cloud from |buffer|.
34 template <class OutputIteratorT>
35 bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &out);
36
37#ifndef DRACO_OLD_GCC
38 template <class OutputIteratorT>
39 bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &&out);
40#endif // DRACO_OLD_GCC
41
42 // Initializes a DecoderBuffer from |data|, and calls function above.
43 template <class OutputIteratorT>
44 bool DecodePointCloud(const char *data, size_t data_size,
45 OutputIteratorT out) {
46 if (data == 0 || data_size <= 0) {
47 return false;
48 }
49
50 DecoderBuffer buffer;
51 buffer.Init(data, data_size);
52 buffer.set_bitstream_version(kDracoPointCloudBitstreamVersion);
53 return DecodePointCloud(&buffer, out);
54 }
55
56 uint32_t quantization_bits() const { return qinfo_.quantization_bits; }
57 uint32_t compression_level() const { return compression_level_; }
58 float range() const { return qinfo_.range; }
59 uint32_t num_points() const { return num_points_; }
60 uint32_t version() const { return version_; }
61 std::string identification_string() const {
62 if (method_ == KDTREE) {
63 return "FloatPointsTreeDecoder: IntegerPointsKDTreeDecoder";
64 } else {
65 return "FloatPointsTreeDecoder: Unsupported Method";
66 }
67 }
68
70 num_points_from_header_ = num_points;
71 }
72
73 private:
74 bool DecodePointCloudKdTreeInternal(DecoderBuffer *buffer,
75 std::vector<Point3ui> *qpoints);
76
77 static const uint32_t version_ = 3;
78 QuantizationInfo qinfo_;
80 uint32_t num_points_;
81 uint32_t compression_level_;
82
83 // Member variable to check if the number of points from the file header
84 // matches the number of points in the compression header. If
85 // |num_points_from_header_| is 0, do not perform the check. Defaults to 0.
86 uint32_t num_points_from_header_;
87};
88
89#ifndef DRACO_OLD_GCC
90// TODO(vytyaz): Reenable once USD migrates from GCC 4.8 to a higher version
91// that can disambiguate calls to overloaded methods taking rvalue reference.
92template <class OutputIteratorT>
94 OutputIteratorT &&out) {
95 OutputIteratorT local = std::forward<OutputIteratorT>(out);
96 return DecodePointCloud(buffer, local);
97}
98#endif // DRACO_OLD_GCC
99
100template <class OutputIteratorT>
102 OutputIteratorT &out) {
103 std::vector<Point3ui> qpoints;
104
105 uint32_t decoded_version;
106 if (!buffer->Decode(&decoded_version)) {
107 return false;
108 }
109
110 if (decoded_version == 3) {
111 int8_t method_number;
112 if (!buffer->Decode(&method_number)) {
113 return false;
114 }
115
116 method_ = static_cast<PointCloudCompressionMethod>(method_number);
117
118 if (method_ == KDTREE) {
119 if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) {
120 return false;
121 }
122 } else { // Unsupported method.
123 fprintf(stderr, "Method not supported. \n");
124 return false;
125 }
126 } else if (decoded_version == 2) { // Version 2 only uses KDTREE method.
127 if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) {
128 return false;
129 }
130 } else { // Unsupported version.
131 fprintf(stderr, "Version not supported. \n");
132 return false;
133 }
134
135 DequantizePoints3(qpoints.begin(), qpoints.end(), qinfo_, out);
136 return true;
137}
138
139} // namespace draco
140
141#endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_
Definition decoder_buffer.h:30
void Init(const char *data, size_t data_size)
Definition decoder_buffer.cc:29
bool Decode(T *out_val)
Definition decoder_buffer.h:68
void set_bitstream_version(uint16_t version)
Definition decoder_buffer.h:111
uint32_t compression_level() const
Definition float_points_tree_decoder.h:57
bool DecodePointCloud(const char *data, size_t data_size, OutputIteratorT out)
Definition float_points_tree_decoder.h:44
float range() const
Definition float_points_tree_decoder.h:58
std::string identification_string() const
Definition float_points_tree_decoder.h:61
uint32_t num_points() const
Definition float_points_tree_decoder.h:59
FloatPointsTreeDecoder()
Definition float_points_tree_decoder.cc:66
uint32_t version() const
Definition float_points_tree_decoder.h:60
bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &out)
Definition float_points_tree_decoder.h:101
uint32_t quantization_bits() const
Definition float_points_tree_decoder.h:56
void set_num_points_from_header(uint32_t num_points)
Definition float_points_tree_decoder.h:69
lazy data
Definition meshpage.php:1583
Definition attribute_octahedron_transform.cc:21
void DequantizePoints3(const QPointIterator &begin, const QPointIterator &end, const QuantizationInfo &info, OutputIterator &oit)
Definition quantize_points_3.h:62
PointCloudCompressionMethod
Definition point_cloud_compression_method.h:21
@ KDTREE
Definition point_cloud_compression_method.h:27
Definition quantize_points_3.h:26