ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
LasVlr.cpp
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 #include "LasVlr.h"
9 
10 #include "LasMetadata.h"
11 
12 // Qt
13 #include <QtGlobal>
14 // qCC_db
15 #include <ecvPointCloud.h>
16 // System
17 #include <algorithm>
18 #include <cstring>
19 
20 LasVlr::LasVlr(const laszip_header& header)
21 {
22  const auto vlrShouldBeCopied = [](const laszip_vlr_struct& vlr)
23  {
25  };
26 
27  ptrdiff_t numVlrs = std::count_if(header.vlrs, header.vlrs + header.number_of_variable_length_records, vlrShouldBeCopied);
28  if (numVlrs > 0)
29  {
30  vlrs.resize(numVlrs);
31  laszip_U32 j = 0;
32  for (laszip_U32 i = 0; i < header.number_of_variable_length_records; ++i)
33  {
34  if (vlrShouldBeCopied(header.vlrs[i]))
35  {
36  LasDetails::CloneVlrInto(header.vlrs[i], vlrs[j]);
37  j++;
38  }
39  }
40  }
41 }
42 
44 {
45  LasVlr::Swap(*this, rhs);
46  return *this;
47 }
48 
50  : extraScalarFields(rhs.extraScalarFields)
51 {
52  if (rhs.numVlrs() != 0)
53  {
54  vlrs.resize(rhs.numVlrs());
55  for (laszip_U32 i = 0; i < rhs.numVlrs(); ++i)
56  {
58  }
59  }
60 }
61 
62 void LasVlr::Swap(LasVlr& lhs, LasVlr& rhs) noexcept
63 {
64  std::swap(lhs.vlrs, rhs.vlrs);
65  std::swap(lhs.extraScalarFields, rhs.extraScalarFields);
66 }
laszip_vlr laszip_vlr_struct
Definition: LasDetails.h:46
bool IsLaszipVlr(const laszip_vlr_struct &)
Returns whether the vlr is the vlr for/of LASzip compression.
Definition: LasDetails.cpp:127
bool IsExtraBytesVlr(const laszip_vlr_struct &)
Returns whether the vlr describes extra bytes.
Definition: LasDetails.cpp:136
void CloneVlrInto(const laszip_vlr_struct &src, laszip_vlr_struct &dst)
Clones the content of the src vlr into the dst vlr.
Definition: LasDetails.cpp:285
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1370
Definition: LasVlr.h:38
LasVlr()=default
std::vector< laszip_vlr_struct > vlrs
Definition: LasVlr.h:120
static void Swap(LasVlr &lhs, LasVlr &rhs) noexcept
Definition: LasVlr.cpp:62
laszip_U32 numVlrs() const
Definition: LasVlr.h:52
LasVlr & operator=(LasVlr rhs)
Definition: LasVlr.cpp:43