ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
LasScalarField.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // ##########################################################################
11 // # #
12 // # CloudViewer PLUGIN: LAS-IO Plugin #
13 // # #
14 // # This program is free software; you can redistribute it and/or modify #
15 // # it under the terms of the GNU General Public License as published by #
16 // # the Free Software Foundation; version 2 of the License. #
17 // # #
18 // # This program is distributed in the hope that it will be useful, #
19 // # but WITHOUT ANY WARRANTY; without even the implied warranty of #
20 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
21 // # GNU General Public License for more details. #
22 // # #
23 // # COPYRIGHT: Thomas Montaigu #
24 // # #
25 // ##########################################################################
26 
27 // CORE
28 #include <CVTypes.h>
29 // qCC_db
30 #include <ecvScalarField.h>
31 
32 // System
33 #include <cstdint>
34 
38 {
42  enum Id
43  {
44  Intensity = 0,
57  // Extended (LAS 1.4)
65  };
66 
70  struct Range
71  {
75  template <class T>
76  constexpr Range(T minValue, T maxValue)
77  : min(static_cast<ScalarType>(minValue))
78  , max(static_cast<ScalarType>(maxValue))
79  {
80  }
81 
83  template <class T>
84  static constexpr Range ForType()
85  {
87  }
88 
89  static Range ForBitCount(uint8_t numBits)
90  {
91  return Range(0, ((1 << static_cast<uint32_t>(numBits)) - 1));
92  }
93 
94  ScalarType min = 0;
95  ScalarType max = 0;
96  };
97 
98  public: // Methods and Constructors
99  LasScalarField() = delete;
100 
101  explicit LasScalarField(LasScalarField::Id id, ccScalarField* sf = nullptr);
102 
103  const char* name() const;
104 
105  public: // Static functions
107  static constexpr const char* NameFromId(LasScalarField::Id id);
114  static LasScalarField::Id IdFromName(const char* name, unsigned targetPointFormat);
119  static std::vector<LasScalarField> ForPointFormat(unsigned pointFormatId);
120 
121  public: // Members
131  ccScalarField* sf{nullptr};
133 };
A scalar field associated to display-related parameters.
int min(int a, int b)
Definition: cutil_math.h:53
int max(int a, int b)
Definition: cutil_math.h:48
constexpr Range(T minValue, T maxValue)
static Range ForBitCount(uint8_t numBits)
static constexpr Range ForType()
Shortcut to create a Range from a native type like uint16_t.
static std::vector< LasScalarField > ForPointFormat(unsigned pointFormatId)
const char * name() const
static LasScalarField::Range ValueRange(LasScalarField::Id id)
Returns the range of value the given field (ID) supports.
static constexpr const char * NameFromId(LasScalarField::Id id)
Returns the name that correspond to the given LasScalarField::Id variant.
LasScalarField()=delete
ccScalarField * sf
Id id
The Id of the LAS field this relates to.
static LasScalarField::Id IdFromName(const char *name, unsigned targetPointFormat)