Skip to content

Commit

Permalink
Fix for #203, errors in simplify full (#206)
Browse files Browse the repository at this point in the history
* Patch for #203

* Responding to comments on #206

* Update core.py

Add missing space to call to UF.get_box()

---------

Co-authored-by: AlvaroCubi <55387701+AlvaroCubi@users.noreply.github.com>
Co-authored-by: Grammer, Kyle <grammerkb@ornl.gov>
  • Loading branch information
3 people authored and psauvan committed Jun 17, 2024
1 parent d1d4d5c commit e0aa4ad
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/geouned/GEOReverse/Modules/Utils/BooleanSolids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/geouned/GEOReverse/Modules/splitFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/geouned/GEOUNED/conversion/cell_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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,
)

Expand Down
4 changes: 2 additions & 2 deletions src/geouned/GEOUNED/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,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.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:
Expand Down
14 changes: 7 additions & 7 deletions src/geouned/GEOUNED/utils/boolean_solids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -472,7 +472,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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/geouned/GEOUNED/void/void_box_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e0aa4ad

Please sign in to comment.