 }
 
 public final class Surface {
+    private static let numberOfBuckets: Int = 128
+    private let weldEpsilon: Float = 0.5
+    private let cellSize: Float = 10.0
+    private var buckets: [Int]
     private var vertices: [Vector3D]
+    private var nextVertex: [Int]
     private var faces: [Triangle]
     
     public init(reserveCapacity: Int) {
-        self.vertices = [float3]()
+        self.buckets = [Int](count: Surface.numberOfBuckets, repeatedValue: -1)
+        self.vertices = [Vector3D]()
+        self.nextVertex = [Int]()
         self.faces = [Triangle]()
         self.vertices.reserveCapacity(reserveCapacity)
+        self.nextVertex.reserveCapacity(reserveCapacity)
         self.faces.reserveCapacity(reserveCapacity)
     }
     

        return faces
    }
    
    public func addVertex(vertex: Vector3D) -> Int {
        let index = vertices.count
        vertices.append(vertex)
        return index
    }
    
    public func addFace(a: Int, _ b: Int, _ c: Int) {
        faces.append(Triangle(a, b, c))
    }
    
    public func triangles() -> [Triangle3D] {

                let deltaBC = (rc - rb) * rowDelta
                var nextBC = rb
                
                for i in 0..<row {
                    let index = subdividedSurface.addVertex(nextBC, unique: (i > 0))
                    rowIndices.append(index)
                    nextBC += deltaBC
                }

                let lastIndex = subdividedSurface.addVertex(rc, unique: false)
                rowIndices.append(lastIndex)
                rows.append(rowIndices)
            }
