GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
attributes_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_ATTRIBUTES_ATTRIBUTES_DECODER_H_
16#define DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_H_
17
18#include <vector>
19
25
26namespace draco {
27
28// Base class for decoding one or more attributes that were encoded with a
29// matching AttributesEncoder. It is a basic implementation of
30// AttributesDecoderInterface that provides functionality that is shared between
31// all AttributesDecoders.
33 public:
35 virtual ~AttributesDecoder() = default;
36
37 // Called after all attribute decoders are created. It can be used to perform
38 // any custom initialization.
39 bool Init(PointCloudDecoder *decoder, PointCloud *pc) override;
40
41 // Decodes any attribute decoder specific data from the |in_buffer|.
42 bool DecodeAttributesDecoderData(DecoderBuffer *in_buffer) override;
43
44 int32_t GetAttributeId(int i) const override {
45 return point_attribute_ids_[i];
46 }
47 int32_t GetNumAttributes() const override {
48 return static_cast<int32_t>(point_attribute_ids_.size());
49 }
50 PointCloudDecoder *GetDecoder() const override {
51 return point_cloud_decoder_;
52 }
53
54 // Decodes attribute data from the source buffer.
55 bool DecodeAttributes(DecoderBuffer *in_buffer) override {
56 if (!DecodePortableAttributes(in_buffer)) {
57 return false;
58 }
60 return false;
61 }
63 return false;
64 }
65 return true;
66 }
67
68 protected:
69 int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const {
70 const int id_map_size =
71 static_cast<int>(point_attribute_to_local_id_map_.size());
72 if (point_attribute_id >= id_map_size) {
73 return -1;
74 }
75 return point_attribute_to_local_id_map_[point_attribute_id];
76 }
77 virtual bool DecodePortableAttributes(DecoderBuffer *in_buffer) = 0;
79 return true;
80 }
81 virtual bool TransformAttributesToOriginalFormat() { return true; }
82
83 private:
84 // List of attribute ids that need to be decoded with this decoder.
85 std::vector<int32_t> point_attribute_ids_;
86
87 // Map between point attribute id and the local id (i.e., the inverse of the
88 // |point_attribute_ids_|.
89 std::vector<int32_t> point_attribute_to_local_id_map_;
90
91 PointCloudDecoder *point_cloud_decoder_;
92 PointCloud *point_cloud_;
93};
94
95} // namespace draco
96
97#endif // DRACO_COMPRESSION_ATTRIBUTES_ATTRIBUTES_DECODER_H_
bool Init(PointCloudDecoder *decoder, PointCloud *pc) override
Definition attributes_decoder.cc:24
int32_t GetLocalIdForPointAttribute(int32_t point_attribute_id) const
Definition attributes_decoder.h:69
virtual ~AttributesDecoder()=default
bool DecodeAttributesDecoderData(DecoderBuffer *in_buffer) override
Definition attributes_decoder.cc:30
int32_t GetNumAttributes() const override
Definition attributes_decoder.h:47
int32_t GetAttributeId(int i) const override
Definition attributes_decoder.h:44
virtual bool DecodeDataNeededByPortableTransforms(DecoderBuffer *in_buffer)
Definition attributes_decoder.h:78
PointCloudDecoder * GetDecoder() const override
Definition attributes_decoder.h:50
virtual bool DecodePortableAttributes(DecoderBuffer *in_buffer)=0
bool DecodeAttributes(DecoderBuffer *in_buffer) override
Definition attributes_decoder.h:55
AttributesDecoder()
Definition attributes_decoder.cc:21
virtual bool TransformAttributesToOriginalFormat()
Definition attributes_decoder.h:81
Definition decoder_buffer.h:30
Definition point_cloud_decoder.h:28
Definition point_cloud.h:29
Definition attribute_octahedron_transform.cc:21