
heat_set_insert_lables     = [ "M2", "M2.5",      "M3", "M3_VORON",      "M4",      "M5",   "M6",   "M8",  "M10"];
heat_set_insert_hole_d     = [  3.2,    4.0,       4.0,        4.4,       7.5,       6.5,    8.1,    9.7,     12];
heat_set_insert_wall_w     = [  1.3,    1.6,       1.6,        1.6,       3.1,       2.6,    3.3,    4.5,      6];
heat_set_insert_hole_depth = [[3.0],  [4.0], [5.7,3.0],      [4.4], [8.1,4.0], [9.5,5.8], [12.7], [12.7], [12.7]];

// M2:
// - L=3.0, D3=3.2, w=1.3
// M2.5:
// - L=4.0, D3=4.0, w=1.6
// M3:
// - L=5.7, D3=4.0, w=1.6
// - L=3.0, D3=4.0, w=1.6
// M3_VORON:
// - L=4.4, D3=4.4, w=1.6
// M4:
// - L=8.1, D3=5.7, w=2.1
// - L=4.0, D3=5.7, w=2.1
// M5:
// - L=9.5, D3=6.5, w=2.6
// - L=5.8, D3=6.5, w=2.6
// M6:
// - L=12.7, D3=8.1, w=3.3
// M8:
// - L=12.7, D3=9.7, w=4.5
// M10:
// - L=12.7, D3=12, w=6


function heatSetInsert_get_sizes(lable) = [
	heat_set_insert_hole_d[search(lable, heat_set_insert_lables)],
	heat_set_insert_wall_w[search(lable, heat_set_insert_lables)],
	heat_set_insert_hole_depth[search(lable, heat_set_insert_lables)]
];

module heatSetInsert_wall(lable="", depth=0, d=-1, r=-1, w=-1)
{
	depths = [];
	if (lable != "")
	{
		id = search(lable, heat_set_inserts_lables);
		if (id < 0)
			error(str("heatSetInsert_wall(): could not find lable '", lable, "'"));
		d = (d==-1) ? heat_set_insert_hole_d[id] : d;
		w = (w==-1) ? heat_set_insert_wall_w[id] : w;
		depths = heat_set_insert_hole_depth[id];
	}
	r = (r==-1) ? d/2 : r;
	if (r < 0)
	{
		error("heatSetInsert_wall(): either lable, r or d has to be set");
	}
	else
	{
		if (len(depths) == 0)
		{
			if (depth <= 1)
			{
				error("heatSetInsert_wall(): either layer or depth has to be set");
			}
		}
		else
		{
			depth = (depth<=0) ? depths[round(depth)] : depth;
		}

		difference() {
			cylinder(h = L+1, r = D3/2+w);
			cylinder(h = L+1, r = D3/2);
		}
	}
}

module heatSetInsert_2d_wall(D3, L, w)
{
	difference() {
		circle(r = D3/2+w);
		circle(r = D3/2);
	}
}

module heatSetInsert_hole(D3, L, w)
{
	cylinder(h = L+1, r = D3/2);
}

module heatSetInsert_hole_2d(D3, L, w)
{
	circle(r = D3/2);
}

// M2

module heatSetInsert_wall_2d_M2()
{
	heatSetInsert_wall_2d(L=3.0, D3=3.2, w=1.3);
}
module heatSetInsert_hole_2d_M2()
{
	heatSetInsert_hole_2d(L=3.0, D3=3.2, w=1.3);
}

module heatSetInsert_wall_M2x2()
{
	heatSetInsert_wall(L=3.0, D3=3.2, w=1.3);
}
module heatSetInsert_hole_M2x2()
{
	heatSetInsert_hole(L=3.0, D3=3.2, w=1.3);
}

// M2.5

module heatSetInsert_wall_2d_M2_5x4()
{
	heatSetInsert_wall_2d(L=4.0, D3=4.0, w=1.6);
}
module heatSetInsert_hole_2d_M2_5x4()
{
	heatSetInsert_hole_2d(L=4.0, D3=4.0, w=1.6);
}

module heatSetInsert_wall_M2_5x4()
{
	heatSetInsert_wall(L=4.0, D3=4.0, w=1.6);
}
module heatSetInsert_hole_M2_5x4()
{
	heatSetInsert_hole(L=4.0, D3=4.0, w=1.6);
}

// M3

module heatSetInsert_wall_2d_M3()
{
	heatSetInsert_wall_2d(L=5.7, D3=4.0, w=1.6);
}
module heatSetInsert_hole_2d_M3()
{
	heatSetInsert_hole_2d(L=5.7, D3=4.0, w=1.6);
}

