OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
point_cloud.cpp
Go to the documentation of this file.
1// OpenBEM - Copyright (C) 2026 Shashwat Sharma
2
3// This file is part of OpenBEM.
4
5// OpenBEM is free software: you can redistribute it and/or modify it under the terms of the
6// GNU General Public License as published by the Free Software Foundation, either version 3
7// of the License, or (at your option) any later version.
8
9// You should have received a copy of the GNU General Public License along with OpenBEM.
10// If not, see <https://www.gnu.org/licenses/>.
11
12
19
20#include <vector>
21
22#include "types.hpp"
24
25
26namespace bem
27{
28
29template <uint8_t dim>
41
42
43template <uint8_t dim>
48 )
49{
52 std::vector<EigRowVec<Float>> dim_points (dim);
53 std::vector<Index> counters (dim);
54
55 for (uint8_t ii = 0; ii < dim; ++ii)
56 {
58 dim_points[ii] = (diff[ii] * ref_points).array() + start[ii];
59 }
60
61 Index idx = 0;
62 while (counters[0] != num_pts[0])
63 {
64 for (uint8_t ii = 0; ii < dim; ++ii)
65 points(ii, idx) = dim_points[ii][counters[ii]];
66 idx++;
67
68 ++counters[dim - 1];
69 for (uint8_t ii = dim - 1; (ii > 0) && (counters[ii] == num_pts[ii]); --ii)
70 {
71 counters[ii] = 0;
72 ++counters[ii - 1];
73 }
74 }
75
76 set_data(points);
77
78 return;
79}
80
81
82template <uint8_t dim>
88 )
89{
90 set_block_data(start, stop, num_pts);
91 points_ = GeometryOps<dim>::polar_to_cartesian(points_).colwise() - center;
92 return;
93}
94
95
96template <uint8_t dim>
98{
99 points_ = points;
100 return;
101};
102
103
104template <uint8_t dim>
106{
107 points_.resize(dim, 0);
108 return;
109};
110
112template class PointCloud<2>;
113template class PointCloud<3>;
114
115}
static EigMatNX< Float, dim > polar_to_cartesian(ConstEigRef< EigMatNX< Float, dim > > points)
Transforms polar (2D) or spherical (3D) coordinates to Cartesian.
void clear_data()
Clears the point cloud data.
void set_line_data(ConstEigRef< EigColVecN< Float, dim > > start, ConstEigRef< EigColVecN< Float, dim > > stop, const Index num_pts)
Sets PointCloud data as points along a straight line.
void set_block_data(ConstEigRef< EigColVecN< Float, dim > > start, ConstEigRef< EigColVecN< Float, dim > > stop, ConstEigRef< EigColVecN< Index, dim > > num_pts)
Sets PointCloud data as a block of points.
void set_data(ConstEigRef< EigMatNX< Float, dim > > points)
Sets the point cloud data.
void set_polar_data(ConstEigRef< EigColVecN< Float, dim > > start, ConstEigRef< EigColVecN< Float, dim > > stop, ConstEigRef< EigColVecN< Float, dim > > center, ConstEigRef< EigColVecN< Index, dim > > num_pts)
Sets PointCloud data as points of a polar grid.
const Eigen::Ref< const EigObj > ConstEigRef
Read-only reference to an Eigen object.
Definition types.hpp:98
Eigen::Matrix< T, 1, Eigen::Dynamic > EigRowVec
Dynamic-size row vector containing type T.
Definition types.hpp:90
Eigen::Matrix< T, N, 1 > EigColVecN
Fixed-size column vector of size N containing type T.
Definition types.hpp:86
Eigen::Matrix< T, N, Eigen::Dynamic > EigMatNX
Fixed-height matrix with N rows containing type T.
Definition types.hpp:78
std::size_t Index
Unsigned integer type for indices and container sizes.
Definition types.hpp:54
Primary namespace for the OpenBEM library.
Definition constants.hpp:31