# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "." in __name__:
    from . import _edgeset
else:
    import _edgeset

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


import ooflib.SWIG.engine.femesh
import ooflib.SWIG.common.cmicrostructure
import ooflib.SWIG.common.coord
import ooflib.SWIG.common.pixelgroup
import ooflib.SWIG.common.pixelattribute
import ooflib.SWIG.common.timestamp
import ooflib.SWIG.common.lock
import ooflib.SWIG.engine.element
import ooflib.SWIG.engine.csubproblem
import ooflib.SWIG.common.doublevec
import ooflib.SWIG.engine.equation
import ooflib.SWIG.engine.fieldindex
import ooflib.SWIG.engine.planarity
import ooflib.SWIG.engine.flux
import ooflib.SWIG.engine.outputval
import ooflib.SWIG.engine.nodalequation
import ooflib.SWIG.engine.field
import ooflib.SWIG.engine.freedom
import ooflib.SWIG.engine.pointdata
import ooflib.SWIG.engine.linearizedsystem
import ooflib.SWIG.engine.sparsemat
import ooflib.SWIG.engine.material
import ooflib.SWIG.common.abstractimage
import ooflib.SWIG.common.ccolor
import ooflib.SWIG.engine.property
import ooflib.SWIG.engine.meshiterator
import ooflib.SWIG.engine.node
import ooflib.SWIG.engine.edge
import ooflib.SWIG.engine.mastercoord
import ooflib.SWIG.engine.elementnodeiterator
import ooflib.SWIG.engine.gausspoint
class EdgeSet(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, arg2):
        _edgeset.EdgeSet_swiginit(self, _edgeset.new_EdgeSet(arg2))
    __swig_destroy__ = _edgeset.delete_EdgeSet

    def addEdge_(self, arg2):
        return _edgeset.EdgeSet_addEdge_(self, arg2)

    def ndlist(self):
        return _edgeset.EdgeSet_ndlist(self)

    def size(self):
        return _edgeset.EdgeSet_size(self)

# Register EdgeSet in _edgeset:
_edgeset.EdgeSet_swigregister(EdgeSet)
class EdgeSetIterator(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, arg2):
        _edgeset.EdgeSetIterator_swiginit(self, _edgeset.new_EdgeSetIterator(arg2))

    def edge(self):
        return _edgeset.EdgeSetIterator_edge(self)

    def end(self):
        return _edgeset.EdgeSetIterator_end(self)

    def increment(self):
        return _edgeset.EdgeSetIterator_increment(self)
    __swig_destroy__ = _edgeset.delete_EdgeSetIterator

# Register EdgeSetIterator in _edgeset:
_edgeset.EdgeSetIterator_swigregister(EdgeSetIterator)
class EdgeNodeDistance(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _edgeset.delete_EdgeNodeDistance
    node = property(_edgeset.EdgeNodeDistance_node_get, _edgeset.EdgeNodeDistance_node_set)
    index = property(_edgeset.EdgeNodeDistance_index_get, _edgeset.EdgeNodeDistance_index_set)
    distance = property(_edgeset.EdgeNodeDistance_distance_get, _edgeset.EdgeNodeDistance_distance_set)
    fraction = property(_edgeset.EdgeNodeDistance_fraction_get, _edgeset.EdgeNodeDistance_fraction_set)

# Register EdgeNodeDistance in _edgeset:
_edgeset.EdgeNodeDistance_swigregister(EdgeNodeDistance)
# -*- 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
# oof_manager@nist.gov.

from ooflib.common import debug
from ooflib.engine.profile import Location

def _EdgeSet___repr__(self):
    outstr = "EdgeSet( "
    for n in self.nodes():
        outstr = outstr + " %s " % n
    outstr = outstr + ")\n"
    return outstr

EdgeSet.__repr__ = _EdgeSet___repr__


# Utility function for building the cached progress data -- makes the
# expensive call into the C++ code to traverse the boundary, measuring
# progress in terms of nodes, node indices, distance traversed, and
# fractional distance traversed.  Caches the results, because it will
# be needed by each boundary condition.
def _EdgeSet_build_caches_(self):
    elist = self.ndlist()
    self.node_cache = [e.node for e in elist]
    self.location_cache = []
    for e in elist:
        self.location_cache.append(
            Location(e.node.position(), index=e.index,
                     s=e.distance, alpha=e.fraction))

EdgeSet.build_caches_ = _EdgeSet_build_caches_

# This is the function you should call to get a Python list of
# objects measuring progress along the boundary.  It calls the
# swigged-and-typemapped C++ "ndlist" function to get a list of
# EdgeNodeDistance pointers, and extracts the node information from it.
def _EdgeSet_nodes(self):
    if not hasattr(self, "node_cache"):
        self.build_caches_()
    return self.node_cache

EdgeSet.nodes = _EdgeSet_nodes

# Function to retrieve the list of locations from the edgeset.
# Locations are basically nodes, enhanced with extra information about
# how far along in the boundary you are.

## TODO: In many (all?) places where EdgeSet.locations() is used, it's
## immediately followed by location.set_time(t) for all locations in
## the set.  Perhaps EdgeSet.locations() should take a time arg and
## set the time itself.
def _EdgeSet_locations(self):
    if not hasattr(self, "node_cache"):
        self. build_caches_()
    return zip(self.node_cache, self.location_cache)

EdgeSet.locations = _EdgeSet_locations


# Wrapper to make sure that addEdge calls make both caches stale.
# Note that the caches are built by, among others, the __repr__, which
# is a little unintuitive.
def _EdgeSet_addEdge(self, boundaryedge):
    try:
        del self.node_cache
    except AttributeError:
        pass
    try:
        del self.location_cache
    except AttributeError:
        pass
    self.addEdge_(boundaryedge)


EdgeSet.addEdge = _EdgeSet_addEdge

# Patterned after the FuncNodeIterator getitem routine in mesh.spy.
def _EdgeSetIterator___getitem__(self, idx):
    if self.end():
        raise IndexError
    ret = self.edge()
    self.increment()
    return ret

EdgeSetIterator.__getitem__ = _EdgeSetIterator___getitem__


