# Path: e3d/model_management/pygeom/face3.py
# class Face3:
#     def __init__(self, a, b, c, normals=None):
#         if normals is None:
#             normals = []
#         self.a = a
#         self.b = b
#         self.c = c
#         self.vertexNormals = normals
#         self.normal = vec3()
# 
#     def abcVec3(self):
#         return vec3(self.a, self.b, self.c)
# 
#     def __repr__(self):
#         return '{},{},{}'.format(self.a, self.b, self.c)


from cycgkit.cgtypes import vec3, mat4
from uuid import uuid1
from .face3 import Face3
import math
            # if any duplicate vertices are found in a Face3
            # we have to remove the face as nothing can be saved
            for n in range(3):
                if indices[n] == indices[(n + 1) % 3]:
                    dupIndex = n
                    faceIndicesToRemove.append(i)
                    break
        for i in range(len(faceIndicesToRemove) - 1, 0, -1):
            # for ( i = faceIndicesToRemove.length - 1 i >= 0 i -- ):
            idx = faceIndicesToRemove[i]

            self.faces.pop(idx)

            # for j in range(len(self.faceVertexUvs)):
            self.faceVertexUvs.pop(idx)

        # Use unique set of vertices

        diff = len(self.vertices) - len(unique)
        self.vertices = unique
        return diff

    def addGroup(self, start, count):

        self.groups.append({'start': start, 'count': count})

        return self

    def setIndex(self, indices):
        for v in indices:

# Path: e3d/model_management/pygeom/face3.py
# class Face3:
#     def __init__(self, a, b, c, normals=None):
#         if normals is None:
#             normals = []
#         self.a = a
#         self.b = b
#         self.c = c
#         self.vertexNormals = normals
#         self.normal = vec3()
# 
#     def abcVec3(self):
#         return vec3(self.a, self.b, self.c)
# 
#     def __repr__(self):
#         return '{},{},{}'.format(self.a, self.b, self.c)


# Path: e3d/model_management/pygeom/Geometry.py
from cycgkit.cgtypes import vec3, mat4
from uuid import uuid1
from .face3 import Face3
import math

            # if any duplicate vertices are found in a Face3
            # we have to remove the face as nothing can be saved
            for n in range(3):
                if indices[n] == indices[(n + 1) % 3]:
                    dupIndex = n
                    faceIndicesToRemove.append(i)
                    break
        for i in range(len(faceIndicesToRemove) - 1, 0, -1):
            # for ( i = faceIndicesToRemove.length - 1 i >= 0 i -- ):
            idx = faceIndicesToRemove[i]

            self.faces.pop(idx)

            # for j in range(len(self.faceVertexUvs)):
            self.faceVertexUvs.pop(idx)

        # Use unique set of vertices

        diff = len(self.vertices) - len(unique)
        self.vertices = unique
        return diff

    def addGroup(self, start, count):

        self.groups.append({'start': start, 'count': count})

        return self

    def setIndex(self, indices):
        for v in indices:

            self.faces.append(Face3(v.x, v.y, v.z))