estimator.py

class gnp.estimator.GeometryEstimator(pcd: Tensor, orientation: Tensor, function_values: Tensor | None = None, model_name: str = 'clean_30k', batch_size: int = 8192, device: str = 'cpu', **data_kwargs: dict | None)[source]

Bases: object

Class used for geometry estimation using the pre-trained PatchGNP.

Parameters:
  • pcd (torch.Tensor) -- Point cloud data (N, 3).

  • orientation (torch.Tensor) -- Normal vectors for each point (N, 3).

  • function_values (torch.Tensor, optional) -- Function values defined on the point cloud, by default None.

  • model_name (str) -- Name of the pre-trained model to use, by default "clean_30k". Options: "clean_30k", "clean_50k", "noise_70k", "outlier_50k".

  • batch_size (int, optional) -- Batch size for processing patches, by default 8192.

  • device (str, optional) -- Device to run the model on, by default "cpu".

  • **data_kwargs -- Additional keyword arguments for data configuration. These will override the default data configurations.

estimate_quantities(quantity_names: list[str]) dict[str, Tensor][source]

Estimate geometric quantities on the point cloud. This function returns a dictionary containing the estimated scalar and/or vector values.

Parameters:

quantity_names (list[str]) -- List of quantity names to estimate. Available quantities include: 'xyz_coordinates', 'normals', 'tangents', 'mean_curvature', 'gaussian_curvature', 'pca_coordinates', 'normals_pca', 'tangents_pca', 'metric', 'shape', 'weingarten', 'inverse_metric', 'inverse_metric_derivatives', 'det_metric', 'laplace_beltrami_from_coefficients'.

Returns:

A dictionary where keys are the quantity names and values are the estimated tensors.

Return type:

dict[str, torch.Tensor]

flow_step(delta_t: float, subsample_radius: float, smooth_radius: float, smooth_x: bool) dict[source]

Perform a single step of mean curvature flow on the point cloud.

Parameters:
  • delta_t (float) -- Time step for the flow.

  • subsample_radius (float) -- Radius used for subsampling points after the flow step.

  • smooth_radius (float) -- Radius used for smoothing the mean curvature before the flow step.

  • smooth_x (bool) -- Whether to smooth the point cloud coordinates before the flow step.

Returns:

A dictionary containing the updated point cloud data ('x'), normals, and mean curvature.

Return type:

dict

gmls_weights(patch_data: PatchData, mask: Tensor, radius: float = 1.0, p: int = 4) tuple[Tensor, Tensor][source]

Compute the weights for the generalized moving least squares (GMLS) method.

Parameters:
  • patch_data (PatchData) -- PatchData object containing coordinate data.

  • mask (torch.Tensor) -- A boolean mask indicating which points in the patch data to use.

  • radius (float, optional) -- Radius to truncate the weight function, by default 1.0.

  • p (int, optional) -- The exponent for the weight function, by default 4.

Returns:

A tuple containing: - The weight matrices for each patch (batch_size, 1, num_points). - The dense mask used to create the dense batch.

Return type:

tuple[torch.Tensor, torch.Tensor]

laplace_beltrami_legendre_blocks(surface: Surface) Tensor[source]

Compute the Laplace-Beltrami operator of Legendre basis functions.

Parameters:

surface (Surface) -- Surface object containing patch information and basis functions.

Returns:

A tensor containing the Laplace-Beltrami operator applied

Return type:

torch.Tensor

legendre_blocks(surface: Surface, mask: Tensor) Tensor[source]

Evaluate Legendre basis functions for each point in the patches.

This method evaluates the Legendre basis functions at the local uv coordinates of the points specified by the mask and returns them as a dense tensor, batched by patch.

Parameters:
  • surface (Surface) -- Surface object containing patch data and basis functions.

  • mask (torch.Tensor) -- A boolean mask to select which points' local coordinates to use for the evaluation.

Returns:

A dense tensor of Legendre basis function evaluations, with shape (num_patches, max_points_in_patch, num_basis_functions).

Return type:

torch.Tensor

mean_flow(num_steps: int, save_data_per_step: int, delta_t: float, subsample_radius: float, smooth_radius: float, smooth_x: bool) list[dict][source]

Perform mean curvature flow on the point cloud over multiple steps.

This method iteratively applies the mean curvature flow step and saves the state of the point cloud at specified intervals.

Parameters:
  • num_steps (int) -- The total number of flow steps to perform.

  • save_data_per_step (int) -- The interval at which to save the point cloud data. For example, a value of 5 means data is saved every 5 steps.

  • delta_t (float) -- Time step for each flow step.

  • subsample_radius (float) -- Radius used for subsampling points after each flow step.

  • smooth_radius (float) -- Radius used for smoothing the mean curvature before each flow step.

  • smooth_x (bool) -- Whether to smooth the point cloud coordinates before each flow step.

Returns:

A list of dictionaries. Each dictionary contains the point cloud data ('x'), 'normals', and 'mean_curvature' at a saved step.

Return type:

list[dict]

patch_data(**datakwargs) PatchData[source]

Create a PatchData object from the point cloud data.

This method configures and generates patches from the input point cloud data, which can then be used by the model for predictions.

Parameters:

**datakwargs -- Keyword arguments to override data configuration settings.

Returns:

A PatchData object containing the point cloud data structured into patches.

Return type:

PatchData

stiffness_matrix_gmls(drop_ratio: float = 0.1, radius: float = 1.0, p: int = 4, remove_outliers: bool = False, outlier_threshold: float = 0.2) tuple[csr_array, Tensor, Tensor][source]

Compute the stiffness matrix using the generalized moving least squares (GMLS) method.

Parameters:
  • drop_ratio (float, optional) -- Ratio of points to drop. Defaults to 0.1.

  • radius (float, optional) -- Radius to truncate weight function. Defaults to 1..

  • p (int, optional) -- Degree p of the weight function. Defaults to 4.

  • remove_outliers (bool, optional) -- Whether to remove outliers. Defaults to False.

  • outlier_threshold (float, optional) -- The threshold used to determine which points are labeled as outliers. Only used if remove_outliers is True.

Returns:

  • sp.csr_array -- Stiffness matrix for solving the Laplace-Beltrami PDE

  • torch.Tensor -- Mask for which values to solve collocation problem on.

  • torch.Tensor -- Mask for points that are removed in smoothing. If remove_outliers is False then the mask will be all true.

surface_patch(patch_data: PatchData | None = None) Surface[source]

Create a Surface from the input patch data using the predictions from the model.

Parameters:

patch_data (PatchData, optional) -- Batch containing the input patch data. If patch_data is None defaults to self.patch_data()

Returns:

Surface object.

Return type:

Surface