feature/root #69
@ -3,6 +3,7 @@ package ru.mipt.npm.root
|
|||||||
import space.kscience.dataforge.meta.double
|
import space.kscience.dataforge.meta.double
|
||||||
import space.kscience.dataforge.meta.get
|
import space.kscience.dataforge.meta.get
|
||||||
import space.kscience.dataforge.meta.int
|
import space.kscience.dataforge.meta.int
|
||||||
|
import space.kscience.dataforge.meta.isEmpty
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.dataforge.names.plus
|
import space.kscience.dataforge.names.plus
|
||||||
import space.kscience.visionforge.solid.*
|
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 {
|
private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid {
|
||||||
volume.fShape?.let {
|
val group = SolidGroup {
|
||||||
addShape(it, context)
|
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)
|
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
|
//private val SolidGroup.rootPrototypes: SolidGroup get() = (parent as? SolidGroup)?.rootPrototypes ?: this
|
||||||
@ -256,7 +265,7 @@ private fun SolidGroup.addRootVolume(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return if (!cache) {
|
return if (!cache) {
|
||||||
val group = buildGroup(volume, context)
|
val group = buildVolume(volume, context)
|
||||||
set(combinedName?.let { Name.parse(it) }, group)
|
set(combinedName?.let { Name.parse(it) }, group)
|
||||||
group
|
group
|
||||||
} else {
|
} else {
|
||||||
@ -264,7 +273,7 @@ private fun SolidGroup.addRootVolume(
|
|||||||
val existing = getPrototype(templateName)
|
val existing = getPrototype(templateName)
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
context.prototypeHolder.prototypes {
|
context.prototypeHolder.prototypes {
|
||||||
set(templateName, buildGroup(volume, context))
|
set(templateName, buildVolume(volume, context))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ class GDMLDemoApp : App(GDMLView::class)
|
|||||||
class GDMLView : View() {
|
class GDMLView : View() {
|
||||||
private val context = Context {
|
private val context = Context {
|
||||||
plugin(FX3DPlugin)
|
plugin(FX3DPlugin)
|
||||||
plugin(VisionManager)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val fx3d = context.fetch(FX3DPlugin)
|
private val fx3d = context.fetch(FX3DPlugin)
|
||||||
|
@ -2,6 +2,7 @@ kotlin.code.style=official
|
|||||||
kotlin.mpp.stability.nowarn=true
|
kotlin.mpp.stability.nowarn=true
|
||||||
|
|
||||||
#kotlin.jupyter.add.scanner=false
|
#kotlin.jupyter.add.scanner=false
|
||||||
|
kotlin.incremental.js.klib=false
|
||||||
|
|
||||||
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
|
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
@ -76,7 +76,7 @@ public open class VisionGroupBase(
|
|||||||
* Set parent for given child and attach it
|
* Set parent for given child and attach it
|
||||||
*/
|
*/
|
||||||
private fun attachChild(token: NameToken, child: Vision?) {
|
private fun attachChild(token: NameToken, child: Vision?) {
|
||||||
val before = children[token]
|
val before = childrenInternal[token]
|
||||||
when {
|
when {
|
||||||
child == null -> {
|
child == null -> {
|
||||||
childrenInternal.remove(token)
|
childrenInternal.remove(token)
|
||||||
|
@ -27,6 +27,8 @@ import kotlin.reflect.KClass
|
|||||||
public class FX3DPlugin : AbstractPlugin() {
|
public class FX3DPlugin : AbstractPlugin() {
|
||||||
override val tag: PluginTag get() = Companion.tag
|
override val tag: PluginTag get() = Companion.tag
|
||||||
|
|
||||||
|
public val solids: Solids by require(Solids)
|
||||||
|
|
||||||
private val objectFactories = HashMap<KClass<out Solid>, FX3DFactory<*>>()
|
private val objectFactories = HashMap<KClass<out Solid>, FX3DFactory<*>>()
|
||||||
private val compositeFactory = FXCompositeFactory(this)
|
private val compositeFactory = FXCompositeFactory(this)
|
||||||
private val referenceFactory = FXReferenceFactory(this)
|
private val referenceFactory = FXReferenceFactory(this)
|
||||||
@ -50,6 +52,7 @@ public class FX3DPlugin : AbstractPlugin() {
|
|||||||
is SolidGroup -> {
|
is SolidGroup -> {
|
||||||
Group(obj.children.mapNotNull { (token, obj) ->
|
Group(obj.children.mapNotNull { (token, obj) ->
|
||||||
(obj as? Solid)?.let {
|
(obj as? Solid)?.let {
|
||||||
|
logger.info { token.toString() }
|
||||||
buildNode(it).apply {
|
buildNode(it).apply {
|
||||||
properties["name"] = token.toString()
|
properties["name"] = token.toString()
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
public class Solids(meta: Meta) : VisionPlugin(meta) {
|
public class Solids(meta: Meta) : VisionPlugin(meta) {
|
||||||
override val tag: PluginTag get() = Companion.tag
|
override val tag: PluginTag get() = Companion.tag
|
||||||
|
|
||||||
override val visionSerializersModule: SerializersModule get() = serializersModuleForSolids
|
override val visionSerializersModule: SerializersModule get() = serializersModuleForSolids
|
||||||
|
|
||||||
public companion object : PluginFactory<Solids> {
|
public companion object : PluginFactory<Solids> {
|
||||||
|
Loading…
Reference in New Issue
Block a user