Skip to content

Commit 819737a

Browse files
munechika-koyomunechika-koyo
munechika-koyo
authored andcommitted
Update tetrahedra mesh demo script to follow TetraMeshData
1 parent cbe36c9 commit 819737a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

demos/materials/tetrahedra_mesh_emission.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
21
import os
32
import time
3+
from pathlib import Path
4+
45
import numpy as np
56
from matplotlib import pyplot as plt
67

7-
from raysect.optical import World, translate, Point3D, Vector3D, rotate_basis
88
from raysect.core.math.function.float.function3d.interpolate import Discrete3DMesh
9+
from raysect.optical import Point3D, Vector3D, World, rotate_basis, translate
910
from raysect.optical.library import RoughTitanium
1011
from raysect.optical.material import InhomogeneousVolumeEmitter
11-
from raysect.optical.observer import PinholeCamera, RGBPipeline2D, RGBAdaptiveSampler2D
12-
from raysect.primitive import Box, TetraMesh
12+
from raysect.optical.observer import PinholeCamera, RGBAdaptiveSampler2D, RGBPipeline2D
13+
from raysect.primitive import Box, TetraMeshData
1314

14-
BASE_PATH = os.path.split(os.path.realpath(__file__))[0]
15+
RESOURCE_PATH = Path(__file__).parent.parent / "resources"
1516

1617

1718
class UnityEmitter(InhomogeneousVolumeEmitter):
@@ -27,10 +28,13 @@ def emission_function(self, point, direction, spectrum, world, ray, primitive, t
2728

2829

2930
# Rabbit tetrahedra mesh emitter
30-
vertices = np.load(os.path.join(BASE_PATH, "../resources/stanford_bunny_vertex.npy"))
31-
tetrahedra = np.load(os.path.join(BASE_PATH, "../resources/stanford_bunny_tetra.npy"))
32-
mesh = TetraMesh(vertices, tetrahedra)
31+
data = np.load(RESOURCE_PATH / "stanford_bunny_tetra_mesh.npz")
32+
vertices = data["vertices"]
33+
tetrahedra = data["tetrahedra"]
34+
print("Creating tetra mesh...")
35+
mesh = TetraMeshData(vertices, tetrahedra)
3336
tetra = Discrete3DMesh.from_mesh(mesh, np.ones(mesh.tetrahedra.shape[0]), limit=False, default_value=0.0)
37+
print("Done.")
3438

3539
# scene
3640
world = World()

0 commit comments

Comments
 (0)