I am creating a mesh of codimension one, i.e. a 2D-manifold in 3D space. I am using the MeshEditor. It is very important that the face orientation, that is the direction of the normal, is correct.
I tried to manipulate the orientation by changing the vertex sequence in the cell specification. A sketch of code:
nodes = []
cells = []
cell_ids = []
# fill the list with data
for c in cells:
# compute normal according to right-hand rule
if wrong_direction:
tmp = c[0]
c[0] = c[1]
c[1] = tmp
mesh_editor.init_vertices(nodes.shape[0])
mesh_editor.init_cells(cells.shape[0])
[mesh_editor.add_vertex(i,n) for i,n in enumerate(nodes)]
[mesh_editor.add_cell(i,c) for i,c in enumerate(cells)]
mesh_editor.close()
Is this the correct way?