def getAdjacentPoints(self, point): path = DNASuitPath() startIndex = point.getIndex() if startIndex not in self.suitEdges: return path for edge in self.suitEdges[startIndex]: path.addPoint(edge.getEndPoint()) return path
def getSuitPath(self, startPoint, endPoint, minPathLen = 40, maxPathLen = 300, allowStreetOnly = False): path = DNASuitPath() while path.getNumPoints() < maxPathLen: startPointIndex = startPoint.getIndex() if startPointIndex == endPoint.getIndex(): # reached the target # but if it's too short, # keep walking/moving if path.getNumPoints() >= minPathLen: break if startPointIndex not in self.suitEdges: raise DNAError('Could not find DNASuitPath.') edges = self.suitEdges[startPointIndex] #look for the first non-door (usually street) point streetPoint = None for edge in edges: startPoint = edge.getEndPoint() startPointType = startPoint.getPointType() # cog hq points are allowed as well isStreetPoint = startPointType not in (DNASuitPoint.pointTypeMap['FRONT_DOOR_POINT'], DNASuitPoint.pointTypeMap['SIDE_DOOR_POINT']) if isStreetPoint: if streetPoint is None: streetPoint = startPoint else: if allowStreetOnly: continue elif startPoint.getIndex() == endPoint.getIndex(): # the end point is a door point # and we found it # add it to the path # and return if (path.getNumPoints() + 1) >= minPathLen: path.addPoint(startPoint) return path else: # too bad, we didn't reach the minPathLen pass if streetPoint is None: raise DNAError('Could not find DNASuitPath.') else: startPoint = streetPoint path.addPoint(startPoint) return path
def getSuitPath(self, startPoint, endPoint, minPathLen=40, maxPathLen=300): path = DNASuitPath() path.addPoint(startPoint) while path.getNumPoints() < maxPathLen: startPointIndex = startPoint.getIndex() if startPointIndex == endPoint.getIndex(): if path.getNumPoints() >= minPathLen: break if startPointIndex not in self.suitEdges: raise DNAError('Could not find DNASuitPath.') edges = self.suitEdges[startPointIndex] for edge in edges: startPoint = edge.getEndPoint() startPointType = startPoint.getPointType() if startPointType != DNASuitPoint.FRONT_DOOR_POINT: if startPointType != DNASuitPoint.SIDE_DOOR_POINT: break else: raise DNAError('Could not find DNASuitPath.') path.addPoint(startPoint) return path