Skip to content

Implicit fields

As the main goal of a neural implicit is to represent a signal over space, it is often required to generate a dataset of training points where the values for this signal is known. This job is handled by FieldGenerator objects. They are given as arguments to a PointSampler object to be called on all the sampled points.

Usual fields are implemented directly into implicitlab.

Available fields

Distance(geom, signed=True, square=False)

Computes the distance to the geometry.

Parameters:

Name Type Description Default
geom Mesh

the geometry object to consider.

required
signed bool

whether the distance is signed or not (i.e. negative inside and positive outside the shape). Defaults to True.

True
square bool

whether to square the value of the distance (while keeping the sign). Defaults to False.

False

Raises:

Type Description
UnsupportedGeometryFormat

Fails if the geometry does not have the right format.

Occupancy(geom, v_in, v_out, v_on)

Computes the occupancy of the given geometry, i.e. a constant value inside and another constant value outside of the object.

Parameters:

Name Type Description Default
geom Mesh

geometrical object to consider.

required
v_in float

value for points inside the object.

required
v_out float

value for points outside the object.

required
v_on float

value for points on the boundary of the object.

required

Raises:

Type Description
UnsupportedGeometryFormat

only makes sense for (closed) 2D polylines and 3D surface meshes.

WindingNumber(geom)

Computes the generalized winding number for the given shape. Is based on the fast_winding_number function from libigl.

Parameters:

Name Type Description Default
geom Mesh

the geometry to consider.

required

Raises:

Type Description
UnsupportedGeometryFormat

Fails if called on a geometry that is not a 3D SurfaceMesh, a 3D point cloud or a 2D polyline.

References

Nearest(geom)

Computes the coordinates of the nearest point on the geometry.

Parameters:

Name Type Description Default
geom Mesh

The geometry to consider

required

Raises:

Type Description
UnsupportedGeometryFormat

Currently implemented for 3D surface meshes, 3D point clouds, 2D polylines and 2D point clouds.

Constant(value)

Bases: FieldGenerator

Constant field generator. Associates the same value at every point.

Parameters:

Name Type Description Default
value float

which value to output at every position in space

required

compute_on(query)

Computes the value of the field at each point of the query array. Points are supposed to be on the geometry.

Note

Defining this function is optional. By default, compute_on(query) returns the value of compute(query). Since values of a field are sometimes known for query points on the geometry (for instance: a distance field has value 0 on the surface), it can be useful to avoid the field computation and overwrite this function.

Parameters:

Name Type Description Default
query ndarray

the query points

required

Returns:

Type Description
ndarray

np.ndarray: the value of the field at each query point.

CustomFunction(fun, fun_on=None)

Bases: FieldGenerator

Custom function field generation. Considers a function f over space and associates to each point x the value f(x)

Parameters:

Name Type Description Default
fun Callable

the function to be called.

required
fun_on Callable

a specific function to be called instead of fun if the point is on the surface. Defaults to None.

None

Make your custom field

The list of possible fields can be expanded by writing a custom class that inherits from the base abstract class FieldGenerator.

FieldGenerator

Bases: ABC

Base class for an implicit field.

compute(query) abstractmethod

Computes the value of the field at each point of the query array.

Parameters:

Name Type Description Default
query ndarray

the query points

required

Returns:

Type Description
ndarray

np.ndarray: the value of the field at each query point

compute_on(query)

Computes the value of the field at each point of the query array. Points are supposed to be on the geometry.

Note

Defining this function is optional. By default, compute_on(query) returns the value of compute(query). Since values of a field are sometimes known for query points on the geometry (for instance: a distance field has value 0 on the surface), it can be useful to avoid the field computation and overwrite this function.

Parameters:

Name Type Description Default
query ndarray

the query points

required

Returns:

Type Description
ndarray

np.ndarray: the value of the field at each query point.

The custom class only needs to define the compute method. Additionnally, the compute_on method can be provided.