23 double station_density,
24 std::size_t max_pnts_per_leaf)
37 std::vector<GeoLib::Point const*>
const& pnts)
41 "GMSHAdaptiveMeshDensity::init(): computing axis aligned bounding box "
42 "(2D) for quadtree.");
46 std::size_t n_pnts(pnts.size());
47 for (std::size_t k(1); k < n_pnts; k++)
49 for (std::size_t j(0); j < 2; j++)
51 if ((*(pnts[k]))[j] < min[j])
53 min[j] = (*(pnts[k]))[j];
56 for (std::size_t j(0); j < 2; j++)
58 if ((*(pnts[k]))[j] > max[j])
60 max[j] = (*(pnts[k]))[j];
66 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok");
69 DBUG(
"GMSHAdaptiveMeshDensity::init(): Creating quadtree.");
72 DBUG(
"GMSHAdaptiveMeshDensity::init(): \tok.");
79 std::vector<GeoLib::Point const*>
const& pnts)
82 const std::size_t n_pnts(pnts.size());
84 "GMSHAdaptiveMeshDensity::addPoints(): Inserting {:d} points into "
87 for (std::size_t k(0); k < n_pnts; k++)
91 DBUG(
"GMSHAdaptiveMeshDensity::addPoints(): \tok.");
114 std::vector<GeoLib::Point*>& pnts, std::size_t additional_levels)
const
117 std::size_t max_depth(0);
120 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
125 it != leaf_list.end();
128 if ((*it)->getPoints().empty())
133 (*it)->getSquarePoints(ll, ur);
134 if ((*it)->getDepth() + additional_levels > max_depth)
136 additional_levels = max_depth - (*it)->getDepth();
138 const std::size_t n_pnts_per_quad_dim =
static_cast<std::size_t
>(1)
139 << additional_levels;
140 const double delta((ur[0] - ll[0]) / (2 * n_pnts_per_quad_dim));
141 for (std::size_t i(0); i < n_pnts_per_quad_dim; i++)
143 for (std::size_t j(0); j < n_pnts_per_quad_dim; j++)
146 ll[0] + (2 * i + 1) * delta,
147 ll[1] + (2 * j + 1) * delta, 0.0, pnts.size()));
158 std::list<GeoLib::QuadTree<GeoLib::Point>*> leaf_list;
161 std::string quad_tree_geo(
"QuadTree");
163 std::vector<GeoLib::Point*> points{};
164 for (
auto const leaf : leaf_list)
169 leaf->getSquarePoints(ll, ur);
170 std::size_t
const pnt_offset(points.size());
178 geo_objs.
addPointVec(std::move(points), quad_tree_geo,
183 std::vector<GeoLib::Polyline*> polylines{};
184 for (std::size_t l = 0; l < leaf_list.size(); ++l)
187 for (std::size_t p = 0; p < 4; ++p)
189 polyline->addPoint(4 * l + p);
191 polyline->closePolyline();
192 polylines.push_back(polyline);
197 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