Differential D9642 Diff 31357 extern/draco/draco/src/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h
Changeset View
Changeset View
Standalone View
Standalone View
extern/draco/draco/src/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h
- This file was moved from extern/draco/dracoenc/src/draco/compression/point_cloud/algorithms/float_points_tree_decoder.h.
| Show All 37 Lines | #ifndef DRACO_OLD_GCC | ||||
| template <class OutputIteratorT> | template <class OutputIteratorT> | ||||
| bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &&out); | bool DecodePointCloud(DecoderBuffer *buffer, OutputIteratorT &&out); | ||||
| #endif // DRACO_OLD_GCC | #endif // DRACO_OLD_GCC | ||||
| // Initializes a DecoderBuffer from |data|, and calls function above. | // Initializes a DecoderBuffer from |data|, and calls function above. | ||||
| template <class OutputIteratorT> | template <class OutputIteratorT> | ||||
| bool DecodePointCloud(const char *data, size_t data_size, | bool DecodePointCloud(const char *data, size_t data_size, | ||||
| OutputIteratorT out) { | OutputIteratorT out) { | ||||
| if (data == 0 || data_size <= 0) | if (data == 0 || data_size <= 0) { | ||||
| return false; | return false; | ||||
| } | |||||
| DecoderBuffer buffer; | DecoderBuffer buffer; | ||||
| buffer.Init(data, data_size); | buffer.Init(data, data_size); | ||||
| buffer.set_bitstream_version(kDracoPointCloudBitstreamVersion); | buffer.set_bitstream_version(kDracoPointCloudBitstreamVersion); | ||||
| return DecodePointCloud(&buffer, out); | return DecodePointCloud(&buffer, out); | ||||
| } | } | ||||
| uint32_t quantization_bits() const { return qinfo_.quantization_bits; } | uint32_t quantization_bits() const { return qinfo_.quantization_bits; } | ||||
| uint32_t compression_level() const { return compression_level_; } | uint32_t compression_level() const { return compression_level_; } | ||||
| float range() const { return qinfo_.range; } | float range() const { return qinfo_.range; } | ||||
| uint32_t num_points() const { return num_points_; } | uint32_t num_points() const { return num_points_; } | ||||
| uint32_t version() const { return version_; } | uint32_t version() const { return version_; } | ||||
| std::string identification_string() const { | std::string identification_string() const { | ||||
| if (method_ == KDTREE) { | if (method_ == KDTREE) { | ||||
| return "FloatPointsTreeDecoder: IntegerPointsKDTreeDecoder"; | return "FloatPointsTreeDecoder: IntegerPointsKDTreeDecoder"; | ||||
| } else { | } else { | ||||
| return "FloatPointsTreeDecoder: Unsupported Method"; | return "FloatPointsTreeDecoder: Unsupported Method"; | ||||
| } | } | ||||
| } | } | ||||
| void set_num_points_from_header(uint32_t num_points) { | |||||
| num_points_from_header_ = num_points; | |||||
| } | |||||
| private: | private: | ||||
| bool DecodePointCloudKdTreeInternal(DecoderBuffer *buffer, | bool DecodePointCloudKdTreeInternal(DecoderBuffer *buffer, | ||||
| std::vector<Point3ui> *qpoints); | std::vector<Point3ui> *qpoints); | ||||
| static const uint32_t version_ = 3; | static const uint32_t version_ = 3; | ||||
| QuantizationInfo qinfo_; | QuantizationInfo qinfo_; | ||||
| PointCloudCompressionMethod method_; | PointCloudCompressionMethod method_; | ||||
| uint32_t num_points_; | uint32_t num_points_; | ||||
| uint32_t compression_level_; | uint32_t compression_level_; | ||||
| // Member variable to check if the number of points from the file header | |||||
| // matches the number of points in the compression header. If | |||||
| // |num_points_from_header_| is 0, do not perform the check. Defaults to 0. | |||||
| uint32_t num_points_from_header_; | |||||
| }; | }; | ||||
| #ifndef DRACO_OLD_GCC | #ifndef DRACO_OLD_GCC | ||||
| // TODO(vytyaz): Reenable once USD migrates from GCC 4.8 to a higher version | // TODO(vytyaz): Reenable once USD migrates from GCC 4.8 to a higher version | ||||
| // that can disambiguate calls to overloaded methods taking rvalue reference. | // that can disambiguate calls to overloaded methods taking rvalue reference. | ||||
| template <class OutputIteratorT> | template <class OutputIteratorT> | ||||
| bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer, | bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer, | ||||
| OutputIteratorT &&out) { | OutputIteratorT &&out) { | ||||
| OutputIteratorT local = std::forward<OutputIteratorT>(out); | OutputIteratorT local = std::forward<OutputIteratorT>(out); | ||||
| return DecodePointCloud(buffer, local); | return DecodePointCloud(buffer, local); | ||||
| } | } | ||||
| #endif // DRACO_OLD_GCC | #endif // DRACO_OLD_GCC | ||||
| template <class OutputIteratorT> | template <class OutputIteratorT> | ||||
| bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer, | bool FloatPointsTreeDecoder::DecodePointCloud(DecoderBuffer *buffer, | ||||
| OutputIteratorT &out) { | OutputIteratorT &out) { | ||||
| std::vector<Point3ui> qpoints; | std::vector<Point3ui> qpoints; | ||||
| uint32_t decoded_version; | uint32_t decoded_version; | ||||
| if (!buffer->Decode(&decoded_version)) | if (!buffer->Decode(&decoded_version)) { | ||||
| return false; | return false; | ||||
| } | |||||
| if (decoded_version == 3) { | if (decoded_version == 3) { | ||||
| int8_t method_number; | int8_t method_number; | ||||
| if (!buffer->Decode(&method_number)) | if (!buffer->Decode(&method_number)) { | ||||
| return false; | return false; | ||||
| } | |||||
| method_ = static_cast<PointCloudCompressionMethod>(method_number); | method_ = static_cast<PointCloudCompressionMethod>(method_number); | ||||
| if (method_ == KDTREE) { | if (method_ == KDTREE) { | ||||
| if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) | if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) { | ||||
| return false; | return false; | ||||
| } | |||||
| } else { // Unsupported method. | } else { // Unsupported method. | ||||
| fprintf(stderr, "Method not supported. \n"); | fprintf(stderr, "Method not supported. \n"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| } else if (decoded_version == 2) { // Version 2 only uses KDTREE method. | } else if (decoded_version == 2) { // Version 2 only uses KDTREE method. | ||||
| if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) | if (!DecodePointCloudKdTreeInternal(buffer, &qpoints)) { | ||||
| return false; | return false; | ||||
| } | |||||
| } else { // Unsupported version. | } else { // Unsupported version. | ||||
| fprintf(stderr, "Version not supported. \n"); | fprintf(stderr, "Version not supported. \n"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| DequantizePoints3(qpoints.begin(), qpoints.end(), qinfo_, out); | DequantizePoints3(qpoints.begin(), qpoints.end(), qinfo_, out); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } // namespace draco | } // namespace draco | ||||
| #endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_ | #endif // DRACO_COMPRESSION_POINT_CLOUD_ALGORITHMS_FLOAT_POINTS_TREE_DECODER_H_ | ||||