Welcome to mirror list, hosted at ThFree Co, Russian Federation.

points_sequencer.h « attributes « compression « draco « src « dracoenc « draco « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2f4f7e16d11269314d83f99ae3bd003f23f078d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2016 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef DRACO_COMPRESSION_ATTRIBUTES_POINTS_SEQUENCER_H_
#define DRACO_COMPRESSION_ATTRIBUTES_POINTS_SEQUENCER_H_

#include <vector>

#include "draco/attributes/point_attribute.h"

namespace draco {

// Class for generating a sequence of point ids that can be used to encode
// or decode attribute values in a specific order.
// See sequential_attribute_encoders/decoders_controller.h for more details.
class PointsSequencer {
 public:
  PointsSequencer() : out_point_ids_(nullptr) {}
  virtual ~PointsSequencer() = default;

  // Fills the |out_point_ids| with the generated sequence of point ids.
  bool GenerateSequence(std::vector<PointIndex> *out_point_ids) {
    out_point_ids_ = out_point_ids;
    return GenerateSequenceInternal();
  }

  // Appends a point to the sequence.
  void AddPointId(PointIndex point_id) { out_point_ids_->push_back(point_id); }

  // Sets the correct mapping between point ids and value ids. I.e., the inverse
  // of the |out_point_ids|. In general, |out_point_ids_| does not contain
  // sufficient information to compute the inverse map, because not all point
  // ids are necessarily contained within the map.
  // Must be implemented for sequencers that are used by attribute decoders.
  virtual bool UpdatePointToAttributeIndexMapping(PointAttribute * /* attr */) {
    return false;
  }

 protected:
  // Method that needs to be implemented by the derived classes. The
  // implementation is responsible for filling |out_point_ids_| with the valid
  // sequence of point ids.
  virtual bool GenerateSequenceInternal() = 0;
  std::vector<PointIndex> *out_point_ids() const { return out_point_ids_; }

 private:
  std::vector<PointIndex> *out_point_ids_;
};

}  // namespace draco

#endif  // DRACO_COMPRESSION_ATTRIBUTES_POINTS_SEQUENCER_H_