Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved import statements #65

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/GEOReverse/Modules/MCNPinput.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
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 .Objects import *
from .Parser import parser as mp
from .remh import cell_card_string, remove_hash


class MCNPinput:
def __init__(self,name):
if not os.path.isfile(name):
Expand Down
15 changes: 9 additions & 6 deletions src/GEOReverse/Modules/Objects.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
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 FreeCAD
import numpy as np
import Part

from .buildSolidCell import BuildSolid
from .remh import cline
from .Utils.booleanFunction import BoolSequence, outterTerms


class CADCell:
def __init__(self,stringCell=None):
Expand Down
1 change: 1 addition & 0 deletions src/GEOReverse/Modules/Parser/PartialFormatter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import string

version = '3.6'

def make_label(item):
Expand Down
5 changes: 3 additions & 2 deletions src/GEOReverse/Modules/Parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
Functions for parsing MCNP input files.
"""

import os
import re
import warnings
import os
from GEOReverse.Modules.Parser.PartialFormatter import PartialFormatter

from .PartialFormatter import PartialFormatter

version = '3.6'

Expand Down
9 changes: 5 additions & 4 deletions src/GEOReverse/Modules/Utils/BooleanSolids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Conversion to MCNP v0.0
# Only one solid and planar surfaces
#
import FreeCAD
import BOPTools.SplitAPI
import math
import re
from GEOReverse.Modules.Utils.booleanFunction import BoolSequence

import BOPTools.SplitAPI
import FreeCAD

from .booleanFunction import BoolSequence

BoolVals = (None,True,False)

Expand Down
1 change: 1 addition & 0 deletions src/GEOReverse/Modules/Utils/booleanFunction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re

mostinner=re.compile(r"\([^\(^\)]*\)") # identify most inner parentheses
number =re.compile(r"(?P<value>[-+]?\d+)")
mix =re.compile(r"(?P<value>([-+]?\d+|\[0+\]))")
Expand Down
3 changes: 2 additions & 1 deletion src/GEOReverse/Modules/XMLParser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from GEOReverse.Modules.remh import cline
from .remh import cline


class cellCARD:

Expand Down
13 changes: 7 additions & 6 deletions src/GEOReverse/Modules/XMLinput.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import math
import os
import sys
import re
import xml.etree.ElementTree as ET

import FreeCAD
from GEOReverse.Modules.remh import cell_card_string, remove_hash
from GEOReverse.Modules.Objects import *
from GEOReverse.Modules.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):
Expand Down
6 changes: 2 additions & 4 deletions src/GEOReverse/Modules/buildCAD.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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


def buildCAD(UnivCell,data,config):
Expand Down
14 changes: 5 additions & 9 deletions src/GEOReverse/Modules/buildSolidCell.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
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 .options import Options
from .splitFunction import SplitSolid, joinBase, splitBase
from .Utils.booleanFunction import BoolSequence


def getPart(slist):
Expand Down
3 changes: 2 additions & 1 deletion src/GEOReverse/Modules/processInp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import configparser
from GEOReverse.Modules.options import Options

from .options import Options


def setOptions(optionFile):
Expand Down
5 changes: 1 addition & 4 deletions src/GEOReverse/Modules/remh.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import sys
import re
import math


import re

#########################################
# define patterns to be found in string #
Expand Down
7 changes: 4 additions & 3 deletions src/GEOReverse/Modules/splitFunction.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import FreeCAD,Part
import BOPTools.SplitAPI
from GEOReverse.Modules.Utils.booleanFunction import outterTerms
import math

import BOPTools.SplitAPI
import FreeCAD
import Part


class splitBase:
def __init__(self,base,knownSurf={}):
Expand Down
18 changes: 9 additions & 9 deletions src/GEOReverse/reverse.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 Import

from .CodeVersion import *
from .Modules.buildCAD import buildCAD, makeTree
from .Modules.MCNPinput import MCNPinput
from .Modules.Objects import CADCell
from .Modules.processInp import setOptions
from .Modules.XMLinput import XMLinput


def reverse(optFile='configRevese.ini') :
Expand Down
29 changes: 15 additions & 14 deletions src/GEOUNED/Conversion/CellDefinition.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
############################
# 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
import Part

from ..Utils import BasicFunctions_part2 as BF
from ..Utils import Functions as UF
from ..Utils import Geometry_GU as GU
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.Options.Classes import Tolerances as tol


def getId(facein, Surfaces):

Expand Down
19 changes: 10 additions & 9 deletions src/GEOUNED/Cuboid/translate.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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
import FreeCAD
import Part

from ..Decompose import Decom_one as Decom
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):
Expand Down
24 changes: 13 additions & 11 deletions src/GEOUNED/Decompose/Decom_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
# 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
import Part

from ..Conversion import CellDefinition as CD
from ..Utils import Functions as UF
from ..Utils import Geometry_GU as GU
from ..Utils.BasicFunctions_part1 import (isInLine, isInPlane, isParallel,
isSameValue)
from ..Utils.BasicFunctions_part2 import isDuplicateInList
from ..Utils.Options.Classes import Options as opt
from ..Utils.Options.Classes import Tolerances as tol

twoPi = math.pi*2

Expand Down
6 changes: 4 additions & 2 deletions src/GEOUNED/LoadFile/LoadFunctions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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):
Expand Down
13 changes: 8 additions & 5 deletions src/GEOUNED/LoadFile/LoadSTEP.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#
# Module to load a STEP file
#
import FreeCAD, Part
from FreeCAD import Import
import os
import re
import os.path
import GEOUNED.Utils.Functions as UF
import GEOUNED.LoadFile.LoadFunctions as LF

import FreeCAD
import Part
from FreeCAD import Import

from ..Utils import Functions as UF
from . import LoadFunctions as LF


# Paco mod
Expand Down
4 changes: 3 additions & 1 deletion src/GEOUNED/Utils/BasicFunctions_part1.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#
# 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

Expand Down
9 changes: 5 additions & 4 deletions src/GEOUNED/Utils/BasicFunctions_part2.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#
# 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 (isInLine, isInPlane, isInTolerance,
isOposite, isParallel, isSameValue)
from ..Write.Functions import MCNPSurface

sameSurfFic = open('fuzzySurfaces','w')
def Fuzzy(index,dtype,surf1,surf2,val,tol):
Expand Down
10 changes: 5 additions & 5 deletions src/GEOUNED/Utils/BooleanSolids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# 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.booleanFunction import BoolSequence
from ..Utils.Functions import GEOUNED_Surface, splitBOP
from ..Utils.Options.Classes import Options as opt

BoolVals = (None,True,False)

Expand Down
Loading