Beispiel #1
0
    def __divide_by_longest_edge(self, triangle, p, t):
        x, y, z = t[triangle]
        px = p[x]
        py = p[y]
        pz = p[z]

        xy = py - px
        xz = pz - px
        yz = pz - py

        lxy = length2(xy)
        lxz = length2(xz)
        lyz = length2(yz)

        if lxy >= lxz and lxy >= lyz:
            p, t, non_conforming_edge = self.__split_triangle(
                x, z, y, p, t, triangle)
        elif lxz >= lxy and lxz >= lyz:
            p, t, non_conforming_edge = self.__split_triangle(
                x, y, z, p, t, triangle)
        elif lyz >= lxy and lyz >= lxz:
            p, t, non_conforming_edge = self.__split_triangle(
                y, x, z, p, t, triangle)

        return p, t, non_conforming_edge
Beispiel #2
0
    def __fix_non_conforming_edge(self, edge, p, t):
        x, y, v, old_triangle_index = edge

        #look for triangles containing this edge
        triangleIndex = -1
        for i in range(len(t)):
            if x in t[i] and y in t[i]:
                triangleIndex = i
                break

        #no triangle found
        if triangleIndex == -1:
            return p, t, None

        #get triangle
        triangle = t[triangleIndex]

        for vertex in triangle:
            if vertex != x and vertex != y:
                z = vertex

        px, py, pz = p[x], p[y], p[z]

        xy = py - px
        xz = pz - px
        yz = pz - py

        lxy = length2(xy)
        lxz = length2(xz)
        lyz = length2(yz)

        if lxy >= lxz and lxy >= lyz:
            p, t, _ = self.__split_triangle(x, z, y, p, t, triangleIndex)
            non_conforming_edge = None
        elif lxz >= lxy and lxz >= lyz:
            p, t, non_conforming_edge = self.__split_triangle(
                x, y, z, p, t, triangleIndex)
            p, t, _ = self.__split_triangle(x, abs(non_conforming_edge[2]), y,
                                            p, t, abs(non_conforming_edge[3]))
        elif lyz >= lxy and lyz >= lxz:
            p, t, non_conforming_edge = self.__split_triangle(
                y, x, z, p, t, triangleIndex)
            p, t, _ = self.__split_triangle(x, abs(non_conforming_edge[2]), y,
                                            p, t, abs(non_conforming_edge[3]))

        return p, t, non_conforming_edge
Beispiel #3
0
    def __fix_non_conforming_edge(self, edge, p, t):
        x, y, v, old_triangle_index = edge

        #look for triangles containing this edge
        triangleIndex = -1
        for i in range(len(t)):
            if x in t[i] and y in t[i]:
                triangleIndex = i
                break

        #no triangle found
        if triangleIndex == -1:
            return p, t, None

        #get triangle
        triangle = t[triangleIndex]

        for vertex in triangle:
            if vertex != x and vertex != y:
                z = vertex

        px, py, pz = p[x], p[y], p[z]

        xy = py-px
        xz = pz-px
        yz = pz-py

        lxy = length2(xy)
        lxz = length2(xz)
        lyz = length2(yz)

        if lxy >= lxz and lxy >= lyz:
            p, t, _ = self.__split_triangle(x, z, y, p, t, triangleIndex)
            non_conforming_edge = None
        elif lxz >= lxy and lxz >= lyz:
            p, t, non_conforming_edge = self.__split_triangle(x, y, z, p, t, triangleIndex)
            p, t, _ = self.__split_triangle(x, abs(non_conforming_edge[2]), y, p, t, abs(non_conforming_edge[3]))
        elif lyz >= lxy and lyz >= lxz:
            p, t, non_conforming_edge = self.__split_triangle(y, x, z, p, t, triangleIndex)
            p, t, _ = self.__split_triangle(x, abs(non_conforming_edge[2]), y, p, t, abs(non_conforming_edge[3]))

        return p, t, non_conforming_edge
Beispiel #4
0
    def __divide_by_longest_edge(self, triangle, p, t):
        x, y, z = t[triangle]
        px = p[x]
        py = p[y]
        pz = p[z]

        xy = py-px
        xz = pz-px
        yz = pz-py

        lxy = length2(xy)
        lxz = length2(xz)
        lyz = length2(yz)

        if lxy >= lxz and lxy >= lyz:
            p, t, non_conforming_edge = self.__split_triangle(x, z, y, p, t, triangle)
        elif lxz >= lxy and lxz >= lyz:
            p, t, non_conforming_edge= self.__split_triangle(x, y, z, p, t, triangle)
        elif lyz >= lxy and lyz >= lxz:
            p, t, non_conforming_edge = self.__split_triangle(y, x, z, p, t, triangle)

        return p, t, non_conforming_edge