32 double station_density,
33 std::size_t max_pnts_per_leaf)
34 : _pnt_density(pnt_density),
35 _station_density(station_density),
36 _max_pnts_per_leaf(max_pnts_per_leaf),
47 std::vector<GeoLib::Point const*>
const& pnts)
51 "GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box "
52 "(2D) for quadtree.");
56 std::size_t n_pnts(pnts.size());
57 for (std::size_t k(1); k < n_pnts; k++)
59 for (std::size_t j(0); j < 2; j++)
61 if ((*(pnts[k]))[j] < min[j])
63 min[j] = (*(pnts[k]))[j];
66 for (std::size_t j(0); j < 2; j++)
68 if ((*(pnts[k]))[j] > max[j])
70 max[j] = (*(pnts[k]))[j];
76 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok");
79 DBUG(
"GMSHAdaptiveMeshDensity::init(): Creating quadtree.");
82 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok.");
89 std::vector<GeoLib::Point const*>
const& pnts)
92 const std::size_t n_pnts(pnts.size());
94 "GMSHAdaptiveMeshDensity::addPoints(): Inserting {:d} points into "
97 for (std::size_t k(0); k < n_pnts; k++)
101 DBUG(
"GMSHAdaptiveMeshDensity::addPoints(): \tok.");
124 std::vector<GeoLib::Point*>& pnts, std::size_t additional_levels)
const
127 std::size_t max_depth(0);
130 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
135 it != leaf_list.end();
138 if ((*it)->getPoints().empty())
143 (*it)->getSquarePoints(ll, ur);
144 if ((*it)->getDepth() + additional_levels > max_depth)
146 additional_levels = max_depth - (*it)->getDepth();
148 const std::size_t n_pnts_per_quad_dim =
static_cast<std::size_t
>(1)
149 << additional_levels;
150 const double delta((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
151 for (std::size_t i(0); i < n_pnts_per_quad_dim; i++)
153 for (std::size_t j(0); j < n_pnts_per_quad_dim; j++)
156 ll[0] + (2 * i + 1) * delta,
157 ll[1] + (2 * j + 1) * delta, 0.0, pnts.size()));
166 std::vector<GeoLib::Point*>& pnts,
167 std::vector<GeoLib::Polyline*>& plys)
const
169 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
174 it != leaf_list.end();
180 (*it)->getSquarePoints(ll, ur);
181 std::size_t
const pnt_offset(pnts.size());
183 pnts.push_back(
new GeoLib::Point(ur[0], ll[1], 0.0, pnt_offset + 1));
185 pnts.push_back(
new GeoLib::Point(ll[0], ur[1], 0.0, pnt_offset + 3));
187 plys[plys.size() - 1]->addPoint(pnt_offset);
188 plys[plys.size() - 1]->addPoint(pnt_offset + 1);
189 plys[plys.size() - 1]->addPoint(pnt_offset + 2);
190 plys[plys.size() - 1]->addPoint(pnt_offset + 3);
191 plys[plys.size() - 1]->addPoint(pnt_offset);
Definition of the Point class.
void DBUG(char const *fmt, Args const &... args)
Definition of the Polygon class.
Definition of the PolyLine class.
Definition of the QuadTree class.
double getMeshDensityAtPoint(GeoLib::Point const *const pnt) const override
double getMeshDensityAtStation(GeoLib::Point const *const) const override
~GMSHAdaptiveMeshDensity() override
void getQuadTreeGeometry(std::vector< GeoLib::Point * > &pnts, std::vector< GeoLib::Polyline * > &plys) const
void getSteinerPoints(std::vector< GeoLib::Point * > &pnts, std::size_t additional_levels=0) const
void initialize(std::vector< GeoLib::Point const * > const &pnts) override
GMSHAdaptiveMeshDensity(double pnt_density, double station_density, std::size_t max_pnts_per_leaf)
std::size_t _max_pnts_per_leaf
void addPoints(std::vector< GeoLib::Point const * > const &pnts)
GeoLib::QuadTree< GeoLib::Point > * _quad_tree
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
void getMaxDepth(std::size_t &max_depth) const
void getLeafs(std::list< QuadTree< POINT > * > &leaf_list)
void getLeaf(const POINT &pnt, POINT &ll, POINT &ur)
bool addPoint(POINT const *pnt)