From 353f6e78f7969b30bfacdde47646db22e6526cc0 Mon Sep 17 00:00:00 2001 From: "Grammer, Kyle" Date: Mon, 3 Jun 2024 08:52:45 -0400 Subject: [PATCH 1/4] Patch for #203 --- src/geouned/GEOUNED/core.py | 4 ++-- src/geouned/GEOUNED/utils/boolean_solids.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/geouned/GEOUNED/core.py b/src/geouned/GEOUNED/core.py index 8d0399b0..e7807e0e 100644 --- a/src/geouned/GEOUNED/core.py +++ b/src/geouned/GEOUNED/core.py @@ -639,8 +639,8 @@ def start(self): if c.Definition.level == 0 or c.IsEnclosure: continue logger.info(f"simplify cell {c.__id__}") - Box = UF.get_box(c) - CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), option="full") + Box = UF.get_box(c,self.options) + CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), option="full",options=self.options) c.Definition.simplify(CT) c.Definition.clean() if type(c.Definition.elements) is bool: diff --git a/src/geouned/GEOUNED/utils/boolean_solids.py b/src/geouned/GEOUNED/utils/boolean_solids.py index 82591f76..53dee67c 100644 --- a/src/geouned/GEOUNED/utils/boolean_solids.py +++ b/src/geouned/GEOUNED/utils/boolean_solids.py @@ -439,7 +439,7 @@ def point_inside(solid): return point cut_line = 32 - cut_box = 2 + cutbox = 2 v1 = solid.Vertexes[0].Point for vi in range(len(solid.Vertexes) - 1, 0, -1): @@ -478,7 +478,7 @@ def point_inside(solid): boxes = subbox n = n + 1 - if n == cut_box: + if n == cutbox: break return point_from_surface(solid) From 1dc65a4ca2295532b2333688bb44de83d5cd29c9 Mon Sep 17 00:00:00 2001 From: "Grammer, Kyle" Date: Mon, 3 Jun 2024 11:26:36 -0400 Subject: [PATCH 2/4] Responding to comments on #206 --- .../GEOReverse/Modules/Utils/BooleanSolids.py | 6 +++--- .../GEOReverse/Modules/splitFunction.py | 6 +++--- .../GEOUNED/conversion/cell_definition.py | 4 ++-- src/geouned/GEOUNED/core.py | 4 ++-- src/geouned/GEOUNED/utils/boolean_solids.py | 18 +++++++++--------- src/geouned/GEOUNED/void/void_box_class.py | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/geouned/GEOReverse/Modules/Utils/BooleanSolids.py b/src/geouned/GEOReverse/Modules/Utils/BooleanSolids.py index 45125712..f86af187 100644 --- a/src/geouned/GEOReverse/Modules/Utils/BooleanSolids.py +++ b/src/geouned/GEOReverse/Modules/Utils/BooleanSolids.py @@ -434,7 +434,7 @@ def point_inside(solid): BBox = solid.optimalBoundingBox(False) box = [BBox.XMin, BBox.XMax, BBox.YMin, BBox.YMax, BBox.ZMin, BBox.ZMax] - boxes, centers = cut_box(box) + boxes, centers = divide_box(box) n = 0 while True: @@ -446,7 +446,7 @@ def point_inside(solid): subbox = [] centers = [] for b in boxes: - btab, ctab = cut_box(b) + btab, ctab = divide_box(b) subbox.extend(btab) centers.extend(ctab) boxes = subbox @@ -458,7 +458,7 @@ def point_inside(solid): # divide a box into 8 smaller boxes -def cut_box(Box): +def divide_box(Box): xmid = (Box[1] + Box[0]) * 0.5 ymid = (Box[3] + Box[2]) * 0.5 zmid = (Box[5] + Box[4]) * 0.5 diff --git a/src/geouned/GEOReverse/Modules/splitFunction.py b/src/geouned/GEOReverse/Modules/splitFunction.py index 99c4e8b3..dcfb44d3 100644 --- a/src/geouned/GEOReverse/Modules/splitFunction.py +++ b/src/geouned/GEOReverse/Modules/splitFunction.py @@ -163,7 +163,7 @@ def point_inside(solid): BBox = solid.optimalBoundingBox(False) box = [BBox.XMin, BBox.XMax, BBox.YMin, BBox.YMax, BBox.ZMin, BBox.ZMax] - boxes, centers = cut_box(box) + boxes, centers = divide_box(box) n = 0 while True: @@ -175,7 +175,7 @@ def point_inside(solid): subbox = [] centers = [] for b in boxes: - btab, ctab = cut_box(b) + btab, ctab = divide_box(b) subbox.extend(btab) centers.extend(ctab) boxes = subbox @@ -188,7 +188,7 @@ def point_inside(solid): # divide a box into 8 smaller boxes -def cut_box(Box): +def divide_box(Box): xmid = (Box[1] + Box[0]) * 0.5 ymid = (Box[3] + Box[2]) * 0.5 zmid = (Box[5] + Box[4]) * 0.5 diff --git a/src/geouned/GEOUNED/conversion/cell_definition.py b/src/geouned/GEOUNED/conversion/cell_definition.py index f67403cc..e0ab524d 100644 --- a/src/geouned/GEOUNED/conversion/cell_definition.py +++ b/src/geouned/GEOUNED/conversion/cell_definition.py @@ -856,7 +856,7 @@ def no_overlapping_cell(metaList, surfaces, options): CT = build_c_table_from_solids( box, (tuple(t_def.get_surfaces_numbers()), Surfs), - option="diag", + "diag", options=options, ) @@ -866,7 +866,7 @@ def no_overlapping_cell(metaList, surfaces, options): CT = build_c_table_from_solids( box, (tuple(new_def.get_surfaces_numbers()), Surfs), - option="full", + "full", options=options, ) diff --git a/src/geouned/GEOUNED/core.py b/src/geouned/GEOUNED/core.py index c92ee760..78fa22ef 100644 --- a/src/geouned/GEOUNED/core.py +++ b/src/geouned/GEOUNED/core.py @@ -681,8 +681,8 @@ def start(self): if c.Definition.level == 0 or c.IsEnclosure: continue logger.info(f"simplify cell {c.__id__}") - Box = UF.get_box(c,self.options) - CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), option="full",options=self.options) + Box = UF.get_box(c,self.options.enlargeBox) + CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), "full", options=self.options) c.Definition.simplify(CT) c.Definition.clean() if type(c.Definition.elements) is bool: diff --git a/src/geouned/GEOUNED/utils/boolean_solids.py b/src/geouned/GEOUNED/utils/boolean_solids.py index 53dee67c..be69ea97 100644 --- a/src/geouned/GEOUNED/utils/boolean_solids.py +++ b/src/geouned/GEOUNED/utils/boolean_solids.py @@ -239,7 +239,7 @@ def combine_diag_elements(d1, d2): return CTelement((0, 0, 1, 0)) -def build_c_table_from_solids(Box, SurfInfo, option, options): +def build_c_table_from_solids(Box, SurfInfo, simplification_mode, options): if type(SurfInfo) is dict: surfaces = SurfInfo @@ -260,7 +260,7 @@ def build_c_table_from_solids(Box, SurfInfo, option, options): surfaces[s].buildShape(Box.BoundBox) CTable = ConstraintTable() - if option == "diag": + if simplification_mode == "diag": CTable.diagonal = True else: CTable.diagonal = False @@ -270,7 +270,7 @@ def build_c_table_from_solids(Box, SurfInfo, option, options): # res,splitRegions = split_solid_fast(Box,Surfaces.get_surface(s1),True) CTable.add_element(s1, s1, CTelement(res, s1, s1)) - if option == "diag": + if simplification_mode == "diag": continue if splitRegions is None: continue # loop, no region to be split by s2 @@ -309,7 +309,7 @@ def build_c_table_from_solids(Box, SurfInfo, option, options): CTable.add_element(s1, s2, CTelement(val, s1, s2)) # if some surfaces don't cross the box some elements in Constraint table are not filled - if option != "diag": + if simplification_mode != "diag": CTable.fill_missing_elements() return CTable @@ -439,7 +439,7 @@ def point_inside(solid): return point cut_line = 32 - cutbox = 2 + cut_box = 2 v1 = solid.Vertexes[0].Point for vi in range(len(solid.Vertexes) - 1, 0, -1): @@ -460,7 +460,7 @@ def point_inside(solid): BBox = solid.optimalBoundingBox(False) box = [BBox.XMin, BBox.XMax, BBox.YMin, BBox.YMax, BBox.ZMin, BBox.ZMax] - boxes, centers = cut_box(box) + boxes, centers = divide_box(box) n = 0 while True: @@ -472,13 +472,13 @@ def point_inside(solid): subbox = [] centers = [] for b in boxes: - btab, ctab = cut_box(b) + btab, ctab = divide_box(b) subbox.extend(btab) centers.extend(ctab) boxes = subbox n = n + 1 - if n == cutbox: + if n == cut_box: break return point_from_surface(solid) @@ -515,7 +515,7 @@ def point_from_surface(solid): # divide a box into 8 smaller boxes -def cut_box(Box): +def divide_box(Box): xmid = (Box[1] + Box[0]) * 0.5 ymid = (Box[3] + Box[2]) * 0.5 zmid = (Box[5] + Box[4]) * 0.5 diff --git a/src/geouned/GEOUNED/void/void_box_class.py b/src/geouned/GEOUNED/void/void_box_class.py index b3d3ae9f..bc9a55af 100644 --- a/src/geouned/GEOUNED/void/void_box_class.py +++ b/src/geouned/GEOUNED/void/void_box_class.py @@ -271,7 +271,7 @@ def get_void_complementary(self, Surfaces, options, tolerances, numeric_format, surfaceDict = {} for i in surfList: surfaceDict[i] = Surfaces.get_surface(i) - CTable = build_c_table_from_solids(Box, surfaceDict, option=simplify, options=options) + CTable = build_c_table_from_solids(Box, surfaceDict, simplify, options=options) else: if res is True: return None, None From c54a129bb3148760704946cfe80e15c7ad5db082 Mon Sep 17 00:00:00 2001 From: Kyle Grammer <34066958+KBGrammer@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:32:13 -0400 Subject: [PATCH 3/4] Update core.py Add missing space to call to UF.get_box() --- src/geouned/GEOUNED/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geouned/GEOUNED/core.py b/src/geouned/GEOUNED/core.py index 78fa22ef..5f1ffa59 100644 --- a/src/geouned/GEOUNED/core.py +++ b/src/geouned/GEOUNED/core.py @@ -681,7 +681,7 @@ def start(self): if c.Definition.level == 0 or c.IsEnclosure: continue logger.info(f"simplify cell {c.__id__}") - Box = UF.get_box(c,self.options.enlargeBox) + Box = UF.get_box(c, self.options.enlargeBox) CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), "full", options=self.options) c.Definition.simplify(CT) c.Definition.clean() From 0597aad09adeae2e2a1d212696cb47dbdaedf465 Mon Sep 17 00:00:00 2001 From: "Grammer, Kyle" Date: Wed, 5 Jun 2024 09:42:12 -0400 Subject: [PATCH 4/4] Replace all get_box calls to have options.enlargeBox, change get_box to refer only to enlargeBox instead of options.enlargeBox --- src/geouned/GEOUNED/conversion/cell_definition.py | 2 +- src/geouned/GEOUNED/utils/functions.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/geouned/GEOUNED/conversion/cell_definition.py b/src/geouned/GEOUNED/conversion/cell_definition.py index e0ab524d..91ed386e 100644 --- a/src/geouned/GEOUNED/conversion/cell_definition.py +++ b/src/geouned/GEOUNED/conversion/cell_definition.py @@ -849,7 +849,7 @@ def no_overlapping_cell(metaList, surfaces, options): t_def, simplify = t_def_and_simplify if True in simplify: logger.info(f"reduce cell {m.__id__}") - box = UF.get_box(m) + box = UF.get_box(m, options.enlargeBox) # evaluate only diagonal elements of the Constraint Table (fastest) and remove surface not # crossing in the solid boundBox diff --git a/src/geouned/GEOUNED/utils/functions.py b/src/geouned/GEOUNED/utils/functions.py index 14cbb0d0..b5d251b0 100644 --- a/src/geouned/GEOUNED/utils/functions.py +++ b/src/geouned/GEOUNED/utils/functions.py @@ -23,9 +23,9 @@ from . import basic_functions_part2 as BF -def get_box(comp, options): +def get_box(comp, enlargeBox): bb = FreeCAD.BoundBox(comp.BoundBox) - bb.enlarge(options.enlargeBox) + bb.enlarge(enlargeBox) xMin, yMin, zMin = bb.XMin, bb.YMin, bb.ZMin xLength, yLength, zLength = bb.XLength, bb.YLength, bb.ZLength