예제 #1
0
    def Search_Paths(self,
                     c_nr=None,
                     c=None,
                     p_nr=None,
                     dir=None,
                     points=None):
        """
        Search_Paths() - Search the paths through the Contour
        """

        # Define the direction of the search (1 = positive, 0 = neg or reverse)

        # If it is the first call a new contour is to be created
        if len(c) == 0:
            c.append(ContourClass(cont_nr=0, order=[[p_nr, dir]]))

        # Suchen des Punktes innerhalb der points List (n�tig da verwendete Punkte gel�scht werden)
        # Search for the item within the list of points (ntig used as points gelscht) ???
        for new_p_nr in range(len(points)):
            if points[new_p_nr].point_nr == p_nr:
                break

        # Next point depending on the direction
        if dir == 0:
            weiter = points[new_p_nr].en_cp
        elif dir == 1:
            weiter = points[new_p_nr].be_cp

        # Schleife f�r die Anzahl der Abzweig M�glichkeiten
        # Loop for the number of the branch can write ???
        for i in range(len(weiter)):
            # Wenn es die erste M�glichkeit ist Hinzuf�gen zur aktuellen Kontur
            # If it is the first possibility to add to the current contour
            if i == 0:
                if not (c[c_nr].is_contour_closed()):
                    c[c_nr].order.append(weiter[0])

            # There is a branch.  It is copied to the current contour and the
            # other branches follow
            elif i > 0:
                if not (c[c_nr].is_contour_closed()):
                    # print 'Abzweig ist m�glich'
                    c.append(deepcopy(c[c_nr]))
                    del c[-1].order[-1]
                    c[-1].order.append(weiter[i])

        for i in range(len(weiter)):
            # print 'I ist: ' +str(i)
            if i == 0:
                new_c_nr = c_nr
            else:
                new_c_nr = len(c) - len(weiter) + i

            new_p_nr = c[new_c_nr].order[-1][0]
            new_dir = c[new_c_nr].order[-1][1]
            if not (c[new_c_nr].is_contour_closed()):
                c = self.Search_Paths(copy(new_c_nr), c, copy(new_p_nr),
                                      copy(new_dir), points)
        return c
예제 #2
0
 def App_Cont_or_Calc_IntPts(self, cont, points, i, tol, warning):
     """
     App_Cont_or_Calc_IntPts()
     """
     # Hinzuf�gen falls es keine geschlossene Polyline ist
     # Add if it is not a closed polyline
     if self.geo[0].Ps.within_tol(self.geo[-1].Pe, tol):
         self.analyse_and_opt()
         cont.append(ContourClass(len(cont), 1, [[i, 0]], self.length))
     else:
         points.append(
             PointsClass(point_nr=len(points),
                         geo_nr=i,
                         Layer_Nr=self.Layer_Nr,
                         be=self.geo[0].Ps,
                         en=self.geo[-1].Pe,
                         be_cp=[],
                         en_cp=[]))
     return warning
예제 #3
0
 def App_Cont_or_Calc_IntPts(self, cont, points, i, tol, warning):
     """
     App_Cont_or_Calc_IntPts()
     """
     cont.append(ContourClass(len(cont), 0, [[i, 0]], 0))
     return warning
예제 #4
0
    def Search_Contours(self, geo=None, all_points=None):
        """
        Search_Contours() - Find the best continuous contours
        """

        found_contours = []
        points = deepcopy(all_points)

        while len(points) > 0:
            # print '\n Neue Suche'
            # Wenn nichts gefunden wird dann einfach die Kontur hochz�hlen
            # If nothing found then count up the contour
            if len(points[0].be_cp) == 0 and len(points[0].en_cp) == 0:
                # print '\nGibt Nix'
                found_contours.append(
                    ContourClass(len(found_contours), 0,
                                 [[points[0].point_nr, 0]], 0))
            elif len(points[0].be_cp) == 0 and len(points[0].en_cp) > 0:
                # print '\nGibt was R�ckw�rts (Anfang in neg dir)'
                new_cont_pos = self.Search_Paths(0, [], points[0].point_nr, 0,
                                                 points)
                found_contours.append(
                    self.Get_Best_Contour(len(found_contours), new_cont_pos,
                                          geo, points))
            elif len(points[0].be_cp) > 0 and len(points[0].en_cp) == 0:
                # print '\nGibt was Vorw�rt (Ende in pos dir)'
                new_cont_neg = self.Search_Paths(0, [], points[0].point_nr, 1,
                                                 points)
                found_contours.append(
                    self.Get_Best_Contour(len(found_contours), new_cont_neg,
                                          geo, points))
            elif len(points[0].be_cp) > 0 and len(points[0].en_cp) > 0:
                # print '\nGibt was in beiden Richtungen'
                # Suchen der m�glichen Pfade
                # Search the possible paths
                new_cont_pos = self.Search_Paths(0, [], points[0].point_nr, 1,
                                                 points)
                # Bestimmen des besten Pfades und �bergabe in cont
                # Determine the best path and Xbergabe in cont ???
                found_contours.append(
                    self.Get_Best_Contour(len(found_contours), new_cont_pos,
                                          geo, points))
                # points = self.Remove_Used_Points(cont[-1], points)

                # Falls der Pfad nicht durch den ersten Punkt geschlossen ist
                # If the path is not closed by the first point
                if found_contours[-1].closed == 0:
                    # print '\nPfad nicht durch den ersten Punkt geschlossen'
                    found_contours[-1].reverse()
                    # print ("Neue Kontur umgedrejt %s" % cont[-1])
                    new_cont_neg = self.Search_Paths(0, [found_contours[-1]],
                                                     points[0].point_nr, 0,
                                                     points)
                    found_contours[-1] = self.Get_Best_Contour(
                        len(found_contours) - 1, new_cont_neg + new_cont_pos,
                        geo, points)

            else:
                print('FEHLER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')

            points = self.Remove_Used_Points(found_contours[-1], points)

            found_contours[-1] = self.Contours_Points2Geo(
                found_contours[-1], all_points)
        return found_contours
예제 #5
0
 def App_Cont_or_Calc_IntPts(self, cont, points, i, tol, warning):
     cont.append(ContourClass(len(cont), 1, [[i, 0]], self.length))
     return warning