cad-to-dagmc 0.3.2__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cad-to-dagmc might be problematic. Click here for more details.

Files changed (71) hide show
  1. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/.github/workflows/ci_with_install.yml +55 -6
  2. cad_to_dagmc-0.4.0/PKG-INFO +111 -0
  3. cad_to_dagmc-0.4.0/README.md +95 -0
  4. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/pyproject.toml +0 -1
  5. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/_version.py +2 -2
  6. cad_to_dagmc-0.4.0/src/cad_to_dagmc/brep_part_finder.py +37 -0
  7. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc/brep_to_h5m.py +5 -52
  8. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc/core.py +68 -61
  9. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc/vertices_to_h5m.py +2 -0
  10. cad_to_dagmc-0.4.0/src/cad_to_dagmc.egg-info/PKG-INFO +111 -0
  11. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc.egg-info/SOURCES.txt +1 -5
  12. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc.egg-info/requires.txt +0 -1
  13. cad_to_dagmc-0.4.0/tests/test_brep_part_finder/test_loading_from_file_vs_shape_object.py +39 -0
  14. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_to_h5m/test_h5m_in_transport.py +26 -146
  15. cad_to_dagmc-0.4.0/tests/test_brep_to_h5m/test_python_api.py +108 -0
  16. cad_to_dagmc-0.4.0/tests/test_cad_to_dagmc/curved_extrude.stp +29003 -0
  17. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/test_h5m_creation.py +21 -15
  18. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/test_h5m_in_simulation.py +1 -1
  19. cad_to_dagmc-0.3.2/PKG-INFO +0 -89
  20. cad_to_dagmc-0.3.2/README.md +0 -73
  21. cad_to_dagmc-0.3.2/environment.yml +0 -16
  22. cad_to_dagmc-0.3.2/src/cad_to_dagmc/brep_part_finder.py +0 -329
  23. cad_to_dagmc-0.3.2/src/cad_to_dagmc.egg-info/PKG-INFO +0 -89
  24. cad_to_dagmc-0.3.2/tests/test_brep_part_finder/test_get_brep_part_properties.py +0 -50
  25. cad_to_dagmc-0.3.2/tests/test_brep_part_finder/test_get_matching_part_id.py +0 -56
  26. cad_to_dagmc-0.3.2/tests/test_brep_part_finder/test_get_matching_part_id_with_file.py +0 -74
  27. cad_to_dagmc-0.3.2/tests/test_brep_part_finder/test_get_matching_part_ids.py +0 -53
  28. cad_to_dagmc-0.3.2/tests/test_brep_part_finder/test_loading_from_file_vs_shape_object.py +0 -15
  29. cad_to_dagmc-0.3.2/tests/test_brep_to_h5m/test_python_api.py +0 -148
  30. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/.github/workflows/anaconda-publish.yml +0 -0
  31. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/.github/workflows/black.yml +0 -0
  32. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/.github/workflows/python-publish.yml +0 -0
  33. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/.gitignore +0 -0
  34. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/LICENSE +0 -0
  35. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/cadquery_assembly.py +0 -0
  36. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/cadquery_compound.py +0 -0
  37. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/cadquery_object_and_stp_file.py +0 -0
  38. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/cadquery_text.py +0 -0
  39. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/create_stp_files_for_examples.py +0 -0
  40. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/curved_cadquery_object.py +0 -0
  41. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/multiple_cadquery_objects.py +0 -0
  42. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/multiple_stp_files.py +0 -0
  43. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/single_cadquery_object.py +0 -0
  44. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/single_stp_file.py +0 -0
  45. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/examples/single_stp_file_multiple_volumes.py +0 -0
  46. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/setup.cfg +0 -0
  47. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc/__init__.py +0 -0
  48. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
  49. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
  50. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
  51. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/extrude_rectangle.stp +0 -0
  52. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/multi_volume_cylinders.stp +0 -0
  53. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/single_cube.stp +0 -0
  54. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/single_volume_thin.stp +0 -0
  55. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/single_volume_thin.vtk +0 -0
  56. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_part_finder/ball_reactor.brep +0 -0
  57. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_to_h5m/create_brep_file_for_testing.py +0 -0
  58. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_to_h5m/one_cube.brep +0 -0
  59. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_to_h5m/test_brep_file.brep +0 -0
  60. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_to_h5m/test_two_joined_cubes.brep +0 -0
  61. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_brep_to_h5m/test_two_sep_cubes.brep +0 -0
  62. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/extrude_rectangle.stp +0 -0
  63. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/multi_volume_cylinders.stp +0 -0
  64. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/single_cube.stp +0 -0
  65. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/single_volume_thin.stp +0 -0
  66. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/test_version.py +0 -0
  67. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/two_connected_cubes.stp +0 -0
  68. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_cad_to_dagmc/two_disconnected_cubes.stp +0 -0
  69. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/test_vertices_to_h5m/test_package.py +0 -0
  70. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/two_connected_cubes.stp +0 -0
  71. {cad_to_dagmc-0.3.2 → cad_to_dagmc-0.4.0}/tests/two_disconnected_cubes.stp +0 -0
