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() :