23 double station_density,
24 std::size_t max_pnts_per_leaf)
38 std::vector<GeoLib::Point const*>
const& pnts)
42 "GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box "
43 "(2D) for quadtree.");
47 std::size_t n_pnts(pnts.size());
48 for (std::size_t k(1); k < n_pnts; k++)
50 for (std::size_t j(0); j < 2; j++)
52 if ((*(pnts[k]))[j] < min[j])
54 min[j] = (*(pnts[k]))[j];
57 for (std::size_t j(0); j < 2; j++)
59 if ((*(pnts[k]))[j] > max[j])
61 max[j] = (*(pnts[k]))[j];
67 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok");
70 DBUG(
"GMSHAdaptiveMeshDensity::init(): Creating quadtree.");
73 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok.");
80 std::vector<GeoLib::Point const*>
const& pnts)
83 const std::size_t n_pnts(pnts.size());
85 "GMSHAdaptiveMeshDensity::addPoints(): Inserting {:d} points into "
88 for (std::size_t k(0); k < n_pnts; k++)
92 DBUG(
"GMSHAdaptiveMeshDensity::addPoints(): \tok.");
115 std::vector<GeoLib::Point*>& pnts, std::size_t additional_levels)
const
118 std::size_t max_depth(0);
121 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
126 it != leaf_list.end();
129 if ((*it)->getPoints().empty())
134 (*it)->getSquarePoints(ll, ur);
135 if ((*it)->getDepth() + additional_levels > max_depth)
137 additional_levels = max_depth - (*it)->getDepth();
139 const std::size_t n_pnts_per_quad_dim =
static_cast<std::size_t
>(1)
140 << additional_levels;
141 const double delta((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
142 for (std::size_t i(0); i < n_pnts_per_quad_dim; i++)
144 for (std::size_t j(0); j < n_pnts_per_quad_dim; j++)
147 ll[0] + (2 * i + 1) * delta,
148 ll[1] + (2 * j + 1) * delta, 0.0, pnts.size()));
159 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
162 std::string quad_tree_geo(
"QuadTree");
164 std::vector<GeoLib::Point*> points{};
165 for (
auto const leaf : leaf_list)
170 leaf->getSquarePoints(ll, ur);
171 std::size_t
const pnt_offset(points.size());
179 geo_objs.
addPointVec(std::move(points), quad_tree_geo,
184 std::vector<GeoLib::Polyline*> polylines{};
185 for (std::size_t l = 0; l < leaf_list.size(); ++l)
188 for (std::size_t p = 0; p < 4; ++p)
190 polyline->addPoint(4 * l + p);
192 polyline->closePolyline();
193 polylines.push_back(polyline);
198 return quad_tree_geo;
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
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 ...
std::map< std::string, std::size_t > NameIdMap
std::vector< T * > const & getVector() const