Fix MM model
This commit is contained in:
parent
5721bb9456
commit
e38bac8d23
@ -28,7 +28,6 @@ class Model(val manager: VisionManager) {
|
|||||||
|
|
||||||
private fun SolidGroup.detector(detector: SC16) {
|
private fun SolidGroup.detector(detector: SC16) {
|
||||||
group(detector.name) {
|
group(detector.name) {
|
||||||
position = detector.center
|
|
||||||
detector.pixels.forEach {
|
detector.pixels.forEach {
|
||||||
pixel(it)
|
pixel(it)
|
||||||
}
|
}
|
||||||
@ -65,6 +64,7 @@ class Model(val manager: VisionManager) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun highlight(pixel: String) {
|
private fun highlight(pixel: String) {
|
||||||
|
println("highlight $pixel")
|
||||||
map[pixel]?.color?.invoke("blue")
|
map[pixel]?.color?.invoke("blue")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +76,7 @@ class Model(val manager: VisionManager) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun displayEvent(event: Event) {
|
fun displayEvent(event: Event) {
|
||||||
|
println("Received event: $event")
|
||||||
events.add(event)
|
events.add(event)
|
||||||
event.hits.forEach {
|
event.hits.forEach {
|
||||||
highlight(it)
|
highlight(it)
|
||||||
@ -83,6 +84,7 @@ class Model(val manager: VisionManager) {
|
|||||||
event.track?.let {
|
event.track?.let {
|
||||||
tracks.polyline(*it.toTypedArray(), name = "track[${event.id}]") {
|
tracks.polyline(*it.toTypedArray(), name = "track[${event.id}]") {
|
||||||
thickness = 4
|
thickness = 4
|
||||||
|
color("red")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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_XY_SIZE
|
||||||
import ru.mipt.npm.muon.monitor.Monitor.PIXEL_Z_SIZE
|
import ru.mipt.npm.muon.monitor.Monitor.PIXEL_Z_SIZE
|
||||||
import space.kscience.visionforge.solid.Point3D
|
import space.kscience.visionforge.solid.Point3D
|
||||||
|
import space.kscience.visionforge.solid.plus
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single pixel
|
* A single pixel
|
||||||
@ -97,7 +98,7 @@ class SC16(
|
|||||||
}
|
}
|
||||||
val offset = Point3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0));
|
val offset = Point3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0));
|
||||||
val pixelName = "${name}_${index}"
|
val pixelName = "${name}_${index}"
|
||||||
SC1(pixelName, offset)
|
SC1(pixelName, offset + center)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,10 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val root = props.model.root.apply {
|
val root = useMemo(props.model) {
|
||||||
edges()
|
props.model.root.apply {
|
||||||
|
edges()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gridRow {
|
gridRow {
|
||||||
|
@ -16,10 +16,10 @@ import kotlin.random.Random
|
|||||||
*/
|
*/
|
||||||
internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
|
internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
|
||||||
// val layer: Layer = findLayer(center.z);
|
// val layer: Layer = findLayer(center.z);
|
||||||
private val upLayer =
|
private val upLayer = findLayer(sc.center.z + sc.zSize / 2f)
|
||||||
findLayer(sc.center.z + sc.zSize / 2f)//Layer("${name}_up", center.z + zSize / 2.0);
|
//Layer("${name}_up", center.z + zSize / 2.0);
|
||||||
private val bottomLayer =
|
private val bottomLayer = findLayer(sc.center.z - sc.zSize / 2f)
|
||||||
findLayer(sc.center.z - sc.zSize / 2f)//Layer("${name}_bottom", center.z - zSize / 2.0);
|
//Layer("${name}_bottom", center.z - zSize / 2.0);
|
||||||
private val centralLayer = findLayer(sc.center.z)
|
private val centralLayer = findLayer(sc.center.z)
|
||||||
|
|
||||||
private val center = Vector3D(sc.center.x.toDouble(), sc.center.y.toDouble(), sc.center.z.toDouble())
|
private val center = Vector3D(sc.center.x.toDouble(), sc.center.y.toDouble(), sc.center.z.toDouble())
|
||||||
@ -115,8 +115,8 @@ internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
|
|||||||
|
|
||||||
private val auxCache = HashMap<SC1, SC1Aux>()
|
private val auxCache = HashMap<SC1, SC1Aux>()
|
||||||
|
|
||||||
fun SC1.isHit(track: Line): Boolean{
|
fun SC1.isHit(track: Line): Boolean {
|
||||||
return auxCache.getOrPut(this){
|
return auxCache.getOrPut(this) {
|
||||||
SC1Aux(this)
|
SC1Aux(this)
|
||||||
}.isHit(track)
|
}.isHit(track)
|
||||||
}
|
}
|
@ -7,9 +7,11 @@ import info.laht.threekt.objects.LineSegments
|
|||||||
import space.kscience.visionforge.computePropertyNode
|
import space.kscience.visionforge.computePropertyNode
|
||||||
import space.kscience.visionforge.onPropertyChange
|
import space.kscience.visionforge.onPropertyChange
|
||||||
import space.kscience.visionforge.solid.PolyLine
|
import space.kscience.visionforge.solid.PolyLine
|
||||||
|
import space.kscience.visionforge.solid.SolidMaterial
|
||||||
import space.kscience.visionforge.solid.color
|
import space.kscience.visionforge.solid.color
|
||||||
import space.kscience.visionforge.solid.string
|
import space.kscience.visionforge.solid.string
|
||||||
import space.kscience.visionforge.solid.three.ThreeMaterials.DEFAULT_LINE_COLOR
|
import space.kscience.visionforge.solid.three.ThreeMaterials.DEFAULT_LINE_COLOR
|
||||||
|
import kotlin.math.ceil
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
public object ThreeLineFactory : ThreeFactory<PolyLine> {
|
public object ThreeLineFactory : ThreeFactory<PolyLine> {
|
||||||
@ -17,12 +19,14 @@ public object ThreeLineFactory : ThreeFactory<PolyLine> {
|
|||||||
|
|
||||||
override fun invoke(three: ThreePlugin, obj: PolyLine): Object3D {
|
override fun invoke(three: ThreePlugin, obj: PolyLine): Object3D {
|
||||||
val geometry = BufferGeometry().apply {
|
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(
|
val material = ThreeMaterials.getLineMaterial(
|
||||||
obj.computePropertyNode(MeshThreeFactory.EDGES_MATERIAL_KEY),
|
obj.computePropertyNode(SolidMaterial.MATERIAL_KEY),
|
||||||
true
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
material.linewidth = obj.thickness.toDouble()
|
material.linewidth = obj.thickness.toDouble()
|
||||||
|
Loading…
Reference in New Issue
Block a user