def _imageFromOrientationMap(menuitem, microstructure, imagename, colorscheme): ms = ooflib.common.microstructure.microStructures[microstructure] orientdata = orientmapdata.getOrientationMap(ms.getObject()) immidge = orientdata.createImage(imagename, colorscheme) # OOFImage object immidge.setSize(ms.getObject().size()) immidge.setMicrostructure(ms.getObject()) imagemenu.loadImageIntoMS(immidge, microstructure)
def _imageFromOrientationMap(menuitem, microstructure, imagename, colorscheme): ms = ooflib.common.microstructure.microStructures[microstructure] orientdata = orientmapdata.getOrientationMap(ms.getObject()) immidge = orientdata.createImage(imagename, colorscheme) # OOFImage object immidge.setSize(ms.getObject().size()) immidge.setMicrostructure(ms.getObject()) imagemenu.loadImageIntoMS(immidge, microstructure) switchboard.notify("redraw")
def draw(self, gfxwindow, device): msobj = self.who().getObject(gfxwindow) data = orientmapdata.getOrientationMap(msobj) if data is not None: orientimage = orientmapdata.OrientMapImage(data, self.colorscheme) if config.dimension() == 2: device.draw_image(orientimage, coord.Coord(0, 0), msobj.size()) elif config.dimension() == 3: device.draw_image(orientimage, coord.Coord(0, 0, 0), msobj.size())
def __call__(self, ms, selection): curselection = selection.getObject() orientationmap = orientmapdata.getOrientationMap(ms) if orientationmap is None: raise ooferror.ErrUserError( "The Microstructure has no orientation map.") selection.start() selection.clearAndSelect( pixelselectioncouriero.OrientationSelection( orientationmap, self.orientation.corient, self.lattice_symmetry.schoenflies(), self.misorientation))
def select(self, immidge, pointlist, selector): ms = immidge.getMicrostructure() orientationmap = orientmapdata.getOrientationMap(ms) if orientationmap is None: raise ooferror.ErrUserError( "The Microstructure has no orientation map.") pt = ms.pixelFromPoint(pointlist[0]) orientation = orientationmap.angle(pt) # a swigged COrientABG selector( pixelselectioncouriero.OrientationSelection( orientationmap, orientation, self.lattice_symmetry.schoenflies(), self.misorientation))
def writeOrientationMap(datafile, mscontext): ms = mscontext.getObject() data = orientmapdata.getOrientationMap(mscontext.getObject()) if data: filename = orientmapdata.getOrientationMapFile(ms) orientations = [data.angle(pt).abg() for pt in ms.coords()] datafile.startCmd(microstructureIO.micromenu.OrientationMap) datafile.argument('microstructure', ms.name()) datafile.argument('filename', filename) datafile.argument('orientations', [[a.alpha(), a.beta(), a.gamma()] for a in orientations]) datafile.endCmd()
def select(self, immidge, points, selector): mspath = immidge.getParent().path() ms = immidge.getMicrostructure() orientationmap = orientmapdata.getOrientationMap(ms) if orientationmap is None: raise ooferror.ErrUserError( "The Microstructure has no orientation map.") startpt = ms.pixelFromPoint(points[0]) selectionctxt = ms.pixelselection.getObject() if selectionctxt.checkpixel(startpt): od = pixeldifferentiator.OrientationDifferentiator( mspath, self.local_flammability, self.global_flammability, self.lattice_symmetry) selector(BurnSelection(ms, od.cobj, startpt, self.next_nearest))
def _loadOrientationMap(menuitem, filename, reader, microstructure): # format is an Enum object. microstructure is a name. mscontext = ooflib.common.microstructure.microStructures[microstructure] mscontext.reserve() mscontext.begin_writing() try: # Check to see if the microstructure already has an # orientation map. It can't have more than one. if orientmapdata.getOrientationMap(mscontext.getObject()) is not None: raise ooferror.ErrUserError( "A Microstructure can contain only one orientation map.") data = reader.read(filename) # creates OrientMap object if (mscontext.getObject().sizeInPixels() != data.sizeInPixels() or mscontext.getObject().size() != data.size()): raise ooferror.ErrUserError( "Cannot load orientation map into an existing Microstructure of a different size. ms=%sx%s (%dx%d), map=%sx%s (%dx%d)" % ( mscontext.getObject().size()[0], mscontext.getObject().size()[1], mscontext.getObject().sizeInPixels()[0], mscontext.getObject().sizeInPixels()[1], data.size()[0], data.size()[1], data.sizeInPixels()[0], data.sizeInPixels()[1])) # Registering the OrientMapData object under its # microstructure's name allows it to be found by the # OrientationMapProp Property in C++. orientmapdata.registerOrientMap(microstructure, data) data.setMicrostructure(mscontext.getObject()) # Storing it as a Python Microstructure plug-in allows the # data to be found by Python (and keeps a live reference to # it, so we don't have to transfer ownership to C++). All of # this registration doesn't actually duplicate the data. orientmapplugin = mscontext.getObject().getPlugIn("OrientationMap") orientmapplugin.set_data(data, filename) orientmapplugin.timestamp.increment() finally: mscontext.end_writing() mscontext.cancel_reservation() reader.postProcess(mscontext) orientmapdata.orientationmapNotify(mscontext.getObject())
def _loadOrientationMap(menuitem, filename, reader, microstructure): # format is an Enum object. microstructure is a name. mscontext = ooflib.common.microstructure.microStructures[microstructure] mscontext.reserve() mscontext.begin_writing() try: # Check to see if the microstructure already has an # orientation map. It can't have more than one. if orientmapdata.getOrientationMap(mscontext.getObject()) is not None: raise ooferror.ErrUserError( "A Microstructure can contain only one orientation map.") data = reader.read(filename) # creates OrientMap object if (mscontext.getObject().sizeInPixels() != data.sizeInPixels() or mscontext.getObject().size() != data.size()): raise ooferror.ErrUserError( "Cannot load orientation map into an existing Microstructure of a different size. ms=%sx%s (%dx%d), map=%sx%s (%dx%d)" % ( mscontext.getObject().size()[0], mscontext.getObject().size()[1], mscontext.getObject().sizeInPixels()[0], mscontext.getObject().sizeInPixels()[1], data.size()[0], data.size()[1], data.sizeInPixels()[0], data.sizeInPixels()[1])) # Registering the OrientMapData object under its # microstructure's name allows it to be found by the # OrientationMapProp Property in C++. orientmapdata.registerOrientMap(microstructure, data) # Storing it as a Python Microstructure plug-in allows the # data to be found by Python (and keeps a live reference to # it, so we don't have to transfer ownership to C++). All of # this registration doesn't actually duplicate the data. orientmapplugin = mscontext.getObject().getPlugIn("OrientationMap") orientmapplugin.set_data(data, filename) orientmapplugin.timestamp.increment() finally: mscontext.end_writing() mscontext.cancel_reservation() reader.postProcess(mscontext) orientmapdata.orientationmapNotify(mscontext.getObject())
def draw(self, gfxwindow, device): msobj = self.who().getObject(gfxwindow) data = orientmapdata.getOrientationMap(msobj) if data is not None: orientimage = orientmapdata.OrientMapImage(data, self.colorscheme) device.draw_image(orientimage, coord.Coord(0,0), msobj.size())
def _withoutOrientationMap(who): result = (whoville.excludeProxies(who) and orientmapdata.getOrientationMap(who.getObject()) is None) return result
def _withOrientationMap(who): return (whoville.excludeProxies(who) and orientmapdata.getOrientationMap(who.getObject()) is not None)
def _withoutOrientationMap(who): result = whoville.excludeProxies(who) and orientmapdata.getOrientationMap(who.getObject()) is None return result
def _withOrientationMap(who): return whoville.excludeProxies(who) and orientmapdata.getOrientationMap(who.getObject()) is not None