ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
LasScalarFieldLoader.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 #include "LasDetails.h"
28 #include "LasExtraScalarField.h"
29 #include "LasScalarField.h"
30 
31 // DB
32 #include <FileIOFilter.h>
33 #include <ecvPointCloud.h>
34 
35 // Qt
36 #include <QFileInfo>
37 
38 // LASzip
39 #include <laszip/laszip_api.h>
40 
46 {
47  public:
48  LasScalarFieldLoader(std::vector<LasScalarField>& standardScalarFields,
49  std::vector<LasExtraScalarField>& extraScalarFields,
50  ccPointCloud& pointCloud);
51 
52  CC_FILE_ERROR handleScalarFields(ccPointCloud& pointCloud, const laszip_point& currentPoint);
53 
56  CC_FILE_ERROR handleRGBValue(ccPointCloud& pointCloud, const laszip_point& currentPoint);
57 
58  CC_FILE_ERROR handleExtraScalarFields(ccPointCloud& pointCloud, const laszip_point& currentPoint);
59 
60  inline void setIgnoreFieldsWithDefaultValues(bool state)
61  {
62  m_ignoreFieldsWithDefaultValues = state;
63  }
64 
65  inline void setForce8bitRgbMode(bool state)
66  {
67  m_force8bitRgbMode = state;
68  }
69 
72  inline void setManualTimeShift(double timeShift)
73  {
74  m_manualTimeShiftValue = timeShift;
75  }
76 
77  inline const std::vector<LasScalarField>& standardFields() const
78  {
79  return m_standardFields;
80  }
81 
82  inline const std::vector<LasExtraScalarField>& extraFields() const
83  {
84  return m_extraScalarFields;
85  }
86 
87  private:
94  template <typename T>
95  CC_FILE_ERROR handleScalarField(LasScalarField& sfInfo, ccPointCloud& pointCloud, T currentValue);
96 
98  CC_FILE_ERROR handleGpsTime(LasScalarField& sfInfo, ccPointCloud& pointCloud, double currentValue);
99 
101  bool createScalarFieldsForExtraBytes(ccPointCloud& pointCloud);
102 
105  template <typename T>
106  static ScalarType ParseValueOfType(uint8_t* source);
107 
110  template <typename T, typename V>
111  static V ParseValueOfTypeAs(const uint8_t* source);
112 
116  void parseRawValues(const LasExtraScalarField& extraField, const uint8_t* dataStart);
117 
118  template <typename T>
119  void handleOptionsFor(const LasExtraScalarField& extraField, T values[3]);
120 
121  private:
122  bool m_force8bitRgbMode{false};
123  bool m_ignoreFieldsWithDefaultValues{true};
124  double m_manualTimeShiftValue{std::numeric_limits<double>::quiet_NaN()};
125  unsigned char m_colorCompShift{0};
126  std::vector<LasScalarField>& m_standardFields;
127  std::vector<LasExtraScalarField>& m_extraScalarFields;
128 
129  union
130  {
134  } m_rawValues;
135 };
CC_FILE_ERROR
Typical I/O filter errors.
Definition: FileIOFilter.h:20
This serves the same purpose as LasScalarField but for extra bytes.
static constexpr unsigned MAX_DIM_SIZE
int64_t signedValues[LasExtraScalarField::MAX_DIM_SIZE]
uint64_t unsignedValues[LasExtraScalarField::MAX_DIM_SIZE]
CC_FILE_ERROR handleRGBValue(ccPointCloud &pointCloud, const laszip_point &currentPoint)
const std::vector< LasExtraScalarField > & extraFields() const
CC_FILE_ERROR handleScalarFields(ccPointCloud &pointCloud, const laszip_point &currentPoint)
CC_FILE_ERROR handleExtraScalarFields(ccPointCloud &pointCloud, const laszip_point &currentPoint)
void setManualTimeShift(double timeShift)
void setForce8bitRgbMode(bool state)
void setIgnoreFieldsWithDefaultValues(bool state)
const std::vector< LasScalarField > & standardFields() const
LasScalarFieldLoader(std::vector< LasScalarField > &standardScalarFields, std::vector< LasExtraScalarField > &extraScalarFields, ccPointCloud &pointCloud)
double floatingValues[LasExtraScalarField::MAX_DIM_SIZE]
A 3D cloud and its associated features (color, normals, scalar fields, etc.)