import json
import subprocess
import os

loa_m = 4.88
loa_sq = 24.4

# Tabela de cotas em mm:
# stn  x      sheer_hb chine_hb sheer_ht chine_ht keel_ht
# 1    0      920.0    740.0    850.0    247.6    0.0
# 2    697    975.1    784.9    850.0    248.6    0.0
# 3    1394   1005.8   814.8    850.0    257.9    0.0
# 4    2091   1024.9   820.0    850.0    278.8    0.0
# 5    2789   992.4    774.2    850.0    306.9    0.0
# 6    3486   874.9    656.4    850.0    362.4    0.0
# 7    4183   577.4    418.1    855.3    534.4    191.1
# 8    4880   0.0      0.0      880.0    880.0    880.0

# Em quadrados (dividido por 200):
# x: [0, 3.485, 6.97, 10.455, 13.945, 17.43, 20.915, 24.4]
# planSheer: [4.60, 4.8755, 5.029, 5.1245, 4.962, 4.3745, 2.887, 0.0]
# planChine: [3.70, 3.9245, 4.074, 4.10, 3.871, 3.282, 2.0905, 0.0]
# profSheer: [4.25, 4.25, 4.25, 4.25, 4.25, 4.25, 4.2765, 4.40]
# profChine: [1.238, 1.243, 1.2895, 1.394, 1.5345, 1.812, 2.672, 4.40]
# profKeel:  [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.9555, 4.40]

# Vamos passar nós bem distribuídos para ajustar.py
# Selecionamos estações representativas para nós de spline
cmd = [
    "python3", "/home/magdalena/.hermes/plugins/iarquiteto-naval-brana/skills/brana-rascunho-2d-interativo/scripts/ajustar.py",
    "--loa-sq", str(loa_sq),
    "--projeto", "/home/magdalena/eee/alunos/victor-lei/projeto.json",
    "--curva", "planSheer", "0,4.60", "6.97,5.029", "10.455,5.1245", "17.43,4.3745", "20.915,2.887", "24.4,0",
    "--curva", "planChine", "0,3.70", "6.97,4.074", "10.455,4.10", "17.43,3.282", "20.915,2.0905", "24.4,0",
    "--curva", "profSheer", "0,4.25", "6.97,4.25", "13.945,4.25", "17.43,4.25", "20.915,4.2765", "24.4,4.40",
    "--curva", "profChine", "0,1.238", "6.97,1.2895", "10.455,1.394", "17.43,1.812", "20.915,2.672", "24.4,4.40",
    "--curva", "profKeel",  "0,0.0", "6.97,0.0", "13.945,0.0", "17.43,0.0", "20.915,0.9555", "24.4,4.40"
]

res = subprocess.run(cmd, capture_output=True, text=True)
print("Ajustar output:\n", res.stdout)
if res.stderr:
    print("Ajustar error:\n", res.stderr)