@@ -1,6 +1,8 @@
1
1
 
2
2
  # This CI will launch a Docker image that contains all the dependencies required
3
3
  # within that image the pytest test suite is run
4
+ # container:
5
+ # image: continuumio/miniconda3:23.3.1-0
4
6
 
5
7
  name: CI with install
6
8
 
@@ -21,41 +23,88 @@ jobs:
21
23
  testing:
22
24
  runs-on: ubuntu-latest
23
25
  container:
24
- image: continuumio/miniconda3:4.12.0
26
+ image: continuumio/miniconda3:23.3.1-0
25
27
  steps:
26
28
  - name: Checkout repository
27
29
  uses: actions/checkout@v3
28
30
 
31
+ # - uses: conda-incubator/setup-miniconda@v2
32
+
29
33
  - name: install non pypi dependencies for cad creation
30
34
  run: |
31
35
  apt-get --allow-releaseinfo-change update
32
36
  apt-get update -y
33
37
  apt-get upgrade -y
34
- apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev
38
+ apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev
35
39
  apt-get install -y libpangocairo-1.0-0
36
- conda install -c conda-forge -y moab
37
- conda install -c conda-forge -y gmsh
38
- conda install -c conda-forge -y python-gmsh
39
- conda install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
40
+ conda install -c conda-forge mamba -y
41
+ mamba install -c conda-forge moab multimethod typish ezdxf nptyping nlopt casadi gmsh python-gmsh ocp>=7.7.1 -y
42
+ mamba install -c cadquery -c conda-forge cadquery=master --no-deps -y
40
43
 
41
44
  - name: install package
42
45
  run: |
46
+ pip install --upgrade pip
43
47
  pip install .
44
48
  python -c "import cad_to_dagmc"
49
+ mamba install -c conda-forge openmc -y
45
50
 
46
51
  - name: run examples
47
52
  run: |
48
53
  cd examples
49
54
  python create_stp_files_for_examples.py
55
+
56
+ - name: run examples
57
+ run: |
58
+ cd examples
50
59
  python cadquery_assembly.py
60
+
61
+ - name: run examples
62
+ run: |
63
+ cd examples
51
64
  python cadquery_compound.py
65
+
66
+ - name: run examples
67
+ run: |
68
+ cd examples
52
69
  python cadquery_object_and_stp_file.py
70
+
71
+ - name: run examples
72
+ run: |
73
+ cd examples
53
74
  python cadquery_text.py
75
+
76
+ - name: run examples 1
77
+ run: |
78
+ cd examples
54
79
  python curved_cadquery_object.py
80
+
81
+ - name: run examples 2
82
+ run: |
83
+ cd examples
55
84
  python multiple_cadquery_objects.py
85
+
86
+ - name: run examples 3
87
+ run: |
88
+ cd examples
56
89
  python multiple_stp_files.py
90
+
91
+ - name: run examples 4
92
+ run: |
93
+ cd examples
57
94
  python single_stp_file_multiple_volumes.py
95
+
96
+ - name: run examples 5
97
+ run: |
98
+ cd examples
99
+
100
+ - name: run examples 6
101
+ run: |
102
+ cd examples
58
103
  python single_cadquery_object.py
