Skip to content

Commit

Permalink
returning number of volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Apr 17, 2024
1 parent a7b8733 commit 18c8db4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/cad_to_dagmc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def add_stp_file(
filename: str,
scale_factor: float = 1.0,
material_tags: typing.Optional[typing.Iterable[str]] = None,
):
) -> int:
"""Loads the parts from stp file into the model.
Args:
Expand All @@ -410,22 +410,28 @@ def add_stp_file(
used to increase the size or decrease the size of the geometry.
Useful when converting the geometry to cm for use in neutronics
simulations.
Returns:
int: number of volumes in the stp file.
"""
part = importers.importStep(str(filename)).val()

if scale_factor == 1.0:
scaled_part = part
else:
scaled_part = part.scale(scale_factor)
self.add_cadquery_object(cadquery_object=scaled_part, material_tags=material_tags)
return self.add_cadquery_object(
cadquery_object=scaled_part,
material_tags=material_tags
)

def add_cadquery_object(
self,
cadquery_object: typing.Union[
cq.assembly.Assembly, cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid
],
material_tags: typing.Optional[typing.Iterable[str]] = None,
):
) -> int:
"""Loads the parts from CadQuery object into the model.
Args:
Expand All @@ -436,6 +442,9 @@ def add_cadquery_object(
same order as the volumes in the geometry added (STP file and
CadQuery objects) and match the material tags used in the
neutronics code (e.g. OpenMC).
Returns:
int: number of volumes in the stp file.
"""

if isinstance(cadquery_object, cq.assembly.Assembly):
Expand All @@ -451,6 +460,8 @@ def add_cadquery_object(
self.material_tags = self.material_tags + material_tags
self.parts = self.parts + iterable_solids

return len(iterable_solids)

def export_unstructured_mesh_file(
self,
filename: str = "umesh.h5m",
Expand Down

0 comments on commit 18c8db4

Please sign in to comment.