@@ -1070,6 +1070,7 @@ def __init__(self, *args, **kwargs):
10701070 self .mask = self .dist < 400
10711071 self .mask = self .mask .astype (float )
10721072 self .mask [25 :35 , 25 :35 , :] = 2
1073+ self .no , self .fc , _ , _ = v2s (self .dist < 100 , 0.5 , 2 )
10731074
10741075 self .plcno = (
10751076 np .array (
@@ -1221,15 +1222,43 @@ def test_remeshsurf(self):
12211222 no , fc , _ , _ = v2s (self .dist , 100 , 2 )
12221223 no1 , fc1 = remeshsurf (no , fc , 1 )
12231224 self .assertAlmostEqual (
1224- sum (elemvolume (no [:, :3 ], fc [:, :3 ])) * 0.0001 , 2.034550093898604 , 4
1225+ sum (elemvolume (no [:, :3 ], fc [:, :3 ])) * 0.0001 , 2.034550093898604 , 3
12251226 )
12261227
1227- # def test_surf2vol(self):
1228- # no, fc, _, _ = v2s(self.dist < 100, 0.5, 2)
1229- # vol = surf2vol(
1230- # no, fc, np.arange(19, 42, 1), np.arange(19, 42, 1), np.arange(19, 42, 1)
1231- # )
1232- # self.assertAlmostEqual(np.sum(vol.astype(np.float32)), 2.034550093898604, 4)
1228+ def test_surf2volz (self ):
1229+ vol = surf2volz (
1230+ self .no ,
1231+ self .fc ,
1232+ np .arange (19 , 42 , 1 ),
1233+ np .arange (19 , 42 , 1 ),
1234+ np .arange (19 , 42 , 1 ),
1235+ )
1236+ self .assertAlmostEqual (np .sum (vol .astype (np .float32 )) * 0.001 , 1.099 , 2 )
1237+
1238+ def test_surf2vol (self ):
1239+ vol = surf2vol (
1240+ self .no ,
1241+ self .fc ,
1242+ np .arange (19 , 42 , 1 ),
1243+ np .arange (19 , 42 , 1 ),
1244+ np .arange (19 , 42 , 1 ),
1245+ )
1246+ self .assertAlmostEqual (np .sum (vol .astype (np .float32 )) * 0.001 , 1.704 , 2 )
1247+
1248+ def test_surf2vol_fill (self ):
1249+ vol = surf2vol (
1250+ self .no ,
1251+ self .fc ,
1252+ np .arange (19 , 42 , 1 ),
1253+ np .arange (19 , 42 , 1 ),
1254+ np .arange (19 , 42 , 1 ),
1255+ fill = 1 ,
1256+ )
1257+ self .assertAlmostEqual (np .sum (vol .astype (np .float32 )) * 0.001 , 4.903 , 2 )
1258+
1259+ def test_s2v (self ):
1260+ vol = s2v (self .no , self .fc , fill = 1 )
1261+ self .assertAlmostEqual (np .sum (vol .astype (np .float32 )) * 0.0001 , 7.8651 , 2 )
12331262
12341263
12351264@unittest .skipIf (
0 commit comments