Comparing version 0.9.10 to 0.9.11
@@ -116,2 +116,58 @@ | ||
convert.vertices_vertices_to_vertices_edges = function(fold) { | ||
var edge, edgeMap, i, j, len, ref, ref1, v1, v2, vertex, vertices; | ||
edgeMap = {}; | ||
ref = fold.edges_vertices; | ||
for (edge = j = 0, len = ref.length; j < len; edge = ++j) { | ||
ref1 = ref[edge], v1 = ref1[0], v2 = ref1[1]; | ||
edgeMap[v1 + "," + v2] = edge; | ||
edgeMap[v2 + "," + v1] = edge; | ||
} | ||
return fold.vertices_edges = (function() { | ||
var k, len1, ref2, results; | ||
ref2 = fold.vertices_vertices; | ||
results = []; | ||
for (vertex = k = 0, len1 = ref2.length; k < len1; vertex = ++k) { | ||
vertices = ref2[vertex]; | ||
results.push((function() { | ||
var l, ref3, results1; | ||
results1 = []; | ||
for (i = l = 0, ref3 = vertices.length; 0 <= ref3 ? l < ref3 : l > ref3; i = 0 <= ref3 ? ++l : --l) { | ||
results1.push(edgeMap[vertex + "," + vertices[i]]); | ||
} | ||
return results1; | ||
})()); | ||
} | ||
return results; | ||
})(); | ||
}; | ||
convert.edges_vertices_faces_vertices_to_faces_edges = function(fold) { | ||
var edge, edgeMap, face, i, j, len, ref, ref1, v1, v2, vertices; | ||
edgeMap = {}; | ||
ref = fold.edges_vertices; | ||
for (edge = j = 0, len = ref.length; j < len; edge = ++j) { | ||
ref1 = ref[edge], v1 = ref1[0], v2 = ref1[1]; | ||
edgeMap[v1 + "," + v2] = edge; | ||
edgeMap[v2 + "," + v1] = edge; | ||
} | ||
return fold.faces_edges = (function() { | ||
var k, len1, ref2, results; | ||
ref2 = fold.faces_vertices; | ||
results = []; | ||
for (face = k = 0, len1 = ref2.length; k < len1; face = ++k) { | ||
vertices = ref2[face]; | ||
results.push((function() { | ||
var l, ref3, results1; | ||
results1 = []; | ||
for (i = l = 0, ref3 = vertices.length; 0 <= ref3 ? l < ref3 : l > ref3; i = 0 <= ref3 ? ++l : --l) { | ||
results1.push(edgeMap[vertices[i] + "," + vertices[(i + 1) % vertices.length]]); | ||
} | ||
return results1; | ||
})()); | ||
} | ||
return results; | ||
})(); | ||
}; | ||
convert.faces_vertices_to_edges = function(mesh) { | ||
@@ -118,0 +174,0 @@ var edge, edgeMap, face, i, key, ref, v1, v2, vertices; |
@@ -22,19 +22,19 @@ var RepeatedPointsDS, filter, geom, | ||
filter.mountainEdges = function(fold) { | ||
return assignment.edgesAssigned(fold, 'M'); | ||
return filter.edgesAssigned(fold, 'M'); | ||
}; | ||
filter.valleyEdges = function(fold) { | ||
return assignment.edgesAssigned(fold, 'V'); | ||
return filter.edgesAssigned(fold, 'V'); | ||
}; | ||
filter.flatEdges = function(fold) { | ||
return assignment.edgesAssigned(fold, 'F'); | ||
return filter.edgesAssigned(fold, 'F'); | ||
}; | ||
filter.boundaryEdges = function(fold) { | ||
return assignment.edgesAssigned(fold, 'B'); | ||
return filter.edgesAssigned(fold, 'B'); | ||
}; | ||
filter.unassignedEdges = function(fold) { | ||
return assignment.edgesAssigned(fold, 'F'); | ||
return filter.edgesAssigned(fold, 'U'); | ||
}; | ||
@@ -77,3 +77,3 @@ | ||
} | ||
ref = filter.keysStartingWith(fold, field + '_'); | ||
ref = filter.keysStartingWith(fold, field + "_"); | ||
for (l = 0, len1 = ref.length; l < len1; l++) { | ||
@@ -91,3 +91,3 @@ key = ref[l]; | ||
} | ||
ref1 = filter.keysEndingWith(fold, '_' + field); | ||
ref1 = filter.keysEndingWith(fold, "_" + field); | ||
for (m = 0, len2 = ref1.length; m < len2; m++) { | ||
@@ -136,2 +136,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) { | ||
@@ -284,3 +324,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; | ||
@@ -305,3 +364,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; | ||
@@ -343,7 +402,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; | ||
@@ -364,7 +423,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]; | ||
@@ -371,0 +447,0 @@ while (v >= vertices_vertices.length) { |
@@ -282,3 +282,3 @@ | ||
return results; | ||
})()).reduce(geom.plus)); | ||
})()).reduce(geom.plus), eps); | ||
}; | ||
@@ -285,0 +285,0 @@ |
@@ -63,5 +63,9 @@ var DEFAULTS, STYLES, SVGNS, geom, viewer; | ||
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); | ||
@@ -118,3 +122,3 @@ viewer.addRotation(view); | ||
attrViewer: true, | ||
examples: true, | ||
examples: false, | ||
"import": true, | ||
@@ -126,3 +130,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) { | ||
@@ -180,11 +184,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); | ||
@@ -335,3 +337,3 @@ } | ||
viewer.makeModel = function(fold) { | ||
var a, as, b, cs, edge, f, f1, f2, i, i1, j, j1, k1, l, len, len1, len2, len3, len4, len5, m, normRel, o, r, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, v, vs, w, z; | ||
var a, as, b, cs, edge, f, f1, f2, i, i1, j, j1, k1, l, len, len1, len2, len3, len4, len5, m, normRel, o, r, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, v, vs, w, z; | ||
m = { | ||
@@ -388,3 +390,3 @@ vs: null, | ||
ref2 = v[0] > v[1] ? [v[1], v[0]] : [v[0], v[1]], a = ref2[0], b = ref2[1]; | ||
as = fold.edges_assignment[i] != null ? fold.edges_assignment[i] : 'U'; | ||
as = ((ref3 = fold.edges_assignment) != null ? ref3[i] : void 0) != null ? fold.edges_assignment[i] : 'U'; | ||
m.es["e" + a + "e" + b] = { | ||
@@ -397,10 +399,10 @@ v1: m.vs[a], | ||
} else { | ||
ref3 = m.fs; | ||
for (i = z = 0, len2 = ref3.length; z < len2; i = ++z) { | ||
f = ref3[i]; | ||
ref4 = f.vs; | ||
for (j = i1 = 0, len3 = ref4.length; i1 < len3; j = ++i1) { | ||
v = ref4[j]; | ||
ref4 = m.fs; | ||
for (i = z = 0, len2 = ref4.length; z < len2; i = ++z) { | ||
f = ref4[i]; | ||
ref5 = f.vs; | ||
for (j = i1 = 0, len3 = ref5.length; i1 < len3; j = ++i1) { | ||
v = ref5[j]; | ||
w = f.vs[geom.next(j, f.vs.length)]; | ||
ref5 = v.i > w.i ? [w, v] : [v, w], a = ref5[0], b = ref5[1]; | ||
ref6 = v.i > w.i ? [w, v] : [v, w], a = ref6[0], b = ref6[1]; | ||
m.es["e" + a.i + "e" + b.i] = { | ||
@@ -414,11 +416,11 @@ v1: a, | ||
} | ||
ref6 = m.fs; | ||
for (i = j1 = 0, len4 = ref6.length; j1 < len4; i = ++j1) { | ||
f = ref6[i]; | ||
ref7 = m.fs; | ||
for (i = j1 = 0, len4 = ref7.length; j1 < len4; i = ++j1) { | ||
f = ref7[i]; | ||
m.fs[i].n = geom.polygonNormal((function() { | ||
var k1, len5, ref7, results; | ||
ref7 = f.vs; | ||
var k1, len5, ref8, results; | ||
ref8 = f.vs; | ||
results = []; | ||
for (k1 = 0, len5 = ref7.length; k1 < len5; k1++) { | ||
v = ref7[k1]; | ||
for (k1 = 0, len5 = ref8.length; k1 < len5; k1++) { | ||
v = ref8[k1]; | ||
results.push(v.cs); | ||
@@ -429,7 +431,7 @@ } | ||
m.fs[i].c = geom.centroid((function() { | ||
var k1, len5, ref7, results; | ||
ref7 = f.vs; | ||
var k1, len5, ref8, results; | ||
ref8 = f.vs; | ||
results = []; | ||
for (k1 = 0, len5 = ref7.length; k1 < len5; k1++) { | ||
v = ref7[k1]; | ||
for (k1 = 0, len5 = ref8.length; k1 < len5; k1++) { | ||
v = ref8[k1]; | ||
results.push(v.cs); | ||
@@ -441,9 +443,9 @@ } | ||
m.fs[i].es = (function() { | ||
var k1, len5, ref7, ref8, results; | ||
ref7 = f.vs; | ||
var k1, len5, ref8, ref9, results; | ||
ref8 = f.vs; | ||
results = []; | ||
for (j = k1 = 0, len5 = ref7.length; k1 < len5; j = ++k1) { | ||
v = ref7[j]; | ||
for (j = k1 = 0, len5 = ref8.length; k1 < len5; j = ++k1) { | ||
v = ref8[j]; | ||
w = f.vs[geom.next(j, f.vs.length)]; | ||
ref8 = v.i > w.i ? [w, v] : [v, w], a = ref8[0], b = ref8[1]; | ||
ref9 = v.i > w.i ? [w, v] : [v, w], a = ref9[0], b = ref9[1]; | ||
edge = m.es["e" + a.i + "e" + b.i]; | ||
@@ -464,5 +466,5 @@ if (edge == null) { | ||
if (fold.faceOrders != null) { | ||
ref7 = fold.faceOrders; | ||
for (k1 = 0, len5 = ref7.length; k1 < len5; k1++) { | ||
ref8 = ref7[k1], f1 = ref8[0], f2 = ref8[1], o = ref8[2]; | ||
ref8 = fold.faceOrders; | ||
for (k1 = 0, len5 = ref8.length; k1 < len5; k1++) { | ||
ref9 = ref8[k1], f1 = ref9[0], f2 = ref9[1], o = ref9[2]; | ||
if (o !== 0) { | ||
@@ -469,0 +471,0 @@ if (geom.parallel(m.fs[f1].n, m.fs[f2].n)) { |
{ | ||
"name": "fold", | ||
"version": "0.9.10", | ||
"version": "0.9.11", | ||
"description": "FOLD file format for origami models, crease patterns, etc.", | ||
@@ -11,3 +11,4 @@ "main": "lib/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepare": "coffee --no-header --bare -o lib -c src", | ||
"prepare": "npm run coffee && npm run dist", | ||
"coffee": "coffee --no-header --bare -o lib -c src", | ||
"dist": "browserify -t coffeeify --extension=.coffee -r ./src/index.coffee:fold -o dist/fold.js" | ||
@@ -14,0 +15,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4253533
4660