Video thumbnail
Preparing Script for Base Meshes
In this video we look more closely at the Marching Cubes algorithm and map out the steps we'll take to construct it. Then we set up our canvas in preparation for the first C# script.

Back to Marching Cubes
Code
Below is the code for the first mesh (we make the remaining base meshes in the next video). This is all of the code required inside the C# scripting component. Make sure you have the correct input (i_vertices, Type Hints: Point3d, List Access) and correct outputs (mesh_tree and bool_patterns). This code is for a Rhino 8 scripting component.
    
// Grasshopper Script Instance
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using System.Linq;

public class Script_Instance : GH_ScriptInstance
{
  
  private void RunScript(
	List<Point3d> i_vertices,
	ref object mesh_tree,
	ref object bool_patterns)
  {
    var vertices = i_vertices.ToList();

    var m_tree = new DataTree<Mesh>();
    var i_tree = new DataTree<int>();

    Mesh m0 = new Mesh();
    GH_Path pth_0 = new GH_Path(0);
    
    foreach (Point3d vertex in i_vertices){
        m0.Vertices.Add(vertex);
    }
    m0.Faces.AddFace(0, 8, 3);
    m_tree.Add(m0, pth_0);

    i_tree.Add(0, pth_0);
    i_tree.Add(1, pth_0);
    i_tree.Add(1, pth_0);
    i_tree.Add(1, pth_0);

    i_tree.Add(1, pth_0);
    i_tree.Add(1, pth_0);
    i_tree.Add(1, pth_0);
    i_tree.Add(1, pth_0);

    //

    mesh_tree = m_tree;
    bool_patterns = i_tree;
  }
}
  
Resources
Lorensen, W. E. (1987). Marching cubes: A high resolution 3d surface construction algorithm. Computer Graphics, 21, 163-169.

Lewiner, T., Lopes, H., Vieira, A. W., & Tavares, G. (2003). Efficient implementation of marching cubes' cases with topological guarantees. Journal of graphics tools, 8(2), 1-15.

Lorensen, W. E. (1987). Marching cubes: A high resolution 3d surface construction algorithm. Computer Graphics, 21, 163-169.

Raman, S., & Wenger, R. (2008, May). Quality isosurface mesh generation using an extended marching cubes lookup table. In Computer Graphics Forum (Vol. 27, No.3, pp. 791-798). Oxford, UK: Blackwell Publishing Ltd.
Doi, A., & Koide, A. (1991).