Migrate to the new plugin
This commit is contained in:
parent
1da4381a4c
commit
60906db32e
@ -1,31 +1,35 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.project")
|
id("ru.mipt.npm.gradle.project")
|
||||||
|
kotlin("jvm") apply false
|
||||||
|
kotlin("jupyter.api") apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.3.0")
|
val dataforgeVersion by extra("0.3.0")
|
||||||
val ktorVersion by extra("1.5.1")
|
val ktorVersion by extra(ru.mipt.npm.gradle.KScienceVersions.ktorVersion)
|
||||||
val htmlVersion by extra("0.7.2")
|
val htmlVersion by extra(ru.mipt.npm.gradle.KScienceVersions.htmlVersion)
|
||||||
val kotlinWrappersVersion by extra("pre.129-kotlin-1.4.20")
|
val kotlinWrappersVersion by extra("pre.148-kotlin-1.4.30")
|
||||||
val fxVersion by extra("14")
|
val fxVersion by extra("14")
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven("https://kotlin.bintray.com/kotlin-js-wrappers")
|
||||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||||
maven("http://maven.jzy3d.org/releases")
|
maven("http://maven.jzy3d.org/releases")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "hep.dataforge"
|
group = "hep.dataforge"
|
||||||
version = "0.2.0-dev-4"
|
version = "0.2.0-dev-5"
|
||||||
}
|
}
|
||||||
|
|
||||||
val githubProject by extra("visionforge")
|
val githubProject by extra("visionforge")
|
||||||
val bintrayRepo by extra("dataforge")
|
val bintrayRepo by extra("dataforge")
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
if(name.startsWith("visionforge")) {
|
if (name.startsWith("visionforge")) {
|
||||||
apply<ru.mipt.npm.gradle.KSciencePublishPlugin>()
|
plugins.apply("ru.mipt.npm.gradle.publish")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import ru.mipt.npm.gradle.DependencyConfiguration
|
|||||||
import ru.mipt.npm.gradle.FXModule
|
import ru.mipt.npm.gradle.FXModule
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package hep.dataforge.vision.gdml.demo
|
package hep.dataforge.vision.gdml.demo
|
||||||
|
|
||||||
import kscience.gdml.*
|
import space.kscience.gdml.*
|
||||||
|
|
||||||
|
|
||||||
fun cubes(): GDML = GDML {
|
fun cubes(): Gdml = Gdml {
|
||||||
val center = define.position("center")
|
val center = define.position("center")
|
||||||
structure {
|
structure {
|
||||||
val air = ref<GDMLMaterial>("G4_AIR")
|
val air = ref<GdmlMaterial>("G4_AIR")
|
||||||
val tubeMaterial = ref<GDMLMaterial>("tube")
|
val tubeMaterial = ref<GdmlMaterial>("tube")
|
||||||
val boxMaterial = ref<GDMLMaterial>("box")
|
val boxMaterial = ref<GdmlMaterial>("box")
|
||||||
val segment = solids.tube("segment", 20, 5.0) {
|
val segment = solids.tube("segment", 20, 5.0) {
|
||||||
rmin = 17
|
rmin = 17
|
||||||
deltaphi = 60
|
deltaphi = 60
|
||||||
|
@ -15,8 +15,8 @@ import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
|||||||
import hep.dataforge.vision.solid.three.ThreeCanvas
|
import hep.dataforge.vision.solid.three.ThreeCanvas
|
||||||
import kotlinx.browser.window
|
import kotlinx.browser.window
|
||||||
import kotlinx.css.*
|
import kotlinx.css.*
|
||||||
import kscience.gdml.GDML
|
import space.kscience.gdml.Gdml
|
||||||
import kscience.gdml.decodeFromString
|
import space.kscience.gdml.decodeFromString
|
||||||
import org.w3c.files.FileReader
|
import org.w3c.files.FileReader
|
||||||
import org.w3c.files.get
|
import org.w3c.files.get
|
||||||
import react.RProps
|
import react.RProps
|
||||||
@ -55,7 +55,7 @@ val GDMLApp = functionalComponent<GDMLAppProps>("GDMLApp") { props ->
|
|||||||
val visionManager = props.context.plugins.fetch(SolidManager).visionManager
|
val visionManager = props.context.plugins.fetch(SolidManager).visionManager
|
||||||
val parsedVision = when {
|
val parsedVision = when {
|
||||||
name.endsWith(".gdml") || name.endsWith(".xml") -> {
|
name.endsWith(".gdml") || name.endsWith(".xml") -> {
|
||||||
val gdml = GDML.decodeFromString(data)
|
val gdml = Gdml.decodeFromString(data)
|
||||||
gdml.toVision()
|
gdml.toVision()
|
||||||
}
|
}
|
||||||
name.endsWith(".json") -> visionManager.decodeFromString(data)
|
name.endsWith(".json") -> visionManager.decodeFromString(data)
|
||||||
|
@ -9,7 +9,7 @@ import hep.dataforge.vision.solid.SolidManager
|
|||||||
import hep.dataforge.vision.solid.SolidMaterial
|
import hep.dataforge.vision.solid.SolidMaterial
|
||||||
import hep.dataforge.vision.Vision
|
import hep.dataforge.vision.Vision
|
||||||
import hep.dataforge.vision.VisionManager
|
import hep.dataforge.vision.VisionManager
|
||||||
import kscience.gdml.GDML
|
import space.kscience.gdml.Gdml
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.zip.GZIPInputStream
|
import java.util.zip.GZIPInputStream
|
||||||
import java.util.zip.ZipInputStream
|
import java.util.zip.ZipInputStream
|
||||||
@ -17,7 +17,7 @@ import java.util.zip.ZipInputStream
|
|||||||
@OptIn(DFExperimental::class)
|
@OptIn(DFExperimental::class)
|
||||||
fun VisionManager.readFile(file: File): Vision = when {
|
fun VisionManager.readFile(file: File): Vision = when {
|
||||||
file.extension == "gdml" || file.extension == "xml" -> {
|
file.extension == "gdml" || file.extension == "xml" -> {
|
||||||
GDML.readFile(file.toPath()).toVision {
|
Gdml.readFile(file.toPath()).toVision {
|
||||||
// lUnit = LUnit.CM
|
// lUnit = LUnit.CM
|
||||||
//
|
//
|
||||||
// solidConfiguration = { parent, solid ->
|
// solidConfiguration = { parent, solid ->
|
||||||
|
@ -3,8 +3,8 @@ package hep.dataforge.vision.gdml.demo
|
|||||||
import hep.dataforge.vision.gdml.readFile
|
import hep.dataforge.vision.gdml.readFile
|
||||||
import hep.dataforge.vision.gdml.toVision
|
import hep.dataforge.vision.gdml.toVision
|
||||||
import hep.dataforge.vision.solid.SolidManager
|
import hep.dataforge.vision.solid.SolidManager
|
||||||
import kscience.gdml.GDML
|
import space.kscience.gdml.Gdml
|
||||||
import kscience.gdml.LUnit
|
import space.kscience.gdml.LUnit
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ fun main(args: Array<String>) {
|
|||||||
require(inputFileName.endsWith(".gdml")){"GDML required"}
|
require(inputFileName.endsWith(".gdml")){"GDML required"}
|
||||||
val outputFileName = args.getOrNull(1)?:inputFileName.replace(".gdml",".json")
|
val outputFileName = args.getOrNull(1)?:inputFileName.replace(".gdml",".json")
|
||||||
|
|
||||||
val gdml = GDML.readFile(Paths.get(inputFileName))
|
val gdml = Gdml.readFile(Paths.get(inputFileName))
|
||||||
//GDML.readFile(Paths.get("D:\\Work\\Projects\\visionforge\\visionforge-spatial-gdml\\src\\jvmTest\\resources\\gdml\\simple1.gdml"))
|
//GDML.readFile(Paths.get("D:\\Work\\Projects\\visionforge\\visionforge-spatial-gdml\\src\\jvmTest\\resources\\gdml\\simple1.gdml"))
|
||||||
|
|
||||||
val vision = gdml.toVision {
|
val vision = gdml.toVision {
|
||||||
|
36
demo/jupyter-playground/build.gradle.kts
Normal file
36
demo/jupyter-playground/build.gradle.kts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
kotlin("jupyter.api")
|
||||||
|
id("com.github.johnrengelman.shadow") version "6.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://repo.kotlin.link")
|
||||||
|
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
||||||
|
maven("https://dl.bintray.com/mipt-npm/kscience")
|
||||||
|
maven("https://dl.bintray.com/mipt-npm/dev")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":demo:playground"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
useIR = true
|
||||||
|
jvmTarget = ru.mipt.npm.gradle.KScienceVersions.JVM_TARGET.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||||
|
targetCompatibility = ru.mipt.npm.gradle.KScienceVersions.JVM_TARGET
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.processJupyterApiResources {
|
||||||
|
libraryProducers = listOf("hep.dataforge.playground.VisionForgePlayGroundForJupyter")
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package hep.dataforge.playground
|
||||||
|
|
||||||
|
import hep.dataforge.context.Context
|
||||||
|
import hep.dataforge.vision.VisionManager
|
||||||
|
import hep.dataforge.vision.gdml.gdml
|
||||||
|
import hep.dataforge.vision.html.Page
|
||||||
|
import hep.dataforge.vision.html.embedVisionFragment
|
||||||
|
import hep.dataforge.vision.html.fragment
|
||||||
|
import hep.dataforge.vision.html.scriptHeader
|
||||||
|
import hep.dataforge.vision.plotly.PlotlyPlugin
|
||||||
|
import hep.dataforge.vision.plotly.VisionOfPlotly
|
||||||
|
import hep.dataforge.vision.solid.SolidManager
|
||||||
|
import hep.dataforge.vision.solid.solid
|
||||||
|
import hep.dataforge.vision.visionManager
|
||||||
|
import kotlinx.html.div
|
||||||
|
import kotlinx.html.stream.createHTML
|
||||||
|
import kscience.plotly.Plot
|
||||||
|
import kscience.plotly.PlotlyFragment
|
||||||
|
import org.jetbrains.kotlinx.jupyter.api.HTML
|
||||||
|
import org.jetbrains.kotlinx.jupyter.api.Notebook
|
||||||
|
import org.jetbrains.kotlinx.jupyter.api.annotations.JupyterLibrary
|
||||||
|
import org.jetbrains.kotlinx.jupyter.api.libraries.*
|
||||||
|
import space.kscience.gdml.Gdml
|
||||||
|
|
||||||
|
@JupyterLibrary
|
||||||
|
internal class VisionForgePlayGroundForJupyter : JupyterIntegration() {
|
||||||
|
|
||||||
|
private val context = Context("Playground") {
|
||||||
|
plugin(SolidManager)
|
||||||
|
plugin(PlotlyPlugin)
|
||||||
|
}
|
||||||
|
|
||||||
|
val jsBundle = ResourceFallbacksBundle(listOf(ResourceLocation("js/visionforge-playground.js",
|
||||||
|
ResourcePathType.CLASSPATH_PATH)))
|
||||||
|
val jsResource = LibraryResource(name = "VisionForge", type = ResourceType.JS, bundles = listOf(jsBundle))
|
||||||
|
|
||||||
|
override fun Builder.onLoaded(notebook: Notebook?) {
|
||||||
|
resource(jsResource)
|
||||||
|
|
||||||
|
import("space.kscience.gdml.*", "kscience.plotly.*", "kscience.plotly.models.*")
|
||||||
|
|
||||||
|
onLoaded {
|
||||||
|
val header = scriptHeader("js/visionforge-playground.js", null, hep.dataforge.vision.html.ResourceLocation.EMBED)
|
||||||
|
display(HTML(createHTML().apply(header).finalize()))
|
||||||
|
}
|
||||||
|
|
||||||
|
render<Gdml> { gdmlModel ->
|
||||||
|
val fragment = VisionManager.fragment {
|
||||||
|
vision {
|
||||||
|
solid {
|
||||||
|
gdml(gdmlModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val html = createHTML().div {
|
||||||
|
embedVisionFragment(context.visionManager, fragment = fragment)
|
||||||
|
}
|
||||||
|
|
||||||
|
HTML(html)
|
||||||
|
}
|
||||||
|
|
||||||
|
render<Plot> { plot ->
|
||||||
|
val fragment = VisionManager.fragment {
|
||||||
|
vision {
|
||||||
|
VisionOfPlotly(plot.config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val html = createHTML().div {
|
||||||
|
embedVisionFragment(context.visionManager, fragment = fragment)
|
||||||
|
}
|
||||||
|
|
||||||
|
HTML(html)
|
||||||
|
}
|
||||||
|
|
||||||
|
render<kscience.plotly.HtmlFragment> { fragment ->
|
||||||
|
HTML(createHTML().apply(fragment.visit).finalize())
|
||||||
|
}
|
||||||
|
|
||||||
|
render<Page> { page ->
|
||||||
|
HTML(page.render(createHTML()), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt")
|
mainClass.set("ru.mipt.npm.gradle.muon.monitor.server.MMServerKt")
|
||||||
}
|
}
|
||||||
|
|
||||||
distributions {
|
distributions {
|
||||||
|
@ -46,22 +46,22 @@ kotlin {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":visionforge-solid"))
|
api(project(":visionforge-solid"))
|
||||||
implementation(project(":visionforge-gdml"))
|
api(project(":visionforge-gdml"))
|
||||||
implementation(project(":visionforge-plotly"))
|
api(project(":visionforge-plotly"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsMain by getting{
|
val jsMain by getting{
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":ui:bootstrap"))
|
api(project(":ui:bootstrap"))
|
||||||
implementation(project(":visionforge-threejs"))
|
api(project(":visionforge-threejs"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jvmMain by getting{
|
val jvmMain by getting{
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":visionforge-server"))
|
api(project(":visionforge-server"))
|
||||||
implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6")
|
implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6")
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,8 +6,6 @@ import hep.dataforge.vision.VisionManager
|
|||||||
import hep.dataforge.vision.html.fragment
|
import hep.dataforge.vision.html.fragment
|
||||||
import hep.dataforge.vision.plotly.plotly
|
import hep.dataforge.vision.plotly.plotly
|
||||||
import hep.dataforge.vision.plotly.withPlotly
|
import hep.dataforge.vision.plotly.withPlotly
|
||||||
import kotlinx.html.hr
|
|
||||||
import kotlinx.html.p
|
|
||||||
import kscience.plotly.scatter
|
import kscience.plotly.scatter
|
||||||
|
|
||||||
@DFExperimental
|
@DFExperimental
|
@ -4,9 +4,9 @@ import hep.dataforge.context.Context
|
|||||||
import hep.dataforge.misc.DFExperimental
|
import hep.dataforge.misc.DFExperimental
|
||||||
import hep.dataforge.vision.html.HtmlVisionFragment
|
import hep.dataforge.vision.html.HtmlVisionFragment
|
||||||
import hep.dataforge.vision.html.ResourceLocation
|
import hep.dataforge.vision.html.ResourceLocation
|
||||||
|
import hep.dataforge.vision.html.page
|
||||||
import hep.dataforge.vision.html.scriptHeader
|
import hep.dataforge.vision.html.scriptHeader
|
||||||
import hep.dataforge.vision.makeFile
|
import hep.dataforge.vision.makeFile
|
||||||
import hep.dataforge.vision.page
|
|
||||||
import hep.dataforge.vision.three.server.VisionServer
|
import hep.dataforge.vision.three.server.VisionServer
|
||||||
import hep.dataforge.vision.three.server.useScript
|
import hep.dataforge.vision.three.server.useScript
|
||||||
import java.awt.Desktop
|
import java.awt.Desktop
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.jvm")
|
id("ru.mipt.npm.gradle.jvm")
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,5 +18,5 @@ dependencies{
|
|||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClass.set("ru.mipt.npm.sat.SatServerKt")
|
mainClass.set("ru.mipt.npm.gradle.sat.SatServerKt")
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import ru.mipt.npm.gradle.DependencyConfiguration
|
|||||||
import ru.mipt.npm.gradle.FXModule
|
import ru.mipt.npm.gradle.FXModule
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,10 @@ import hep.dataforge.meta.*
|
|||||||
import hep.dataforge.names.plus
|
import hep.dataforge.names.plus
|
||||||
import hep.dataforge.names.startsWith
|
import hep.dataforge.names.startsWith
|
||||||
import hep.dataforge.values.asValue
|
import hep.dataforge.values.asValue
|
||||||
|
import hep.dataforge.vision.getProperty
|
||||||
import hep.dataforge.vision.onPropertyChange
|
import hep.dataforge.vision.onPropertyChange
|
||||||
|
import hep.dataforge.vision.set
|
||||||
|
import hep.dataforge.vision.setProperty
|
||||||
import hep.dataforge.vision.solid.*
|
import hep.dataforge.vision.solid.*
|
||||||
import hep.dataforge.vision.solid.Solid.Companion.GEOMETRY_KEY
|
import hep.dataforge.vision.solid.Solid.Companion.GEOMETRY_KEY
|
||||||
import hep.dataforge.vision.solid.three.*
|
import hep.dataforge.vision.solid.three.*
|
||||||
|
@ -14,4 +14,6 @@ The actual layering scheme is more complicated. All objects support styling. The
|
|||||||
|
|
||||||
### Intermediate representation
|
### Intermediate representation
|
||||||
|
|
||||||
|
An important thing about VisionForge is that it does not strictly bound to a single format representation.
|
||||||
|
|
||||||
### Kotlin DSL for creating vision-graphs
|
### Kotlin DSL for creating vision-graphs
|
@ -74,4 +74,4 @@ Not all GDML solids are currently supported by the converter, they could be adde
|
|||||||
|
|
||||||
VisionForge is not tied to any single renderer. Right now the primary target is the Browser rendering with [Three.js library](https://threejs.org/). The Three.js supports different renderers including WebGL with hardware support and virtual reality.
|
VisionForge is not tied to any single renderer. Right now the primary target is the Browser rendering with [Three.js library](https://threejs.org/). The Three.js supports different renderers including WebGL with hardware support and virtual reality.
|
||||||
|
|
||||||
The bindings for three-js was implemented in kotlin-js based on a [work by Lars Ivar Hatledal](https://github.com/markaren/three-kt-wrapper). The wrapper allows seamless integration with a lot of different library APIs incliding custom cameras and CSG.
|
The bindings for three-js was implemented in kotlin-js based on a [work by Lars Ivar Hatledal](https://github.com/markaren/three-kt-wrapper). The wrapper allows seamless integration with a lot of different library APIs including custom cameras and CSG.
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
val kotlinVersion = "1.4.30"
|
val kotlinVersion = "1.4.30"
|
||||||
val toolsVersion = "0.7.6"
|
val toolsVersion = "0.8.3"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
maven("https://repo.kotlin.link")
|
||||||
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
|
||||||
maven("https://dl.bintray.com/kotlin/kotlinx")
|
|
||||||
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
|
||||||
maven("https://dl.bintray.com/mipt-npm/kscience")
|
|
||||||
maven("https://dl.bintray.com/mipt-npm/dev")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.project") version toolsVersion
|
id("ru.mipt.npm.gradle.project") version toolsVersion
|
||||||
id("ru.mipt.npm.mpp") version toolsVersion
|
id("ru.mipt.npm.gradle.mpp") version toolsVersion
|
||||||
id("ru.mipt.npm.jvm") version toolsVersion
|
id("ru.mipt.npm.gradle.jvm") version toolsVersion
|
||||||
id("ru.mipt.npm.js") version toolsVersion
|
id("ru.mipt.npm.gradle.js") version toolsVersion
|
||||||
id("ru.mipt.npm.publish") version toolsVersion
|
id("ru.mipt.npm.gradle.publish") version toolsVersion
|
||||||
kotlin("jvm") version kotlinVersion
|
kotlin("jvm") version kotlinVersion
|
||||||
|
kotlin("jupyter.api") version "0.8.3.218"
|
||||||
kotlin("js") version kotlinVersion
|
kotlin("js") version kotlinVersion
|
||||||
kotlin("multiplatform") version kotlinVersion
|
kotlin("multiplatform") version kotlinVersion
|
||||||
}
|
}
|
||||||
@ -45,8 +43,9 @@ include(
|
|||||||
":visionforge-server",
|
":visionforge-server",
|
||||||
":visionforge-plotly",
|
":visionforge-plotly",
|
||||||
":demo:solid-showcase",
|
":demo:solid-showcase",
|
||||||
// ":demo:gdml",
|
":demo:gdml",
|
||||||
":demo:muon-monitor",
|
":demo:muon-monitor",
|
||||||
":demo:sat-demo"
|
":demo:sat-demo",
|
||||||
// ":playground"
|
":demo:playground",
|
||||||
|
":demo:jupyter-playground"
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.js")
|
id("ru.mipt.npm.gradle.js")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion: String by rootProject.extra
|
val dataforgeVersion: String by rootProject.extra
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.js")
|
id("ru.mipt.npm.gradle.js")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion: String by rootProject.extra
|
val dataforgeVersion: String by rootProject.extra
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.js")
|
id("ru.mipt.npm.gradle.js")
|
||||||
}
|
}
|
||||||
|
|
||||||
val reactVersion by extra("17.0.0")
|
val reactVersion by extra("17.0.1")
|
||||||
val kotlinWrappersVersion: String by rootProject.extra
|
val kotlinWrappersVersion: String by rootProject.extra
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
api(project(":visionforge-solid"))
|
api(project(":visionforge-solid"))
|
||||||
api("org.jetbrains:kotlin-styled:5.2.0-$kotlinWrappersVersion")
|
api("org.jetbrains:kotlin-styled:5.2.1-$kotlinWrappersVersion")
|
||||||
api("org.jetbrains:kotlin-react-dom:$reactVersion-$kotlinWrappersVersion")
|
api("org.jetbrains:kotlin-react-dom:$reactVersion-$kotlinWrappersVersion")
|
||||||
implementation(project(":visionforge-threejs"))
|
implementation(project(":visionforge-threejs"))
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.js")
|
id("ru.mipt.npm.gradle.js")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion: String by rootProject.extra
|
val dataforgeVersion: String by rootProject.extra
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion: String by rootProject.extra
|
val dataforgeVersion: String by rootProject.extra
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package hep.dataforge.vision.html
|
package hep.dataforge.vision.html
|
||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
|
import hep.dataforge.misc.DFExperimental
|
||||||
import hep.dataforge.vision.visionManager
|
import hep.dataforge.vision.visionManager
|
||||||
import kotlinx.html.*
|
import kotlinx.html.*
|
||||||
|
import kotlinx.html.stream.createHTML
|
||||||
|
|
||||||
public data class Page(
|
public data class Page(
|
||||||
public val context: Context,
|
public val context: Context,
|
||||||
@ -24,4 +26,12 @@ public data class Page(
|
|||||||
embedVisionFragment(context.visionManager, fragment = content)
|
embedVisionFragment(context.visionManager, fragment = content)
|
||||||
}
|
}
|
||||||
}.finalize()
|
}.finalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DFExperimental
|
||||||
|
public fun Context.page(
|
||||||
|
title: String,
|
||||||
|
content: HtmlVisionFragment,
|
||||||
|
vararg headers: Pair<String, HtmlFragment>,
|
||||||
|
): Page = Page(this, title, mapOf(*headers), content)
|
@ -56,25 +56,17 @@ import java.nio.file.Path
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@DFExperimental
|
|
||||||
public fun Context.page(
|
|
||||||
title: String,
|
|
||||||
content: HtmlVisionFragment,
|
|
||||||
vararg headers: Pair<String, HtmlFragment>,
|
|
||||||
): Page = Page(this, title, mapOf(*headers), content)
|
|
||||||
|
|
||||||
|
|
||||||
@DFExperimental
|
@DFExperimental
|
||||||
public fun Page.makeFile(
|
public fun Page.makeFile(
|
||||||
path: Path?,
|
path: Path?,
|
||||||
defaultHeaders: ((Path) -> Map<String,HtmlFragment>)? = null,
|
defaultHeaders: ((Path) -> Map<String, HtmlFragment>)? = null,
|
||||||
): Path {
|
): Path {
|
||||||
val actualFile = path?.let {
|
val actualFile = path?.let {
|
||||||
Path.of(System.getProperty("user.home")).resolve(path)
|
Path.of(System.getProperty("user.home")).resolve(path)
|
||||||
} ?: Files.createTempFile("tempPlot", ".html")
|
} ?: Files.createTempFile("tempPlot", ".html")
|
||||||
|
|
||||||
val actualDefaultHeaders = defaultHeaders?.invoke(actualFile)
|
val actualDefaultHeaders = defaultHeaders?.invoke(actualFile)
|
||||||
val actualPage = if(actualDefaultHeaders == null) this else copy(headers = actualDefaultHeaders + headers)
|
val actualPage = if (actualDefaultHeaders == null) this else copy(headers = actualDefaultHeaders + headers)
|
||||||
|
|
||||||
val htmlString = actualPage.render(createHTML())
|
val htmlString = actualPage.render(createHTML())
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.jvm")
|
id("ru.mipt.npm.gradle.jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion: String by rootProject.extra
|
val dataforgeVersion: String by rootProject.extra
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
@ -7,7 +7,7 @@ kotlin {
|
|||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":visionforge-solid"))
|
api(project(":visionforge-solid"))
|
||||||
api("kscience.gdml:gdml:0.2.0")
|
api("space.kscience:gdml:0.2.0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import hep.dataforge.vision.solid.*
|
|||||||
import hep.dataforge.vision.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY
|
import hep.dataforge.vision.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY
|
||||||
import hep.dataforge.vision.styleSheet
|
import hep.dataforge.vision.styleSheet
|
||||||
import hep.dataforge.vision.useStyle
|
import hep.dataforge.vision.useStyle
|
||||||
import kscience.gdml.*
|
import space.kscience.gdml.*
|
||||||
import kotlin.math.cos
|
import kotlin.math.cos
|
||||||
import kotlin.math.sin
|
import kotlin.math.sin
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
@ -26,7 +26,7 @@ private inline operator fun Number.times(d: Double) = toDouble() * d
|
|||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
private inline operator fun Number.times(f: Float) = toFloat() * f
|
private inline operator fun Number.times(f: Float) = toFloat() * f
|
||||||
|
|
||||||
public class GDMLTransformerSettings {
|
public class GdmlTransformerSettings {
|
||||||
public enum class Action {
|
public enum class Action {
|
||||||
ADD,
|
ADD,
|
||||||
REJECT,
|
REJECT,
|
||||||
@ -36,12 +36,12 @@ public class GDMLTransformerSettings {
|
|||||||
public var lUnit: LUnit = LUnit.CM
|
public var lUnit: LUnit = LUnit.CM
|
||||||
public var aUnit: AUnit = AUnit.RADIAN
|
public var aUnit: AUnit = AUnit.RADIAN
|
||||||
|
|
||||||
public var solidAction: (GDMLSolid) -> Action = { Action.PROTOTYPE }
|
public var solidAction: (GdmlSolid) -> Action = { Action.PROTOTYPE }
|
||||||
public var volumeAction: (GDMLGroup) -> Action = { Action.PROTOTYPE }
|
public var volumeAction: (GdmlGroup) -> Action = { Action.PROTOTYPE }
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
private class GdmlTransformer(val settings: GdmlTransformerSettings) {
|
||||||
//private val materialCache = HashMap<GDMLMaterial, Meta>()
|
//private val materialCache = HashMap<GdmlMaterial, Meta>()
|
||||||
private val random = Random(222)
|
private val random = Random(222)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +56,7 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
|
|
||||||
private val referenceStore = HashMap<Name, MutableList<SolidReferenceGroup>>()
|
private val referenceStore = HashMap<Name, MutableList<SolidReferenceGroup>>()
|
||||||
|
|
||||||
private fun proxySolid(root: GDML, group: SolidGroup, solid: GDMLSolid, name: String): SolidReferenceGroup {
|
private fun proxySolid(root: Gdml, group: SolidGroup, solid: GdmlSolid, name: String): SolidReferenceGroup {
|
||||||
val templateName = solidsName + name
|
val templateName = solidsName + name
|
||||||
if (proto[templateName] == null) {
|
if (proto[templateName] == null) {
|
||||||
solids.addSolid(root, solid, name)
|
solids.addSolid(root, solid, name)
|
||||||
@ -66,7 +66,7 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
return ref
|
return ref
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun proxyVolume(root: GDML, group: SolidGroup, physVolume: GDMLPhysVolume, volume: GDMLGroup): SolidReferenceGroup {
|
private fun proxyVolume(root: Gdml, group: SolidGroup, physVolume: GdmlPhysVolume, volume: GdmlGroup): SolidReferenceGroup {
|
||||||
val templateName = volumesName + volume.name.asName()
|
val templateName = volumesName + volume.name.asName()
|
||||||
if (proto[templateName] == null) {
|
if (proto[templateName] == null) {
|
||||||
proto[templateName] = volume(root, volume)
|
proto[templateName] = volume(root, volume)
|
||||||
@ -78,7 +78,7 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
|
|
||||||
private val styleCache = HashMap<Name, Meta>()
|
private val styleCache = HashMap<Name, Meta>()
|
||||||
|
|
||||||
var solidConfiguration: Solid.(parent: GDMLVolume, solid: GDMLSolid) -> Unit = { parent, _ ->
|
var solidConfiguration: Solid.(parent: GdmlVolume, solid: GdmlSolid) -> Unit = { parent, _ ->
|
||||||
if (parent.physVolumes.isNotEmpty()) {
|
if (parent.physVolumes.isNotEmpty()) {
|
||||||
useStyle("opaque") {
|
useStyle("opaque") {
|
||||||
SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
|
SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
|
||||||
@ -94,23 +94,23 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
useStyle(name)
|
useStyle(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun configureSolid(root: GDML, obj: Solid, parent: GDMLVolume, solid: GDMLSolid) {
|
fun configureSolid(root: Gdml, obj: Solid, parent: GdmlVolume, solid: GdmlSolid) {
|
||||||
val material = parent.materialref.resolve(root) ?: GDMLElement(parent.materialref.ref)
|
val material = parent.materialref.resolve(root) ?: GdmlElement(parent.materialref.ref)
|
||||||
|
|
||||||
val styleName = "materials.${material.name}"
|
val styleName = "materials.${material.name}"
|
||||||
|
|
||||||
obj.useStyle(styleName) {
|
obj.useStyle(styleName) {
|
||||||
MATERIAL_COLOR_KEY put random.nextInt(16777216)
|
MATERIAL_COLOR_KEY put random.nextInt(16777216)
|
||||||
"gdml.material" put material.name
|
"Gdml.material" put material.name
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.solidConfiguration(parent, solid)
|
obj.solidConfiguration(parent, solid)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Solid> T.withPosition(
|
fun <T : Solid> T.withPosition(
|
||||||
newPos: GDMLPosition? = null,
|
newPos: GdmlPosition? = null,
|
||||||
newRotation: GDMLRotation? = null,
|
newRotation: GdmlRotation? = null,
|
||||||
newScale: GDMLScale? = null,
|
newScale: GdmlScale? = null,
|
||||||
): T = apply {
|
): T = apply {
|
||||||
newPos?.let {
|
newPos?.let {
|
||||||
val point = Point3D(it.x(settings.lUnit), it.y(settings.lUnit), it.z(settings.lUnit))
|
val point = Point3D(it.x(settings.lUnit), it.y(settings.lUnit), it.z(settings.lUnit))
|
||||||
@ -134,23 +134,23 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
//TODO convert units if needed
|
//TODO convert units if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Solid> T.withPosition(root: GDML, physVolume: GDMLPhysVolume): T = withPosition(
|
fun <T : Solid> T.withPosition(root: Gdml, physVolume: GdmlPhysVolume): T = withPosition(
|
||||||
physVolume.resolvePosition(root),
|
physVolume.resolvePosition(root),
|
||||||
physVolume.resolveRotation(root),
|
physVolume.resolveRotation(root),
|
||||||
physVolume.resolveScale(root)
|
physVolume.resolveScale(root)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun SolidGroup.addSolid(
|
fun SolidGroup.addSolid(
|
||||||
root: GDML,
|
root: Gdml,
|
||||||
solid: GDMLSolid,
|
solid: GdmlSolid,
|
||||||
name: String = "",
|
name: String = "",
|
||||||
): Solid {
|
): Solid {
|
||||||
//context.solidAdded(solid)
|
//context.solidAdded(solid)
|
||||||
val lScale = solid.lscale(settings.lUnit)
|
val lScale = solid.lscale(settings.lUnit)
|
||||||
val aScale = solid.ascale()
|
val aScale = solid.ascale()
|
||||||
return when (solid) {
|
return when (solid) {
|
||||||
is GDMLBox -> box(solid.x * lScale, solid.y * lScale, solid.z * lScale, name)
|
is GdmlBox -> box(solid.x * lScale, solid.y * lScale, solid.z * lScale, name)
|
||||||
is GDMLTube -> tube(
|
is GdmlTube -> tube(
|
||||||
solid.rmax * lScale,
|
solid.rmax * lScale,
|
||||||
solid.z * lScale,
|
solid.z * lScale,
|
||||||
solid.rmin * lScale,
|
solid.rmin * lScale,
|
||||||
@ -158,13 +158,13 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
solid.deltaphi * aScale,
|
solid.deltaphi * aScale,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
is GDMLCone -> cone(solid.rmax1, solid.z, solid.rmax2, name = name) {
|
is GdmlCone -> cone(solid.rmax1, solid.z, solid.rmax2, name = name) {
|
||||||
require(solid.rmin1 == 0.0) { "Empty cones are not supported" }
|
require(solid.rmin1 == 0.0) { "Empty cones are not supported" }
|
||||||
require(solid.rmin2 == 0.0) { "Empty cones are not supported" }
|
require(solid.rmin2 == 0.0) { "Empty cones are not supported" }
|
||||||
startAngle = solid.startphi.toFloat()
|
startAngle = solid.startphi.toFloat()
|
||||||
angle = solid.deltaphi.toFloat()
|
angle = solid.deltaphi.toFloat()
|
||||||
}
|
}
|
||||||
is GDMLXtru -> extrude(name) {
|
is GdmlXtru -> extrude(name) {
|
||||||
shape {
|
shape {
|
||||||
solid.vertices.forEach {
|
solid.vertices.forEach {
|
||||||
point(it.x * lScale, it.y * lScale)
|
point(it.x * lScale, it.y * lScale)
|
||||||
@ -179,9 +179,9 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is GDMLScaledSolid -> {
|
is GdmlScaledSolid -> {
|
||||||
//Add solid with modified scale
|
//Add solid with modified scale
|
||||||
val innerSolid: GDMLSolid = solid.solidref.resolve(root)
|
val innerSolid: GdmlSolid = solid.solidref.resolve(root)
|
||||||
?: error("Solid with tag ${solid.solidref.ref} for scaled solid ${solid.name} not defined")
|
?: error("Solid with tag ${solid.solidref.ref} for scaled solid ${solid.name} not defined")
|
||||||
|
|
||||||
addSolid(root, innerSolid, name).apply {
|
addSolid(root, innerSolid, name).apply {
|
||||||
@ -190,12 +190,12 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
scaleZ = solid.scale.z.toFloat()
|
scaleZ = solid.scale.z.toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is GDMLSphere -> sphere(solid.rmax * lScale, solid.deltaphi * aScale, solid.deltatheta * aScale, name) {
|
is GdmlSphere -> sphere(solid.rmax * lScale, solid.deltaphi * aScale, solid.deltatheta * aScale, name) {
|
||||||
phiStart = solid.startphi * aScale
|
phiStart = solid.startphi * aScale
|
||||||
thetaStart = solid.starttheta * aScale
|
thetaStart = solid.starttheta * aScale
|
||||||
}
|
}
|
||||||
is GDMLOrb -> sphere(solid.r * lScale, name = name)
|
is GdmlOrb -> sphere(solid.r * lScale, name = name)
|
||||||
is GDMLPolyhedra -> extrude(name) {
|
is GdmlPolyhedra -> extrude(name) {
|
||||||
//getting the radius of first
|
//getting the radius of first
|
||||||
require(solid.planes.size > 1) { "The polyhedron geometry requires at least two planes" }
|
require(solid.planes.size > 1) { "The polyhedron geometry requires at least two planes" }
|
||||||
val baseRadius = solid.planes.first().rmax * lScale
|
val baseRadius = solid.planes.first().rmax * lScale
|
||||||
@ -210,13 +210,13 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
layer(plane.z * lScale, scale = plane.rmax * lScale / baseRadius)
|
layer(plane.z * lScale, scale = plane.rmax * lScale / baseRadius)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is GDMLBoolSolid -> {
|
is GdmlBoolSolid -> {
|
||||||
val first: GDMLSolid = solid.first.resolve(root) ?: error("")
|
val first: GdmlSolid = solid.first.resolve(root) ?: error("")
|
||||||
val second: GDMLSolid = solid.second.resolve(root) ?: error("")
|
val second: GdmlSolid = solid.second.resolve(root) ?: error("")
|
||||||
val type: CompositeType = when (solid) {
|
val type: CompositeType = when (solid) {
|
||||||
is GDMLUnion -> CompositeType.UNION
|
is GdmlUnion -> CompositeType.UNION
|
||||||
is GDMLSubtraction -> CompositeType.SUBTRACT
|
is GdmlSubtraction -> CompositeType.SUBTRACT
|
||||||
is GDMLIntersection -> CompositeType.INTERSECT
|
is GdmlIntersection -> CompositeType.INTERSECT
|
||||||
}
|
}
|
||||||
|
|
||||||
return composite(type, name) {
|
return composite(type, name) {
|
||||||
@ -234,30 +234,30 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is GDMLEllipsoid -> TODO("Renderer for $solid not supported yet")
|
is GdmlEllipsoid -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLElTube -> TODO("Renderer for $solid not supported yet")
|
is GdmlElTube -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLElCone -> TODO("Renderer for $solid not supported yet")
|
is GdmlElCone -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLParaboloid -> TODO("Renderer for $solid not supported yet")
|
is GdmlParaboloid -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLParallelepiped -> TODO("Renderer for $solid not supported yet")
|
is GdmlParallelepiped -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLTorus -> TODO("Renderer for $solid not supported yet")
|
is GdmlTorus -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLTrapezoid -> TODO("Renderer for $solid not supported yet")
|
is GdmlTrapezoid -> TODO("Renderer for $solid not supported yet")
|
||||||
is GDMLPolycone -> TODO("Renderer for $solid not supported yet")
|
is GdmlPolycone -> TODO("Renderer for $solid not supported yet")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SolidGroup.addSolidWithCaching(
|
fun SolidGroup.addSolidWithCaching(
|
||||||
root: GDML,
|
root: Gdml,
|
||||||
solid: GDMLSolid,
|
solid: GdmlSolid,
|
||||||
name: String = solid.name,
|
name: String = solid.name,
|
||||||
): Solid? {
|
): Solid? {
|
||||||
return when (settings.solidAction(solid)) {
|
return when (settings.solidAction(solid)) {
|
||||||
GDMLTransformerSettings.Action.ADD -> {
|
GdmlTransformerSettings.Action.ADD -> {
|
||||||
addSolid(root, solid, name)
|
addSolid(root, solid, name)
|
||||||
}
|
}
|
||||||
GDMLTransformerSettings.Action.PROTOTYPE -> {
|
GdmlTransformerSettings.Action.PROTOTYPE -> {
|
||||||
proxySolid(root, this, solid, name)
|
proxySolid(root, this, solid, name)
|
||||||
}
|
}
|
||||||
GDMLTransformerSettings.Action.REJECT -> {
|
GdmlTransformerSettings.Action.REJECT -> {
|
||||||
//ignore
|
//ignore
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@ -265,14 +265,14 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun SolidGroup.addPhysicalVolume(
|
fun SolidGroup.addPhysicalVolume(
|
||||||
root: GDML,
|
root: Gdml,
|
||||||
physVolume: GDMLPhysVolume,
|
physVolume: GdmlPhysVolume,
|
||||||
) {
|
) {
|
||||||
val volume: GDMLGroup = physVolume.volumeref.resolve(root)
|
val volume: GdmlGroup = physVolume.volumeref.resolve(root)
|
||||||
?: error("Volume with ref ${physVolume.volumeref.ref} could not be resolved")
|
?: error("Volume with ref ${physVolume.volumeref.ref} could not be resolved")
|
||||||
|
|
||||||
// a special case for single solid volume
|
// a special case for single solid volume
|
||||||
if (volume is GDMLVolume && volume.physVolumes.isEmpty() && volume.placement == null) {
|
if (volume is GdmlVolume && volume.physVolumes.isEmpty() && volume.placement == null) {
|
||||||
val solid = volume.solidref.resolve(root)
|
val solid = volume.solidref.resolve(root)
|
||||||
?: error("Solid with tag ${volume.solidref.ref} for volume ${volume.name} not defined")
|
?: error("Solid with tag ${volume.solidref.ref} for volume ${volume.name} not defined")
|
||||||
addSolidWithCaching(root, solid, physVolume.name ?: "")?.apply {
|
addSolidWithCaching(root, solid, physVolume.name ?: "")?.apply {
|
||||||
@ -283,24 +283,24 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when (settings.volumeAction(volume)) {
|
when (settings.volumeAction(volume)) {
|
||||||
GDMLTransformerSettings.Action.ADD -> {
|
GdmlTransformerSettings.Action.ADD -> {
|
||||||
val group: SolidGroup = volume(root, volume)
|
val group: SolidGroup = volume(root, volume)
|
||||||
this[physVolume.name ?: ""] = group.withPosition(root, physVolume)
|
this[physVolume.name ?: ""] = group.withPosition(root, physVolume)
|
||||||
}
|
}
|
||||||
GDMLTransformerSettings.Action.PROTOTYPE -> {
|
GdmlTransformerSettings.Action.PROTOTYPE -> {
|
||||||
proxyVolume(root, this, physVolume, volume)
|
proxyVolume(root, this, physVolume, volume)
|
||||||
}
|
}
|
||||||
GDMLTransformerSettings.Action.REJECT -> {
|
GdmlTransformerSettings.Action.REJECT -> {
|
||||||
//ignore
|
//ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SolidGroup.addDivisionVolume(
|
fun SolidGroup.addDivisionVolume(
|
||||||
root: GDML,
|
root: Gdml,
|
||||||
divisionVolume: GDMLDivisionVolume,
|
divisionVolume: GdmlDivisionVolume,
|
||||||
) {
|
) {
|
||||||
val volume: GDMLGroup = divisionVolume.volumeref.resolve(root)
|
val volume: GdmlGroup = divisionVolume.volumeref.resolve(root)
|
||||||
?: error("Volume with ref ${divisionVolume.volumeref.ref} could not be resolved")
|
?: error("Volume with ref ${divisionVolume.volumeref.ref} could not be resolved")
|
||||||
|
|
||||||
//TODO add divisions
|
//TODO add divisions
|
||||||
@ -308,20 +308,20 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun volume(
|
private fun volume(
|
||||||
root: GDML,
|
root: Gdml,
|
||||||
group: GDMLGroup,
|
group: GdmlGroup,
|
||||||
): SolidGroup = SolidGroup().apply {
|
): SolidGroup = SolidGroup().apply {
|
||||||
if (group is GDMLVolume) {
|
if (group is GdmlVolume) {
|
||||||
val solid: GDMLSolid = group.solidref.resolve(root)
|
val solid: GdmlSolid = group.solidref.resolve(root)
|
||||||
?: error("Solid with tag ${group.solidref.ref} for volume ${group.name} not defined")
|
?: error("Solid with tag ${group.solidref.ref} for volume ${group.name} not defined")
|
||||||
|
|
||||||
addSolidWithCaching(root, solid)?.apply {
|
addSolidWithCaching(root, solid)?.apply {
|
||||||
configureSolid(root, this, group, solid)
|
configureSolid(root, this, group, solid)
|
||||||
}
|
}
|
||||||
|
|
||||||
when (val vol: GDMLPlacement? = group.placement) {
|
when (val vol: GdmlPlacement? = group.placement) {
|
||||||
is GDMLPhysVolume -> addPhysicalVolume(root, vol)
|
is GdmlPhysVolume -> addPhysicalVolume(root, vol)
|
||||||
is GDMLDivisionVolume -> addDivisionVolume(root, vol)
|
is GdmlDivisionVolume -> addDivisionVolume(root, vol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
|
|
||||||
private fun finalize(final: SolidGroup): SolidGroup {
|
private fun finalize(final: SolidGroup): SolidGroup {
|
||||||
//final.prototypes = proto
|
//final.prototypes = proto
|
||||||
final.useStyle("GDML") {
|
final.useStyle("Gdml") {
|
||||||
Solid.ROTATION_ORDER_KEY put RotationOrder.ZXY
|
Solid.ROTATION_ORDER_KEY put RotationOrder.ZXY
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,19 +364,19 @@ private class GDMLTransformer(val settings: GDMLTransformerSettings) {
|
|||||||
return final
|
return final
|
||||||
}
|
}
|
||||||
|
|
||||||
fun transform(root: GDML): SolidGroup = finalize(volume(root, root.world))
|
fun transform(root: Gdml): SolidGroup = finalize(volume(root, root.world))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public fun GDML.toVision(block: GDMLTransformerSettings.() -> Unit = {}): SolidGroup {
|
public fun Gdml.toVision(block: GdmlTransformerSettings.() -> Unit = {}): SolidGroup {
|
||||||
val context = GDMLTransformer(GDMLTransformerSettings().apply(block))
|
val context = GdmlTransformer(GdmlTransformerSettings().apply(block))
|
||||||
return context.transform(this)
|
return context.transform(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append gdml node to the group
|
* Append Gdml node to the group
|
||||||
*/
|
*/
|
||||||
public fun SolidGroup.gdml(gdml: GDML, key: String = "", transformer: GDMLTransformerSettings.() -> Unit = {}) {
|
public fun SolidGroup.gdml(gdml: Gdml, key: String = "", transformer: GdmlTransformerSettings.() -> Unit = {}) {
|
||||||
val visual = gdml.toVision(transformer)
|
val visual = gdml.toVision(transformer)
|
||||||
//println(Visual3DPlugin.json.stringify(VisualGroup3D.serializer(), visual))
|
//println(Visual3DPlugin.json.stringify(VisualGroup3D.serializer(), visual))
|
||||||
set(key, visual)
|
set(key, visual)
|
@ -1,20 +1,20 @@
|
|||||||
package hep.dataforge.vision.gdml
|
package hep.dataforge.vision.gdml
|
||||||
|
|
||||||
import hep.dataforge.vision.solid.SolidGroup
|
import hep.dataforge.vision.solid.SolidGroup
|
||||||
import kscience.gdml.GDML
|
|
||||||
import nl.adaptivity.xmlutil.StAXReader
|
import nl.adaptivity.xmlutil.StAXReader
|
||||||
|
import space.kscience.gdml.Gdml
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
public actual typealias Counter = AtomicInteger
|
public actual typealias Counter = AtomicInteger
|
||||||
|
|
||||||
public fun GDML.Companion.readFile(file: Path): GDML {
|
public fun Gdml.Companion.readFile(file: Path): Gdml {
|
||||||
val xmlReader = StAXReader(Files.newInputStream(file), "UTF-8")
|
val xmlReader = StAXReader(Files.newInputStream(file), "UTF-8")
|
||||||
return format.parse(GDML.serializer(), xmlReader)
|
return format.parse(Gdml.serializer(), xmlReader)
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun SolidGroup.gdml(file: Path, key: String = "", transformer: GDMLTransformerSettings.() -> Unit = {}) {
|
public fun SolidGroup.gdml(file: Path, key: String = "", transformer: GdmlTransformerSettings.() -> Unit = {}) {
|
||||||
val gdml = GDML.readFile(file)
|
val gdml = Gdml.readFile(file)
|
||||||
gdml(gdml, key, transformer)
|
gdml(gdml, key, transformer)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package hep.dataforge.vision.gdml
|
package hep.dataforge.vision.gdml
|
||||||
|
|
||||||
import hep.dataforge.vision.solid.SolidManager
|
import hep.dataforge.vision.solid.SolidManager
|
||||||
import kscience.gdml.GDML
|
import space.kscience.gdml.Gdml
|
||||||
import nl.adaptivity.xmlutil.StAXReader
|
import nl.adaptivity.xmlutil.StAXReader
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ class TestConvertor {
|
|||||||
fun testBMNGeometry() {
|
fun testBMNGeometry() {
|
||||||
val stream = javaClass.getResourceAsStream("/gdml/BM@N.gdml")
|
val stream = javaClass.getResourceAsStream("/gdml/BM@N.gdml")
|
||||||
val xmlReader = StAXReader(stream, "UTF-8")
|
val xmlReader = StAXReader(stream, "UTF-8")
|
||||||
val xml = GDML.format.parse(GDML.serializer(), xmlReader)
|
val xml = Gdml.format.parse(Gdml.serializer(), xmlReader)
|
||||||
val vision = xml.toVision()
|
val vision = xml.toVision()
|
||||||
println(SolidManager.encodeToString(vision))
|
println(SolidManager.encodeToString(vision))
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ class TestConvertor {
|
|||||||
val stream = javaClass.getResourceAsStream("/gdml/cubes.gdml")
|
val stream = javaClass.getResourceAsStream("/gdml/cubes.gdml")
|
||||||
|
|
||||||
val xmlReader = StAXReader(stream, "UTF-8")
|
val xmlReader = StAXReader(stream, "UTF-8")
|
||||||
val xml = GDML.format.parse(GDML.serializer(), xmlReader)
|
val xml = Gdml.format.parse(Gdml.serializer(), xmlReader)
|
||||||
val visual = xml.toVision()
|
val visual = xml.toVision()
|
||||||
// println(visual)
|
// println(visual)
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ class TestConvertor {
|
|||||||
val stream = javaClass.getResourceAsStream("/gdml/simple1.gdml")
|
val stream = javaClass.getResourceAsStream("/gdml/simple1.gdml")
|
||||||
|
|
||||||
val xmlReader = StAXReader(stream, "UTF-8")
|
val xmlReader = StAXReader(stream, "UTF-8")
|
||||||
val xml = GDML.format.parse(GDML.serializer(), xmlReader)
|
val xml = Gdml.format.parse(Gdml.serializer(), xmlReader)
|
||||||
val vision = xml.toVision()
|
val vision = xml.toVision()
|
||||||
println(SolidManager.encodeToString(vision))
|
println(SolidManager.encodeToString(vision))
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import hep.dataforge.vision.visitor.countDistinct
|
|||||||
import hep.dataforge.vision.visitor.flowStatistics
|
import hep.dataforge.vision.visitor.flowStatistics
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kscience.gdml.GDML
|
import space.kscience.gdml.Gdml
|
||||||
import nl.adaptivity.xmlutil.StAXReader
|
import nl.adaptivity.xmlutil.StAXReader
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
@ -17,7 +17,7 @@ suspend fun main() {
|
|||||||
File("D:\\Work\\Projects\\dataforge-vis\\visionforge-gdml\\src\\jvmTest\\resources\\gdml\\BM@N.gdml").inputStream()
|
File("D:\\Work\\Projects\\dataforge-vis\\visionforge-gdml\\src\\jvmTest\\resources\\gdml\\BM@N.gdml").inputStream()
|
||||||
|
|
||||||
val xmlReader = StAXReader(stream, "UTF-8")
|
val xmlReader = StAXReader(stream, "UTF-8")
|
||||||
val xml = GDML.format.parse(GDML.serializer(), xmlReader)
|
val xml = Gdml.format.parse(Gdml.serializer(), xmlReader)
|
||||||
val vision = xml.toVision()
|
val vision = xml.toVision()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
val plotlyVersion = "0.3.1"
|
val plotlyVersion = "0.3.1"
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
//import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.jvm")
|
id("ru.mipt.npm.gradle.jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
val ktorVersion: String by rootProject.extra
|
val ktorVersion: String by rootProject.extra
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
kscience{
|
kscience{
|
||||||
@ -7,7 +7,6 @@ kscience{
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
commonMain {
|
commonMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.js")
|
id("ru.mipt.npm.gradle.js")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin{
|
kotlin{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.gradle.mpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
val ktorVersion: String by rootProject.extra
|
val ktorVersion: String by rootProject.extra
|
||||||
|
@ -4,9 +4,9 @@ import hep.dataforge.context.Context
|
|||||||
import hep.dataforge.misc.DFExperimental
|
import hep.dataforge.misc.DFExperimental
|
||||||
import hep.dataforge.vision.html.HtmlVisionFragment
|
import hep.dataforge.vision.html.HtmlVisionFragment
|
||||||
import hep.dataforge.vision.html.ResourceLocation
|
import hep.dataforge.vision.html.ResourceLocation
|
||||||
|
import hep.dataforge.vision.html.page
|
||||||
import hep.dataforge.vision.html.scriptHeader
|
import hep.dataforge.vision.html.scriptHeader
|
||||||
import hep.dataforge.vision.makeFile
|
import hep.dataforge.vision.makeFile
|
||||||
import hep.dataforge.vision.page
|
|
||||||
import java.awt.Desktop
|
import java.awt.Desktop
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user