OGS

Detailed Description

A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points (_sfc_pnts) and a vector that stores the Triangles consisting of points from _sfc_pnts.

Definition at line 33 of file Surface.h.

#include <Surface.h>

Inheritance diagram for GeoLib::Surface:
[legend]
Collaboration diagram for GeoLib::Surface:
[legend]

Public Member Functions

 Surface (const std::vector< Point * > &pnt_vec)
 
 Surface (Surface const &src)
 
 ~Surface () override
 
 Surface (Surface &&src)=delete
 
Surfaceoperator= (Surface const &src)=delete
 
Surfaceoperator= (Surface &&src)=delete
 
GEOTYPE getGeoType () const override
 return a geometry type More...
 
void addTriangle (std::size_t pnt_a, std::size_t pnt_b, std::size_t pnt_c)
 
std::size_t getNumberOfTriangles () const
 
const Triangleoperator[] (std::size_t i) const
 const access operator for the access to the i-th Triangle of the surface. More...
 
bool isPntInBoundingVolume (MathLib::Point3d const &pnt, double eps) const
 
bool isPntInSfc (MathLib::Point3d const &pnt, double eps) const
 
const std::vector< Point * > * getPointVec () const
 
AABB const & getAABB () const
 
- Public Member Functions inherited from GeoLib::GeoObject
virtual ~GeoObject ()=default
 

Protected Attributes

const std::vector< Point * > & _sfc_pnts
 
std::vector< Triangle * > _sfc_triangles
 
std::unique_ptr< AABB_bounding_volume
 
std::unique_ptr< SurfaceGrid_surface_grid
 

Constructor & Destructor Documentation

◆ Surface() [1/3]

GeoLib::Surface::Surface ( const std::vector< Point * > &  pnt_vec)
explicit

Definition at line 24 of file Surface.cpp.

25  : _sfc_pnts(pnt_vec), _bounding_volume(nullptr), _surface_grid(nullptr)
26 {
27 }
std::unique_ptr< AABB > _bounding_volume
Definition: Surface.h:87
std::unique_ptr< SurfaceGrid > _surface_grid
Definition: Surface.h:92
const std::vector< Point * > & _sfc_pnts
Definition: Surface.h:83

◆ Surface() [2/3]

GeoLib::Surface::Surface ( Surface const &  src)

Definition at line 29 of file Surface.cpp.

30  : _sfc_pnts(src._sfc_pnts),
31  _bounding_volume(new AABB(*(src._bounding_volume))),
32  _surface_grid(nullptr)
33 {
34  _sfc_triangles.reserve(src._sfc_triangles.size());
35  std::transform(src._sfc_triangles.cbegin(),
36  src._sfc_triangles.cend(),
37  std::back_inserter(_sfc_triangles),
38  [](Triangle* t) { return new Triangle(*t); });
39 }
std::vector< Triangle * > _sfc_triangles
Definition: Surface.h:85
static const double t

References _sfc_triangles, and MathLib::t.

◆ ~Surface()

GeoLib::Surface::~Surface ( )
override

Definition at line 41 of file Surface.cpp.

42 {
43  for (auto& _sfc_triangle : _sfc_triangles)
44  {
45  delete _sfc_triangle;
46  }
47 }

References _sfc_triangles.

◆ Surface() [3/3]

GeoLib::Surface::Surface ( Surface &&  src)
delete

Member Function Documentation

◆ addTriangle()

void GeoLib::Surface::addTriangle ( std::size_t  pnt_a,
std::size_t  pnt_b,
std::size_t  pnt_c 
)

adds three indices describing a triangle and updates the bounding box

Definition at line 49 of file Surface.cpp.

52 {
53  assert(pnt_a < _sfc_pnts.size() && pnt_b < _sfc_pnts.size() &&
54  pnt_c < _sfc_pnts.size());
55 
56  // Check if two points of the triangle have identical IDs
57  if (pnt_a == pnt_b || pnt_a == pnt_c || pnt_b == pnt_c)
58  {
59  return;
60  }
61 
62  // Adding a new triangle invalides the surface grid.
63  _surface_grid.reset();
64 
65  _sfc_triangles.push_back(new Triangle(_sfc_pnts, pnt_a, pnt_b, pnt_c));
66  if (!_bounding_volume)
67  {
68  std::vector<std::size_t> ids(3);
69  ids[0] = pnt_a;
70  ids[1] = pnt_b;
71  ids[2] = pnt_c;
72  _bounding_volume = std::make_unique<GeoLib::AABB>(_sfc_pnts, ids);
73  }
74  else
75  {
76  _bounding_volume->update(*_sfc_pnts[pnt_a]);
77  _bounding_volume->update(*_sfc_pnts[pnt_b]);
78  _bounding_volume->update(*_sfc_pnts[pnt_c]);
79  }
80 }

