fix(understand): what the field test found — P&ID lengths need no equipment, caret notation, numbered rooms

Run on a real P&ID pair (kept outside the repository), the pipe takeoff wrote
an empty table. Three causes, each fixed with a test that failed first:

- Measured on the P&ID, a run still needed equipment tags at both ends,
  which only routing on the layout needs. Few pipes on a field P&ID end on
  a tagged outline. On the P&ID each piece now goes to the room it lies in:
  cut at the room outlines when the P&ID has room faces, else to the
  nearest room label. Diameters are kept piece by piece. On the layout a
  takeoff that could not route every run now says how many, why, the drawn
  length left to the control rows, and that length_source='pid' with
  force=True measures on the P&ID instead.
- A TEXT stores its line breaks in caret notation ('6^JROOM'), which
  plain() left as it was, so a room label's number read as '6^J...'.
  plain() now decodes ^J, ^M, ^I and '^ ', leaving MTEXT stacks
  ('\S1^2;') alone.
- Labels that only mention a room were read as rooms: a control cabinet
  naming the room it serves, or a note pointing into a room. An unnumbered
  label that names equipment is no room. Without room faces, when the
  drawing numbers its rooms, only numbered labels take pieces.

On the field pair the takeoff now fills its table, and every room key is a
real room number. The comparison with the hand-made workbook stays with
the user's files. README collected tests: 4981. The suite passes (4980, 1
xfailed).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-24 15:57:18 +03:00
co-authored by Claude Opus 5.5
parent 307ccc799f
commit ac32700ba8
7 changed files with 213 additions and 44 deletions
+10
View File
@@ -31,6 +31,16 @@ def test_plain_decodes_the_percent_codes():
assert plain("%%065") == "A"
def test_plain_decodes_the_caret_notation_of_a_text_entity():
# A TEXT or ATTRIB stores its control characters in caret notation: ^J a line
# break, ^I a tab, "^ " a caret. Left undecoded, "6^JROOM" is one word and a
# room label's number reads as "6^JROOM".
assert plain("6^JROOM") == "6\nROOM"
assert plain("A^IB") == "A\tB"
assert plain("x^ y") == "x^y"
assert plain("\\S1^2;") == "1/2" # an MTEXT stack keeps its separator
def test_plain_decodes_a_unicode_escape():
assert plain("\\U+2205 51") == "\u2205 51"
assert plain("\\u+00D8") == "\u00d8"