Skip to content

Commit

Permalink
Merge pull request #11 from fusion-energy/improved_docs
Browse files Browse the repository at this point in the history
added doc strings and comments
  • Loading branch information
shimwell authored Aug 5, 2022
2 parents 602062a + 7200a0a commit fc3d79b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Multiple non touching volumes pass tests :heavy_check_mark:

Multiple touching volumes FAIL tests :heavy_multiplication_x:

Assiging material tags to correct voulmes NON EXISTENT tests :heavy_multiplication_x:
Assigning material tags to correct volumes NON EXISTENT tests :heavy_multiplication_x:

___

Expand Down Expand Up @@ -52,20 +52,24 @@ A work around for this is to create the h5m geometry in one conda environment an

# Usage

Produces a tagged h5m file for a STP file with a single part / volume

```python
import cad_to_dagmc

stp_file = cad_to_dagmc.load_stp_file("tests/two_connected_cubes.stp")
stp_file = cad_to_dagmc.load_stp_file("tests/single_cube.stp")
vertices, triangles = cad_to_dagmc.tessellate(stp_file, tolerance=2)

vertices_to_h5m(
vertices=vertices,
triangles=triangles,
material_tags=["mat1", "mat2"],
h5m_filename="test.h5m",
material_tags=["mat1"],
h5m_filename="dagmc.h5m",
)
```

Produces a tagged h5m file for a STP file with a multiple part / volume

```python
import cad_to_dagmc

Expand All @@ -76,6 +80,6 @@ vertices_to_h5m(
vertices=vertices,
triangles=triangles,
material_tags=["mat1", "mat2", "mat3", "mat4", "mat5", "mat6"],
h5m_filename="test.h5m",
h5m_filename="dagmc.h5m",
)
````
10 changes: 7 additions & 3 deletions cad_to_dagmc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def load_stp_file(filename: str, scale_factor: float = 1.0, auto_merge=True):


def merge_surfaces(geometry):
"""Merges surfaces in the geometry that are the same"""

solids = geometry.Solids()

Expand Down Expand Up @@ -128,6 +129,7 @@ def tessellate_single_part(


def tessellate_parts(merged_solid, tolerance: float, angularTolerance: float = 0.1):

merged_solid.mesh(tolerance, angularTolerance)

offset = 0
Expand Down Expand Up @@ -205,8 +207,10 @@ def tessellate_parts(merged_solid, tolerance: float, angularTolerance: float = 0
return vertices, list_of_triangles_per_solid


def tessellate(merged_solid, tolerance: float = 0.1, angularTolerance: float = 0.1):
merged_solid.mesh(tolerance, angularTolerance)
def tessellate(parts, tolerance: float = 0.1, angularTolerance: float = 0.1):
"""Creates a mesh / faceting / tessellation of the surface"""

parts.mesh(tolerance, angularTolerance)

offset = 0

Expand All @@ -219,7 +223,7 @@ def tessellate(merged_solid, tolerance: float = 0.1, angularTolerance: float = 0

loop_counter = 0

for s in merged_solid.Solids():
for s in parts.Solids():
# print(s.hashCode())
# all_vertices[s.hashCode()] = {}
triangles_on_solids_faces[s.hashCode()] = {}
Expand Down
16 changes: 8 additions & 8 deletions tests/test_h5m_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def test_h5m_with_single_volume_list():

for stp_file, h5m_file in zip(stp_files, h5m_files):

stp_file = cad_to_dagmc.load_stp_file(stp_file)
merged_cad_obj = cad_to_dagmc.load_stp_file(stp_file)

# merged_stp_file = cad_to_dagmc.merge_surfaces(stp_file)
vertices, triangles = cad_to_dagmc.tessellate(merged_stp_file, tolerance=2)
vertices, triangles = cad_to_dagmc.tessellate(merged_cad_obj, tolerance=2)

vertices_to_h5m(
vertices=vertices,
Expand All @@ -59,9 +59,9 @@ def test_h5m_with_multi_volume_not_touching():
]
for stp_file, mat_tags, h5m_file in zip(stp_files, material_tags, h5m_files):

stp_file_object = cad_to_dagmc.load_stp_file(stp_file)
merged_stp_file = cad_to_dagmc.merge_surfaces(stp_file_object)
vertices, triangles = cad_to_dagmc.tessellate(merged_stp_file, tolerance=2)
merged_cad_obj = cad_to_dagmc.load_stp_file(stp_file)
# merged_cad_obj = cad_to_dagmc.merge_surfaces(stp_file_object)
vertices, triangles = cad_to_dagmc.tessellate(merged_cad_obj, tolerance=2)

vertices_to_h5m(
vertices=vertices,
Expand Down Expand Up @@ -92,9 +92,9 @@ def test_h5m_with_multi_volume_touching():
]
for stp_file, mat_tags, h5m_file in zip(stp_files, material_tags, h5m_files):

stp_file_object = cad_to_dagmc.load_stp_file(stp_file)
# merged_stp_file = cad_to_dagmc.merge_surfaces(stp_file_object)
vertices, triangles = cad_to_dagmc.tessellate(merged_stp_file, tolerance=2)
merged_cad_obj = cad_to_dagmc.load_stp_file(stp_file)
# merged_cad_obj = cad_to_dagmc.merge_surfaces(stp_file_object)
vertices, triangles = cad_to_dagmc.tessellate(merged_cad_obj, tolerance=2)

vertices_to_h5m(
vertices=vertices,
Expand Down

0 comments on commit fc3d79b

Please sign in to comment.