def onStrokeAdded( self, stroke ): #If it's a closed figure, it is its own wall rtm_logger.debug("Stroke Added") newWallDict = {'closed': False, 'matches': {}} ep1 = stroke.Points[0] ep2 = stroke.Points[-1] strokeLen = GeomUtils.strokeLength(stroke) addToWalls = True if GeomUtils.pointDistanceSquared(ep1.X, ep1.Y, ep2.X, ep2.Y) < (strokeLen * 0.05) ** 2: rtm_logger.debug("Closed stroke") newWallDict['closed'] = True rtm_logger.debug("Adding stroke as possible future wall") self.wallInfo[stroke] = newWallDict #self.linkStrokesTogether() for testStroke, wallDict in self.wallInfo.items(): gran = min(len(stroke.Points), len(testStroke.Points)) if wallDict['closed'] and GeomUtils.strokeContainsStroke(testStroke, stroke, granularity = gran): outStk = testStroke inStk = stroke elif newWallDict['closed'] and GeomUtils.strokeContainsStroke(stroke, testStroke, granularity = gran): outStk = stroke inStk = testStroke else: continue rtm_logger.debug("Found containment with another stroke") rtAnno = RaceTrackAnnotation(rightwalls = [outStk], leftwalls = [inStk]) BoardSingleton().AnnotateStrokes([stroke, testStroke], rtAnno) del(self.wallInfo[testStroke]) addToWalls = False break