Esempio n. 1
0
    def _flip_reversed_edges(self, dct):
        """
        Reverse the points of flipped edges in the geometry dictionary
        """

        _keys = tuple(dct.keys())
        _prev = _keys[0]
        _flip_test = []
        _flipped_edges = {}

        #check for proper point order
        for _edge in _keys[1:]:

            #test for flipped endpoints
            _flip_test = [
                TupleMath.manhattan(_prev.StartPoint, _edge.StartPoint)[0] < 0.01,
                TupleMath.manhattan(_prev.EndPoint, _edge.EndPoint)[0] < 0.01,
                TupleMath.manhattan(_prev.StartPoint, _edge.EndPoint)[0] < 0.01
            ]

            #flip the current edge points if either of last two cases
            if _flip_test[1] or _flip_test[2]:

                if _edge not in _flipped_edges:
                    _flipped_edges[_edge] = True
                    dct[_edge] = dct[_edge][::-1]

            #flip the previous edge points if first or last case
            if _flip_test[0] or _flip_test[2]:

                if _prev not in _flipped_edges:
                    _flipped_edges[_prev] = True
                    dct[_prev] = dct[_prev][::-1]

            _prev = _edge
Esempio n. 2
0
    def _combine_points(self, dct):
        """
        Combine a dictionary of points into a single list,
        eliminating duplicates and building the vector / angle tuples
        """

        _points = []

        for _v in dct.values():

            _p = [_w for _w in _v]

            #Eliminate duplicates at start / end points
            if _points:
                if TupleMath.manhattan(_p[0], _points[-1]) < 0.01:
                    _p = _p[1:]

            _points += _p

        return _points