The helper function:
def xmsmesh_to_dataframe(pts, cells):
"""
Convert mesh pts and cells to dataframe
Args:
pts (MultiPolyMesherIo.points): Points from a MultiPolyMesherIo
cells (MultiPolyMesherIo.cells: Cells from a MultiPolyMesherIo
Returns:
pd.DataFrame: MultiPolyMesherIo points in a dataframe
pd.DataFrame: MultiPolyMesherIo cells in a dataframe
"""
r_pts = pd.DataFrame(pts, columns=['x', 'y', 'z'])
r_cells = pd.DataFrame([(cells[x+2], cells[x+3], cells[x+4]) for x in range(0, len(cells), 5)], columns=['v0', 'v1', 'v2'])
return r_pts, r_cells
would logically reside in the package itself and allow for users to reformat the output into dataframes either with a keyword flag, or as a method on xmsmesh.meshing.MultiPolyMesherIo class. Personally, I'd prefer something like this:
mesh_io = xmsmesh.meshing.MultiPolyMesherIo(poly_inputs=input_polygon, refine_points=refine_points)
where
mesh_io.dframe() would return the equivalent of xmsmesh_to_dataframe above.
Other ideas would be:
- have dataframes be default output
- add a
mesh_io.array() method that returns a np.array.
The helper function:
would logically reside in the package itself and allow for users to reformat the output into dataframes either with a keyword flag, or as a method on xmsmesh.meshing.MultiPolyMesherIo class. Personally, I'd prefer something like this:
mesh_io = xmsmesh.meshing.MultiPolyMesherIo(poly_inputs=input_polygon, refine_points=refine_points)where
mesh_io.dframe()would return the equivalent ofxmsmesh_to_dataframeabove.Other ideas would be:
mesh_io.array()method that returns a np.array.