feature/root #69

Merged
altavir merged 23 commits from feature/root into dev 2021-09-11 19:14:21 +03:00
6 changed files with 23 additions and 10 deletions
Showing only changes of commit aea4eb7d45 - Show all commits

View File

@ -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)
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.let {
it.forEach { node ->
}
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))
}
}

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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<KClass<out Solid>, 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()
}

View File

@ -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<Solids> {