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

Removed compile time dependencies deploying forward declaration in class GMSHAdaptiveMeshDensity.

parent 3fce6e30
No related branches found
No related tags found
No related merge requests found
...@@ -20,11 +20,14 @@ ...@@ -20,11 +20,14 @@
// GeoLib // GeoLib
#include "Polygon.h" #include "Polygon.h"
#ifndef NDEBUG
#include "Polyline.h"
#endif
namespace FileIO namespace FileIO
{ {
GMSHAdaptiveMeshDensity::GMSHAdaptiveMeshDensity(double pnt_density, double station_density, GMSHAdaptiveMeshDensity::GMSHAdaptiveMeshDensity(double pnt_density, double station_density,
size_t max_pnts_per_leaf) : std::size_t max_pnts_per_leaf) :
_pnt_density(pnt_density), _station_density(station_density), _pnt_density(pnt_density), _station_density(station_density),
_max_pnts_per_leaf(max_pnts_per_leaf), _quad_tree(NULL) _max_pnts_per_leaf(max_pnts_per_leaf), _quad_tree(NULL)
{ {
...@@ -41,12 +44,12 @@ void GMSHAdaptiveMeshDensity::init(std::vector<GeoLib::Point const*> const& pnts ...@@ -41,12 +44,12 @@ void GMSHAdaptiveMeshDensity::init(std::vector<GeoLib::Point const*> const& pnts
DBUG("GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box (2D) for quadtree."); DBUG("GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box (2D) for quadtree.");
GeoLib::Point min(pnts[0]->getCoords()), max(pnts[0]->getCoords()); GeoLib::Point min(pnts[0]->getCoords()), max(pnts[0]->getCoords());
size_t n_pnts(pnts.size()); std::size_t n_pnts(pnts.size());
for (size_t k(1); k<n_pnts; k++) { for (std::size_t k(1); k<n_pnts; k++) {
for (size_t j(0); j < 2; j++) for (std::size_t j(0); j < 2; j++)
if ((*(pnts[k]))[j] < min[j]) if ((*(pnts[k]))[j] < min[j])
min[j] = (*(pnts[k]))[j]; min[j] = (*(pnts[k]))[j];
for (size_t j(0); j < 2; j++) for (std::size_t j(0); j < 2; j++)
if ((*(pnts[k]))[j] > max[j]) if ((*(pnts[k]))[j] > max[j])
max[j] = (*(pnts[k]))[j]; max[j] = (*(pnts[k]))[j];
} }
...@@ -66,9 +69,9 @@ void GMSHAdaptiveMeshDensity::init(std::vector<GeoLib::Point const*> const& pnts ...@@ -66,9 +69,9 @@ void GMSHAdaptiveMeshDensity::init(std::vector<GeoLib::Point const*> const& pnts
void GMSHAdaptiveMeshDensity::addPoints(std::vector<GeoLib::Point const*> const& pnts) void GMSHAdaptiveMeshDensity::addPoints(std::vector<GeoLib::Point const*> const& pnts)
{ {
// *** QuadTree - insert points // *** QuadTree - insert points
const size_t n_pnts(pnts.size()); const std::size_t n_pnts(pnts.size());
DBUG("GMSHAdaptiveMeshDensity::addPoints(): Inserting %d points into quadtree.", n_pnts); DBUG("GMSHAdaptiveMeshDensity::addPoints(): Inserting %d points into quadtree.", n_pnts);
for (size_t k(0); k < n_pnts; k++) for (std::size_t k(0); k < n_pnts; k++)
_quad_tree->addPoint(pnts[k]); _quad_tree->addPoint(pnts[k]);
DBUG("GMSHAdaptiveMeshDensity::addPoints(): \tok."); DBUG("GMSHAdaptiveMeshDensity::addPoints(): \tok.");
_quad_tree->balance(); _quad_tree->balance();
...@@ -85,14 +88,14 @@ double GMSHAdaptiveMeshDensity::getMeshDensityAtStation(GeoLib::Point const* con ...@@ -85,14 +88,14 @@ double GMSHAdaptiveMeshDensity::getMeshDensityAtStation(GeoLib::Point const* con
{ {
GeoLib::Point ll, ur; GeoLib::Point ll, ur;
_quad_tree->getLeaf(*pnt, ll, ur); _quad_tree->getLeaf(*pnt, ll, ur);
return (_station_density * (ur[0] - ll[0])); return _station_density * (ur[0] - ll[0]);
} }
void GMSHAdaptiveMeshDensity::getSteinerPoints (std::vector<GeoLib::Point*> & pnts, void GMSHAdaptiveMeshDensity::getSteinerPoints (std::vector<GeoLib::Point*> & pnts,
size_t additional_levels) const std::size_t additional_levels) const
{ {
// get Steiner points // get Steiner points
size_t max_depth(0); std::size_t max_depth(0);
_quad_tree->getMaxDepth(max_depth); _quad_tree->getMaxDepth(max_depth);
std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list; std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
...@@ -107,10 +110,10 @@ void GMSHAdaptiveMeshDensity::getSteinerPoints (std::vector<GeoLib::Point*> & pn ...@@ -107,10 +110,10 @@ void GMSHAdaptiveMeshDensity::getSteinerPoints (std::vector<GeoLib::Point*> & pn
if ((*it)->getDepth() + additional_levels > max_depth) { if ((*it)->getDepth() + additional_levels > max_depth) {
additional_levels = max_depth - (*it)->getDepth(); additional_levels = max_depth - (*it)->getDepth();
} }
const size_t n_pnts_per_quad_dim (MathLib::fastpow(2, additional_levels)); const std::size_t n_pnts_per_quad_dim (MathLib::fastpow(2, additional_levels));
const double delta ((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim)); const double delta ((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
for (size_t i(0); i<n_pnts_per_quad_dim; i++) { for (std::size_t i(0); i<n_pnts_per_quad_dim; i++) {
for (size_t j(0); j<n_pnts_per_quad_dim; j++) { for (std::size_t j(0); j<n_pnts_per_quad_dim; j++) {
pnts.push_back(new GeoLib::Point (ll[0] + (2*i+1) * delta, ll[1] + (2*j+1) * delta, 0.0)); pnts.push_back(new GeoLib::Point (ll[0] + (2*i+1) * delta, ll[1] + (2*j+1) * delta, 0.0));
} }
} }
...@@ -121,7 +124,7 @@ void GMSHAdaptiveMeshDensity::getSteinerPoints (std::vector<GeoLib::Point*> & pn ...@@ -121,7 +124,7 @@ void GMSHAdaptiveMeshDensity::getSteinerPoints (std::vector<GeoLib::Point*> & pn
#ifndef NDEBUG #ifndef NDEBUG
void GMSHAdaptiveMeshDensity::getQuadTreeGeometry(std::vector<GeoLib::Point*> &pnts, void GMSHAdaptiveMeshDensity::getQuadTreeGeometry(std::vector<GeoLib::Point*> &pnts,
std::vector<GeoLib::Polyline*> &plys) const std::vector<GeoLib::Polyline*> &plys) const
{ {
std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list; std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
_quad_tree->getLeafs(leaf_list); _quad_tree->getLeafs(leaf_list);
...@@ -131,7 +134,7 @@ void GMSHAdaptiveMeshDensity::getQuadTreeGeometry(std::vector<GeoLib::Point*> &p ...@@ -131,7 +134,7 @@ void GMSHAdaptiveMeshDensity::getQuadTreeGeometry(std::vector<GeoLib::Point*> &p
// fetch corner points from leaf // fetch corner points from leaf
GeoLib::Point *ll(new GeoLib::Point), *ur(new GeoLib::Point); GeoLib::Point *ll(new GeoLib::Point), *ur(new GeoLib::Point);
(*it)->getSquarePoints(*ll, *ur); (*it)->getSquarePoints(*ll, *ur);
size_t pnt_offset (pnts.size()); std::size_t pnt_offset (pnts.size());
pnts.push_back(ll); pnts.push_back(ll);
pnts.push_back(new GeoLib::Point((*ur)[0], (*ll)[1], 0.0)); pnts.push_back(new GeoLib::Point((*ur)[0], (*ll)[1], 0.0));
pnts.push_back(ur); pnts.push_back(ur);
......
...@@ -18,27 +18,33 @@ ...@@ -18,27 +18,33 @@
// GeoLib // GeoLib
#include "Point.h" #include "Point.h"
#include "QuadTree.h" #include "QuadTree.h"
#ifndef NDEBUG
#include "Polyline.h"
#endif
namespace GeoLib { namespace GeoLib
{
class Polygon; class Polygon;
#ifndef NDEBUG
class Polyline;
#endif
} }
namespace FileIO { namespace FileIO
{
class GMSHAdaptiveMeshDensity: public GMSHMeshDensityStrategy { class GMSHAdaptiveMeshDensity : public GMSHMeshDensityStrategy
{
public: public:
GMSHAdaptiveMeshDensity(double pnt_density, double station_density, std::size_t max_pnts_per_leaf); GMSHAdaptiveMeshDensity(double pnt_density,
double station_density,
std::size_t max_pnts_per_leaf);
virtual ~GMSHAdaptiveMeshDensity(); virtual ~GMSHAdaptiveMeshDensity();
void init(std::vector<GeoLib::Point const*> const& pnts); void init(std::vector<GeoLib::Point const*> const& pnts);
double getMeshDensityAtPoint(GeoLib::Point const*const pnt) const; double getMeshDensityAtPoint(GeoLib::Point const* const pnt) const;
void addPoints(std::vector<GeoLib::Point const*> const& pnts); void addPoints(std::vector<GeoLib::Point const*> const& pnts);
double getMeshDensityAtStation(GeoLib::Point const*const) const; double getMeshDensityAtStation(GeoLib::Point const* const) const;
void getSteinerPoints (std::vector<GeoLib::Point*> & pnts, std::size_t additional_levels = 0) const; void getSteinerPoints (std::vector<GeoLib::Point*> & pnts,
std::size_t additional_levels = 0) const;
#ifndef NDEBUG #ifndef NDEBUG
void getQuadTreeGeometry(std::vector<GeoLib::Point*> &pnts, std::vector<GeoLib::Polyline*> &plys) const; void getQuadTreeGeometry(std::vector<GeoLib::Point*> &pnts,
std::vector<GeoLib::Polyline*> &plys) const;
#endif #endif
private: private:
...@@ -47,7 +53,6 @@ private: ...@@ -47,7 +53,6 @@ private:
std::size_t _max_pnts_per_leaf; std::size_t _max_pnts_per_leaf;
GeoLib::QuadTree<GeoLib::Point> *_quad_tree; GeoLib::QuadTree<GeoLib::Point> *_quad_tree;
}; };
} // end namespace FileIO } // end namespace FileIO
#endif /* GMSHADAPTIVEMESHDENSITY_H_ */ #endif /* GMSHADAPTIVEMESHDENSITY_H_ */
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