Skip to content

Discuss refreshing/refactoring DistanceGrid/ImplicitCollision/ImplicitFiel plugins #5575

@damienmarchal

Description

@damienmarchal

Updating scalar field representation in SOFA

Currently there is at least three plugin with component implementing behavior relying on represting shape with scalar field function (SF). I.e. function that maps a point from the euclidian space (in 3d) to a single value scalar then defining the object surface as the set of points where the scalar field function is equal to a given value (eg: 0.0) . When the field is encoding a distance function, we refer to them as Distance Field (DF).

Let's have a look at the current Sofa situation.

Plugin: SofaImplicitField

Declare and define the base classe (ScalarField) to inherit from in order to implement a scalar field. The object must have a getValue method. This method is implementing the field function that maps from R^3 to R. The ScalarField class provides getGradient and getHessian of the field. If the latter two are not provided they are computed using finite difference.

ScalarField also implement different algorithms:

  • a segment to "surface" intersection that consists in marching along the segment until the first zero iso-value is found.
  • a project to surface,

To allow certain type of optimization, the ScalarField method have a "domain" parameter can be used to accelerate the computation by using the domain parameter to help locate more efficiently the elements involved in computation. This only make sense if the field is local and its computation can be decomposed in different domains.

In component/geometry:
Three geometric shapes are actually implemented: StartShapedField, SphericalFIeld, BottleField
These must be considered as examples. A much rich set of primitives can be found here: https://iquilezles.org/articles/distfunctions/

There is also a DiscreetGridField, which is the sampling of a field in a 3D grid and its "reconstruction" using a linear interpolation. The implementation also contains file loader from MHD field. The component handle field translation, but cannot handle rotation and scale.

In component/mapping:

  • ImplicitSurfaceMapping: take a set of position, and radius, and mesh with a marching cube the field that is generated from the formula: http://astronomy.swin.edu.au/~pbourke/modelling/implicitsurf/ (a blended sum of ball's field). This component mix the marching cube algorithm and a specific field computation... it may be worth separating the two concerns.

Plugin: SofaDistanceGrid

The plugin focus on a special case of Scalar Field (SF) name Distance Field (DF) for collision. The general idea is that when the field encodes a signed distance function (often refer as SDF), i.e a function that returns negative value for inside, positive value for outside, zero on the frontiere and the value correspond to the distance to the closest point with field value is zero... then it is trivial to test for intersection of particles using the field value. If the field's evaluation can be computed efficiently and in constant time, this can lead to reduce performance for the collision.

A simple structure with constant time evaluation of a field is a discreet field, a 3d grid used holding the samples of the scalar field . On top of such discreet field, a continuous field can be constructed using an interpolation scheme.

In the SofaDistanceGrid plugin, several component are using these discreet fields for collision.
Let's have a look:

  • DistanceGrid seems to implement the c++ container suitable to implement a discreet grid field. There is code to load such a grid from different fileformat (eg: VTK). The function can also compute the distance grid from a mesh (there is an implementation of the Fast Marching Method), there is also different function bounds for getValue() (useful for collision detction quick rejection)

  • DistanceGridForceField seems to compute a force as a combination of a "virtual" spring linking the points of a topology with their closest point on the implicit surface. Additional forces can be produces for triangles or tetrahedron, by computing the center of mass of the triangle (resp tetra) that is combined with a kind of spring force penalizing the change of area (resp, volume).

  • RigidDistanceGridCollisionModel: Use a DistanceGrid as a collision model for a rigid, the grid's content can be loaded from a file, rotation, scale and translation can be applied to the grid. The collision is computed using the RigidDistanceGridDiscreteIntersection class.

  • FFDDistanceGridCollisionModel (missing): Use a FFD cage to deform the space before calling a DistanceGrid field getValue evaluation. The deformation field (the FFD) can be animated using an HexahedronFEMForceFIeld. The topology seems to be from a SpareGridTopology (which is surprising).

There also exists several plugin, public or private that have used implicit field function. Here are some of them (please report if you are aware of others)

Plugin: ImplicitSurface

A private plugin from DEFROST that contains both a skeleton based implicit geometry description, with marching cube to mesh the surface. There is some code shared with SofaImplicitField but actually most of the code seems to be dating back to the sofaeve project. There are several branches in this plugin, some of them seems to contain collision related elements including some linear and non linear constraints related to the implicite surface.

(Description to be continuated...)

branch: ImplicitCollision

(Description to be continuated...)

Plugin: ShapeGenerator

Private DEFROST plugin, with the work with T. Morzadec on shape generation, some branch contains component for surface et volumetric meshing of iso-surfaces defined with implicit function.

URL: https://gitlab.inria.fr/defrost/ShapeGenerator/

Work: GenerativeDesign

Private DEFROST plugin, with the work on shape generation by E. Menager.
https://gitlab.inria.fr/defrost/projects/2022/GenerativeDesign
Seems to use mostly voxels.

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