Git Product home page Git Product logo

Comments (3)

shimwell avatar shimwell commented on June 8, 2024

Looking into this and I think the method of finding the bounding box can be improved. Currently it runs openmc.lib and finds the bounding box from the initilized object.

However this requires openmc to be installed.

Another way would be to load up the h5m file with meshio and obtain the bounding box. The vertices of the bounding box can then be searched to find the lower left and upper right corners, by searching for points that are greater than the centroid and less than the centroid in all dimensions. and offset (now called expand) can also be allied to the resulting bounding box

import trimesh

class dagmc_bounding_box():
    def __init__(self, h5m_filename):
        self.h5m_filename=h5m_filename
        
    def corners(self, expand=None):
        trimesh_mesh_object = trimesh.load_mesh(self.h5m_filename, process=False)
        verts =trimesh_mesh_object.bounding_box.vertices
        for vert in verts:
            print(vert)
            if vert[0]<trimesh_mesh_object.centroid[0] and vert[1]<trimesh_mesh_object.centroid[1] and vert[2]<trimesh_mesh_object.centroid[2]:
                print('upper left corner', vert)
                llc = (vert[0],vert[1],vert[2])
            if vert[0]>trimesh_mesh_object.centroid[0] and vert[1]>trimesh_mesh_object.centroid[1] and vert[2]>trimesh_mesh_object.centroid[2]:
                print('upper right corner', vert)
                urc = (vert[0],vert[1],vert[2])
        if expand:
            llc = (llc[0]-expand[0], llc[1]-expand[1], llc[2]-expand[2])
            urc = (urc[0]+expand[0], urc[1]+expand[1], urc[2]+expand[2])
        return llc, urc
        

bounding_box_for_openmc_mesh = dagmc_bounding_box('dagmc_not_merged.h5m').corners(expand=[1000, 1000, 1000])

print(bounding_box_for_openmc_mesh)

from openmc-dagmc-wrapper.

shimwell avatar shimwell commented on June 8, 2024

I'm adding this feature on this branch https://github.com/fusion-energy/openmc-dagmc-wrapper/tree/adding_offset_to_bounding_box

from openmc-dagmc-wrapper.

shimwell avatar shimwell commented on June 8, 2024

bounding box is now made in a separate package and offset can be set there

from openmc-dagmc-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.