|
ReUseX
0.0.1
3D Point Cloud Processing for Building Reuse
|
Greedy iterative label placement solver. More...
#include <labelLayoutSolver.hpp>
Classes | |
| struct | Candidate |
| Internal representation of a single placement candidate for a label. More... | |
Public Member Functions | |
| template<typename Func> | |
| LabelLayoutSolver (int w, int h, Func &&func, const LayoutConfig &cfg=LayoutConfig()) | |
| Construct a solver for a canvas of the given dimensions. | |
| void | setConfig (const LayoutConfig &cfg) |
| Update the layout configuration. | |
| void | setCanvasSize (int w, int h) |
| Change the canvas dimensions (e.g. after a resize). | |
| void | clear () |
| Remove all items from the solver (allows reuse across frames). | |
| void | add (float l, float t, float r, float b, const std::string &text, int baseFontSize) |
| Register a new label to be placed. | |
| void | solve () |
| Run the iterative placement optimisation. | |
| std::vector< LayoutResult > | getResults () const |
| Retrieve the placement result for each label in insertion order. | |
Greedy iterative label placement solver.
Given a set of object bounding boxes and their text labels, LabelLayoutSolver finds a non-overlapping placement for each label by minimising a cost function that penalises:
The solver generates a set of discrete placement candidates for each label (four anchor positions × several font-scale tiers + sliding variants) and then iteratively re-assigns labels to reduce total cost.
Usage example:
Definition at line 214 of file labelLayoutSolver.hpp.
|
inline |
Construct a solver for a canvas of the given dimensions.
| w | Canvas width in pixels. |
| h | Canvas height in pixels. |
| func | Callable that measures a text string at a given font size and returns a TextSize. Signature: TextSize(const std::string &text, int fontSize). |
| cfg | Optional tuning parameters. |
Definition at line 262 of file labelLayoutSolver.hpp.
|
inline |
Register a new label to be placed.
| l | Left edge of the associated object box. |
| t | Top edge. |
| r | Right edge. |
| b | Bottom edge. |
| text | Label string (UTF-8). |
| baseFontSize | Initial (maximum) font size in pixels. |
Definition at line 294 of file labelLayoutSolver.hpp.
References ReUseX::vision::osd::LabelLayoutSolver::Candidate::area, ReUseX::vision::osd::LabelLayoutSolver::Candidate::box, ReUseX::vision::osd::LabelLayoutSolver::Candidate::fontSize, ReUseX::vision::osd::LabelLayoutSolver::Candidate::geometricCost, ReUseX::vision::osd::LabelLayoutSolver::Candidate::invArea, ReUseX::vision::osd::LabelLayoutSolver::Candidate::staticCost, and ReUseX::vision::osd::LabelLayoutSolver::Candidate::textAscent.
|
inline |
Remove all items from the solver (allows reuse across frames).
Definition at line 281 of file labelLayoutSolver.hpp.
|
inline |
Retrieve the placement result for each label in insertion order.
Definition at line 483 of file labelLayoutSolver.hpp.
|
inline |
Change the canvas dimensions (e.g. after a resize).
Definition at line 275 of file labelLayoutSolver.hpp.
|
inline |
Update the layout configuration.
Definition at line 272 of file labelLayoutSolver.hpp.
|
inline |
Run the iterative placement optimisation.
Call this after adding all items and before calling getResults().
Definition at line 342 of file labelLayoutSolver.hpp.
References ReUseX::vision::osd::LabelLayoutSolver::Candidate::box, ReUseX::vision::osd::LabelLayoutSolver::Candidate::geometricCost, ReUseX::vision::osd::LayoutBox::intersectArea(), ReUseX::vision::osd::LayoutBox::intersects(), ReUseX::vision::osd::LabelLayoutSolver::Candidate::invArea, and ReUseX::vision::osd::LabelLayoutSolver::Candidate::staticCost.