Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposal of new feature:
TetraMeshDataTL;DR: Reading files in the created tree structure will greatly enhance the speed of the process with this PR.
Description
I would propose a new feature, the
TetraMeshDataclass, modeled after the existingMeshDatadefinition.(I have already suggested #407 but would like to split the function.)
It was implemented with the following objectives:
.rsm, which has constructed a K-D tree structure.Additionally, this class will be used when loading mesh files formatted as
.vtkor.obj, which contain tetrahedral (3-D unstructured) mesh data in the future.Examples of the use:
TetraMeshData.rsm.rsmfileSpeed test
I attempted to compare the instancing of
Discrete3DMeshwithTetraMeshDataloaded from a file.As a mesh file, I used the
stanford_bunny.meshfile located indemos/resources/.Discrete3DMeshTetraMeshDataTetraMeshDatafrom fileI attained a loading speed for tetra mesh that is approximately 9 times faster than generating
TetraMeshDatausing vertices and tetrahedral index arrays.This difference is expected to widen as the vertex data size increases.
The test script that I used is in the collapsed section below.
Test script
Class structure
The structure of the
TetraMeshDataI implemented is as follows.classDiagram class KDTree3DCore { +bint is_contained(Point3D point) +void save(object file) +void load(object file) } class TetraMeshData { +__init__(object vertices, object tetrahedra, bint tolerant=True) +__getstate__() +__setstate__(state) +__reduce__() +vertices +tetrahedra +Point3D vertex(int index) +ndarray tetrahedron(int index) +Point3D barycenter(int index) +double volume(int index) +double volume_total() +BoundingBox3D bounding_box(AffineMatrix3D to_world) +bint is_contained(Point3D point) +void save(object file) +void load(object file) +classmethod from_file(cls, file) } KDTree3DCore <|-- TetraMeshDataDetails of unit test
I also implemented a unit test for
TestMeshDatain raysect/primitive/mesh/tests/test_tetra_mesh.py.Below is a table showing the correspondence between the methods of the
TestTetraMeshDataclass in unit tests and the methods tested in theTestMeshDataclass.TestTetraMeshDataTetraMeshDatatest_initialization()__init__()test_invalid_tetrahedron_indices()__init__()test_vertex_method()vertex()test_invalid_vertex_index()vertex()test_barycenter()barycenter()test_compute_volume()volume(),volume_total()test_is_contained()is_contained()test_bounding_box()bounding_box()test_pickle_state ()__getstate__(),__setstate__(),save(),load()I would appreciate it if you would review it and make any suggestions and comments.