module heatSetInsert_wall_M3x5_7()
{
	heatSetInsert_wall(L=5.7, D3=4.0, w=1.6);
}
module heatSetInsert_hole_M3x5_7()
{
	heatSetInsert_hole(L=5.7, D3=4.0, w=1.6);
}

module heatSetInsert_wall_M3x3()
{
	heatSetInsert_wall(L=3.0, D3=4.0, w=1.6);
}
module heatSetInsert_hole_M3x3()
{
	heatSetInsert_hole(L=3.0, D3=4.0, w=1.6);
}

module heatSetInsert_wall_M3x5x4_voron()
{
	heatSetInsert_wall(L=4.4, D3=4.4, w=1.6);
}
module heatSetInsert_wall_2d_M3x5x4_voron()
{
	heatSetInsert_wall_2d(L=4.4, D3=4.4, w=1.6);
}
module heatSetInsert_hole_M3x5x4_voron()
{
	heatSetInsert_hole(L=4.4, D3=4.4, w=1.6);
}
module heatSetInsert_hole_2d_M3x5x4_voron()
{
	heatSetInsert_hole_2d(L=4.4, D3=4.4, w=1.6);
}

// M4

module heatSetInsert_wall_2d_M4()
{
	heatSetInsert_wall_2d(L=8.1, D3=5.7, w=2.1);
}
module heatSetInsert_hole_2d_M4()
{
	heatSetInsert_hole_2d(L=8.1, D3=5.7, w=2.1);
}

module heatSetInsert_wall_M4x8_1()
{
	heatSetInsert_wall(L=8.1, D3=5.7, w=2.1);
}
module heatSetInsert_hole_M4x8_1()
{
	heatSetInsert_hole(L=8.1, D3=5.7, w=2.1);
}

module heatSetInsert_wall_M4x4()
{
	heatSetInsert_wall(L=4.0, D3=5.7, w=2.1);
}
module heatSetInsert_hole_M4x4()
{
	heatSetInsert_hole(L=4.0, D3=5.7, w=2.1);
}

// M5

module heatSetInsert_wall_2d_M5()
{
	heatSetInsert_wall_2d(L=9.5, D3=6.5, w=2.6);
}
module heatSetInsert_hole_2d_M5()
{
	heatSetInsert_hole_2d(L=9.5, D3=6.5, w=2.6);
}

module heatSetInsert_wall_M5x9_5()
{
	heatSetInsert_wall(L=9.5, D3=6.5, w=2.6);
}
module heatSetInsert_hole_M5x9_5()
{
	heatSetInsert_hole(L=9.5, D3=6.5, w=2.6);
}

module heatSetInsert_wall_M5x5_8()
{
	heatSetInsert_wall(L=5.8, D3=6.5, w=2.6);
}
module heatSetInsert_hole_M5x5_8()
{
	heatSetInsert_hole(L=5.8, D3=6.5, w=2.6);
}

// M6

module heatSetInsert_wall_2d_M6()
{
	heatSetInsert_wall_2d(L=12.7, D3=8.1, w=3.3);
}
module heatSetInsert_hole_2d_M6()
{
	heatSetInsert_hole_2d(L=12.7, D3=8.1, w=3.3);
}

module heatSetInsert_wall_M6x12_7()
{
	heatSetInsert_wall(L=12.7, D3=8.1, w=3.3);
}
module heatSetInsert_hole_M6x12_7()
{
	heatSetInsert_hole(L=12.7, D3=8.1, w=3.3);
}

// M8

module heatSetInsert_wall_2d_M8x12_7()
{
	heatSetInsert_wall_2d(L=12.7, D3=9.7, w=4.5);
}
module heatSetInsert_hole_2d_M8x12_7()
{
	heatSetInsert_hole_2d(L=12.7, D3=9.7, w=4.5);
}

module heatSetInsert_wall_M8x12_7()
{
	heatSetInsert_wall(L=12.7, D3=9.7, w=4.5);
}
module heatSetInsert_hole_M8x12_7()
{
	heatSetInsert_hole(L=12.7, D3=9.7, w=4.5);
}

// M10

module heatSetInsert_wall_2d_M10x12_7()
{
	heatSetInsert_wall_2d(L=12.7, D3=12, w=6);
}
module heatSetInsert_hole_2d_M10x12_7()
{
	heatSetInsert_hole_2d(L=12.7, D3=12, w=6);
}

module heatSetInsert_wall_M10x12_7()
{
	heatSetInsert_wall(L=12.7, D3=12, w=6);
}
module heatSetInsert_hole_M10x12_7()
{
	heatSetInsert_hole(L=12.7, D3=12, w=6);
}

