@@ -227,8 +227,11 @@ def mesh_check_cell(cIdx,verbose,mesh_state):
227227 return np .all (np .array (outwards )> 0 )
228228
229229
230- def mesh_slice (slice_normal , slice_offset , xyz , face_nodes , face_cells , cell_faces ):
230+ def mesh_slice (slice_normal , slice_offset , cell_mapping , xyz , face_nodes , face_cells , cell_faces ):
231231 tol = 1e-10
232+ if cell_mapping is None :
233+ cell_mapping = np .arange (len (cell_faces ))
234+
232235 # identify which faces to slice:
233236 if 1 :
234237 offset_xyz = np .dot (xyz ,slice_normal ) - slice_offset
@@ -495,7 +498,10 @@ def mesh_slice(slice_normal, slice_offset, xyz, face_nodes, face_cells, cell_fac
495498 # bad here.
496499 if f_i == 0 and side_xyz [f_nodes [f_i + 1 ]]!= 0 :
497500 # last-to-first edge is the one.
498- assert f_nodes [- 1 ]>= n_node_orig ,"More trouble with slice nodes"
501+ # pretty sure this overly restrictive. face could have come in with a node
502+ # on the slice. Even if it's a new face, one of the nodes could have already
503+ # been on the slice.
504+ #assert f_nodes[-1]>=n_node_orig,"More trouble with slice nodes"
499505 nodeA = f_nodes [- 1 ]
500506 nodeB = f_nodes [0 ]
501507 assert nodeA != nodeB
@@ -563,6 +569,7 @@ def mesh_slice(slice_normal, slice_offset, xyz, face_nodes, face_cells, cell_fac
563569 new_cIdx = len (cell_faces )
564570 cell_faces [cIdx ,:] = cell_face_neg
565571 cell_faces = utils .array_append (cell_faces ,cell_face_pos )
572+ cell_mapping = utils .array_append (cell_mapping , cell_mapping [cIdx ])
566573 face_cells = utils .array_append (face_cells ,np .array ([cIdx ,new_cIdx ]))
567574
568575 #import pdb
@@ -602,7 +609,7 @@ def mesh_slice(slice_normal, slice_offset, xyz, face_nodes, face_cells, cell_fac
602609 else :
603610 assert False ,"Failed to find face to flip"
604611
605- return (xyz , face_nodes , face_cells , cell_faces )
612+ return cell_mapping , (xyz , face_nodes , face_cells , cell_faces )
606613
607614
608615def mesh_cell_bboxes (xyz ,face_nodes ,face_cells ,cell_faces ):
0 commit comments