From 5bf756c3cab495d1dd3fd4f0fa717359f09612a3 Mon Sep 17 00:00:00 2001 From: Patrick Sauvan Date: Mon, 1 Jul 2024 11:01:46 +0200 Subject: [PATCH] update boolean surface class --- src/geouned/GEOUNED/core.py | 2 +- src/geouned/GEOUNED/utils/boolean_solids.py | 32 +++++++++------------ src/geouned/GEOUNED/void/void_box_class.py | 2 +- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/geouned/GEOUNED/core.py b/src/geouned/GEOUNED/core.py index db913578..044f4baa 100644 --- a/src/geouned/GEOUNED/core.py +++ b/src/geouned/GEOUNED/core.py @@ -504,7 +504,7 @@ def start(self): continue logger.info(f"simplify cell {c.__id__}") Box = UF.get_box(c, self.options.enlargeBox) - CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), "full", options=self.options) + CT = build_c_table_from_solids(Box, (c.Surfaces, Surfs), "full", options=self.options, excludeAux=True) 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 4984b5e3..50904896 100644 --- a/src/geouned/GEOUNED/utils/boolean_solids.py +++ b/src/geouned/GEOUNED/utils/boolean_solids.py @@ -182,10 +182,7 @@ def solid_in_box(self, Seq): # Sequence of the cell if self.diagonal: seqValues = dict() for s in surfs: - if s.aux: - val = None - else: - val = BoolVals[self[s][s].val] + val = BoolVals[self[s][s].val] if val is not None: seqValues[s] = val # if evaluate None : Box intersection Cell != 0 Part of the cell in the box @@ -195,11 +192,7 @@ def solid_in_box(self, Seq): # Sequence of the cell return res if type(res) is bool else None else: - if surfs[0].aux: - trueSet = {surfs[0]: True} - falseSet = {surfs[0]: False} - else: - trueSet, falseSet = self.get_constraint_set(surfs[0]) + trueSet, falseSet = self.get_constraint_set(surfs[0]) if trueSet is not None: trueVal = Seq.evaluate(trueSet) @@ -247,7 +240,7 @@ def combine_diag_elements(d1, d2): return CTelement((0, 0, 1, 0)) -def build_c_table_from_solids(Box, SurfInfo, simplification_mode, options): +def build_c_table_from_solids(Box, SurfInfo, simplification_mode, options, excludeAux=False): if type(SurfInfo) is dict: surfaces = SurfInfo @@ -258,13 +251,6 @@ def build_c_table_from_solids(Box, SurfInfo, simplification_mode, options): surfaces = SurfInfo.Surfaces surfaceList = SurfInfo.surfaceList - newList = [] - for s in surfaceList: - if s.aux: - continue - newList.append(s) - surfaceList = newList - if type(surfaces[surfaceList[0]]) is GeounedSurface: for s in surfaceList: ss = surfaces[s] @@ -281,10 +267,18 @@ def build_c_table_from_solids(Box, SurfInfo, simplification_mode, options): CTable.diagonal = False for i, s1 in enumerate(surfaceList): - res, splitRegions = split_solid_fast(Box, surfaces[s1], True, options) - # res,splitRegions = split_solid_fast(Box,Surfaces.get_surface(s1),True) + if excludeAux and s1.aux: + # if auxillary surfaces are excluded : + # 1) assume auxillary surface s1 is "crossing" the box (diagnonal elements) + # 2) if surface s2 cross the box => surface s1 cross s2 + res = 0 + splitRegions = None + else: + res, splitRegions = split_solid_fast(Box, surfaces[s1], True, options) + # res,splitRegions = split_solid_fast(Box,Surfaces.get_surface(s1),True) CTable.add_element(s1, s1, CTelement(res, s1, s1)) + if simplification_mode == "diag": continue if splitRegions is None: diff --git a/src/geouned/GEOUNED/void/void_box_class.py b/src/geouned/GEOUNED/void/void_box_class.py index 76bd72d5..377cf735 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, simplify, options=options) + CTable = build_c_table_from_solids(Box, surfaceDict, simplify, options=options, excludeAux=False) else: if res is True: return None, None