ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
LasSaver.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 "LasScalarFieldSaver.h"
28 #include "LasWaveformSaver.h"
29 
30 // qCC_db
31 #include <FileIOFilter.h>
32 
33 // LASzip
34 #include <laszip/laszip_api.h>
35 
36 // System
37 #include <memory>
38 
39 class ccPointCloud;
40 
41 class LasSaver
42 {
43  public:
44  struct Parameters
45  {
46  std::vector<LasScalarField> standardFields;
47  std::vector<LasExtraScalarField> extraFields;
48  bool shouldSaveRGB{false};
49  bool shouldSaveWaveform{false};
50  uint8_t versionMajor{1};
51  uint8_t versionMinor{0};
52  uint8_t pointFormat{0};
55  };
56 
57  LasSaver(ccPointCloud& cloud, Parameters& parameters);
58  ~LasSaver() noexcept;
59 
60  CC_FILE_ERROR open(const QString filePath);
61 
63 
64  bool savesWaveforms() const;
65 
66  QString getLastError() const;
67 
68  private:
69  void initLaszipHeader(const Parameters& parameters);
70 
71  private:
72  unsigned m_currentPointIndex{0};
73  ccPointCloud& m_cloudToSave;
74  laszip_header m_laszipHeader{};
75  laszip_POINTER m_laszipWriter{nullptr};
76  LasScalarFieldSaver m_fieldsSaver;
77  bool m_shouldSaveRGB{false};
78  std::unique_ptr<LasWaveformSaver> m_waveformSaver{nullptr};
79  laszip_point* m_laszipPoint{nullptr};
80 };
CC_FILE_ERROR
Typical I/O filter errors.
Definition: FileIOFilter.h:20
~LasSaver() noexcept
Definition: LasSaver.cpp:108
LasSaver(ccPointCloud &cloud, Parameters &parameters)
Definition: LasSaver.cpp:18
CC_FILE_ERROR open(const QString filePath)
Definition: LasSaver.cpp:118
bool savesWaveforms() const
Definition: LasSaver.cpp:222
QString getLastError() const
Definition: LasSaver.cpp:227
CC_FILE_ERROR saveNextPoint()
Definition: LasSaver.cpp:150
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
uint8_t versionMajor
Definition: LasSaver.h:50
CCVector3d lasScale
Definition: LasSaver.h:53
uint8_t versionMinor
Definition: LasSaver.h:51
CCVector3d lasOffset
Definition: LasSaver.h:54
uint8_t pointFormat
Definition: LasSaver.h:52
std::vector< LasScalarField > standardFields
Definition: LasSaver.h:46
std::vector< LasExtraScalarField > extraFields
Definition: LasSaver.h:47