예제 #1
0
        return max(self.timestamp, skelcontext.bdyselected)


defaultSelSkelBdyColor = color.orange
defaultSelSkelBdyLineWidth = 4
defaultSelSkelBdyDotSize = 4
if config.dimension() == 2:
    defaultSelSkelBdyArrowSize = 10
    arrowparam = parameter.IntRangeParameter(
        'arrowsize', (0, 20),
        defaultSelSkelBdyArrowSize,
        tip="Arrow size for edge boundaries.")
elif config.dimension() == 3:
    defaultSelSkelBdyArrowSize = 1.5
    arrowparam = parameter.FloatRangeParameter(
        'arrowsize', (0, 10, 0.1),
        defaultSelSkelBdyArrowSize,
        tip="Arrow size for edge boundaries.")


def _setSelSkelBdyParams(menuitem, color, linewidth, dotsize, arrowsize):
    global defaultSelSkelBdyColor
    global defaultSelSkelBdyLineWidth
    global defaultSelSkelBdyDotSize
    global defaultSelSkelBdyArrowSize
    defaultSelSkelBdyColor = color
    defaultSelSkelBdyLineWidth = linewidth
    defaultSelSkelBdyDotSize = dotsize
    defaultSelSkelBdyArrowSize = arrowsize


selskelbdyparams = [
예제 #2
0
    defaultVoxelRegionSelectionFaceColor = face_color
    global defaultVoxelRegionSelectionFaceOpacity
    defaultVoxelRegionSelectionFaceOpacity = face_opacity
    global defaultVoxelRegionSelectionOtherOpacity
    defaultVoxelRegionSelectionOtherOpacity = other_opacity
    global defaultHideInactive
    defaultHideInactive = hide_inactive
    global defaultDimInactive
    defaultDimInactive = dim_inactive

# Sizing and coloring options for the box and arrow. These can be
# set in the graphics defaults menu.
voxelregionselectionparams = [
    parameter.FloatRangeParameter(
        'point_size', 
        pointSizeRange,
        defaultVoxelRegionSelectionPointSize,
        tip="Size of the points on the corners of the box."),
    parameter.FloatRangeParameter(
        'line_width', 
        lineWidthRange,
        defaultVoxelRegionSelectionLineWidth,
        tip="Width of the lines on the edges of the box."),
    color.ColorParameter(
        'line_color', 
        defaultVoxelRegionSelectionLineColor,
        tip="Color for the edges of the box."), 
    color.ColorParameter(
        'face_color', 
        defaultVoxelRegionSelectionFaceColor,
        tip="Color of the faces of the box."),                   
예제 #3
0

pixelselectionmethod.PixelSelectionRegistration(
    'Orientation',
    OrientationSelector,
    ordering=1.1,
    events=['up'],
    params=[
        latticesystem.LatticeSymmetryParameter(
            'lattice_symmetry',
            tip=
            "Assume the material at each point has this symmetry, making some orientations equivalent."
        ),
        parameter.FloatRangeParameter(
            'misorientation', (0, 180, 1),
            0,
            tip=
            "Select orientations with misorientation less than this, relative to the selected pixel's orientation, in degrees."
        )
    ],
    whoclasses=['Microstructure'],
    tip=
    "Select pixels whose orientation is within the given misorientation of the selected pixel's orientation."
)

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

## TODO: This method should be suppressed in the Pixel Selection
## Toolbox if the microstructure has no orientation map.  The best way
## to do that might be to make OrientationMap a WhoClass, and treat it
## like an Image.  Then the 'whoclasses' entry in the Registration
## would do what we need here.
예제 #4
0
파일: ss22.py 프로젝트: pk-organics/OOF3D
        timestepper.NLData.__init__(self, subproblem, linsys, endtime)


def _asymmetric(subproblem):
    return ((subproblem.second_order_fields()
             and subproblem.matrix_symmetry_M == symstate.ASYMMETRIC)
            or subproblem.matrix_symmetry_C == symstate.ASYMMETRIC
            or subproblem.matrix_symmetry_K == symstate.ASYMMETRIC)


registeredclass.Registration(
    'SS22',
    timestepper.TimeStepper,
    SS22,
    params=[
        parameter.FloatRangeParameter(
            'theta1', (0.0, 1.0, 0.1),
            0.5,
            tip='First moment of the weight function for time averages.'),
        parameter.FloatRangeParameter(
            'theta2', (0.0, 1.0, 0.1),
            0.5,
            tip='Second moment of the weight function for time averages.')
    ],
    ordering=3.0,
    require_timederiv=True,
    tip=
    "Zienkowicz and Taylor's SS22 algorithm for solving equations with second order time derivatives.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/ss22.xml'))
예제 #5
0
        for segment in skel.segment_iterator():
            if segment.homogeneity(skel.MS) < self.threshold:
                selected.append(segment)
        selection.start()
        selection.clear()
        selection.select(selected)


registeredclass.Registration(
    'Select by Homogeneity',
    SegmentSelectionModifier,
    SegmentHomogeneity,
    ordering=1.5,
    params=[
        parameter.FloatRangeParameter('threshold', (0.0, 1.0, 0.01),
                                      value=0.9,
                                      tip='The threshold homogeneity.')
    ],
    tip="Select segments with homogeneity less than the given threshold.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/menu/hetero_segments.xml'))

#######################


# Select the indicated group.
class SegmentSelectGroup(SegmentSelectionModifier):
    def __init__(self, group):
        self.group = group

    def __call__(self, skeleton, selection):
예제 #6
0
class FadeImage(ImageModifier):
    def __init__(self, factor):
        self.factor = factor

    def __call__(self, image):
        image.fade(self.factor)


registeredclass.Registration(
    'Fade',
    ImageModifier,
    FadeImage,
    ordering=1.1,
    params=[
        parameter.FloatRangeParameter('factor', (0, 1, 0.01),
                                      0.1,
                                      tip="0 does nothing, 1 fades to white.")
    ],
    tip="Fade the image by the given factor.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/image/reg/fadeimage.xml'))


class DimImage(ImageModifier):
    def __init__(self, factor):
        self.factor = factor

    def __call__(self, image):
        image.dim(self.factor)


registeredclass.Registration(
예제 #7
0
class SpreadValues(imagemodifier.ImageModifier):
    def __init__(self, T):
        self.T = T

    def __call__(self, image):
        dbls = oofimage.grayify(image)
        dbls = imageops.spread(dbls, self.T)
        imageops.setFromArray(image, dbls)


registeredclass.Registration(
    "SpreadDataValues",
    imagemodifier.ImageModifier,
    SpreadValues,
    ordering=200,
    params=[parameter.FloatRangeParameter('T', (0, 1, .01), value=.5)],
    tip="Scale values over given threshold for larger spread.")


class SpreadValues2(imagemodifier.ImageModifier):
    def __init__(self, T):
        self.T = T

    def __call__(self, image):
        dbls = oofimage.grayify(image)
        dbls = imageops.spread2(dbls, self.T)
        imageops.setFromArray(image, dbls)


registeredclass.Registration(
    "SpreadDataValues2",
예제 #8
0
                self.global_flammability, self.color_space_norm == "L2")
            selector(BurnSelection(ms, cd.cobj, startpt, self.next_nearest))
            # b = BasicBurner(self.local_flammability, self.global_flammability,
            #                 self.color_space_norm==L2, self.next_nearest)
            # selector(BurnSelection(ms, b, immidge.getObject(), startpt))


pixelselectionmethod.PixelSelectionRegistration(
    'Burn',
    Burn,
    ordering=1.0,
    params=[
        parameter.FloatRangeParameter(
            'local_flammability',
            range=(0, 1, 0.001),
            value=0.1,
            tip=
            'Maximum difference in neighboring pixel values across which a burn will extend.'
        ),
        parameter.FloatRangeParameter(
            'global_flammability',
            range=(0, 1, 0.001),
            value=0.2,
            tip=
            'Difference from initial pixel value beyond which a burn will not spread.'
        ),
        enum.EnumParameter(
            'color_space_norm',
            pixeldifferentiator.ColorNorm,
            value=pixeldifferentiator.L1,
            tip="How to compute the difference between two colors in RGB space."
예제 #9
0
    global saveTilingFactor, saveMinTileScale, saveFixedSubdivision
    pixelsetboundary.cvar.tilingfactor = saveTilingFactor
    pixelsetboundary.cvar.mintilescale = saveMinTileScale
    pixelsetboundary.cvar.fixed_subdivision = saveFixedSubdivision


micromenu.addItem(
    oofmenu.OOFMenuItem(
        'SetHomogeneityParameters',
        callback=setHomogParams,
        ordering=1000,
        secret=1,
        params=[
            parameter.FloatRangeParameter(
                'factor',
                range=(0.0, 1.0, 0.01),
                default=0.5,
                tip='Refinement factor for hierarchical tiles'),
            parameter.IntParameter('minimumTileSize',
                                   default=6,
                                   tip='Minimum tile size, in pixel units'),
            parameter.AutoIntParameter('fixedSubdivision',
                                       default=automatic.automatic,
                                       tip='Fixed number of subdivisions')
        ],
        help="Set parameters for calculating element homogeneity."))

micromenu.addItem(
    oofmenu.OOFMenuItem(
        'ResetHomogeneityParameters',
        callback=resetHomogParams,
예제 #10
0
               criterion(skeleton, element):
                self.markElement(element, divisions, markedEdges)
            if prog.stopped():
                return
            prog.setFraction(1.0 * (i + 1) / n)
            prog.setMessage("checked %d/%d elements" % (i + 1, n))


registeredclass.Registration(
    'Heterogeneous Elements',
    RefinementTarget,
    CheckHomogeneity,
    ordering=0,
    params=[
        parameter.FloatRangeParameter(
            'threshold', (0.0, 1.0, 0.05),
            value=0.9,
            tip='Refine elements whose homogeneity is less than this.')
    ],
    tip='Refine heterogeneous elements.',
    discussion="""<para>
    Any elements whose <link
    linkend='Section-Concepts-Skeleton-Homogeneity'>homogeneity</link>
    is less than the given <varname>threshold</varname> will be
    refined.  <xref linkend='Figure-refine'/> illustrates the
    refinement of all elements with homogeneity less than 1.0.
    </para>""")

#####################


class SegmentChooser(registeredclass.RegisteredClass):
    defaultClipPlaneClickAndDragOpacity = plane_opacity
    global defaultHideInactive
    defaultHideInactive = hide_inactive
    global defaultDimInactive
    defaultDimInactive = dim_inactive


# Sizing and coloring options for the plane-arrow pair, which can be
# set in the graphics defaults menu.
clipplaneclickanddragparams = [
    color.ColorParameter(
        'arrow_color',
        defaultClipPlaneClickAndDragArrowColor,
        tip="Color of the arrow representing the normal vector."),
    parameter.FloatRangeParameter('arrow_tip_radius',
                                  radiusRange,
                                  defaultClipPlaneClickAndDragArrowTipRadius,
                                  tip="Radius of the arrow tip."),
    parameter.FloatRangeParameter(
        'arrow_length',
        lengthRange,
        defaultClipPlaneClickAndDragArrowLength,
        tip="Length of the arrow relative to the plane"),
    color.ColorParameter('plane_color',
                         defaultClipPlaneClickAndDragColor,
                         tip="Color of the plane."),
    parameter.FloatRangeParameter('plane_opacity',
                                  opacityRange,
                                  defaultClipPlaneClickAndDragOpacity,
                                  tip="Opacity of the plane."),
    parameter.BooleanParameter(
        'hide_inactive',
예제 #12
0
    </para>"""


class ReductionRateCondition:
    def reductionRateFailed(self, delta, total):
        if delta is None:
            return 1

    # delta is negative, if energy is going down
        reduction = -delta / total * 100.
        return reduction < self.reduction_rate


reductionRateParam = parameter.FloatRangeParameter(
    'reduction_rate', (0., 100., 0.1),
    value=0.1,
    tip=
    "Minimum allowable energy reduction rate as a percentage of the total energy."
)


class AcceptanceRateCondition:
    def acceptanceRateFailed(self, rate):
        if rate is None:
            return 1
        return rate * 100. < self.acceptance_rate


acceptanceRateParam = parameter.FloatRangeParameter(
    'acceptance_rate', (0., 100., 0.1),
    value=7,
    tip=
예제 #13
0
            self.autoOpacityFactor = factor
            self.canvaslayer.set_opacity(self.getOpacity())
    
defaultImageOpacity = 1.0
opacityRange = (0, 1, 0.05)

bitmapDisplay = registeredclass.Registration(
    'Bitmap',
    display.DisplayMethod,
    BitmapDisplayMethod,
    ordering=-100,
    layerordering=display.Planar,
    params = [
        parameter.RegisteredParameter(
            "filter",
            voxelfilter.VoxelFilterPtr,
            voxelfilter.AllVoxels(),
            tip="Voxels to include in the display."),
        parameter.FloatRangeParameter(
            "opacity",
            opacityRange,
            defaultImageOpacity,
            tip='Opacity of the image.')          
        ],
    whoclasses = ('Image',),
    tip="Display an Image as a bitmap.",
    discussion = xmlmenudump.loadFile(
        'DISCUSSIONS/common/reg/bitmapdisplay.xml')
    )

예제 #14
0
    def select(self, skelctxt, selection):
        clist, plist = selection.trackerlist()
        courier = skeletonselectioncourier.SegmentHomogeneityCourier(
            skelctxt.getObject(), self.min_homogeneity, self.max_homogeneity,
            clist, plist)
        self.operator.operate(selection, courier)


SegmentSelectionModRegistration(
    'By Homogeneity',
    SegmentHomogeneity,
    ordering=_homogeneityOrdering,
    params=[
        parameter.FloatRangeParameter(
            'min_homogeneity', (0.0, 1.0, 0.01),
            value=0.0,
            tip='Select segments with homogeneity greater than this.'),
        parameter.FloatRangeParameter(
            'max_homogeneity', (0.0, 1.0, 0.01),
            value=0.0,
            tip='Select segments with homogeneity lesss than this.'),
        selectionoperators.SelectionOperatorParam('operator')
    ],
    tip="Select segments with homogeneity less than the given threshold.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/menu/hetero_segments.xml'))

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#


class RandomSegments(SegmentSelectionModifier):
예제 #15
0
defaultSelectedElementOpacity = 0.6


def _setSelectedElementParams(menuitem, color, opacity):
    global defaultSelectedElementColor
    global defaultSelectedElementOpacity
    defaultSelectedElementColor = color
    defaultSelectedElementOpacity = opacity


selectedElementParams = [
    color.ColorParameter('color',
                         defaultSelectedElementColor,
                         tip="Color for the selected elements."),
    parameter.FloatRangeParameter('opacity', (0., 1., 0.01),
                                  defaultSelectedElementOpacity,
                                  tip="Opacity of the selected elements.")
]

mainmenu.gfxdefaultsmenu.Skeletons.addItem(
    oofmenu.OOFMenuItem(
        'Selected_Elements',
        callback=_setSelectedElementParams,
        ordering=1,
        params=selectedElementParams,
        help=
        "Set default parameters for displaying selected skeleton elements.",
        discussion="""<para>

    Set default parameters for the
    <xref linkend="RegisteredClass-SkeletonElementSelectionDisplay"/>,
예제 #16
0
#################################

findParentSegment = refine.findParentSegment
findSignature = refine.findSignature

####################

registeredclass.Registration(
    'Snap Refine',
    skeletonmodifier.SkeletonModifier,
    SnapRefine,
    ordering=400,
    params=[
        parameter.RegisteredParameter('targets',
                                      refinementtarget.RefinementTarget,
                                      tip='Target elements to be refined.'),
        parameter.RegisteredParameter('criterion',
                                      refine.RefinementCriterion,
                                      tip='Exclude certain elements.'),
        parameter.FloatRangeParameter(
            'min_distance', (0.01, 3.0, 0.01),
            value=1.0,
            tip="""Minimum distance of transition points along a given edge
from each other and the end-points, in units of the maximum pixel dimension."""
        )
        #            ,skeletonmodifier.alphaParameter
    ],
    tip="Subdivide elements along pixel boundaries.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/snaprefine.xml'))
예제 #17
0
    def fix(self, skel, element, obtuse_angles, acute_angles,
            large_solid_angles, small_solid_angles, large_dihedral_angles,
            small_dihedral_angles):
        return _removeBadTetra(skel, element, obtuse_angles, acute_angles,
                               large_solid_angles, small_solid_angles,
                               large_dihedral_angles, small_dihedral_angles)

registeredclass.Registration(
    'Remove Bad Tetrahedra',
    Rationalizer,
    RemoveBadTetrahedra,
    gerund='removing bad tetrahedra',
    ordering=20000,  # do this last!
    params=[
        parameter.FloatRangeParameter(
            'acute_angle', (0.0, 45.0, 0.5),
            value=15.0,
            tip='Minimum acceptable acute interior angle, in degrees'),
        parameter.FloatRangeParameter(
            'obtuse_angle', (90.0, 180.0, 1.0),
            value=150.0,
            tip='Maximum acceptable obtuse interior angle, in degrees')
    ],
    tip='Remove triangles with extreme interior solid angles.',
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/ration_sharp.xml'))


def _removeBadTetra(skel, element, obtuse_angles, acute_angles,
                    large_solid_angles, small_solid_angles,
                    large_dihedral_angles, small_dihedral_angles):

    faceToNodeMap = element.faceToNodeMap()
예제 #18
0
    </para>"""


class ReductionRateCondition:
    def reductionRateFailed(self, delta, total):
        if delta is None:
            return 1

    # delta is negative, if energy is going down
        reduction = -delta / total * 100.
        return reduction < self.reduction_rate


reductionRateParam = parameter.FloatRangeParameter(
    'reduction_rate', (0., 100., 0.1),
    value=0.1,
    tip=
    "Minimum allowable energy reduction rate as a percentage of the total energy."
)


class AcceptanceRateCondition:
    def acceptanceRateFailed(self, rate):
        if rate is None:
            return 1
        return rate * 100. < self.acceptance_rate


acceptanceRateParam = parameter.FloatRangeParameter(
    'acceptance_rate', (0., 100., 0.1),
    value=7,
    tip=
예제 #19
0
defaultTintOpacity = 0.9


def _setDefaultPixelSelectionParams(menuitem, color, tintOpacity):
    global defaultPixelSelectionColor
    global defaultTintOpacity
    defaultPixelSelectionColor = color
    defaultTintOpacity = tintopacity


colorparams = [
    color.ColorParameter('color',
                         defaultPixelSelectionColor,
                         tip='Color of selected pixels.'),
    parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                  defaultTintOpacity,
                                  tip='Opacity of tint of selected pixels.'
                                  '  0 is transparent, 1 is opaque.')
]

mainmenu.gfxdefaultsmenu.Pixels.addItem(
    oofmenu.OOFMenuItem(
        'Pixel_Selection',
        callback=_setDefaultPixelSelectionParams,
        params=colorparams,
        help="Set default parameters for displaying selected pixels.",
        discussion="""<para>

    Set default parameters for the <xref
    linkend="RegisteredClass:BitmapOverlayDisplayMethod"/> that is used
    to display <link linkend="Section:Concepts:Microstructure:PixelSelection">pixel selections</link>.
    This command can be put in the &oof2rc; file to set defaults for all
예제 #20
0
        selection.start()
        selection.clearAndSelect(
            pixelselectioncouriero.OrientationSelection(
                orientationmap, self.orientation.corient,
                self.lattice_symmetry.schoenflies(), self.misorientation))


registeredclass.Registration(
    'Orientation Range',
    pixelselectionmod.SelectionModifier,
    OrientationRange,
    ordering=10,
    params=[
        parameter.ConvertibleRegisteredParameter(
            'orientation',
            orientationmatrix.Orientation,
            tip="Select orientations similar to this."),
        latticesystem.LatticeSymmetryParameter(
            'lattice_symmetry',
            tip=
            "Assume the material at each point has this symmetry, making some orientations equivalent."
        ),
        parameter.FloatRangeParameter(
            'misorientation', (0, 180, 1),
            0,
            tip=
            "Select orientations with misorientation less than this, relative to the given orientation, in degrees."
        )
    ],
    tip="Select all pixels whose orientation is in a given range.")
예제 #21
0
    def fix(self, skel, element, which):
        nodes = element.nodes
        parents = element.getParents()
        if which%2 == 0:
            triangles = (ProvisionalTriangle([nodes[0], nodes[1], nodes[2]],
                                             parents=parents),
                         ProvisionalTriangle([nodes[0], nodes[2], nodes[3]],
                                             parents=parents))
        else:
            triangles = (ProvisionalTriangle([nodes[1], nodes[2], nodes[3]],
                                             parents=parents),
                         ProvisionalTriangle([nodes[0], nodes[1], nodes[3]],
                                             parents=parents))
        change = skeleton.ProvisionalChanges(skel)
        change.removeElements(element)
        change.insertElements(*triangles)
        return [change]
    
registeredclass.Registration(
    'Split Wide Quads',
    rationalize.Rationalizer,
    QuadSplit,
    gerund = 'splitting wide quads',
    ordering=1,
    params=[
    parameter.FloatRangeParameter('angle', (90.0, 180.0, 1.0), value = 150.0,
                                  tip = 'Maximum acceptable interior angle')
    ],
    tip = 'Split quadrilaterals with large interior angles.',
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/ration_wide.xml'))
예제 #22
0
        self.canvaslayer.set_opacity(self.opacity)


def _setSelectedElementParams(menuitem, color, opacity):
    global defaultSelectedElementColor
    global defaultSelectedElementOpacity
    defaultSelectedElementColor = color
    defaultSelectedElementOpacity = opacity


selectedElementParams = [
    color.ColorParameter('color',
                         defaultSelectedElementColor,
                         tip="Color for the selected elements."),
    parameter.FloatRangeParameter('opacity', (0., 1., 0.01),
                                  defaultSelectedElementOpacity,
                                  tip="Opacity of the selected elements.")
]

mainmenu.gfxdefaultsmenu.Skeletons.addItem(
    oofmenu.OOFMenuItem(
        'Selected_Elements',
        callback=_setSelectedElementParams,
        ordering=1,
        params=selectedElementParams,
        help=
        "Set default parameters for displaying selected skeleton elements.",
        discussion="""<para>

    Set default parameters for the
    <xref linkend="RegisteredClass:SkeletonElementSelectionDisplay"/>,
예제 #23
0
    from ooflib.engine import skeleton3d as skeleton
from ooflib.engine.IO import skeletongroupparams

import random

########################

# The alpha parameter for computing an element's effective energy is
# defined here so that different commands can share the same Parameter
# object.  Then GUI users won't have to be changing the parameter
# separately in all the different commands that use it.

alphaParameter = parameter.FloatRangeParameter(
    'alpha',
    range=(0., 1.0, 0.01),
    value=0.3,
    tip=
    'alpha controls the relative importance of element shape and homogeneity.  alpha=0 emphasizes shape and ignores homogeneity.  alpha=1 emphasizes homogeneity and ignores shape.'
)

#########################


class SkelModTargets(registeredclass.RegisteredClass):
    registry = []
    tip = "Which elements to modify?"
    discussion = """<para>
    <classname>SkelModTargets</classname> objects are used as the
    <varname>targets</varname> parameter in <link
    linkend='RegisteredClass-SkeletonModifier'><classname>SkeletonModifiers</classname></link>.
    They determine which &elems; will be modified when a <xref
예제 #24
0
    def setMicrostructure(self):
        who = self.who().resolve(self.gfxwindow)
        if who:
            self.filter.setMicrostructure(who.getMicrostructure())
            self.canvaslayer.setEmpty(self.selectionContext().empty())


defaultPixelSelectionColor = color.RGBColor(1.0, 0.22, 0.09)
defaultOpacity = 0.9

pixelSelectParams = [
    color.ColorParameter('color',
                         defaultPixelSelectionColor,
                         tip='Color of selected voxels.'),
    parameter.FloatRangeParameter('opacity', (0., 1.0, 0.01),
                                  defaultOpacity,
                                  tip="Opacity of the color")
]

pixelSelectionDisplay = registeredclass.Registration(
    'Pixel Selection',
    display.DisplayMethod,
    PixelSelectionDisplay,
    params=pixelSelectParams,
    ordering=0,
    layerordering=display.SemiPlanar(0.1),
    whoclasses=('Microstructure', 'Image', 'Top Bitmap'),
    tip="Indicator for selected voxels.")


def _setDefaultPixelSelectionParams(menuitem, color, opacity):
예제 #25
0
                           value=automatic.automatic,
                           resolver=skeletonNameResolver,
                           tip="Name of the new skeleton."),
    whoville.WhoParameter('microstructure',
                          ooflib.common.microstructure.microStructures,
                          tip=parameter.emptyTipString)) +
    periodicityParams +
    parameter.ParameterGroup(
    parameter.FloatParameter('maxscale', value=1.0,
                             tip="Rough size of the largest elements."),
    parameter.FloatParameter("minscale", value=1.0,
                             tip="Rough size of the smallest elements."),
    enum.EnumParameter('units', ooflib.common.units.Units, value='Physical',
                       tip="Units for minscale and maxscale."),
    parameter.FloatRangeParameter('threshold', (0.0, 1.0, 0.01),
                                  value=0.90,
                                  tip="Minimum acceptable homogeneity")
    ),                                  # end of ParameterGroup
    help="Automatically create and refine a &skel;.",
    discussion=xmlmenudump.loadFile("DISCUSSIONS/engine/menu/autoskel.xml")
    ))

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

def sanity_check(menuitem, skeleton, quick):
    skel = skeletoncontext.skeletonContexts[skeleton].getObject()
    if quick:
        sane = skel.quick_sanity_check()
    else:
        sane = skel.sanity_check()
    if not sane:
예제 #26
0
    # def getTimeStamp(self, gfxwindow):
    #     return self.timestamp

    def isOverlayer(self):
        return True

    # def isEmpty(self, gfxwindow):
    #     bitmap = self.who().resolve(gfxwindow).getBitmap()
    #     return bitmap is None or bitmap.empty()


if config.dimension() == 2:
    bitoverlayparams = [
        color.ColorParameter('color', tip="Bitmap color."),
        parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                      0.6,
                                      tip="Opacity of the overlay.")
    ]
elif config.dimension() == 3:
    bitoverlayparams = [
        color.ColorParameter('color', tip="Bitmap color."),
        parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                      0.0,
                                      tip="Opacity of the tint."),
    ]

bitmapOverlay = registeredclass.Registration(
    'BitmapOverlay',
    display.DisplayMethod,
    BitmapOverlayDisplayMethod,
    params=bitoverlayparams,
예제 #27
0
                device.draw_alpha_image(bitmap, coord.Coord(0, 0),
                                        bitmap.size())
            elif config.dimension() == 3:
                bitmap.setVoxelAlpha(self.voxelOpacity)
                device.draw_alpha_image(bitmap, coord.Coord(0, 0, 0),
                                        bitmap.size())

    def getTimeStamp(self, gfxwindow):
        return self.timestamp


if config.dimension() == 2:
    bitoverlayparams = [
        color.ColorParameter('color', tip="Bitmap color."),
        parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                      0.6,
                                      tip="Opacity of the overlay.")
    ]
elif config.dimension() == 3:
    bitoverlayparams = [
        color.ColorParameter('color', tip="Bitmap color."),
        parameter.FloatRangeParameter('tintOpacity', (0., 1., 0.01),
                                      0.0,
                                      tip="Opacity of the tint."),
        parameter.FloatRangeParameter('voxelOpacity', (0., 1., 0.01),
                                      0.2,
                                      tip="Opacity of the given region.")
    ]

bitmapOverlay = registeredclass.Registration(
    'BitmapOverlay',
예제 #28
0
    'Material',
    display.DisplayMethod,
    MicrostructureMaterialDisplay,
    ordering=0,
    layerordering=display.Planar(0.4),
    params=[
        color.ColorParameter(
            'no_material',
            color.black,
            tip="Color to use if no material has been assigned to a pixel"),
        color.ColorParameter(
            'no_color',
            color.blue,
            tip="Color to use if the assigned material has no assigned color"),
        parameter.FloatRangeParameter("opacity",
                                      bitmapdisplay.opacityRange,
                                      bitmapdisplay.defaultImageOpacity,
                                      tip="Opacity of material colors."),
        parameter.RegisteredParameter("filter",
                                      voxelfilter.VoxelFilterPtr,
                                      voxelfilter.AllVoxels(),
                                      tip="Voxels to include in the display.")
    ],
    whoclasses=('Microstructure', ),
    tip="Display the color of the Material assigned to each pixel.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/microstructuredisplay.xml'))

############################

if config.dimension() == 2:
    ## TODO MER: Update for new display layer methods and 3D.
예제 #29
0
# Dummy parameter for smart widget
class ZZFluxParameter(meshparameters.FluxParameter):
    pass

registeredclass.Registration(
    'Z-Z Estimator',
    ErrorEstimator,
    ZZ_Estimator,
    ordering=0.,
    params=[
    parameter.RegisteredParameter('norm',
                                  ErrorNorm,
                                  tip="How to measure the size of an error."),
    ZZFluxParameter('flux', tip=parameter.emptyTipString),
    parameter.FloatRangeParameter('threshold', (0.0, 100.0, 0.5),
                                  value=10.,
                                  tip='Maximum allowable percentage error.')
    ],
    tip="Error estimation by Zienkiewicz and Zhu's superconvergent patch recovery.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/zzspr.xml'))

################################

# RefinementTarget for AdaptiveMeshRefinement.  Marks all elements
# that fail the error estimator test.
class AdaptiveMeshRefine(refinementtarget.RefinementTarget):
    def __init__(self, subproblem, estimator):
        #self.mesh = mesh  # mesh
        self.subproblem = subproblem
        self.estimator = estimator  # ErrorEstimator instance
            
예제 #30
0
        whoville.WhoParameter(
            'source',
            ooflib.common.microstructure.microStructures,
            tip="Copy the current selection from this Microstructure."),
        selectionoperators.SelectionOperatorParam('operator')
    ],
    tip="Copy the current selection from another Microstructure.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/copy_pixsel.xml')
    )

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

class RandomPixelSelection(pixelselection.VoxelSelectionModifier):
    def __init__(self, p, operator):
        self.p = p
        self.operator = operator
    def select(self, ms, selection):
        courier = pixelselectioncourier.RandomSelection(ms.getObject(), self.p)
        self.operator.operate(selection, courier)

pixelselection.VoxelSelectionModRegistration(
    "Random",
    RandomPixelSelection,
    ordering=10.,
    params=[
        parameter.FloatRangeParameter('p', (0., 1., 0.01), value=0.5,
                                      tip="Probability of selecting a voxel"),
        selectionoperators.SelectionOperatorParam('operator')
    ],
    tip="Select pixels randomly")