Skip to content

Commit

Permalink
Added support for rounded heel edges.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnesarco committed Mar 2, 2024
1 parent 4ceef4d commit 169753a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 7 deletions.
2 changes: 1 addition & 1 deletion freecad/marz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# | along with Marz Workbench. If not, see <https://www.gnu.org/licenses/>. |
# +---------------------------------------------------------------------------+

__version__ = "0.0.28-alpha"
__version__ = "0.0.29-alpha"
__author__ = "Frank David Martinez M <mnesarco at gmail.com>"
__copyright__ = "Copyright 2020, Frank D. Martinez. M."
__license__ = "GPLv3"
Expand Down
1 change: 1 addition & 0 deletions freecad/marz/feature/instrument_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
fcp('neck.transitionLength', 50, 'Length of the heel transition', compat=COMPAT_PRE_028),
fcp('neck.transitionTension', 35, 'Tension of the heel transition', compat=COMPAT_PRE_028),
fcp('neck.transitionFunction', TransitionFunction.CATENARY, 'Math function of the heel transition', enum=TransitionFunction, compat=COMPAT_PRE_028),
fcp('neck.heelFillet', 6.35, 'Heel corners fillet (radius)', compat=COMPAT_PRE_028),

# Fretboard
fcp('fretboard.thickness', 7, 'Board thickness', compat=COMPAT_PRE_028),
Expand Down
39 changes: 37 additions & 2 deletions freecad/marz/feature/neck.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
from freecad.marz.model.neck_profile import getNeckProfile
from freecad.marz.extension.threading import Task
from freecad.marz.model.transitions import transitionDatabase
from freecad.marz.extension.ui import createPartBody, updatePartShape
from freecad.marz.extension.ui import createPartBody, updatePartShape, Log
from freecad.marz.model.vxy import angleVxy, vxy
from freecad.marz.utils.geom import is_edge_at, are_parallel, showShape


@PureFunctionCache
Expand Down Expand Up @@ -240,6 +241,30 @@ def heelBase():
return part.removeSplitter()


def heel_fillet(heel, p1, p2, radius):
if radius <= 1e-3:
return heel

v1 = geom.vec(p1)
v2 = geom.vec(p2)
Z = Vector(0,0,1)
selected = []

def fillable(edge):
return ((is_edge_at(edge, v1) or is_edge_at(edge, v2))
and are_parallel(edge.tangentAt(edge.FirstParameter), Z))

selected = [e for e in heel.Edges if fillable(e)]
# for edge in heel.Edges:
# if (is_edge_at(edge, v1) or is_edge_at(edge, v2)) and are_parallel(edge.tangentAt(edge.FirstParameter), Z):
# selected.append(edge)

if len(selected) > 0:
heel = heel.makeFillet(radius, selected)

return heel


@PureFunctionCache
@traced('Make Tenon')
def makeTenon(fbd, neckAngleRad, posXY, h, tenonThickness, tenonLength, tenonOffset, joint):
Expand Down Expand Up @@ -336,9 +361,19 @@ def createShape(self):
def heel(self, neckd, line, forPocket=False):
body = self.instrument.body
neck = self.instrument.neck
return makeHeel(neckd, line, neck.angle, neck.joint, body.backThickness, body.topThickness, neck.topOffset,
part = makeHeel(neckd, line, neck.angle, neck.joint, body.backThickness, body.topThickness, neck.topOffset,
body.neckPocketDepth, body.neckPocketLength, neck.jointFret, neck.transitionLength, neck.transitionTension,
body.length, neck.tenonThickness, neck.tenonLength, neck.tenonOffset, forPocket)

try:
return heel_fillet(
part,
neckd.fbd.neckFrame.bridge.end,
neckd.fbd.neckFrame.bridge.start,
self.instrument.neck.heelFillet)
except:
Log("Error filleting the heel with radius: ", self.instrument.neck.heelFillet)
return part

def createPart(self):
"""
Expand Down
5 changes: 4 additions & 1 deletion freecad/marz/model/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ class Neck(Feature):
def __init__(self, instrument, joint=NeckJoint.THROUHG, startThickness=15,
endThickness=17, jointFret=16, topOffset=0, angle=3, tenonThickness=10,
tenonLength=10, tenonOffset=2, profile="C Classic",
transitionLength=50, transitionTension=10, transitionFunction=TransitionFunction.CATENARY):
transitionLength=50, transitionTension=10, transitionFunction=TransitionFunction.CATENARY,
heelFillet=6.35):
"""
Args:
joint : Type of Neck-Body Joint (NeckJoint)
Expand All @@ -249,6 +250,7 @@ def __init__(self, instrument, joint=NeckJoint.THROUHG, startThickness=15,
tenonOffset : Offset of the tenon
transitionLength : Length of the transition between neck and heel
transitionTension: Tension of the transition between neck and heel
heelFillet : Hell fillet radius
"""
super().__init__(instrument)
self.joint = joint
Expand All @@ -264,6 +266,7 @@ def __init__(self, instrument, joint=NeckJoint.THROUHG, startThickness=15,
self.transitionLength = transitionLength
self.transitionTension = transitionTension
self.transitionFunction = transitionFunction
self.heelFillet = heelFillet


class Fretboard(Feature):
Expand Down
16 changes: 16 additions & 0 deletions freecad/marz/utils/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def vecyz(v, x=0):
def showPoint(v):
Part.show(Part.Shape([Part.Point(v)]))

@RunInUIThread
def showShape(v):
Part.show(v)

def showPoints(vs):
for v in vs: showPoint(v)
Expand Down Expand Up @@ -147,3 +150,16 @@ def sectionSegment(shape, line):
(d, vs, es) = line.distToShape(shape)
if d < 1e-5 and len(vs) > 1:
return Part.LineSegment(vs[0][0], vs[1][0])


def is_edge_at(edge, point, tol=1e-5):
start = edge.valueAt(edge.FirstParameter)
end = edge.valueAt(edge.LastParameter)
return point.isEqual(end, tol) or point.isEqual(start, tol)

def are_parallel(vec_a, vec_b, tol=1e-6):
vec_c = vec_a.cross(vec_b)
return vec_c.Length <= tol

def are_perpendicular(vec_a, vec_b, tol=1e-6):
return vec_a.dot(vec_b) <= tol
2 changes: 1 addition & 1 deletion manifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;* General identification metadata *
;***************************************************************************
[general]
version=0.28
version=0.29
name=Marz
title=Marz Guitar Design
description=Parametric Guitar Design
Expand Down
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package format="1">
<name>Marz Workbench</name>
<description>Parametric Guitar design workbench</description>
<version>0.0.28-alpha</version>
<version>0.0.29-alpha</version>
<maintainer email="twitter: @mnesarco">Frank Martinez</maintainer>
<license file="LICENSE">GPL-3.0</license>
<url type="repository" branch="master">https://github.com/mnesarco/MarzWorkbench</url>
Expand All @@ -13,7 +13,7 @@
<name>Marz Workbench</name>
<classname>MarzWorkbench</classname>
<description>Parametric Guitar design workbench.</description>
<version>0.0.28-alpha</version>
<version>0.0.29-alpha</version>
<subdirectory>./</subdirectory>
<icon>Resources/icons/Marz.svg</icon>
<freecadmin>0.19.0</freecadmin>
Expand Down

0 comments on commit 169753a

Please sign in to comment.