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

float_points_tree_encoder.cc « algorithms « point_cloud « compression « draco « src « draco « draco « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 317430f2b8ef51b64522da4433bb47c09b9ee6b9 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// 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.
//
#include "draco/compression/point_cloud/algorithms/float_points_tree_encoder.h"

#include <algorithm>
#include <cmath>

#include "draco/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h"
#include "draco/core/math_utils.h"

namespace draco {

const uint32_t FloatPointsTreeEncoder::version_ = 3;

FloatPointsTreeEncoder::FloatPointsTreeEncoder(
    PointCloudCompressionMethod method)
    : method_(method), num_points_(0), compression_level_(6) {
  qinfo_.quantization_bits = 16;
  qinfo_.range = 0;
}

FloatPointsTreeEncoder::FloatPointsTreeEncoder(
    PointCloudCompressionMethod method, uint32_t quantization_bits,
    uint32_t compression_level)
    : method_(method), num_points_(0), compression_level_(compression_level) {
  DRACO_DCHECK_LE(compression_level_, 6);
  qinfo_.quantization_bits = quantization_bits;
  qinfo_.range = 0;
}

bool FloatPointsTreeEncoder::EncodePointCloudKdTreeInternal(
    std::vector<Point3ui> *qpoints) {
  DRACO_DCHECK_LE(compression_level_, 6);
  switch (compression_level_) {
    case 0: {
      DynamicIntegerPointsKdTreeEncoder<0> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
    case 1: {
      DynamicIntegerPointsKdTreeEncoder<1> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
    case 2: {
      DynamicIntegerPointsKdTreeEncoder<2> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
    case 3: {
      DynamicIntegerPointsKdTreeEncoder<3> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
    case 4: {
      DynamicIntegerPointsKdTreeEncoder<4> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
    case 5: {
      DynamicIntegerPointsKdTreeEncoder<5> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
    default: {
      DynamicIntegerPointsKdTreeEncoder<6> qpoints_encoder(3);
      qpoints_encoder.EncodePoints(qpoints->begin(), qpoints->end(),
                                   qinfo_.quantization_bits + 1, &buffer_);
      break;
    }
  }

  return true;
}

}  // namespace draco