Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #46 from spacether/bug/fix_rounded-square-ccw_example
Browse files Browse the repository at this point in the history
Bug/fix rounded square ccw example
  • Loading branch information
spacether authored Jul 22, 2018
2 parents 620e13c + 860f7f4 commit 109d5db
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 54 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ Initial Release: December 2014

## Change Log

#### 0.9.6
- Fixes part.fillet_lines method, all tests now pass
- Verified on Mac OS X
- Closes github Issue 32: '2/15 of the tests fail'

#### 0.9.5 (github + pypi)
- Adds tests: sample tests at tests/test_samples.py
- Adds tests: meshing tests at tests/test_meshing.py
Expand Down
Binary file modified dist/documentation.zip
Binary file not shown.
Binary file modified dist/examples.zip
Binary file not shown.
Binary file not shown.
9 changes: 6 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = 'Justin Black'

# The short X.Y version
version = '0.9.5'
version = ''
# The full version, including alpha/beta/rc tags
release = '0.9.5'
release = ''


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -184,7 +184,10 @@
# -- Options for todo extension ----------------------------------------------

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
todo_include_todos = True
from pycalculix.version import __version__
version = __version__
release = version
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.todo',
Expand Down
1 change: 1 addition & 0 deletions examples/rounded-square-ccw.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
line_2 = part.draw_line_ax(-length)[0]
part.draw_line_rad(-thickness*0.4)
part.draw_line_to(radius_inner, axial)
model.plot_geometry(model_name + '_pre', display=show_gui)
part.fillet_lines(line_1, line_2, radius)

model.plot_geometry(model_name + '_geom', display=show_gui)
Expand Down
1 change: 1 addition & 0 deletions examples/rounded-square-cw.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
line_2 = part.draw_line_rad(-thickness)[0]
part.draw_line_ax(-length*0.5)
part.draw_line_to(radius_inner, axial)
model.plot_geometry(model_name + '_pre', display=show_gui)
part.fillet_lines(line_1, line_2, radius)

model.plot_geometry(model_name + '_geom', display=show_gui)
Expand Down
110 changes: 60 additions & 50 deletions pycalculix/partmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def draw_circle(self, center_x, center_y, radius, num_arcs=4):
center_y (float): y-axis hole center
radius (float): hole radius
num_arcs (int): number of arcs to use, must be >= 3
Returns:
loop (geometry.LineLoop): a LineLoop list of SignArc
"""
Expand Down Expand Up @@ -518,66 +518,76 @@ def fillet_lines(self, line1, line2, radius):
Args:
line1 (SignLine): line that the arc starts on, arc is tangent
line2 (SignLine): line that the ar ends on, arc is tangent
line2 (SignLine): line that the arc ends on, arc is tangent
radius (float): arc radius size
Returns:
list: [arc, start_point, end_point]
"""
# this function fillets lines in a part
# check if the lines are touching
tmp = self.__cursor
if not line1.line.touches(line2.line):
print('ERROR: Cannot fillet! Lines must touch!')
return

if line1.line.pt(1) == line2.line.pt(0):
first_line = line1
second_line = line2
elif line2.line.pt(1) == line1.line.pt(0):
first_line = line2
second_line = line1
else:
print('ERROR: Sign lines must both be going in CW or CCW '
'direction. The two passed lines are going in '
'different directions. Unable to fillet them.')
return

if line1.touches(line2):
# offset the lines, assuming area is being traced clockwise
# get the intersection point
magnitude = radius
l1_off = line1.offset(magnitude)
l2_off = line2.offset(magnitude)
tmp = self.__cursor
# offset the lines, assuming area is being traced clockwise
# get the intersection point
magnitude = radius
l1_off = first_line.offset(magnitude)
l2_off = second_line.offset(magnitude)
ctrpt = l1_off.intersects(l2_off)
if ctrpt == None:
# flip the offset direction if lines don't intersect
magnitude = -radius
l1_off = first_line.offset(magnitude)
l2_off = second_line.offset(magnitude)
ctrpt = l1_off.intersects(l2_off)
if ctrpt == None:
# flip the offset direction if lines don't intersect
magnitude = -radius
l1_off = line1.offset(magnitude)
l2_off = line2.offset(magnitude)
ctrpt = l1_off.intersects(l2_off)

# now we have an intersecting point
#print('Arc center pt is: ', ctrpt)
p1_new = line1.arc_tang_intersection(ctrpt, magnitude)
p2_new = line2.arc_tang_intersection(ctrpt, magnitude)
rempt = line1.pt(1)

p1_new = self.__make_get_pt(p1_new.x, p1_new.y)[0]
ctrpt = self.__make_get_pt(ctrpt.x, ctrpt.y)[0]
p2_new = self.__make_get_pt(p2_new.x, p2_new.y)[0]

# make the new arc
arc = self.__make_get_sline(geometry.Arc(p1_new, p2_new, ctrpt))[0]

# put the arc in the right location in the area
area = line1.lineloop.parent
area.line_insert(line1, arc)
print('Arc inserted into area %i' % (area.id))

# edit the adjacent lines to replace the removed pt
line1.set_pt(1, arc.pt(0))
line2.set_pt(0, arc.pt(1))
# del old pt, store new points for the arc
self.fea.points.remove(rempt)

return [arc, arc.pt(0), arc.pt(1)]
else:
print('Cannot fillet! Lines must touch!')

# now we have an intersecting point
p1_new = first_line.arc_tang_intersection(ctrpt, magnitude)
p2_new = second_line.arc_tang_intersection(ctrpt, magnitude)
rempt = first_line.pt(1)

p1_new = self.__make_get_pt(p1_new.x, p1_new.y)[0]
ctrpt = self.__make_get_pt(ctrpt.x, ctrpt.y)[0]
p2_new = self.__make_get_pt(p2_new.x, p2_new.y)[0]

# make the new arc
arc = self.__make_get_sline(geometry.Arc(p1_new, p2_new, ctrpt))[0]

# put the arc in the right location in the area
area = first_line.lineloop.parent
area.line_insert(first_line, arc)
print('Arc inserted into area %i' % (area.id))

# edit the adjacent lines to replace the removed pt
first_line.set_pt(1, arc.pt(0))
second_line.set_pt(0, arc.pt(1))
# del old pt, store new points for the arc
self.fea.points.remove(rempt)

# reset the cursor to where it should be
self.__cursor = tmp
return [arc, arc.pt(0), arc.pt(1)]

def fillet_all(self, radius):
"""Fillets all external lines not within 10 degrees of tangency
Args:
radius (float): the fillet radius to use
Returns:
arcs (list): list of SignArc
"""
Expand Down Expand Up @@ -630,7 +640,7 @@ def plot(self, axis, label=True, color='yellow'):
# apply the label
if label:
self.label(axis)

def __cut_line(self, point, line):
"""Cuts the passed line at the passed point.
Expand Down Expand Up @@ -781,7 +791,7 @@ def __get_cut_line(self, cutline):

def __cut_with_line(self, cutline, debug):
"""Cuts the part using the passed line.
Args:
cutline (Line): line to cut the area with
debug (list): bool for printing, bool for plotting after every cut
Expand Down Expand Up @@ -898,7 +908,7 @@ def __vect_to_line(self, point, cvect):
Args:
point (Point): the location we are cutting from
cvect (Point): the vector direction of the cut from pt
Returns:
cutline (Line): cut line
"""
Expand Down
2 changes: 1 addition & 1 deletion pycalculix/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.5"
__version__ = "0.9.6"

0 comments on commit 109d5db

Please sign in to comment.