Fix MM model

This commit is contained in:
Alexander Nozik 2021-08-11 18:17:47 +03:00
parent 5721bb9456
commit e38bac8d23
5 changed files with 22 additions and 13 deletions

View File

@ -28,7 +28,6 @@ class Model(val manager: VisionManager) {
private fun SolidGroup.detector(detector: SC16) {
group(detector.name) {
position = detector.center
detector.pixels.forEach {
pixel(it)
}
@ -65,6 +64,7 @@ class Model(val manager: VisionManager) {
}
private fun highlight(pixel: String) {
println("highlight $pixel")
map[pixel]?.color?.invoke("blue")
}
@ -76,6 +76,7 @@ class Model(val manager: VisionManager) {
}
fun displayEvent(event: Event) {
println("Received event: $event")
events.add(event)
event.hits.forEach {
highlight(it)
@ -83,6 +84,7 @@ class Model(val manager: VisionManager) {
event.track?.let {
tracks.polyline(*it.toTypedArray(), name = "track[${event.id}]") {
thickness = 4
color("red")
}
}
}

View File

@ -3,6 +3,7 @@ package ru.mipt.npm.muon.monitor
import ru.mipt.npm.muon.monitor.Monitor.PIXEL_XY_SIZE
import ru.mipt.npm.muon.monitor.Monitor.PIXEL_Z_SIZE
import space.kscience.visionforge.solid.Point3D
import space.kscience.visionforge.solid.plus
/**
* A single pixel
@ -97,7 +98,7 @@ class SC16(
}
val offset = Point3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0));
val pixelName = "${name}_${index}"
SC1(pixelName, offset)
SC1(pixelName, offset + center)
}
}
}

View File

@ -56,9 +56,11 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
}
}
val root = props.model.root.apply {
val root = useMemo(props.model) {
props.model.root.apply {
edges()
}
}
gridRow {
flexColumn {

View File

@ -16,10 +16,10 @@ import kotlin.random.Random
*/
internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
// val layer: Layer = findLayer(center.z);
private val upLayer =
findLayer(sc.center.z + sc.zSize / 2f)//Layer("${name}_up", center.z + zSize / 2.0);
private val bottomLayer =
findLayer(sc.center.z - sc.zSize / 2f)//Layer("${name}_bottom", center.z - zSize / 2.0);
private val upLayer = findLayer(sc.center.z + sc.zSize / 2f)
//Layer("${name}_up", center.z + zSize / 2.0);
private val bottomLayer = findLayer(sc.center.z - sc.zSize / 2f)
//Layer("${name}_bottom", center.z - zSize / 2.0);
private val centralLayer = findLayer(sc.center.z)
private val center = Vector3D(sc.center.x.toDouble(), sc.center.y.toDouble(), sc.center.z.toDouble())

View File

@ -7,9 +7,11 @@ import info.laht.threekt.objects.LineSegments
import space.kscience.visionforge.computePropertyNode
import space.kscience.visionforge.onPropertyChange
import space.kscience.visionforge.solid.PolyLine
import space.kscience.visionforge.solid.SolidMaterial
import space.kscience.visionforge.solid.color
import space.kscience.visionforge.solid.string
import space.kscience.visionforge.solid.three.ThreeMaterials.DEFAULT_LINE_COLOR
import kotlin.math.ceil
import kotlin.reflect.KClass
public object ThreeLineFactory : ThreeFactory<PolyLine> {
@ -17,12 +19,14 @@ public object ThreeLineFactory : ThreeFactory<PolyLine> {
override fun invoke(three: ThreePlugin, obj: PolyLine): Object3D {
val geometry = BufferGeometry().apply {
setFromPoints(Array(obj.points.size) { obj.points[it].toVector() })
setFromPoints(Array((obj.points.size - 1) * 2) {
obj.points[ceil(it / 2.0).toInt()].toVector()
})
}
val material = ThreeMaterials.getLineMaterial(
obj.computePropertyNode(MeshThreeFactory.EDGES_MATERIAL_KEY),
true
obj.computePropertyNode(SolidMaterial.MATERIAL_KEY),
false
)
material.linewidth = obj.thickness.toDouble()