Marching Squares

https://user-images.githubusercontent.com/14288520/209447787-335afcf4-26d8-40d5-bb71-2ea28f067475.png

Dependencies

This node requires SkImage library to work.

Functionality

This node uses Marching Squares algorithm to find iso-lines of a scalar field, i.e. lines in some plane, for which the scalar field has constant specified value. The lines are generated as mesh - vertices and edges. You can use one of interpolation nodes to build Curve objects from them.

https://user-images.githubusercontent.com/14288520/209448129-feb46200-4ee7-4c05-b38b-1d23a44af5b3.png

See also

Inputs

This node has the following inputs:

  • Field. Scalar field to build iso-curves for. This input can consume a list of scalar fields, or a list of lists of scalar fields. Nesting level of outputs will correspond to nesting level of data in this input. This input is mandatory.

https://user-images.githubusercontent.com/14288520/209448345-4b5f4812-b208-47ec-b7b7-fdb255a54838.png https://user-images.githubusercontent.com/14288520/209450533-6adb8f4c-cc72-4572-a4b4-382682dd58ac.png
  • Value. The value, for which the iso-curves should be built. The default value is 1.0.

https://user-images.githubusercontent.com/14288520/209451096-b9799be0-a461-4d2d-8d1f-a5fd3d2801cb.png https://user-images.githubusercontent.com/14288520/209451130-a401dd2c-0038-4c72-9d44-7dbb54dab444.png
  • Samples. Number of samples along X and Y axes. This defines the resolution of curves: the bigger is value, the more vertices will the node generate, and the more precise the curves will be. But higher resolution requires more computation time. The default value is 50.

https://user-images.githubusercontent.com/14288520/209451249-1bb38dc6-4073-457b-abc8-7a0ef3b0f1fd.png
  • MinX, MaxX, MinY, MaxY. Minimum and maximum values of X and Y coordinates to find the iso-curves in. Default values define the square [-1; +1] x [-1; +1].

  • Z. The value of Z coordinate to generate the curves at. The default value is 0. So, by default, the node will use the section of scalar field by XOY plane to draw the iso-curves for.

https://gist.github.com/9699442f326876f6af21d8c305a0170c

https://user-images.githubusercontent.com/14288520/209451424-705bfb2c-d783-4b59-be22-a9d7d8d59ea7.png
  • Matrix. Reference frame to be used. X, Y and Z axes, which are used to section the scalar field, are defined by this matrix. By default, identity matrix is used, which means the global axes will be used.

https://gist.github.com/e5951d94d21dcb16193b985eb139b7da

https://user-images.githubusercontent.com/14288520/209451649-d04a934c-7852-49d2-a8f7-589d3b679048.png

Parameters

This node has the following parameters:

  • Flat output. If checked, the node will generate a single flat list of objects (iso-curves) for all provided iso-values. Otherwise, the node will generate a separate list of objects for each iso-value. Checked by default.

https://user-images.githubusercontent.com/14288520/209451720-59f100ed-3425-44e5-b824-cee69a6275c9.png
  • Make faces. If checked, the node will generate Faces for iso-curves that are closed within specified X/Y bounds. Unchecked by default.

Good results on a single value:

https://user-images.githubusercontent.com/14288520/209451885-ebae5116-def0-4d21-be9f-4d0f0b3aa1b7.png

On several values faces are overlapped:

https://user-images.githubusercontent.com/14288520/209451930-6cbca798-a9a8-4e95-8152-13f7897c8776.png
  • Connect boundary. If checked, the node will connect pieces of the same curve, that was split because it was cut by specified X/Y bounds. Otherwise, several separate pieces will be generated in such case. Checked by default.

https://user-images.githubusercontent.com/14288520/209452147-4305cec0-d0f9-46f5-a77f-8ad81c600d29.png

Example of usage

Build five planes parallel to XOY, and draw iso-lines of scalar field for seven different values:

https://user-images.githubusercontent.com/14288520/209452338-a5a7579f-9d3a-44d6-9f62-86919f3cf90d.png

It is hard to colorize values:

https://gist.github.com/96a7575ff899466965d5158bfe5e7301

https://user-images.githubusercontent.com/14288520/209452397-addd6f24-9294-44b0-868b-83458b67db4a.png https://user-images.githubusercontent.com/14288520/208299072-ae4c04db-cfe8-4c65-9ed5-495aba74b4df.gif