{"_id":"surface-nets","_rev":"11-7d7dfe04374607f0290bf109d0f80617","name":"surface-nets","description":"General purpose level set extraction","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"surface-nets","version":"1.0.0","description":"General purpose level set extraction","main":"surfacenets.js","directories":{"example":"example","test":"test"},"dependencies":{"ndarray-extract-contour":"^1.0.0","triangulate-hypercube":"^0.0.0","zero-crossings":"^1.0.0"},"devDependencies":{"gl-matrix":"~2.1.0","ndarray":"~1.0.11","ndarray-fill":"~0.1.0","svg-3d-simplicial-complex":"~0.1.1","tape":"~2.12.3"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/surface-nets.git"},"keywords":["surface","net","marching","cubes","polygonize","isosurface","ndarray","extract","boundary","volume","marching","squares"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/surface-nets/issues"},"homepage":"https://github.com/mikolalysenko/surface-nets","_id":"surface-nets@1.0.0","dist":{"shasum":"60d4eaff6dc5b74ec1631bbace1460632e53a80d","tarball":"https://registry.npmjs.org/surface-nets/-/surface-nets-1.0.0.tgz","integrity":"sha512-Gsv+i4OIrdkwZtFfIHcxZ6kEQwU0jMKZwltPJQwVyU8dVaUHOk2yoM5MBpHYSYZg1iqwlcpQISgNtwgW0QGVNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDfZ5RFZO/sS5qzFBI7jHnREd5K1CEHQ1U7wwen56Uz/wIhAL4tcCaLYb/G9uCTRb7oNdvjVPmpchJKWJe3PdDZ/gMz"}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}]},"1.0.1":{"name":"surface-nets","version":"1.0.1","description":"General purpose level set extraction","main":"surfacenets.js","directories":{"example":"example","test":"test"},"dependencies":{"ndarray-extract-contour":"^1.0.0","triangulate-hypercube":"^0.0.0","zero-crossings":"^1.0.0"},"devDependencies":{"gl-matrix":"~2.1.0","ndarray":"~1.0.11","ndarray-fill":"~0.1.0","svg-3d-simplicial-complex":"~0.1.1","tape":"~2.12.3","isosurface":"^1.0.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/surface-nets.git"},"keywords":["surface","net","marching","cubes","polygonize","isosurface","ndarray","extract","boundary","volume","marching","squares","surface nets","dual contouring","dual","contour","isocontour"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/surface-nets/issues"},"homepage":"https://github.com/mikolalysenko/surface-nets","_id":"surface-nets@1.0.1","dist":{"shasum":"ef4709bbcc74d7cbd143e928d8a8e4ae82c728b9","tarball":"https://registry.npmjs.org/surface-nets/-/surface-nets-1.0.1.tgz","integrity":"sha512-3td9VSIOBiwFvrhiGV7j8FnAAG3c22eYImBG3Ce4Er5WIqxfH/dxl/uTAkmrahSmOiBbPgQwBrrePORmmGU7qA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJeYNVDVstk67l1oLPqQppsVmZqtUmVAvjhcfUj2RVEgIhAO0ZehZXX343YJIRpKHM+TmNhQ7K9eKDA8jIDqd01OnL"}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}]},"1.0.2":{"name":"surface-nets","version":"1.0.2","description":"General purpose level set extraction","main":"surfacenets.js","directories":{"example":"example","test":"test"},"dependencies":{"ndarray-extract-contour":"^1.0.0","triangulate-hypercube":"^1.0.0","zero-crossings":"^1.0.0"},"devDependencies":{"gl-matrix":"~2.1.0","ndarray":"~1.0.11","ndarray-fill":"~0.1.0","svg-3d-simplicial-complex":"~0.1.1","tape":"~2.12.3","isosurface":"^1.0.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/mikolalysenko/surface-nets.git"},"keywords":["surface","net","marching","cubes","polygonize","isosurface","ndarray","extract","boundary","volume","marching","squares","surface nets","dual contouring","dual","contour","isocontour"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/surface-nets/issues"},"homepage":"https://github.com/mikolalysenko/surface-nets","_id":"surface-nets@1.0.2","dist":{"shasum":"e433c8cbba94a7274c6f4c99552b461bf1fc7a4b","tarball":"https://registry.npmjs.org/surface-nets/-/surface-nets-1.0.2.tgz","integrity":"sha512-Se+BaCb5yc8AV1IfT6TwTWEe/KuzzjzcMQQCbcIahzk9xRO5bIxxGM2MmKxE9nmq8+RD8DLBLXu0BjXoRs21iw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFIQIHXmqvA5XtHtXRHsUkyRr2ZRs16GCyuQwb4bcZWgAiEAtYn+cVZ9V/TtBEvtLjniwskp8A8jwmdxWs9+Mjxq48M="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}]}},"readme":"surface-nets\n============\nExtract a simplicial level set from an [ndarray](https://github.com/mikolalysenko/ndarray) in any dimension using naive surface nets.  This module works in both node.js and with [browserify](http://browserify.org/)!\n\n# Example\n\nHere is a 2D example:\n\n```javascript\n//Load modules\nvar surfaceNets = require(\"surface-nets\")\nvar ndarray = require(\"ndarray\")\nvar fill = require(\"ndarray-fill\")\n\n//Initialize array to a circle\nvar array = ndarray(new Float32Array(32*32), [32,32])\nfill(array, function(i,j) {\n  return Math.pow(i-16,2) + Math.pow(j-16,2)\n})\n\n//Extract 2D contour (this is all there is to it!)\nvar complex = surfaceNets(array, 15*15)\n\n//Write SVG image to stdout\nvar svgFile = ['<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"320\" height=\"320\">']\ncomplex.cells.forEach(function(cell) {\n  var p0 = complex.positions[cell[0]]\n  var p1 = complex.positions[cell[1]]\n  svgFile.push('<line x1=\"', 10*p0[0], '\" y1=\"', 10*p0[1], '\" x2=\"', 10*p1[0], '\" y2=\"', 10*p1[1], '\" stroke=\"red\" stroke-width=\"1\" />')\n})\ncomplex.positions.forEach(function(p) {\n  svgFile.push('<circle cx=\"', 10*p[0], '\" cy=\"', 10*p[1], '\" r=\"1\" stroke=\"black\" stroke-width=\"0.1\" fill=\"black\" />')\n})\nsvgFile.push('</svg>')\nconsole.log(svgFile.join(\"\"))\n```\n\nAnd here is the output SVG:\n\n<img src=\"https://mikolalysenko.github.io/surface-nets/example/2d.svg\">\n\nThis module also works in 3D.  Here is an example:\n\n```javascript\n//Load modules\nvar surfaceNets = require(\"surface-nets\")\nvar ndarray = require(\"ndarray\")\nvar fill = require(\"ndarray-fill\")\nvar mat4 = require(\"gl-matrix\").mat4\n\n//Initialize array\nvar array = ndarray(new Float32Array(32*32*32), [32,32,32])\nfill(array, function(i,j,k) {\n  return Math.pow(i-16,2) + Math.pow(j-16,2) + Math.pow(k-16,2)\n})\n\n//Generate surface! (again, just one line)\nvar complex = surfaceNets(array, 100)\n\n//Render the implicit surface to stdout\nconsole.log('<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"512\" height=\"512\" version=\"1.1\">')\nconsole.log(require(\"svg-3d-simplicial-complex\")(\n  complex.cells, \n  complex.positions, {\n    view: mat4.lookAt(\n      mat4.create(), \n      [32, 32, 32], \n      [16, 16, 16], \n      [0,1,0]),\n    projection: mat4.perspective(mat4.create(),\n      Math.PI/4.0,\n      1.0,\n      0.1,\n      1000.0),\n    viewport: [[0,0], [512,512]]\n  }))\nconsole.log(\"</svg>\")\n```\n\nAnd here is the result:\n\n<img src=\"https://mikolalysenko.github.io/surface-nets/example/3d.svg\">\n\nAnd while it is a bit trivial, you can also generate surfaces in 1D:\n\n```javascript\nvar surfaceNets = require(\"surface-nets\")\nvar ndarray = require(\"ndarray\")\n\nconsole.log(surfaceNets(ndarray([1, -1, 0, 5, -10])))\n```\n\nOutput:\n\n```javascript\n{ positions: [ [ 0.5 ], [ 2 ], [ 3.3333333333333335 ] ],\n  cells: [ [ 0 ], [ 1 ], [ 2 ] ] }\n```\n\nThe code *should* work in 4D and higher dimensions, but this is not well tested and it is harder to visualize.  (Also, why would you want to bother!?!)\n\n# Install\n\n```\nnpm install surface-nets\n```\n\n# API\n\n#### `require(\"surface-nets\")(array[,level])`\nExtracts the level set at `level` from `array` as a simplicial complex.\n\n* `array` is an [ndarray](https://github.com/mikolalysenko/ndarray)\n* `level` is an optional number which determines the level at which the levelset is evaluated (default `0`)\n\n**Returns** An object with a pair of properties representing a simplicial complex:\n\n* `positions` is an array encoding the positions of the vertices.  The coordinates of the positions are with respect to the indices in `array`.\n* `cells` is an array encoding the cells of the simplicial complex as tuples of indices into the `position` array.\n\n# Credits\n(c) 2014 Mikola Lysenko. MIT License","maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"time":{"modified":"2022-06-27T02:26:25.446Z","created":"2014-04-10T05:21:24.916Z","1.0.0":"2014-04-10T05:21:24.916Z","1.0.1":"2014-05-05T18:45:57.510Z","1.0.2":"2014-05-07T21:09:58.636Z"},"homepage":"https://github.com/mikolalysenko/surface-nets","keywords":["surface","net","marching","cubes","polygonize","isosurface","ndarray","extract","boundary","volume","marching","squares","surface nets","dual contouring","dual","contour","isocontour"],"repository":{"type":"git","url":"git://github.com/mikolalysenko/surface-nets.git"},"author":{"name":"Mikola Lysenko"},"bugs":{"url":"https://github.com/mikolalysenko/surface-nets/issues"},"license":"MIT","readmeFilename":"README.md","users":{"tmpvar":true,"ptx":true,"hughsk":true}}