From e1138be8618fcb1bf52038c0915ff3b0085748cb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 15 Jul 2021 12:28:25 +0300 Subject: [PATCH] layer marking --- .../kotlin/space/kscience/visionforge/gdml/markLayers.kt | 6 +++--- .../kotlin/space/kscience/visionforge/solid/Solid.kt | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt index dfee104e..befc69bb 100644 --- a/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt +++ b/visionforge-gdml/src/commonMain/kotlin/space/kscience/visionforge/gdml/markLayers.kt @@ -55,12 +55,12 @@ public fun SolidGroup.markLayers(thresholds: List = listOf(500, 1000, 20000 val counterTree = VisionCounterTree(Name.EMPTY, this, hashMapOf()) val totalCount = counterTree.childrenCount if (totalCount > thresholds.firstOrNull() ?: 0) { - val allNodes = counterTree.topToBottom().filter { it.selfCount > 1 }.distinct().toMutableList() + val allNodes = counterTree.topToBottom().distinct().toMutableList() //println("tree construction finished") allNodes.sortWith( compareBy( { it.name.length }, - { it.childrenCount * it.selfCount } + { (it.children.size + 1) * it.selfCount } ).reversed() ) @@ -76,7 +76,7 @@ public fun SolidGroup.markLayers(thresholds: List = listOf(500, 1000, 20000 if (layerIndex == 0) break node.vision.layer = layerIndex - remaining -= node.selfCount * node.childrenCount + remaining -= node.selfCount * (node.children.size + 1) logger?.apply { if (node.selfCount > 1) { info { "Prototype with name ${node.name} moved to layer $layerIndex. $remaining nodes remains" } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt index 0a59d141..a4c8e69c 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt @@ -37,8 +37,6 @@ public interface Solid : Vision { override val descriptor: NodeDescriptor get() = Companion.descriptor - - public companion object { // val SELECTED_KEY = "selected".asName() public val DETAIL_KEY: Name = "detail".asName()