# Path: pam/model.py
# CONNECTION_RESULTS = []
# MODEL = None
# CONNECTION_ERRORS = []
# MAPPING_NAMES = ['MAP_euclid', 'MAP_normal', 'MAP_random', 'MAP_top', 'MAP_uv', 'MAP_mask3D']
# DISTANCE_NAMES = ['DIS_euclid', 'DIS_euclidUV', 'DIS_jumpUV', 'DIS_UVjump', 'DIS_normalUV', 'DIS_UVnormal']
#     NG_LIST = snapshot.NG_LIST
#     NG_DICT = snapshot.NG_DICT
#     CONNECTION_INDICES = snapshot.CONNECTION_INDICES
#     CONNECTIONS = Pickle2Connection(snapshot.CONNECTIONS)
#     CONNECTION_RESULTS = convertArray2Vector(snapshot.CONNECTION_RESULTS)
#     CONNECTION_ERRORS = []
#     MODEL = Model(NG_LIST, NG_DICT, CONNECTIONS, CONNECTION_INDICES)
#     MODEL = Model()
#     CONNECTION_RESULTS = []
#         MODEL = m
#     CONNECTION_RESULTS = []
#         MODEL = m
#     MODEL = Model()
# class Connection():
# class Model():
# class ModelJsonEncoder(json.JSONEncoder):
# class ConnectionJsonEncoder(json.JSONEncoder):
# class ModelSnapshot(object):
# class PAMModelLoad(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
# class PAMModelSave(bpy.types.Operator, bpy_extras.io_utils.ExportHelper):
# class PAMModelJSONLoad(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
# class PAMModelJSONSave(bpy.types.Operator, bpy_extras.io_utils.ExportHelper):
#     def __init__(self, layers, slayer, mappings):
#     def layers(self):
#     def mappings(self):
#     def mapping_connections(self):
#     def mapping_distances(self):
#     def pre_layer(self):
#     def post_layer(self):
#     def synaptic_layer(self):
#     def synaptic_layer_index(self):
#     def pre_intermediate_layers(self):
#     def post_intermediate_layers(self):
#     def __str__(self):
#     def __repr__(self):
#     def __eq__(self, con):
#     def __ne__(self, con):
#     def toDict(self):
#     def toList(self):
#     def __init__(self, ng_list = None, ng_dict = None, connections = None, connection_indices = None):
#     def addConnection(self, connection):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def default(self, model):
#     def default(self, connection):
# def decodeJSONModel(m):
# def connectionFromDict(c):
# def connectionFromList(c):
# def saveModelToJson(model, path):
# def loadModelFromJson(path):
# def getPreIndicesOfPostIndex(c_index, post_index ):
# def convertObject2String(connection):
# def convertString2Object(connection):
# def Connection2Pickle(connections):
# def Pickle2Connection(connections):
# def convertVector2Array(connection_results):
# def convertArray2Vector(connection_results):
#     def __init__(self):
#     def __eq__(self, other):
# def savePickle(path):
# def loadPickle(path):
# def comparePickle(path1, path2):
# def reset():
# def clearQuadtreeCache():
# def saveZip(path, model = None, connection_results = None):
# def loadZip(path):
#     def draw(self, context):
#     def execute(self, context):
#     def draw(self, context):
#     def poll(cls, context):
#     def execute(self, context):
#     def execute(self, context):
#     def poll(cls, context):
#     def execute(self, context):
# 
# Path: pam/pam.py
# SEED = 0
#     SEED = bpy.context.scene.pam_mapping.seed
# def computeUVScalingFactor(obj):
# def map3dPointToParticle(obj, particle_system, location):
# def maskParticle(p_layer, p_index, mask_layer, distance=0.2):
# def distanceToMask(p_layer, p_index, particle_index, mask_layer):
# def computeConnectivityProbability(uv1, uv2, func, args):
# def computeDistance_PreToSynapse(no_connection, pre_index, synapses=[]):
# def sortNeuronsToUV(layer, neuronset, u_or_v):
# def computeMapping(layers, connections, distances, point, debug=False):
# def computeDistanceToSynapse(ilayer, slayer, p_3d, s_2d, dis):
# def addConnection(*args):
# def replaceMapping(index, connection):
# def computeAllConnections():
# def updateMapping(index):
# def computeConnectivity(con, create=True, threads = None):
# def post_neuron_wrapper(x):
# def post_neuron_initializer(players, pconnections, pdistances):
# def pre_neuron_wrapper(x):
# def pre_neuron_initializer(players, pconnections, pdistances, puv_grid, pno_synapses):
# def computeConnectivityThreaded(con, create=True, threads = None):
# def computeConnectivityAll(layers, neuronset1, neuronset2, slayer, connections, distances, func, args):
# def printConnections():
# def computeDistance(layer1, layer2, neuronset1, neuronset2, common_layer,
#                     connection_matrix):
# def measureUVs(objects):
# def initializeUVs():
# def returnNeuronGroups():
# def resetOrigins():
# def initialize3D():
# 
# Path: pam/constants.py
# RAY_FAC = 0.3
# INTERPOLATION_QUALITY = 10
# CACHE_QUADTREE_DEPTH = 2
# UV_THRESHOLD = 1e-8
# UV_GRID_THRESHOLD = 1e-3
# DEFAULT_RESOLUTION = 0.05
# KERNEL_THRESHOLD = 0.05
# PATH_BEVEL_DEPTH = 0.005


