"""Compare the viewer's servo MESH (st3215.stl) to the servo STEP I trim/check against.
If bboxes match, holder ∩ STEP = 0 also means holder ∩ stl = 0 (no real intersection).
"""
from build123d import import_step, import_stl

STEP = "/data/cameron/repos/cad_experiments/parts/waveshare_feetech_st3215_servo.step"
STL = "/data/cameron/repos/smith300_para_stuff/st3215.stl"


def bb(sh):
    b = sh.bounding_box()
    return (round(b.min.X, 2), round(b.min.Y, 2), round(b.min.Z, 2),
            round(b.max.X, 2), round(b.max.Y, 2), round(b.max.Z, 2))


step = import_step(STEP)
stl = import_stl(STL)
print("STEP  bbox:", bb(step))
print("stl   bbox:", bb(stl))
try:
    print("STEP volume:", round(step.volume, 1))
except Exception as e:
    print("STEP volume: n/a", e)
