Skip to content

Commit

Permalink
Fixing issue 154 (#158)
Browse files Browse the repository at this point in the history
* added test that currently fails

* fixed bug with freecad attribute usage

* added missing arg

* format
  • Loading branch information
shimwell authored May 14, 2024
1 parent d7953ce commit 882fc7f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/geouned/GEOUNED/Utils/BasicFunctions_part2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def is_same_plane(p1, p2, options, tolerances, numeric_format, fuzzy=(False, 0))
d2 = -d2
d = abs(d1 - d2)
if tolerances.relativeTol:
tol = tolerances.pln_distance * max(p2.dim1, p2.dim2)
tol = tolerances.pln_distance * max(p2.dimL1, p2.dimL2)
else:
tol = tolerances.pln_distance

Expand Down Expand Up @@ -120,7 +120,15 @@ def is_same_cylinder(
is_same_center, is_fuzzy = is_in_tolerance(d, tol, 0.5 * tol, 2 * tol)
if is_fuzzy and fuzzy[0]:
Fuzzy(
fuzzy[1], "cylAxs", cyl1, cyl2, d, tol, tolerances, numeric_format
fuzzy[1],
"cylAxs",
cyl1,
cyl2,
d,
tol,
options,
tolerances,
numeric_format,
)

return is_same_center
Expand Down
17 changes: 17 additions & 0 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,20 @@ def test_cad_to_csg_from_json_with_non_defaults():

my_cad_to_csg.start()
my_cad_to_csg.export_csg()


def test_with_relative_tol_true():

# test to protect against incorrect attribute usage in FreeCAD
# more details https://github.com/GEOUNED-org/GEOUNED/issues/154

geo = geouned.CadToCsg(
stepFile=f"{step_files[1].resolve()}",
tolerances=geouned.Tolerances(relativeTol=False),
)
geo.start()
geo = geouned.CadToCsg(
stepFile=f"{step_files[1].resolve()}",
tolerances=geouned.Tolerances(relativeTol=True),
)
geo.start()

0 comments on commit 882fc7f

Please # to comment.