Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c9094d9
add Global::get_per_axis_per_criteria<>()
thomaslepoix Sep 14, 2026
4d0feeb
Cli : add per material option handling
thomaslepoix Sep 16, 2026
a66c0cc
GUI : add per material option handling
thomaslepoix Sep 21, 2026
e4721ea
GUI : allow data validation on edition
thomaslepoix Sep 24, 2026
256ca9a
add parser & serializer per material option handling
thomaslepoix Oct 1, 2026
362165e
add per material dmax & lmin & smoothness
thomaslepoix Oct 1, 2026
e53f8f7
test Global::get_per_axis_per_criteria<>()
thomaslepoix Oct 1, 2026
154ab9a
make dmax & diagonal_dmax & proximity_limit absolute -> wavelength-re…
thomaslepoix Oct 7, 2026
309f2d9
fix Board::find_ambient_material(Axis, Coord) & add Planes
thomaslepoix Oct 8, 2026
b110a5a
GUI : remove 'old value' edition column when overwhelming
thomaslepoix Oct 8, 2026
dd31de7
GUI : set Interval default smoothness from Global rules
thomaslepoix Oct 8, 2026
f1f8c9b
refactor : fix some badsmells
thomaslepoix Oct 11, 2026
889bfd6
GUI : add fmax in status bar
thomaslepoix Oct 12, 2026
e929e30
add 'Expressed as wavelength divisor' indication for d & dmax & diago…
thomaslepoix Oct 13, 2026
3676724
stick to resolution definition : 'resolution (cpw) = wavelength (m) /…
thomaslepoix Oct 19, 2026
2bf57e5
doc : rename smoothness factor : f -> w
thomaslepoix Oct 19, 2026
9c527b8
add lpf2 csx example
thomaslepoix Oct 20, 2026
0d52a7a
comment out unimplemented diagonal_lmin
thomaslepoix Oct 20, 2026
ff72ec4
fix & update naming of Cli & Serializer & Parser options
thomaslepoix Oct 20, 2026
ce7cdde
fix : --per-mat-<> & --per-mat-type-<> multiple parsing
thomaslepoix Oct 20, 2026
32fc578
Cli : show some default values
thomaslepoix Oct 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/interval.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ Despite being actually just the last step of the whole process, this explanatory
- `x`: Position of `MeshlinePolicies`.
- `m`: Position of the middle of the `Interval` between two `MeshlinePolicies`.
- `h`: Half of the Interval between two `MeshlinePolicies`.
- `f`: Smoothness factor `[1;2]`.
- `w`: Smoothness factor `[1;2]`.
- `d`: Distance between the two lines around a `MeshlinePolicy`.
- `dinit`: Space between `x` and the first line (may not be the half of `d`).
- `dmax`: Maximal authorized space between two lines.
- `dmax`: Maximal authorized space between two lines. Calculated from minimal resolution: `dmax = λ/res_min`.
- `s`: Space to fill of lines.
- `z`: Distance from the first line (belonging to `MeshlinePolicy`) to the last line before `m` (the middle of the `Interval`).
- `lz`: Number of lines before the middle of the `Interval` (minus the line belonging to the `MeshlinePolicy`).
Expand All @@ -36,7 +36,7 @@ Despite being actually just the last step of the whole process, this explanatory

### Steps

