OGS
SurfaceGrid.h
Go to the documentation of this file.
1 /*
2  * \date 2012-09-22
3  * \brief Declaration of the SurfaceGrid class.
4  *
5  * \file
6  * \copyright
7  * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
8  * Distributed under a Modified BSD License.
9  * See accompanying file LICENSE.txt or
10  * http://www.opengeosys.org/project/license
11  */
12 
13 #pragma once
14 
15 #include <array>
16 #include <limits>
17 #include <optional>
18 #include <vector>
19 
20 #include "AABB.h"
21 #include "Point.h"
22 
23 namespace GeoLib {
24 
25 // forward declarations
26 class Triangle;
27 class Surface;
28 
29 class SurfaceGrid final : public AABB {
30 public:
31  explicit SurfaceGrid(GeoLib::Surface const*const sfc);
32  bool isPointInSurface(MathLib::Point3d const & pnt,
33  double eps = std::numeric_limits<double>::epsilon()) const;
34 
35 private:
36  void sortTrianglesInGridCells(GeoLib::Surface const* const sfc);
37  bool sortTriangleInGridCells(GeoLib::Triangle const*const triangle);
38  std::optional<std::array<std::size_t, 3>> getGridCellCoordinates(
39  MathLib::Point3d const& p) const;
40  std::array<double,3> _step_sizes{};
41  std::array<double,3> _inverse_step_sizes{};
42  std::array<std::size_t,3> _n_steps;
43  std::vector<std::vector<GeoLib::Triangle const*>> _triangles_in_grid_box;
44 };
45 
46 } // end namespace GeoLib
Definition of the AABB class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:49
void sortTrianglesInGridCells(GeoLib::Surface const *const sfc)
std::vector< std::vector< GeoLib::Triangle const * > > _triangles_in_grid_box
Definition: SurfaceGrid.h:43
std::array< double, 3 > _step_sizes
Definition: SurfaceGrid.h:40
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:42
std::array< double, 3 > _inverse_step_sizes
Definition: SurfaceGrid.h:41
bool sortTriangleInGridCells(GeoLib::Triangle const *const triangle)
SurfaceGrid(GeoLib::Surface const *const sfc)
Definition: SurfaceGrid.cpp:25
std::optional< std::array< std::size_t, 3 > > getGridCellCoordinates(MathLib::Point3d const &p) const
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
Definition: Surface.h:34
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
Definition: Triangle.h:26