@@ -217,6 +217,31 @@ def do_3d_projection(self, renderer):
217217 def draw (self , renderer ):
218218 Patch .draw (self , renderer )
219219
220+
221+ class PathPatch3D (Patch3D ):
222+ '''
223+ 3D PathPatch object.
224+ '''
225+
226+ def __init__ (self , path , ** kwargs ):
227+ zs = kwargs .pop ('zs' , [])
228+ zdir = kwargs .pop ('zdir' , 'z' )
229+ Patch .__init__ (self , ** kwargs )
230+ self .set_3d_properties (path , zs , zdir )
231+
232+ def set_3d_properties (self , path , zs = 0 , zdir = 'z' ):
233+ Patch3D .set_3d_properties (self , path .vertices , zs = zs , zdir = zdir )
234+ self ._code3d = path .codes
235+
236+ def do_3d_projection (self , renderer ):
237+ s = self ._segment3d
238+ xs , ys , zs = zip (* s )
239+ vxs , vys ,vzs , vis = proj3d .proj_transform_clip (xs , ys , zs , renderer .M )
240+ self ._path2d = mpath .Path (zip (vxs , vys ), self ._code3d )
241+ # FIXME: coloring
242+ self ._facecolor2d = self ._facecolor3d
243+ return min (vzs )
244+
220245def get_patch_verts (patch ):
221246 """Return a list of vertices for the path of a patch."""
222247 trans = patch .get_patch_transform ()
@@ -233,6 +258,15 @@ def patch_2d_to_3d(patch, z=0, zdir='z'):
233258 patch .__class__ = Patch3D
234259 patch .set_3d_properties (verts , z , zdir )
235260
261+ def pathpatch_2d_to_3d (pathpatch , z = 0 , zdir = 'z' ):
262+ """Convert a PathPatch to a PathPatch3D object."""
263+ path = pathpatch .get_path ()
264+ trans = pathpatch .get_patch_transform ()
265+
266+ mpath = trans .transform_path (path )
267+ pathpatch .__class__ = PathPatch3D
268+ pathpatch .set_3d_properties (mpath , z , zdir )
269+
236270class Patch3DCollection (PatchCollection ):
237271 '''
238272 A collection of 3D patches.
0 commit comments