Comparing version 0.9.6 to 0.9.7
130
dist/fold.js
@@ -254,3 +254,3 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
filter.unassignedEdges = function(fold) { | ||
return assignment.edgesAssigned(fold, 'F'); | ||
return assignment.edgesAssigned(fold, 'U'); | ||
}; | ||
@@ -293,3 +293,3 @@ | ||
} | ||
ref = filter.keysStartingWith(fold, field + '_'); | ||
ref = filter.keysStartingWith(fold, field + "_"); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
@@ -307,3 +307,3 @@ key = ref[l]; | ||
} | ||
ref1 = filter.keysEndingWith(fold, '_' + field); | ||
ref1 = filter.keysEndingWith(fold, "_" + field); | ||
for (m = 0, len2 = ref1.length; m < len2; m++) { | ||
@@ -352,2 +352,42 @@ key = ref1[m]; | ||
filter.numType = function(fold, type) { | ||
/* | ||
Count the maximum number of objects of a given type, by looking at all | ||
fields with key of the form `type_...`. | ||
*/ | ||
var counts, key, value; | ||
counts = (function() { | ||
var k, len, ref, results; | ||
ref = filter.keysStartingWith(fold, type); | ||
results = []; | ||
for (k = 0, len = ref.length; k < len; k++) { | ||
key = ref[k]; | ||
value = fold[key]; | ||
if (value.length == null) { | ||
continue; | ||
} | ||
results.push(value.length); | ||
} | ||
return results; | ||
})(); | ||
if (counts.length === 0) { | ||
return null; | ||
} else { | ||
return Math.max.apply(Math, counts); | ||
} | ||
}; | ||
filter.numVertices = function(fold) { | ||
return filter.numType(fold, 'vertices'); | ||
}; | ||
filter.numEdges = function(fold) { | ||
return filter.numType(fold, 'edges'); | ||
}; | ||
filter.numFaces = function(fold) { | ||
return filter.numType(fold, 'faces'); | ||
}; | ||
filter.removeDuplicateEdges_vertices = function(fold) { | ||
@@ -500,3 +540,22 @@ var edge, id, key, old2new, seen, v, w; | ||
*/ | ||
var cross, crossI, e, e1, e2, i, i1, i2, k, l, len, len1, len2, len3, m, n, p, ref, ref1, ref2, ref3, s, s1, s2, u, v, vertices; | ||
var addEdge, cross, crossI, e, e1, e2, i, i1, i2, k, l, len, len1, len2, len3, m, n, p, ref, ref1, ref2, ref3, s, s1, s2, u, v, vertices; | ||
addEdge = function(v1, v2, oldEdgeIndex) { | ||
var k, key, len, ref, results; | ||
ref = filter.keysStartingWith(fold, 'edges_'); | ||
results = []; | ||
for (k = 0, len = ref.length; k < len; k++) { | ||
key = ref[k]; | ||
switch (key.slice(6)) { | ||
case 'vertices': | ||
results.push(fold.edges_vertices.push([v1, v2])); | ||
break; | ||
case 'edges': | ||
case 'faces': | ||
break; | ||
default: | ||
results.push(fold[key].push(fold[key][oldEdgeIndex])); | ||
} | ||
} | ||
return results; | ||
}; | ||
ref = fold.vertices_coords; | ||
@@ -521,3 +580,3 @@ for (v = k = 0, len = ref.length; k < len; v = ++k) { | ||
if (geom.pointStrictlyInSegment(p, s)) { | ||
fold.edges_vertices.push([v, e[1]]); | ||
addEdge(v, e[1], i); | ||
e[1] = v; | ||
@@ -559,7 +618,7 @@ } | ||
if (indexOf.call(e1, crossI) < 0) { | ||
fold.edges_vertices.push([crossI, e1[1]]); | ||
addEdge(crossI, e1[1], i1); | ||
e1[1] = crossI; | ||
} | ||
if (indexOf.call(e2, crossI) < 0) { | ||
fold.edges_vertices.push([crossI, e2[1]]); | ||
addEdge(crossI, e2[1], i2); | ||
e2[1] = crossI; | ||
@@ -580,7 +639,24 @@ } | ||
*/ | ||
var edge, k, len, ref, v, vertices_vertices, w; | ||
vertices_vertices = []; | ||
ref = fold.edges_vertices; | ||
for (k = 0, len = ref.length; k < len; k++) { | ||
edge = ref[k]; | ||
var edge, k, len, numVertices, ref, ref1, v, vertices_vertices, w; | ||
numVertices = (ref = filter.numVertices(fold)) != null ? ref : Math.max.apply(Math, (function() { | ||
var k, len, ref1, results; | ||
ref1 = fold.edges_vertices; | ||
results = []; | ||
for (k = 0, len = ref1.length; k < len; k++) { | ||
edge = ref1[k]; | ||
results.push(Math.max(edge[0], edge[1])); | ||
} | ||
return results; | ||
})()); | ||
vertices_vertices = (function() { | ||
var k, ref1, results; | ||
results = []; | ||
for (v = k = 0, ref1 = numVertices; 0 <= ref1 ? k < ref1 : k > ref1; v = 0 <= ref1 ? ++k : --k) { | ||
results.push([]); | ||
} | ||
return results; | ||
})(); | ||
ref1 = fold.edges_vertices; | ||
for (k = 0, len = ref1.length; k < len; k++) { | ||
edge = ref1[k]; | ||
v = edge[0], w = edge[1]; | ||
@@ -882,3 +958,3 @@ while (v >= vertices_vertices.length) { | ||
return results; | ||
})()).reduce(geom.plus)); | ||
})()).reduce(geom.plus), eps); | ||
}; | ||
@@ -1481,5 +1557,9 @@ | ||
viewer.processInput = function(text, view) { | ||
viewer.processInput = function(input, view) { | ||
var k; | ||
view.fold = JSON.parse(text); | ||
if (typeof input === 'string') { | ||
view.fold = JSON.parse(input); | ||
} else { | ||
view.fold = input; | ||
} | ||
view.model = viewer.makeModel(view.fold); | ||
@@ -1536,3 +1616,3 @@ viewer.addRotation(view); | ||
attrViewer: true, | ||
examples: true, | ||
examples: false, | ||
"import": true, | ||
@@ -1544,3 +1624,3 @@ "export": true, | ||
viewer.addViewer = function(div, opts) { | ||
var buttonDiv, i, inputDiv, k, l, len, ref, ref1, select, t, toggleDiv, v, val, view; | ||
var buttonDiv, i, inputDiv, k, l, len, ref, ref1, ref2, select, t, title, toggleDiv, url, v, val, view; | ||
if (opts == null) { | ||
@@ -1598,11 +1678,9 @@ opts = {}; | ||
select = viewer.appendHTML(inputDiv, 'select'); | ||
viewer.appendHTML(select, 'option', { | ||
value: '../examples/simple.fold' | ||
}).innerHTML = 'Default'; | ||
viewer.appendHTML(select, 'option', { | ||
value: '../examples/box.fold' | ||
}).innerHTML = 'Flexicube Unit'; | ||
viewer.appendHTML(select, 'option', { | ||
value: '../examples/squaretwist.fold' | ||
}).innerHTML = 'Square Twist'; | ||
ref2 = view.opts.examples; | ||
for (title in ref2) { | ||
url = ref2[title]; | ||
viewer.appendHTML(select, 'option', { | ||
value: url | ||
}).innerHTML = title; | ||
} | ||
viewer.importURL(select.value, view); | ||
@@ -1609,0 +1687,0 @@ } |
@@ -232,12 +232,12 @@ # [FOLD](https://github.com/edemaine/fold/) Specification (version 1 DRAFT) | ||
same normal point away from the adjacent face. | ||
* `edges_foldAngles`: For each edge, the fold angle (deviation from flatness) | ||
* `edges_foldAngle`: For each edge, the fold angle (deviation from flatness) | ||
along each edge of the pattern. The fold angle is a number in degrees | ||
lying in the range [−180, 180]. The fold angle is positive for | ||
valley folds, negative for mountain folds, and zero for flat, unassigned, | ||
and border folds. Accordingly, the sign of `edge_foldAngles` should match | ||
and border folds. Accordingly, the sign of `edge_foldAngle` should match | ||
`edges_assignment` if both are specified. | ||
* `edges_lengths`: For each edge, the length of the edge (a number). | ||
* `edges_length`: For each edge, the length of the edge (a number). | ||
This is mainly useful for defining the intrinsic geometry of | ||
abstract complexes where `vertices_coords` are unspecified; | ||
otherwise, `edges_lengths` can be computed from `vertices_coords`. | ||
otherwise, `edges_length` can be computed from `vertices_coords`. | ||
@@ -244,0 +244,0 @@ ## Face information: `faces_...` |
{ | ||
"name": "fold", | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"description": "FOLD file format for origami models, crease patterns, etc.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
4247287
4479