Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Bead Generation Site
Manage
Activity
Members
Labels
Plan
Issues
8
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Claire
Bead Generation Site
Commits
fa21867a
Commit
fa21867a
authored
2 years ago
by
Albert Dong
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://git.uclalemur.com/team-claire/beadgen
parents
118f4b17
d2fd4872
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/structureGen.py
+24
-14
24 additions, 14 deletions
backend/structureGen.py
backend/tempBeadGen.py
+48
-1
48 additions, 1 deletion
backend/tempBeadGen.py
frontend/src/routes/structures/+page.svelte
+4
-3
4 additions, 3 deletions
frontend/src/routes/structures/+page.svelte
with
76 additions
and
18 deletions
backend/structureGen.py
+
24
−
14
View file @
fa21867a
...
...
@@ -3,7 +3,9 @@ import shape_array_generation
import
tempBeadGen
import
tools
import
math
from
build123d
import
*
#corner_type: 0=largesphere, 1=curvedcylinder
def
squareStructGen
(
side_length
,
beads_per_side
,
hole_radius
,
corner_type
):
bead_array
=
shape_array_generation
.
new_square_bead_chain
(
side_length
,
beads_per_side
)
...
...
@@ -11,22 +13,30 @@ def squareStructGen(side_length, beads_per_side, hole_radius, corner_type):
for
i
in
range
(
0
,
len
(
bead_array
)):
bead
=
bead_array
[
i
]
if
(
i
==
0
):
if
(
bead_array
[
i
+
1
][
1
]
!=
0
):
new_bead
=
tempBeadGen
.
junctionBead
(
1
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
if
(
corner_type
==
0
):
if
(
i
==
0
):
if
(
bead_array
[
i
+
1
][
1
]
!=
0
):
new_bead
=
tempBeadGen
.
junctionBead
(
1
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
else
:
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
bead
[
1
]
==
90
):
new_bead
=
beadGen
.
generateAngledBead
(
bead
[
0
]
*
0.707
,
hole_radius
,
[
0
,
bead
[
1
]],
cutout_query
=
False
)[
1
]
else
:
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
bead
[
1
]
==
90
):
new_bead
=
beadGen
.
generateAngledBead
(
bead
[
0
]
*
0.707
,
hole_radius
,
[
0
,
bead
[
1
]],
cutout_query
=
False
)[
1
]
else
:
if
(
bead_array
[
i
+
1
][
1
]
!=
0
and
bead_array
[
i
-
1
][
1
]
!=
0
):
new_bead
=
tempBeadGen
.
junctionBead
(
1
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
bead_array
[
i
+
1
][
1
]
!=
0
and
bead_array
[
i
-
1
][
1
]
==
0
):
new_bead
=
tempBeadGen
.
junctionBead
(
1
,
0
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
bead_array
[
i
+
1
][
1
]
==
0
and
bead_array
[
i
-
1
][
1
]
!=
0
):
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
if
(
bead_array
[
i
+
1
][
1
]
!=
0
and
bead_array
[
i
-
1
][
1
]
!=
0
):
new_bead
=
tempBeadGen
.
junctionBead
(
1
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
bead_array
[
i
+
1
][
1
]
!=
0
and
bead_array
[
i
-
1
][
1
]
==
0
):
new_bead
=
tempBeadGen
.
junctionBead
(
1
,
0
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
bead_array
[
i
+
1
][
1
]
==
0
and
bead_array
[
i
-
1
][
1
]
!=
0
):
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
1
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
else
:
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
0
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
elif
(
corner_type
==
1
):
#curved cylinder
if
(
bead
[
1
]
==
90
):
new_bead
=
tempBeadGen
.
curvedCylinderBead
(
bead
[
0
]
/
2
,
bead
[
1
],
hole_radius
)
if
(
i
==
len
(
bead_array
)
-
1
):
new_bead
-=
Pos
(
0
,
bead
[
0
]
/
2
,
bead
[
0
]
/
3
)
*
Cylinder
(
hole_radius
,
bead
[
0
],
rotation
=
(
45
,
0
,
0
),
align
=
(
Align
.
CENTER
,
Align
.
CENTER
,
Align
.
MIN
))
else
:
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
0
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
bead
[
0
]
*
0.707
)
new_bead
=
tempBeadGen
.
cylinderBead
(
0
,
0
,
bead
[
0
]
/
2
,
bead
[
0
],
hole_radius
,
0
)
beads
.
append
(
new_bead
)
combined
=
tools
.
combineItemList
(
beads
,
2
*
side_length
/
beads_per_side
)
...
...
This diff is collapsed.
Click to expand it.
backend/tempBeadGen.py
+
48
−
1
View file @
fa21867a
from
build123d
import
*
from
ocp_vscode
import
*
import
math
# tip types: 0=cone, 1=sphere, 2=flat
...
...
@@ -96,4 +98,49 @@ def junctionBead(tipType, baseType, radius, height, hole_radius, cut_radius):
hole
=
Cylinder
(
radius
/
4
,
radius
,
rotation
=
(
0
,
-
90
,
0
),
align
=
(
Align
.
MIN
,
Align
.
CENTER
,
Align
.
MIN
))
bead
-=
Pos
(
-
radius
*
(
ratio
*
0.8
),
0
,
0
)
*
hole
return
bead
\ No newline at end of file
return
bead
def
curvedCylinderBead
(
radius
,
angle
,
hole_radius
):
ratio
=
0.88
cut
=
Pos
(
0
,
0
,
0
)
*
Cone
(
bottom_radius
=
radius
,
top_radius
=
hole_radius
,
height
=
radius
,
align
=
(
Align
.
CENTER
,
Align
.
CENTER
,
Align
.
MIN
),
)
curve_radius
=
radius
*
1.3
path
=
TangentArc
((
0
,
0
,
0
),
(
0
,
curve_radius
*
(
1
-
math
.
cos
(
math
.
radians
(
angle
))),
curve_radius
*
math
.
sin
(
math
.
radians
(
angle
))),
tangent
=
(
0
,
0
,
1
))
base
=
sweep
(
sections
=
section
(
obj
=
cut
,
section_by
=
Plane
.
XY
),
path
=
path
)
tip
=
Plane
(
base
.
faces
().
sort_by
().
last
)
*
cut
b
=
base
+
tip
-
cut
wall_thickness
=
(
radius
*
(
1
-
ratio
))
b
-=
offset
(
b
,
amount
=-
wall_thickness
)
hole_shape
=
make_face
(
cut
.
edges
().
sort_by
(
Axis
.
Z
).
last
)
b
-=
extrude
(
to_extrude
=
hole_shape
,
amount
=
wall_thickness
)
b
-=
extrude
(
to_extrude
=
hole_shape
,
amount
=-
hole_shape
.
center
().
Z
)
b
-=
extrude
(
to_extrude
=
Plane
(
base
.
faces
().
sort_by
().
last
)
*
Pos
(
0
,
0
,
-
wall_thickness
)
*
cut
.
faces
().
sort_by
().
last
,
amount
=
cut
.
faces
().
sort_by
().
last
.
center
().
Z
+
wall_thickness
,
both
=
True
,
)
hole
=
Cylinder
(
radius
/
4
,
radius
,
rotation
=
(
0
,
-
90
,
0
),
align
=
(
Align
.
MIN
,
Align
.
CENTER
,
Align
.
MIN
))
b
-=
Pos
(
-
radius
*
ratio
*
0.8
,
0
,
radius
/
2
)
*
hole
return
b
#curved = curvedCylinderBead(10, 120, 0.8)
#show_object(curved)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/routes/structures/+page.svelte
+
4
−
3
View file @
fa21867a
...
...
@@ -14,7 +14,7 @@
let
scene
=
new
THREE
.
Scene
();
let
struct_type
=
"
polygon
"
;
let
corner_type
=
"
large-sphere
"
;
let
corner_type
=
1
;
let
side_length
=
30
;
let
beads_per_side
=
3
;
let
hole_radius
=
1
;
...
...
@@ -23,7 +23,7 @@
let
api_path
:
string
;
$
:
{
if
(
struct_type
==
"
square
"
)
{
api_path
=
`http://localhost:8000/api/square-struct?side_length=
${
side_length
}
&beads_per_side=
${
beads_per_side
}
&hole_radius=
${
hole_radius
}
`
;
api_path
=
`http://localhost:8000/api/square-struct?side_length=
${
side_length
}
&beads_per_side=
${
beads_per_side
}
&hole_radius=
${
hole_radius
}
&corner_type=
${
corner_type
}
`
;
}
else
if
(
struct_type
==
"
triangle
"
)
{
api_path
=
`http://localhost:8000/api/triangle-struct?side_length=
${
side_length
}
&beads_per_side=
${
beads_per_side
}
&hole_radius=
${
hole_radius
}
`
;
}
else
if
(
struct_type
==
"
polygon
"
)
{
...
...
@@ -53,7 +53,8 @@
<label
for=
"corner-type"
>
Corner Type
</label>
<select
name=
"corner-type"
bind:value=
{
corner_type
}
>
<option
value=
"large-sphere"
>
Large Sphere
</option>
<option
value=
0
>
Large Sphere
</option>
<option
value=
1
>
Curved Cylinder
</option>
</select>
{
#if
!
struct_type
||
struct_type
==
"
polygon
"
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment