diff --git a/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp b/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..37809ccd550b58c905988dd7dc24546340e8d243 --- /dev/null +++ b/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp @@ -0,0 +1,41 @@ +/** + * @copyright + * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt + */ + +#include "BoundaryElementsAtPoint.h" + +#include "GeoLib/Point.h" +#include "MeshLib/Elements/Element.h" +#include "MeshLib/Elements/Point.h" +#include "MeshLib/Mesh.h" +#include "MeshLib/MeshSearch/ElementSearch.h" +#include "MeshLib/Node.h" + +#include "MeshGeoToolsLib/MeshNodeSearcher.h" + +namespace MeshGeoToolsLib +{ +BoundaryElementsAtPoint::BoundaryElementsAtPoint( + MeshLib::Mesh const &mesh, MeshNodeSearcher &mshNodeSearcher, + GeoLib::Point const &point) + : _mesh(mesh), _point(point) +{ + auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point); + assert(node_ids.size() == 1); + std::array<MeshLib::Node*, 1> const nodes = {{ + const_cast<MeshLib::Node*>(_mesh.getNode(node_ids[0]))}}; + + _boundary_elements.push_back(new MeshLib::Point{nodes, 0, node_ids[0]}); +} + +BoundaryElementsAtPoint::~BoundaryElementsAtPoint() +{ + for (auto p : _boundary_elements) + delete p; +} + +} // MeshGeoToolsLib diff --git a/MeshGeoToolsLib/BoundaryElementsAtPoint.h b/MeshGeoToolsLib/BoundaryElementsAtPoint.h new file mode 100644 index 0000000000000000000000000000000000000000..0a407278fd5cf644afab169fcad08fad749bfd1d --- /dev/null +++ b/MeshGeoToolsLib/BoundaryElementsAtPoint.h @@ -0,0 +1,68 @@ +/** + * @copyright + * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt + */ + +#ifndef BOUNDARYELEMENTSATPOINT_H_ +#define BOUNDARYELEMENTSATPOINT_H_ + +#include <vector> + +namespace GeoLib +{ +class Point; +} + +namespace MeshLib +{ +class Mesh; +class Element; +} + +namespace MeshGeoToolsLib +{ +class MeshNodeSearcher; + +/// This class collects point elements located at a given point elements. +class BoundaryElementsAtPoint final +{ +public: + /// Constructor + /// \param mesh a mesh object + /// \param mshNodeSearcher a MeshNodeSearcher object which is internally + /// used to search mesh nodes + /// \param point a point object where edges are searched + BoundaryElementsAtPoint(MeshLib::Mesh const& mesh, + MeshNodeSearcher& mshNodeSearcher, + GeoLib::Point const& point); + + ~BoundaryElementsAtPoint(); + + MeshLib::Mesh const& getMesh() const + { + return _mesh; + } + + GeoLib::Point const& getPoint() const + { + return _point; + } + + /// Return the vector of boundary elements (i.e. points). + std::vector<MeshLib::Element*> const& getBoundaryElements() const + { + return _boundary_elements; + } + +private: + MeshLib::Mesh const& _mesh; + GeoLib::Point const& _point; + std::vector<MeshLib::Element*> _boundary_elements; +}; + +} // end namespace MeshGeoToolsLib + +#endif // BOUNDARYELEMENTSATPOINT_H_