Esempio n. 1
0
    # Coord, but it doeesn't really matter.  Points can be faster to
    # use since they don't have any swig overhead.
    if config.dimension() == 2:
        if type(ptlist) == types.ListType:
            return [Point(pt[0], pt[1]) for pt in ptlist]
        return ptlist.__class__([Point(pt[0], pt[1]) for pt in ptlist])
    elif config.dimension() == 3:
        if type(ptlist) == types.ListType:
            return [Point(pt[0], pt[1], pt[2]) for pt in ptlist]
        return ptlist.__class__([Point(pt[0], pt[1], pt[2]) for pt in ptlist])


## Documentation for Point and iPoint classes

from ooflib.common.IO import xmlmenudump
xmlmenudump.XMLObjectDoc(
    'iPoint', xmlmenudump.loadFile('DISCUSSIONS/common/object/ipoint.xml'))

xmlmenudump.XMLObjectDoc(
    'Point', xmlmenudump.loadFile('DISCUSSIONS/common/object/point.xml'))

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


class Rectangle(object):
    # A Rectangle is a pair of points at diagonally opposite corners.
    def __init__(self, pt0, pt1):
        # Don't assume that args pt0 and pt1 have .x and .y data
        self.lowleft = Point(min(pt0[0], pt1[0]), min(pt0[1], pt1[1]))
        self.upright = Point(max(pt0[0], pt1[0]), max(pt0[1], pt1[1]))

    def enclosing_rectangle(self):
Esempio n. 2
0
class NothingPlaceHolder(PlaceHolder):
    idtag = 'nothing'


class LatestPlaceHolder(PlaceHolder):
    idtag = 'latest'


class EarliestPlaceHolder(PlaceHolder):
    idtag = 'earliest'


# TODO: update the docs.
xmlmenudump.XMLObjectDoc(
    'Placeholder',
    xmlmenudump.loadFile("DISCUSSIONS/common/object/placeholder.xml"))

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

# For historical reasons, the PlaceHolderParameter accepts the value
# 'all', which means the same thing as '"every"'.  The idtag for
# EveryPlaceHolder used to be "all", so scripts could contain arguments
# like pixels=all.  In Python 2.5 and beyond, 'all' is a built-in
# function, so it's unwise to redefine it as a PlaceHolder.  However,
# scripts may still contain pixels=all, so the PlaceHolderParameter
# was introduced.  It accepts the built-in function 'all' as a value,
# and interprets it as the PlaceHolder "every".

# PlaceHolderParameter doesn't use the default Parameter.set method,
# because that method doesn't handle the PlaceHolder metaclass
Esempio n. 3
0
# -*- python -*-

# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# [email protected].

# This has its own file to avoid an import loop.  It otherwise would
# be in automatic.py.

from ooflib.common.IO import xmlmenudump

xmlmenudump.XMLObjectDoc(
    'automatic',
    xmlmenudump.loadFile('DISCUSSIONS/common/object/automatic.xml'))
Esempio n. 4
0
            self._value = FluxProfileSet(value)
        elif isinstance(value, Profile):
            self._value = FluxProfileSet([value])
        else:
            raise parameter.ParameterMismatch('Got ' + ` value ` +
                                              ' for Parameter ' + self.name)

    def binaryRepr(self, datafile, value):
        n = len(value)
        strs = [struct.pack(">i", n)]
        for p in value.get_profiles():
            strs.append(p.binaryRepr(datafile))
        return string.join(strs, "")

    def binaryRead(self, parser):
        b = parser.getBytes(struct.calcsize(">i"))
        (length, ) = struct.unpack(">i", b)
        proflist = [None] * length
        for i in range(length):
            proflist[i] = registeredclass.binaryReadRegClass(
                parser, ProfileXT.registry)
        return FluxProfileSet(proflist)

    def valueDesc(self):
        return "A <xref linkend='Object-FluxProfileSet'/> object, or a <link linkend='Object-list'>list</link> of <link linkend='RegisteredClass-ProfileXT'><classname>ProfileXTs</classname></link>, or a single <classname>ProfileXT</classname>."


xmlmenudump.XMLObjectDoc(
    'FluxProfileSet',
    xmlmenudump.loadFile('DISCUSSIONS/engine/object/fluxprofileset.xml'))
Esempio n. 5
0
        # provided. All others are provided if applicable.  nx and ny
        # are the unit-vector components of the boundary normal at
        # this location. i is the node index, s is the arc length,
        # alpha is the fractional arc length.
        strfunction.StrFunction.__init__(self, 'x, y, nx, ny, i, s, alpha',
                                         funcstr)

    def __repr__(self):
        # ProfileFunctions only have to write their values when they
        # are used in ProfileFunctionParameters, which can set
        # themselves from a string. So just write the string.
        return "'%s'" % self.funcstr


xmlmenudump.XMLObjectDoc(
    'ProfileFunction',
    xmlmenudump.loadFile('DISCUSSIONS/engine/object/profilefunction.xml'))

# The ProfileFunctionParameter can accept either a string or a
# ProfileFunction object, but it only stores a ProfileFunction object.
# Like XYStrFunctionParameter, it needs a special "set" function.


class ProfileFunctionParameterBase(parameter.Parameter):
    def __init__(self, name, value=None, default=None, tip=None):
        parameter.Parameter.__init__(self,
                                     name,
                                     value=value,
                                     default=default,
                                     tip=tip)
Esempio n. 6
0
    def binaryRepr(self, datafile, value):
        return struct.pack(HexagonalCijklParameter.packfmt, value.c11,
                           value.c12, value.c13, value.c33, value.c44)

    def binaryRead(self, parser):
        b = parser.getBytes(HexagonalCijklParameter.packsize)
        args = struct.unpack(HexagonalCijklParameter.packfmt, b)
        return HexagonalRank4TensorCij(*args)

    def valueDesc(self):
        return "A <link linkend='Object-HexagonalRank4TensorCij'><classname>HexagonalRank4TensorCij</classname></link> object."


xmlmenudump.XMLObjectDoc(
    'Rank 4 Tensors:HexagonalRank4TensorCij',
    xmlmenudump.loadFile('DISCUSSIONS/engine/object/hexagonalrank4.xml'),
    ordering=400)


class TetragonalRank4TensorCij(Comparable):
    def __init__(self, c11, c12, c13, c33, c44, c66, c16):
        self.c11 = c11
        self.c12 = c12
        self.c13 = c13
        self.c16 = c16
        self.c33 = c33
        self.c44 = c44
        self.c66 = c66

    def __repr__(self):
        return "TetragonalRank4TensorCij(c11=%s, c12=%s, c13=%s, c33=%s, c44=%s, c66=%s, c16=%s)" % \