def run(): global F, G clear() smooth() view('iso') F = cylinder(L=8., D=2., nt=36, nl=20, diag='u').centered() F = TriSurface(F).setProp(3).close(method='planar').fixNormals() G = F.rotate(90., 0).trl(0, 1.).setProp(1) export({'F': F, 'G': G}) draw([F, G]) res = askItems([ _I('op', text='Operation', choices=[ '+ (Union)', '- (Difference)', '* Intersection', 'Intersection Curve', ], itemtype='vradio'), _I('verbose', False, text='Show stats'), ]) if not res: return op = res['op'][0] verbose = res['verbose'] if op in '+-*': I = F.boolean(G, op, verbose=verbose) else: I = F.intersection(G, verbose=verbose) clear() draw(I) if op in '+-*': return else: if ack('Create a surface inside the curve ?'): I = I.toMesh() e = connectedLineElems(I.elems) I = Mesh(I.coords, connectedLineElems(I.elems)[0]) clear() draw(I, color=red, linewidth=3) S = fillBorder(I, method='planar') draw(S)
def run(): global F,G clear() smooth() view('iso') F = cylinder(L=8.,D=2.,nt=36,nl=20,diag='u').centered() F = TriSurface(F).setProp(3).close(method='planar').fixNormals() G = F.rotate(90.,0).trl(0,1.).setProp(1) export({'F':F,'G':G}) draw([F,G]) res = askItems( [ _I('op',text='Operation',choices=[ '+ (Union)', '- (Difference)', '* Intersection', 'Intersection Curve', ],itemtype='vradio'), _I('verbose',False,text='Show stats'), ]) if not res: return op = res['op'][0] verbose = res['verbose'] if op in '+-*': I = F.boolean(G,op,verbose=verbose) else: I = F.intersection(G,verbose=verbose) clear() draw(I) if op in '+-*': return else: if ack('Create a surface inside the curve ?'): I = I.toMesh() e = connectedLineElems(I.elems) I = Mesh(I.coords,connectedLineElems(I.elems)[0]) clear() draw(I,color=red,linewidth=3) S = fillBorder(I,method='planar') draw(S)