ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Cloud.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 "ml/contrib/Cloud.h"
9 
10 namespace cloudViewer {
11 namespace ml {
12 namespace contrib {
13 
14 static_assert(std::is_standard_layout<PointXYZ>::value &&
15  std::is_trivial<PointXYZ>::value,
16  "PointXYZ class must be a StandardLayout and TrivialType type.");
17 
18 // Getters
19 // *******
20 
21 PointXYZ max_point(std::vector<PointXYZ> points) {
22  // Initialize limits
23  PointXYZ maxP(points[0]);
24 
25  // Loop over all points
26  for (auto p : points) {
27  if (p.x > maxP.x) maxP.x = p.x;
28 
29  if (p.y > maxP.y) maxP.y = p.y;
30 
31  if (p.z > maxP.z) maxP.z = p.z;
32  }
33 
34  return maxP;
35 }
36 
37 PointXYZ min_point(std::vector<PointXYZ> points) {
38  // Initialize limits
39  PointXYZ minP(points[0]);
40 
41  // Loop over all points
42  for (auto p : points) {
43  if (p.x < minP.x) minP.x = p.x;
44 
45  if (p.y < minP.y) minP.y = p.y;
46 
47  if (p.z < minP.z) minP.z = p.z;
48  }
49 
50  return minP;
51 }
52 
53 } // namespace contrib
54 } // namespace ml
55 } // namespace cloudViewer
int points
PointXYZ min_point(std::vector< PointXYZ > points)
Definition: Cloud.cpp:37
PointXYZ max_point(std::vector< PointXYZ > points)
Definition: Cloud.cpp:21
Generic file read and write utility for python interface.