from pam import model
from pam import pam
from pam import constants
import bpy
import numpy
import logging


logger = logging.getLogger(__package__)

def getUniqueUVMapErrors():
    """Returns a list of unique connection errors that occur during uv-mapping phase.

    :return: list of failed UV-Mappings
    :rtype: list of exceptions.UVMapError"""
    errors = {}

# Path: pam/model.py
# CONNECTION_RESULTS = []
# MODEL = None
# CONNECTION_ERRORS = []
# MAPPING_NAMES = ['MAP_euclid', 'MAP_normal', 'MAP_random', 'MAP_top', 'MAP_uv', 'MAP_mask3D']
# DISTANCE_NAMES = ['DIS_euclid', 'DIS_euclidUV', 'DIS_jumpUV', 'DIS_UVjump', 'DIS_normalUV', 'DIS_UVnormal']
#     NG_LIST = snapshot.NG_LIST
#     NG_DICT = snapshot.NG_DICT
#     CONNECTION_INDICES = snapshot.CONNECTION_INDICES
#     CONNECTIONS = Pickle2Connection(snapshot.CONNECTIONS)
#     CONNECTION_RESULTS = convertArray2Vector(snapshot.CONNECTION_RESULTS)
#     CONNECTION_ERRORS = []
#     MODEL = Model(NG_LIST, NG_DICT, CONNECTIONS, CONNECTION_INDICES)
#     MODEL = Model()
#     CONNECTION_RESULTS = []
#         MODEL = m
#     CONNECTION_RESULTS = []
#         MODEL = m
#     MODEL = Model()
# class Connection():
# class Model():
# class ModelJsonEncoder(json.JSONEncoder):
# class ConnectionJsonEncoder(json.JSONEncoder):
# class ModelSnapshot(object):
# class PAMModelLoad(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
# class PAMModelSave(bpy.types.Operator, bpy_extras.io_utils.ExportHelper):
# class PAMModelJSONLoad(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
# class PAMModelJSONSave(bpy.types.Operator, bpy_extras.io_utils.ExportHelper):
#     def __init__(self, layers, slayer, mappings):
#     def layers(self):
#     def mappings(self):
#     def mapping_connections(self):
#     def mapping_distances(self):
#     def pre_layer(self):
#     def post_layer(self):
#     def synaptic_layer(self):
#     def synaptic_layer_index(self):
#     def pre_intermediate_layers(self):
#     def post_intermediate_layers(self):
#     def __str__(self):
#     def __repr__(self):
#     def __eq__(self, con):
#     def __ne__(self, con):
#     def toDict(self):
#     def toList(self):
#     def __init__(self, ng_list = None, ng_dict = None, connections = None, connection_indices = None):
#     def addConnection(self, connection):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def default(self, model):
#     def default(self, connection):
# def decodeJSONModel(m):
# def connectionFromDict(c):
# def connectionFromList(c):
# def saveModelToJson(model, path):
# def loadModelFromJson(path):
# def getPreIndicesOfPostIndex(c_index, post_index ):
# def convertObject2String(connection):
# def convertString2Object(connection):
# def Connection2Pickle(connections):
# def Pickle2Connection(connections):
# def convertVector2Array(connection_results):
# def convertArray2Vector(connection_results):
#     def __init__(self):
#     def __eq__(self, other):
# def savePickle(path):
# def loadPickle(path):
# def comparePickle(path1, path2):
# def reset():
# def clearQuadtreeCache():
# def saveZip(path, model = None, connection_results = None):
# def loadZip(path):
#     def draw(self, context):
#     def execute(self, context):
#     def draw(self, context):
#     def poll(cls, context):
#     def execute(self, context):
#     def execute(self, context):
#     def poll(cls, context):
#     def execute(self, context):
# 
# Path: pam/pam.py
# SEED = 0
#     SEED = bpy.context.scene.pam_mapping.seed
# def computeUVScalingFactor(obj):
# def map3dPointToParticle(obj, particle_system, location):
# def maskParticle(p_layer, p_index, mask_layer, distance=0.2):
# def distanceToMask(p_layer, p_index, particle_index, mask_layer):
# def computeConnectivityProbability(uv1, uv2, func, args):
# def computeDistance_PreToSynapse(no_connection, pre_index, synapses=[]):
# def sortNeuronsToUV(layer, neuronset, u_or_v):
# def computeMapping(layers, connections, distances, point, debug=False):
# def computeDistanceToSynapse(ilayer, slayer, p_3d, s_2d, dis):
# def addConnection(*args):
# def replaceMapping(index, connection):
# def computeAllConnections():
# def updateMapping(index):
# def computeConnectivity(con, create=True, threads = None):
# def post_neuron_wrapper(x):
# def post_neuron_initializer(players, pconnections, pdistances):
# def pre_neuron_wrapper(x):
# def pre_neuron_initializer(players, pconnections, pdistances, puv_grid, pno_synapses):
# def computeConnectivityThreaded(con, create=True, threads = None):
# def computeConnectivityAll(layers, neuronset1, neuronset2, slayer, connections, distances, func, args):
# def printConnections():
# def computeDistance(layer1, layer2, neuronset1, neuronset2, common_layer,
#                     connection_matrix):
# def measureUVs(objects):
# def initializeUVs():
# def returnNeuronGroups():
# def resetOrigins():
# def initialize3D():
# 
# Path: pam/constants.py
# RAY_FAC = 0.3
# INTERPOLATION_QUALITY = 10
# CACHE_QUADTREE_DEPTH = 2
# UV_THRESHOLD = 1e-8
# UV_GRID_THRESHOLD = 1e-3
# DEFAULT_RESOLUTION = 0.05
# KERNEL_THRESHOLD = 0.05
# PATH_BEVEL_DEPTH = 0.005


# Path: pam/debug.py
from pam import model
from pam import pam
from pam import constants
import bpy
import numpy
import logging



logger = logging.getLogger(__package__)

def getUniqueUVMapErrors():
    """Returns a list of unique connection errors that occur during uv-mapping phase.

    :return: list of failed UV-Mappings
    :rtype: list of exceptions.UVMapError"""
    errors = {}

    for err in model.CONNECTION_ERRORS: