-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBMNTest.kt
54 lines (47 loc) · 1.56 KB
/
BMNTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package sicentifik.gdml
import kotlinx.serialization.serializer
import nl.adaptivity.xmlutil.StAXReader
import org.junit.Test
import scientifik.gdml.*
import java.io.File
import java.net.URL
class BMNTest {
@Test
fun printChildren() {
println(
GDMLDefine::class.sealedSubclasses.joinToString(
prefix = "[\"",
separator = "\", \"",
postfix = "\"]"
) { it.serializer().descriptor.name })
println(
GDMLMaterial::class.sealedSubclasses.joinToString(
prefix = "[\"",
separator = "\", \"",
postfix = "\"]"
) { it.serializer().descriptor.name })
println(
GDMLSolid::class.sealedSubclasses.joinToString(
prefix = "[\"",
separator = "\", \"",
postfix = "\"]"
) { it.serializer().descriptor.name })
}
@Test
fun testRead() {
val url = URL("https://drive.google.com/open?id=1w5e7fILMN83JGgB8WANJUYm8OW2s0WVO")
val file = File("gdml-source\\BM@N.gdml")
//val file = File("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.gdml")
val stream = if(file.exists()){
file.inputStream()
} else {
url.openStream()
}
val xmlReader = StAXReader(stream, "UTF-8")
val gdml = GDML.format.parse(GDML::class, xmlReader)
println(gdml.world)
val ref = GDMLRef<GDMLAssembly>("Magnet")
val magnet = ref.resolve(gdml)!!
println(magnet)
}
}