Cleanup and fix ROOT bug
This commit is contained in:
parent
4ec611eda3
commit
c921d5541b
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,4 +9,3 @@ data/
|
|||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
|
|
||||||
/kotlin-js-store/yarn.lock
|
/kotlin-js-store/yarn.lock
|
||||||
.
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
|
||||||
import space.kscience.gradle.isInDevelopment
|
import space.kscience.gradle.isInDevelopment
|
||||||
import space.kscience.gradle.useApache2Licence
|
import space.kscience.gradle.useApache2Licence
|
||||||
import space.kscience.gradle.useSPCTeam
|
import space.kscience.gradle.useSPCTeam
|
||||||
@ -30,6 +31,12 @@ subprojects {
|
|||||||
freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers"
|
freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<KotlinJsCompile>{
|
||||||
|
kotlinOptions{
|
||||||
|
useEsClasses = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ksciencePublish {
|
ksciencePublish {
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package ru.mipt.npm.root
|
package ru.mipt.npm.root
|
||||||
|
|
||||||
import space.kscience.dataforge.meta.double
|
import space.kscience.dataforge.meta.*
|
||||||
import space.kscience.dataforge.meta.doubleArray
|
|
||||||
import space.kscience.dataforge.meta.get
|
|
||||||
import space.kscience.dataforge.meta.int
|
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
|
import space.kscience.dataforge.names.parseAsName
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
import space.kscience.visionforge.MutableVisionContainer
|
import space.kscience.visionforge.MutableVisionContainer
|
||||||
import space.kscience.visionforge.isEmpty
|
import space.kscience.visionforge.isEmpty
|
||||||
@ -25,6 +23,8 @@ private data class RootToSolidContext(
|
|||||||
val prototypeHolder: PrototypeHolder,
|
val prototypeHolder: PrototypeHolder,
|
||||||
val currentLayer: Int = 0,
|
val currentLayer: Int = 0,
|
||||||
val maxLayer: Int = 5,
|
val maxLayer: Int = 5,
|
||||||
|
val ignoreRootColors: Boolean = false,
|
||||||
|
val colorCache: MutableMap<Meta, String> = mutableMapOf(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// converting to XYZ to Tait–Bryan angles according to https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
// converting to XYZ to Tait–Bryan angles according to https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||||
@ -300,7 +300,7 @@ private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid?
|
|||||||
layer = context.currentLayer
|
layer = context.currentLayer
|
||||||
val nodes = volume.fNodes
|
val nodes = volume.fNodes
|
||||||
|
|
||||||
if (nodes.isEmpty() || context.currentLayer >= context.maxLayer) {
|
if (volume.typename != "TGeoVolumeAssembly" && (nodes.isEmpty() || context.currentLayer >= context.maxLayer)) {
|
||||||
//TODO add smart filter
|
//TODO add smart filter
|
||||||
volume.fShape?.let { shape ->
|
volume.fShape?.let { shape ->
|
||||||
addShape(shape, context)
|
addShape(shape, context)
|
||||||
@ -326,6 +326,16 @@ private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid?
|
|||||||
group.items.values.first().apply { parent = null }
|
group.items.values.first().apply { parent = null }
|
||||||
} else {
|
} else {
|
||||||
group
|
group
|
||||||
|
}.apply {
|
||||||
|
volume.fMedium?.let { medium ->
|
||||||
|
color.set(context.colorCache.getOrPut(medium.meta) { RootColors[11 + context.colorCache.size] })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.ignoreRootColors) {
|
||||||
|
volume.fFillColor?.let {
|
||||||
|
properties[MATERIAL_COLOR_KEY] = RootColors[it]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,6 +348,7 @@ private fun SolidGroup.addRootVolume(
|
|||||||
cache: Boolean = true,
|
cache: Boolean = true,
|
||||||
block: Solid.() -> Unit = {},
|
block: Solid.() -> Unit = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val combinedName = if (volume.fName.isEmpty()) {
|
val combinedName = if (volume.fName.isEmpty()) {
|
||||||
name
|
name
|
||||||
} else if (name == null) {
|
} else if (name == null) {
|
||||||
@ -347,12 +358,7 @@ private fun SolidGroup.addRootVolume(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
val group = buildVolume(volume, context)?.apply {
|
val group = buildVolume(volume, context)?.apply(block)
|
||||||
volume.fFillColor?.let {
|
|
||||||
properties[MATERIAL_COLOR_KEY] = RootColors[it]
|
|
||||||
}
|
|
||||||
block()
|
|
||||||
}
|
|
||||||
setChild(combinedName?.let { Name.parse(it) }, group)
|
setChild(combinedName?.let { Name.parse(it) }, group)
|
||||||
} else {
|
} else {
|
||||||
val templateName = volumesName + volume.name
|
val templateName = volumesName + volume.name
|
||||||
@ -364,17 +370,17 @@ private fun SolidGroup.addRootVolume(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref(templateName, name).apply {
|
ref(templateName, name).apply(block)
|
||||||
volume.fFillColor?.let {
|
|
||||||
properties[MATERIAL_COLOR_KEY] = RootColors[it]
|
|
||||||
}
|
|
||||||
block()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun MutableVisionContainer<Solid>.rootGeo(dGeoManager: DGeoManager): SolidGroup = solidGroup {
|
public fun MutableVisionContainer<Solid>.rootGeo(
|
||||||
val context = RootToSolidContext(this)
|
dGeoManager: DGeoManager,
|
||||||
|
name: String? = null,
|
||||||
|
maxLayer: Int = 5,
|
||||||
|
ignoreRootColors: Boolean = false,
|
||||||
|
): SolidGroup = solidGroup(name = name?.parseAsName()) {
|
||||||
|
val context = RootToSolidContext(this, maxLayer = maxLayer, ignoreRootColors = ignoreRootColors)
|
||||||
dGeoManager.fNodes.forEach { node ->
|
dGeoManager.fNodes.forEach { node ->
|
||||||
addRootNode(node, context)
|
addRootNode(node, context)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.mipt.npm.root
|
package ru.mipt.npm.root
|
||||||
|
|
||||||
public object RootColors {
|
public object RootColors {
|
||||||
private val colorMap = Array<String>(924) { "white" }
|
private val colorMap = MutableList(924) { "white" }
|
||||||
|
|
||||||
//colorMap[110] = "white"
|
//colorMap[110] = "white"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import ru.mipt.npm.muon.monitor.sim.Cos2TrackGenerator
|
|||||||
import ru.mipt.npm.muon.monitor.sim.simulateOne
|
import ru.mipt.npm.muon.monitor.sim.simulateOne
|
||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
import space.kscience.dataforge.context.Global
|
import space.kscience.dataforge.context.Global
|
||||||
import space.kscience.dataforge.context.fetch
|
import space.kscience.dataforge.context.request
|
||||||
import space.kscience.dataforge.misc.DFExperimental
|
import space.kscience.dataforge.misc.DFExperimental
|
||||||
import space.kscience.visionforge.solid.Solids
|
import space.kscience.visionforge.solid.Solids
|
||||||
import java.awt.Desktop
|
import java.awt.Desktop
|
||||||
@ -36,7 +36,7 @@ private val generator = Cos2TrackGenerator(JDKRandomGenerator(223))
|
|||||||
fun Application.module(context: Context = Global) {
|
fun Application.module(context: Context = Global) {
|
||||||
val currentDir = File(".").absoluteFile
|
val currentDir = File(".").absoluteFile
|
||||||
environment.log.info("Current directory: $currentDir")
|
environment.log.info("Current directory: $currentDir")
|
||||||
val solidManager = context.fetch(Solids)
|
val solidManager = context.request(Solids)
|
||||||
|
|
||||||
install(ContentNegotiation) {
|
install(ContentNegotiation) {
|
||||||
json()
|
json()
|
||||||
|
@ -7,9 +7,14 @@ import space.kscience.dataforge.meta.Meta
|
|||||||
import space.kscience.dataforge.meta.get
|
import space.kscience.dataforge.meta.get
|
||||||
import space.kscience.dataforge.meta.isLeaf
|
import space.kscience.dataforge.meta.isLeaf
|
||||||
import space.kscience.dataforge.meta.string
|
import space.kscience.dataforge.meta.string
|
||||||
|
import space.kscience.visionforge.Colors
|
||||||
|
import space.kscience.visionforge.html.ResourceLocation
|
||||||
import space.kscience.visionforge.solid.Solids
|
import space.kscience.visionforge.solid.Solids
|
||||||
import java.nio.file.Paths
|
import space.kscience.visionforge.solid.ambientLight
|
||||||
|
import space.kscience.visionforge.solid.set
|
||||||
|
import space.kscience.visionforge.solid.solid
|
||||||
import java.util.zip.ZipInputStream
|
import java.util.zip.ZipInputStream
|
||||||
|
import kotlin.io.path.Path
|
||||||
import kotlin.io.path.writeText
|
import kotlin.io.path.writeText
|
||||||
|
|
||||||
|
|
||||||
@ -34,73 +39,17 @@ fun main() {
|
|||||||
println(it)
|
println(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
val solid = Solids.rootGeo(geo)
|
makeVisionFile(path = Path("data/output.html"), resourceLocation = ResourceLocation.EMBED) {
|
||||||
|
|
||||||
Paths.get("BM@N.vf.json").writeText(Solids.encodeToString(solid))
|
|
||||||
//println(Solids.encodeToString(solid))
|
|
||||||
|
|
||||||
makeVisionFile {
|
|
||||||
vision("canvas") {
|
vision("canvas") {
|
||||||
requirePlugin(Solids)
|
requirePlugin(Solids)
|
||||||
solid
|
solid {
|
||||||
|
ambientLight {
|
||||||
|
color.set(Colors.white)
|
||||||
|
}
|
||||||
|
rootGeo(geo,"BM@N", maxLayer = 3, ignoreRootColors = true).also {
|
||||||
|
Path("data/BM@N.vf.json").writeText(Solids.encodeToString(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* SolidGroup {
|
|
||||||
set(
|
|
||||||
"Coil",
|
|
||||||
solid.getPrototype("Coil".asName())!!.apply {
|
|
||||||
parent = null
|
|
||||||
}
|
|
||||||
)
|
|
||||||
*//* group("Shade") {
|
|
||||||
y = 200
|
|
||||||
color("red")
|
|
||||||
coneSurface(
|
|
||||||
bottomOuterRadius = 135,
|
|
||||||
bottomInnerRadius = 25,
|
|
||||||
height = 50,
|
|
||||||
topOuterRadius = 135,
|
|
||||||
topInnerRadius = 25,
|
|
||||||
angle = 1.5707964
|
|
||||||
) {
|
|
||||||
position = Point3D(79.6, 0, -122.1)
|
|
||||||
rotation = Point3D(-1.5707964, 0, 0)
|
|
||||||
}
|
|
||||||
coneSurface(
|
|
||||||
bottomOuterRadius = 135,
|
|
||||||
bottomInnerRadius = 25,
|
|
||||||
height = 50,
|
|
||||||
topOuterRadius = 135,
|
|
||||||
topInnerRadius = 25,
|
|
||||||
angle = 1.5707964
|
|
||||||
) {
|
|
||||||
position = Point3D(-79.6, 0, -122.1)
|
|
||||||
rotation = Point3D(1.5707964, 0, -3.1415927)
|
|
||||||
}
|
|
||||||
coneSurface(
|
|
||||||
bottomOuterRadius = 135,
|
|
||||||
bottomInnerRadius = 25,
|
|
||||||
height = 50,
|
|
||||||
topOuterRadius = 135,
|
|
||||||
topInnerRadius = 25,
|
|
||||||
angle = 1.5707964
|
|
||||||
) {
|
|
||||||
position = Point3D(79.6, 0, 122.1)
|
|
||||||
rotation = Point3D(1.5707964, 0, 0)
|
|
||||||
}
|
|
||||||
coneSurface(
|
|
||||||
bottomOuterRadius = 135,
|
|
||||||
bottomInnerRadius = 25,
|
|
||||||
height = 50,
|
|
||||||
topOuterRadius = 135,
|
|
||||||
topInnerRadius = 25,
|
|
||||||
angle = 1.5707964
|
|
||||||
) {
|
|
||||||
position = Point3D(-79.6, 0, 122.1)
|
|
||||||
rotation = Point3D(-1.5707964, 0, -3.1415927)
|
|
||||||
}
|
|
||||||
}*//*
|
|
||||||
}*/
|
|
@ -7,10 +7,11 @@ val dataforgeVersion: String by rootProject.extra
|
|||||||
kscience{
|
kscience{
|
||||||
jvm()
|
jvm()
|
||||||
js()
|
js()
|
||||||
|
native()
|
||||||
dependencies {
|
dependencies {
|
||||||
api("space.kscience:dataforge-context:$dataforgeVersion")
|
api("space.kscience:dataforge-context:$dataforgeVersion")
|
||||||
api(spclibs.kotlinx.html)
|
api(spclibs.kotlinx.html)
|
||||||
api("org.jetbrains.kotlin-wrappers:kotlin-css")
|
// api("org.jetbrains.kotlin-wrappers:kotlin-css")
|
||||||
}
|
}
|
||||||
testDependencies {
|
testDependencies {
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${space.kscience.gradle.KScienceVersions.coroutinesVersion}")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${space.kscience.gradle.KScienceVersions.coroutinesVersion}")
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package space.kscience.visionforge
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMultiplatform::class)
|
||||||
|
@OptionalExpectation
|
||||||
|
public expect annotation class JvmSynchronized()
|
@ -13,7 +13,6 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
|||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.isEmpty
|
import space.kscience.dataforge.names.isEmpty
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
import kotlin.jvm.Synchronized
|
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,11 +58,11 @@ public class VisionChangeBuilder : MutableVisionContainer<Vision> {
|
|||||||
|
|
||||||
public fun isEmpty(): Boolean = propertyChange.isEmpty() && propertyChange.isEmpty() && children.isEmpty()
|
public fun isEmpty(): Boolean = propertyChange.isEmpty() && propertyChange.isEmpty() && children.isEmpty()
|
||||||
|
|
||||||
@Synchronized
|
@JvmSynchronized
|
||||||
private fun getOrPutChild(visionName: Name): VisionChangeBuilder =
|
private fun getOrPutChild(visionName: Name): VisionChangeBuilder =
|
||||||
children.getOrPut(visionName) { VisionChangeBuilder() }
|
children.getOrPut(visionName) { VisionChangeBuilder() }
|
||||||
|
|
||||||
@Synchronized
|
@JvmSynchronized
|
||||||
internal fun reset() {
|
internal fun reset() {
|
||||||
vision = null
|
vision = null
|
||||||
propertyChange = MutableMeta()
|
propertyChange = MutableMeta()
|
||||||
|
@ -6,7 +6,6 @@ import kotlinx.coroutines.flow.*
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import space.kscience.dataforge.names.*
|
import space.kscience.dataforge.names.*
|
||||||
import space.kscience.visionforge.VisionChildren.Companion.STATIC_TOKEN_BODY
|
import space.kscience.visionforge.VisionChildren.Companion.STATIC_TOKEN_BODY
|
||||||
import kotlin.jvm.Synchronized
|
|
||||||
|
|
||||||
@DslMarker
|
@DslMarker
|
||||||
public annotation class VisionBuilder
|
public annotation class VisionBuilder
|
||||||
@ -132,7 +131,7 @@ internal abstract class VisionChildrenImpl(
|
|||||||
|
|
||||||
abstract var items: MutableMap<NameToken, Vision>?
|
abstract var items: MutableMap<NameToken, Vision>?
|
||||||
|
|
||||||
@Synchronized
|
@JvmSynchronized
|
||||||
private fun buildItems(): MutableMap<NameToken, Vision> {
|
private fun buildItems(): MutableMap<NameToken, Vision> {
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
items = LinkedHashMap()
|
items = LinkedHashMap()
|
||||||
|
@ -11,7 +11,6 @@ import space.kscience.dataforge.meta.*
|
|||||||
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
||||||
import space.kscience.dataforge.meta.descriptors.get
|
import space.kscience.dataforge.meta.descriptors.get
|
||||||
import space.kscience.dataforge.names.*
|
import space.kscience.dataforge.names.*
|
||||||
import kotlin.jvm.Synchronized
|
|
||||||
|
|
||||||
public interface VisionProperties {
|
public interface VisionProperties {
|
||||||
|
|
||||||
@ -155,7 +154,7 @@ public abstract class AbstractVisionProperties(
|
|||||||
|
|
||||||
override val own: Meta? get() = properties
|
override val own: Meta? get() = properties
|
||||||
|
|
||||||
@Synchronized
|
@JvmSynchronized
|
||||||
protected fun getOrCreateProperties(): MutableMeta {
|
protected fun getOrCreateProperties(): MutableMeta {
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
//TODO check performance issues
|
//TODO check performance issues
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package space.kscience.visionforge
|
||||||
|
|
||||||
|
public actual typealias JvmSynchronized = Synchronized
|
@ -67,9 +67,7 @@ public fun VisionPage.makeFile(
|
|||||||
path: Path?,
|
path: Path?,
|
||||||
fileHeaders: ((Path) -> Map<String, HtmlFragment>)? = null,
|
fileHeaders: ((Path) -> Map<String, HtmlFragment>)? = null,
|
||||||
): Path {
|
): Path {
|
||||||
val actualFile = path?.let {
|
val actualFile = path ?: Files.createTempFile("tempPlot", ".html")
|
||||||
Path.of(System.getProperty("user.home")).resolve(path)
|
|
||||||
} ?: Files.createTempFile("tempPlot", ".html")
|
|
||||||
|
|
||||||
val actualDefaultHeaders = fileHeaders?.invoke(actualFile)
|
val actualDefaultHeaders = fileHeaders?.invoke(actualFile)
|
||||||
val actualHeaders = if (actualDefaultHeaders == null) pageHeaders else actualDefaultHeaders + pageHeaders
|
val actualHeaders = if (actualDefaultHeaders == null) pageHeaders else actualDefaultHeaders + pageHeaders
|
||||||
|
@ -12,6 +12,6 @@ kscience {
|
|||||||
api("space.kscience:gdml:0.4.0")
|
api("space.kscience:gdml:0.4.0")
|
||||||
}
|
}
|
||||||
dependencies(jvmTest) {
|
dependencies(jvmTest) {
|
||||||
implementation("ch.qos.logback:logback-classic:1.2.11")
|
implementation(spclibs.logback.classic)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ plugins {
|
|||||||
id("space.kscience.gradle.mpp")
|
id("space.kscience.gradle.mpp")
|
||||||
}
|
}
|
||||||
|
|
||||||
val markdownVersion = "0.2.4"
|
val markdownVersion = "0.4.1"
|
||||||
|
|
||||||
kscience {
|
kscience {
|
||||||
jvm()
|
jvm()
|
||||||
|
@ -5,6 +5,7 @@ plugins {
|
|||||||
kscience {
|
kscience {
|
||||||
jvm()
|
jvm()
|
||||||
js()
|
js()
|
||||||
|
native()
|
||||||
useSerialization {
|
useSerialization {
|
||||||
json()
|
json()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,10 @@ import space.kscience.dataforge.meta.descriptors.MetaDescriptor
|
|||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.NameToken
|
import space.kscience.dataforge.names.NameToken
|
||||||
import space.kscience.dataforge.names.parseAsName
|
import space.kscience.dataforge.names.parseAsName
|
||||||
import space.kscience.visionforge.*
|
import space.kscience.visionforge.AbstractVisionGroup
|
||||||
|
import space.kscience.visionforge.MutableVisionContainer
|
||||||
|
import space.kscience.visionforge.MutableVisionGroup
|
||||||
|
import space.kscience.visionforge.VisionBuilder
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +56,7 @@ public class SolidGroup : AbstractVisionGroup(), Solid, PrototypeHolder, Mutable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a prototype redirecting the request to the parent if prototype is not found.
|
* Get a prototype redirecting the request to the parent if prototype is not found.
|
||||||
* If prototype is a ref, then it is unfolded automatically.
|
* If a prototype is a ref, then it is unfolded automatically.
|
||||||
*/
|
*/
|
||||||
override fun getPrototype(name: Name): Solid? =
|
override fun getPrototype(name: Name): Solid? =
|
||||||
prototypes?.get(name)?.prototype ?: (parent as? PrototypeHolder)?.getPrototype(name)
|
prototypes?.get(name)?.prototype ?: (parent as? PrototypeHolder)?.getPrototype(name)
|
||||||
|
@ -10,7 +10,6 @@ import kotlinx.serialization.serializer
|
|||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
import space.kscience.dataforge.context.PluginFactory
|
import space.kscience.dataforge.context.PluginFactory
|
||||||
import space.kscience.dataforge.context.PluginTag
|
import space.kscience.dataforge.context.PluginTag
|
||||||
import space.kscience.dataforge.context.request
|
|
||||||
import space.kscience.dataforge.meta.Meta
|
import space.kscience.dataforge.meta.Meta
|
||||||
import space.kscience.dataforge.misc.DFExperimental
|
import space.kscience.dataforge.misc.DFExperimental
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
@ -27,15 +26,9 @@ public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer<Sol
|
|||||||
child?.setAsRoot(visionManager)
|
child?.setAsRoot(visionManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
public companion object : PluginFactory<Solids>, MutableVisionContainer<Solid> {
|
public companion object : PluginFactory<Solids> {
|
||||||
override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP)
|
override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP)
|
||||||
|
|
||||||
public val default: Solids by lazy {
|
|
||||||
Context("@Solids") {
|
|
||||||
plugin(Solids)
|
|
||||||
}.request(Solids)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun build(context: Context, meta: Meta): Solids = Solids(meta)
|
override fun build(context: Context, meta: Meta): Solids = Solids(meta)
|
||||||
|
|
||||||
private fun PolymorphicModuleBuilder<Solid>.solids() {
|
private fun PolymorphicModuleBuilder<Solid>.solids() {
|
||||||
@ -79,9 +72,9 @@ public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer<Sol
|
|||||||
public fun decodeFromString(str: String): Solid =
|
public fun decodeFromString(str: String): Solid =
|
||||||
jsonForSolids.decodeFromString(PolymorphicSerializer(Solid::class), str)
|
jsonForSolids.decodeFromString(PolymorphicSerializer(Solid::class), str)
|
||||||
|
|
||||||
override fun setChild(name: Name?, child: Solid?) {
|
// override fun setChild(name: Name?, child: Solid?) {
|
||||||
default.setChild(name, child)
|
// default.setChild(name, child)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class CompositeTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testCompositeBuilder(){
|
fun testCompositeBuilder(){
|
||||||
lateinit var composite: Composite
|
lateinit var composite: Composite
|
||||||
Solids.solidGroup {
|
testSolids.solidGroup {
|
||||||
composite = composite(CompositeType.INTERSECT) {
|
composite = composite(CompositeType.INTERSECT) {
|
||||||
y = 300
|
y = 300
|
||||||
box(100, 100, 100) {
|
box(100, 100, 100) {
|
||||||
|
@ -11,7 +11,7 @@ class ConvexTest {
|
|||||||
@Suppress("UNUSED_VARIABLE")
|
@Suppress("UNUSED_VARIABLE")
|
||||||
@Test
|
@Test
|
||||||
fun testConvexBuilder() {
|
fun testConvexBuilder() {
|
||||||
val group = Solids.solidGroup {
|
val group = testSolids.solidGroup {
|
||||||
convex {
|
convex {
|
||||||
point(50, 50, -50)
|
point(50, 50, -50)
|
||||||
point(50, -50, -50)
|
point(50, -50, -50)
|
||||||
|
@ -9,7 +9,7 @@ import kotlin.test.assertEquals
|
|||||||
class GroupTest {
|
class GroupTest {
|
||||||
@Test
|
@Test
|
||||||
fun testGroupWithComposite() {
|
fun testGroupWithComposite() {
|
||||||
val group = Solids.solidGroup{
|
val group = testSolids.solidGroup{
|
||||||
union("union") {
|
union("union") {
|
||||||
box(100, 100, 100) {
|
box(100, 100, 100) {
|
||||||
z = 100
|
z = 100
|
||||||
|
@ -41,7 +41,7 @@ class SerializationTest {
|
|||||||
x = 100
|
x = 100
|
||||||
z = -100
|
z = -100
|
||||||
}
|
}
|
||||||
val group = Solids.solidGroup {
|
val group = testSolids.solidGroup {
|
||||||
newRef("cube", cube)
|
newRef("cube", cube)
|
||||||
refGroup("pg", Name.parse("pg.content")) {
|
refGroup("pg", Name.parse("pg.content")) {
|
||||||
sphere(50) {
|
sphere(50) {
|
||||||
@ -57,7 +57,7 @@ class SerializationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun lightSerialization(){
|
fun lightSerialization(){
|
||||||
val group = Solids.solidGroup {
|
val group = testSolids.solidGroup {
|
||||||
ambientLight {
|
ambientLight {
|
||||||
color.set(Colors.white)
|
color.set(Colors.white)
|
||||||
intensity = 100.0
|
intensity = 100.0
|
||||||
|
@ -7,8 +7,10 @@ import space.kscience.visionforge.getChild
|
|||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
internal val testSolids = Global.request(Solids)
|
||||||
|
|
||||||
class SolidPluginTest {
|
class SolidPluginTest {
|
||||||
val vision = Solids.solidGroup {
|
val vision = testSolids.solidGroup {
|
||||||
box(100, 100, 100, name = "aBox")
|
box(100, 100, 100, name = "aBox")
|
||||||
|
|
||||||
sphere(100, name = "aSphere") {
|
sphere(100, name = "aSphere") {
|
||||||
|
@ -62,7 +62,7 @@ class SolidPropertyTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testStyleProperty() {
|
fun testStyleProperty() {
|
||||||
var box: Box? = null
|
var box: Box? = null
|
||||||
val group = Solids.solidGroup {
|
val group = testSolids.solidGroup {
|
||||||
styleSheet {
|
styleSheet {
|
||||||
update("testStyle") {
|
update("testStyle") {
|
||||||
"test" put 22
|
"test" put 22
|
||||||
@ -98,7 +98,7 @@ class SolidPropertyTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testReferenceStyleProperty() {
|
fun testReferenceStyleProperty() {
|
||||||
var box: SolidReference? = null
|
var box: SolidReference? = null
|
||||||
val group = Solids.solidGroup {
|
val group = testSolids.solidGroup {
|
||||||
styleSheet {
|
styleSheet {
|
||||||
update("testStyle") {
|
update("testStyle") {
|
||||||
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
||||||
|
@ -11,7 +11,7 @@ import kotlin.test.assertEquals
|
|||||||
|
|
||||||
@DFExperimental
|
@DFExperimental
|
||||||
class SolidReferenceTest {
|
class SolidReferenceTest {
|
||||||
val groupWithReference = Solids.solidGroup {
|
val groupWithReference = testSolids.solidGroup {
|
||||||
val theStyle by style {
|
val theStyle by style {
|
||||||
SolidMaterial.MATERIAL_COLOR_KEY put "red"
|
SolidMaterial.MATERIAL_COLOR_KEY put "red"
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ internal class VisionUpdateTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testVisionUpdate() {
|
fun testVisionUpdate() {
|
||||||
val targetVision = Solids.solidGroup {
|
val targetVision = testSolids.solidGroup {
|
||||||
box(200, 200, 200, name = "origin")
|
box(200, 200, 200, name = "origin")
|
||||||
}
|
}
|
||||||
val dif = visionManager.VisionChange {
|
val dif = visionManager.VisionChange {
|
||||||
|
@ -7,7 +7,7 @@ import three.geometries.SphereGeometry
|
|||||||
|
|
||||||
public object ThreeSphereFactory : ThreeMeshFactory<Sphere>(Sphere::class) {
|
public object ThreeSphereFactory : ThreeMeshFactory<Sphere>(Sphere::class) {
|
||||||
override fun buildGeometry(obj: Sphere): BufferGeometry {
|
override fun buildGeometry(obj: Sphere): BufferGeometry {
|
||||||
return obj.detail?.let {detail ->
|
return obj.detail?.let { detail ->
|
||||||
SphereGeometry(
|
SphereGeometry(
|
||||||
radius = obj.radius,
|
radius = obj.radius,
|
||||||
phiStart = obj.phiStart,
|
phiStart = obj.phiStart,
|
||||||
@ -17,7 +17,7 @@ public object ThreeSphereFactory : ThreeMeshFactory<Sphere>(Sphere::class) {
|
|||||||
widthSegments = detail,
|
widthSegments = detail,
|
||||||
heightSegments = detail
|
heightSegments = detail
|
||||||
)
|
)
|
||||||
}?: SphereGeometry(
|
} ?: SphereGeometry(
|
||||||
radius = obj.radius,
|
radius = obj.radius,
|
||||||
phiStart = obj.phiStart,
|
phiStart = obj.phiStart,
|
||||||
phiLength = obj.phi,
|
phiLength = obj.phi,
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
"OVERRIDING_FINAL_MEMBER",
|
"OVERRIDING_FINAL_MEMBER",
|
||||||
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
||||||
"CONFLICTING_OVERLOADS",
|
"CONFLICTING_OVERLOADS",
|
||||||
"EXTERNAL_DELEGATION",
|
"EXTERNAL_DELEGATION"
|
||||||
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@file:JsModule("three-csg-ts")
|
@file:JsModule("three-csg-ts")
|
||||||
|
Loading…
Reference in New Issue
Block a user