def _readMSMaterial(menuitem, microstructure, category, material): if material is not None: mscontext = ooflib.common.microstructure.microStructures[microstructure] ms = mscontext.getObject() mscontext.begin_writing() try: mat = materialmanager.getMaterial(material) pxls = microstructureIO.getCategoryPixels(microstructure, category) mat.assignToPixels(ms, pxls) finally: mscontext.end_writing()
def _readMSMaterial(menuitem, microstructure, category, material): if material is not None: mscontext = ooflib.common.microstructure.microStructures[ microstructure] ms = mscontext.getObject() mscontext.begin_writing() try: mat = materialmanager.getMaterial(material) pxls = microstructureIO.getCategoryPixels(microstructure, category) mat.assignToPixels(ms, pxls) finally: mscontext.end_writing()
def _namedactivearea(menuitem, microstructure, category, active_areas): # Get the pixels for this category, and add all the active areas # associated with this category to each pixel. ms_obj = ms_module.getMicrostructure(microstructure) pxls = microstructureIO.getCategoryPixels(microstructure, category) px_dict = {} for name in active_areas: px_dict[name] = [] for p in pxls: aal = activearea.areaListFromPixel(ms_obj, p) for name in active_areas: aal.add(name) px_dict[name].append(p) for name in active_areas: aa = ms_obj.getNamedActiveArea(name) aa.activearea.add_pixels(px_dict[name])
def _readPixelGroups(menuitem, microstructure, category, groups): mscontext = ooflib.common.microstructure.microStructures[microstructure] ms = mscontext.getObject() mscontext.begin_writing() new_group_list = [] all_group_dict = {} try: pixels = microstructureIO.getCategoryPixels(microstructure, category) for groupname in groups: (grp, newness) = ms.getGroup(groupname) grp.addPixels(pixels) all_group_dict[grp] = 1 if newness: new_group_list.append(grp) finally: mscontext.end_writing() for g in all_group_dict.keys(): switchboard.notify("changed pixel group", g, microstructure) for g in new_group_list: switchboard.notify("new pixel group", g)
def _readPixelGroups(menuitem, microstructure, category, groups): mscontext = ooflib.common.microstructure.microStructures[microstructure] ms = mscontext.getObject() mscontext.begin_writing() new_group_list = [] all_group_dict = {} try: pixels = microstructureIO.getCategoryPixels(microstructure, category) for groupname in groups: (grp, newness) = ms.getGroup(groupname) grp.add(pixels) all_group_dict[grp]=1 if newness: new_group_list.append(grp) finally: mscontext.end_writing() for g in all_group_dict: switchboard.notify("changed pixel group", g, microstructure) for g in new_group_list: switchboard.notify("new pixel group", g)