ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
LasScalarFieldSaver.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 class ccPointCloud;
32 struct laszip_point;
33 
37 {
38  public:
39  LasScalarFieldSaver() = default;
40 
43  LasScalarFieldSaver(std::vector<LasScalarField>&& standardFields,
44  std::vector<LasExtraScalarField>&& extraFields);
45 
46  inline void setStandarFields(std::vector<LasScalarField>&& standardFields)
47  {
48  m_standardFields = standardFields;
49  }
50 
51  inline void setExtraFields(std::vector<LasExtraScalarField>&& extraFields)
52  {
53  m_extraFields = extraFields;
54  }
55 
56  inline const std::vector<LasExtraScalarField>& extraFields() const
57  {
58  return m_extraFields;
59  }
60 
62  void handleScalarFields(size_t pointIndex, laszip_point& point);
63 
65  void handleExtraFields(size_t pointIndex, laszip_point& point);
66 
67  private:
68  template <typename T>
69  static void WriteScalarValueAs(ScalarType value, uint8_t* dest)
70  {
71  if (value > std::numeric_limits<T>::max())
72  {
73  *reinterpret_cast<T*>(dest) = std::numeric_limits<T>::max();
74  }
75  else if (value < std::numeric_limits<T>::lowest())
76  {
77  *reinterpret_cast<T*>(dest) = std::numeric_limits<T>::lowest();
78  }
79  else
80  {
81  *reinterpret_cast<T*>(dest) = static_cast<T>(value);
82  }
83  }
84 
85  private:
86  std::vector<LasScalarField> m_standardFields;
87  std::vector<LasExtraScalarField> m_extraFields;
88 };
const std::vector< LasExtraScalarField > & extraFields() const
void setStandarFields(std::vector< LasScalarField > &&standardFields)
void setExtraFields(std::vector< LasExtraScalarField > &&extraFields)
void handleExtraFields(size_t pointIndex, laszip_point &point)
Saves the extra scalar fields values for pointIndex into the given laszip_point.
LasScalarFieldSaver()=default
void handleScalarFields(size_t pointIndex, laszip_point &point)
Saves the scalar fields values for pointIndex into the given laszip_point.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
int max(int a, int b)
Definition: cutil_math.h:48
Definition: lsd.c:149