From 44782e3e66f038be8e8eb5b643422fdfe3c4b781 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 22 Apr 2024 16:54:13 +0100 Subject: [PATCH 1/5] changed single file from package to relative imports --- src/GEOUNED/Cuboid/translate.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/GEOUNED/Cuboid/translate.py b/src/GEOUNED/Cuboid/translate.py index 863c4443..db9d2c16 100644 --- a/src/GEOUNED/Cuboid/translate.py +++ b/src/GEOUNED/Cuboid/translate.py @@ -1,12 +1,11 @@ -from GEOUNED.Utils.booleanFunction import BoolSequence -import GEOUNED.Utils.Geometry_GU as GU -from GEOUNED.Utils.BasicFunctions_part1 \ - import isParallel, isOposite -import GEOUNED.Utils.BasicFunctions_part2 as BF -import GEOUNED.Decompose.Decom_one as Decom -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt import FreeCAD,Part +from ..Utils.booleanFunction import BoolSequence +from ..Utils import Geometry_GU as GU +from ..Utils.BasicFunctions_part1 import isParallel, isOposite +from ..Utils import BasicFunctions_part2 as BF +from ..Decompose import Decom_one as Decom +from ..Utils.Options.Classes import Tolerances as tol +from ..Utils.Options.Classes import Options as opt def commonEdge(face1,face2): From 3ca760fe407442394fa84bb26df5421b666289c1 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 22 Apr 2024 17:12:25 +0100 Subject: [PATCH 2/5] 2nd file converted to relative imports --- src/GEOUNED/Conversion/CellDefinition.py | 25 +++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/GEOUNED/Conversion/CellDefinition.py b/src/GEOUNED/Conversion/CellDefinition.py index 1e2cda97..681560c1 100644 --- a/src/GEOUNED/Conversion/CellDefinition.py +++ b/src/GEOUNED/Conversion/CellDefinition.py @@ -1,21 +1,18 @@ ############################ # Module for Cell definiton # ############################# -import FreeCAD, Part -from GEOUNED.Utils.Functions import GEOUNED_Surface -from GEOUNED.Utils.BasicFunctions_part1 \ - import isParallel, isOposite, isInLine, signPlane, isSameValue -from GEOUNED.Utils.booleanFunction import BoolSequence, insertInSequence - -import GEOUNED.Utils.BasicFunctions_part2 as BF -import GEOUNED.Utils.Functions as UF -import GEOUNED.Utils.Qform as QF -import GEOUNED.Utils.Geometry_GU as GU -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.Utils.BooleanSolids import buildCTableFromSolids,removeExtraSurfaces import math -from collections import OrderedDict +import FreeCAD, Part +from ..Utils.Functions import GEOUNED_Surface +from ..Utils.BasicFunctions_part1 import isParallel, isOposite, isInLine, signPlane, isSameValue +from ..Utils.booleanFunction import BoolSequence, insertInSequence +from ..Utils import BasicFunctions_part2 as BF +from ..Utils import Functions as UF +from ..Utils import Geometry_GU as GU +from ..Utils.Options.Classes import Tolerances as tol +from ..Utils.Options.Classes import Options as opt +from ..Utils.BooleanSolids import buildCTableFromSolids,removeExtraSurfaces + def getId(facein, Surfaces): From 521b82aa7e895fb5977c4da08659005e9941056e Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 22 Apr 2024 17:19:03 +0100 Subject: [PATCH 3/5] converted more fiels to relative import --- src/GEOUNED/Decompose/Decom_one.py | 20 +++++++++----------- src/GEOUNED/LoadFile/LoadFunctions.py | 4 ++-- src/GEOUNED/LoadFile/LoadSTEP.py | 8 ++++---- src/GEOUNED/Utils/Options/__init__.py | 3 +-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/GEOUNED/Decompose/Decom_one.py b/src/GEOUNED/Decompose/Decom_one.py index 80ca97c2..42858359 100644 --- a/src/GEOUNED/Decompose/Decom_one.py +++ b/src/GEOUNED/Decompose/Decom_one.py @@ -2,18 +2,16 @@ # Only one solid and planar surfaces # -import FreeCAD, Part -import GEOUNED.Utils.Functions as UF -import GEOUNED.Utils.Geometry_GU as GU -import GEOUNED.Conversion.CellDefinition as CD -from collections import OrderedDict -from GEOUNED.Utils.BasicFunctions_part1 import isParallel, isSameValue,\ - isInLine, isInPlane -from GEOUNED.Utils.BasicFunctions_part2 import isDuplicateInList -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt import math -import copy +from collections import OrderedDict +import FreeCAD, Part +from ..Utils import Functions as UF +from ..Utils import Geometry_GU as GU +from ..Conversion import CellDefinition as CD +from ..Utils.BasicFunctions_part1 import isParallel, isSameValue, isInLine, isInPlane +from ..Utils.BasicFunctions_part2 import isDuplicateInList +from ..Utils.Options.Classes import Tolerances as tol +from ..Utils.Options.Classes import Options as opt twoPi = math.pi*2 diff --git a/src/GEOUNED/LoadFile/LoadFunctions.py b/src/GEOUNED/LoadFile/LoadFunctions.py index 8225fd09..21a4dc23 100644 --- a/src/GEOUNED/LoadFile/LoadFunctions.py +++ b/src/GEOUNED/LoadFile/LoadFunctions.py @@ -1,7 +1,7 @@ import re import FreeCAD -from GEOUNED.Utils.Functions import GEOUNED_Solid -from GEOUNED.Utils.Options.Classes import Options as opt +from ..Utils.Functions import GEOUNED_Solid +from ..Utils.Options.Classes import Options as opt def GetLabel(label): diff --git a/src/GEOUNED/LoadFile/LoadSTEP.py b/src/GEOUNED/LoadFile/LoadSTEP.py index 59dd8990..cdc9c4f3 100644 --- a/src/GEOUNED/LoadFile/LoadSTEP.py +++ b/src/GEOUNED/LoadFile/LoadSTEP.py @@ -1,12 +1,12 @@ # # Module to load a STEP file # +import os +import re import FreeCAD, Part from FreeCAD import Import -import re -import os.path -import GEOUNED.Utils.Functions as UF -import GEOUNED.LoadFile.LoadFunctions as LF +from ..Utils import Functions as UF +from ..LoadFile import LoadFunctions as LF # Paco mod diff --git a/src/GEOUNED/Utils/Options/__init__.py b/src/GEOUNED/Utils/Options/__init__.py index f6437a78..7954e096 100644 --- a/src/GEOUNED/Utils/Options/__init__.py +++ b/src/GEOUNED/Utils/Options/__init__.py @@ -1,5 +1,4 @@ -import os.path -from GEOUNED.Utils.Options.Classes import Options, Tolerances, MCNP_numeric_format +from .Classes import Options, Tolerances, MCNP_numeric_format #default options values forceCylinder = True # Force using cylinders instead cones for auxillary surfaces of torus surface definition From 583916f42e5624f322e38be56207be5b80d3b715 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 22 Apr 2024 17:47:49 +0100 Subject: [PATCH 4/5] relative imports everywhere --- src/GEOReverse/Modules/MCNPinput.py | 9 +++--- src/GEOReverse/Modules/Objects.py | 11 +++---- src/GEOReverse/Modules/Parser/parser.py | 2 +- src/GEOReverse/Modules/Utils/BooleanSolids.py | 5 ++- src/GEOReverse/Modules/XMLParser.py | 2 +- src/GEOReverse/Modules/XMLinput.py | 6 ++-- src/GEOReverse/Modules/buildCAD.py | 6 ++-- src/GEOReverse/Modules/buildSolidCell.py | 14 +++----- src/GEOReverse/Modules/processInp.py | 2 +- src/GEOReverse/Modules/remh.py | 1 - src/GEOReverse/Modules/splitFunction.py | 4 +-- src/GEOReverse/reverse.py | 16 ++++------ src/GEOUNED/LoadFile/LoadSTEP.py | 3 +- src/GEOUNED/Utils/BasicFunctions_part1.py | 2 +- src/GEOUNED/Utils/BasicFunctions_part2.py | 7 ++-- src/GEOUNED/Utils/BooleanSolids.py | 9 +++--- src/GEOUNED/Utils/Functions.py | 15 ++++----- src/GEOUNED/Utils/Geometry_GU.py | 8 ++--- src/GEOUNED/Utils/booleanFunction.py | 1 + src/GEOUNED/Void/Void.py | 14 ++++---- src/GEOUNED/Void/VoidBoxClass.py | 15 ++++----- src/GEOUNED/Write/Functions.py | 16 +++++----- src/GEOUNED/Write/MCNPFormat.py | 17 ++++------ src/GEOUNED/Write/OpenMCFormat.py | 13 +++----- src/GEOUNED/Write/PHITSFormat.py | 18 ++++------- src/GEOUNED/Write/SerpentFormat.py | 17 ++++------ src/GEOUNED/Write/WriteFiles.py | 10 +++--- src/GEOUNED/__init__.py | 32 ++++++++----------- 28 files changed, 115 insertions(+), 160 deletions(-) diff --git a/src/GEOReverse/Modules/MCNPinput.py b/src/GEOReverse/Modules/MCNPinput.py index fcc53bb0..1ed6fe70 100644 --- a/src/GEOReverse/Modules/MCNPinput.py +++ b/src/GEOReverse/Modules/MCNPinput.py @@ -1,13 +1,12 @@ +import math import os -import sys import re import FreeCAD -from GEOReverse.Modules.Parser import parser as mp -from GEOReverse.Modules.remh import cell_card_string, remove_hash -from GEOReverse.Modules.Objects import * -import math import numpy as np from numpy import linalg as LA +from .Parser import parser as mp +from .remh import cell_card_string, remove_hash +from .Objects import * class MCNPinput: def __init__(self,name): diff --git a/src/GEOReverse/Modules/Objects.py b/src/GEOReverse/Modules/Objects.py index bfcdaf61..b7ee1881 100644 --- a/src/GEOReverse/Modules/Objects.py +++ b/src/GEOReverse/Modules/Objects.py @@ -1,10 +1,9 @@ -from GEOReverse.Modules.buildSolidCell import BuildSolid -import FreeCAD, Part -import numpy as np import math -from GEOReverse.Modules.remh import cline -from GEOReverse.Modules.Utils.booleanFunction import outterTerms,BoolSequence -from GEOReverse.Modules.Utils.BooleanSolids import buildCTableFromSolids +import numpy as np +import FreeCAD, Part +from .buildSolidCell import BuildSolid +from .remh import cline +from .Utils.booleanFunction import outterTerms,BoolSequence class CADCell: def __init__(self,stringCell=None): diff --git a/src/GEOReverse/Modules/Parser/parser.py b/src/GEOReverse/Modules/Parser/parser.py index 6c4bec26..7826858b 100644 --- a/src/GEOReverse/Modules/Parser/parser.py +++ b/src/GEOReverse/Modules/Parser/parser.py @@ -7,7 +7,7 @@ import re import warnings import os -from GEOReverse.Modules.Parser.PartialFormatter import PartialFormatter +from .PartialFormatter import PartialFormatter version = '3.6' diff --git a/src/GEOReverse/Modules/Utils/BooleanSolids.py b/src/GEOReverse/Modules/Utils/BooleanSolids.py index def406cf..f35ca752 100644 --- a/src/GEOReverse/Modules/Utils/BooleanSolids.py +++ b/src/GEOReverse/Modules/Utils/BooleanSolids.py @@ -2,11 +2,10 @@ # Conversion to MCNP v0.0 # Only one solid and planar surfaces # +import math import FreeCAD import BOPTools.SplitAPI -import math -import re -from GEOReverse.Modules.Utils.booleanFunction import BoolSequence +from .booleanFunction import BoolSequence BoolVals = (None,True,False) diff --git a/src/GEOReverse/Modules/XMLParser.py b/src/GEOReverse/Modules/XMLParser.py index 20113b3b..2b11cb2d 100644 --- a/src/GEOReverse/Modules/XMLParser.py +++ b/src/GEOReverse/Modules/XMLParser.py @@ -1,4 +1,4 @@ -from GEOReverse.Modules.remh import cline +from .remh import cline class cellCARD: diff --git a/src/GEOReverse/Modules/XMLinput.py b/src/GEOReverse/Modules/XMLinput.py index a28ab1dd..2e7ed68e 100644 --- a/src/GEOReverse/Modules/XMLinput.py +++ b/src/GEOReverse/Modules/XMLinput.py @@ -1,10 +1,8 @@ import os -import sys import re import FreeCAD -from GEOReverse.Modules.remh import cell_card_string, remove_hash -from GEOReverse.Modules.Objects import * -from GEOReverse.Modules.XMLParser import get_cards +from .Objects import * +from .XMLParser import get_cards import math import numpy as np from numpy import linalg as LA diff --git a/src/GEOReverse/Modules/buildCAD.py b/src/GEOReverse/Modules/buildCAD.py index aadcadf0..d91cadbb 100644 --- a/src/GEOReverse/Modules/buildCAD.py +++ b/src/GEOReverse/Modules/buildCAD.py @@ -1,8 +1,6 @@ -import FreeCAD, Part import BOPTools.SplitAPI -from GEOReverse.Modules.buildSolidCell import FuseSolid -from GEOReverse.Modules.Utils.BooleanSolids import buildCTableFromSolids -from GEOReverse.Modules.Utils.booleanFunction import BoolSequence +from .buildSolidCell import FuseSolid +from .Utils.booleanFunction import BoolSequence diff --git a/src/GEOReverse/Modules/buildSolidCell.py b/src/GEOReverse/Modules/buildSolidCell.py index dbd524bf..37be4e6d 100644 --- a/src/GEOReverse/Modules/buildSolidCell.py +++ b/src/GEOReverse/Modules/buildSolidCell.py @@ -1,13 +1,7 @@ -import FreeCAD, Part -import BOPTools.SplitAPI -from BOPTools import GeneralFuseResult as GFR -from GEOReverse.Modules.Utils.booleanFunction import BoolSequence -from GEOReverse.Modules.splitFunction import SplitSolid,splitBase,joinBase -from GEOReverse.Modules.Utils.BooleanSolids import buildCTableFromSolids -from GEOReverse.Modules.options import Options - -import math - +import Part +from .Utils.booleanFunction import BoolSequence +from .splitFunction import SplitSolid,splitBase,joinBase +from .options import Options def getPart(slist): sol = [] diff --git a/src/GEOReverse/Modules/processInp.py b/src/GEOReverse/Modules/processInp.py index a15036ef..729c24f1 100644 --- a/src/GEOReverse/Modules/processInp.py +++ b/src/GEOReverse/Modules/processInp.py @@ -1,5 +1,5 @@ import configparser -from GEOReverse.Modules.options import Options +from .options import Options def setOptions(optionFile): diff --git a/src/GEOReverse/Modules/remh.py b/src/GEOReverse/Modules/remh.py index 39df3f78..197379fd 100644 --- a/src/GEOReverse/Modules/remh.py +++ b/src/GEOReverse/Modules/remh.py @@ -1,4 +1,3 @@ -import sys import re import math diff --git a/src/GEOReverse/Modules/splitFunction.py b/src/GEOReverse/Modules/splitFunction.py index 4b5902a7..61b318c7 100644 --- a/src/GEOReverse/Modules/splitFunction.py +++ b/src/GEOReverse/Modules/splitFunction.py @@ -1,8 +1,6 @@ +import math import FreeCAD,Part import BOPTools.SplitAPI -from GEOReverse.Modules.Utils.booleanFunction import outterTerms -import math - class splitBase: def __init__(self,base,knownSurf={}): diff --git a/src/GEOReverse/reverse.py b/src/GEOReverse/reverse.py index cba945c1..a63aef3f 100644 --- a/src/GEOReverse/reverse.py +++ b/src/GEOReverse/reverse.py @@ -1,12 +1,10 @@ -import sys -import FreeCAD, Part, Import - -from GEOReverse.Modules.MCNPinput import MCNPinput -from GEOReverse.Modules.XMLinput import XMLinput -from GEOReverse.Modules.buildCAD import buildCAD,makeTree -from GEOReverse.Modules.Objects import CADCell -from GEOReverse.Modules.processInp import setOptions -from GEOReverse.CodeVersion import * +import FreeCAD, Import +from .Modules.MCNPinput import MCNPinput +from .Modules.XMLinput import XMLinput +from .Modules.buildCAD import buildCAD,makeTree +from .Modules.Objects import CADCell +from .Modules.processInp import setOptions +from .CodeVersion import * def reverse(optFile='configRevese.ini') : diff --git a/src/GEOUNED/LoadFile/LoadSTEP.py b/src/GEOUNED/LoadFile/LoadSTEP.py index cdc9c4f3..b72744f4 100644 --- a/src/GEOUNED/LoadFile/LoadSTEP.py +++ b/src/GEOUNED/LoadFile/LoadSTEP.py @@ -6,8 +6,7 @@ import FreeCAD, Part from FreeCAD import Import from ..Utils import Functions as UF -from ..LoadFile import LoadFunctions as LF - +from . import LoadFunctions as LF # Paco mod def extractMaterials(filename): diff --git a/src/GEOUNED/Utils/BasicFunctions_part1.py b/src/GEOUNED/Utils/BasicFunctions_part1.py index 0ade2170..1327b32f 100644 --- a/src/GEOUNED/Utils/BasicFunctions_part1.py +++ b/src/GEOUNED/Utils/BasicFunctions_part1.py @@ -1,8 +1,8 @@ # # Set of useful functions used in different parts of the code # -import FreeCAD import math +import FreeCAD def isSameValue(v1,v2,tolerance=1e-6): return abs(v1-v2) < tolerance diff --git a/src/GEOUNED/Utils/BasicFunctions_part2.py b/src/GEOUNED/Utils/BasicFunctions_part2.py index a0c79fc3..99af69c3 100644 --- a/src/GEOUNED/Utils/BasicFunctions_part2.py +++ b/src/GEOUNED/Utils/BasicFunctions_part2.py @@ -1,11 +1,10 @@ # # Set of useful functions used in different parts of the code # -from GEOUNED.Utils.BasicFunctions_part1 \ - import isParallel, isOposite,isSameValue, isInTolerance, isInLine, isInPlane -from GEOUNED.Write.Functions import MCNPSurface -import FreeCAD import math +import FreeCAD +from ..Utils.BasicFunctions_part1 import isParallel, isOposite,isSameValue, isInTolerance, isInLine, isInPlane +from ..Write.Functions import MCNPSurface sameSurfFic = open('fuzzySurfaces','w') diff --git a/src/GEOUNED/Utils/BooleanSolids.py b/src/GEOUNED/Utils/BooleanSolids.py index 2c099108..67b5b6f8 100644 --- a/src/GEOUNED/Utils/BooleanSolids.py +++ b/src/GEOUNED/Utils/BooleanSolids.py @@ -2,12 +2,11 @@ # Conversion to MCNP v0.0 # Only one solid and planar surfaces # -import FreeCAD import math -import re -from GEOUNED.Utils.Functions import GEOUNED_Surface, splitBOP -from GEOUNED.Utils.booleanFunction import BoolSequence -from GEOUNED.Utils.Options.Classes import Options as opt +import FreeCAD +from ..Utils.Functions import GEOUNED_Surface, splitBOP +from ..Utils.booleanFunction import BoolSequence +from ..Utils.Options.Classes import Options as opt BoolVals = (None,True,False) diff --git a/src/GEOUNED/Utils/Functions.py b/src/GEOUNED/Utils/Functions.py index f6b8dea3..18707d87 100644 --- a/src/GEOUNED/Utils/Functions.py +++ b/src/GEOUNED/Utils/Functions.py @@ -1,16 +1,15 @@ # # Set of useful functions used in different parts of the code # -import BOPTools.SplitAPI -import GEOUNED.Utils.BasicFunctions_part2 as BF -from GEOUNED.Utils.BasicFunctions_part1 import isParallel,\ - Plane3PtsParams, PlaneParams, CylinderParams, ConeParams, SphereParams, TorusParams -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options -import copy -import FreeCAD, Part import math import numpy as np +import BOPTools.SplitAPI +import FreeCAD, Part +from . import BasicFunctions_part2 as BF +from ..Utils.BasicFunctions_part1 import isParallel,\ + Plane3PtsParams, PlaneParams, CylinderParams, ConeParams, SphereParams, TorusParams +from ..Utils.Options.Classes import Tolerances as tol +from ..Utils.Options.Classes import Options def getBox(comp): diff --git a/src/GEOUNED/Utils/Geometry_GU.py b/src/GEOUNED/Utils/Geometry_GU.py index ddd4ac5a..922e4d46 100644 --- a/src/GEOUNED/Utils/Geometry_GU.py +++ b/src/GEOUNED/Utils/Geometry_GU.py @@ -1,11 +1,11 @@ # # definition of GEOUNED objects to release memory # -import FreeCAD, Part import math -from GEOUNED.Utils.BasicFunctions_part1 import isSameValue -from GEOUNED.Utils.BasicFunctions_part2 import isSameTorus -from GEOUNED.Utils.Options.Classes import Tolerances as tol +import Part +from .BasicFunctions_part1 import isSameValue +from .BasicFunctions_part2 import isSameTorus +from ..Utils.Options.Classes import Tolerances as tol # SURFACES class Surfaces_GU(object): diff --git a/src/GEOUNED/Utils/booleanFunction.py b/src/GEOUNED/Utils/booleanFunction.py index 4c679157..4691cbb2 100644 --- a/src/GEOUNED/Utils/booleanFunction.py +++ b/src/GEOUNED/Utils/booleanFunction.py @@ -1,4 +1,5 @@ import re + mostinner=re.compile(r"\([^\(^\)]*\)") # identify most inner parentheses number =re.compile(r"(?P[-+]?\d+)") mix =re.compile(r"(?P([-+]?\d+|\[0+\]))") diff --git a/src/GEOUNED/Void/Void.py b/src/GEOUNED/Void/Void.py index d729f0f6..1438c031 100644 --- a/src/GEOUNED/Void/Void.py +++ b/src/GEOUNED/Void/Void.py @@ -1,11 +1,11 @@ -from GEOUNED.Void.VoidBoxClass import VoidBox -from GEOUNED.Utils.BasicFunctions_part1 import isOposite -from GEOUNED.Utils.Functions import GEOUNED_Solid, GEOUNED_Surface -from GEOUNED.Utils.booleanFunction import BoolSequence -from GEOUNED.Utils.Options.Classes import Options as opt -import GEOUNED.LoadFile.LoadFunctions as LF -import GEOUNED.Void.voidFunctions as VF import FreeCAD, Part +from .VoidBoxClass import VoidBox +from ..Utils.BasicFunctions_part1 import isOposite +from ..Utils.Functions import GEOUNED_Solid, GEOUNED_Surface +from ..Utils.booleanFunction import BoolSequence +from ..Utils.Options.Classes import Options as opt +from ..LoadFile import LoadFunctions as LF +from ..Void import voidFunctions as VF def voidGeneration(MetaList,EnclosureList,Surfaces,UniverseBox,setting,init): voidList = [] diff --git a/src/GEOUNED/Void/VoidBoxClass.py b/src/GEOUNED/Void/VoidBoxClass.py index 51cc9a00..6e67c5f8 100644 --- a/src/GEOUNED/Void/VoidBoxClass.py +++ b/src/GEOUNED/Void/VoidBoxClass.py @@ -1,14 +1,13 @@ """File with the VoidBox class""" import FreeCAD import Part -import GEOUNED.Decompose.Decom_one as Decom -import GEOUNED.Conversion.CellDefinition as Conv - -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.Utils.BasicFunctions_part1 import isOposite -from GEOUNED.Utils.Functions import GEOUNED_Solid, GEOUNED_Surface -from GEOUNED.Utils.booleanFunction import BoolSequence -from GEOUNED.Utils.BooleanSolids import buildCTableFromSolids, removeExtraSurfaces +from ..Decompose import Decom_one as Decom +from ..Conversion import CellDefinition as Conv +from ..Utils.Options.Classes import Options as opt +from ..Utils.BasicFunctions_part1 import isOposite +from ..Utils.Functions import GEOUNED_Solid, GEOUNED_Surface +from ..Utils.booleanFunction import BoolSequence +from ..Utils.BooleanSolids import buildCTableFromSolids, removeExtraSurfaces class VoidBox (): diff --git a/src/GEOUNED/Write/Functions.py b/src/GEOUNED/Write/Functions.py index cebc945e..90cec5d9 100644 --- a/src/GEOUNED/Write/Functions.py +++ b/src/GEOUNED/Write/Functions.py @@ -1,13 +1,13 @@ -import GEOUNED.Utils.Qform as Qform -from GEOUNED.Utils.BasicFunctions_part1 import isParallel, isOposite -from GEOUNED.Utils.Options.Classes import MCNP_numeric_format as nf -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.Write.StringFunctions import remove_redundant - -import FreeCAD import math import re +import FreeCAD +from ..Utils import Qform as Qform +from ..Utils.BasicFunctions_part1 import isParallel, isOposite +from ..Utils.Options.Classes import MCNP_numeric_format as nf +from ..Utils.Options.Classes import Tolerances as tol +from ..Utils.Options.Classes import Options as opt +from .StringFunctions import remove_redundant + class CardLine : def __init__(self,card,linesize=80,tabspace=6,fmt=''): diff --git a/src/GEOUNED/Write/MCNPFormat.py b/src/GEOUNED/Write/MCNPFormat.py index 73e5a8ce..02b3462b 100644 --- a/src/GEOUNED/Write/MCNPFormat.py +++ b/src/GEOUNED/Write/MCNPFormat.py @@ -1,19 +1,14 @@ ############################## # Module to write MCNP input # ############################## +import math from datetime import datetime - -from GEOUNED.Utils.Functions import Surfaces_dict -from GEOUNED.Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite -from GEOUNED.Write.Functions import MCNPSurface, changeSurfSign, writeMCNPCellDef,CardLine -from GEOUNED.Utils.Options.Classes import MCNP_numeric_format as nf -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.CodeVersion import * import FreeCAD -import copy -import math -import re +from ..Utils.Functions import Surfaces_dict +from ..Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite +from .Functions import MCNPSurface, changeSurfSign, writeMCNPCellDef,CardLine +from ..Utils.Options.Classes import Options as opt +from ..CodeVersion import * class MCNP_input: def __init__(self,Meta,Surfaces,setting) : diff --git a/src/GEOUNED/Write/OpenMCFormat.py b/src/GEOUNED/Write/OpenMCFormat.py index 469a4cd8..b2a9d461 100644 --- a/src/GEOUNED/Write/OpenMCFormat.py +++ b/src/GEOUNED/Write/OpenMCFormat.py @@ -1,17 +1,12 @@ ############################## # Module to write MCNP input # ############################## -from datetime import datetime -from GEOUNED.Utils.Functions import Surfaces_dict -from GEOUNED.Write.Functions import OpenMCSurface, changeSurfSign, writeOpenMCregion,CardLine -from GEOUNED.Utils.Options.Classes import MCNP_numeric_format as nf -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.CodeVersion import * import FreeCAD -import copy -import math -import re +from ..Utils.Functions import Surfaces_dict +from .Functions import OpenMCSurface, changeSurfSign, writeOpenMCregion +from ..Utils.Options.Classes import Options as opt +from ..CodeVersion import * class OpenMC_input: def __init__(self,Meta,Surfaces,setting) : diff --git a/src/GEOUNED/Write/PHITSFormat.py b/src/GEOUNED/Write/PHITSFormat.py index a895bb62..d59b9be5 100644 --- a/src/GEOUNED/Write/PHITSFormat.py +++ b/src/GEOUNED/Write/PHITSFormat.py @@ -11,19 +11,15 @@ # 5. Eliminated the only MCNP related parts # 6. Added some comments to remind +import re from datetime import datetime -from GEOUNED.Utils.Functions import Surfaces_dict -from GEOUNED.Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite -from GEOUNED.Write.Functions import PHITSSurface, changeSurfSign, writePHITSCellDef,CardLine,CellString -from GEOUNED.Utils.Options.Classes import MCNP_numeric_format as nf -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.CodeVersion import * import FreeCAD -import copy -import math -import re -import os +from ..Utils.Functions import Surfaces_dict +from ..Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite +from ..Write.Functions import PHITSSurface, changeSurfSign, writePHITSCellDef,CellString +from ..Utils.Options.Classes import Options as opt +from ..CodeVersion import * + class PHITS_input: def __init__(self,Meta,Surfaces,setting) : diff --git a/src/GEOUNED/Write/SerpentFormat.py b/src/GEOUNED/Write/SerpentFormat.py index 5462e866..6c37fe99 100644 --- a/src/GEOUNED/Write/SerpentFormat.py +++ b/src/GEOUNED/Write/SerpentFormat.py @@ -2,18 +2,13 @@ # Module to write Serpent input # ################################# from datetime import datetime - -from GEOUNED.Utils.Functions import Surfaces_dict -from GEOUNED.Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite -from GEOUNED.Write.Functions import SerpentSurface, changeSurfSign, writeSerpentCellDef,CardLine -from GEOUNED.Utils.Options.Classes import MCNP_numeric_format as nf -from GEOUNED.Utils.Options.Classes import Tolerances as tol -from GEOUNED.Utils.Options.Classes import Options as opt -from GEOUNED.CodeVersion import * import FreeCAD -import copy -import math -import re +from ..Utils.Functions import Surfaces_dict +from ..Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite +from .Functions import SerpentSurface, changeSurfSign, writeSerpentCellDef +from ..Utils.Options.Classes import Options as opt +from ..CodeVersion import * + class Serpent_input: def __init__(self,Meta,Surfaces,setting) : diff --git a/src/GEOUNED/Write/WriteFiles.py b/src/GEOUNED/Write/WriteFiles.py index 954d433f..3c296bf0 100644 --- a/src/GEOUNED/Write/WriteFiles.py +++ b/src/GEOUNED/Write/WriteFiles.py @@ -1,8 +1,8 @@ -import GEOUNED.Write.AdditionalFiles as OutFiles -from GEOUNED.Write.MCNPFormat import MCNP_input -from GEOUNED.Write.OpenMCFormat import OpenMC_input -from GEOUNED.Write.SerpentFormat import Serpent_input -from GEOUNED.Write.PHITSFormat import PHITS_input +from . import AdditionalFiles as OutFiles +from .MCNPFormat import MCNP_input +from .OpenMCFormat import OpenMC_input +from .SerpentFormat import Serpent_input +from .PHITSFormat import PHITS_input def writeGeometry(UniverseBox,MetaList,Surfaces,code_setting): diff --git a/src/GEOUNED/__init__.py b/src/GEOUNED/__init__.py index 9ca60786..73eeb362 100644 --- a/src/GEOUNED/__init__.py +++ b/src/GEOUNED/__init__.py @@ -2,7 +2,7 @@ # # We load the STEP and the materials -import sys + # this try except attempts to import freecad (lowercase) which is the conda # package name for FreeCAD (mixed case) upon import the conda package appends # the sys path for Conda installed FreeCAD, consequently FreeCAD can then be @@ -11,25 +11,21 @@ import freecad except: pass -import FreeCAD,Part import configparser - -from os import path,mkdir +from os import path, mkdir from datetime import datetime - - -import GEOUNED.LoadFile.LoadSTEP as Load -import GEOUNED.Decompose.Decom_one as Decom -import GEOUNED.Utils.Functions as UF -import GEOUNED.Conversion.CellDefinition as Conv -from GEOUNED.Write.Functions import writeMCNPCellDef -from GEOUNED.Write.WriteFiles import writeGeometry -from GEOUNED.CodeVersion import * -from GEOUNED.Utils.Options.Classes import Tolerances, MCNP_numeric_format, Options -from GEOUNED.Utils.BooleanSolids import buildCTableFromSolids -from GEOUNED.Cuboid.translate import translate - -import GEOUNED.Void.Void as Void +import FreeCAD, Part +from .LoadFile import LoadSTEP as Load +from .Decompose import Decom_one as Decom +from .Utils import Functions as UF +from .Conversion import CellDefinition as Conv +from .Write.Functions import writeMCNPCellDef +from .Write.WriteFiles import writeGeometry +from .CodeVersion import * +from .Utils.Options.Classes import Tolerances, MCNP_numeric_format, Options +from .Utils.BooleanSolids import buildCTableFromSolids +from .Cuboid.translate import translate +from .Void import Void as Void class GEOUNED() : From a53e630eeb47a7b640b9c4c4020392db1cca231e Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 22 Apr 2024 19:45:17 +0100 Subject: [PATCH 5/5] isort on all imports --- src/GEOReverse/Modules/MCNPinput.py | 7 +++++-- src/GEOReverse/Modules/Objects.py | 8 +++++-- .../Modules/Parser/PartialFormatter.py | 1 + src/GEOReverse/Modules/Parser/parser.py | 3 ++- src/GEOReverse/Modules/Utils/BooleanSolids.py | 4 +++- .../Modules/Utils/booleanFunction.py | 1 + src/GEOReverse/Modules/XMLParser.py | 1 + src/GEOReverse/Modules/XMLinput.py | 11 ++++++---- src/GEOReverse/Modules/buildCAD.py | 2 +- src/GEOReverse/Modules/buildSolidCell.py | 6 ++++-- src/GEOReverse/Modules/processInp.py | 1 + src/GEOReverse/Modules/remh.py | 4 +--- src/GEOReverse/Modules/splitFunction.py | 5 ++++- src/GEOReverse/reverse.py | 12 ++++++----- src/GEOUNED/Conversion/CellDefinition.py | 18 +++++++++------- src/GEOUNED/Cuboid/translate.py | 14 +++++++------ src/GEOUNED/Decompose/Decom_one.py | 12 +++++++---- src/GEOUNED/LoadFile/LoadFunctions.py | 2 ++ src/GEOUNED/LoadFile/LoadSTEP.py | 6 +++++- src/GEOUNED/Utils/BasicFunctions_part1.py | 2 ++ src/GEOUNED/Utils/BasicFunctions_part2.py | 6 ++++-- src/GEOUNED/Utils/BooleanSolids.py | 7 ++++--- src/GEOUNED/Utils/Functions.py | 17 +++++++++------ src/GEOUNED/Utils/Geometry_GU.py | 5 ++++- src/GEOUNED/Utils/Options/__init__.py | 2 +- src/GEOUNED/Utils/Qform.py | 5 ++++- src/GEOUNED/Void/Void.py | 11 ++++++---- src/GEOUNED/Void/VoidBoxClass.py | 7 ++++--- src/GEOUNED/Write/Functions.py | 6 ++++-- src/GEOUNED/Write/MCNPFormat.py | 9 +++++--- src/GEOUNED/Write/OpenMCFormat.py | 6 ++++-- src/GEOUNED/Write/PHITSFormat.py | 9 +++++--- src/GEOUNED/Write/SerpentFormat.py | 8 ++++--- src/GEOUNED/Write/StringFunctions.py | 1 - src/GEOUNED/Write/WriteFiles.py | 7 ++++--- src/GEOUNED/__init__.py | 21 +++++++++++-------- 36 files changed, 160 insertions(+), 87 deletions(-) diff --git a/src/GEOReverse/Modules/MCNPinput.py b/src/GEOReverse/Modules/MCNPinput.py index 1ed6fe70..55a26bb4 100644 --- a/src/GEOReverse/Modules/MCNPinput.py +++ b/src/GEOReverse/Modules/MCNPinput.py @@ -1,12 +1,15 @@ import math import os import re + import FreeCAD import numpy as np from numpy import linalg as LA -from .Parser import parser as mp -from .remh import cell_card_string, remove_hash + from .Objects import * +from .Parser import parser as mp +from .remh import cell_card_string, remove_hash + class MCNPinput: def __init__(self,name): diff --git a/src/GEOReverse/Modules/Objects.py b/src/GEOReverse/Modules/Objects.py index b7ee1881..3bf72afb 100644 --- a/src/GEOReverse/Modules/Objects.py +++ b/src/GEOReverse/Modules/Objects.py @@ -1,9 +1,13 @@ import math + +import FreeCAD import numpy as np -import FreeCAD, Part +import Part + from .buildSolidCell import BuildSolid from .remh import cline -from .Utils.booleanFunction import outterTerms,BoolSequence +from .Utils.booleanFunction import BoolSequence, outterTerms + class CADCell: def __init__(self,stringCell=None): diff --git a/src/GEOReverse/Modules/Parser/PartialFormatter.py b/src/GEOReverse/Modules/Parser/PartialFormatter.py index f4d050cf..2b08e050 100644 --- a/src/GEOReverse/Modules/Parser/PartialFormatter.py +++ b/src/GEOReverse/Modules/Parser/PartialFormatter.py @@ -1,4 +1,5 @@ import string + version = '3.6' def make_label(item): diff --git a/src/GEOReverse/Modules/Parser/parser.py b/src/GEOReverse/Modules/Parser/parser.py index 7826858b..914e6379 100644 --- a/src/GEOReverse/Modules/Parser/parser.py +++ b/src/GEOReverse/Modules/Parser/parser.py @@ -4,9 +4,10 @@ Functions for parsing MCNP input files. """ +import os import re import warnings -import os + from .PartialFormatter import PartialFormatter version = '3.6' diff --git a/src/GEOReverse/Modules/Utils/BooleanSolids.py b/src/GEOReverse/Modules/Utils/BooleanSolids.py index f35ca752..2fcf28f2 100644 --- a/src/GEOReverse/Modules/Utils/BooleanSolids.py +++ b/src/GEOReverse/Modules/Utils/BooleanSolids.py @@ -3,8 +3,10 @@ # Only one solid and planar surfaces # import math -import FreeCAD + import BOPTools.SplitAPI +import FreeCAD + from .booleanFunction import BoolSequence BoolVals = (None,True,False) diff --git a/src/GEOReverse/Modules/Utils/booleanFunction.py b/src/GEOReverse/Modules/Utils/booleanFunction.py index 947b5dda..fd2d944b 100644 --- a/src/GEOReverse/Modules/Utils/booleanFunction.py +++ b/src/GEOReverse/Modules/Utils/booleanFunction.py @@ -1,4 +1,5 @@ import re + mostinner=re.compile(r"\([^\(^\)]*\)") # identify most inner parentheses number =re.compile(r"(?P[-+]?\d+)") mix =re.compile(r"(?P([-+]?\d+|\[0+\]))") diff --git a/src/GEOReverse/Modules/XMLParser.py b/src/GEOReverse/Modules/XMLParser.py index 2b11cb2d..55f7c0af 100644 --- a/src/GEOReverse/Modules/XMLParser.py +++ b/src/GEOReverse/Modules/XMLParser.py @@ -1,5 +1,6 @@ from .remh import cline + class cellCARD: def __init__(self,data): diff --git a/src/GEOReverse/Modules/XMLinput.py b/src/GEOReverse/Modules/XMLinput.py index 2e7ed68e..a801e557 100644 --- a/src/GEOReverse/Modules/XMLinput.py +++ b/src/GEOReverse/Modules/XMLinput.py @@ -1,12 +1,15 @@ +import math import os import re +import xml.etree.ElementTree as ET + import FreeCAD -from .Objects import * -from .XMLParser import get_cards -import math import numpy as np from numpy import linalg as LA -import xml.etree.ElementTree as ET + +from .Objects import * +from .XMLParser import get_cards + class XMLinput: def __init__(self,name): diff --git a/src/GEOReverse/Modules/buildCAD.py b/src/GEOReverse/Modules/buildCAD.py index d91cadbb..8a035948 100644 --- a/src/GEOReverse/Modules/buildCAD.py +++ b/src/GEOReverse/Modules/buildCAD.py @@ -1,9 +1,9 @@ import BOPTools.SplitAPI + from .buildSolidCell import FuseSolid from .Utils.booleanFunction import BoolSequence - def buildCAD(UnivCell,data,config): UniverseCut = True diff --git a/src/GEOReverse/Modules/buildSolidCell.py b/src/GEOReverse/Modules/buildSolidCell.py index 37be4e6d..78d579eb 100644 --- a/src/GEOReverse/Modules/buildSolidCell.py +++ b/src/GEOReverse/Modules/buildSolidCell.py @@ -1,7 +1,9 @@ import Part -from .Utils.booleanFunction import BoolSequence -from .splitFunction import SplitSolid,splitBase,joinBase + from .options import Options +from .splitFunction import SplitSolid, joinBase, splitBase +from .Utils.booleanFunction import BoolSequence + def getPart(slist): sol = [] diff --git a/src/GEOReverse/Modules/processInp.py b/src/GEOReverse/Modules/processInp.py index 729c24f1..3f300bb3 100644 --- a/src/GEOReverse/Modules/processInp.py +++ b/src/GEOReverse/Modules/processInp.py @@ -1,4 +1,5 @@ import configparser + from .options import Options diff --git a/src/GEOReverse/Modules/remh.py b/src/GEOReverse/Modules/remh.py index 197379fd..701b322b 100644 --- a/src/GEOReverse/Modules/remh.py +++ b/src/GEOReverse/Modules/remh.py @@ -1,7 +1,5 @@ -import re import math - - +import re ######################################### # define patterns to be found in string # diff --git a/src/GEOReverse/Modules/splitFunction.py b/src/GEOReverse/Modules/splitFunction.py index 61b318c7..8dbad941 100644 --- a/src/GEOReverse/Modules/splitFunction.py +++ b/src/GEOReverse/Modules/splitFunction.py @@ -1,6 +1,9 @@ import math -import FreeCAD,Part + import BOPTools.SplitAPI +import FreeCAD +import Part + class splitBase: def __init__(self,base,knownSurf={}): diff --git a/src/GEOReverse/reverse.py b/src/GEOReverse/reverse.py index a63aef3f..3b53505d 100644 --- a/src/GEOReverse/reverse.py +++ b/src/GEOReverse/reverse.py @@ -1,10 +1,12 @@ -import FreeCAD, Import +import FreeCAD +import Import + +from .CodeVersion import * +from .Modules.buildCAD import buildCAD, makeTree from .Modules.MCNPinput import MCNPinput -from .Modules.XMLinput import XMLinput -from .Modules.buildCAD import buildCAD,makeTree from .Modules.Objects import CADCell -from .Modules.processInp import setOptions -from .CodeVersion import * +from .Modules.processInp import setOptions +from .Modules.XMLinput import XMLinput def reverse(optFile='configRevese.ini') : diff --git a/src/GEOUNED/Conversion/CellDefinition.py b/src/GEOUNED/Conversion/CellDefinition.py index 681560c1..ca390815 100644 --- a/src/GEOUNED/Conversion/CellDefinition.py +++ b/src/GEOUNED/Conversion/CellDefinition.py @@ -2,16 +2,20 @@ # Module for Cell definiton # ############################# import math -import FreeCAD, Part -from ..Utils.Functions import GEOUNED_Surface -from ..Utils.BasicFunctions_part1 import isParallel, isOposite, isInLine, signPlane, isSameValue -from ..Utils.booleanFunction import BoolSequence, insertInSequence -from ..Utils import BasicFunctions_part2 as BF + +import FreeCAD +import Part + +from ..Utils import BasicFunctions_part2 as BF from ..Utils import Functions as UF from ..Utils import Geometry_GU as GU -from ..Utils.Options.Classes import Tolerances as tol +from ..Utils.BasicFunctions_part1 import (isInLine, isOposite, isParallel, + isSameValue, signPlane) +from ..Utils.booleanFunction import BoolSequence, insertInSequence +from ..Utils.BooleanSolids import buildCTableFromSolids, removeExtraSurfaces +from ..Utils.Functions import GEOUNED_Surface from ..Utils.Options.Classes import Options as opt -from ..Utils.BooleanSolids import buildCTableFromSolids,removeExtraSurfaces +from ..Utils.Options.Classes import Tolerances as tol def getId(facein, Surfaces): diff --git a/src/GEOUNED/Cuboid/translate.py b/src/GEOUNED/Cuboid/translate.py index db9d2c16..9db5881c 100644 --- a/src/GEOUNED/Cuboid/translate.py +++ b/src/GEOUNED/Cuboid/translate.py @@ -1,11 +1,13 @@ -import FreeCAD,Part -from ..Utils.booleanFunction import BoolSequence -from ..Utils import Geometry_GU as GU -from ..Utils.BasicFunctions_part1 import isParallel, isOposite -from ..Utils import BasicFunctions_part2 as BF +import FreeCAD +import Part + from ..Decompose import Decom_one as Decom -from ..Utils.Options.Classes import Tolerances as tol +from ..Utils import BasicFunctions_part2 as BF +from ..Utils import Geometry_GU as GU +from ..Utils.BasicFunctions_part1 import isOposite, isParallel +from ..Utils.booleanFunction import BoolSequence from ..Utils.Options.Classes import Options as opt +from ..Utils.Options.Classes import Tolerances as tol def commonEdge(face1,face2): diff --git a/src/GEOUNED/Decompose/Decom_one.py b/src/GEOUNED/Decompose/Decom_one.py index 42858359..f0f57bf3 100644 --- a/src/GEOUNED/Decompose/Decom_one.py +++ b/src/GEOUNED/Decompose/Decom_one.py @@ -4,14 +4,18 @@ import math from collections import OrderedDict -import FreeCAD, Part + +import FreeCAD +import Part + +from ..Conversion import CellDefinition as CD from ..Utils import Functions as UF from ..Utils import Geometry_GU as GU -from ..Conversion import CellDefinition as CD -from ..Utils.BasicFunctions_part1 import isParallel, isSameValue, isInLine, isInPlane +from ..Utils.BasicFunctions_part1 import (isInLine, isInPlane, isParallel, + isSameValue) from ..Utils.BasicFunctions_part2 import isDuplicateInList -from ..Utils.Options.Classes import Tolerances as tol from ..Utils.Options.Classes import Options as opt +from ..Utils.Options.Classes import Tolerances as tol twoPi = math.pi*2 diff --git a/src/GEOUNED/LoadFile/LoadFunctions.py b/src/GEOUNED/LoadFile/LoadFunctions.py index 21a4dc23..45c942b5 100644 --- a/src/GEOUNED/LoadFile/LoadFunctions.py +++ b/src/GEOUNED/LoadFile/LoadFunctions.py @@ -1,5 +1,7 @@ import re + import FreeCAD + from ..Utils.Functions import GEOUNED_Solid from ..Utils.Options.Classes import Options as opt diff --git a/src/GEOUNED/LoadFile/LoadSTEP.py b/src/GEOUNED/LoadFile/LoadSTEP.py index b72744f4..9deaa28b 100644 --- a/src/GEOUNED/LoadFile/LoadSTEP.py +++ b/src/GEOUNED/LoadFile/LoadSTEP.py @@ -3,11 +3,15 @@ # import os import re -import FreeCAD, Part + +import FreeCAD +import Part from FreeCAD import Import + from ..Utils import Functions as UF from . import LoadFunctions as LF + # Paco mod def extractMaterials(filename): rhoreal = [] diff --git a/src/GEOUNED/Utils/BasicFunctions_part1.py b/src/GEOUNED/Utils/BasicFunctions_part1.py index 1327b32f..0b455fa4 100644 --- a/src/GEOUNED/Utils/BasicFunctions_part1.py +++ b/src/GEOUNED/Utils/BasicFunctions_part1.py @@ -2,8 +2,10 @@ # Set of useful functions used in different parts of the code # import math + import FreeCAD + def isSameValue(v1,v2,tolerance=1e-6): return abs(v1-v2) < tolerance diff --git a/src/GEOUNED/Utils/BasicFunctions_part2.py b/src/GEOUNED/Utils/BasicFunctions_part2.py index 99af69c3..b80b322e 100644 --- a/src/GEOUNED/Utils/BasicFunctions_part2.py +++ b/src/GEOUNED/Utils/BasicFunctions_part2.py @@ -2,10 +2,12 @@ # Set of useful functions used in different parts of the code # import math + import FreeCAD -from ..Utils.BasicFunctions_part1 import isParallel, isOposite,isSameValue, isInTolerance, isInLine, isInPlane -from ..Write.Functions import MCNPSurface +from ..Utils.BasicFunctions_part1 import (isInLine, isInPlane, isInTolerance, + isOposite, isParallel, isSameValue) +from ..Write.Functions import MCNPSurface sameSurfFic = open('fuzzySurfaces','w') def Fuzzy(index,dtype,surf1,surf2,val,tol): diff --git a/src/GEOUNED/Utils/BooleanSolids.py b/src/GEOUNED/Utils/BooleanSolids.py index 67b5b6f8..60ab1380 100644 --- a/src/GEOUNED/Utils/BooleanSolids.py +++ b/src/GEOUNED/Utils/BooleanSolids.py @@ -3,11 +3,12 @@ # Only one solid and planar surfaces # import math + import FreeCAD -from ..Utils.Functions import GEOUNED_Surface, splitBOP -from ..Utils.booleanFunction import BoolSequence -from ..Utils.Options.Classes import Options as opt +from ..Utils.booleanFunction import BoolSequence +from ..Utils.Functions import GEOUNED_Surface, splitBOP +from ..Utils.Options.Classes import Options as opt BoolVals = (None,True,False) diff --git a/src/GEOUNED/Utils/Functions.py b/src/GEOUNED/Utils/Functions.py index 18707d87..f5a34f63 100644 --- a/src/GEOUNED/Utils/Functions.py +++ b/src/GEOUNED/Utils/Functions.py @@ -2,14 +2,19 @@ # Set of useful functions used in different parts of the code # import math -import numpy as np + import BOPTools.SplitAPI -import FreeCAD, Part -from . import BasicFunctions_part2 as BF -from ..Utils.BasicFunctions_part1 import isParallel,\ - Plane3PtsParams, PlaneParams, CylinderParams, ConeParams, SphereParams, TorusParams -from ..Utils.Options.Classes import Tolerances as tol +import FreeCAD +import numpy as np +import Part + +from ..Utils.BasicFunctions_part1 import (ConeParams, CylinderParams, + Plane3PtsParams, PlaneParams, + SphereParams, TorusParams, + isParallel) from ..Utils.Options.Classes import Options +from ..Utils.Options.Classes import Tolerances as tol +from . import BasicFunctions_part2 as BF def getBox(comp): diff --git a/src/GEOUNED/Utils/Geometry_GU.py b/src/GEOUNED/Utils/Geometry_GU.py index 922e4d46..769bab91 100644 --- a/src/GEOUNED/Utils/Geometry_GU.py +++ b/src/GEOUNED/Utils/Geometry_GU.py @@ -2,10 +2,13 @@ # definition of GEOUNED objects to release memory # import math + import Part + +from ..Utils.Options.Classes import Tolerances as tol from .BasicFunctions_part1 import isSameValue from .BasicFunctions_part2 import isSameTorus -from ..Utils.Options.Classes import Tolerances as tol + # SURFACES class Surfaces_GU(object): diff --git a/src/GEOUNED/Utils/Options/__init__.py b/src/GEOUNED/Utils/Options/__init__.py index 7954e096..8a43702e 100644 --- a/src/GEOUNED/Utils/Options/__init__.py +++ b/src/GEOUNED/Utils/Options/__init__.py @@ -1,4 +1,4 @@ -from .Classes import Options, Tolerances, MCNP_numeric_format +from .Classes import MCNP_numeric_format, Options, Tolerances #default options values forceCylinder = True # Force using cylinders instead cones for auxillary surfaces of torus surface definition diff --git a/src/GEOUNED/Utils/Qform.py b/src/GEOUNED/Utils/Qform.py index 792e912f..27ac1bf5 100644 --- a/src/GEOUNED/Utils/Qform.py +++ b/src/GEOUNED/Utils/Qform.py @@ -4,9 +4,12 @@ # # -import FreeCAD, Part import math +import FreeCAD +import Part + + def RotationMatrix(u,v): """ Definition of the rotation matrix for two vectors""" diff --git a/src/GEOUNED/Void/Void.py b/src/GEOUNED/Void/Void.py index 1438c031..c7805e33 100644 --- a/src/GEOUNED/Void/Void.py +++ b/src/GEOUNED/Void/Void.py @@ -1,11 +1,14 @@ -import FreeCAD, Part -from .VoidBoxClass import VoidBox +import FreeCAD +import Part + +from ..LoadFile import LoadFunctions as LF from ..Utils.BasicFunctions_part1 import isOposite -from ..Utils.Functions import GEOUNED_Solid, GEOUNED_Surface from ..Utils.booleanFunction import BoolSequence +from ..Utils.Functions import GEOUNED_Solid, GEOUNED_Surface from ..Utils.Options.Classes import Options as opt -from ..LoadFile import LoadFunctions as LF from ..Void import voidFunctions as VF +from .VoidBoxClass import VoidBox + def voidGeneration(MetaList,EnclosureList,Surfaces,UniverseBox,setting,init): voidList = [] diff --git a/src/GEOUNED/Void/VoidBoxClass.py b/src/GEOUNED/Void/VoidBoxClass.py index 6e67c5f8..9ead80e3 100644 --- a/src/GEOUNED/Void/VoidBoxClass.py +++ b/src/GEOUNED/Void/VoidBoxClass.py @@ -1,13 +1,14 @@ """File with the VoidBox class""" import FreeCAD import Part -from ..Decompose import Decom_one as Decom + from ..Conversion import CellDefinition as Conv -from ..Utils.Options.Classes import Options as opt +from ..Decompose import Decom_one as Decom from ..Utils.BasicFunctions_part1 import isOposite -from ..Utils.Functions import GEOUNED_Solid, GEOUNED_Surface from ..Utils.booleanFunction import BoolSequence from ..Utils.BooleanSolids import buildCTableFromSolids, removeExtraSurfaces +from ..Utils.Functions import GEOUNED_Solid, GEOUNED_Surface +from ..Utils.Options.Classes import Options as opt class VoidBox (): diff --git a/src/GEOUNED/Write/Functions.py b/src/GEOUNED/Write/Functions.py index 90cec5d9..4094aa47 100644 --- a/src/GEOUNED/Write/Functions.py +++ b/src/GEOUNED/Write/Functions.py @@ -1,11 +1,13 @@ import math import re + import FreeCAD + from ..Utils import Qform as Qform -from ..Utils.BasicFunctions_part1 import isParallel, isOposite +from ..Utils.BasicFunctions_part1 import isOposite, isParallel from ..Utils.Options.Classes import MCNP_numeric_format as nf -from ..Utils.Options.Classes import Tolerances as tol from ..Utils.Options.Classes import Options as opt +from ..Utils.Options.Classes import Tolerances as tol from .StringFunctions import remove_redundant diff --git a/src/GEOUNED/Write/MCNPFormat.py b/src/GEOUNED/Write/MCNPFormat.py index 02b3462b..4695198d 100644 --- a/src/GEOUNED/Write/MCNPFormat.py +++ b/src/GEOUNED/Write/MCNPFormat.py @@ -3,12 +3,15 @@ ############################## import math from datetime import datetime + import FreeCAD + +from ..CodeVersion import * +from ..Utils.BasicFunctions_part1 import isOposite, pointsToCoeffs from ..Utils.Functions import Surfaces_dict -from ..Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite -from .Functions import MCNPSurface, changeSurfSign, writeMCNPCellDef,CardLine from ..Utils.Options.Classes import Options as opt -from ..CodeVersion import * +from .Functions import CardLine, MCNPSurface, changeSurfSign, writeMCNPCellDef + class MCNP_input: def __init__(self,Meta,Surfaces,setting) : diff --git a/src/GEOUNED/Write/OpenMCFormat.py b/src/GEOUNED/Write/OpenMCFormat.py index b2a9d461..58e2afb5 100644 --- a/src/GEOUNED/Write/OpenMCFormat.py +++ b/src/GEOUNED/Write/OpenMCFormat.py @@ -3,10 +3,12 @@ ############################## import FreeCAD + +from ..CodeVersion import * from ..Utils.Functions import Surfaces_dict -from .Functions import OpenMCSurface, changeSurfSign, writeOpenMCregion from ..Utils.Options.Classes import Options as opt -from ..CodeVersion import * +from .Functions import OpenMCSurface, changeSurfSign, writeOpenMCregion + class OpenMC_input: def __init__(self,Meta,Surfaces,setting) : diff --git a/src/GEOUNED/Write/PHITSFormat.py b/src/GEOUNED/Write/PHITSFormat.py index d59b9be5..5740d9c4 100644 --- a/src/GEOUNED/Write/PHITSFormat.py +++ b/src/GEOUNED/Write/PHITSFormat.py @@ -13,12 +13,15 @@ import re from datetime import datetime + import FreeCAD + +from ..CodeVersion import * +from ..Utils.BasicFunctions_part1 import isOposite, pointsToCoeffs from ..Utils.Functions import Surfaces_dict -from ..Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite -from ..Write.Functions import PHITSSurface, changeSurfSign, writePHITSCellDef,CellString from ..Utils.Options.Classes import Options as opt -from ..CodeVersion import * +from ..Write.Functions import (CellString, PHITSSurface, changeSurfSign, + writePHITSCellDef) class PHITS_input: diff --git a/src/GEOUNED/Write/SerpentFormat.py b/src/GEOUNED/Write/SerpentFormat.py index 6c37fe99..d215c7f1 100644 --- a/src/GEOUNED/Write/SerpentFormat.py +++ b/src/GEOUNED/Write/SerpentFormat.py @@ -2,12 +2,14 @@ # Module to write Serpent input # ################################# from datetime import datetime + import FreeCAD + +from ..CodeVersion import * +from ..Utils.BasicFunctions_part1 import isOposite, pointsToCoeffs from ..Utils.Functions import Surfaces_dict -from ..Utils.BasicFunctions_part1 import pointsToCoeffs,isOposite -from .Functions import SerpentSurface, changeSurfSign, writeSerpentCellDef from ..Utils.Options.Classes import Options as opt -from ..CodeVersion import * +from .Functions import SerpentSurface, changeSurfSign, writeSerpentCellDef class Serpent_input: diff --git a/src/GEOUNED/Write/StringFunctions.py b/src/GEOUNED/Write/StringFunctions.py index 355c5d1b..a1bc1ea3 100644 --- a/src/GEOUNED/Write/StringFunctions.py +++ b/src/GEOUNED/Write/StringFunctions.py @@ -1,6 +1,5 @@ import re - ######################################### # define patterns to be found in string # ######################################### diff --git a/src/GEOUNED/Write/WriteFiles.py b/src/GEOUNED/Write/WriteFiles.py index 3c296bf0..9746065d 100644 --- a/src/GEOUNED/Write/WriteFiles.py +++ b/src/GEOUNED/Write/WriteFiles.py @@ -1,8 +1,9 @@ from . import AdditionalFiles as OutFiles from .MCNPFormat import MCNP_input -from .OpenMCFormat import OpenMC_input -from .SerpentFormat import Serpent_input -from .PHITSFormat import PHITS_input +from .OpenMCFormat import OpenMC_input +from .PHITSFormat import PHITS_input +from .SerpentFormat import Serpent_input + def writeGeometry(UniverseBox,MetaList,Surfaces,code_setting): diff --git a/src/GEOUNED/__init__.py b/src/GEOUNED/__init__.py index 73eeb362..572ffeca 100644 --- a/src/GEOUNED/__init__.py +++ b/src/GEOUNED/__init__.py @@ -12,20 +12,23 @@ except: pass import configparser -from os import path, mkdir from datetime import datetime -import FreeCAD, Part -from .LoadFile import LoadSTEP as Load +from os import mkdir, path + +import FreeCAD +import Part + +from .CodeVersion import * +from .Conversion import CellDefinition as Conv +from .Cuboid.translate import translate from .Decompose import Decom_one as Decom +from .LoadFile import LoadSTEP as Load from .Utils import Functions as UF -from .Conversion import CellDefinition as Conv -from .Write.Functions import writeMCNPCellDef -from .Write.WriteFiles import writeGeometry -from .CodeVersion import * -from .Utils.Options.Classes import Tolerances, MCNP_numeric_format, Options from .Utils.BooleanSolids import buildCTableFromSolids -from .Cuboid.translate import translate +from .Utils.Options.Classes import MCNP_numeric_format, Options, Tolerances from .Void import Void as Void +from .Write.Functions import writeMCNPCellDef +from .Write.WriteFiles import writeGeometry class GEOUNED() :