44
55import pickle
66import json
7+ import collections
78
89from copy import deepcopy
910from ast import literal_eval
@@ -644,17 +645,17 @@ def from_vertices_and_faces(cls, vertices, faces):
644645 """
645646 mesh = cls ()
646647
647- if type (vertices ) == list :
648+ if isinstance (vertices , collections . MutableSequence ) :
648649 for x , y , z in iter (vertices ):
649650 mesh .add_vertex (x = x , y = y , z = z )
650- elif type (vertices ) == dict :
651+ elif isinstance (vertices , collections . Mapping ) :
651652 for key , xyz in vertices .items ():
652653 mesh .add_vertex (key = key , attr_dict = {i : j for i , j in zip (['x' , 'y' , 'z' ], xyz )})
653654
654- if type (faces ) == list :
655+ if isinstance (faces , collections . MutableSequence ) :
655656 for face in iter (faces ):
656657 mesh .add_face (face )
657- elif type (faces ) == dict :
658+ elif isinstance (faces , collections . Mapping ) :
658659 for fkey , vertices in faces .items ():
659660 mesh .add_face (vertices , fkey )
660661
@@ -3178,19 +3179,19 @@ def plot(self,
31783179
31793180 # # mesh.add_face([a, b, c, d, e, f, g, h])
31803181
3181- for k in mesh .faces ():
3182- print (k , mesh .is_face_on_boundary (k ))
3182+ # for k in mesh.faces():
3183+ # print(k, mesh.is_face_on_boundary(k))
31833184
31843185
3185- print (list (mesh .edges (True )))
3186+ # print(list(mesh.edges(True)))
31863187
31873188
3188- plotter = MeshPlotter (mesh )
3189+ # plotter = MeshPlotter(mesh)
31893190
3190- plotter .draw_vertices ()
3191- plotter .draw_edges ()
3192- plotter .draw_faces (text = 'key' )
3193- plotter .show ()
3191+ # plotter.draw_vertices()
3192+ # plotter.draw_edges()
3193+ # plotter.draw_faces(text='key')
3194+ # plotter.show()
31943195
31953196 # print(mesh.get_vertices_attribute('x'))
31963197 # print(mesh.get_vertices_attributes('xy'))
@@ -3213,8 +3214,27 @@ def plot(self,
32133214 mesh = Mesh .from_vertices_and_faces (vertices , faces )
32143215
32153216 plotter = MeshPlotter (mesh )
3216- plotter .draw_vertices ()
3217+ plotter .draw_vertices (text = 'key' )
32173218 plotter .draw_edges ()
32183219 plotter .draw_faces (text = 'key' )
32193220 plotter .show ()
32203221
3222+ vertices = [
3223+ [0 , 0 , 0 ],
3224+ [1 , 1 , 0 ],
3225+ [1 , - 1 , 0 ],
3226+ [- 1 , - 1 , 0 ],
3227+ [- 1 , 1 , 0 ]
3228+ ]
3229+ faces = [
3230+ [0 , 2 , 1 ],
3231+ [0 , 4 , 3 ]
3232+ ]
3233+
3234+ mesh = Mesh .from_vertices_and_faces (vertices , faces )
3235+
3236+ plotter = MeshPlotter (mesh )
3237+ plotter .draw_vertices (text = 'key' )
3238+ plotter .draw_edges ()
3239+ plotter .draw_faces (text = 'key' )
3240+ plotter .show ()
0 commit comments