// ============================================================================
// KIT D'URGENCE #13 : CLÉ DE SECOURS MULTIFONCTION 4-EN-1 (GAZ / EAU / ÉLEC / PURGE)
// Fichier paramétrique OpenSCAD — Impression recommandée : PETG / ASA / PC / Nylon
// Remplissage (Infill) : 60% à 100% Gyroid ou Rectilinear | Périmètres (Walls) : 5+
// ============================================================================
$fn = 64;

arm_len = 36;
arm_dia = 14;
hub_dia = 22;
hub_h   = 14;

module tube_with_socket(outer_d, length, socket_type, socket_size, socket_depth=18) {
    difference() {
        cylinder(d=outer_d, h=length);
        translate([0, 0, length - socket_depth + 0.01]) {
            if (socket_type == "square") {
                // Empreinte carrée (avec jeu d'impression +0.35mm)
                cube([socket_size + 0.35, socket_size + 0.35, socket_depth * 2], center=true);
            } else if (socket_type == "triangle") {
                // Empreinte triangulaire équilatérale (cote sur plat ou cercle circonscrit)
                cylinder(r=(socket_size / sqrt(3)) + 0.35, h=socket_depth, $fn=3);
            } else if (socket_type == "wing") {
                // Empreinte fente papillon vanne d'arrêt compteur d'eau
                cube([outer_d + 2, 4.6, socket_depth * 2], center=true);
            }
        }
    }
}

module cle_4_en_1() {
    difference() {
        union() {
            // Moyeu central renforcé
            cylinder(d=hub_dia, h=hub_h, center=true);
            // Bras 1 (+X) : Carré 8 mm (Vanne d'eau principale / Regard / Gaines techniques)
            rotate([0, 90, 0]) tube_with_socket(arm_dia, arm_len, "square", 8.0);
            // Bras 2 (-X) : Carré 5 mm (Purgeur de radiateur chauffage central)
            rotate([0, -90, 0]) tube_with_socket(12, arm_len, "square", 5.0);
            // Bras 3 (+Y) : Triangle 9 mm (Coffret Gaz GRDF / Électricité Enedis / Borne)
            rotate([-90, 0, 0]) tube_with_socket(arm_dia, arm_len, "triangle", 9.5);
            // Bras 4 (-Y) : Fente Papillon 4.5 mm (Robinet avant/après compteur d'eau)
            rotate([90, 0, 0]) tube_with_socket(arm_dia, arm_len, "wing", 4.5);
        }
        // Anneau central passe-mousqueton EDC (diamètre 8 mm)
        cylinder(d=8, h=hub_h + 4, center=true);
    }
}

cle_4_en_1();