References _bounding_volume, _sfc_pnts, _sfc_triangles, and _surface_grid.

Referenced by anonymous_namespace{convertMeshToGeo.cpp}::addElementToSurface().

◆ getAABB()

AABB const& GeoLib::Surface::getAABB ( ) const
inline

method allows access to the internal axis aligned bounding box

Returns
axis aligned bounding box

Definition at line 79 of file Surface.h.

79 { return *_bounding_volume; }

References _bounding_volume.

◆ getGeoType()

GEOTYPE GeoLib::Surface::getGeoType ( ) const
inlineoverridevirtual

return a geometry type

Implements GeoLib::GeoObject.

Definition at line 45 of file Surface.h.

45 { return GEOTYPE::SURFACE; }

References GeoLib::SURFACE.

◆ getNumberOfTriangles()

std::size_t GeoLib::Surface::getNumberOfTriangles ( ) const

◆ getPointVec()

const std::vector<Point*>* GeoLib::Surface::getPointVec ( ) const
inline

Definition at line 74 of file Surface.h.

74 { return &_sfc_pnts; }

References _sfc_pnts.

◆ isPntInBoundingVolume()

bool GeoLib::Surface::isPntInBoundingVolume ( MathLib::Point3d const &  pnt,
double  eps 
) const

is the given point in the bounding volume of the surface

Definition at line 93 of file Surface.cpp.

95 {
96  return _bounding_volume->containsPoint(pnt, eps);
97 }

References _bounding_volume.

Referenced by MeshGeoToolsLib::MeshNodesAlongSurface::MeshNodesAlongSurface().

◆ isPntInSfc()

bool GeoLib::Surface::isPntInSfc ( MathLib::Point3d const &  pnt,
double  eps 
) const

is the given point pnt located in the surface

Parameters
pntthe point
epsgeometric tolerance for the search
Returns
true if the point is contained in the surface

Definition at line 99 of file Surface.cpp.

100 {
101  // Mutable _surface_grid is constructed if method is called the first time.
102  if (_surface_grid == nullptr)
103  {
104  _surface_grid = std::make_unique<GeoLib::SurfaceGrid>(this);
105  }
106  return _surface_grid->isPointInSurface(pnt, eps);
107 }

References _surface_grid.

Referenced by MeshGeoToolsLib::MeshNodesAlongSurface::MeshNodesAlongSurface().

◆ operator=() [1/2]

Surface& GeoLib::Surface::operator= ( Surface &&  src)
delete

◆ operator=() [2/2]

Surface& GeoLib::Surface::operator= ( Surface const &  src)
delete

◆ operator[]()

const Triangle * GeoLib::Surface::operator[] ( std::size_t  i) const

const access operator for the access to the i-th Triangle of the surface.

Definition at line 87 of file Surface.cpp.

88 {
89  assert(i < _sfc_triangles.size());
90  return _sfc_triangles[i];
91 }

References _sfc_triangles.

Member Data Documentation

◆ _bounding_volume

std::unique_ptr<AABB> GeoLib::Surface::_bounding_volume
protected

bounding volume is an axis aligned bounding box

Definition at line 87 of file Surface.h.

Referenced by addTriangle(), getAABB(), and isPntInBoundingVolume().

◆ _sfc_pnts

const std::vector<Point*>& GeoLib::Surface::_sfc_pnts
protected

a vector of pointers to Points

Definition at line 83 of file Surface.h.

Referenced by addTriangle(), and getPointVec().

◆ _sfc_triangles

std::vector<Triangle*> GeoLib::Surface::_sfc_triangles
protected

position of pointers to the geometric points

Definition at line 85 of file Surface.h.

Referenced by Surface(), ~Surface(), addTriangle(), getNumberOfTriangles(), and operator[]().

◆ _surface_grid

std::unique_ptr<SurfaceGrid> GeoLib::Surface::_surface_grid
mutableprotected

The surface grid is a helper data structure to accelerate the point search. The method addTriangle() invalidates/resets the surface grid. A valid surface grid is created in case the const method isPntInSfc() is called and a valid surface grid is not existing.

Definition at line 92 of file Surface.h.

Referenced by addTriangle(), and isPntInSfc().


The documentation for this class was generated from the following files: