Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
4 changes: 4 additions & 0 deletions src/app/openemsh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ optional<Step> next(Step step) {
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 @@ set<Step> that_and_after(Step step) {
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 @@ void OpenEMSH::run(std::set<Step> const& steps) const {
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(); });
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 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
72 changes: 72 additions & 0 deletions src/domain/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,43 @@ Board::Board(
get_caretaker().take_care_of(polygon);
}

//******************************************************************************
shared_ptr<Material> Board::find_ambient_material(Axis axis, Coord const& coord) const {
// TODO is this order (view_axis) in phase with B1D cast(view_axis, B2D) ?
auto planes = [](Axis axis) -> array<Plane, 2> {
switch(axis) {
case X: return { ZX, XY };
case Y: return { YZ, XY };
case Z: return { YZ, ZX };
default: ::unreachable();
}
} (axis);

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[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 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 @@ -619,6 +656,35 @@ void Board::add_fixed_meshline_policies(Axis axis) {
bar.complete();
}

//******************************************************************************
void Board::adjust_mesh_to_materials(Axis axis) {
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 +739,12 @@ void Board::add_fixed_meshline_policies() {
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
3 changes: 3 additions & 0 deletions src/domain/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading
Loading