Skip to content

Commit

Permalink
adding csgtocad to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Jun 14, 2024
1 parent c3031dd commit 6e215a9
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 7 deletions.
3 changes: 3 additions & 0 deletions docs/developer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,19 @@ However we need one more dependency to run the tests.
Then we can run the tests with the following command from the root of the repository.

.. code-block:: sh
python -m pytest
We can run individual test files by specifying the file path

.. code-block:: sh
python -m pytest tests/test_convert.py
We can run individual test functions by specifying the file path and function name

.. code-block:: sh
python -m pytest tests/test_convert.py -k 'test_conversion'
Additional pytest options that might be useful are including -s for standard output and -vv for very verbose output.
Expand Down
6 changes: 4 additions & 2 deletions docs/usage/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ GEOUNED can be used as a Python package with the API or as a command line tool w
:numbered:
:maxdepth: 1

python_api_usage
python_cli_usage
python_cadtocsg_api_usage
python_cadtocsg_cli_usage
python_csgtocad_api_usage
python_csgtocad_cli_usage
4 changes: 2 additions & 2 deletions docs/usage/python_cadtocsg_api_usage.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Python Package Usage
====================
Python Package Usage, CAD to CSG conversion
===========================================

The main class is ``CadToCsg()`` which converts CAD geometry to Constructive Solid Geometry (CSG).
There are many arguments that can be passed into the ``CadToCsg()`` class which are documented in the `Python API reference section <../python_api.html>`_ of the documentation.
Expand Down
6 changes: 3 additions & 3 deletions docs/usage/python_cadtocsg_cli_usage.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Command Line Tool Usage
=======================
Command Line Tool Usage, CAD to CSG conversion
==============================================

GEOUNED can be used in the command line.
GEOUNED CAD to CSG conversion can be performed in the command line.

These examples assumes you have a CAD STEP file in the current working directory of the terminal called "cuboid.stp"

Expand Down
22 changes: 22 additions & 0 deletions docs/usage/python_csgtocad_api_usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Python Package Usage, CSG to CAD conversion
===========================================

The main class is ``CsgToCad()`` which converts Constructive Solid Geometry (CSG) to CAD.
There are a few arguments that can be passed into the ``CsgToCad()`` class which are documented in the `Python API reference section <../python_api.html>`_ of the documentation.


If you have install GEOUNED and FreeCAD into your system Python then you can simply run a .py script with Python.
The most minimal use case below shows GEOUNED being imported and the CsgToCad being used to convert a CSG geometry into a STEP CAD file.
The example makes use of default attributes.

.. code-block:: python
import geouned
Users can change :meth:`geouned.Options`, :meth:`geouned.Settings`, :meth:`geouned.Tolerances` and :meth:`geouned.NumericFormat` to suit the conversion desired.
The following example shows a usage with every attributes specified.

.. code-block:: python
import geouned
78 changes: 78 additions & 0 deletions docs/usage/python_csgtocad_cli_usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Command Line Tool Usage, CAD to CSG conversion
==============================================

GEOUNED CSG to CAD conversion can be performed in the command line.

Both OpenMC XML CSG and MCNP CSG formats are supported.

The first example assumes you have an OpenMC XML CSG file in the current working directory of the terminal called "cylinder_box.xml".

The most minimal use case below shows a minimal config_openmc.json file being used.

First create a JSON file called "config_openmc.json" containing the following.

.. code-block:: json
{
"export_cad":{
"input_filename": "cylinder_box.xml",
"csg_format": "openmc_xml"
}
}
Then execute the command line interface tool to convert your OpenMC XML CSG file to a STEP CAD file with the default configuration.

.. code-block:: bash
geouned_csgtocad -i config_openmc.json
MCNP CSG files can also be converted, this example assumes you have a MCNP CSG file in te current working directory called "cylinder_box.mcnp".

For MCNP CSG files, the JSON config file should be as follows and is assumed to be named "config_mcnp.json".


.. code-block:: json
{
"export_cad":{
"input_filename": "cylinder_box.mcnp",
"csg_format": "mcnp"
}
}
Then execute the command line interface tool to convert your MCNP CSG file to a STEP CAD file with the default configuration.

.. code-block:: bash
geouned_csgtocad -i config_mcnp.json
The following example shows a usage with every attributes specified in the config.json file.

The contents of the JSON file closely matches the Class arguments and method arguments when using the Python package.

For a full description of each keyword see the `Python API reference section <../python_api.html>`_ of the documentation.

Here is a complete JSON file specification

.. code-block:: json
{
"export_cad":{
"input_filename": "tests/csg_files/cylinder_box.xml",
"csg_format": "openmc_xml",
"output_filename" : "cad_from_csg",
"bounding_box": [-1000, -1000, -1000, 1000, 1000, 1000],
"universe_start": 0,
"level_max": "all",
"cell_range_type": "all",
"cell_range": [],
"mat_range_type": "all",
"mat_range": []
}
}
.. code-block:: bash
geouned_csgtocad -i config.json

0 comments on commit 6e215a9

Please sign in to comment.