forked from kscience/visionforge
Hot fix for circular top volume reference
This commit is contained in:
parent
0ee14aa90e
commit
aea4eb7d45
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user