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

mesh_attribute_indices_encoding_observer.h « traverser « mesh « compression « draco « src « draco « draco « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e66dd14b2382a10bc3723517f995c6a3252fe9fa (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
64
65
66
67
68
69
70
71
72
73
74
75
76
// 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_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_
#define DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_

#include "draco/compression/attributes/mesh_attribute_indices_encoding_data.h"
#include "draco/compression/attributes/points_sequencer.h"
#include "draco/mesh/mesh.h"

namespace draco {

// Class that can be used to generate encoding (and decoding) order of attribute
// values based on the traversal of the encoded mesh. The class should be used
// as the TraversalObserverT member of a Traverser class such as the
// DepthFirstTraverser (depth_first_traverser.h).
// TODO(hemmer): rename to AttributeIndicesCodingTraverserObserver
template <class CornerTableT>
class MeshAttributeIndicesEncodingObserver {
 public:
  MeshAttributeIndicesEncodingObserver()
      : att_connectivity_(nullptr),
        encoding_data_(nullptr),
        mesh_(nullptr),
        sequencer_(nullptr) {}
  MeshAttributeIndicesEncodingObserver(
      const CornerTableT *connectivity, const Mesh *mesh,
      PointsSequencer *sequencer,
      MeshAttributeIndicesEncodingData *encoding_data)
      : att_connectivity_(connectivity),
        encoding_data_(encoding_data),
        mesh_(mesh),
        sequencer_(sequencer) {}

  // Interface for TraversalObserverT

  void OnNewFaceVisited(FaceIndex /* face */) {}

  inline void OnNewVertexVisited(VertexIndex vertex, CornerIndex corner) {
    const PointIndex point_id =
        mesh_->face(FaceIndex(corner.value() / 3))[corner.value() % 3];
    // Append the visited attribute to the encoding order.
    sequencer_->AddPointId(point_id);

    // Keep track of visited corners.
    encoding_data_->encoded_attribute_value_index_to_corner_map.push_back(
        corner);

    encoding_data_
        ->vertex_to_encoded_attribute_value_index_map[vertex.value()] =
        encoding_data_->num_values;

    encoding_data_->num_values++;
  }

 private:
  const CornerTableT *att_connectivity_;
  MeshAttributeIndicesEncodingData *encoding_data_;
  const Mesh *mesh_;
  PointsSequencer *sequencer_;
};

}  // namespace draco

#endif  // DRACO_COMPRESSION_MESH_TRAVERSER_MESH_ATTRIBUTE_INDICES_ENCODING_OBSERVER_H_