Skip to content

Commit

Permalink
fix bug with object surface
Browse files Browse the repository at this point in the history
  • Loading branch information
psauvan committed Aug 2, 2024
1 parent cf67060 commit bf250dc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 45 deletions.
14 changes: 9 additions & 5 deletions src/geouned/GEOUNED/conversion/cell_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,15 @@ def cellDef(meta_obj, surfaces, universe_box, options, tolerances, numeric_forma
orSeq.append(*extra)
surf_piece.append(orSeq)

surf_piece_bool = BoolSequence(operator="AND")
for p in surf_piece:
surf_piece_bool.append(p.get_BoolSequence())
surf_piece_bool.join_operators()
surf_piece_bool.simplify()
if surf_piece:
surf_piece_bool = BoolSequence(operator="AND")
for p in surf_piece:
surf_piece_bool.append(p.get_BoolSequence())
surf_piece_bool.join_operators()
surf_piece_bool.simplify()
else:
del_list.append(isol)
continue

# possible expresion for e
# i1
Expand Down
2 changes: 1 addition & 1 deletion src/geouned/GEOUNED/utils/boolean_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_BoolSequence(self, aux=False):
if self.s2 is None:
return self

seq = BoolSequence(self.op)
seq = BoolSequence(operator=self.op)
seq.append(bsurface(self.s1, aux=aux))

if type(self.s2) is int:
Expand Down
92 changes: 53 additions & 39 deletions testing/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,43 @@
from pathlib import Path

sys.path.append(str(Path(__file__).parents[1] / "src"))
#sys.path.append("/opt/geouned/v1.2.0/src/")
sys.path.append("/usr/lib64/freecad/lib64/")
import geouned

from geouned import CadToCsg


def setInput(inName, inpDir, outDir):
def setInputs():
test_settings = geouned.Settings(
voidGen=True,
debug=False ,
compSolids=False,
simplify="full",
minVoidSize=100.0,
)

test_options = geouned.Options(
forceCylinder=False,
newSplitPlane=True,
nPlaneReverse=0,
splitTolerance=0,
)

test_export = {
'title' : 'Input Test',
'outFormat' : ('mcnp',),
'volSDEF' : True,
'volCARD' : True,
'dummyMat' : True,
'cellSummaryFile' : False,
'cellCommentFile' : False
}

return test_settings, test_options, test_export



def getNames(inName, inpDir, outDir):

if inName.endswith(".step"):
filename = inName[0:-5]
Expand All @@ -23,37 +54,9 @@ def setInput(inName, inpDir, outDir):
if outDir == "":
outDir = "."

inName = f"{inpDir}/{inName}"
outName = f"{outDir}/{filename}"

template = """[Files]
title = Input Test
stepFile = {}
geometryName = {}
[Parameters]
compSolids = False
volCARD = False
volSDEF = True
voidGen = True
dummyMat = True
minVoidSize = 100
cellSummaryFile = False
cellCommentFile = False
debug = False
simplify = full
[Options]
forceCylinder = False
splitTolerance = 0
newSplitPlane = True
nPlaneReverse = 0
""".format(
inName, outName
)

with open(file="config.ini", mode="w", encoding="utf-8") as outfile:
outfile.write(template)
return f'{inpDir}/{inName}', f'{outDir}/{filename}'




def getInputList(folder, ext=None):
Expand Down Expand Up @@ -151,12 +154,23 @@ def printResults(f, res, lost):
print(line)


def mkGEOInp(inpDir, outDir):
for f in getInputList(inpDir, ("stp", "step")):
setInput(f, inpDir, outDir)
GEO = CadToCsg()
GEO.set_configuration(inifile)
GEO.Start()
def mkGEOInp(inpDir, outDir, file=None):
sets, opts, exp = setInputs()
if file is None:
files = getInputList(inpDir, ("stp", "step"))
else:
files = (file,)

for f in files:
inFile, outFile = getNames(f,inpDir,outDir)
exp['geometryName'] = outFile

print('translate: ',inFile)
print('translate: ',outFile)
GEO = CadToCsg(settings = sets, options = opts)
GEO.load_step_file(inFile)
GEO.start()
GEO.export_csg(**exp)
del GEO


Expand Down

0 comments on commit bf250dc

Please sign in to comment.