AcornElectron

Changeset

43:7f0bd49f1912
2014-10-07 Paul Boddie raw files shortlog changelog graph Added configuration options for separating the pieces and omitting features.
cartridge.scad (file)
     1.1 --- a/cartridge.scad	Tue Oct 07 18:30:46 2014 +0200
     1.2 +++ b/cartridge.scad	Tue Oct 07 19:13:16 2014 +0200
     1.3 @@ -26,6 +26,10 @@
     1.4  	TOP_LABEL_INSET = 1;
     1.5  	GROOVE = 1;
     1.6  
     1.7 +	BACK = 1; BACK_SURFACE = 1;
     1.8 +	FRONT = 1; FRONT_SURFACE = 1;
     1.9 +	APART = 1;
    1.10 +
    1.11  	/*
    1.12  	Rounding/fillet radius and additional margin of subtracted
    1.13  	material. The additional margin helps avoid geometry problems.
    1.14 @@ -359,364 +363,380 @@
    1.15  
    1.16  	/* The actual shapes. */
    1.17  
    1.18 -	translate([-width * 0.6, 0, 0])
    1.19 -	difference() {
    1.20 +	front_displacement = APART ? -width * 0.6 : 0;
    1.21 +
    1.22 +	if (FRONT)
    1.23 +		translate([front_displacement, 0, 0])
    1.24 +		difference() {
    1.25  
    1.26 -		/* The cartridge surfaces. */
    1.27 +			/* The cartridge surfaces. */
    1.28  
    1.29 -		union() {
    1.30 +			union() {
    1.31  
    1.32 -			/* Front portion. */
    1.33 +				/* Front portion. */
    1.34  
    1.35 -			translate([0, -front_depth + front / 2, 0])
    1.36 -				cube([width, front, height], center = true);
    1.37 -			translate([-width / 2 + front_left / 2, -front_depth / 2, 0])
    1.38 -				cube([front_left, front_depth, height], center = true);
    1.39 -			translate([width / 2 - front_right / 2, -front_depth / 2, 0])
    1.40 -				cube([front_right, front_depth, height], center = true);
    1.41 -			translate([0, -front_depth / 2, height / 2 - top / 2])
    1.42 -				cube([width, front_depth, top], center = true);
    1.43 -			difference() {
    1.44 +				if (FRONT_SURFACE) {
    1.45 +					cube_at(width, front, height,
    1.46 +						0, -1, 0,
    1.47 +						0, -int_front_depth, 0);
    1.48 +					cube_at(front_left, front_depth, height,
    1.49 +						-1, -1, 0,
    1.50 +						-int_width / 2, 0, 0);
    1.51 +					cube_at(front_right, front_depth, height,
    1.52 +						1, -1, 0,
    1.53 +						int_width / 2, 0, 0);
    1.54 +					cube_at(width, front_depth, top,
    1.55 +						0, -1, 1,
    1.56 +						0, 0, int_payload_upper_extent);
    1.57 +				}
    1.58  
    1.59 -				/* Floor of cartridge. */
    1.60 +				difference() {
    1.61 +
    1.62 +					/* Floor of cartridge. */
    1.63 +
    1.64 +					cube_at(width, front_depth, bottom,
    1.65 +						0, -1, 1,
    1.66 +						0, 0, -height / 2 + int_connector_height);
    1.67 +
    1.68 +					/* Left cutout. */
    1.69  
    1.70 -				cube_at(width, front_depth, bottom,
    1.71 -					0, -1, 1,
    1.72 -					0, 0, -height / 2 + int_connector_height);
    1.73 +					cube_at(edge_connector_cutout_front_width,
    1.74 +						edge_connector_cutout_front_depth,
    1.75 +						bottom,
    1.76 +						1, -1, 1,
    1.77 +						-width / 2 + edge_connector_cutout_front_offset,
    1.78 +						0,
    1.79 +						-height / 2 + int_connector_height);
    1.80 +
    1.81 +					/* Right cutout. */
    1.82  
    1.83 -				/* Left cutout. */
    1.84 +					cube_at(edge_connector_cutout_front_width,
    1.85 +						edge_connector_cutout_front_depth,
    1.86 +						bottom,
    1.87 +						-1, -1, 1,
    1.88 +						width / 2 - edge_connector_cutout_front_offset,
    1.89 +						0,
    1.90 +						-height / 2 + int_connector_height);
    1.91 +				}
    1.92 +
    1.93 +				/* PCB supports. */
    1.94  
    1.95 -				cube_at(edge_connector_cutout_front_width,
    1.96 -					edge_connector_cutout_front_depth,
    1.97 -					bottom,
    1.98 -					1, -1, 1,
    1.99 -					-width / 2 + edge_connector_cutout_front_offset,
   1.100 -					0,
   1.101 -					-height / 2 + int_connector_height);
   1.102 +				cube_at(pcb_front_support_width,
   1.103 +						pcb_front_support_depth,
   1.104 +						pcb_front_support_height,
   1.105 +						1, -1, 1,
   1.106 +						-edge_connector_cutout_back_width / 2 +
   1.107 +							pcb_support_margin,
   1.108 +						0,
   1.109 +						-height / 2 + bottom + int_connector_height);
   1.110  
   1.111 -				/* Right cutout. */
   1.112 +				cube_at(pcb_front_support_width,
   1.113 +						pcb_front_support_depth,
   1.114 +						pcb_front_support_height,
   1.115 +						-1, -1, 1,
   1.116 +						edge_connector_cutout_back_width / 2 -
   1.117 +							pcb_support_margin,
   1.118 +						0,
   1.119 +						-height / 2 + bottom + int_connector_height);
   1.120  
   1.121 -				cube_at(edge_connector_cutout_front_width,
   1.122 -					edge_connector_cutout_front_depth,
   1.123 -					bottom,
   1.124 -					-1, -1, 1,
   1.125 -					width / 2 - edge_connector_cutout_front_offset,
   1.126 -					0,
   1.127 -					-height / 2 + int_connector_height);
   1.128 +				/* Circular "lugs" to hold PCBs in place. */
   1.129 +
   1.130 +				pcb_front_lug(-1);
   1.131 +				pcb_front_lug(1);
   1.132  			}
   1.133  
   1.134 -			/* PCB supports. */
   1.135 +			/* Label insets. */
   1.136 +
   1.137 +			union() {
   1.138 +
   1.139 +				/* Front label. */
   1.140  
   1.141 -			cube_at(pcb_front_support_width,
   1.142 -					pcb_front_support_depth,
   1.143 -					pcb_front_support_height,
   1.144 -					1, -1, 1,
   1.145 -					-edge_connector_cutout_back_width / 2 +
   1.146 -						pcb_support_margin,
   1.147 -					0,
   1.148 -					-height / 2 + bottom + int_connector_height);
   1.149 -
   1.150 -			cube_at(pcb_front_support_width,
   1.151 -					pcb_front_support_depth,
   1.152 -					pcb_front_support_height,
   1.153 -					-1, -1, 1,
   1.154 -					edge_connector_cutout_back_width / 2 -
   1.155 -						pcb_support_margin,
   1.156 -					0,
   1.157 -					-height / 2 + bottom + int_connector_height);
   1.158 +				if (FRONT_LABEL_INSET)
   1.159 +					translate([-front_label_width / 2, -front_depth,
   1.160 +						front_label_offset_from_bottom - height / 2])
   1.161 +						cube([front_label_width, front_label_depth,
   1.162 +							front_label_height]);
   1.163  
   1.164 -			/* Circular "lugs" to hold PCBs in place. */
   1.165 -
   1.166 -			pcb_front_lug(-1);
   1.167 -			pcb_front_lug(1);
   1.168 -		}
   1.169 -
   1.170 -		/* Label insets. */
   1.171 -
   1.172 -		union() {
   1.173 +				/* Top label. See also the back piece. */
   1.174  
   1.175 -			/* Front label. */
   1.176 +				if (TOP_LABEL_INSET)
   1.177 +					translate([-top_label_width / 2,
   1.178 +						-front_depth + top_label_offset_from_front,
   1.179 +						height / 2 - top_label_depth])
   1.180 +						cube([top_label_width, top_label_height,
   1.181 +							top_label_depth]);
   1.182 +			}
   1.183  
   1.184 -			if (FRONT_LABEL_INSET)
   1.185 -				translate([-front_label_width / 2, -front_depth,
   1.186 -					front_label_offset_from_bottom - height / 2])
   1.187 -					cube([front_label_width, front_label_depth,
   1.188 -						front_label_height]);
   1.189 -
   1.190 -			/* Top label. See also the back piece. */
   1.191 +			/* Inner front edge cavity. */
   1.192  
   1.193 -			if (TOP_LABEL_INSET)
   1.194 -				translate([-top_label_width / 2,
   1.195 -					-front_depth + top_label_offset_from_front,
   1.196 -					height / 2 - top_label_depth])
   1.197 -					cube([top_label_width, top_label_height,
   1.198 -						top_label_depth]);
   1.199 -		}
   1.200 -
   1.201 -		/* Inner front edge cavity. */
   1.202 +			translate([inner_front_edge_width / 2, -int_front_depth, -height / 2])
   1.203 +				rotate([0, -90, 0])
   1.204 +					linear_extrude(height = inner_front_edge_width)
   1.205 +						polygon([
   1.206 +							[-extra, -inner_front_edge_depth],
   1.207 +							[0, -inner_front_edge_depth],
   1.208 +							[inner_front_edge_height, 0],
   1.209 +							[-extra, 0],
   1.210 +							]);
   1.211  
   1.212 -		translate([inner_front_edge_width / 2, -int_front_depth, -height / 2])
   1.213 -			rotate([0, -90, 0])
   1.214 -				linear_extrude(height = inner_front_edge_width)
   1.215 -					polygon([
   1.216 -						[-extra, -inner_front_edge_depth],
   1.217 -						[0, -inner_front_edge_depth],
   1.218 -						[inner_front_edge_height, 0],
   1.219 -						[-extra, 0],
   1.220 -						]);
   1.221 +			/* Inner top cutout for the top and sides of the back portion. */
   1.222  
   1.223 -		/* Inner top cutout for the top and sides of the back portion. */
   1.224 +			cube_at(inner_top_front_cutout_width,
   1.225 +				inner_top_front_cutout_depth,
   1.226 +				inner_top_front_cutout_height,
   1.227 +				0, -1, 1,
   1.228 +				0, 0, int_payload_upper_extent);
   1.229  
   1.230 -		cube_at(inner_top_front_cutout_width,
   1.231 -			inner_top_front_cutout_depth,
   1.232 -			inner_top_front_cutout_height,
   1.233 -			0, -1, 1,
   1.234 -			0, 0, int_payload_upper_extent);
   1.235 +			cube_at(inner_side_front_cutout_width,
   1.236 +				inner_side_front_cutout_depth,
   1.237 +				inner_side_front_cutout_height,
   1.238 +				1, -1, 0,
   1.239 +				int_width / 2, 0, -inner_top_front_cutout_height);
   1.240  
   1.241 -		cube_at(inner_side_front_cutout_width,
   1.242 -			inner_side_front_cutout_depth,
   1.243 -			inner_side_front_cutout_height,
   1.244 -			1, -1, 0,
   1.245 -			int_width / 2, 0, -inner_top_front_cutout_height);
   1.246 +			cube_at(inner_side_front_cutout_width,
   1.247 +				inner_side_front_cutout_depth,
   1.248 +				inner_side_front_cutout_height,
   1.249 +				-1, -1, 0,
   1.250 +				-int_width / 2, 0, -inner_top_front_cutout_height);
   1.251  
   1.252 -		cube_at(inner_side_front_cutout_width,
   1.253 -			inner_side_front_cutout_depth,
   1.254 -			inner_side_front_cutout_height,
   1.255 -			-1, -1, 0,
   1.256 -			-int_width / 2, 0, -inner_top_front_cutout_height);
   1.257 +			/* Fillets to round off the edges. */
   1.258 +
   1.259 +			union() {
   1.260  
   1.261 -		/* Fillets to round off the edges. */
   1.262 -
   1.263 -		union() {
   1.264 -
   1.265 -			/* Top left and right rounding. */
   1.266 -		
   1.267 -			translate([-width / 2 + ro, -front_depth / 2, height / 2 - ro])
   1.268 -				rotate([0, 0, 180])
   1.269 +				/* Top left and right rounding. */
   1.270 +			
   1.271 +				translate([-width / 2 + ro, -front_depth / 2, height / 2 - ro])
   1.272 +					rotate([0, 0, 180])
   1.273 +						rotate([90, 0, 0])
   1.274 +							fillet(rr, front_depth);
   1.275 +				translate([width / 2 - ro, -front_depth / 2, height / 2 - ro])
   1.276  					rotate([90, 0, 0])
   1.277  						fillet(rr, front_depth);
   1.278 -			translate([width / 2 - ro, -front_depth / 2, height / 2 - ro])
   1.279 -				rotate([90, 0, 0])
   1.280 -					fillet(rr, front_depth);
   1.281  
   1.282 -			/* Top front rounding. */
   1.283 -		
   1.284 -			translate([0, -front_depth + ro, height / 2 - ro])
   1.285 -				rotate([0, 0, 180])
   1.286 -					rotate([0, -90, 0])
   1.287 -						fillet(rr, width);
   1.288 +				/* Top front rounding. */
   1.289 +			
   1.290 +				translate([0, -front_depth + ro, height / 2 - ro])
   1.291 +					rotate([0, 0, 180])
   1.292 +						rotate([0, -90, 0])
   1.293 +							fillet(rr, width);
   1.294  
   1.295 -			/* Edge rounding. */
   1.296 -		
   1.297 -			translate([-width / 2 + ro, -front_depth + ro, 0])
   1.298 -				rotate([0, 0, 180])
   1.299 -					fillet(rr, height);
   1.300 -			translate([width / 2 - ro, -front_depth + ro, 0])
   1.301 -				rotate([0, 0, 270])
   1.302 -					fillet(rr, height);
   1.303 +				/* Edge rounding. */
   1.304 +			
   1.305 +				translate([-width / 2 + ro, -front_depth + ro, 0])
   1.306 +					rotate([0, 0, 180])
   1.307 +						fillet(rr, height);
   1.308 +				translate([width / 2 - ro, -front_depth + ro, 0])
   1.309 +					rotate([0, 0, 270])
   1.310 +						fillet(rr, height);
   1.311 +			}
   1.312  		}
   1.313 -	}
   1.314  
   1.315  	/*
   1.316  	Place the back piece next to the front, with the internals facing out
   1.317 -	the same way.
   1.318 +	the same way, if APART is defined.
   1.319  	*/
   1.320  
   1.321 -	translate([width * 0.6, 0, 0])
   1.322 -	rotate([0, 0, 180])
   1.323 -	difference() {
   1.324 +	back_displacement = APART ? width * 0.6 : 0;
   1.325 +	back_rotation = APART ? 180 : 0;
   1.326 +
   1.327 +	if (BACK)
   1.328 +		translate([back_displacement, 0, 0])
   1.329 +		rotate([0, 0, back_rotation])
   1.330 +		difference() {
   1.331 +
   1.332 +			/* The cartridge surfaces. */
   1.333 +
   1.334 +			union() {
   1.335 +
   1.336 +				/* Back portion. */
   1.337  
   1.338 -		/* The cartridge surfaces. */
   1.339 +				if (BACK_SURFACE) {
   1.340 +					cube_at(width, back, height,
   1.341 +						0, 1, 0,
   1.342 +						0, int_back_depth, 0);
   1.343 +					cube_at(back_left, back_depth + groove_width_extra, height,
   1.344 +						-1, 1, 0,
   1.345 +						-int_width / 2, -groove_width_extra, 0);
   1.346 +					cube_at(back_right, back_depth + groove_width_extra, height,
   1.347 +						1, 1, 0,
   1.348 +						int_width / 2, -groove_width_extra, 0);
   1.349 +					cube_at(width, back_depth + groove_width_extra, top,
   1.350 +						0, 1, 1,
   1.351 +						0, -groove_width_extra, int_payload_upper_extent);
   1.352 +				}
   1.353  
   1.354 -		union() {
   1.355 +				difference() {
   1.356  
   1.357 -			/* Back portion. */
   1.358 +					/* Floor of cartridge. */
   1.359  
   1.360 -			cube_at(width, back, height,
   1.361 -				0, 1, 0,
   1.362 -				0, int_back_depth, 0);
   1.363 -			cube_at(back_left, back_depth + groove_width_extra, height,
   1.364 -				-1, 1, 0,
   1.365 -				-int_width / 2, -groove_width_extra, 0);
   1.366 -			cube_at(back_right, back_depth + groove_width_extra, height,
   1.367 -				1, 1, 0,
   1.368 -				int_width / 2, -groove_width_extra, 0);
   1.369 -			cube_at(width, back_depth + groove_width_extra, top,
   1.370 -				0, 1, 1,
   1.371 -				0, -groove_width_extra, int_payload_upper_extent);
   1.372 +					cube_at(width, back_depth, bottom,
   1.373 +						0, 1, 1,
   1.374 +						0, 0, -height / 2 + int_connector_height);
   1.375 +
   1.376 +					/* Edge connector cutout. */
   1.377 +
   1.378 +					cube_at(edge_connector_cutout_back_width,
   1.379 +						edge_connector_cutout_back_depth,
   1.380 +						bottom,
   1.381 +						0, 1, 1,
   1.382 +						0, 0, -height / 2 + int_connector_height);
   1.383 +				}
   1.384 +
   1.385 +				/* PCB supports. */
   1.386  
   1.387 -			difference() {
   1.388 -
   1.389 -				/* Floor of cartridge. */
   1.390 +				pcb_support(-1, pcb_back_support_left_bump_height,
   1.391 +					pcb_back_support_left_bump_offset_from_bottom);
   1.392 +				pcb_support(1, pcb_back_support_right_bump_height,
   1.393 +					pcb_back_support_right_bump_offset_from_bottom);
   1.394  
   1.395 -				cube_at(width, back_depth, bottom,
   1.396 -					0, 1, 1,
   1.397 -					0, 0, -height / 2 + int_connector_height);
   1.398 +				/* Circular "lugs" to hold PCBs in place. */
   1.399 +
   1.400 +				pcb_lug(-1);
   1.401 +				pcb_lug(1);
   1.402 +			}
   1.403  
   1.404 -				/* Edge connector cutout. */
   1.405 +			/* Label insets. */
   1.406 +
   1.407 +			union() {
   1.408 +
   1.409 +				/* Top label. See also the front piece. */
   1.410  
   1.411 -				cube_at(edge_connector_cutout_back_width,
   1.412 -					edge_connector_cutout_back_depth,
   1.413 -					bottom,
   1.414 -					0, 1, 1,
   1.415 -					0, 0, -height / 2 + int_connector_height);
   1.416 +				if (TOP_LABEL_INSET)
   1.417 +					translate([-top_label_width / 2,
   1.418 +						-front_depth + top_label_offset_from_front,
   1.419 +						height / 2 - top_label_depth])
   1.420 +						cube([top_label_width, top_label_height,
   1.421 +							top_label_depth]);
   1.422  			}
   1.423  
   1.424 -			/* PCB supports. */
   1.425 -
   1.426 -			pcb_support(-1, pcb_back_support_left_bump_height,
   1.427 -				pcb_back_support_left_bump_offset_from_bottom);
   1.428 -			pcb_support(1, pcb_back_support_right_bump_height,
   1.429 -				pcb_back_support_right_bump_offset_from_bottom);
   1.430 -
   1.431 -			/* Circular "lugs" to hold PCBs in place. */
   1.432 +			/* Top and side grooves, positioned in the back portion. */
   1.433  
   1.434 -			pcb_lug(-1);
   1.435 -			pcb_lug(1);
   1.436 -		}
   1.437 +			union() {
   1.438  
   1.439 -		/* Label insets. */
   1.440 -
   1.441 -		union() {
   1.442 -
   1.443 -			/* Top label. See also the front piece. */
   1.444 +				/* Left groove. */
   1.445  
   1.446 -			if (TOP_LABEL_INSET)
   1.447 -				translate([-top_label_width / 2,
   1.448 -					-front_depth + top_label_offset_from_front,
   1.449 -					height / 2 - top_label_depth])
   1.450 -					cube([top_label_width, top_label_height,
   1.451 -						top_label_depth]);
   1.452 -		}
   1.453 -
   1.454 -		/* Top and side grooves, positioned in the back portion. */
   1.455 -
   1.456 -		union() {
   1.457 +				cube_at(groove_depth, groove_width, height,
   1.458 +					1, 1, 0,
   1.459 +					-width / 2, -groove_width_extra, 0);
   1.460  
   1.461 -			/* Left groove. */
   1.462 -
   1.463 -			cube_at(groove_depth, groove_width, height,
   1.464 -				1, 1, 0,
   1.465 -				-width / 2, -groove_width_extra, 0);
   1.466 -
   1.467 -			/* Right groove. */
   1.468 -
   1.469 -			cube_at(groove_depth, groove_width, height,
   1.470 -				-1, 1, 0,
   1.471 -				width / 2, -groove_width_extra, 0);
   1.472 +				/* Right groove. */
   1.473  
   1.474 -			/* Top grooves. */
   1.475 -
   1.476 -			cube_at(width, groove_width, groove_depth,
   1.477 -				0, 1, -1,
   1.478 -				0, -groove_width_extra, height / 2);
   1.479 +				cube_at(groove_depth, groove_width, height,
   1.480 +					-1, 1, 0,
   1.481 +					width / 2, -groove_width_extra, 0);
   1.482  
   1.483 -			cube_at(width, top_groove_width, top_groove_depth,
   1.484 -				0, 1, -1,
   1.485 -				0, -groove_width_extra, height / 2);
   1.486 -		}
   1.487 -
   1.488 -		/* Back cavity. */
   1.489 -
   1.490 -		if (BACK_CAVITY)
   1.491 -			intersection() {
   1.492 -
   1.493 -				/* From the bottom upwards. */
   1.494 +				/* Top grooves. */
   1.495  
   1.496 -				translate([0, back_depth, -height / 2])
   1.497 -					linear_extrude(height = back_cavity_height)
   1.498 -						translate([-int_width / 2, 0, 0])
   1.499 -							polygon([
   1.500 -								[back_cavity_offset_from_inner_left, 0],
   1.501 -								[back_cavity_inner_offset_from_inner_left,
   1.502 -									-back_cavity_depth],
   1.503 -								[back_cavity_inner_offset_from_inner_left +
   1.504 -									back_cavity_inner_width,
   1.505 -									-back_cavity_depth],
   1.506 -								[back_cavity_offset_from_inner_left +
   1.507 -									back_cavity_width, 0]
   1.508 -								]);
   1.509 +				cube_at(width, groove_width, groove_depth,
   1.510 +					0, 1, -1,
   1.511 +					0, -groove_width_extra, height / 2);
   1.512  
   1.513 -				/* From left to right. */
   1.514 -
   1.515 -				translate([back_cavity_width / 2, back_depth, -height / 2])
   1.516 -					rotate([0, -90, 0])
   1.517 -						linear_extrude(height = back_cavity_width)
   1.518 -							polygon([
   1.519 -								[-extra, -back_cavity_depth],
   1.520 -								[back_cavity_inner_height,
   1.521 -									-back_cavity_depth],
   1.522 -								[back_cavity_height, 0],
   1.523 -								[-extra, 0]
   1.524 -								]);
   1.525 +				cube_at(width, top_groove_width, top_groove_depth,
   1.526 +					0, 1, -1,
   1.527 +					0, -groove_width_extra, height / 2);
   1.528  			}
   1.529  
   1.530 -		/* Inner back cavities. */
   1.531 +			/* Back cavity. */
   1.532 +
   1.533 +			if (BACK_CAVITY)
   1.534 +				intersection() {
   1.535 +
   1.536 +					/* From the bottom upwards. */
   1.537  
   1.538 -		translate([0, int_back_depth, -height / 2])
   1.539 -			linear_extrude(height = int_connector_height)
   1.540 -				translate([-int_width / 2, 0, 0])
   1.541 -					polygon([
   1.542 -						[0, 0],
   1.543 -						[inner_back_slope_max_offset, 0],
   1.544 -						[inner_back_slope_min_offset,
   1.545 -							inner_back_slope_depth],
   1.546 -						[0, inner_back_slope_depth]
   1.547 -						]);
   1.548 +					translate([0, back_depth, -height / 2])
   1.549 +						linear_extrude(height = back_cavity_height)
   1.550 +							translate([-int_width / 2, 0, 0])
   1.551 +								polygon([
   1.552 +									[back_cavity_offset_from_inner_left, 0],
   1.553 +									[back_cavity_inner_offset_from_inner_left,
   1.554 +										-back_cavity_depth],
   1.555 +									[back_cavity_inner_offset_from_inner_left +
   1.556 +										back_cavity_inner_width,
   1.557 +										-back_cavity_depth],
   1.558 +									[back_cavity_offset_from_inner_left +
   1.559 +										back_cavity_width, 0]
   1.560 +									]);
   1.561 +
   1.562 +					/* From left to right. */
   1.563 +
   1.564 +					translate([back_cavity_width / 2, back_depth, -height / 2])
   1.565 +						rotate([0, -90, 0])
   1.566 +							linear_extrude(height = back_cavity_width)
   1.567 +								polygon([
   1.568 +									[-extra, -back_cavity_depth],
   1.569 +									[back_cavity_inner_height,
   1.570 +										-back_cavity_depth],
   1.571 +									[back_cavity_height, 0],
   1.572 +									[-extra, 0]
   1.573 +									]);
   1.574 +				}
   1.575 +
   1.576 +			/* Inner back cavities. */
   1.577  
   1.578 -		translate([0, int_back_depth, -height / 2])
   1.579 -			linear_extrude(height = int_connector_height)
   1.580 -				translate([int_width / 2, 0, 0])
   1.581 -					polygon([
   1.582 -						[0, 0],
   1.583 -						[-inner_back_slope_max_offset, 0],
   1.584 -						[-inner_back_slope_min_offset,
   1.585 -							inner_back_slope_depth],
   1.586 -						[0, inner_back_slope_depth]
   1.587 -						]);
   1.588 +			translate([0, int_back_depth, -height / 2])
   1.589 +				linear_extrude(height = int_connector_height)
   1.590 +					translate([-int_width / 2, 0, 0])
   1.591 +						polygon([
   1.592 +							[0, 0],
   1.593 +							[inner_back_slope_max_offset, 0],
   1.594 +							[inner_back_slope_min_offset,
   1.595 +								inner_back_slope_depth],
   1.596 +							[0, inner_back_slope_depth]
   1.597 +							]);
   1.598  
   1.599 -		/* Inner back edge cavity. */
   1.600 +			translate([0, int_back_depth, -height / 2])
   1.601 +				linear_extrude(height = int_connector_height)
   1.602 +					translate([int_width / 2, 0, 0])
   1.603 +						polygon([
   1.604 +							[0, 0],
   1.605 +							[-inner_back_slope_max_offset, 0],
   1.606 +							[-inner_back_slope_min_offset,
   1.607 +								inner_back_slope_depth],
   1.608 +							[0, inner_back_slope_depth]
   1.609 +							]);
   1.610  
   1.611 -		translate([inner_back_edge_width / 2,
   1.612 -			int_back_depth + inner_back_edge_depth, -height / 2])
   1.613 -			rotate([0, -90, 0])
   1.614 -				linear_extrude(height = inner_back_edge_width)
   1.615 -					polygon([
   1.616 -						[-extra, -inner_back_edge_depth],
   1.617 -						[inner_back_edge_height, -inner_back_edge_depth],
   1.618 -						[0, 0],
   1.619 -						[-extra, 0]
   1.620 -						]);
   1.621 +			/* Inner back edge cavity. */
   1.622  
   1.623 -		/* Fillets to round off the edges. */
   1.624 -
   1.625 -		union() {
   1.626 +			translate([inner_back_edge_width / 2,
   1.627 +				int_back_depth + inner_back_edge_depth, -height / 2])
   1.628 +				rotate([0, -90, 0])
   1.629 +					linear_extrude(height = inner_back_edge_width)
   1.630 +						polygon([
   1.631 +							[-extra, -inner_back_edge_depth],
   1.632 +							[inner_back_edge_height, -inner_back_edge_depth],
   1.633 +							[0, 0],
   1.634 +							[-extra, 0]
   1.635 +							]);
   1.636  
   1.637 -			/* Top left and right rounding. */
   1.638 -		
   1.639 -			translate([-width / 2 + ro, back_depth / 2, height / 2 - ro])
   1.640 -				rotate([0, 0, 180])
   1.641 +			/* Fillets to round off the edges. */
   1.642 +
   1.643 +			union() {
   1.644 +
   1.645 +				/* Top left and right rounding. */
   1.646 +			
   1.647 +				translate([-width / 2 + ro, back_depth / 2, height / 2 - ro])
   1.648 +					rotate([0, 0, 180])
   1.649 +						rotate([90, 0, 0])
   1.650 +							fillet(rr, back_depth);
   1.651 +				translate([width / 2 - ro, back_depth / 2, height / 2 - ro])
   1.652  					rotate([90, 0, 0])
   1.653  						fillet(rr, back_depth);
   1.654 -			translate([width / 2 - ro, back_depth / 2, height / 2 - ro])
   1.655 -				rotate([90, 0, 0])
   1.656 -					fillet(rr, back_depth);
   1.657 -		
   1.658 -			/* Top back rounding. */
   1.659 -		
   1.660 -			translate([0, back_depth - ro, height / 2 - ro])
   1.661 -				rotate([0, -90, 0])
   1.662 -					fillet(rr, width);
   1.663 -		
   1.664 -			/* Edge rounding. */
   1.665 -		
   1.666 -			translate([width / 2 - ro, back_depth - ro, 0])
   1.667 -				fillet(rr, height);
   1.668 -			translate([-width / 2 + ro, back_depth - ro, 0])
   1.669 -				rotate([0, 0, 90])
   1.670 +			
   1.671 +				/* Top back rounding. */
   1.672 +			
   1.673 +				translate([0, back_depth - ro, height / 2 - ro])
   1.674 +					rotate([0, -90, 0])
   1.675 +						fillet(rr, width);
   1.676 +			
   1.677 +				/* Edge rounding. */
   1.678 +			
   1.679 +				translate([width / 2 - ro, back_depth - ro, 0])
   1.680  					fillet(rr, height);
   1.681 +				translate([-width / 2 + ro, back_depth - ro, 0])
   1.682 +					rotate([0, 0, 90])
   1.683 +						fillet(rr, height);
   1.684 +			}
   1.685  		}
   1.686 -	}
   1.687  }
   1.688  
   1.689  cartridge();