Skip to content

layout: classify_flow_sides assumes left-to-right chain direction #445

@bpowers

Description

@bpowers

Problem

classify_flow_sides in the layout engine assumes all chain outflows go Right and all chain inflows go Left (standard left-to-right aging chain direction). For imported or manually-edited diagrams with vertical or reversed chains, adding a cloud flow may place it on the same face as the chain connector, causing overlaps.

The function is located in src/simlin-engine/src/layout/mod.rs (around line 1416).

Why it matters

  • Correctness: Cloud flows placed on the same face as a chain connector will visually overlap, making the diagram confusing or unreadable.
  • Affected use case: Models imported from other SD tools (Vensim, Stella) or diagrams where the user has manually arranged stocks in a vertical or right-to-left chain layout.
  • Component: simlin-engine, specifically src/simlin-engine/src/layout/mod.rs

Context

This is not a regression. Before PR #444, ALL cloud flows overlapped chains. The current heuristic (introduced in PR #444 / branch layout-perpendicular-side-flows) is strictly better than the prior behavior, but it is limited to the standard left-to-right aging chain assumption. The improvement is correct for the most common case but incomplete for non-standard layouts.

Possible approach

Infer the actual chain direction from the preserved flow geometry when classifying side flows in incremental_layout. Rather than hardcoding Right for outflows and Left for inflows, examine the existing positions of chain-connected stocks to determine the chain's orientation (horizontal LTR, horizontal RTL, vertical top-to-bottom, vertical bottom-to-top) and assign cloud flow sides accordingly.

Discovery

Identified during development of PR #444 (perpendicular side flows for aging chains).

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineIssues with the rust-based simulation enginelayoutDiagram auto-layout engine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions