
// export : openscad -o poignee_hometrainer.stl poignee_hometrainer.scad

D = 15.6 ;
Cut = 12.45 ;
Plan = 12.75 ;
L = 18 ;
vis = 5 ;

module axe (D, Cut, Plan, L) {
     difference () {
          cylinder (h=L, r=D/2, $fn=100) ;
          translate([-Plan/2, -(Cut-D/2)-(D-Cut), -0.1]) cube ([Plan, D-Cut, L+0.2]) ;
     }
}


//translate([0, -Cut+D/2, 0]) cube ([100, Cut, L]) ;


//difference () {
//     cylinder (h=L+5, r=D/2+5) ;
//     translate([0, 0, -0.1]) axe (D, Cut, Plan, L+0.1) ;
//     translate([0, 0, L-0.1]) cylinder (h=5+0.2, r=vis/2) ;
//}

poignee = 80 ;
bord = 2 ;

// difference ()
// {
// 
//      difference ()
//      {
//           translate([-poignee/2, -(D+10)/2, 0]) cube ([poignee, D+10, L+5]) ;
//           translate([-(poignee-bord)/2, -(D+10-bord)/2, -bord]) cube ([poignee-bord, D+10-bord, L+5+0.1]) ;
//      }          
// 
//      translate([0, 0, L-0.1]) cylinder (h=5+0.2, r=vis/2, $fn=100) ;
//                
// }
// 
//      translate([0, 0, -0.1]) axe (D, Cut, Plan, L+0.1) ;

module grille () {
     translate([-bord/4, -(D+10)/2, 0]) cube ([bord/2, D+10, L+5-2.5*bord]) ;
     
     translate([poignee/2-2.25*bord, -(D+10)/2, 0]) cube ([bord/2, D+10, L/2]) ;
     translate([-poignee/2+1.75*bord, -(D+10)/2, 0]) cube ([bord/2, D+10, L/2]) ;

     translate([poignee/5-2.25*bord, -(D+10)/2, 0]) cube ([bord/2, D+10, L/2]) ;
     translate([-poignee/5+1.75*bord, -(D+10)/2, 0]) cube ([bord/2, D+10, L/2]) ;

     translate([-poignee/2-(D+10)/2, 0, 0]) cube ([poignee+(D+10), bord/2, L]) ;
}

module bloc (Long, Larg, Haut)
{
     difference () {
     union () {
          translate([-Long/2, -(Larg)/2, 0]) cube ([Long, Larg, Haut]) ;
          translate([-Long/2, 0, 0]) cylinder (h=Haut, r=Larg/2, $fn=100) ;
          translate([Long/2, 0, 0]) cylinder (h=Haut, r=Larg/2, $fn=100) ;
     }

     translate([Long/3-bord, 1.5*Larg-bord, -0.1]) cylinder (h=Haut+0.2, r=Larg, $fn=100) ;
     translate([Long/3-bord, -1.5*Larg+bord, -0.1]) cylinder (h=Haut+0.2, r=Larg, $fn=100) ;
     translate([-Long/3+bord, 1.5*Larg-bord, -0.1]) cylinder (h=Haut+0.2, r=Larg, $fn=100) ;
     translate([-Long/3+bord, -1.5*Larg+bord, -0.1]) cylinder (h=Haut+0.2, r=Larg, $fn=100) ;

     }
}

difference ()
{
     union ()
     {
          difference () {
               bloc (poignee, D+10, L+5) ;
               translate([0, 0, bord]) bloc (poignee, D+10-bord, L+5+0.1) ;
          }
          
          translate([0, 0, bord]) difference () {
               union () {
                    cylinder (h=L, r=(D+bord*2)/2, $fn=100) ;
                    grille () ;
               }
               axe (D, Cut, Plan, L+0.1) ;
          }
     }
     
     translate([0, 0, -D/2]) cylinder (h=D, r=vis/2, $fn=100) ;
}
