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

camel case for all classes #95

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install .
python -c 'import geouned'
python -c 'from geouned import GEOUNED'
python -c 'from geouned import CadToCsg'
python -c 'from geouned.GEOReverse import reverse'
python -m pip install .[tests]

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ cython_debug/
# testing folder
tests_outputs/

# debug output folders
fuzzySurfaces
Suspicious_solids/
Warning_Solids_definition.txt

.vscode
**/__pycache__
docs/source/_build/**
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ The second step is to call or GEOUNED for CAD to CSG conversion or GEOReverse fo
From CAD to CSG:

```python
from geouned import GEOUNED
from geouned import CadToCsg
inifile='Name of config file for forward conversion'
GEO = GEOUNED(inifile)
GEO = CadToCsg(inifile)
GEO.SetOptions()
GEO.Start()
```
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: GNU General Public License v3.0",
"License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
"Operating System :: OS Independent",
]

Expand Down
4 changes: 2 additions & 2 deletions scripts/geouned
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sys.path.append(geo_path)
# linux distribution
sys.path.append('/usr/lib64/freecad/lib64/')

import geouned
from geouned import CadToCsg
from geouned.GEOReverse import reverse

runReverse = False
Expand Down Expand Up @@ -38,7 +38,7 @@ else:


if not runReverse :
GEO = GEOUNED.GEOUNED(inifile)
GEO = CadToCsg(inifile)
GEO.SetOptions()
GEO.Start()

Expand Down
4 changes: 2 additions & 2 deletions scripts/geouned.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# sys.path.append(geo_path)
# sys.path.append('C:\\Program Files\\FreeCAD 0.19\\bin...')

import geouned
from geouned import CadToCsg
from geouned.GEOReverse import reverse

runReverse = False
Expand Down Expand Up @@ -38,7 +38,7 @@
raise ValueError("Too many input arguments")

if not runReverse:
GEO = GEOUNED.GEOUNED(inifile)
GEO = CadToCsg(inifile)
GEO.SetOptions()
GEO.Start()

Expand Down
8 changes: 4 additions & 4 deletions src/geouned/GEOReverse/Modules/MCNPinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from .Objects import *
from .Parser import parser as mp
from .remh import cell_card_string, remove_hash
from .remh import CellCardString, remove_hash


class MCNPinput:
class McnpInput:
def __init__(self, name):
if not os.path.isfile(name):
raise FileNotFoundError(f"File {name} does not exist")
Expand Down Expand Up @@ -59,7 +59,7 @@ def GetFilteredCells(self, Surfaces, config):
# set cell as CAD cell Object
for cname, c in universe.items():
# print(cname,c.geom.str)
universe[cname] = CADCell(c)
universe[cname] = CadCell(c)

return levels, FilteredCells, newSurfaces

Expand All @@ -72,7 +72,7 @@ def GetLevelStructure(self):
if c.ctype != mp.CID.cell:
continue
c.get_values()
cstr = cell_card_string("".join(c.lines))
cstr = CellCardString("".join(c.lines))

if cstr.TRCL:
cstr.TRCL = TransformationMatrix(cstr.TRCL, self.Transformations)
Expand Down
12 changes: 6 additions & 6 deletions src/geouned/GEOReverse/Modules/Objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import Part

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


class CADCell:
class CadCell:
def __init__(self, stringCell=None):

if not stringCell:
Expand Down Expand Up @@ -44,14 +44,14 @@ def __init__(self, stringCell=None):
self.__setDefinition__(stringCell)

def copy(self):
cpCell = CADCell()
cpCell = CadCell()
cpCell.surfaceList = self.surfaceList[:]
cpCell.surfaces = {}
for name, s in self.surfaces.items():
cpCell.surfaces[name] = s.copy()

if type(self.definition) is cline:
cpCell.definition = cline(self.definition.str)
if type(self.definition) is Cline:
cpCell.definition = Cline(self.definition.str)

elif type(self.definition) is BoolSequence:
cpCell.definition = self.definition.copy()
Expand Down Expand Up @@ -115,7 +115,7 @@ def getSubCell(self, seq):
# subCellList=[]
# for df in subDefList:
# subCell = self.copy()
# subCell.definition= cline(df)
# subCell.definition= Cline(df)
# subCell.shape = None
# subCell.surfaceList = subCell.definition.getSurfacesNumbers()
# for s in tuple(subCell.surfaces.keys()) :
Expand Down
4 changes: 2 additions & 2 deletions src/geouned/GEOReverse/Modules/Parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def fmt_gen(s):
partial_formmatter = PartialFormatter()


class __CIDClass(object):
class CidClass(object):
"""
There are two levels of card types. 1-st level is purely defined by card
position in the input file. There can be:
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_name(cls, cid):
raise ValueError()


CID = __CIDClass()
CID = CidClass()


class Card(object):
Expand Down
12 changes: 6 additions & 6 deletions src/geouned/GEOReverse/Modules/XMLParser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .remh import cline
from .remh import Cline


class cellCARD:
class CellCard:

def __init__(self, data):
self.type = "cell"
Expand All @@ -27,10 +27,10 @@ def processData(self, data):
else:
self.FILL = None

self.geom = cline(data["region"].replace("|", ":"))
self.geom = Cline(data["region"].replace("|", ":"))


class surfCARD:
class SurfCard:
def __init__(self, data):

self.type = "surface"
Expand All @@ -50,7 +50,7 @@ def get_cards(root):
def process_card(card):
ctype = card.tag
if ctype == "cell":
return cellCARD(card.attrib)
return CellCard(card.attrib)

elif ctype == "surface":
return surfCARD(card.attrib)
return SurfCard(card.attrib)
4 changes: 2 additions & 2 deletions src/geouned/GEOReverse/Modules/XMLinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .XMLParser import get_cards


class XMLinput:
class XmlInput:
def __init__(self, name):
if not os.path.isfile(name):
raise FileNotFoundError(f"File {name} does not exist")
Expand Down Expand Up @@ -61,7 +61,7 @@ def GetFilteredCells(self, Surfaces, config):
# set cell as CAD cell Object
for cname, c in universe.items():
# print(cname,c.geom.str)
universe[cname] = CADCell(c)
universe[cname] = CadCell(c)

return levels, FilteredCells, newSurfaces

Expand Down
4 changes: 2 additions & 2 deletions src/geouned/GEOReverse/Modules/buildSolidCell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Part

from .options import Options
from .splitFunction import SplitSolid, joinBase, splitBase
from .splitFunction import SplitSolid, joinBase, SplitBase
from .Utils.booleanFunction import BoolSequence


Expand All @@ -21,7 +21,7 @@ def BuildSolid(cell, boundBox, mode="oneByOne", simplify=False):
# cell.definition = BoolSequence(cell.definition.str)
cell.cleanUndefined()

celParts = BuildDepth(cell, splitBase(cutCell), mode, True, simplify)
celParts = BuildDepth(cell, SplitBase(cutCell), mode, True, simplify)

celParts = getPart(celParts)
# print('celparts',len(celParts))
Expand Down
40 changes: 20 additions & 20 deletions src/geouned/GEOReverse/Modules/remh.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def reverse_repl(m):

def complementary(ccell, outter=True):
"""return the complementary cell"""
wrkcell = cline(ccell.str)
wrkcell = Cline(ccell.str)
if wrkcell.str[-1] == "\n":
wrkcell.str = wrkcell.str[:-1]

Expand Down Expand Up @@ -237,12 +237,12 @@ def complementary(ccell, outter=True):


############################################################
class cline:
class Cline:
def __init__(self, line):
self.str = line

def copy(self):
return cline(self.str)
return Cline(self.str)

def getSurfacesNumbers(self):
s = set(unsignedint.findall(self.str))
Expand Down Expand Up @@ -301,7 +301,7 @@ def restore_comments(self):
return

def outterTerms(self):
cgeom = cline(self.str)
cgeom = Cline(self.str)

cgeom.remove_comments(full=True)
cgeom.remove_redundant()
Expand Down Expand Up @@ -434,7 +434,7 @@ def get_hashcell(self, start=0):
count -= 1
if count == 0:
end = p.end()
cell = cline(self.str[start + 1 : end])
cell = Cline(self.str[start + 1 : end])
break
return cell, end

Expand Down Expand Up @@ -532,7 +532,7 @@ def SplitCell(self):


############################################################
class cell_card_string:
class CellCardString:

def __init__(self, card):
self.stat = {"word": None, "hashcell": None, "hashsurf": None, "hash": None}
Expand All @@ -549,8 +549,8 @@ def __init__(self, card):
def __card_split__(self, cardin):
"""Split the card string in three parts :
- headstr : string containing the cell name, mat number and density (if mat != 0) of the cell
- geom : cline class containing the part of the geometric definition of the cell
- param : cline class containing the cell parameters part
- geom : Cline class containing the part of the geometric definition of the cell
- param : Cline class containing the cell parameters part
hproc is true if the complementary operator of the cell can be substituted"""

m = celmat.match(cardin)
Expand All @@ -560,8 +560,8 @@ def __card_split__(self, cardin):
if m.group("scnd").lower() == "like":
self.headstr = cardin[: m.start("scnd")]
s = likebut.search(cardin, m.end("scnd"))
self.geom = cline(cardin[m.start("scnd") : s.end()])
self.parm = cline(cardin[s.end() :])
self.geom = Cline(cardin[m.start("scnd") : s.end()])
self.parm = Cline(cardin[s.end() :])
self.hproc = False
mc = unsignedint.search(self.geom.str)
self.likeCell = int(mc.group())
Expand All @@ -578,7 +578,7 @@ def __card_split__(self, cardin):

if self.hproc:
self.headstr = cardin[:cstart]
cellcard = cline(cardin[cstart:])
cellcard = Cline(cardin[cstart:])
cellcard.remove_comments()
m = param.search(cellcard.str)
if m:
Expand All @@ -599,8 +599,8 @@ def __card_split__(self, cardin):

if m:
start = m.end(1)
self.geom = cline(cellcard.str[:start])
self.parm = cline(cellcard.str[start:])
self.geom = Cline(cellcard.str[:start])
self.parm = Cline(cellcard.str[start:])

# look for transformation in cell parameters
self.parm.remove_comments()
Expand All @@ -609,8 +609,8 @@ def __card_split__(self, cardin):
self.hproc = False
self.parm.restore_comments()
else:
self.geom = cline(cellcard.str)
self.parm = cline("")
self.geom = Cline(cellcard.str)
self.parm = Cline("")

return

Expand Down Expand Up @@ -717,7 +717,7 @@ def remove(card, cname, keepComments):
"""remove complementary operator and subtitute by complementary cell"""
if "parser.Card" in str(type(card)):
celline = "".join(card.lines)
cardstr = cell_card_string(celline)
cardstr = CellCardString(celline)
else:
cardstr = card
cardstr.get_stat()
Expand All @@ -726,7 +726,7 @@ def remove(card, cname, keepComments):
return (
cardstr.geom
) # no complementary operator or cannot be # cannot be removed
cell = cline(cardstr.geom.str)
cell = Cline(cardstr.geom.str)
# find all operators in the cell and
# substitute all complementary operators
# locate object in list to reverse iteration
Expand All @@ -753,7 +753,7 @@ def remove(card, cname, keepComments):
if m.group(1) == "(": # complementary cell defined as surface intersections
hcell, end = cell.get_hashcell(start)
cellmod = cell.str[0:start] + complementary(hcell) + cell.str[end:]
cell = cline(cellmod)
cell = Cline(cellmod)
else:
hcname = int(
m.group(1)
Expand All @@ -769,8 +769,8 @@ def remove(card, cname, keepComments):
+ " "
+ cell.str[end:]
)
cell = cline(cellmod)
cell = Cline(cellmod)
return cell

newcell = remove(cards[cname], cname, keepComments)
return cline(newcell.str)
return Cline(newcell.str)
Loading
Loading