Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
d5f15039
Commit
d5f15039
authored
May 06, 2017
by
amandaghassaei
Browse files
save fold working
parent
1156820b
Changes
6
Hide whitespace changes
Inline
Side-by-side
css/main.css
View file @
d5f15039
...
...
@@ -320,6 +320,7 @@ svg{
.bigLabel
{
font-size
:
18px
;
margin-top
:
20px
;
}
.checkbox.bigLabel
.icons
,
.radio
.icons
{
top
:
2px
;
...
...
index.html
View file @
d5f15039
...
...
@@ -602,7 +602,7 @@
Filename:
<input
id=
"stlFilename"
value=
""
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
>
.stl
<br/><br/>
Scale:
<input
value=
""
placeholder=
""
class=
"exportScale form-control"
type=
"text"
><br/><br/>
Dimensions:
<b><span
class=
"exportDimensions"
></span></b><br/>
<span
class=
"smallTxt"
>
(the STL file format is unitless, but typically assumed to be either in inches or mm)
</span><br/>
<br/>
<span
class=
"smallTxt"
>
(the STL file format is unitless, but typically assumed to be either in inches or mm)
</span><br/>
<label
class=
"bigLabel checkbox"
for=
"doublesidedSTL"
>
<input
id=
"doublesidedSTL"
data-toggle=
"checkbox"
class=
"custom-checkbox layersSelector"
type=
"checkbox"
><span
class=
"icons"
><span
class=
"icon-unchecked"
></span><span
class=
"icon-checked"
></span></span>
Double Sided
...
...
@@ -622,25 +622,34 @@
<span
aria-hidden=
"true"
>
×
</span>
</button>
<b>
Export FOLD
</b><br/><br/>
Filename:
<input
id=
"foldFilename"
value=
""
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
>
.
stl
<br/><br/>
Filename:
<input
id=
"foldFilename"
value=
""
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
>
.
fold
<br/><br/>
Author:
<input
id=
"foldAuthor"
value=
"Amanda Ghassaei"
placeholder=
""
class=
"bigInput text form-control"
type=
"text"
><br/><br/>
Scale:
<input
value=
""
placeholder=
""
class=
"exportScale form-control"
type=
"text"
>
Units:
<div
class=
"btn-group"
>
<button
data-toggle=
"dropdown"
class=
"btn btn-default dropdown-toggle"
type=
"button"
><span
id
=
"unitsDisplay"
></span>
<span
class=
"caret"
></span></button>
<button
data-toggle=
"dropdown"
class=
"btn btn-default dropdown-toggle"
type=
"button"
><span
class
=
"unitsDisplay"
></span>
<span
class=
"caret"
></span></button>
<ul
id=
"unitsDropdown"
role=
"menu"
class=
"dropdown-menu"
>
<li><a
data-id=
"unit"
href=
"#"
>
unitless
</a></li>
<li><a
data-id=
"in"
href=
"#"
>
in
</a></li>
<li><a
data-id=
"pt"
href=
"#"
>
pt
</a></li>
<li><a
data-id=
"m"
href=
"#"
>
m
</a></li>
<li><a
data-id=
"cm"
href=
"#"
>
cm
</a></li>
<li><a
data-id=
"mm"
href=
"#"
>
mm
</a></li>
<li><a
data-id=
"um"
href=
"#"
>
um
</a></li>
<li><a
data-id=
"nm"
href=
"#"
>
nm
</a></li>
<li><a
class=
"units"
data-id=
"unit"
href=
"#"
>
unitless
</a></li>
<li><a
class=
"units"
data-id=
"in"
href=
"#"
>
in
</a></li>
<li><a
class=
"units"
data-id=
"pt"
href=
"#"
>
pt
</a></li>
<li><a
class=
"units"
data-id=
"m"
href=
"#"
>
m
</a></li>
<li><a
class=
"units"
data-id=
"cm"
href=
"#"
>
cm
</a></li>
<li><a
class=
"units"
data-id=
"mm"
href=
"#"
>
mm
</a></li>
<li><a
class=
"units"
data-id=
"um"
href=
"#"
>
um
</a></li>
<li><a
class=
"units"
data-id=
"nm"
href=
"#"
>
nm
</a></li>
</ul>
</div>
<br/><br/>
Dimensions:
<b><span
class=
"exportDimensions"
></span></b>
Dimensions:
<b><span
class=
"exportDimensions"
></span>
<span
class=
"unitsDisplay"
></span></b><br/>
<label
class=
"bigLabel checkbox"
for=
"triangulateFOLDexport"
>
<input
id=
"triangulateFOLDexport"
data-toggle=
"checkbox"
class=
"custom-checkbox layersSelector"
type=
"checkbox"
><span
class=
"icons"
><span
class=
"icon-unchecked"
></span><span
class=
"icon-checked"
></span></span>
Save with triangulated faces
</label>
<label
class=
"bigLabel checkbox"
for=
"exportFoldAngle"
>
<input
id=
"exportFoldAngle"
data-toggle=
"checkbox"
disabled
class=
"custom-checkbox layersSelector"
type=
"checkbox"
><span
class=
"icons"
><span
class=
"icon-unchecked"
></span><span
class=
"icon-checked"
></span></span>
Save with vertices_foldAngles (coming soon)
</label>
<span
class=
"smallTxt"
>
For more information about the FOLD file format, see the
<a
target=
"_blank"
href=
"https://github.com/edemaine/fold"
>
offical docs
</a></span>
.
</div>
<div
class=
"modal-footer"
>
<button
id=
"doFOLDsave"
type=
"button"
class=
"actionButton btn btn-success"
data-dismiss=
"modal"
>
Save
</button>
...
...
js/controls.js
View file @
d5f15039
...
...
@@ -26,7 +26,7 @@ function initControls(globals){
$
(
"
#foldFilename
"
).
val
(
globals
.
filename
+
"
:
"
+
parseInt
(
globals
.
creasePercent
*
100
)
+
"
PercentFolded
"
);
var
units
=
globals
.
foldUnits
;
if
(
units
==
"
unit
"
)
units
=
"
unitless
"
;
$
(
"
#
unitsDisplay
"
).
html
(
units
);
$
(
"
.
unitsDisplay
"
).
html
(
units
);
$
(
'
#exportFOLDModal
'
).
modal
(
'
show
'
);
});
setLink
(
"
#exportSTL
"
,
function
(){
...
...
@@ -46,6 +46,15 @@ function initControls(globals){
setCheckbox
(
"
#doublesidedSTL
"
,
globals
.
doublesidedSTL
,
function
(
val
){
globals
.
doublesidedSTL
=
val
;
});
setLink
(
"
.units
"
,
function
(
e
){
var
units
=
$
(
e
.
target
).
data
(
"
id
"
);
globals
.
foldUnits
=
units
;
if
(
units
==
"
unit
"
)
units
=
"
unitless
"
;
$
(
"
.unitsDisplay
"
).
html
(
units
);
});
setCheckbox
(
"
#triangulateFOLDexport
"
,
globals
.
triangulateFOLDexport
,
function
(
val
){
globals
.
triangulateFOLDexport
=
val
;
});
setLink
(
"
#doSTLsave
"
,
function
(){
saveSTL
();
...
...
js/globals.js
View file @
d5f15039
...
...
@@ -59,6 +59,8 @@ function initGlobals(){
//save fold settings
foldUnits
:
"
unit
"
,
triangulateFOLDexport
:
false
,
exportFoldAngle
:
false
,
userInteractionEnabled
:
false
...
...
js/pattern.js
View file @
d5f15039
...
...
@@ -19,6 +19,7 @@ function initPattern(globals){
var
outlines
=
[];
var
cuts
=
[];
var
triangulations
=
[];
var
polygons
=
[];
var
SVGloader
=
new
THREE
.
SVGLoader
();
...
...
@@ -167,7 +168,8 @@ function initPattern(globals){
mergeVertices
();
var
allEdges
=
outlines
.
concat
(
mountains
).
concat
(
valleys
).
concat
(
cuts
).
concat
(
triangulationsRaw
);
var
faces
=
triangulatePolys
(
findPolygons
(
allEdges
),
allEdges
);
polygons
=
findPolygons
(
allEdges
);
var
faces
=
triangulatePolys
(
polygons
,
allEdges
);
var
allCreaseParams
=
getFacesAndVerticesForEdges
(
faces
,
allEdges
);
globals
.
model
.
buildModel
(
faces
,
vertices
,
allEdges
,
allCreaseParams
);
...
...
@@ -656,10 +658,26 @@ function initPattern(globals){
document
.
body
.
removeChild
(
downloadLink
);
}
function
getAllEdges
(){
return
{
mountains
:
mountains
,
valleys
:
valleys
,
outlines
:
outlines
,
cuts
:
cuts
,
triangulations
:
triangulations
}
}
function
getPolygons
(){
return
polygons
[
0
];
}
return
{
loadSVG
:
loadSVG
,
saveSVG
:
saveSVG
,
getFacesAndVerticesForEdges
:
getFacesAndVerticesForEdges
,
triangulatePolys
:
triangulatePolys
triangulatePolys
:
triangulatePolys
,
getAllEdges
:
getAllEdges
,
getPolygons
:
getPolygons
}
}
\ No newline at end of file
js/saveFOLD.js
View file @
d5f15039
...
...
@@ -27,14 +27,65 @@ function saveFOLD(){
frame_title
:
filename
,
frame_classes
:
[
"
singleModel
"
],
frame_attributes
:
[
"
3D
"
],
frame_description
:
""
,
frame_unit
:
globals
.
foldUnits
,
vertices_coords
:
[],
edges_vertices
:
[],
edges_
foldAngles
:
[],
edges_
assignment
:
[],
faces_vertices
:
[]
};
for
(
var
i
=
0
;
i
<
geo
.
vertices
.
length
;
i
++
){
var
vertex
=
geo
.
vertices
[
i
];
json
.
vertices_coords
.
push
([
vertex
.
x
,
vertex
.
y
,
vertex
.
z
]);
}
var
edges
=
globals
.
pattern
.
getAllEdges
();
for
(
var
i
=
0
;
i
<
edges
.
mountains
.
length
;
i
++
){
var
nodes
=
edges
.
mountains
[
i
];
json
.
edges_vertices
.
push
([
nodes
[
0
],
nodes
[
1
]]);
json
.
edges_assignment
.
push
(
"
M
"
);
}
for
(
var
i
=
0
;
i
<
edges
.
valleys
.
length
;
i
++
){
var
nodes
=
edges
.
valleys
[
i
];
json
.
edges_vertices
.
push
([
nodes
[
0
],
nodes
[
1
]]);
json
.
edges_assignment
.
push
(
"
V
"
);
}
for
(
var
i
=
0
;
i
<
edges
.
cuts
.
length
;
i
++
){
var
nodes
=
edges
.
cuts
[
i
];
json
.
edges_vertices
.
push
([
nodes
[
0
],
nodes
[
1
]]);
json
.
edges_assignment
.
push
(
"
B
"
);
}
for
(
var
i
=
0
;
i
<
edges
.
outlines
.
length
;
i
++
){
var
nodes
=
edges
.
outlines
[
i
];
json
.
edges_vertices
.
push
([
nodes
[
0
],
nodes
[
1
]]);
json
.
edges_assignment
.
push
(
"
B
"
);
}
if
(
globals
.
triangulateFOLDexport
){
for
(
var
i
=
0
;
i
<
edges
.
triangulations
.
length
;
i
++
){
var
nodes
=
edges
.
triangulations
[
i
];
json
.
edges_vertices
.
push
([
nodes
[
0
],
nodes
[
1
]]);
json
.
edges_assignment
.
push
(
"
F
"
);
}
for
(
var
i
=
0
;
i
<
geo
.
faces
.
length
;
i
++
){
var
face
=
geo
.
faces
[
i
];
json
.
faces_vertices
.
push
([
face
.
a
,
face
.
b
,
face
.
c
]);
}
}
else
{
var
polys
=
globals
.
pattern
.
getPolygons
();
for
(
var
i
=
0
;
i
<
polys
.
length
;
i
++
){
var
poly
=
polys
[
i
].
slice
();
poly
.
pop
();
json
.
faces_vertices
.
push
(
poly
);
}
}
if
(
globals
.
exportFoldAngle
){
var
foldAngles
=
[];
//todo target fold angles or current?
json
.
edges_foldAngles
=
foldAngles
;
}
var
blob
=
new
Blob
([
JSON
.
stringify
(
json
,
null
,
4
)],
{
type
:
'
application/octet-binary
'
});
saveAs
(
blob
,
filename
+
"
.fold
"
);
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment