Beispiel #1
0
    def draw_hatch_entity(self, entity: DXFGraphic,
                          properties: Properties) -> None:
        def to_path(p):
            path = Path.from_hatch_boundary_path(p, ocs, elevation)
            path.close()
            return path

        if not self.out.show_hatch:
            return

        hatch = cast(Hatch, entity)
        ocs = hatch.ocs()
        # all OCS coordinates have the same z-axis stored as vector (0, 0, z),
        # default (0, 0, 0)
        elevation = entity.dxf.elevation.z

        external_paths = []
        holes = []
        paths = hatch.paths.rendering_paths(hatch.dxf.hatch_style)
        if self.nested_polygon_detection:
            polygons = self.nested_polygon_detection(map(to_path, paths))
            external_paths, holes = nesting.winding_deconstruction(polygons)
        else:
            for p in paths:
                if p.path_type_flags & const.BOUNDARY_PATH_EXTERNAL:
                    external_paths.append(to_path(p))
                else:
                    holes.append(to_path(p))

        if external_paths:
            self.out.draw_filled_paths(external_paths, holes, properties)
        elif holes:
            # First path is the exterior path, everything else is a hole
            self.out.draw_filled_paths([holes[0]], holes[1:], properties)
Beispiel #2
0
def test_winding_deconstruction(polygons, exp_ccw, exp_cw):
    ccw, cw = nesting.winding_deconstruction(polygons)
    assert ccw == exp_ccw
    assert cw == exp_cw