104
+
105
+ - name: run examples 7
106
+ run: |
107
+ cd examples
59
108
  python single_stp_file.py
60
109
 
61
110
  - name: Run pytest
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.1
2
+ Name: cad_to_dagmc
3
+ Version: 0.4.0
4
+ Summary: Converts CAD files to a DAGMC h5m file
5
+ Author-email: Jonathan Shimwell <mail@jshimwell.com>
6
+ Project-URL: Homepage, https://github.com/fusion-energy/cad_to_dagmc
7
+ Project-URL: Bug Tracker, https://github.com/fusion-energy/cad_to_dagmc/issues
8
+ Keywords: dagmc,geometry,plot,slice
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ Provides-Extra: tests
15
+ License-File: LICENSE
16
+
17
+
18
+ [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)
19
+
20
+ [![CI with install](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml)
21
+
22
+ [![Upload Python Package](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml)
23
+
24
+
25
+ [![PyPI](https://img.shields.io/pypi/v/cad_to_dagmc?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/cad_to_dagmc/)
26
+
27
+ ___
28
+
29
+ A minimal package that uses CadQuery functionality to convert Cad geometry to [DAGMC](https://github.com/svalinn/DAGMC/) h5m files
30
+
31
+ This particular method of producing DAGMC compatible h5m files from CAD geometry
32
+ is intended to convert STP files or [CadQuery](https://cadquery.readthedocs.io) objects to h5m file.
33
+
34
+ One unique feature of this package is the ability to combine STP files with CadQuery objects.
35
+ This allows for the addition of parametric geometry to static geometry.
36
+
37
+ # Installation
38
+
39
+ In principle, any Conda distribution will work.
40
+
41
+
42
+ # Install using Conda and pip
43
+
44
+ This example uses Conda to install some dependencies that are not available via PyPi.
45
+
46
+ Create a new conda environment
47
+ ```bash
48
+ conda create --name new_env python=3.9 -y
49
+ ```
50
+
51
+ Activate the environment
52
+ ```bash
53
+ conda activate new_env
54
+ ```
55
+
56
+ Install the dependencies
57
+ ```bash
58
+ conda install -c conda-forge moab multimethod typish ezdxf nptyping nlopt casadi gmsh python-gmsh ocp>=7.7.1 -y
59
+ conda install -c cadquery -c conda-forge cadquery=master --no-deps -y
60
+ ```
61
+
62
+ Then you can install the cad_to_dagmc package with ```pip```
63
+ ```bash
64
+ pip install cad_to_dagmc
65
+ ```
66
+
67
+ You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/).You can run ```conda install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
68
+ ```bash
69
+ conda install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
70
+ ```
71
+
72
+
73
+ # Install using Mamba and pip
74
+
75
+ This example uses Mamba to install some dependencies that are not available via PyPi.
76
+
77
+ Create a new conda environment, I've chosen Python 3.9 here but new versions are
78
+ also supported.
79
+ ```bash
80
+ conda create --name new_env python=3.9 -y
81
+ ```
82
+
83
+ Activate the environment
84
+ ```bash
85
+ mamba activate new_env
86
+ ```
87
+
88
+ Install the dependencies
89
+ ```bash
90
+ conda install -c conda-forge mamba -y
91
+ mamba install -c conda-forge moab multimethod typish ezdxf nptyping nlopt casadi gmsh python-gmsh ocp>=7.7.1 -y
92
+ mamba install -c cadquery -c conda-forge cadquery=master --no-deps -y
93
+ ```
94
+
95
+ Then you can install the cad_to_dagmc package with ```pip```
96
+ ```bash
97
+ pip install cad_to_dagmc
98
+ ```
99
+
100
+ You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/).You can run ```conda install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
101
+ ```bash
102
+ mamba install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
103
+ ```
104
+
105
+ # Usage - creation of DAGMC h5m files
106
+
107
+ For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
108
+
109
+ # Usage - simulation with transport code
110
+
111
+ For examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop)
@@ -0,0 +1,95 @@
1
+
2
+ [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)
3
+
4
+ [![CI with install](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml)
5
+
6
+ [![Upload Python Package](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml)
7
+
8
+
9
+ [![PyPI](https://img.shields.io/pypi/v/cad_to_dagmc?color=brightgreen&label=pypi&logo=grebrightgreenen&logoColor=green)](https://pypi.org/project/cad_to_dagmc/)
10
+
11
+ ___
12
+
13
+ A minimal package that uses CadQuery functionality to convert Cad geometry to [DAGMC](https://github.com/svalinn/DAGMC/) h5m files
14
+
15
+ This particular method of producing DAGMC compatible h5m files from CAD geometry
16
+ is intended to convert STP files or [CadQuery](https://cadquery.readthedocs.io) objects to h5m file.
17
+
18
+ One unique feature of this package is the ability to combine STP files with CadQuery objects.
19
+ This allows for the addition of parametric geometry to static geometry.
20
+
21
+ # Installation
22
+
23
+ In principle, any Conda distribution will work.
24
+
25
+
26
+ # Install using Conda and pip
27
+
28
+ This example uses Conda to install some dependencies that are not available via PyPi.
29
+
30
+ Create a new conda environment
31
+ ```bash
32
+ conda create --name new_env python=3.9 -y
33
+ ```
34
+
35
+ Activate the environment
36
+ ```bash
37
+ conda activate new_env
38
+ ```
39
+
40
+ Install the dependencies
41
+ ```bash
42
+ conda install -c conda-forge moab multimethod typish ezdxf nptyping nlopt casadi gmsh python-gmsh ocp>=7.7.1 -y
43
+ conda install -c cadquery -c conda-forge cadquery=master --no-deps -y
44
+ ```
45
+
46
+ Then you can install the cad_to_dagmc package with ```pip```
47
+ ```bash
48
+ pip install cad_to_dagmc
49
+ ```
50
+
51
+ You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/).You can run ```conda install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
52
+ ```bash
53
+ conda install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
54
+ ```
55
+
56
+
57
+ # Install using Mamba and pip
58
+
59
+ This example uses Mamba to install some dependencies that are not available via PyPi.
60
+
61
+ Create a new conda environment, I've chosen Python 3.9 here but new versions are
62
+ also supported.
63
+ ```bash
64
+ conda create --name new_env python=3.9 -y
65
+ ```
66
+
67
+ Activate the environment
68
+ ```bash
69
+ mamba activate new_env
70
+ ```
71
+
72
+ Install the dependencies
73
+ ```bash
74
+ conda install -c conda-forge mamba -y
75
+ mamba install -c conda-forge moab multimethod typish ezdxf nptyping nlopt casadi gmsh python-gmsh ocp>=7.7.1 -y
76
+ mamba install -c cadquery -c conda-forge cadquery=master --no-deps -y
77
+ ```
78
+
79
+ Then you can install the cad_to_dagmc package with ```pip```
80
+ ```bash
81
+ pip install cad_to_dagmc
82
+ ```
83
+
84
+ You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/).You can run ```conda install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
85
+ ```bash
86
+ mamba install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
87
+ ```
88
+
89
+ # Usage - creation of DAGMC h5m files
90
+
91
+ For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
92
+
93
+ # Usage - simulation with transport code
94
+
95
+ For examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop)
@@ -18,7 +18,6 @@ classifiers = [
18
18
  "Operating System :: OS Independent",
19
19
  ]
20
20
  dependencies = [
21
- "cadquery>=2.2.0",
22
21
  "trimesh",
23
22
  "networkx",
24
23
  ]
@@ -1,4 +1,4 @@
1
1
  # file generated by setuptools_scm
2
2
  # don't change, don't track in version control
3
- __version__ = version = '0.3.2'
4
- __version_tuple__ = version_tuple = (0, 3, 2)
3
+ __version__ = version = '0.4.0'
4
+ __version_tuple__ = version_tuple = (0, 4, 0)
@@ -0,0 +1,37 @@
1
+ import cadquery as cq
2
+
3
+
4
+ def convert_shape_to_iterable_of_shapes(shapes):
5
+ if isinstance(shapes, cq.occ_impl.shapes.Compound):
6
+ # brep route
7
+ iterable_solids = shapes.Solids()
8
+ elif isinstance(shapes, cq.Workplane):
9
+ # workplane route
10
+ iterable_solids = shapes.val().Solids()
11
+ else:
12
+ iterable_solids = shapes.Solids()
13
+
14
+ return iterable_solids
15
+
16
+
17
+ def get_ids_from_assembly(assembly):
18
+ ids = []
19
+ for obj, name, loc, _ in assembly:
20
+ ids.append(name)
21
+ return ids
22
+
23
+
24
+ def get_ids_from_imprinted_assembly(solid_id_dict):
25
+ ids = []
26
+ for id in list(solid_id_dict.values()):
27
+ print(id[0])
28
+ ids.append(id[0])
29
+ return ids
30
+
31
+
32
+ def order_material_ids_by_brep_order(original_ids, scrambled_id, material_tags):
33
+ material_tags_in_brep_order = []
34
+ for brep_id in scrambled_id:
35
+ id_of_solid_in_org = original_ids.index(brep_id)
36
+ material_tags_in_brep_order.append(material_tags[id_of_solid_in_org])
37
+ return material_tags_in_brep_order
@@ -4,50 +4,8 @@ from .vertices_to_h5m import vertices_to_h5m
4
4
  import typing
5
5
 
6
6
 
7
- def brep_to_h5m(
8
- brep_filename: str,
9
- material_tags: typing.Iterable[str],
10
- h5m_filename: str = "dagmc.h5m",
11
- min_mesh_size: float = 30,
12
- max_mesh_size: float = 10,
13
- mesh_algorithm: int = 1,
14
- ) -> str:
15
- """Converts a Brep file into a DAGMC h5m file. This makes use of Gmsh and
16
- will therefore need to have Gmsh installed to work.
17
-
18
- Args:
19
- brep_filename: the filename of the Brep file to convert
20
- material_tags: A list of material tags to tag the DAGMC volumes with.
21
- Should be in the same order as the volumes
22
- h5m_filename: the filename of the DAGMC h5m file to write
23
- min_mesh_size: the minimum mesh element size to use in Gmsh. Passed
24
- into gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
25
- max_mesh_size: the maximum mesh element size to use in Gmsh. Passed
26
- into gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
27
- mesh_algorithm: The Gmsh mesh algorithm number to use. Passed into
28
- gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
29
- Returns:
30
- The filename of the h5m file produced
31
- """
32
-
33
- gmsh, volumes = mesh_brep(
34
- brep_filename=brep_filename,
35
- min_mesh_size=min_mesh_size,
36
- max_mesh_size=max_mesh_size,
37
- mesh_algorithm=mesh_algorithm,
38
- )
39
-
40
- h5m_filename = mesh_to_h5m_in_memory_method(
41
- volumes=volumes,
42
- material_tags=material_tags,
43
- h5m_filename=h5m_filename,
44
- )
45
-
46
- return h5m_filename
47
-
48
-
49
7
  def mesh_brep(
50
- brep_filename: str,
8
+ brep_object: str,
51
9
  min_mesh_size: float = 30,
52
10
  max_mesh_size: float = 10,
53
11
  mesh_algorithm: int = 1,
@@ -56,7 +14,7 @@ def mesh_brep(
56
14
  Gmsh.
57
15
 
58
16
  Args:
59
- brep_filename: the filename of the Brep file to convert
17
+ brep_object: the filename of the Brep file to convert
60
18
  min_mesh_size: the minimum mesh element size to use in Gmsh. Passed
61
19
  into gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
62
20
  max_mesh_size: the maximum mesh element size to use in Gmsh. Passed
@@ -68,14 +26,11 @@ def mesh_brep(
68
26
  The gmsh object and volumes in Brep file
69
27
  """
70
28
 
71
- if not Path(brep_filename).is_file():
72
- msg = f"The specified brep ({brep_filename}) file was not found"
73
- raise FileNotFoundError(msg)
74
-
75
29
  gmsh.initialize()
76
30
  gmsh.option.setNumber("General.Terminal", 1)
77
31
  gmsh.model.add("made_with_brep_to_h5m_package")
78
- volumes = gmsh.model.occ.importShapes(brep_filename)
32
+ volumes = gmsh.model.occ.importShapesNativePointer(brep_object)
33
+ # gmsh.model.occ.importShapes(brep_object)
79
34
  gmsh.model.occ.synchronize()
80
35
 
81
36
  gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
@@ -155,11 +110,9 @@ def mesh_to_h5m_in_memory_method(
155
110
  gmsh.finalize()
156
111
 
157
112
  # checks and fixes triangle fix_normals within vertices_to_h5m
158
- vertices_to_h5m(
113
+ return vertices_to_h5m(
159
114
  vertices=GroupedCoords,
160
115
  triangles=nodes_in_each_pg,
161
116
  material_tags=material_tags,
162
117
  h5m_filename=h5m_filename,
163
118
  )
164
-
165
- return h5m_filename
@@ -1,22 +1,22 @@
1
- from tempfile import mkstemp
2
-
3
1
  import typing
4
2
  from cadquery import importers
5
- from cadquery import Assembly
6
- from OCP.GCPnts import GCPnts_QuasiUniformDeflection
3
+
4
+ # from cadquery import Assembly
5
+ # from OCP.GCPnts import GCPnts_QuasiUniformDeflection
7
6
 
8
7
  # from cadquery.occ_impl import shapes
9
8
  import OCP
10
9
  import cadquery as cq
11
- from OCP.TopLoc import TopLoc_Location
12
- from OCP.BRep import BRep_Tool
13
- from OCP.TopAbs import TopAbs_Orientation
14
10
 
15
- from .brep_to_h5m import brep_to_h5m
11
+ # from OCP.TopLoc import TopLoc_Location
12
+ # from OCP.BRep import BRep_Tool
13
+ # from OCP.TopAbs import TopAbs_Orientation
14
+
15
+ from .brep_to_h5m import mesh_brep, mesh_to_h5m_in_memory_method
16
16
  from .brep_part_finder import (
17
- get_part_properties_from_shapes,
18
- get_part_properties_from_shapes,
19
- get_matching_part_ids,
17
+ get_ids_from_assembly,
18
+ get_ids_from_imprinted_assembly,
19
+ order_material_ids_by_brep_order,
20
20
  )
21
21
 
22
22
 
@@ -45,7 +45,7 @@ class CadToDagmc:
45
45
  Useful when converting the geometry to cm for use in neutronics
46
46
  simulations.
47
47
  """
48
-
48
+ print(f"loading stp file {filename}")
49
49
  part = importers.importStep(str(filename)).val()
50
50
 
51
51
  if scale_factor == 1:
@@ -94,71 +94,78 @@ class CadToDagmc:
94
94
  filename: str = "dagmc.h5m",
95
95
  min_mesh_size: float = 1,
96
96
  max_mesh_size: float = 10,
97
- verbose: bool = False,
98
- volume_atol: float = 0.000001,
99
- center_atol: float = 0.000001,
100
- bounding_box_atol: float = 0.000001,
97
+ mesh_algorithm: int = 1,
101
98
  ):
102
- brep_shape = self._merge_surfaces()
103
-
104
- tmp_brep_filename = mkstemp(suffix=".brep", prefix="paramak_")[1]
105
- brep_shape.exportBrep(tmp_brep_filename)
106
-
107
- if verbose:
108
- print(f"Brep file saved to {tmp_brep_filename}")
109
-
110
- brep_file_part_properties = get_part_properties_from_shapes(brep_shape)
99
+ assembly = cq.Assembly()
100
+ for part in self.parts:
101
+ assembly.add(part)
102
+
103
+ (
104
+ imprinted_assembly,
105
+ imprinted_solids_with_original_id,
106
+ ) = cq.occ_impl.assembly.imprint(assembly)
107
+
108
+ original_ids = get_ids_from_assembly(assembly)
109
+ scrambled_ids = get_ids_from_imprinted_assembly(
110
+ imprinted_solids_with_original_id
111
+ )
111
112
 
112
- shape_properties = get_part_properties_from_shapes(self.parts)
113
+ # both id lists should be the same length as each other and the same
114
+ # length as the self.material_tags
113
115
 
114
- brep_and_shape_part_ids = get_matching_part_ids(
115
- brep_part_properties=brep_file_part_properties,
116
- shape_properties=shape_properties,
117
- volume_atol=volume_atol,
118
- center_atol=center_atol,
119
- bounding_box_atol=bounding_box_atol,
116
+ material_tags_in_brep_order = order_material_ids_by_brep_order(
117
+ original_ids, scrambled_ids, self.material_tags
120
118
  )
121
119
 
122
- material_tags_in_brep_order = []
123
- for brep_id, shape_id in brep_and_shape_part_ids:
124
- material_tags_in_brep_order.append(self.material_tags[shape_id - 1])
120
+ gmsh, volumes = mesh_brep(
121
+ brep_object=imprinted_assembly.wrapped._address(),
122
+ min_mesh_size=min_mesh_size,
123
+ max_mesh_size=max_mesh_size,
124
+ mesh_algorithm=mesh_algorithm,
125
+ )
125
126
 
126
- brep_to_h5m(
127
- brep_filename=tmp_brep_filename,
127
+ h5m_filename = mesh_to_h5m_in_memory_method(
128
+ volumes=volumes,
128
129
  material_tags=material_tags_in_brep_order,
129
130
  h5m_filename=filename,
130
- min_mesh_size=min_mesh_size,
131
- max_mesh_size=max_mesh_size,
132
131
  )
132
+ return h5m_filename
133
133
 
134
- def _merge_surfaces(self):
135
- """Merges surfaces in the geometry that are the same. More details on
136
- the merging process in the DAGMC docs
137
- https://svalinn.github.io/DAGMC/usersguide/cubit_basics.html"""
138
134
 
139
- # solids = geometry.Solids()
135
+ def merge_surfaces(parts):
136
+ """Merges surfaces in the geometry that are the same. More details on
137
+ the merging process in the DAGMC docs
138
+ https://svalinn.github.io/DAGMC/usersguide/cubit_basics.html"""
140
139
 
141
- bldr = OCP.BOPAlgo.BOPAlgo_Splitter()
140
+ # solids = geometry.Solids()
142
141
 
143
- if len(self.parts) == 1:
144
- # merged_solid = cq.Compound(solids)
145
- return self.parts[0]
142
+ bldr = OCP.BOPAlgo.BOPAlgo_Splitter()
146
143
 
147
- for solid in self.parts:
148
- # checks if solid is a compound as .val() is not needed for compounds
149
- if isinstance(
150
- solid, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)
151
- ):
152
- bldr.AddArgument(solid.wrapped)
153
- else:
154
- bldr.AddArgument(solid.val().wrapped)
144
+ if len(parts) == 1:
145
+ # merged_solid = cq.Compound(solids)
146
+
147
+ if isinstance(
148
+ parts[0], (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)
149
+ ):
150
+ # stp file
151
+ return parts[0], parts[0].wrapped
152
+ else:
153
+ return parts[0], parts[0].toOCC()
154
+
155
+ # else:
156
+ for solid in parts:
157
+ # checks if solid is a compound as .val() is not needed for compounds
158
+ if isinstance(solid, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
159
+ bldr.AddArgument(solid.wrapped)
160
+ else:
161
+ bldr.AddArgument(solid.val().wrapped)
155
162
 
156
- bldr.SetNonDestructive(True)
163
+ bldr.SetNonDestructive(True)
157
164
 
158
- bldr.Perform()
165
+ bldr.Perform()
159
166
 
160
- bldr.Images()
167
+ bldr.Images()
161
168
 
162
- merged_solid = cq.Compound(bldr.Shape())
169
+ merged_solid = cq.Compound(bldr.Shape())
163
170
 
164
- return merged_solid
171
+ return merged_solid, merged_solid.wrapped
@@ -207,3 +207,5 @@ def vertices_to_h5m(
207
207
  moab_core.add_entities(file_set, all_sets)
208
208
 
209
209
  moab_core.write_file(h5m_filename)
210
+
211
+ return h5m_filename