def render_3dfaces( self, layout: "GenericLayoutType", dxfattribs=None, matrix: "Matrix44" = None, ucs: "UCS" = None, ): """Render mesh as :class:`~ezdxf.entities.Face3d` entities into `layout`. Args: layout: :class:`~ezdxf.layouts.BaseLayout` object dxfattribs: dict of DXF attributes e.g. ``{'layer': 'mesh', 'color': 7}`` matrix: transformation matrix of type :class:`~ezdxf.math.Matrix44` ucs: transform vertices by :class:`~ezdxf.math.UCS` to :ref:`WCS` """ dxfattribs = dict(dxfattribs) if dxfattribs else {} t = MeshTransformer.from_builder(self) if matrix is not None: t.transform(matrix) if ucs is not None: t.transform(ucs.matrix) for face in subdivide_ngons(t.faces_as_vertices()): layout.add_3dface(face, dxfattribs=dxfattribs)
def render_polyface(self, layout: 'GenericLayoutType', dxfattribs: dict = None, matrix: 'Matrix44' = None, ucs: 'UCS' = None): """ Render mesh as :class:`~ezdxf.entities.Polyface` entity into `layout`. Args: layout: :class:`~ezdxf.layouts.BaseLayout` object dxfattribs: dict of DXF attributes e.g. ``{'layer': 'mesh', 'color': 7}`` matrix: transformation matrix of type :class:`~ezdxf.math.Matrix44` ucs: transform vertices by :class:`~ezdxf.math.UCS` to :ref:`WCS` """ polyface = layout.add_polyface(dxfattribs=dxfattribs) t = MeshTransformer.from_builder(self) if matrix is not None: t.transform(matrix) if ucs is not None: t.transform(ucs.matrix) polyface.append_faces(subdivide_ngons(t.faces_as_vertices())) return polyface
def test_subdivide_ngons(): hexagon = list(circle(6)) result = list(subdivide_ngons([hexagon])) assert len(result) == 6