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
def Search_Contours(self, geo=None, all_points=None, cont=None): """ Search_Contours() - Find the best continuous contours """ points = deepcopy(all_points) while (len(points)) > 0: #If nothing found then count up the contour if (len(points[0].be_cp) == 0) & (len(points[0].en_cp) == 0): #print '\nGibt Nix' cont.append( ContourClass(len(cont), 0, [[points[0].point_nr, 0]], 0)) elif (len(points[0].be_cp) == 0) & (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) cont.append( self.Get_Best_Contour(len(cont), new_cont_pos, geo, points)) elif (len(points[0].be_cp) > 0) & (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) cont.append( self.Get_Best_Contour(len(cont), new_cont_neg, geo, points)) elif (len(points[0].be_cp) > 0) & (len(points[0].en_cp) > 0): #print '\nGibt was in beiden Richtungen' #Search the possible paths new_cont_pos = self.Search_Paths(0, [], points[0].point_nr, 1, points) #Determine the best path and Xbergabe in cont ??? cont.append( self.Get_Best_Contour(len(cont), new_cont_pos, geo, points)) #points = self.Remove_Used_Points(cont[-1], points) #If the path is not closed by the first point if cont[-1].closed == 0: #print '\nPfad nicht durch den ersten Punkt geschlossen' cont[-1].reverse() #print ("Neue Kontur umgedrejt %s" % cont[-1]) new_cont_neg = self.Search_Paths(0, [cont[-1]], points[0].point_nr, 0, points) cont[-1] = self.Get_Best_Contour( len(cont) - 1, new_cont_neg + new_cont_pos, geo, points) else: print 'FEHLER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' points = self.Remove_Used_Points(cont[-1], points) cont[-1] = self.Contours_Points2Geo(cont[-1], all_points) return cont
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
def App_Cont_or_Calc_IntPts(self, cont, points, i, tol, warning): """ App_Cont_or_Calc_IntPts() """ if abs(self.length) < tol: pass #Add if it is not a closed polyline elif self.geo[0].Pa.isintol(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].Pa, en=self.geo[-1].Pe, be_cp=[], en_cp=[])) return warning
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
def App_Cont_or_Calc_IntPts(self, cont, points, i, tol, warning): cont.append(ContourClass(len(cont), 1, [[i, 0]], self.length)) return warning