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_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_
16 #define DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_
17 
18 #include <inttypes.h>
19 
20 #include <vector>
21 
22 #include "draco/attributes/geometry_indices.h"
23 
24 namespace draco {
25 
26 // Data used for encoding and decoding of mesh attributes.
27 struct MeshAttributeIndicesEncodingData {
MeshAttributeIndicesEncodingDataMeshAttributeIndicesEncodingData28   MeshAttributeIndicesEncodingData() : num_values(0) {}
29 
InitMeshAttributeIndicesEncodingData30   void Init(int num_vertices) {
31     vertex_to_encoded_attribute_value_index_map.resize(num_vertices);
32 
33     // We expect to store one value for each vertex.
34     encoded_attribute_value_index_to_corner_map.reserve(num_vertices);
35   }
36 
37   // Array for storing the corner ids in the order their associated attribute
38   // entries were encoded/decoded. For every encoded attribute value entry we
39   // store exactly one corner. I.e., this is the mapping between an encoded
40   // attribute entry ids and corner ids. This map is needed for example by
41   // prediction schemes. Note that not all corners are included in this map,
42   // e.g., if multiple corners share the same attribute value, only one of these
43   // corners will be usually included.
44   std::vector<CornerIndex> encoded_attribute_value_index_to_corner_map;
45 
46   // Map for storing encoding order of attribute entries for each vertex.
47   // i.e. Mapping between vertices and their corresponding attribute entry ids
48   // that are going to be used by the decoder.
49   // -1 if an attribute entry hasn't been encoded/decoded yet.
50   std::vector<int32_t> vertex_to_encoded_attribute_value_index_map;
51 
52   // Total number of encoded/decoded attribute entries.
53   int num_values;
54 };
55 
56 }  // namespace draco
57 
58 #endif  // DRACO_COMPRESSION_ATTRIBUTES_MESH_ATTRIBUTE_INDICES_ENCODING_DATA_H_
59