Skip to content

Return dataframe from xmsmesher #47

Description

@kcpevey

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions