33 double station_density,
34 std::size_t max_pnts_per_leaf)
35 : _pnt_density(pnt_density),
36 _station_density(station_density),
37 _max_pnts_per_leaf(max_pnts_per_leaf),
48 std::vector<GeoLib::Point const*>
const& pnts)
52 "GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box "
53 "(2D) for quadtree.");
57 std::size_t n_pnts(pnts.size());
58 for (std::size_t k(1); k < n_pnts; k++)
60 for (std::size_t j(0); j < 2; j++)
62 if ((*(pnts[k]))[j] < min[j])
64 min[j] = (*(pnts[k]))[j];
67 for (std::size_t j(0); j < 2; j++)
69 if ((*(pnts[k]))[j] > max[j])
71 max[j] = (*(pnts[k]))[j];
77 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok");
80 DBUG(
"GMSHAdaptiveMeshDensity::init(): Creating quadtree.");
83 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok.");
90 std::vector<GeoLib::Point const*>
const& pnts)
93 const std::size_t n_pnts(pnts.size());
95 "GMSHAdaptiveMeshDensity::addPoints(): Inserting {:d} points into "
98 for (std::size_t k(0); k < n_pnts; k++)
102 DBUG(
"GMSHAdaptiveMeshDensity::addPoints(): \tok.");
125 std::vector<GeoLib::Point*>& pnts, std::size_t additional_levels)
const
128 std::size_t max_depth(0);
131 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
136 it != leaf_list.end();
139 if ((*it)->getPoints().empty())
144 (*it)->getSquarePoints(ll, ur);
145 if ((*it)->getDepth() + additional_levels > max_depth)
147 additional_levels = max_depth - (*it)->getDepth();
149 const std::size_t n_pnts_per_quad_dim =
static_cast<std::size_t
>(1)
150 << additional_levels;
151 const double delta((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
152 for (std::size_t i(0); i < n_pnts_per_quad_dim; i++)
154 for (std::size_t j(0); j < n_pnts_per_quad_dim; j++)
157 ll[0] + (2 * i + 1) * delta,
158 ll[1] + (2 * j + 1) * delta, 0.0, pnts.size()));
169 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
172 std::string quad_tree_geo(
"QuadTree");
174 std::vector<GeoLib::Point*> points{};
175 for (
auto const leaf : leaf_list)
180 leaf->getSquarePoints(ll, ur);
181 std::size_t
const pnt_offset(points.size());
189 geo_objs.
addPointVec(std::move(points), quad_tree_geo,
194 std::vector<GeoLib::Polyline*> polylines{};
195 for (std::size_t l = 0; l < leaf_list.size(); ++l)
198 for (std::size_t p = 0; p < 4; ++p)
200 polyline->addPoint(4 * l + p);
202 polyline->closePolyline();
203 polylines.push_back(polyline);
208 return quad_tree_geo;
Definition of the GEOObjects class.
Definition of the Point class.
void DBUG(fmt::format_string< Args... > fmt, Args &&... 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
std::string getQuadTreeGeometry(GeoLib::GEOObjects &geo_objs) 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
Container class for geometric objects.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
const PointVec * getPointVecObj(const std::string &name) const
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)
std::map< std::string, std::size_t > NameIdMap
std::vector< T * > const & getVector() const