Skip to content

MDL writer: write_flow_element omits pipe connector geometry (type 1 lines) #329

Closed

Description

@bpowers

Problem

write_flow_element() in src/simlin-engine/src/mdl/writer.rs (line 909) emits only two lines per flow:

  • Type 11 (valve): position and visual properties
  • Type 10 (attached variable): name and label position

It does not use flow.points to emit the type 1 connector lines that represent the pipe geometry -- the line segments connecting stocks/clouds to the valve. This means stock/cloud attachments at flow endpoints are lost during MDL roundtrip. The MDL reader correctly parses these type 1 lines (see view/elements.rs:201), so the data is available on the Flow struct's points field, but the writer never consumes it.

Impact

  • Visual fidelity: Flow pipe paths (start/end connections, intermediate waypoints) are lost in written MDL sketches. Flows appear as isolated valves with no visible connections.
  • Roundtrip correctness: MDL -> datamodel -> MDL loses diagram connectivity information.
  • Equation semantics: Not affected. Flow equations and stock linkages are preserved correctly through the equation section of the MDL file.

Component(s) affected

  • src/simlin-engine/src/mdl/writer.rs -- write_flow_element() function (line 909)

Possible approach

For each flow element, in addition to the existing type 11 and type 10 lines, emit type 1 connector lines derived from flow.points. Each point pair defines a pipe segment. The from/to UIDs for the first and last segments should reference the connected stock/cloud UIDs (available via flow.points), and intermediate segments reference the valve UID. The connector line format is documented in view/elements.rs:201-203.

Context

Identified during review of PR #324 (MDL writer).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions