Exemple #1
0
 def __init__(self, param, scope=None, name=None):
     debug.mainthreadTest()
     hbox = gtk.HBox()
     xlabel = gtk.Label("x:")
     xlabel.set_alignment(1.0, 0.5)
     self.xwidget = FloatWidget(parameter.FloatParameter('Tweedledum', 0),
                                name="X")
     ylabel = gtk.Label("y:")
     ylabel.set_alignment(1.0, 0.5)
     self.ywidget = FloatWidget(parameter.FloatParameter('Tweedledee', 0),
                                name="Y")
     hbox.pack_start(xlabel, expand=0, fill=0, padding=2)
     hbox.pack_start(self.xwidget.gtk, expand=1, fill=1)
     hbox.pack_start(ylabel, expand=0, fill=0, padding=2)
     hbox.pack_start(self.ywidget.gtk, expand=1, fill=1)
     self.sbcallbacks = [
         switchboard.requestCallbackMain(self.xwidget, self.widgetChangeCB),
         switchboard.requestCallbackMain(self.ywidget, self.widgetChangeCB)
     ]
     ParameterWidget.__init__(self, hbox, scope=scope, name=name)
     self.set_value(param.value)
     self.widgetChanged(self.xwidget.isValid() and self.ywidget.isValid(),
                        interactive=0)
Exemple #2
0
    def __init__(self,label,rows,cols,value=None,scope=None,name=None):
        debug.mainthreadTest()
        frame = gtk.Frame()
        self.table = gtk.Table(rows=rows+1, columns=cols+1)
        frame.add(self.table)
        parameterwidgets.ParameterWidget.__init__(self, frame, scope, name)
        widgetscope.WidgetScope.__init__(self, scope)
        #scope.addWidget(self)
        self.rows = rows
        self.cols = cols
        self.floats = {}
        self.sbcallbacks = []
        #
        #self.table = gtk.GtkTable(rows=self.rows+2,cols=self.cols+2)
        #
        # Do labels first.
        for r in range(self.rows):
            lbl = gtk.Label(' %d ' % (r+1))
            lbl.set_alignment(1.0, 0.5)
            self.table.attach(lbl,0,1,r+1,r+2)
        for c in range(self.cols):
            lbl = gtk.Label(`c+1`)
            self.table.attach(lbl,c+1,c+2,0,1)

        digitsize = guitop.top().digitsize

        # Now put the actual floats in.
        for r in range(self.rows):
            for c in range(r,self.cols):
                newfloat = parameterwidgets.FloatWidget(
                    parameter.FloatParameter('dummy',0.0),
                    scope=self,
                    name="%d,%d"%(r,c))
                self.sbcallbacks.append(
                    switchboard.requestCallbackMain(newfloat,
                                                    self.floatChangeCB))
                # Also, set the size -- otherwise, the matrix
                # array gets to be too big.
                newfloat.gtk.set_size_request(8*digitsize,-1)
                
                self.floats[(r,c)] = newfloat
                try:
                    self.floats[(r,c)].set_value(value[(r,c)])
                except:
                    pass
                self.table.attach(newfloat.gtk,c+1,c+2,r+1,r+2,
                                  xoptions=gtk.FILL)
        self.widgetChanged(1, interactive=0)
Exemple #3
0
    def __init__(self, param, scope=None, name=None, verbose=False):
        debug.mainthreadTest()

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)
        table = gtk.Table(rows=config.dimension(), columns=2)
        frame.add(table)

        labels = "xyz"
        self.componentWidgets = []
        self.sbcallbacks = []
        for i in range(config.dimension()):
            label = gtk.Label(labels[i] + ':')
            label.set_alignment(1.0, 0.5)
            table.attach(label,
                         0,
                         1,
                         i,
                         i + 1,
                         xpadding=3,
                         xoptions=gtk.FILL,
                         yoptions=0)
            p = parameter.FloatParameter(labels[i], 0.0)
            widget = FloatWidget(p, name=labels[i] + "Componenent")
            self.componentWidgets.append(widget)
            table.attach(widget.gtk,
                         1,
                         2,
                         i,
                         i + 1,
                         xpadding=3,
                         xoptions=gtk.EXPAND | gtk.FILL,
                         yoptions=0)
            self.sbcallbacks.append(
                switchboard.requestCallbackMain(widget, self.widgetChangeCB))
        ParameterWidget.__init__(self,
                                 frame,
                                 scope=scope,
                                 name=name,
                                 verbose=verbose)
        self.set_value(param.value)
        valid = all(w.isValid() for w in self.componentWidgets)
        self.widgetChanged(valid, interactive=0)
Exemple #4
0
        ##            else:
        ##                largest=temp

        scaled = imageops.scaleArray2(largest, 0.0, 1.0)

        imageops.setFromArray(image, scaled)


registeredclass.Registration(
    'Canny',
    ImageFilter,
    CannyModifier,
    ordering=200,
    params=[
        parameter.FloatParameter(
            'stdDev',
            value=1,
            tip="Standard deviation for the gaussian smoothing")
    ],
    tip="Apply the Canny Edge Detector to detect edges")


class LaplacianFilterModifier(ImageFilter):
    def __call__(self, image):
        dbls = oofimage.grayify(image)
        temp = imageops.laplacian(dbls)
        scaled = imageops.scaleArray2(temp, 0.0, 1.0)
        imageops.setFromArray(image, scaled)


registeredclass.Registration('LaplacianFilter',
                             ImageFilter,
Exemple #5
0
    def reset(self, continuing):
        self.done = False
    def next(self):
        if self.done:
            raise StopIteration
        self.done = True
        return self.time + self.time0
    def singleTime(self):
        return self.time

registeredclass.Registration(
    'Once',
    Schedule,
    Once,
    ordering=1,
    params=[parameter.FloatParameter('time', 0.0, tip='The output time.')],
    tip="Produce output at just one time.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/once.xml'))

class Periodic(UnconditionalSchedule):
    def __init__(self, delay, interval):
        self.delay = delay
        self.interval = interval
        self.count = 0
        UnconditionalSchedule.__init__(self)
    def reset(self, continuing):
        self.count = 0
    def next(self):
        t = self.time0 + self.delay + self.count*self.interval
        self.count += 1
        return t
Exemple #6
0
            if indxdiff == 2 or indxdiff == -2:
                changes.extend(self.fix2(skel, element, edgeLengths[0][1]))
            return changes
        return []

    def fix(self, skel, element, which):
        node0 = element.nodes[which]
        node1 = element.nodes[(which+1)%4]
        return [skel.mergeNodePairs((node0, node1)),
                skel.mergeNodePairs((node1, node0))]

    def fix2(self, skel, element, which):
        nodes = [element.nodes[(which+i)%4] for i in range(4)]
        return [skel.mergeNodePairs((nodes[0], nodes[1]), (nodes[2], nodes[3])),
            skel.mergeNodePairs((nodes[1], nodes[0]), (nodes[2], nodes[3])),
            skel.mergeNodePairs((nodes[1], nodes[0]), (nodes[3], nodes[2])),
            skel.mergeNodePairs((nodes[0], nodes[1]), (nodes[3], nodes[2]))]

registeredclass.Registration(
    'Remove Short Sides',
    rationalize.Rationalizer,
    RemoveShortSide,
    gerund = 'removing short sides',
    ordering=0,
    params=[
    parameter.FloatParameter('ratio', value = 5.0,
                             tip = 'Maximum acceptable ratio of the lengths of the second shortest and the shortest sides.')
    ],
    tip = "Eliminate the shortest side of a quadrilateral.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/ration_short.xml'))
Exemple #7
0
                return 1
        return 0

    def description(self):
        return ` self.value `

    def __repr__(self):
        return "ConstantProfile(value=%s)" % ` self.value `


registeredclass.Registration(
    "Constant Profile", (ProfileX, ProfileXT, ProfileXTd),
    ConstantProfile,
    ordering=0,
    params=[
        parameter.FloatParameter("value", 0.0, tip="Value of this profile.")
    ],
    tip="Boundary condition has a constant value.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/constantprofile.xml'))

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


class LinearProfile(Profile, ProfileX, ProfileXT, ProfileXTd):
    def __init__(self, start, end):
        self.start = start
        self.end = end
        Profile.__init__(self)

    def __call__(self, location):
Exemple #8
0
            if self.units == 'Pixel':
                return element.area(
                ) > self.threshold * skeleton.MS.areaOfPixels()
            elif self.units == 'Physical':
                return element.area() > self.threshold
            elif self.units == 'Fractional':
                return element.area() > self.threshold * skeleton.MS.area()

    registeredclass.Registration(
        'Minimum Area',
        RefinementCriterion,
        MinimumArea,
        ordering=1,
        params=[
            parameter.FloatParameter('threshold',
                                     10,
                                     tip="Minimum acceptable element area."),
            enum.EnumParameter('units',
                               units.Units,
                               units.Units('Pixel'),
                               tip='Units for the minimum area')
        ],
        tip='Only refine elements with area greater than the given threshold.',
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/reg/minimumarea.xml'))

elif config.dimension() == 3:

    class MinimumVolume(RefinementCriterion):
        def __init__(self, threshold, units):
            self.threshold = threshold
Exemple #9
0
BINARY = DataFileFormatExt("binary")
ABAQUS = DataFileFormatExt("abaqus")

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


def versionCB(menuitem, number, format):
    if format == BINARY:
        menuitem.parser.binaryMode()


versionCmd = oofmenu.OOFMenuItem(
    'FileVersion',
    callback=versionCB,
    params=[
        parameter.FloatParameter('number', tip='file format version number'),
        enum.EnumParameter('format',
                           DataFileFormat,
                           tip='format for the data file.')
    ],
    help="Identify data file format.  Used internally in data files.",
    discussion="""
    <para>&oof2; data files must begin with a FileVersion command.
    The <varname>number</varname> parameter is used to maintain
    compatibility with older data files.  For now, its value should be
    <userinput>1.0</userinput>.  The <varname>format</varname>
    parameter must be one of the values discussed in <xref
    linkend='Section:Concepts:FileFormats'/>.</para>
    """)

mainmenu.OOF.LoadData.addItem(versionCmd)
Exemple #10
0
    def convertToBulk(self, el2d):
        return el2d.bulk_element


registeredclass.ThreeDOnlyRegistration(
    "Planar Cross Section",
    Domain,
    PlanarCrossSectionDomain,
    20,
    params=[
        parameter.ConvertibleRegisteredParameter(
            "normal", direction.Direction,
            direction.VectorDirection(1., 0., 0.),
            "The normal direction to the cross section plane."),
        parameter.FloatParameter(
            "offset",
            0.0,
            tip="The distance from the origin to the cross section plane."),
        enum.EnumParameter(
            "side",
            primitives.PlaneOrientation,
            "FRONT",
            tip="Evaluate the output with elements on this side of the plane.")
    ],
    sampling=(analysissample.ContinuumSampleSet, ),
    tip="Use a plane through the Mesh as the post-processing domain.")

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


class ElementGroup(BulkDomain):
    def __init__(self, elements):
Exemple #11
0
        selection.start()
        selection.unselect(
            pixelselectioncourier.ShrinkSelection(
                ms, selection.getSelectionAsGroup(), self.radius))


if config.dimension() == 2:
    registeredclass.Registration(
        'Expand',
        SelectionModifier,
        Expand,
        ordering=3.0,
        params=[
            parameter.FloatParameter(
                'radius',
                1.0,
                tip=
                'Select pixels within this distance of other selected pixels.')
        ],
        tip=
        "Select all pixels within a given distance of the current selection.",
        discussion=xmlmenudump.loadFile(
            "DISCUSSIONS/common/menu/expand_pixsel.xml"))

    registeredclass.Registration(
        'Shrink',
        SelectionModifier,
        Shrink,
        ordering=3.1,
        params=[
            parameter.FloatParameter(
Exemple #12
0
            if idx == jdx:
                res += 1.0
        if idx == jdx and kdx == ldx:
            res -= 1.0 / 3.0

        return res / denom


if False:
    reg = propertyregistration.PropertyRegistration(
        'Mechanical:Plasticity:TestPlasticity',
        TestPlasticityProp,
        "ooflib.engine.property.plasticity.plasticity",
        105,
        params=[
            parameter.FloatParameter("yield_stress", 1.0, tip="Yield stress.")
        ],
        propertyType="Plasticity")

    ## TODO: I have no idea if this is correct.  This whole file probably
    ## has to be redone entirely in any case. I just added this line when
    ## adding the fluxInfo calls to all the PropertyRegistrations. --SAL
    reg.fluxInfo(fluxes=[Stress],
                 fields=[Displacement],
                 time_derivs=[0],
                 nonlinear=True)

    # TODO: Should specify fields here, too, but only the ones we require
    # to evaluate the constraint.  We need plastic strain, of course.
    # Hardening types of plasticity will also need the appropriate
    # hardening-variable fields.  We do *not* need the plastic parameter
Exemple #13
0
        return data, None  # None ==> hexgrid not detected yet


orientmapdata.OrientMapRegistration(
    'TSL',
    TSLreader,
    ordering=2,
    params=[
        parameter.BooleanParameter('flip_x',
                                   False,
                                   tip='Flip data, swapping x and -x.'),
        parameter.BooleanParameter('flip_y',
                                   True,
                                   tip='Flip data, swapping y and -y.'),
        parameter.FloatParameter(
            'angle_offset',
            0,
            tip='Subtract this angle (in degrees) from phi1.')
    ],
    tip="TSL .ang file (old format)")

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


class TSLreader2(TSLreaderBase):
    def readData(self, tslfile, prog):
        count = 1
        lines = tslfile.readlines()
        nlines = len(lines)
        data = utils.ReservableList(nlines)
        hexgrid = False
        for line in lines:
Exemple #14
0
elif config.dimension() == 3:

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

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

    registeredclass.Registration(
        'Contrast',
        ImageModifier,
        ContrastImage,
        ordering=2.02,
        params=[
            parameter.FloatParameter(
                'factor', 1.5, tip='Factor by which to increase contrast.')
        ],
        tip="Enhance intensity differences.",
        discussion=xmlmenudump.loadFile('DISCUSSIONS/image/reg/contrast.xml'))

if config.dimension() == 2:

    class DespeckleImage(ImageModifier):
        def __call__(self, image):
            image.despeckle()

    registeredclass.Registration(
        'Despeckle',
        ImageModifier,
        DespeckleImage,
        ordering=2.03,
Exemple #15
0
    # The remainder of the PropertyRegistration arguments are
    # optional.

    # "params" is a list of Parameter objects, describing the input
    # parameters for the property.  This example defines two
    # parameters, a Trigonal second rank tensor named "modulus" and a
    # scalar named "coupling".
    
    params = [
        symmmatrix.TrigonalRank2TensorParameter(
            "modulus",                      # name
            symmmatrix.TrigonalRank2Tensor(xx=1.0, zz=0.5), # default value
            tip="Nothing is real."),        # a helpful note
        parameter.FloatParameter("coupling", # name
                                 10.,       # default value
                                 tip="Nothing to get hung about.")
    ],

    # "fields" is a list of the Fields that the Property uses.  The
    # Property won't make any contribution to the finite element
    # computation unless all of these Fields are defined on the Mesh.
    fields = [Strawberry, problem.Temperature],

    # "fluxes" is a list of the Fluxes that this property contributes
    # to.  The Property will be ignored in finite element calculations
    # unless equations involving these fluxes are being solved.
    fluxes = [Jam],

    # The "propertyType" is the same string that identifies this
    # Property in the conjugatePair call, above.
Exemple #16
0
#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#=-=#


def _pointSum(mesh, elements, coords, point1, point2, a, b):
    ans = [a * f + b * s for f, s in itertools.izip(point1, point2)]
    return ans


PointSumOutput = output.Output(
    name="point sum",
    callback=_pointSum,
    otype=(coord.Coord, primitives.Point),
    inputs=[coord.CoordParameter("point1"),
            coord.CoordParameter("point2")],
    params=[
        parameter.FloatParameter("a", default=1.0),
        parameter.FloatParameter("b", default=1.0)
    ])

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

# Take the difference between two outputs.


def _difference(mesh, elements, coords, minuend, subtrahend):
    minuends = minuend.evaluate(mesh, elements, coords)
    subtrahends = subtrahend.evaluate(mesh, elements, coords)
    return [x - y for x, y in itertools.izip(minuends, subtrahends)]


def _difference_shortrepr(self):
Exemple #17
0
 parameter.PositiveIntParameter('angle_column',
                                1,
                                tip='First column of angle data.'),
 parameter.MetaRegisteredParameter(
     'angle_type',
     orientationmatrix.Orientation,
     orientationmatrix.Bunge,
     tip="The way in which orientations are specified in the input file."
 ),
 enum.EnumParameter('angle_units',
                    AngleUnits,
                    'Radians',
                    tip="The units used for angles in the input file."),
 parameter.FloatParameter(
     'angle_offset',
     0,
     tip="An xy-plane rotation to apply to all input orientations,"
     " in degrees.  In the Abg format, the angle is added to gamma."
     " In Bunge, it's subtracted from phi1."),
 parameter.PositiveIntParameter('xy_column',
                                4,
                                tip='First column of position data.'),
 parameter.FloatParameter(
     'scale_factor',
     1.0,
     tip="All x and y values will be multiplied by this factor."),
 parameter.BooleanParameter('flip_x',
                            False,
                            tip='Flip data in the x direction.'),
 parameter.BooleanParameter('flip_y',
                            True,
                            tip='Flip data in the y direction.'),
Exemple #18
0
        def makeMenu(self, menu):
            self.menu = menu
            dollymenu = menu.addItem(oofmenu.OOFMenuItem("Dolly", cli_only=1))
            dollymenu.addItem(
                oofmenu.OOFMenuItem(
                    "In",
                    callback=self.dollyIn,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            dollymenu.addItem(
                oofmenu.OOFMenuItem(
                    "Out",
                    callback=self.dollyOut,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            dollymenu.addItem(
                oofmenu.OOFMenuItem("Fill",
                                    threadable=oofmenu.UNTHREADABLE,
                                    callback=self.dollyFill))
            trackmenu = menu.addItem(oofmenu.OOFMenuItem("Track", cli_only=1))
            trackmenu.addItem(
                oofmenu.OOFMenuItem(
                    "Horizontal",
                    callback=self.trackHoriz,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("distance")]))
            trackmenu.addItem(
                oofmenu.OOFMenuItem(
                    "Vertical",
                    callback=self.trackVert,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("distance")]))
            trackmenu.addItem(
                oofmenu.OOFMenuItem("Recenter",
                                    callback=self.recenter,
                                    threadable=oofmenu.UNTHREADABLE))

            rotatemenu = menu.addItem(oofmenu.OOFMenuItem("Rotate",
                                                          cli_only=1))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Roll",
                                    callback=self.roll,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Azimuth",
                                    callback=self.azimuth,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Elevation",
                                    callback=self.elevation,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Yaw",
                                    callback=self.yaw,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Pitch",
                                    callback=self.pitch,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))

            zoommenu = menu.addItem(oofmenu.OOFMenuItem("Zoom", cli_only=1))
            zoommenu.addItem(
                oofmenu.OOFMenuItem(
                    "In",
                    callback=self.zoomIn,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            zoommenu.addItem(
                oofmenu.OOFMenuItem(
                    "Out",
                    callback=self.zoomOut,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            zoommenu.addItem(
                oofmenu.OOFMenuItem("Fill",
                                    threadable=oofmenu.UNTHREADABLE,
                                    callback=self.zoomFill))

            clipmenu = menu.addItem(oofmenu.OOFMenuItem("Clip", cli_only=1))
            clipmenu.addItem(
                oofmenu.OOFMenuItem(
                    "New",
                    callback=self.newClipCB,
                    params=[
                        parameter.ConvertibleRegisteredParameter(
                            "normal", direction.Direction,
                            direction.DirectionX()),
                        parameter.FloatParameter("offset", 0.0)
                    ]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem(
                    "Edit",
                    callback=self.editClipCB,
                    params=[
                        parameter.IntParameter("plane"),
                        parameter.ConvertibleRegisteredParameter(
                            "normal", direction.Direction),
                        parameter.FloatParameter("offset")
                    ]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Delete",
                                    callback=self.delClipCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Enable",
                                    callback=self.clipEnableCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Disable",
                                    callback=self.clipDisableCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Flip",
                                    callback=self.clipFlipCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Unflip",
                                    callback=self.clipUnflipCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("InvertOn", callback=self.clipInvertOnCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("InvertOff",
                                    callback=self.clipInvertOffCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("SuppressOn",
                                    callback=self.clipSuppressOnCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("SuppressOff",
                                    callback=self.clipSuppressOffCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Select",
                                    callback=self.clipSelectCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Unselect", callback=self.clipUnselectCB))

            menu.addItem(
                oofmenu.OOFMenuItem("Restore_View",
                                    callback=self.restoreView,
                                    params=[view.ViewParameter("view")]))
            menu.addItem(
                oofmenu.OOFMenuItem("Restore_Named_View",
                                    callback=self._restoreNamedView,
                                    params=[ViewNameParameter("view")]))
            menu.addItem(
                oofmenu.OOFMenuItem("Save_View",
                                    callback=self.saveView,
                                    params=[parameter.StringParameter("name")
                                            ]))
            menu.addItem(
                oofmenu.OOFMenuItem(
                    "Delete_View",
                    callback=self.deleteView,
                    params=[
                        ViewNameParameter(
                            "view", tip="The name of the View to delete.")
                    ]))
Exemple #19
0
def _loadTime(menuitem, mesh, time):
    meshctxt = ooflib.engine.mesh.meshes[mesh]
    meshctxt.setCurrentTime(time)
    switchboard.notify("mesh changed", meshctxt)


meshmenu.addItem(
    OOFMenuItem(
        'Time',
        callback=_loadTime,
        params=[
            whoville.WhoParameter('mesh',
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString),
            parameter.FloatParameter('time', tip=parameter.emptyTipString)
        ],
        help="Time is used internally in Mesh data files.",
        discussion="<para>Set the time for the current Field values.</para>"))


def _cacheFields(menuitem, mesh, time):
    meshctxt = ooflib.engine.mesh.meshes[mesh]
    meshctxt.setCurrentTime(time)
    meshctxt.cacheCurrentData()
    switchboard.notify("mesh changed", meshctxt)
    switchboard.notify("mesh data changed", meshctxt)  # ???


meshmenu.addItem(
    OOFMenuItem(
Exemple #20
0
    def __call__(self, image):
        image.blur(self.radius, self.sigma)


registeredclass.Registration(
    'Blur',
    ImageModifier,
    BlurImage,
    ordering=2.00,
    params=[
        parameter.FloatParameter(
            'radius',
            0.0,
            # TODO: not sure if this tip is accurate for the 3D case -- the
            # vtk documentation isn't very clear about what units the radius
            # is in.
            tip=
            "Radius of the Gaussian, in pixels, not counting the center pixel."
        ),
        parameter.FloatParameter(
            'sigma', 1.0, tip="Standard deviation of the Gaussian, in pixels")
    ],
    tip=
    "Blur an image by convolving it with a Gaussian operator of the given radius and standard deviation (sigma).",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/image/reg/blurimage.xml'))

if config.dimension() == 2:

    class ContrastImage(ImageModifier):
        def __init__(self, sharpen):
Exemple #21
0
skeletonmenu.addItem(oofmenu.OOFMenuItem(
    'Auto',
    callback=autoskeleton.autoSkeleton,
    threadable=oofmenu.THREADABLE,
    no_log=True,                        # because it calls other menu items
    params=parameter.ParameterGroup(
    parameter.AutomaticNameParameter('name',
                           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):
Exemple #22
0
        return cmatrixmethods.solveCG(matrix, rhs, pc, self.max_iterations,
                                      self.tolerance, solution)

registeredclass.Registration(
    "CG",
    MatrixMethod,
    ConjugateGradient,
    ordering=1,
    symmetricOnly=True,
    params=[
        parameter.RegisteredParameter(
            "preconditioner",
            preconditioner.PreconditionerPtr,
            tip="Black magic for making the matrix more easily solvable."),
        parameter.FloatParameter(
            "tolerance",
            1.e-13,
            tip="Largest acceptable relative error in the matrix solution."),
        parameter.IntParameter("max_iterations",
                               1000,
                               tip="Maximum number of iterations to perform.")
    ],
    tip="Conjugate Gradient method for iteratively solving symmetric matrices.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/cg.xml'))


def check_symmetry(menuitem, state):
    global _check_symmetry
    _check_symmetry = state


mainmenu.debugmenu.addItem(
Exemple #23
0
    def func(self, position, time, component):
        return self.value

    def shortrepr(self):
        return str(self.value)


registeredclass.Registration(
    "Constant",
    ScalarFieldInit,
    ConstScalarFieldInit,
    0,
    params=[
        parameter.FloatParameter('value',
                                 0.0,
                                 tip='Value to assign to the Field.')
    ],
    tip="Initialize a scalar field with a constant value.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/const_scalar_field_init.xml'))

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


class ConstTwoVectorFieldInit(TwoVectorFieldInit):
    def __init__(self, cx, cy):
        self.cx = cx
        self.cy = cy

    def func(self, position, time, component):
Exemple #24
0
                #             min(newstep, maxstep)))
                # debug.fmsg("endValues=", stepResult.endValues)
                stepResult.nextStep = min(newstep, maxstep)
                # debug.fmsg("OK increased step size to", stepResult.nextStep)
                stepResult.ok = True
        return stepResult


registeredclass.Registration(
    'Adaptive',
    StepDriver,
    AdaptiveDriver,
    ordering=1,
    params=[
        parameter.FloatParameter('tolerance',
                                 1.e-4,
                                 tip="Maximum permissable error."),
        parameter.FloatParameter("initialstep", 0.1, tip="Initial step size."),
        parameter.FloatParameter('minstep',
                                 1.e-5,
                                 tip="Minimum time step size."),
        parameter.RegisteredParameter(
            'errorscaling',
            steperrorscaling.StepErrorScaling,
            value=steperrorscaling.AbsoluteErrorScaling(),
            tip="How to compute the error for each degree of freedom."),
        parameter.RegisteredParameter('stepper',
                                      QCTimeStepper,
                                      tip="Time stepping method.")
    ],
    tip="Take variable sized timesteps.",
Exemple #25
0
    def step(self, subprob, *args, **kwargs):
        return subprob.time_stepper.nonlinearstep(subprob,
                                                  nonlinearMethod=self,
                                                  *args,
                                                  **kwargs)

    def computeStaticFields(self, subprobctxt, linsys, unknowns):
        # Called by SubProblemContext.initializeStaticFields.
        return subprobctxt.computeStaticFieldsNL(linsys, unknowns)


# Shared parameters for the nontrivial solvers.

nonlin_params = [
    parameter.FloatParameter(
        'relative_tolerance',
        1.e-8,
        tip="Relative tolerance for convergence to a nonlinear solution."),
    parameter.FloatParameter(
        'absolute_tolerance',
        1.e-13,
        tip="Absolute tolerance for convergence to a nonlinear solution."),
    parameter.IntParameter(
        'maximum_iterations',
        200,
        tip=
        "Maximum number of iterations for convergence to a nonlinear solution."
    )
]

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#
Exemple #26
0
        oofimage.setFromBool(image, bools)


registeredclass.Registration(
    'FullEdgeDetection',
    imagemodifier.ImageModifier,
    FullGaborModifier,
    ordering=100,
    params=[
        parameter.IntParameter('a', value=3, tip="a in pixels"),
        parameter.IntParameter('b', value=3, tip="b in pixels"),
        parameter.IntParameter('numAngles',
                               value=6,
                               tip="number of angles to apply the filter"),
        parameter.FloatParameter(
            'Threshold',
            value=.5,
            tip="Threshold value used when thresholding image"),
        parameter.IntParameter(
            'Line_color',
            value=2,
            tip=
            "Colors of the lines to detect. (2) Both white and dark lines. (1) Only white lines (0) Only black lines."
        ),
        parameter.IntParameter('d',
                               value=7,
                               tip="Value used for morphological closing"),
        parameter.IntParameter('n', value=9, tip="Number of interations"),
        parameter.IntParameter('B',
                               value=5,
                               tip="Half the size of the box in pixels"),
        parameter.IntParameter('trimYN',
Exemple #27
0
                if domain.contains(pt):
                    self.sample_list.append(PointSample(pt))
                x += self.delta_x
                if x > bxmax:
                    x = bxmin
                    y += self.delta_y
                    if y > bymax:
                        return 1  # done


DirectSampleSetRegistration(
    "Spaced Grid Points",
    SpacedGridSampleSet,
    21,
    params=[
        parameter.FloatParameter(
            'delta_x', 0.1, tip="Horizontal spacing between grid points."),
        parameter.FloatParameter('delta_y',
                                 0.1,
                                 tip="Vertical spacing between grid points.")
    ],
    sample_type=GRID,
    tip='Evaluate data on a rectangular grid of points.',
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/reg/spacedgridsampleset.xml'))

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


class DiscretePointSampleSet(PointSampleSet):
    containedClass = PointSample
Exemple #28
0
                self.solver_converged = False
            else:
                self.solver_converged = True
        finally:
            meshctxt.end_writing()

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

registeredclass.Registration(
    'Relax',
    skeletonmodifier.SkeletonModifier,
    Relax,
    ordering=0.5,
    params=[
        skeletonmodifier.alphaParameter,
        parameter.FloatParameter(name = 'gamma', value = 0.5,
                                 tip='Node mobility'),
        parameter.IntParameter('iterations', value = 1, tip='number of steps')
        ],
    tip='Improve a skeleton by solving a finite element system where the properties are functions of the underlying homogeneity and shape',
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/relax.xml')
    )


# Old tip for gamma:
#    tip='Coefficient of mesh expansion or rate of
#    expansion/contraction per inhomogeneity or per deviation from
#    ideal shape. A small positive value is recommended for meshes
#    where element edges want to be made coincide with pixel group
#    edges.'
Exemple #29
0
    ms = ooflib.common.microstructure.Microstructure(
        name, primitives.iPoint(width_in_pixels, height_in_pixels),
        primitives.Point(width, height))


msmenu.addItem(
    oofmenu.OOFMenuItem(
        'New_Parallel',
        callback=newMicrostructure_Parallel,
        secret=1,
        no_log=1,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=[
            parameter.StringParameter('name'),
            parameter.FloatParameter('width',
                                     1.,
                                     tip='Width in physical units.'),
            parameter.FloatParameter('height',
                                     1.,
                                     tip='Height in physical units.'),
            parameter.IntParameter('width_in_pixels',
                                   10,
                                   tip='Width in pixels.'),
            parameter.IntParameter('height_in_pixels',
                                   10,
                                   tip='Height in pixels.')
        ]))

### OOF.LoadData.IPC.Microstructure.Initialize
### Transfers the microstructure to the back-end
Exemple #30
0
    def scaled(self, factors):
        avgscale = factors.x + factors.y
        if config.dimension() == 3:
            avgscale += factors.z
        avgscale = avgscale/config.dimension()
        return CircleSelectionShape(self.center.scale(factors),
                                    self.radius*avgscale)

registeredclass.Registration(
    "Circle",
    SelectionShape,
    CircleSelectionShape,
    ordering=1,
    params=[primitives.PointParameter("center",
                                      tip="The center of the circle."),
            parameter.FloatParameter("radius", 0.0)],
    tip="Select a circular or spherical region.")

class EllipseSelectionShape(SelectionShape):
    def __init__(self, point0, point1):
        self.point0 = point0
        self.point1 = point1
    def scaled(self, factors):
        return EllipseSelectionShape(self.point0.scale(factors),
                                     self.point1.scale(factors))

registeredclass.Registration(
    "Ellipse",
    SelectionShape,
    EllipseSelectionShape,
    ordering=2,