fusion-energy / cad_to_dagmc

Convert CAD geometry (STP files) or Cadquery assemblies to DAGMC h5m files
MIT License
24 stars 6 forks source link

Now returning the number of volumes in the cad when calling a cad adding method #84

Closed shimwell closed 7 months ago

shimwell commented 7 months ago

this just returns the number of volumes in the cad object/stp file when they are added

this provides a way of users finding out how many material tags to add

tests have been added to the CI

shimwell commented 7 months ago

possible test idea

def test_add_cadquery_object_returned_volumes():
    """Checks that a add_cadquery_object method returns the correct number of volumes"""

    sphere1 = cq.Workplane().sphere(20)
    sphere2 = cq.Workplane().moveTo(100, 100).sphere(20)
    sphere3 = cq.Workplane().moveTo(-100, -100).sphere(20)

    c2d = CadToDagmc()
    vols = c2d.add_cadquery_object(sphere1)
    assert vols == 1

    assembly = cq.Assembly()
    assembly.add(sphere1)
    assembly.add(sphere2)
    assembly.add(sphere3)
    c2d = CadToDagmc()
    vols = c2d.add_cadquery_object(assembly)
    assert vols == 3