def getNewGeos(self, geos): # TODO use intersect class and update_start_end_points new_geos = Geos([]) for geo in geos.abs_iter(): if isinstance(geo, LineGeo): new_geos.extend(self.breakLineGeo(geo)) elif isinstance(geo, ArcGeo): new_geos.extend(self.breakArcGeo(geo)) else: new_geos.append(geo) return new_geos
def breakArcGeo(self, arcGeo): """ Try to break passed arcGeo with any of the shapes on a break layers. Will break arcGeos recursively. @return: The list of geometries after breaking (arcGeo itself if no breaking happened) """ newGeos = Geos([]) for breakLayer in self.breakLayers: for breakShape in breakLayer.shapes.not_disabled_iter(): intersections = self.intersectArcGeometry(arcGeo, breakShape) if len(intersections) == 2: (near, far) = self.classifyIntersections(arcGeo, intersections) logger.debug("Arc %s broken from (%f, %f) to (%f, %f)" % (arcGeo.toShortString(), near.x, near.y, far.x, far.y)) newGeos.extend(self.breakArcGeo(ArcGeo(Ps=arcGeo.Ps, Pe=near, O=arcGeo.O, r=arcGeo.r, s_ang=arcGeo.s_ang, direction=arcGeo.ext))) newGeos.append(BreakGeo(near, far, breakShape.axis3_mill_depth, breakShape.f_g1_plane, breakShape.f_g1_depth)) newGeos.extend(self.breakArcGeo(ArcGeo(Ps=far, Pe=arcGeo.Pe, O=arcGeo.O, r=arcGeo.r, e_ang=arcGeo.e_ang, direction=arcGeo.ext))) return newGeos return [arcGeo]
def breakLineGeo(self, lineGeo): """ Try to break passed lineGeo with any of the shapes on a break layers. Will break lineGeos recursively. @return: The list of geometries after breaking (lineGeo itself if no breaking happened) """ newGeos = Geos([]) for breakLayer in self.breakLayers: for breakShape in breakLayer.shapes.not_disabled_iter(): intersections = self.intersectLineGeometry(lineGeo, breakShape) if len(intersections) == 2: (near, far) = self.classifyIntersections(lineGeo, intersections) logger.debug("Line %s broken from (%f, %f) to (%f, %f)" % (lineGeo.to_short_string(), near.x, near.y, far.x, far.y)) newGeos.extend(self.breakLineGeo(LineGeo(lineGeo.Ps, near))) newGeos.append(BreakGeo(near, far, breakShape.axis3_mill_depth, breakShape.f_g1_plane, breakShape.f_g1_depth)) newGeos.extend(self.breakLineGeo(LineGeo(far, lineGeo.Pe))) return newGeos return [lineGeo]