raysect / source

The main source repository for the Raysect project.
http://www.raysect.org
BSD 3-Clause "New" or "Revised" License
86 stars 23 forks source link

Add `TetraMeshData` class to handle tetrahedral mesh data #407

Open munechika-koyo opened 2 years ago

munechika-koyo commented 2 years ago

Hi,

I would like to propose this PR to introduce new class TetraMesh which is defined reffering to raysect.primitive.mesh.MeshData. When constructing a kD tree for tetrahedral meshes, MeshKDTree3D class in raysect.core.math.function.float.function3d.interpolate.common module was used, and I need more general way of handling tetrahedral vertices or indices. So, I decided to add some mesh-handling methods and put it into raysect.primitive module. According to this modification, I improved some implementations and documents.

In addition, Tetmesh in external package used in demo scripts: Py3DViewer does not work well because of incompatible with version (I guess.), so I changed to use numpy.load method to load tetrahedral vertices and indices arrays.

I would appreciate it if you would confirm my PR and marge it into develop branch:)

CnlPepper commented 2 years ago

I'm a little unsure how a tetrahedral mesh fits in the primitive module? Primitives are meant to define a surface that may or may not enclose a volume. A tetrahedral mesh doesn't just represent a surface alone. We'd need to think about where this should live, or if the primitive definition should be extended.

I've unfortunately not got much time to look through this at present as it is a large merge request. I will make one quick comment: the tetra mesh bunny file is a bit large! A simpler mesh would be sufficient for a demo.

munechika-koyo commented 2 years ago

As @CnlPepper mentioned, TetraMesh is not actual primitive objects. I think it is similar to the MeshData definition (actually I imitated it to implement TetraMesh)

the tetra mesh bunny file is a bit large! A simpler mesh would be sufficient for a demo.

I removed .mesh file due to the out of use. The numpy binary files (.npy) I added have smaller size (totally 30MB) than the .mesh file (45.9MB).

munechika-koyo commented 9 months ago

the tetra mesh bunny file is a bit large! A simpler mesh would be sufficient for a demo.

I compressed mesh data in a .npz format, including both the tetra mesh's vertices and indices. This file has a size of about 12MB. What do you think about this change?

I'm a little unsure how a tetrahedral mesh fits in the primitive module.

As you mentioned, I think the name TetraMesh should be changed to TetraMeshData because the previous one is not inherited from the Primitive object as well. I want to push this PR to implement the functionality to save/load the tetrahedral mesh structure generated by the kd-tree core like the MeshData.save or MeshData.load because it takes more time to re-generate a tetrahedral kD-tree structure than load it from a .rsm file

I would appreciate it if you would take it into account.