From 1e625dd44343176e59f2148dc83d1a3367c2e3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Thu, 9 Nov 2017 17:33:13 +0100 Subject: [PATCH] remove openscad utils --- src/c3nav/mapdata/utils/scad.py | 41 --------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/c3nav/mapdata/utils/scad.py diff --git a/src/c3nav/mapdata/utils/scad.py b/src/c3nav/mapdata/utils/scad.py deleted file mode 100644 index 4a6081ad..00000000 --- a/src/c3nav/mapdata/utils/scad.py +++ /dev/null @@ -1,41 +0,0 @@ -import json -from decimal import Decimal - -from shapely.geometry import mapping - -from c3nav.mapdata.utils.geometry import assert_multipolygon - - -def polygon_scad(polygon, height): - results = [_polygon_scad(polygon, height=height) for polygon in assert_multipolygon(polygon)] - if not results: - raise ValueError - if len(results) == 1: - return results[0] - return 'union() {\n'+add_indent(''.join(results))+'}\n' - - -def _polygon_scad(polygon, height): - coords = mapping(polygon.simplify(0.001))['coordinates'] - - exterior = coords[0] - interiors = coords[1:] - result = 'linear_extrude(height=%.2f, center=false, convexity=20) ' % height - result += _ring_scad(exterior) - if interiors: - result = 'difference() {\n'+add_indent(result) - result += ' translate([0, 0, -0.01]) {\n' - for ring in interiors: - result += ' linear_extrude(height=%.2f, center=false, convexity=20) ' % (height+Decimal('0.02')) - result += _ring_scad(ring) - result += ' }\n' - result += '}\n' - return result - - -def _ring_scad(coords): - return 'polygon(points='+json.dumps(coords[:-1], separators=(',', ':'))+', convexity=20);\n' - - -def add_indent(text): - return ' '+text.replace('\n', '\n ')[:(-4 if text.endswith('\n') else None)]