Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/psauvan/GEOUNED
Browse files Browse the repository at this point in the history
  • Loading branch information
psauvan committed May 9, 2024
2 parents bc74e7e + 76ef697 commit 3091418
Show file tree
Hide file tree
Showing 48 changed files with 13,962 additions and 12,167 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/enforce_main_pr_from_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Check that PR to main is coming from dev if necessary'

on:
pull_request:

jobs:
check_branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
if: github.base_ref == 'main' && github.head_ref != 'dev'
run: |
echo "ERROR: You can only merge to main from dev."
exit 1
53 changes: 27 additions & 26 deletions scripts/colorCADmat.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
import re
import sys

sys.path.append('/usr/lib64/freecad/lib64/')
sys.path.append("/usr/lib64/freecad/lib64/")
import ImportGui

bd = 255
gd = 255*255
rd = 255* 255* 255
matNumber=re.compile(r"Material_(?P<matnum>\d+)")
gd = 255 * 255
rd = 255 * 255 * 255
matNumber = re.compile(r"Material_(?P<matnum>\d+)")

def getColor(num,vmin=0,vmax=rd):

def getColor(num, vmin=0, vmax=rd):
colRange = rd
dnum = vmax - vmin
dnum = vmax - vmin
dx = num - vmin
scale = colRange/dnum
scale = colRange / dnum
snum = dx * scale + 1
red = snum//gd
r = snum - red * gd

red = snum // gd
r = snum - red * gd
green = r // bd
blue = r - green * bd
return (red/255,green/255,blue/255)
return (red / 255, green / 255, blue / 255)


def setColorMaterial(documents):
featureObj = []
matMin = 999999999
matMax = 0
for obj in documents.Objects:
if obj.TypeId == 'Part::Feature' :
for o in obj.InListRecursive:
m = matNumber.search(o.Label)
if m :
mat = int(m.group('matnum'))
matMin = min(matMin,mat)
matMax = max(matMax,mat)
featureObj.append((obj,mat))
for obj,mat in featureObj:
obj.ViewObject.ShapeColor = getColor(mat,matMin,matMax)
if obj.TypeId == "Part::Feature":
for o in obj.InListRecursive:
m = matNumber.search(o.Label)
if m:
mat = int(m.group("matnum"))
matMin = min(matMin, mat)
matMax = max(matMax, mat)
featureObj.append((obj, mat))

for obj, mat in featureObj:
obj.ViewObject.ShapeColor = getColor(mat, matMin, matMax)


# color solids in a Freecad document with respect to the material number
doc = App.ActiveDocument
setColorMaterial(doc)
name = doc.Label
outname = name+'_color'
ImportGui.export(doc.RootObjects,outname+'.stp')
doc.saveAs(outname+'.FCStd')

outname = name + "_color"
ImportGui.export(doc.RootObjects, outname + ".stp")
doc.saveAs(outname + ".FCStd")
53 changes: 27 additions & 26 deletions scripts/geouned.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,43 @@

# only if modules are not in the PYTHONPATH or directly installed in the python distribution used
import sys
#geo_path="C:\\Users\\Juan\\Documents\\work\\GEOUNED\\RepoGit\\GitHub\\GEOUNEDcode\\src"
#sys.path.append(geo_path)
#sys.path.append('C:\\Program Files\\FreeCAD 0.19\\bin...')

# geo_path="C:\\Users\\Juan\\Documents\\work\\GEOUNED\\RepoGit\\GitHub\\GEOUNEDcode\\src"
# sys.path.append(geo_path)
# sys.path.append('C:\\Program Files\\FreeCAD 0.19\\bin...')

import geouned
from geouned.GEOReverse import reverse

runReverse = False
if len(sys.argv) < 2 :
inifile = 'config.ini'
if len(sys.argv) < 2:
inifile = "config.ini"

elif len(sys.argv) == 2 :
if sys.argv[1] == '-r':
runReverse = True
inifile = 'configReverse.ini'
else:
inifile = sys.argv[1]
elif len(sys.argv) == 2:
if sys.argv[1] == "-r":
runReverse = True
inifile = "configReverse.ini"
else:
inifile = sys.argv[1]

elif len(sys.argv) == 3:
if sys.argv[1] == '-r':
runReverse = True
inifile = sys.argv[2]
elif sys.argv[2] == '-r':
runReverse = True
inifile = sys.argv[1]
else:
raise ValueError('Bad option')
if sys.argv[1] == "-r":
runReverse = True
inifile = sys.argv[2]
elif sys.argv[2] == "-r":
runReverse = True
inifile = sys.argv[1]
else:
raise ValueError("Bad option")

else:
raise ValueError('Too many input arguments')
raise ValueError("Too many input arguments")

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

else:
print(inifile)
reverse(inifile)
print(inifile)
reverse(inifile)
9 changes: 4 additions & 5 deletions src/geouned/GEOReverse/CodeVersion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
''' Starting beta stable version 0.9
""" Starting beta stable version 0.9
- new in version 0.9.1
- read MCNP macrobodies : RPP, BOX, RCC, REC, TRC
Expand All @@ -7,8 +7,7 @@
elliptical cone and elliptical torus surfaces have been added.
Changes have not been fully checked, some bugs may still remains. Please contact the authors in case of failure.
'''

GEOReverse_Version = '0.9.1'
GEOReverse_ReleaseDate = '16/11/2023'
"""

GEOReverse_Version = "0.9.1"
GEOReverse_ReleaseDate = "16/11/2023"
Loading

0 comments on commit 3091418

Please sign in to comment.