Add GrippingEdge

Still needs to replace Boxes.grip()
This commit is contained in:
Florian Festi 2016-06-30 14:25:29 +02:00
parent 46f1e1d440
commit a7f0e97012
3 changed files with 89 additions and 7 deletions

View File

@ -297,6 +297,8 @@ class Boxes:
self.edges = {}
self.addPart(edges.Edge(self, None))
self.addPart(edges.OutSetEdge(self, None))
s = edges.GripSettings(self.thickness)
self.addPart(edges.GrippingEdge(self, s))
# Finger joints
# Share settings object

View File

@ -211,6 +211,79 @@ class OutSetEdge(BaseEdge):
def startwidth(self):
return self.boxes.thickness
#############################################################################
#### Gripping Edge
#############################################################################
class GripSettings(Settings):
"""Settings for GrippingEdge
Values:
* absolute_params
* style : A : "A" (wiggly line) or "B" (bumps)
* outset : True : extend outward the straight edge
* relative (in multiples of thickness)
* depth : 0.3 : depth of the grooves
"""
absolute_params = {
"style" : "A",
"outset" : True,
}
relative_params = {
"depth" : 0.3,
}
class GrippingEdge(BaseEdge):
description = """Corrugated edge useful as an gipping area"""
char = 'g'
def A(self, length):
depth = self.settings.depth
grooves = int(length // (depth*2.0)) + 1
depth = length / grooves / 4.0
o = 1 if self.settings.outset else -1
for groove in range(grooves):
self.corner(o * -90, depth)
self.corner(o * 180, depth)
self.corner(o * -90, depth)
def B(self, length):
depth = self.settings.depth
grooves = int(length // (depth*2.0)) + 1
depth = length / grooves / 2.0
o = 1 if self.settings.outset else -1
if self.settings.outset:
self.corner(-90)
else:
self.corner(90)
self.edge(depth)
self.corner(-180)
for groove in range(grooves):
self.corner(180, depth)
self.corner(-180, 0)
if self.settings.outset:
self.corner(90)
else:
self.edge(depth)
self.corner(90)
def margin(self):
if self.settings.outset:
return self.settings.depth + self.boxes.spacing
else:
return self.boxes.spacing
def __call__(self, length, **kw):
getattr(self, self.settings.style)(length)
class CompoundEdge(BaseEdge):
"""Edge composed of multiple different Edges"""
description = "Compound Edge"

View File

@ -5,17 +5,18 @@ As edges started out as methods of the main Boxes class they still are
callables. A set of instances are kept the ``.edges`` attribute of the
``Boxes`` class. It is a dict with strings of length one as keys:
* e : Edge
* E : OutSetEdge
* s : StackableEdge
* S : StackableEdgeTop
* f : FingerJointEdge
* F : FingerJointEdgeCounterPart
* h : FingerHoleEdge
* d : DoveTailJoint
* D : DoveTailJointCounterPart
* e : Edge
* E : OutSetEdge
* f : FingerJointEdge
* F : FingerJointEdgeCounterPart
* g : GrippingEdge
* h : FingerHoleEdge
* ijk : Hinge (start, end, both sides)
* IJK : HingePin (start, end, both sides)
* s : StackableEdge
* S : StackableEdgeTop
Edges of the same type share a settings instance to make sure both
sides match (when the same length is given).
@ -41,6 +42,12 @@ Straight Edges
.. autoclass:: boxes.edges.Edge
.. autoclass:: boxes.edges.OutSetEdge
Grip
----
.. autoclass:: boxes.edges.GripSettings
.. autoclass:: boxes.edges.GrippingEdge
Stackable Edges
---------------