diff --git a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt index 87422b97..582389e2 100644 --- a/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt +++ b/cern-root-loader/src/commonMain/kotlin/ru/mipt/npm/root/dRootToSolid.kt @@ -3,6 +3,7 @@ package ru.mipt.npm.root import space.kscience.dataforge.meta.double import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.int +import space.kscience.dataforge.meta.isEmpty import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.plus import space.kscience.visionforge.solid.* @@ -228,15 +229,23 @@ private fun SolidGroup.addRootNode(obj: DGeoNode, context: RootToSolidContext) { } } -private fun buildGroup(volume: DGeoVolume, context: RootToSolidContext): SolidGroup = SolidGroup { - volume.fShape?.let { - addShape(it, context) - } - volume.fNodes.let { - it.forEach { node -> +private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid { + val group = SolidGroup { + if(volume.fNodes.isEmpty()) { + //TODO add smart filter + volume.fShape?.let { shape -> + addShape(shape, context) + } + } + volume.fNodes.forEach { node -> addRootNode(node, context) } } + return if (group.children.size == 1 && group.meta.isEmpty()) { + (group.children.values.first() as Solid).apply { parent = null } + } else { + group + } } //private val SolidGroup.rootPrototypes: SolidGroup get() = (parent as? SolidGroup)?.rootPrototypes ?: this @@ -256,7 +265,7 @@ private fun SolidGroup.addRootVolume( } return if (!cache) { - val group = buildGroup(volume, context) + val group = buildVolume(volume, context) set(combinedName?.let { Name.parse(it) }, group) group } else { @@ -264,7 +273,7 @@ private fun SolidGroup.addRootVolume( val existing = getPrototype(templateName) if (existing == null) { context.prototypeHolder.prototypes { - set(templateName, buildGroup(volume, context)) + set(templateName, buildVolume(volume, context)) } } diff --git a/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt b/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt index f2371f44..83e750ba 100644 --- a/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt +++ b/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt @@ -21,7 +21,6 @@ class GDMLDemoApp : App(GDMLView::class) class GDMLView : View() { private val context = Context { plugin(FX3DPlugin) - plugin(VisionManager) } private val fx3d = context.fetch(FX3DPlugin) diff --git a/gradle.properties b/gradle.properties index 0ed8858a..24f28924 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ kotlin.code.style=official kotlin.mpp.stability.nowarn=true #kotlin.jupyter.add.scanner=false +kotlin.incremental.js.klib=false org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G org.gradle.parallel=true \ No newline at end of file diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt index 7280ae1f..d4af712d 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionGroupBase.kt @@ -76,7 +76,7 @@ public open class VisionGroupBase( * Set parent for given child and attach it */ private fun attachChild(token: NameToken, child: Vision?) { - val before = children[token] + val before = childrenInternal[token] when { child == null -> { childrenInternal.remove(token) diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt index 9aed5d50..48f99ac1 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt @@ -27,6 +27,8 @@ import kotlin.reflect.KClass public class FX3DPlugin : AbstractPlugin() { override val tag: PluginTag get() = Companion.tag + public val solids: Solids by require(Solids) + private val objectFactories = HashMap, FX3DFactory<*>>() private val compositeFactory = FXCompositeFactory(this) private val referenceFactory = FXReferenceFactory(this) @@ -50,6 +52,7 @@ public class FX3DPlugin : AbstractPlugin() { is SolidGroup -> { Group(obj.children.mapNotNull { (token, obj) -> (obj as? Solid)?.let { + logger.info { token.toString() } buildNode(it).apply { properties["name"] = token.toString() } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt index ca83f00f..c5b9b04b 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt @@ -18,6 +18,7 @@ import kotlin.reflect.KClass public class Solids(meta: Meta) : VisionPlugin(meta) { override val tag: PluginTag get() = Companion.tag + override val visionSerializersModule: SerializersModule get() = serializersModuleForSolids public companion object : PluginFactory {