- Choose `dmax` among `Interval`'s `dmax` and projection from both sides' `d` of `f**(lz+1)`, so the sizes of the two cells around `m` (belonging to both sides) will respect the smoothness factor (`f`).
- Choose `dmax` among `Interval`'s `dmax` and projection from both sides' `d` of `w**(lz+1)`, so the sizes of the two cells around `m` (belonging to both sides) will respect the smoothness factor (`w`).
- Reduce `d` until enough lines are in the half (`lz >= lmin`).
- Reduce the smoothness factor (which augments the spaces between lines, except `d`) until `z` matches `s`, that is to say until the last line of the half overlaps with `m` (actually just passed `m`).
- Trim out the last line, that overlaps `m` (a line at `m`, that will count for both halves, will be placed instead).
2 changes: 1 addition & 1 deletion doc/interval.tex
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
] in {\lines} {
\draw [line width=0.5pt] (\ox,\oy) ++(0,1)
+(\lastn,0) .. controls +(0,0.2) and +(0,0.2) .. +(\n,0)
+(\fpeval{(\lastn+\n)/2},0.2) node[above] {$d\cdot f$$^\i$};
+(\fpeval{(\lastn+\n)/2},0.2) node[above] {$d\cdot w$$^\i$};

\pgfmathparse{\dmax < \fpeval{abs(\lastn-\n)}}
\ifnum \pgfmathresult>0
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_sources( openemsh
"${CMAKE_CURRENT_SOURCE_DIR}/domain/mesh/interval.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/domain/mesh/meshline.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/domain/mesh/meshline_policy.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/domain/global.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/domain/material.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/domain/meshline_policy_manager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/domain/conflict_manager.cpp"
Expand Down Expand Up @@ -96,6 +97,7 @@ target_sources( openemsh_bin
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/utils/nodegraph/wire.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_delegate.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_dialog.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_dialog_per_axis_per_criteria.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model_global.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model_angle.cpp"
Expand All @@ -104,6 +106,7 @@ target_sources( openemsh_bin
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model_edge.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model_interval.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model_meshline_policy.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/edit/edit_model_per_axis_per_criteria.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/processing_view/processing_axis.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/processing_view/processing_plane.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ui/qt/processing_view/processing_style.cpp"
Expand Down
5 changes: 5 additions & 0 deletions src/app/openemsh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
case Step::DETECT_AND_SOLVE_TCMLP:
return Step::DETECT_INTERVALS;
case Step::DETECT_INTERVALS:
return Step::ADJUST_MESH_TO_MATERIAL;
case Step::ADJUST_MESH_TO_MATERIAL:
return Step::DETECT_INTERVALS_PER_DIAG_ZONES;
case Step::DETECT_INTERVALS_PER_DIAG_ZONES:
return Step::SOLVE_DIAG_ZONES_INTERVALS;
Expand Down Expand Up @@ -75,6 +77,7 @@
case DETECT_INDIVIDUAL_EDGES: out.emplace(DETECT_INDIVIDUAL_EDGES); [[fallthrough]];
case DETECT_AND_SOLVE_TCMLP: out.emplace(DETECT_AND_SOLVE_TCMLP); [[fallthrough]];
case DETECT_INTERVALS: out.emplace(DETECT_INTERVALS); [[fallthrough]];
case ADJUST_MESH_TO_MATERIAL: out.emplace(ADJUST_MESH_TO_MATERIAL); [[fallthrough]];
case DETECT_INTERVALS_PER_DIAG_ZONES: out.emplace(DETECT_INTERVALS_PER_DIAG_ZONES); [[fallthrough]];
case SOLVE_DIAG_ZONES_INTERVALS: out.emplace(SOLVE_DIAG_ZONES_INTERVALS); [[fallthrough]];
case MESH: out.emplace(MESH); break;
Expand Down Expand Up @@ -178,6 +181,7 @@
handle(DETECT_INDIVIDUAL_EDGES, [&] { board->detect_individual_edges(); });
handle(DETECT_AND_SOLVE_TCMLP, [&] { board->detect_and_solve_too_close_meshline_policies(); });
handle(DETECT_INTERVALS, [&] { board->detect_intervals(); });
handle(ADJUST_MESH_TO_MATERIAL, [&] { board->adjust_mesh_to_materials(); });

Check failure on line 184 in src/app/openemsh.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Explicitly capture the required scope variables.

See more on https://sonarcloud.io/project/issues?id=Open-RFlab_openemsh&issues=AaEiZFvEhvuiaV7XYljq&open=AaEiZFvEhvuiaV7XYljq&pullRequest=41

Check failure on line 184 in src/app/openemsh.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Explicitly capture all local variables required in this lambda.

See more on https://sonarcloud.io/project/issues?id=Open-RFlab_openemsh&issues=AaEiZFvEhvuiaV7XYljr&open=AaEiZFvEhvuiaV7XYljr&pullRequest=41
handle(DETECT_INTERVALS_PER_DIAG_ZONES, [&] { board->detect_intervals_per_diagonal_zones(); });
handle(SOLVE_DIAG_ZONES_INTERVALS, [&] { board->solve_diagonal_zones_intervals(); });
handle(MESH, [&] { board->mesh(); });
Expand All @@ -200,6 +204,7 @@
Step::DETECT_INDIVIDUAL_EDGES,
Step::DETECT_AND_SOLVE_TCMLP,
Step::DETECT_INTERVALS,
Step::ADJUST_MESH_TO_MATERIAL,
Step::DETECT_INTERVALS_PER_DIAG_ZONES,
Step::SOLVE_DIAG_ZONES_INTERVALS,
Step::MESH
Expand Down
8 changes: 5 additions & 3 deletions src/app/steps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum class Step {
DETECT_INDIVIDUAL_EDGES,
DETECT_AND_SOLVE_TCMLP,
DETECT_INTERVALS,
ADJUST_MESH_TO_MATERIAL,
DETECT_INTERVALS_PER_DIAG_ZONES,
SOLVE_DIAG_ZONES_INTERVALS,
MESH
Expand All @@ -49,9 +50,10 @@ inline std::size_t index(std::optional<Step> step) {
case Step::DETECT_INDIVIDUAL_EDGES: return 10;
case Step::DETECT_AND_SOLVE_TCMLP: return 11;
case Step::DETECT_INTERVALS: return 12;
case Step::DETECT_INTERVALS_PER_DIAG_ZONES: return 13;
case Step::SOLVE_DIAG_ZONES_INTERVALS: return 14;
case Step::MESH: return 15;
case Step::ADJUST_MESH_TO_MATERIAL: return 13;
case Step::DETECT_INTERVALS_PER_DIAG_ZONES: return 14;
case Step::SOLVE_DIAG_ZONES_INTERVALS: return 15;
case Step::MESH: return 16;
default: ::unreachable();
}
}
Expand Down
74 changes: 68 additions & 6 deletions src/domain/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
return make_shared<Board>(
std::move(polygons),
std::move(fixed_meshline_policy_creators),
std::move(material),
std::move(background_material),
std::move(params),
Caretaker::singleton().get_history_root());
}

//******************************************************************************
void Board::Builder::set_background_material(shared_ptr<Material> background) {
material = background;
void Board::Builder::set_background_material(shared_ptr<Material> material) {
background_material = material;
}

// TODO should be in meshline manager?
Expand Down Expand Up @@ -153,14 +153,14 @@
Board::Board(
PlaneSpace<std::vector<std::shared_ptr<Polygon>>>&& polygons,
AxisSpace<std::vector<std::function<void (Board*, Timepoint*)>>>&& fixed_meshline_policy_creators,
shared_ptr<Material>&& background,
shared_ptr<Material>&& background_material,
Params&& params,
Timepoint* t)
: Originator(t, BoardState(std::move(polygons)))
, global_params(make_shared<GlobalParams>(std::move(params), t))
, conflict_manager(make_shared<ConflictManager>(t))
, line_policy_manager(make_shared<MeshlinePolicyManager>(global_params.get(), t))
, material(background)
, background_material(background_material)
, fixed_meshline_policy_creators(std::move(fixed_meshline_policy_creators)) {

conflict_manager->init(line_policy_manager.get());
Expand All @@ -173,6 +173,33 @@
get_caretaker().take_care_of(polygon);
}

//******************************************************************************
shared_ptr<Material> Board::find_ambient_material(Axis axis, Coord const& coord) const {
vector<pair<shared_ptr<Material>, remove_const_t<decltype(Polygon::priority)>>> materials;

for(ViewAxis view_axis : AllViewAxis) {
for(shared_ptr<Polygon> const& polygon : get_current_state().polygons[Planes[axis][view_axis]]) {
if(polygon->material
&& does_overlap(cast(view_axis, polygon->bounding), coord)) {
materials.emplace_back(shared_ptr<Material>(polygon->material), polygon->priority);
}
}
}

ranges::sort(materials, [](auto const& a, auto const& b) {
auto const& [material_a, priority_a] = a;
auto const& [material_b, priority_b] = b;
return priority_a != priority_b
? priority_a < priority_b
: *material_a < *material_b;
});

if(!materials.empty())
return materials.back().first;
else
return background_material;
}

//******************************************************************************
shared_ptr<Material> Board::find_ambient_material(Plane plane, Segment const& segment) const {
return find_ambient_material(plane, segment, nullptr).first;
Expand Down Expand Up @@ -205,7 +232,7 @@
if(!materials.empty())
return materials.back();
else
return { material, std::numeric_limits<remove_const_t<decltype(Polygon::priority)>>::min() };
return { background_material, std::numeric_limits<remove_const_t<decltype(Polygon::priority)>>::min() };
}

//******************************************************************************
Expand Down Expand Up @@ -619,6 +646,35 @@
bar.complete();
}

//******************************************************************************
void Board::adjust_mesh_to_materials(Axis axis) {

Check warning on line 650 in src/domain/board.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=Open-RFlab_openemsh&issues=AaEiZFiuhvuiaV7XYljV&open=AaEiZFiuhvuiaV7XYljV&pullRequest=41
auto [t, state_mlpm] = line_policy_manager->make_next_state();

auto [bar, i, _] = Progress::Bar::build(
state_mlpm.intervals[axis].size() + 1,
"["s + to_string(axis) + "] Adjusting mesh to Materials ");

for(auto const& interval : state_mlpm.intervals[axis]) {
auto const& params = global_params->get_current_state();
auto state_i = interval->get_current_state();
auto material = find_ambient_material(axis, interval->m);

auto const& lmin = global_params->get_lmin(axis, material.get(), params);
auto const& smoothness = global_params->get_smoothness(axis, material.get(), params);
state_i.main_material = material.get();
state_i.dmax = min(state_i.dmax, global_params->get_dmax(axis, material.get(), params));
state_i.before.lmin = lmin;
state_i.after.lmin = lmin;
state_i.before.smoothness = smoothness;
state_i.after.smoothness = smoothness;

interval->set_state(t, state_i);
bar.tick(++i);
}

bar.complete();
}

//******************************************************************************
void Board::adjust_edges_to_materials() {
for(auto const& plane : AllPlane)
Expand Down Expand Up @@ -673,6 +729,12 @@
add_fixed_meshline_policies(axis);
}

//******************************************************************************
void Board::adjust_mesh_to_materials() {
for(auto const& axis : AllAxis)
adjust_mesh_to_materials(axis);
}

//******************************************************************************
void Board::auto_solve_all_edge_in_polygon() {
for(auto const& plane : AllPlane)
Expand Down
11 changes: 7 additions & 4 deletions src/domain/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Board
class Builder {
public:

void set_background_material(std::shared_ptr<Material> background);
void set_background_material(std::shared_ptr<Material> material);
void add_fixed_meshline_policy(Axis axis, Coord coord);
void add_polygon(Plane plane, std::shared_ptr<Material> const& material, std::string const& name, std::size_t priority, Polygon::RangeZ const& z_placement, std::initializer_list<Point> points);
void add_polygon(Plane plane, std::shared_ptr<Material> const& material, std::string const& name, std::size_t priority, Polygon::RangeZ const& z_placement, std::vector<std::unique_ptr<Point const>>&& points);
Expand All @@ -69,19 +69,19 @@ class Board
[[nodiscard]] std::shared_ptr<Board> build(Params&& params = Params());

private:
std::shared_ptr<Material> material;
std::shared_ptr<Material> background_material;
PlaneSpace<std::vector<std::shared_ptr<Polygon>>> polygons;
AxisSpace<std::vector<std::function<void (Board*, Timepoint*)>>> fixed_meshline_policy_creators;
};

std::shared_ptr<Material> material;
std::shared_ptr<Material> background_material;
AxisSpace<std::vector<std::function<void (Board*, Timepoint*)>>> const fixed_meshline_policy_creators; // Meant to delay MeshlinePolicies creation at Step time instead of Parse time.

Board(PlaneSpace<std::vector<std::shared_ptr<Polygon>>>&& polygons, Params&& params, Timepoint* t);
Board(
PlaneSpace<std::vector<std::shared_ptr<Polygon>>>&& polygons,
AxisSpace<std::vector<std::function<void (Board*, Timepoint*)>>>&& fixed_meshline_policy_creators,
std::shared_ptr<Material>&& background,
std::shared_ptr<Material>&& background_material,
Params&& params,
Timepoint* t);

Expand All @@ -94,6 +94,7 @@ class Board
void detect_diagonal_angles(Plane plane);
void detect_diagonal_zones(Plane plane);
void add_fixed_meshline_policies(Axis axis);
void adjust_mesh_to_materials(Axis axis);

void adjust_edges_to_materials();
void detect_diagonal_angles();
Expand All @@ -104,6 +105,7 @@ class Board
void detect_colinear_edges();
void detect_individual_edges();
void add_fixed_meshline_policies();
void adjust_mesh_to_materials();

/// Mesh resolution dependant detection tasks
///*************************************************************************
Expand All @@ -127,6 +129,7 @@ class Board
std::size_t get_mesh_cell_number() const;

private:
std::shared_ptr<Material> find_ambient_material(Axis axis, Coord const& coord) const;
std::shared_ptr<Material> find_ambient_material(Plane plane, Segment const& segment) const;
std::pair<std::shared_ptr<Material>, std::remove_const_t<decltype(Polygon::priority)>> find_ambient_material(Plane plane, Segment const& segment, std::shared_ptr<Polygon> const& current_polygon) const;
};
Expand Down
8 changes: 5 additions & 3 deletions src/domain/conflicts/conflict_diagonal_or_circular_zone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using namespace std;
ConflictDiagonalOrCircularZone::ConflictDiagonalOrCircularZone(Axis axis, vector<Angle*> const& angles, GlobalParams* global_params, Timepoint* t)
: Originator(t, {
.dmax = global_params->get_current_state().diagonal_dmax,
.lmin = global_params->get_current_state().lmin,
.lmin = global_params->get_lmin(axis),
.minimal_angle = global_params->get_current_state().consecutive_diagonal_minimal_angle,
.angles = angles })
, Conflict(Kind::DIAGONAL_OR_CIRCULAR_ZONE)
Expand Down Expand Up @@ -89,8 +89,10 @@ void ConflictDiagonalOrCircularZone::solve_intervals() {

for(Interval* interval : state.intervals) {
auto state_i = interval->get_current_state();
state_i.dmax = state.dmax;
interval->set_state(t, state_i);
if(state.dmax < state_i.dmax) {
state_i.dmax = state.dmax;
interval->set_state(t, state_i);
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/domain/conflicts/conflict_diagonal_or_circular_zone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ class ConflictDiagonalOrCircularZone
: public Originator<ConflictDiagonalOrCircularZoneState const>
, public Visitable<ConflictDiagonalOrCircularZone, EntityVisitor>
, public Conflict {
private:
GlobalParams* global_params;

public:
GlobalParams* global_params;
Axis const axis;

ConflictDiagonalOrCircularZone(Axis axis, std::vector<Angle*> const& angles, GlobalParams* global_params, Timepoint* t);
Expand Down
8 changes: 8 additions & 0 deletions src/domain/geometrics/space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ static_assert(Axes[ZX][V] == X);
static_assert(Axes[XY][H] == X);
static_assert(Axes[XY][V] == Y);

//******************************************************************************
static_assert(Planes[X][H] == XY);
static_assert(Planes[X][V] == ZX);
static_assert(Planes[Y][H] == YZ);
static_assert(Planes[Y][V] == XY);
static_assert(Planes[Z][H] == ZX);
static_assert(Planes[Z][V] == YZ);

//******************************************************************************
optional<ViewAxis> transpose(Plane const plane, Axis const axis) noexcept {
switch(plane) {
Expand Down
7 changes: 7 additions & 0 deletions src/domain/geometrics/space.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ inline static PlaneSpace<ViewAxisSpace<Axis const>> constexpr Axes {{
{ X, Y }
}};

//******************************************************************************
inline static AxisSpace<ViewAxisSpace<Plane const>> constexpr Planes {{
{ XY, ZX },
{ YZ, XY },
{ ZX, YZ }
}};

/// ViewAxis describe the orientation of Axis itself.
///*****************************************************************************
std::optional<ViewAxis> transpose(Plane const plane, Axis const axis) noexcept;
Expand Down
Loading
Loading