Skip to content
Snippets Groups Projects
Commit 46fcc1b1 authored by Tom Fischer's avatar Tom Fischer
Browse files

[GL/Grid] Return result directly instead of using input/output parameter.

parent e75c84b4
No related branches found
No related tags found
No related merge requests found
......@@ -95,10 +95,9 @@ public:
getPntVecsOfGridCellsIntersectingCube(P const& center,
double half_len) const;
void getPntVecsOfGridCellsIntersectingCuboid(
Eigen::Vector3d const& min_pnt,
Eigen::Vector3d const& max_pnt,
std::vector<std::vector<POINT*> const*>& pnts) const;
std::vector<std::vector<POINT*> const*>
getPntVecsOfGridCellsIntersectingCuboid(
Eigen::Vector3d const& min_pnt, Eigen::Vector3d const& max_pnt) const;
#ifndef NDEBUG
/**
......@@ -253,11 +252,16 @@ std::vector<std::vector<POINT*> const*>
Grid<POINT>::getPntVecsOfGridCellsIntersectingCube(P const& center,
double half_len) const
{
std::vector<std::vector<POINT*> const*> pnts;
Eigen::Vector3d const c{center[0], center[1], center[2]};
std::array<std::size_t, 3> min_coords(getGridCoords(c.array() - half_len));
std::array<std::size_t, 3> max_coords(getGridCoords(c.array() + half_len));
std::vector<std::vector<POINT*> const*> pnts;
pnts.reserve(
(Eigen::Map<Eigen::Matrix<std::size_t, 3, 1>>(max_coords.data()) -
Eigen::Map<Eigen::Matrix<std::size_t, 3, 1>>(min_coords.data()))
.prod());
std::size_t const steps0_x_steps1(_n_steps[0] * _n_steps[1]);
for (std::size_t c0 = min_coords[0]; c0 < max_coords[0] + 1; c0++)
{
......@@ -276,14 +280,15 @@ Grid<POINT>::getPntVecsOfGridCellsIntersectingCube(P const& center,
}
template <typename POINT>
void Grid<POINT>::getPntVecsOfGridCellsIntersectingCuboid(
Eigen::Vector3d const& min_pnt,
Eigen::Vector3d const& max_pnt,
std::vector<std::vector<POINT*> const*>& pnts) const
std::vector<std::vector<POINT*> const*>
Grid<POINT>::getPntVecsOfGridCellsIntersectingCuboid(
Eigen::Vector3d const& min_pnt, Eigen::Vector3d const& max_pnt) const
{
std::array<std::size_t, 3> min_coords(getGridCoords(min_pnt));
std::array<std::size_t, 3> max_coords(getGridCoords(max_pnt));
std::vector<std::vector<POINT*> const*> pnts;
std::size_t const steps0_x_steps1(_n_steps[0] * _n_steps[1]);
for (std::size_t c0 = min_coords[0]; c0 < max_coords[0] + 1; c0++)
{
......@@ -298,6 +303,7 @@ void Grid<POINT>::getPntVecsOfGridCellsIntersectingCuboid(
}
}
}
return pnts;
}
#ifndef NDEBUG
......
......@@ -116,9 +116,9 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(
dest_element.getNodes() + dest_element.getNumberOfBaseNodes());
// request "interesting" nodes from grid
std::vector<std::vector<MeshLib::Node*> const*> nodes;
src_grid.getPntVecsOfGridCellsIntersectingCuboid(
elem_aabb.getMinPoint(), elem_aabb.getMaxPoint(), nodes);
std::vector<std::vector<MeshLib::Node*> const*> const nodes =
src_grid.getPntVecsOfGridCellsIntersectingCuboid(
elem_aabb.getMinPoint(), elem_aabb.getMaxPoint());
std::size_t cnt(0);
double average_value(0.0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment