upxo.xtalops.xtalops module

upxo.xtalops.xtalops.create_grid_points_in_polygon(polygon, grid_spacing=1.0, padding=0.0, return_classification=True)[source]

Create a rectangular grid based on polygon bounds and identify points inside/on boundary.

Parameters:
  • polygon (shapely.geometry.Polygon) – The boundary zone polygon to process

  • grid_spacing (float, default=1.0) – Spacing between grid points in both x and y directions

  • padding (float, default=0.0) – Additional padding to extend grid beyond polygon bounds

  • return_classification (bool, default=True) – If True, returns separate arrays for interior and boundary points. If False, returns all points inside or on boundary.

Returns:

  • grid_points (ndarray, shape (N, 2)) – All grid points within the bounding box

  • interior_points (ndarray, shape (M, 2)) – Points strictly inside the polygon (only if return_classification=True)

  • boundary_points (ndarray, shape (K, 2)) – Points on the polygon boundary (only if return_classification=True)

  • points_mask (ndarray, shape (N,) dtype=bool) – Boolean mask indicating which grid points are inside or on boundary (only if return_classification=False)

Examples

>>> # Get all points inside/on boundary
>>> grid_pts, mask = create_grid_points_in_polygon(bz, grid_spacing=0.5,
...                                                 return_classification=False)
>>> valid_pts = grid_pts[mask]
>>> # Get separated interior and boundary points
>>> grid_pts, interior_pts, boundary_pts = create_grid_points_in_polygon(bz,
...                                                                       grid_spacing=0.5)

Usage

from upxo.xtalops.xtalops import create_grid_points_in_polygon

upxo.xtalops.xtalops.skeletonize_polygon(polygon, method='medial_axis', grid_spacing=0.5, padding=0.1)[source]

Usage

from upxo.xtalops.xtalops import skeletonize_polygon as skpol