mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-22 21:50:51 -05:00
Give the Section View's Cut Face the Infill Colour in the Solid Model
The solid model capped the section view's cut with the body's wall colour, while the two layer caps already took the infill's. The section cap now takes the infill colour sampled over every layer the solid stands for, as the body takes the wall colour, falling back to the body's colour where a body has no infill. Views that colour by filament are unchanged.
This commit is contained in:
1 parent
4f71398a0f
commit
99cab87d25
3 files changed
+27
-18
No files matched your search
@@ -101,7 +101,7 @@ The solid stands in for the toolpaths, so it wears their colours. In the views t
|
||||
filament (Summary, Filament, Tool) each body keeps the filament colour its shell was loaded with.
|
||||
In every other view `GCodeViewer::update_solid_model_colors()` samples the toolpaths through
|
||||
`Viewer::get_vertex_color()`: the body takes the outer wall's colour over the layers the solid
|
||||
stands for, each cap the infill's in the layer it is cut under, sparse infill before solid, and
|
||||
stands for, each layer cap the infill's in the layer it is cut under, sparse infill before solid, and
|
||||
the prime tower its own role's. One vertex stands for the role, chosen by
|
||||
`Viewer::find_extrusion_vertex()`: in a view that grades the toolpaths by a value, the
|
||||
length-weighted median of that value over the role's extrusions in up to eight layers spread over
|
||||
@@ -116,7 +116,9 @@ the ends of the layer range then do not bound. And so does a belt printer's: its
|
||||
tilted at the belt angle, with heights in the G-code's frame, which no horizontal cut follows.
|
||||
|
||||
A section view cuts the solid by its plane as it cuts the toolpaths, and the section face is one
|
||||
more cap, counted on the body cut by that plane alone and drawn between the two heights.
|
||||
more cap, counted on the body cut by that plane alone and drawn between the two heights. It may
|
||||
cross any of the layers the solid stands for, so its colour is the infill's sampled over all of
|
||||
them, as the body's is, or the body's own where the body has no infill.
|
||||
|
||||
The solid is drawn opaque whatever the filaments' alpha: a translucent filament shows its toolpaths
|
||||
inside through the walls at rest, and the solid has no inside to show.
|
||||
|
||||
@@ -3801,6 +3801,7 @@ void GCodeViewer::init_solid_model_caps(const std::array<float, 2>& z_range, std
|
||||
init_quad(cap, on_plane, reach * u, reach * v);
|
||||
cap.count_plane = m_clipping_plane;
|
||||
cap.quad_z_range = { z_bottom, z_top };
|
||||
cap.color_index = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3945,17 +3946,18 @@ void GCodeViewer::render_solid_model(int canvas_width, int canvas_height)
|
||||
}
|
||||
}
|
||||
|
||||
// The solid stands in for the toolpaths, so it takes their colours in the view that colours them
|
||||
// by something other than the filament: each body the outer wall's, each cap the infill's of the
|
||||
// layer it is cut under, sparse if the layer has any, else solid, and the tower its own role's,
|
||||
// each from the toolpaths within the body's own footprint, so that objects printed at different
|
||||
// grades keep their own. The views that colour by filament leave every body its own colour. The
|
||||
// bodies are sampled over the layers the solid stands for and each cap in its own layer, each
|
||||
// colour that of the vertex the viewer picks to represent the role there, so a view that grades
|
||||
// the toolpaths, by speed or fan, shows the solid in the grade most of that role was printed at.
|
||||
// The bodies are sampled once, as the drag begins, and held while a slider drag moves the span:
|
||||
// sampled again at every step, the grade would flip with the layers the sample happens to fall
|
||||
// on. Each cap follows its own layer.
|
||||
// The solid stands in for the toolpaths, so it takes their colours in the view that colours them by
|
||||
// something other than the filament: each body the outer wall's, each layer cap the infill's of the
|
||||
// layer it is cut under, sparse if the layer has any, else solid, the section view's cap the
|
||||
// infill's over all the layers, and the tower its own role's, each from the toolpaths within the
|
||||
// body's own footprint, so that objects printed at different grades keep their own. The views that
|
||||
// colour by filament leave every body its own colour. The bodies and the section view's cap are
|
||||
// sampled over the layers the solid stands for and each layer cap in its own layer, each colour
|
||||
// that of the vertex the viewer picks to represent the role there, so a view that grades the
|
||||
// toolpaths, by speed or fan, shows the solid in the grade most of that role was printed at. The
|
||||
// bodies are sampled once, as the drag begins, and held while a slider drag moves the span: sampled
|
||||
// again at every step, the grade would flip with the layers the sample happens to fall on. The
|
||||
// section view's cap is held with them; each layer cap follows its own layer.
|
||||
void GCodeViewer::update_solid_model_colors(const libvgcode::Interval& whole_layers)
|
||||
{
|
||||
SolidModelColors& colors = m_solid_model_colors;
|
||||
@@ -3996,8 +3998,13 @@ void GCodeViewer::update_solid_model_colors(const libvgcode::Interval& whole_lay
|
||||
const libvgcode::XYBox box{ { static_cast<float>(footprint.min.x()) - margin, static_cast<float>(footprint.min.y()) - margin },
|
||||
{ static_cast<float>(footprint.max.x()) + margin, static_cast<float>(footprint.max.y()) + margin } };
|
||||
SolidModelColors::Body& body = colors.bodies[n];
|
||||
if (!held)
|
||||
if (!held) {
|
||||
body.body = sample(whole_layers, tower ? tower_role : walls, box);
|
||||
// the section view's cut may cross any of the layers, so it is sampled over all of them, as the body is
|
||||
body.caps[2] = tower ? std::nullopt : sample(whole_layers, infill, box);
|
||||
if (!body.caps[2].has_value())
|
||||
body.caps[2] = body.body;
|
||||
}
|
||||
for (size_t k = 0; k < 2; ++k) {
|
||||
body.caps[k] = tower ? std::nullopt : sample({ whole_layers[k], whole_layers[k] }, infill, box);
|
||||
if (!body.caps[k].has_value())
|
||||
|
||||
@@ -354,10 +354,10 @@ private:
|
||||
// the quad, cut by the other caps
|
||||
std::array<float, 2> quad_z_range{ -FLT_MAX, FLT_MAX };
|
||||
std::array<float, 4> quad_plane{ 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
// which of the sampled cap colours it takes, none for the body's own
|
||||
// which of the sampled cap colours it takes
|
||||
std::optional<size_t> color_index;
|
||||
};
|
||||
// the bottom cap, then the top one, as the colours are indexed, then the section view's; a cap
|
||||
// the bottom cap, then the top one, then the section view's, as the colours are indexed; a cap
|
||||
// the solid is not cut at is left without a quad
|
||||
void init_solid_model_caps(const std::array<float, 2>& z_range, std::array<SolidModelCap, 3>& caps) const;
|
||||
void release_caster_depth();
|
||||
@@ -392,8 +392,8 @@ private:
|
||||
{
|
||||
// unset where the view colours by filament, or no vertex of the role was found there
|
||||
std::optional<ColorRGBA> body;
|
||||
// the bottom and top caps
|
||||
std::array<std::optional<ColorRGBA>, 2> caps;
|
||||
// the bottom and top caps, then the section view's, sampled over every layer of the solid
|
||||
std::array<std::optional<ColorRGBA>, 3> caps;
|
||||
};
|
||||
std::vector<Body> bodies;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user