RDB 2: riegl/rdb/pointcloud/queryStat.hpp Source File

| RDB 2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
queryStat.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 queryStat.hpp
26 * \author RIEGL LMS GmbH, Austria
27 * \brief Point statistics query
28 * \version 2015-10-14/AW: Initial version
29 * \version 2016-11-07/AW: Optionally filter index graph nodes (#2390)
30 * \version 2017-11-24/AW: Constructors declared as "explicit" (#2825)
31 * \version 2018-07-05/AW: Wrappers for minimum() and maximum() added
32 * \version 2019-11-05/AW: Optionally return cleaned attribute extents (#3071)
33 *
34 *******************************************************************************
35 */
36
37 #ifndef RIEGL_RDB_POINTCLOUD_QUERYSTAT_HPP
38 #define RIEGL_RDB_POINTCLOUD_QUERYSTAT_HPP
39
40 //---< INCLUDES >---------------------------------------------------------------
41
42 #include <memory>
43 #include <string>
44 #include <vector>
45 #include <cstdint>
46 #include "riegl/rdb/pointcloud/dataTypes.hpp"
47 #include "riegl/rdb/pointcloud/graphNode.hpp"
48 #include "riegl/rdb/pointcloud/transaction.hpp"
49 #include "riegl/rdb/pointcloud/pointcloudData.hpp"
50
51 //---< NAMESPACE >--------------------------------------------------------------
52
53 namespace riegl {
54 namespace rdb {
55 namespace pointcloud {
56
57 //---< CLASS QueryStat >--------------------------------------------------------
58 /*!
59 * \brief Point statistics query
60 *
61 * This query provides point attribute statistics like minimum and
62 * maximum value.
63 *
64 * \see riegl::rdb::Pointcloud::stat()
65 *
66 * \note You either must delete the query object or call close()
67 * __before__ the parent Pointcloud instance is closed/deleted!
68 */
69 class QueryStat
70 {
71 public:
72 /*!
73 * \brief Default constructor
74 *
75 * Creates a null query - i.e. the query cannot be used to read stats.
76 *
77 * \see riegl::rdb::Pointcloud::stat()
78 */
79 explicit QueryStat();
80
81 /*!
82 * \brief Constructor
83 *
84 * Creates a query prepared for reading stats.
85 *
86 * \note You cannot create new QueryStat objects this way,
87 * use riegl::rdb::Pointcloud::stat() instead.
88 */
89 explicit QueryStat(riegl::rdb::PointcloudData *pointcloud);
90
91 /*!
92 * \brief Check if query is not null
93 *
94 * \see valid()
95 */
96 operator bool() const;
97
98 /*!
99 * \brief Check if query is not null
100 *
101 * A null query cannot be used to read stats.
102 */
103 bool valid() const;
104
105 /*!
106 * \brief Finish query
107 *
108 * Call this function when done with reading stats.
109 */
110 void close();
111
112 /*!
113 * \brief Get index graph
114 *
115 * This function returns a simple directed graph which represents
116 * the index structure that is used to organize the point cloud.
117 *
118 * The optional filter expression can be used to select particular
119 * graph nodes - if no filter is given, all nodes will be returned.
120 * Filter expression syntax see riegl::rdb::Pointcloud::select().
121 *
122 * Note: The reported point counts and attribute extents are not
123 * affected by the filter expressions given here or defined in the
124 * meta data item riegl.stored_filters.
125 *
126 * Details see description of class GraphNode.
127 */
128 void index(
129 GraphNode &root, //!< [out] graph root node
130 const std::string &filter = std::string() //!< [in] optional filter expression
131 );
132 GraphNode index(
133 const std::string &filter = std::string() //!< [in] optional filter expression
134 )
135 {
136 GraphNode result;
137 index(result, filter);
138 return result;
139 }
140
141 /*!
142 * \brief Lowest value of node
143 *
144 * Provides the attribute's minimum value of a branch (i.e. node and children).
145 * If the node ID is zero, then the minimum value of all points is returned.
146 *
147 * The target buffer is expected to be s*d bytes large, where
148 * __s__ is the size of one element as defined by 'dataType' and
149 * __d__ is the number of attribute dimensions (elements).
150 */
151 void minimum(
152 const GraphNode::ID &nodeID, //!< [in] node identifier
153 const std::string &attribute, //!< [in] attribute name
154 const DataType dataType, //!< [in] data type of target buffer
155 void *buffer, //!< [out] buffer for minimum value
156 const bool cleaned=false //!< [in] true: ignore invalid values
157 );
158
159 //! \copydoc minimum()
160 template <typename ValueType>
161 void minimum(
162 const GraphNode::ID &nodeID, //!< [in] node identifier
163 const std::string &attribute, //!< [in] attribute name
164 ValueType &buffer, //!< [out] buffer (data, pointer to data, std::array or std::vector)
165 const bool cleaned=false //!< [in] true: ignore invalid values
166 )
167 {
168 minimum(nodeID, attribute, dataTypeOf(buffer), dataPointerOf(buffer), cleaned);
169 }
170
171 //! \copydoc minimum()
172 template <typename ValueType>
173 void minimum(
174 const GraphNode::ID &nodeID, //!< [in] node identifier
175 const std::string &attribute, //!< [in] attribute name
176 ValueType *buffer, //!< [out] buffer (data, pointer to data, std::array or std::vector)
177 const bool cleaned=false //!< [in] true: ignore invalid values
178 )
179 {
180 minimum(nodeID, attribute, dataTypeOf(buffer), buffer, cleaned);
181 }
182
183 /*!
184 * \brief Highest value of node
185 *
186 * Provides the attribute's maximum value of a branch (i.e. node and children).
187 * If the node ID is zero, then the maximum value of all points is returned.
188 *
189 * The target buffer is expected to be s*d bytes large, where
190 * __s__ is the size of one element as defined by 'dataType' and
191 * __d__ is the number of attribute dimensions (elements).
192 */
193 void maximum(
194 const GraphNode::ID &nodeID, //!< [in] node identifier
195 const std::string &attribute, //!< [in] attribute name
196 const DataType dataType, //!< [in] data type of target buffer
197 void *buffer, //!< [out] buffer for maximum value
198 const bool cleaned=false //!< [in] true: ignore invalid values
199 );
200
201 //! \copydoc maximum()
202 template <typename ValueType>
203 void maximum(
204 const GraphNode::ID &nodeID, //!< [in] node identifier
205 const std::string &attribute, //!< [in] attribute name
206 ValueType &buffer, //!< [out] buffer (data, pointer to data, std::array or std::vector)
207 const bool cleaned=false //!< [in] true: ignore invalid values
208 )
209 {
210 maximum(nodeID, attribute, dataTypeOf(buffer), dataPointerOf(buffer), cleaned);
211 }
212
213 //! \copydoc maximum()
214 template <typename ValueType>
215 void maximum(
216 const GraphNode::ID &nodeID, //!< [in] node identifier
217 const std::string &attribute, //!< [in] attribute name
218 ValueType *buffer, //!< [out] buffer (data, pointer to data, std::array or std::vector)
219 const bool cleaned=false //!< [in] true: ignore invalid values
220 )
221 {
222 maximum(nodeID, attribute, dataTypeOf(buffer), buffer, cleaned);
223 }
224
225 /*!
226 * \brief Attribute revision
227 *
228 * Provides the ID of the last transaction that has modified the attribute
229 * in any node of the given branch.
230 */
231 void revision(
232 const GraphNode::ID &nodeID, //!< [in] node identifier
233 const std::string &attribute, //!< [in] attribute name
234 Transaction::ID &revision //!< [out] transaction ID, see above
235 );
236 Transaction::ID revision(
237 const GraphNode::ID &nodeID, //!< [in] node identifier
238 const std::string &attribute //!< [in] attribute name
239 )
240 {
241 Transaction::ID result;
242 revision(nodeID, attribute, result);
243 return result;
244 }
245
246 private:
247 struct Private;
248 std::shared_ptr<Private> data;
249 };
250
251 }}} // namespace riegl::rdb::pointcloud
252
253 #endif // RIEGL_RDB_POINTCLOUD_QUERYSTAT_HPP
riegl::rdb::pointcloud::QueryStat
Point statistics query.
Definition: queryStat.hpp:69
riegl::rdb::pointcloud::QueryStat::maximum
void maximum(const GraphNode::ID &nodeID, const std::string &attribute, const DataType dataType, void *buffer, const bool cleaned=false)
Highest value of node.
riegl::rdb::pointcloud::DataType
DataType
Point attribute access data type.
Definition: dataTypes.hpp:56
riegl::rdb::pointcloud::QueryStat::QueryStat
QueryStat()
Default constructor.
riegl::rdb::pointcloud::QueryStat::minimum
void minimum(const GraphNode::ID &nodeID, const std::string &attribute, ValueType &buffer, const bool cleaned=false)
Lowest value of node.
Definition: queryStat.hpp:161
riegl::rdb::pointcloud::dataPointerOf
ValueType * dataPointerOf(ValueType *const value)
Get pointer to variable or to data in a std::array or vector container.
Definition: dataTypes.hpp:176
riegl::rdb::pointcloud::QueryStat::minimum
void minimum(const GraphNode::ID &nodeID, const std::string &attribute, ValueType *buffer, const bool cleaned=false)
Lowest value of node.
Definition: queryStat.hpp:173
riegl::rdb::pointcloud::QueryStat::close
void close()
Finish query.
riegl::rdb::pointcloud::QueryStat::revision
Transaction::ID revision(const GraphNode::ID &nodeID, const std::string &attribute)
Definition: queryStat.hpp:236
riegl::rdb::pointcloud::GraphNode::ID
std::uint32_t ID
Definition: graphNode.hpp:78
transaction.hpp
Point cloud transaction.
riegl::rdb::pointcloud::QueryStat::maximum
void maximum(const GraphNode::ID &nodeID, const std::string &attribute, ValueType *buffer, const bool cleaned=false)
Highest value of node.
Definition: queryStat.hpp:215
graphNode.hpp
Index graph node.
riegl::rdb::pointcloud::dataTypeOf
DataType dataTypeOf()
Convenience wrapper for DataTypeOf class.
Definition: dataTypes.hpp:147
riegl::rdb::pointcloud::GraphNode
Graph Node.
Definition: graphNode.hpp:75
riegl::rdb::pointcloud::QueryStat::maximum
void maximum(const GraphNode::ID &nodeID, const std::string &attribute, ValueType &buffer, const bool cleaned=false)
Highest value of node.
Definition: queryStat.hpp:203
riegl::rdb::pointcloud::QueryStat::minimum
void minimum(const GraphNode::ID &nodeID, const std::string &attribute, const DataType dataType, void *buffer, const bool cleaned=false)
Lowest value of node.
riegl::rdb::pointcloud::QueryStat::valid
bool valid() const
Check if query is not null.
riegl::rdb::pointcloud::Transaction::ID
std::uint32_t ID
Definition: transaction.hpp:60
dataTypes.hpp
Point attribute access data types.
pointcloudData.hpp
Pointcloud class implementation details.
riegl::rdb::pointcloud::QueryStat::index
void index(GraphNode &root, const std::string &filter=std::string())
Get index graph.
riegl::rdb::pointcloud::QueryStat::index
GraphNode index(const std::string &filter=std::string())
Definition: queryStat.hpp:132
riegl::rdb::pointcloud::QueryStat::revision
void revision(const GraphNode::ID &nodeID, const std::string &attribute, Transaction::ID &revision)
Attribute revision.