cleanup
This commit is contained in:
parent
30e6370204
commit
545753b14b
@ -22,7 +22,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "hep.dataforge"
|
||||
version = "0.2.0-dev-5"
|
||||
version = "0.2.0-dev-6"
|
||||
}
|
||||
|
||||
val githubProject by extra("visionforge")
|
||||
|
@ -3,9 +3,9 @@ package hep.dataforge.vision.gdml.demo
|
||||
import hep.dataforge.misc.DFExperimental
|
||||
import hep.dataforge.vision.Vision
|
||||
import hep.dataforge.vision.VisionManager
|
||||
import hep.dataforge.vision.gdml.readFile
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import space.kscience.gdml.Gdml
|
||||
import space.kscience.gdml.decodeFromFile
|
||||
import java.io.File
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.ZipInputStream
|
||||
@ -13,20 +13,7 @@ import java.util.zip.ZipInputStream
|
||||
@OptIn(DFExperimental::class)
|
||||
fun VisionManager.readFile(file: File): Vision = when {
|
||||
file.extension == "gdml" || file.extension == "xml" -> {
|
||||
Gdml.readFile(file.toPath()).toVision {
|
||||
// lUnit = LUnit.CM
|
||||
//
|
||||
// solidConfiguration = { parent, solid ->
|
||||
// if (solid.name == "cave") {
|
||||
// setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue())
|
||||
// }
|
||||
// if (parent.physVolumes.isNotEmpty()) {
|
||||
// useStyle("opaque") {
|
||||
// SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Gdml.decodeFromFile(file.toPath(),true).toVision()
|
||||
}
|
||||
file.extension == "json" -> decodeFromString(file.readText())
|
||||
file.name.endsWith("json.zip") -> {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
|
||||
import hep.dataforge.vision.gdml.readFile
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.solid.Solids
|
||||
import space.kscience.gdml.Gdml
|
||||
import space.kscience.gdml.LUnit
|
||||
import space.kscience.gdml.decodeFromFile
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
|
||||
@ -14,7 +14,7 @@ fun main(args: Array<String>) {
|
||||
require(inputFileName.endsWith(".gdml")) { "GDML required" }
|
||||
val outputFileName = args.getOrNull(1) ?: inputFileName.replace(".gdml", ".json")
|
||||
|
||||
val gdml = Gdml.readFile(Paths.get(inputFileName))
|
||||
val gdml = Gdml.decodeFromFile(Paths.get(inputFileName), true)
|
||||
//GDML.readFile(Paths.get("D:\\Work\\Projects\\visionforge\\visionforge-spatial-gdml\\src\\jvmTest\\resources\\gdml\\simple1.gdml"))
|
||||
|
||||
val vision = gdml.toVision {
|
||||
|
@ -60,7 +60,9 @@ internal class VisionForgePlayGroundForJupyter : JupyterIntegration() {
|
||||
"kscience.plotly.*",
|
||||
"kscience.plotly.models.*",
|
||||
"kotlinx.html.*",
|
||||
"hep.dataforge.vision.solid.*"
|
||||
"hep.dataforge.vision.solid.*",
|
||||
"hep.dataforge.vision.html.Page",
|
||||
"hep.dataforge.vision.html.page"
|
||||
)
|
||||
|
||||
import<VisionForge>()
|
||||
|
@ -26,7 +26,7 @@ public fun VisionForge.makeVisionFile(
|
||||
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
||||
show: Boolean = true,
|
||||
): Unit {
|
||||
val actualPath = page(title, content).makeFile(path) { actualPath ->
|
||||
val actualPath = page(title, content = content).makeFile(path) { actualPath ->
|
||||
mapOf("threeJs" to scriptHeader("js/visionforge-playground.js", actualPath, resourceLocation))
|
||||
}
|
||||
if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI())
|
||||
|
@ -32,7 +32,7 @@ public data class Page(
|
||||
|
||||
@DFExperimental
|
||||
public fun VisionForge.page(
|
||||
title: String,
|
||||
content: HtmlVisionFragment,
|
||||
title: String = "VisionForge page",
|
||||
vararg headers: Pair<String, HtmlFragment>,
|
||||
content: HtmlVisionFragment,
|
||||
): Page = Page(context, title, mapOf(*headers), content)
|
@ -1,20 +1,19 @@
|
||||
package hep.dataforge.vision.gdml
|
||||
|
||||
import hep.dataforge.vision.solid.SolidGroup
|
||||
import nl.adaptivity.xmlutil.StAXReader
|
||||
import space.kscience.gdml.Gdml
|
||||
import java.nio.file.Files
|
||||
import space.kscience.gdml.decodeFromFile
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
public actual typealias Counter = AtomicInteger
|
||||
|
||||
public fun Gdml.Companion.readFile(file: Path): Gdml {
|
||||
val xmlReader = StAXReader(Files.newInputStream(file), "UTF-8")
|
||||
return format.decodeFromReader(Gdml.serializer(), xmlReader)
|
||||
}
|
||||
|
||||
public fun SolidGroup.gdml(file: Path, key: String = "", transformer: GdmlTransformerSettings.() -> Unit = {}) {
|
||||
val gdml = Gdml.readFile(file)
|
||||
public fun SolidGroup.gdml(
|
||||
file: Path,
|
||||
key: String = "",
|
||||
usePreprocessor: Boolean = false,
|
||||
transformer: GdmlTransformerSettings.() -> Unit = {},
|
||||
) {
|
||||
val gdml = Gdml.decodeFromFile(file, usePreprocessor)
|
||||
gdml(gdml, key, transformer)
|
||||
}
|
||||
|
@ -34,4 +34,12 @@ class TestConvertor {
|
||||
val vision = gdml.toVision()
|
||||
//println(SolidManager.encodeToString(vision))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIaxo() {
|
||||
val stream = javaClass.getResourceAsStream("/gdml/babyIAXO.gdml")!!
|
||||
val gdml = Gdml.decodeFromStream(stream, true)
|
||||
val vision = gdml.toVision()
|
||||
println(Solids.encodeToString(vision))
|
||||
}
|
||||
}
|
1065
visionforge-gdml/src/jvmTest/resources/gdml/babyIAXO.gdml
Normal file
1065
visionforge-gdml/src/jvmTest/resources/gdml/babyIAXO.gdml
Normal file
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@ public fun VisionForge.makeThreeJsFile(
|
||||
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
||||
show: Boolean = true,
|
||||
): Unit {
|
||||
val actualPath = page(title, content).makeFile(path) { actualPath ->
|
||||
val actualPath = page(title, content = content).makeFile(path) { actualPath ->
|
||||
mapOf("threeJs" to scriptHeader("js/visionforge-three.js", actualPath, resourceLocation))
|
||||
}
|
||||
if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI())
|
||||
|
Loading…
Reference in New Issue
Block a user