def sectionizeSelection(): """Sectionize the selection.""" F = selection.check(single=True) if not F: return name = selection[0] pf.message("Sectionizing Formex '%s'" % name) ns, th, segments = sectionize.createSegments(F) if not ns: return sections, ctr, diam = sectionize.sectionize(F, segments, th) #pf.message("Centers: %s" % ctr) #pf.message("Diameters: %s" % diam) if ack('Save section data?'): types = ['Text Files (*.txt)', 'All Files (*)'] fn = askNewFilename(pf.cfg['workdir'], types) if fn: chdir(fn) fil = open(fn, 'w') fil.write("%s\n" % ctr) fil.write("%s\n" % diam) fil.close() if ack('Draw circles?'): circles = sectionize.drawCircles(sections, ctr, diam) ctrline = sectionize.connectPoints(ctr) if ack('Draw circles on Formex ?'): sectionize.drawAllCircles(F, circles) circles = Formex.concatenate(circles) circles.setProp(3) ctrline.setProp(1) draw(ctrline, color='red') export({'circles': circles, 'ctrline': ctrline, 'flypath': ctrline}) if ack('Fly through the Formex ?'): flyAlong(ctrline) ## if ack('Fly through in smooth mode ?'): ## smooth() ## flytruCircles(ctr) selection.draw()
def sectionizeSelection(): """Sectionize the selection.""" F = checkSelection(single=True) if not F: return name = selection[0] GD.message("Sectionizing Formex '%s'" % name) ns, th, segments = sectionize.createSegments(F) if not ns: return sections, ctr, diam = sectionize.sectionize(F, segments, th) # GD.message("Centers: %s" % ctr) # GD.message("Diameters: %s" % diam) if ack("Save section data?"): types = ["Text Files (*.txt)", "All Files (*)"] fn = askFilename(GD.cfg["workdir"], types, exist=False) if fn: chdir(fn) fil = file(fn, "w") fil.write("%s\n" % ctr) fil.write("%s\n" % diam) fil.close() if ack("Draw circles?"): circles = sectionize.drawCircles(sections, ctr, diam) ctrline = sectionize.connectPoints(ctr) if ack("Draw circles on Formex ?"): sectionize.drawAllCircles(F, circles) circles = Formex.concatenate(circles) circles.setProp(3) ctrline.setProp(1) draw(ctrline, color="red") export({"circles": circles, "ctrline": ctrline, "flypath": ctrline}) if ack("Fly through the Formex ?"): flyAlong(ctrline) ## if ack('Fly through in smooth mode ?'): ## smooth() ## flytruCircles(ctr) drawSelection()
def sectionizeSelection(): """Sectionize the selection.""" F = selection.check(single=True) if not F: return name = selection[0] GD.message("Sectionizing Formex '%s'" % name) ns,th,segments = sectionize.createSegments(F) if not ns: return sections,ctr,diam = sectionize.sectionize(F,segments,th) #GD.message("Centers: %s" % ctr) #GD.message("Diameters: %s" % diam) if ack('Save section data?'): types = [ 'Text Files (*.txt)', 'All Files (*)' ] fn = askFilename(GD.cfg['workdir'],types,exist=False) if fn: chdir(fn) fil = file(fn,'w') fil.write("%s\n" % ctr) fil.write("%s\n" % diam) fil.close() if ack('Draw circles?'): circles = sectionize.drawCircles(sections,ctr,diam) ctrline = sectionize.connectPoints(ctr) if ack('Draw circles on Formex ?'): sectionize.drawAllCircles(F,circles) circles = Formex.concatenate(circles) circles.setProp(3) ctrline.setProp(1) draw(ctrline,color='red') export({'circles':circles,'ctrline':ctrline,'flypath':ctrline}) if ack('Fly through the Formex ?'): flyAlong(ctrline) ## if ack('Fly through in smooth mode ?'): ## smooth() ## flytruCircles(ctr) selection.draw()
def __init__(self,F): """Initialize a plane section. Initialization can be done either by a list of points or a set of line segments. By Points: Each point is connected to the following one, and (unless they are very close) the last one back to the first. Traversing the resulting path should rotate positively around the z axis to yield a positive surface. By Segments: It is the responsibilty of the user to ensure that the segments form a closed curve. If not, the calculated section data will be rather meaningless. """ if F.nplex() == 1: self.F = sectionize.connectPoints(F,close=True) elif F.nplex() == 2: self.F = F else: raise ValueError,"Expected a plex-1 or plex-2 Formex"
def __init__(self, F): """Initialize a plane section. Initialization can be done either by a list of points or a set of line segments. By Points: Each point is connected to the following one, and (unless they are very close) the last one back to the first. Traversing the resulting path should rotate positively around the z axis to yield a positive surface. By Segments: It is the responsibilty of the user to ensure that the segments form a closed curve. If not, the calculated section data will be rather meaningless. """ if F.nplex() == 1: self.F = sectionize.connectPoints(F, close=True) elif F.nplex() == 2: self.F = F else: raise ValueError, "Expected a plex-1 or plex-2 Formex"
def square_example(scale=[1.,1.,1.]): P = Formex([[[1,1]]]).rosette(4,90).scale(scale) F = sectionize.connectPoints(P,close=True) draw(F) return sectionChar(F)