Shape Function Reference

Shape Function Reference

Introduction

The Metafold geometry kernel uses a computational directed acyclic graph (DAG) of operators to define shape functions. The DAG can be created through factory functions available in the SDK. By composing these operators you can create expressive implicit representations of arbitrarily complex shapes.

Operators are categorized into three main groups:

  • Sample: TODO
  • Filter: TODO
  • Transform: TODO

These operators are a symbolic representation of functions within the computational graph that are consumed by our backend via jobs like, evaluate_graph. In order to access the data locally you must download the resulting assets using the SDK and import it into your project. For example:

# ...

metafold = MetafoldClient(access_token, project_id)

# Symbolic representation.
source = GenerateSamplePoints(
    {
        "offset": [-60, -60, -60],
        "size": [120, 120, 120],
        "resolution": [512, 512, 512]
    }
)

# Convert representation to json format which is consumable by the backend.
source_graph = JSONEvaluator()
source(source_graph)
evaluation = metafold.jobs.run("evaluate_graph", {"graph": source_graph.json()})

# Download the created asset.
metafold.assets.download_file(evaluation.assets[0].id, "grid_points.bin")

# Load the results. This is an explicit, discretized representation of the shape.
grid_points = np.fromfile("grid_points.bin", dtype=np.float32)

# Print the first grid point.
print(grid_points[0:3])
# np.array([-60., -60., -60.])

Source Operators

GenerateSamplePoints

LoadSamplePoints

LoadVolume

Transform Operators

ComputeNormals

TransformCylindricalCoords

TransformMirrorCoords

TransformSphericalCoords

TransformTwistCoords

Sample Operators

MapTexturePrimitive

SampleBox

SampleBeam

SampleCustomShape

SampleTriangleMesh

SampleLattice

SampleSpinodoid [Under Development]

SampleSurfaceLattice

SampleVolume

Filter Operators

CSG

Shell

LinearFilter

Redistance

Threshold

Assets

Assets are handled using a Python dictionary or Javascript object. Each asset class has a field path where a user references the file containing the asset.

# ...

triangle_mesh_path = "path/to/mesh"
line_network_asset = TriangleMeshAsset()
line_network_asset["path"] = triangle_mesh_path

f = SampleTriangleMesh(source, mesh_data=line_network_asset)

# ...