ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
wlPointCloud.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 // system
11 #include <vector>
12 
13 namespace wl {
15 struct Point {
16  union {
17  struct {
18  float x;
19  float y;
20  float z;
21  };
22  float u[3];
23  };
24 
25  Point() : x(0), y(0), z(0) {}
26 };
27 
28 class PointCloud : public std::vector<Point> {
29 public:
30  void computeBoundingBox(Point& bbMin, Point& bbMax) {
31  if (empty()) {
32  bbMin = bbMax = Point();
33  return;
34  }
35 
36  bbMin = bbMax = at(0);
37  for (std::size_t i = 1; i < size(); i++) {
38  const wl::Point& P = at(i);
39  for (int d = 0; d < 3; ++d) {
40  if (P.u[d] < bbMin.u[d]) {
41  bbMin.u[d] = P.u[d];
42  } else if (P.u[d] > bbMax.u[d]) {
43  bbMax.u[d] = P.u[d];
44  }
45  }
46  }
47  }
48 };
49 } // namespace wl
int size
void computeBoundingBox(Point &bbMin, Point &bbMax)
Definition: wlPointCloud.h:30
Rgb at(size_t color_id)
Point type.
Definition: wlPointCloud.h:15
float u[3]
Definition: wlPointCloud.h:22