| RDB 2

queryInvert.hpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 *
4 * Copyright 2026 RIEGL Laser Measurement Systems
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * SPDX-License-Identifier: Apache-2.0
19 *
20 *******************************************************************************
21 */
22 /*!
23 *******************************************************************************
24 *
25 * \file queryInvert.hpp
26 * \author RIEGL LMS GmbH, Austria
27 * \brief Point invert query
28 * \version 2016-11-14/AW: Initial version
29 * \version 2017-11-24/AW: Constructors declared as "explicit" (#2825)
30 *
31 *******************************************************************************
32 */
33
34 #ifndef RIEGL_RDB_POINTCLOUD_QUERYINVERT_HPP
35 #define RIEGL_RDB_POINTCLOUD_QUERYINVERT_HPP
36
37 //---< INCLUDES >---------------------------------------------------------------
38
39 #include <memory>
40 #include <string>
41 #include <vector>
42 #include <cstdlib>
43 #include <cstdint>
44
45 #include "riegl/rdb/pointcloud/graphNode.hpp"
46 #include "riegl/rdb/pointcloud/pointcloudData.hpp"
47
48 //---< NAMESPACE >--------------------------------------------------------------
49
50 namespace riegl {
51 namespace rdb {
52 namespace pointcloud {
53
54 //---< CLASS QueryInvert >------------------------------------------------------
55 /*!
56 * \brief Point invert query
57 *
58 * This class can be used to invert point attributes for all points or just
59 * those that meet some filter criteria. Calculating the inverted value (v')
60 * from the original value (v) and the attribute limits (min and max) is done
61 * as follows:
62 *
63 * v' = max - (v - min)
64 *
65 * For dynamic point attributes (bits/flags) this simply means to flip the
66 * bit (e.g. set "riegl.selected" to 1 if it was 0, otherwise set it to 0).
67 *
68 * This query is similar to using select() and update() and manually inverting
69 * the point attributes except that it might be faster (less processing time)
70 * and easier to use.
71 *
72 * \see riegl::rdb::Pointcloud::invert()
73 *
74 * \note You either must delete the query object or call close()
75 * __before__ the parent Pointcloud instance is closed/deleted!
76 */
77 class QueryInvert
78 {
79 public:
80 /*!
81 * \brief Default constructor
82 *
83 * Creates a null query - i.e. the query cannot be used to modify points.
84 *
85 * \see riegl::rdb::Pointcloud::invert()
86 */
87 explicit QueryInvert();
88
89 /*!
90 * \brief Constructor
91 *
92 * Creates a query prepared for modifying points.
93 *
94 * \note You cannot create new QueryInvert objects this way,
95 * use riegl::rdb::Pointcloud::invert() instead.
96 */
97 explicit QueryInvert(
98 riegl::rdb::PointcloudData *pointcloud,
99 const std::vector<GraphNode::ID> *nodes,
100 const std::string &filter
101 );
102
103 /*!
104 * \brief Check if query is not null
105 *
106 * \see valid()
107 */
108 operator bool() const;
109
110 /*!
111 * \brief Check if query is not null
112 *
113 * A null query cannot be used to read points.
114 */
115 bool valid() const;
116
117 /*!
118 * \brief Finish query
119 *
120 * Call this function when done with modifying points.
121 */
122 void close();
123
124 /*!
125 * \brief Define attribute
126 *
127 * Use this function to define the point attribute to be inverted. To
128 * define multiple attributes, simply call this function once for each.
129 *
130 * \note Point attributes having a length greater than 1 (vectors like
131 * the true color attribute "riegl.rgba") can only be inverted
132 * as a whole, i.e. you cannot invert particular vector elements
133 * (e.g. using "riegl.rgba[0]" will not work).
134 *
135 * \see riegl::rdb::pointcloud::PointAttributes
136 */
137 void attribute(
138 const std::string &name //!< [in] attribute name
139 );
140
141 /*!
142 * \brief Invert points
143 *
144 * Use this function to actually invert the point attribute(s).
145 *
146 * To process all points, you need to repeatedly call next() until it
147 * returns 0 (zero, see example 8). The number of points to process in
148 * one step is defined by 'count'. Please note that the actual number
149 * of processed points may be slightly different. To cancel processing
150 * just stop calling next() and cancel (rollback) the transaction.
151 *
152 * \returns the number of points processed
153 */
154 std::uint32_t next(
155 std::uint32_t count //!< [in] number of points to process
156 );
157
158 /*!
159 * \brief Progress
160 *
161 * This function returns a coarse progress information in percent (0..100%).
162 * Since the total number of modified points is not known in advance, this
163 * value just reflects the progress of the (internal) index traversal.
164 */
165 std::uint32_t progress() const;
166
167 private:
168 struct Private;
169 std::shared_ptr<Private> data;
170 };
171
172 }}} // namespace riegl::rdb::pointcloud
173
174 #endif // RIEGL_RDB_POINTCLOUD_QUERYINVERT_HPP
riegl::rdb::pointcloud::QueryInvert::QueryInvert
QueryInvert()
Default constructor.
graphNode.hpp
Index graph node.
riegl
RIEGL Laser Measurement Systems GmbH, Austria.
Definition: context.hpp:48
riegl::rdb::pointcloud::QueryInvert::attribute
void attribute(const std::string &name)
Define attribute.
riegl::rdb::pointcloud::QueryInvert::next
std::uint32_t next(std::uint32_t count)
Invert points.
riegl::rdb::pointcloud::QueryInvert
Point invert query.
Definition: queryInvert.hpp:77
riegl::rdb::pointcloud::QueryInvert::close
void close()
Finish query.
riegl::rdb::pointcloud::QueryInvert::valid
bool valid() const
Check if query is not null.
pointcloudData.hpp
Pointcloud class implementation details.
riegl::rdb::pointcloud::QueryInvert::progress
std::uint32_t progress() const
Progress.