204 auto& path_components = data_->components;
205 auto& path_points = data_->points;
207 auto get_path_component = [&path_components, &path_points](
209 if (component_i >= path_components.size()) {
210 return std::monostate{};
212 const auto& component = path_components[component_i];
213 switch (component.type) {
216 &path_points[component.index]);
219 &path_points[component.index]);
222 &path_points[component.index]);
224 return std::monostate{};
228 auto compute_contour_start_direction =
229 [&get_path_component](
size_t current_path_component_index) {
230 size_t next_component_index = current_path_component_index + 1;
231 while (!std::holds_alternative<std::monostate>(
232 get_path_component(next_component_index))) {
233 auto next_component = get_path_component(next_component_index);
236 if (maybe_vector.has_value()) {
237 return maybe_vector.value();
239 next_component_index++;
245 std::vector<PolylineContour::Component> poly_components;
246 std::optional<size_t> previous_path_component_index;
247 auto end_contour = [&
polyline, &previous_path_component_index,
248 &get_path_component, &poly_components]() {
255 if (!previous_path_component_index.has_value()) {
261 contour.components = poly_components;
262 poly_components.clear();
264 size_t previous_index = previous_path_component_index.value();
265 while (!std::holds_alternative<std::monostate>(
266 get_path_component(previous_index))) {
267 auto previous_component = get_path_component(previous_index);
270 if (maybe_vector.has_value()) {
271 contour.end_direction = maybe_vector.value();
274 if (previous_index == 0) {
282 for (
size_t component_i = 0; component_i < path_components.size();
284 const auto& path_component = path_components[component_i];
285 switch (path_component.type) {
287 poly_components.push_back({
288 .component_start_index =
polyline.points->size() - 1,
292 &path_points[path_component.index])
293 ->AppendPolylinePoints(*
polyline.points);
294 previous_path_component_index = component_i;
297 poly_components.push_back({
298 .component_start_index =
polyline.points->size() - 1,
302 &path_points[path_component.index])
304 previous_path_component_index = component_i;
307 poly_components.push_back({
308 .component_start_index =
polyline.points->size() - 1,
312 &path_points[path_component.index])
314 previous_path_component_index = component_i;
317 if (component_i == path_components.size() - 1) {
324 Vector2 start_direction = compute_contour_start_direction(component_i);
325 const auto&
contour = data_->contours[path_component.index];
327 .is_closed =
contour.is_closed,
328 .start_direction = start_direction,
329 .components = poly_components});
void EnumerateComponents(const Applier< LinearPathComponent > &linear_applier, const Applier< QuadraticPathComponent > &quad_applier, const Applier< CubicPathComponent > &cubic_applier, const Applier< ContourComponent > &contour_applier) const