RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
bbox3d.h
1//
2// Created by RainSure on 2023/10/26.
3//
4
5#ifndef RSMESH_BBOX3D_H
6#define RSMESH_BBOX3D_H
7
8#include "point3d.h"
9#include "common/macros.h"
10
11namespace rsmesh {
12 namespace geometry {
13
14 class bbox3d {
15 public:
16 bbox3d();
17
18 bbox3d(const point3d& min, const point3d &max);
19
20 bool operator== (const bbox3d& rhs) const;
21
22 [[nodiscard]] point3d center() const;
23
24 [[nodiscard]] bool contains(const point3d& p) const;
25
26 [[nodiscard]] bbox3d convex_hull(const bbox3d& other) const;
27
28 [[nodiscard]] const point3d& max() const;
29
30 [[nodiscard]] const point3d& min() const;
31
32 [[nodiscard]] vector3d size() const;
33
34 [[nodiscard]] bbox3d transform(const linear_transformation3d& t) const;
35
36 [[nodiscard]] bbox3d union_hull(const bbox3d& other) const;
37
38 // static bbox3d from_points(const points3d& points);
39
40
41 template<class InputIterator>
42 static bbox3d from_points(InputIterator points_begin, InputIterator points_end) {
43 bbox3d result;
44 if(points_begin == points_end) return result;
45 auto it = points_begin;
46 auto first_point = *it;
47 result.min_(0) = result.max_(0) = first_point(0);
48 result.min_(1) = result.max_(1) = first_point(1);
49 result.min_(2) = result.max_(2) = first_point(2);
50
51 for( ; it != points_end; it ++) {
52 auto point = *it;
53 result.min_(0) = std::min(result.min_(0), point(0));
54 result.min_(1) = std::min(result.min_(1), point(1));
55 result.min_(2) = std::min(result.min_(2), point(2));
56 result.max_(0) = std::max(result.max_(0), point(0));
57 result.max_(1) = std::max(result.max_(1), point(1));
58 result.max_(2) = std::max(result.max_(2), point(2));
59 }
60
61 return result;
62 }
63
64 template <class Derived>
65 static bbox3d from_points(const Eigen::MatrixBase<Derived>& points) {
66 if (points.rows() == 0) {
67 return {};
68 }
69
70 return {points.colwise().minCoeff(), points.colwise().maxCoeff()};
71 }
72
73 private:
74 point3d min_;
75 point3d max_;
76 };
77
78 } // rsmesh
79} // geometry
80
81#endif //RSMESH_BBOX3D_H
bool contains(const point3d &p) const
Definition bbox3d.cpp:48
bbox3d()
bbox3d类的默认构造函数
Definition bbox3d.cpp:16
bool operator==(const bbox3d &rhs) const
重载了==运算符,用于判断两个bbox3d是否相等
Definition bbox3d.cpp:31
bbox3d convex_hull(const bbox3d &other) const
Definition bbox3d.cpp:60
point3d center() const
返回包围盒的中心点
Definition bbox3d.cpp:39
vector3d point3d
3维点
Definition point3d.h:39
Eigen::Matrix< double, 3, 3, Eigen::RowMajor > linear_transformation3d
线性变换矩阵
Definition point3d.h:53
Eigen::RowVector3d vector3d
3维向量
Definition point3d.h:30
本系统的主命名空间,包含了common, examples, fmm, geometry, numeric, point_cloud等子命名空间