1
-
2
1
import os
3
2
import time
3
+ from pathlib import Path
4
+
4
5
import numpy as np
5
6
from matplotlib import pyplot as plt
6
7
7
- from raysect .optical import World , translate , Point3D , Vector3D , rotate_basis
8
8
from raysect .core .math .function .float .function3d .interpolate import Discrete3DMesh
9
+ from raysect .optical import Point3D , Vector3D , World , rotate_basis , translate
9
10
from raysect .optical .library import RoughTitanium
10
11
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
13
14
14
- BASE_PATH = os . path . split ( os . path . realpath ( __file__ ))[ 0 ]
15
+ RESOURCE_PATH = Path ( __file__ ). parent . parent / "resources"
15
16
16
17
17
18
class UnityEmitter (InhomogeneousVolumeEmitter ):
@@ -27,10 +28,13 @@ def emission_function(self, point, direction, spectrum, world, ray, primitive, t
27
28
28
29
29
30
# 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 )
33
36
tetra = Discrete3DMesh .from_mesh (mesh , np .ones (mesh .tetrahedra .shape [0 ]), limit = False , default_value = 0.0 )
37
+ print ("Done." )
34
38
35
39
# scene
36
40
world = World ()
0 commit comments