2021-09-06 22:48:03 +03:00
|
|
|
package space.kscience.visionforge.examples
|
|
|
|
|
|
|
|
import ru.mipt.npm.root.DGeoManager
|
|
|
|
import ru.mipt.npm.root.serialization.TGeoManager
|
|
|
|
import ru.mipt.npm.root.toSolid
|
|
|
|
import space.kscience.dataforge.meta.Meta
|
|
|
|
import space.kscience.dataforge.meta.get
|
|
|
|
import space.kscience.dataforge.meta.isLeaf
|
|
|
|
import space.kscience.dataforge.values.string
|
|
|
|
import space.kscience.visionforge.solid.Solids
|
2021-09-11 14:26:21 +03:00
|
|
|
import java.nio.file.Paths
|
2021-09-14 14:02:36 +03:00
|
|
|
import java.util.zip.ZipInputStream
|
2021-09-11 14:26:21 +03:00
|
|
|
import kotlin.io.path.writeText
|
2021-09-06 22:48:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
private fun Meta.countTypes(): Sequence<String> = sequence {
|
|
|
|
if (!isLeaf) {
|
|
|
|
get("_typename")?.value?.let { yield(it.string) }
|
|
|
|
items.forEach { yieldAll(it.value.countTypes()) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun main() {
|
2021-09-14 14:02:36 +03:00
|
|
|
val string = ZipInputStream(TGeoManager::class.java.getResourceAsStream("/root/BM@N_geometry.zip")!!).use {
|
|
|
|
it.nextEntry
|
|
|
|
it.readAllBytes().decodeToString()
|
|
|
|
}
|
2021-09-06 22:48:03 +03:00
|
|
|
|
|
|
|
val geo = DGeoManager.parse(string)
|
|
|
|
|
|
|
|
|
|
|
|
val sizes = geo.meta.countTypes().groupBy { it }.mapValues { it.value.size }
|
|
|
|
sizes.forEach {
|
|
|
|
println(it)
|
|
|
|
}
|
|
|
|
|
|
|
|
val solid = geo.toSolid()
|
|
|
|
|
2021-09-11 14:26:21 +03:00
|
|
|
Paths.get("BM@N.vf.json").writeText(Solids.encodeToString(solid))
|
2021-09-06 22:48:03 +03:00
|
|
|
//println(Solids.encodeToString(solid))
|
|
|
|
|
2022-01-20 11:13:17 +03:00
|
|
|
makeVisionFile {
|
2021-09-06 22:48:03 +03:00
|
|
|
vision("canvas") {
|
2022-01-20 11:13:17 +03:00
|
|
|
requirePlugin(Solids)
|
2021-09-06 22:48:03 +03:00
|
|
|
solid
|
2021-09-14 14:02:36 +03:00
|
|
|
}
|
2021-09-11 14:26:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-06 22:48:03 +03:00
|
|
|
/* SolidGroup {
|
|
|
|
set(
|
|
|
|
"Coil",
|
|
|
|
solid.getPrototype("Coil".asName())!!.apply {
|
|
|
|
parent = null
|
|
|
|
}
|
|
|
|
)
|
|
|
|
*//* group("Shade") {
|
|
|
|
y = 200
|
|
|
|
color("red")
|
|
|
|
coneSurface(
|
|
|
|
bottomOuterRadius = 135,
|
|
|
|
bottomInnerRadius = 25,
|
|
|
|
height = 50,
|
|
|
|
topOuterRadius = 135,
|
|
|
|
topInnerRadius = 25,
|
|
|
|
angle = 1.5707964
|
|
|
|
) {
|
|
|
|
position = Point3D(79.6, 0, -122.1)
|
|
|
|
rotation = Point3D(-1.5707964, 0, 0)
|
|
|
|
}
|
|
|
|
coneSurface(
|
|
|
|
bottomOuterRadius = 135,
|
|
|
|
bottomInnerRadius = 25,
|
|
|
|
height = 50,
|
|
|
|
topOuterRadius = 135,
|
|
|
|
topInnerRadius = 25,
|
|
|
|
angle = 1.5707964
|
|
|
|
) {
|
|
|
|
position = Point3D(-79.6, 0, -122.1)
|
|
|
|
rotation = Point3D(1.5707964, 0, -3.1415927)
|
|
|
|
}
|
|
|
|
coneSurface(
|
|
|
|
bottomOuterRadius = 135,
|
|
|
|
bottomInnerRadius = 25,
|
|
|
|
height = 50,
|
|
|
|
topOuterRadius = 135,
|
|
|
|
topInnerRadius = 25,
|
|
|
|
angle = 1.5707964
|
|
|
|
) {
|
|
|
|
position = Point3D(79.6, 0, 122.1)
|
|
|
|
rotation = Point3D(1.5707964, 0, 0)
|
|
|
|
}
|
|
|
|
coneSurface(
|
|
|
|
bottomOuterRadius = 135,
|
|
|
|
bottomInnerRadius = 25,
|
|
|
|
height = 50,
|
|
|
|
topOuterRadius = 135,
|
|
|
|
topInnerRadius = 25,
|
|
|
|
angle = 1.5707964
|
|
|
|
) {
|
|
|
|
position = Point3D(-79.6, 0, 122.1)
|
|
|
|
rotation = Point3D(-1.5707964, 0, -3.1415927)
|
|
|
|
}
|
|
|
|
}*//*
|
|
|
|
}*/
|