OGS
SurfaceGrid.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <array>
7#include <limits>
8#include <optional>
9#include <vector>
10
11#include "AABB.h"
12#include "Point.h"
13
14namespace GeoLib
15{
16
17// forward declarations
18class Triangle;
19class Surface;
20
21class SurfaceGrid final : public AABB
22{
23public:
24 explicit SurfaceGrid(GeoLib::Surface const* const sfc);
26 MathLib::Point3d const& pnt,
27 double eps = std::numeric_limits<double>::epsilon()) const;
28
29private:
30 void sortTrianglesInGridCells(GeoLib::Surface const* const sfc);
31 bool sortTriangleInGridCells(GeoLib::Triangle const* const triangle);
32 std::optional<std::array<std::size_t, 3>> getGridCellCoordinates(
33 MathLib::Point3d const& p) const;
34 std::array<double, 3> _step_sizes{};
35 std::array<double, 3> _inverse_step_sizes{};
36 std::array<std::size_t, 3> _n_steps;
37 std::vector<std::vector<GeoLib::Triangle const*>> _triangles_in_grid_box;
38};
39
40} // end namespace GeoLib
AABB(std::vector< PNT_TYPE * > const &pnts, std::vector< std::size_t > const &ids)
Definition AABB.h:53
void sortTrianglesInGridCells(GeoLib::Surface const *const sfc)
std::vector< std::vector< GeoLib::Triangle const * > > _triangles_in_grid_box
Definition SurfaceGrid.h:37
bool isPointInSurface(MathLib::Point3d const &pnt, double eps=std::numeric_limits< double >::epsilon()) const
std::array< std::size_t, 3 > _n_steps
Definition SurfaceGrid.h:36
std::array< double, 3 > _inverse_step_sizes
Definition SurfaceGrid.h:35
bool sortTriangleInGridCells(GeoLib::Triangle const *const triangle)
SurfaceGrid(GeoLib::Surface const *const sfc)
std::optional< std::array< std::size_t, 3 > > getGridCellCoordinates(MathLib::Point3d const &p) const
std::array< double, 3 > _step_sizes
Definition SurfaceGrid.h:34
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
Definition Triangle.h:21