104{
106
107 float max_surface_deviation;
108
109 {
110#if 0
111
115#else
116
120#endif
121 max_surface_deviation = (quality_factor < 0.5f) ?
122 lerp(delta_min, delta_mid, 2. * quality_factor) :
123 lerp(delta_max, delta_mid, 2. * (1. - quality_factor));
124 }
125
126
127 size_t ordered_id = current_facet;
128 {
129 bool first_hit = false;
130 for (; ordered_id <
m_faces.size(); ++ ordered_id) {
131 const std::pair<float, float> &zspan =
m_faces[ordered_id].z_span;
132
133 if (zspan.first >= print_z)
134 break;
135
136 if (zspan.second > print_z) {
137
138 if (! first_hit) {
139 first_hit = true;
140 current_facet = ordered_id;
141 }
142
143 if (zspan.second < print_z +
EPSILON)
144 continue;
145
147 }
148 }
149 }
150
151
153
154
156 for (; ordered_id <
m_faces.size(); ++ ordered_id) {
157 const std::pair<float, float> &zspan =
m_faces[ordered_id].z_span;
158
159 if (zspan.first >= print_z + height)
160 break;
161
162
163 if (zspan.second < print_z +
EPSILON)
164 continue;
165
166
168
169 float z_diff = zspan.first - print_z;
170 if (reduced_height < z_diff) {
171 assert(z_diff < height +
EPSILON);
172
173
174
175
176#ifdef ADAPTIVE_LAYER_HEIGHT_DEBUG
177 BOOST_LOG_TRIVIAL(trace) <<
"cusp computation, height is reduced from " <<
height <<
"to " << z_diff <<
" due to z-diff";
178#endif
180 } else if (reduced_height < height) {
181#ifdef ADAPTIVE_LAYER_HEIGHT_DEBUG
182 BOOST_LOG_TRIVIAL(trace) <<
"adaptive layer computation: height is reduced from " <<
height <<
"to " << reduced_height <<
" due to higher facet";
183#endif
185 }
186 }
187
189 }
190
191#ifdef ADAPTIVE_LAYER_HEIGHT_DEBUG
192 BOOST_LOG_TRIVIAL(trace) <<
"adaptive layer computation, layer-bottom at z:" << print_z <<
", quality_factor:" << quality_factor <<
", resulting layer height:" <<
height;
193#endif
195}
static constexpr double EPSILON
Definition libslic3r.h:51
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:540
ColorRGB lerp(const ColorRGB &a, const ColorRGB &b, float t)
Definition Color.cpp:228
static float layer_height_from_slope(const SlicingAdaptive::FaceZ &face, float max_surface_deviation)
Definition SlicingAdaptive.cpp:52
coordf_t layer_height
Definition Slicing.hpp:61
coordf_t min_layer_height
Definition Slicing.hpp:64