FME Geometry, PythonCaller, GenerativeArt

#main_script import fmeobjects import numpy as np from fmeobjects import FMELine, FMEPoint, FMEPolygon from scipy.spatial import Delaunay """ build naive triangulation """ def triangle_row(start, n, L, distortion=0): H = np.sqrt(3) / 2 * L x0, y0 = start pts = np.array([ (x0 + i * (L / 2), y0 + H * np.sin(i * np.pi / 2)) for i in range(2 * n + 1) ]) if distortion 0: noise = np.random.uniform(-distortion, distortion, pts.shape) pts = pts + noise return pts class FeatureProcessor(object): def __init__(self): pass def input(self, feature: fmeobjects.FMEFeature): start_point = np.array([0,0]) trianguline = triangle_row(start_point, 10, 1,1) pline_input = list(map(tuple, trianguline)) line1 = FMELine(pline_input) feature.setGeometry(line1) self.pyoutput(feature) # random 2D points in range 0-100 pts = np.random.rand(10, 2) * 3 tri = Delaunay(pts) for simplex in tri.simplices: triangle_pts = pts[simplex] pline_input = list(map(tuple, triangle_pts)) line1 = FMELine(pline_input) polygon = FMEPolygon(line1) feature.setGeometry(polygon) self.pyoutput(feature)