RDB 2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
queryInvert.hpp
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  *
4  * Copyright 2021 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 <cstdint>
43 
46 
47 //---< NAMESPACE >--------------------------------------------------------------
48 
49 namespace riegl {
50 namespace rdb {
51 namespace pointcloud {
52 
53 //---< CLASS QueryInvert >------------------------------------------------------
54 /*!
55  * \brief Point invert query
56  *
57  * This class can be used to invert point attributes for all points or just
58  * those that meet some filter criteria. Calculating the inverted value (v')
59  * from the original value (v) and the attribute limits (min and max) is done
60  * as follows:
61  *
62  * v' = max - (v - min)
63  *
64  * For dynamic point attributes (bits/flags) this simply means to flip the
65  * bit (e.g. set "riegl.selected" to 1 if it was 0, otherwise set it to 0).
66  *
67  * This query is similar to using select() and update() and manually inverting
68  * the point attributes except that it might be faster (less processing time)
69  * and easier to use.
70  *
71  * \see riegl::rdb::Pointcloud::invert()
72  *
73  * \note You either must delete the query object or call close()
74  * __before__ the parent Pointcloud instance is closed/deleted!
75  */
77 {
78 public:
79  /*!
80  * \brief Default constructor
81  *
82  * Creates a null query - i.e. the query cannot be used to modify points.
83  *
84  * \see riegl::rdb::Pointcloud::invert()
85  */
86  explicit QueryInvert();
87 
88  /*!
89  * \brief Constructor
90  *
91  * Creates a query prepared for modifying points.
92  *
93  * \note You cannot create new QueryInvert objects this way,
94  * use riegl::rdb::Pointcloud::invert() instead.
95  */
96  explicit QueryInvert(
97  riegl::rdb::PointcloudData *pointcloud,
98  const std::vector<GraphNode::ID> *nodes,
99  const std::string &filter
100  );
101 
102  /*!
103  * \brief Check if query is not null
104  *
105  * \see valid()
106  */
107  operator bool() const;
108 
109  /*!
110  * \brief Check if query is not null
111  *
112  * A null query cannot be used to read points.
113  */
114  bool valid() const;
115 
116  /*!
117  * \brief Finish query
118  *
119  * Call this function when done with modifying points.
120  */
121  void close();
122 
123  /*!
124  * \brief Define attribute
125  *
126  * Use this function to define the point attribute to be inverted. To
127  * define multiple attributes, simply call this function once for each.
128  *
129  * \note Point attributes having a length greater than 1 (vectors like
130  * the true color attribute "riegl.rgba") can only be inverted
131  * as a whole, i.e. you cannot invert particular vector elements
132  * (e.g. using "riegl.rgba[0]" will not work).
133  *
134  * \see riegl::rdb::pointcloud::PointAttributes
135  */
136  void attribute(
137  const std::string &name //!< [in] attribute name
138  );
139 
140  /*!
141  * \brief Invert points
142  *
143  * Use this function to actually invert the point attribute(s).
144  *
145  * To process all points, you need to repeatedly call next() until it
146  * returns 0 (zero, see example 8). The number of points to process in
147  * one step is defined by 'count'. Please note that the actual number
148  * of processed points may be slightly different. To cancel processing
149  * just stop calling next() and cancel (rollback) the transaction.
150  *
151  * \returns the number of points processed
152  */
153  uint32_t next(
154  uint32_t count //!< [in] number of points to process
155  );
156 
157  /*!
158  * \brief Progress
159  *
160  * This function returns a coarse progress information in percent (0..100%).
161  * Since the total number of modified points is not known in advance, this
162  * value just reflects the progress of the (internal) index traversal.
163  */
164  uint32_t progress() const;
165 
166 private:
167  struct Private;
168  std::shared_ptr<Private> data;
169 };
170 
171 }}} // namespace riegl::rdb::pointcloud
172 
173 #endif // RIEGL_RDB_POINTCLOUD_QUERYINVERT_HPP
QueryInvert()
Default constructor.
bool valid() const
Check if query is not null.
Index graph node.
void attribute(const std::string &name)
Define attribute.
uint32_t progress() const
Progress.
uint32_t next(uint32_t count)
Invert points.
Pointcloud class implementation details.