Skip to content
Snippets Groups Projects
Commit fa21867a authored by Albert Dong's avatar Albert Dong
Browse files
parents 118f4b17 d2fd4872
Branches
No related merge requests found
......@@ -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)
......
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
......@@ -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"}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment