Compare commits
319 Commits
v0.1.5-dev
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
fb12ca8902 | ||
|
c6258e72fb | ||
db5064f6ed | |||
d504943295 | |||
8a6fab97e3 | |||
b88090a7dd | |||
9745a58873 | |||
bfa7f5ea57 | |||
|
ad9f43f5a5 | ||
abf04cc657 | |||
f2f6608a2e | |||
|
e512e9bbcf | ||
30fa35bef5 | |||
|
cebef9472a | ||
|
d278427f66 | ||
|
6260117c68 | ||
|
e70ef813de | ||
faeefe8572 | |||
6d5c00f88b | |||
59e939a175 | |||
bf5d47fd0e | |||
43285de33c | |||
6b8e166978 | |||
104e8f8f6f | |||
b5fdc6c4fe | |||
3caa22f8bf | |||
e7f0e1e4fc | |||
8d74bc55d1 | |||
a715c2660a | |||
6787ec85de | |||
b40c1d0025 | |||
9eb5def13c | |||
dee2cf848c | |||
0ec9033702 | |||
|
44c4356794 | ||
0041a66575 | |||
42eb0a6f66 | |||
|
a655410a2a | ||
d131dc49ab | |||
f89b003e93 | |||
bdbe940272 | |||
2e3b63c0f4 | |||
aea4eb7d45 | |||
0ee14aa90e | |||
e25c1bd49b | |||
7b5faaa61e | |||
68704086e9 | |||
193665b99a | |||
df30f8ecc3 | |||
e39f79e4ab | |||
64e084dc53 | |||
|
cc1e35bfca | ||
|
a3eaa167a5 | ||
|
59bc541540 | ||
|
51b8ae279a | ||
|
ce9a2dde11 | ||
|
5f07bf1920 | ||
|
ab1ff5b16f | ||
|
0b4fea5ff1 | ||
|
9b6cdd0166 | ||
1b2d61008f | |||
|
1e4e4373bc | ||
|
f0bf293017 | ||
|
a7252e62f9 | ||
02df77e97e | |||
|
7103f49ff9 | ||
829d0dfde7 | |||
9a1ea8bd1f | |||
5d2c853cbe | |||
a748282d63 | |||
4201362cc4 | |||
f2120aedf3 | |||
6ff3a04278 | |||
b79265e8c2 | |||
|
f00408166b | ||
a15afb3d52 | |||
9afe5da45b | |||
bb61b97c1d | |||
cbc67cb16b | |||
238a9e0dd1 | |||
|
f602e21b23 | ||
|
350d7c6634 | ||
|
67a2d3c241 | ||
|
0c71101858 | ||
|
c70d4d2da6 | ||
|
d361d42c29 | ||
|
7b99ec54d2 | ||
|
68495c0cdf | ||
8a8bac48db | |||
95459422d6 | |||
af327c17e3 | |||
f99a359e24 | |||
a33d9d1946 | |||
60cec91ab8 | |||
d916dde6a7 | |||
c44162671f | |||
c425f3b36f | |||
1505aa8091 | |||
c410baac8c | |||
e38bac8d23 | |||
|
25e46a6c47 | ||
5721bb9456 | |||
|
a027e71c48 | ||
|
004cdc049b | ||
7b78052f61 | |||
8d21d3cd74 | |||
|
052336700a | ||
|
2a9e5c4078 | ||
|
0e3c3cf2ce | ||
|
60da696785 | ||
|
5b2da86838 | ||
|
92474b0334 | ||
|
623d1e7e3e | ||
|
99c6d0e14c | ||
|
84e0211b54 | ||
|
16c3144b45 | ||
|
9c6d646b53 | ||
|
2d6be6629a | ||
|
cb057db93b | ||
|
133de264c1 | ||
|
f71130ea0b | ||
|
1d77768071 | ||
|
689071d0da | ||
|
6d7356f08c | ||
|
d5c0afd8c0 | ||
|
2c2b7a5fa2 | ||
|
b3ecc2136e | ||
|
426c1ff990 | ||
|
b566d1c9f6 | ||
|
eea617f418 | ||
|
a0d3e46f61 | ||
|
89cff65a90 | ||
|
0dafbb2a34 | ||
|
29bcaab1f8 | ||
|
639a192d59 | ||
|
145673752e | ||
|
2643d2b587 | ||
|
4bdea746fc | ||
|
aa53b7b9b7 | ||
|
456e01fcfa | ||
|
4a2b891b83 | ||
|
d51a38eac4 | ||
|
a474ad7b3b | ||
|
72d3503dc3 | ||
|
786b902fd9 | ||
|
e818ecdcc3 | ||
|
f611409208 | ||
|
44da86d496 | ||
|
10626a836d | ||
|
73d5943a07 | ||
|
3a5da762d1 | ||
|
e37bc77988 | ||
|
5bd6f98c6e | ||
|
eb3786c5ca | ||
a0d62c65d7 | |||
787c841a51 | |||
|
f6459ec07f | ||
e50e266f94 | |||
01ea6b5494 | |||
87260cea86 | |||
|
bdb28eb338 | ||
|
6435f71783 | ||
a87692ae1f | |||
c1627b4504 | |||
493c527743 | |||
fb358dbc8e | |||
|
7242b5b4e0 | ||
|
a5466dca0c | ||
|
95220422cc | ||
e1138be861 | |||
38c76e824d | |||
8f95d6f485 | |||
f2e7e16d62 | |||
0d53b6f77d | |||
5af8fe3e99 | |||
073d374a9e | |||
42e2530f6f | |||
7b30b62849 | |||
2b6942b827 | |||
ba637413c7 | |||
c82c0ecea3 | |||
199cad1dc1 | |||
18b6ac2c37 | |||
|
32dad9d8b5 | ||
|
3fdd0d62d4 | ||
a7841edb3c | |||
a583030c1c | |||
230cd5dc61 | |||
b0cd80a4e6 | |||
7cf819d7ce | |||
ea5f0abbf6 | |||
9cc3f65a18 | |||
9b99df88a5 | |||
91e7e8573e | |||
dfc0ffda38 | |||
bd1f7d75fc | |||
288307eaa8 | |||
359eb05f83 | |||
fb3ff4d6fc | |||
bdbff04d78 | |||
8652b03fa5 | |||
1f8700efde | |||
5afa9117c4 | |||
b8fadb06b5 | |||
e615fcc2bc | |||
65c0183ba7 | |||
faf3fa8512 | |||
2798439582 | |||
03b666017b | |||
e644b1b20a | |||
ff80629f24 | |||
3a87e43483 | |||
8a41f185de | |||
0961ae90b7 | |||
97b988d419 | |||
1a5a207fb7 | |||
8060933859 | |||
7febb4452a | |||
3f6e39b18d | |||
545753b14b | |||
30e6370204 | |||
0e488563a9 | |||
78a04728ba | |||
720555a942 | |||
7c9315b029 | |||
bc15d9241b | |||
a5bfa0f147 | |||
27fe492ab7 | |||
5d0ceb8e50 | |||
60906db32e | |||
1da4381a4c | |||
e82ea7bb94 | |||
2b7971eeea | |||
dab93fc136 | |||
19513656bd | |||
4820082248 | |||
f7301805fd | |||
18828e87f2 | |||
5eb9925d35 | |||
716487d70a | |||
bb6c6e2175 | |||
0c1d6139ae | |||
33146fef1b | |||
3f9f253416 | |||
|
f0f117d4fc | ||
51af6b9378 | |||
56481933ed | |||
1e183107cf | |||
346b61724f | |||
2b02f151d2 | |||
25a47a9719 | |||
3c0df98f50 | |||
216be4a6a1 | |||
66ea23ad60 | |||
eefc036dcb | |||
0259d4eb15 | |||
4c235b0f53 | |||
ccb916cff7 | |||
6939fba292 | |||
be1d79c229 | |||
97cdfd3719 | |||
6a6d9659ca | |||
929832f3a5 | |||
b2ba92e745 | |||
85bb690699 | |||
c83954dca9 | |||
1ccd45d6c5 | |||
382686b9aa | |||
f4970955cb | |||
651a875eee | |||
70ac2c99dd | |||
734d1e1168 | |||
a38d70bade | |||
6a742658af | |||
faddb8a393 | |||
a7136d3eff | |||
8a4779e9c4 | |||
face7bfd0c | |||
a85cd828e6 | |||
9b42d4f186 | |||
ebb7bf72d1 | |||
2be4576495 | |||
5e340aa179 | |||
a44e8091c8 | |||
e44096e844 | |||
698f74adaa | |||
d1607459a1 | |||
dc805228b4 | |||
d2553d5b40 | |||
e01a688664 | |||
cae3ab00d9 | |||
6a48948c15 | |||
613624ff17 | |||
62a76f2c86 | |||
7e037b57fc | |||
dfac01d352 | |||
fdc221dfa1 | |||
5b8d298ac6 | |||
6b4bc6912f | |||
8f6c3822ff | |||
7571b58e99 | |||
aaad836567 | |||
3edb00b6bf | |||
22c3521a9e | |||
072b036fa2 | |||
f72d626b0b | |||
c3001cd858 | |||
6116523091 | |||
9361145197 | |||
c83a25b0a1 | |||
68cf4748d8 | |||
ea82082304 | |||
998afb1ce0 | |||
b362f86f9b | |||
a5eba1789b | |||
48705e6670 | |||
de2ef1dcc5 | |||
62a6eafdeb | |||
ea276d35e9 |
22
.github/workflows/build.yml
vendored
Normal file
22
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: Gradle build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ dev, master ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: liberica
|
||||
- name: execute build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build
|
19
.github/workflows/gradle.yml
vendored
19
.github/workflows/gradle.yml
vendored
@ -1,19 +0,0 @@
|
||||
name: Gradle build
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
25
.github/workflows/pages.yml
vendored
Normal file
25
.github/workflows/pages.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: Dokka publication
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 40
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: liberica
|
||||
- name: execute build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: dokkaHtmlMultiModule
|
||||
- uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: build/dokka/htmlMultiModule
|
27
.github/workflows/publish.yml
vendored
Normal file
27
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
name: Gradle publish
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [ created ]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
environment:
|
||||
name: publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2.5.0
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: liberica
|
||||
- name: execute build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Publish
|
||||
shell: bash
|
||||
run: >
|
||||
./gradlew release --no-daemon --build-cache -Ppublishing.enabled=true
|
||||
-Ppublishing.space.user=${{ secrets.SPACE_APP_ID }}
|
||||
-Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }}
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,7 +4,6 @@
|
||||
out/
|
||||
.gradle
|
||||
build/
|
||||
|
||||
data/
|
||||
|
||||
!gradle-wrapper.jar
|
||||
gradle.properties
|
4
.space.kts
Normal file
4
.space.kts
Normal file
@ -0,0 +1,4 @@
|
||||
job("Build") {
|
||||
gradlew("openjdk:11", "build")
|
||||
}
|
||||
|
56
CHANGELOG.md
56
CHANGELOG.md
@ -0,0 +1,56 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
|
||||
## [0.2.0]
|
||||
### Added
|
||||
- Server module
|
||||
- Change collector
|
||||
- Customizable accessors for colors
|
||||
- SphereLayer solid
|
||||
- Hexagon interface and GenericHexagon implementation (Box inherits Hexagon)
|
||||
- Increased the default detail level for spheres and cones to 32
|
||||
- Simple clipping for Solids in ThreeJs
|
||||
- Markdown module
|
||||
- Tables module
|
||||
|
||||
|
||||
### Changed
|
||||
- Vision does not implement ItemProvider anymore. Property changes are done via `getProperty`/`setProperty` and `property` delegate.
|
||||
- Point3D and Point2D are made separate classes instead of expect/actual (to split up different engines.
|
||||
- JavaFX support moved to a separate module
|
||||
- Threejs support moved to a separate module
|
||||
- \[Format breaking change!\] Stylesheets are moved into properties under `@stylesheet` key
|
||||
- VisionGroup builder accepts `null` as name for statics instead of `""`
|
||||
- gdml sphere is rendered as a SphereLayer instead of Sphere (#35)
|
||||
- Tube is replaced by more general ConeSurface
|
||||
- position, rotation and size moved to properties
|
||||
- prototypes moved to children
|
||||
- Immutable Solid instances
|
||||
- Property listeners are not triggered if there are no changes.
|
||||
- Feedback websocket connection in the client.
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- Primary modules dependencies on UI
|
||||
|
||||
|
||||
### Fixed
|
||||
- Version conflicts
|
||||
|
||||
|
||||
### Security
|
||||
|
235
README.md
235
README.md
@ -1,34 +1,40 @@
|
||||
[![JetBrains Research](https://jb.gg/badges/research.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
|
||||
[![DOI](https://zenodo.org/badge/174502624.svg)](https://zenodo.org/badge/latestdoi/174502624)
|
||||
|
||||
![Gradle build](https://github.com/mipt-npm/visionforge/workflows/Gradle%20build/badge.svg)
|
||||
|
||||
[![Slack](https://img.shields.io/badge/slack-channel-green?logo=slack)](https://kotlinlang.slack.com/archives/CEXV2QWNM)
|
||||
|
||||
# DataForge Visualization Platform
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Requirements](#requirements)
|
||||
* [Features](#features)
|
||||
* [About DataForge](#about-dataforge)
|
||||
* [Modules contained in this repository](#modules-contained-in-this-repository)
|
||||
* [visionforge-core](#visionforge-core)
|
||||
* [visionforge-solid](#visionforge-solid)
|
||||
* [visionforge-gdml](#visionforge-gdml)
|
||||
* [Visualization for External Systems](#visualization-for-external-systems)
|
||||
* [Visualization for External Systems](#visualization-for-external-systems)
|
||||
* [Demonstrations](#demonstrations)
|
||||
* [Simple Example - Spatial Showcase](#simple-example---spatial-showcase)
|
||||
* [Simple Example - Solid Showcase](#simple-example---solid-showcase)
|
||||
* [Full-Stack Application Example - Muon Monitor](#full-stack-application-example---muon-monitor-visualization)
|
||||
* [GDML Example](#gdml-example)
|
||||
|
||||
|
||||
## Introduction
|
||||
|
||||
This repository contains a [DataForge](#about-dataforge)\-based framework
|
||||
used for visualization in various scientific applications.
|
||||
This repository contains a [DataForge](#about-dataforge)\-based framework
|
||||
used for visualization in various scientific applications.
|
||||
|
||||
The main framework's use case for now is 3D visualization for particle physics experiments.
|
||||
The main framework's use case for now is 3D visualization for particle physics experiments.
|
||||
Other applications including 2D plots are planned for the future.
|
||||
|
||||
The project is developed as a [Kotlin multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html)
|
||||
The project is developed as a [Kotlin multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html)
|
||||
application, currently targeting browser JavaScript and JVM.
|
||||
|
||||
## Requirements
|
||||
|
||||
JVM backend requires JDK 11 or later
|
||||
|
||||
## Features
|
||||
|
||||
@ -48,60 +54,193 @@ Platform uses some of the concepts and modules of DataForge, including: `Meta`,
|
||||
`Provider`, and some others.
|
||||
|
||||
To learn more about DataForge, please consult the following URLs:
|
||||
* [Kotlin multiplatform implementation of DataForge](https://github.com/mipt-npm/dataforge-core)
|
||||
* [DataForge documentation](http://npm.mipt.ru/dataforge/)
|
||||
* [Original implementation of DataForge](https://bitbucket.org/Altavir/dataforge/src/default/)
|
||||
* [Kotlin multiplatform implementation of DataForge](https://github.com/mipt-npm/dataforge-core)
|
||||
* [DataForge documentation](http://npm.mipt.ru/dataforge/)
|
||||
* [Original implementation of DataForge](https://bitbucket.org/Altavir/dataforge/src/default/)
|
||||
|
||||
|
||||
## Modules contained in this repository
|
||||
|
||||
### visionforge-core
|
||||
<hr/>
|
||||
|
||||
Contains a general hierarchy of classes and interfaces useful for visualization.
|
||||
This module is not specific to 3D-visualization.
|
||||
* ### [cern-root-loader](cern-root-loader)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [demo](demo)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [jupyter](jupyter)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [ui](ui)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-core](visionforge-core)
|
||||
>
|
||||
>
|
||||
> **Maturity**: DEVELOPMENT
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-fx](visionforge-fx)
|
||||
>
|
||||
>
|
||||
> **Maturity**: PROTOTYPE
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-gdml](visionforge-gdml)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-markdown](visionforge-markdown)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-plotly](visionforge-plotly)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-server](visionforge-server)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-solid](visionforge-solid)
|
||||
>
|
||||
>
|
||||
> **Maturity**: DEVELOPMENT
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-tables](visionforge-tables)
|
||||
>
|
||||
>
|
||||
> **Maturity**: PROTOTYPE
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-threejs](visionforge-threejs)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [gdml](demo/gdml)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [js-playground](demo/js-playground)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [muon-monitor](demo/muon-monitor)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [playground](demo/playground)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [plotly-fx](demo/plotly-fx)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [sat-demo](demo/sat-demo)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [solid-showcase](demo/solid-showcase)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-jupyter-gdml](jupyter/visionforge-jupyter-gdml)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [bootstrap](ui/bootstrap)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [react](ui/react)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [ring](ui/ring)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
* ### [visionforge-threejs-server](visionforge-threejs/visionforge-threejs-server)
|
||||
>
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
<hr/>
|
||||
|
||||
The `visionforge-core` module also includes configuration editors for JS (in `jsMain`) and JVM (in `jvmMain`).
|
||||
|
||||
**Class diagram:**
|
||||
|
||||
![](doc/resources/class-diag-core.png)
|
||||
|
||||
|
||||
### visionforge-solid
|
||||
|
||||
Includes common classes and serializers for 3D visualization, as well as Three.js and JavaFX implementations.
|
||||
|
||||
**Class diagram:**
|
||||
|
||||
![](doc/resources/class-diag-solid.png)
|
||||
![](docs/images/class-diag-solid.png)
|
||||
|
||||
##### Prototypes
|
||||
|
||||
One of the important features of the framework is support for 3D object prototypes (sometimes
|
||||
also referred to as templates). The idea is that prototype geometry can be rendered once and reused
|
||||
also referred to as templates). The idea is that prototype geometry can be rendered once and reused
|
||||
for multiple objects. This helps to significantly decrease memory usage.
|
||||
|
||||
The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and
|
||||
`Proxy` class helps to reuse a template object.
|
||||
The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and
|
||||
`SolidReference` class helps to reuse a template object.
|
||||
|
||||
##### Styles
|
||||
|
||||
`SolidGroup` has a `styleSheet` property that can optionally define styles at the Group's
|
||||
level. Styles are applied to child (descendant) objects using `Vision.styles: List<String>` property.
|
||||
`VisionGroup` has a `styleSheet` property that can optionally define styles at the Group's
|
||||
level. Styles are applied to child (descendant) objects using `Vision.styles: List<String>` property.
|
||||
|
||||
### visionforge-threejs
|
||||
|
||||
### visionforge-gdml
|
||||
|
||||
GDML bindings for 3D visualization (to be moved to gdml project).
|
||||
|
||||
|
||||
## Visualization for External Systems
|
||||
## Visualization for External Systems
|
||||
|
||||
The `visionforge` framework can be used to visualize geometry and events from external,
|
||||
non-Kotlin based systems, such as ROOT. This will require a plugin to convert data model
|
||||
of the external system to that of `visionforge`. Performing such integration is a work
|
||||
currently in progress.
|
||||
|
||||
|
||||
|
||||
## Demonstrations
|
||||
|
||||
@ -109,36 +248,42 @@ The `demo` module contains several example projects (demonstrations) of using th
|
||||
They are briefly described in this section, for more details please consult the corresponding per-project
|
||||
README file.
|
||||
|
||||
### Simple Example - Spatial Showcase
|
||||
### Simple Example - Solid Showcase
|
||||
|
||||
Contains a simple demonstration with a grid including a few shapes that you can rotate, move camera, and so on.
|
||||
Some shapes will also periodically change their color and visibility.
|
||||
|
||||
[More details](demo/spatial-showcase/README.md)
|
||||
[More details](demo/solid-showcase/README.md)
|
||||
|
||||
**Example view:**
|
||||
|
||||
![](doc/resources/spatial-showcase.png)
|
||||
![](docs/images/solid-showcase.png)
|
||||
|
||||
|
||||
### Full-Stack Application Example - Muon Monitor Visualization
|
||||
|
||||
A full-stack application example, showing the
|
||||
A full-stack application example, showing the
|
||||
[Muon Monitor](http://npm.mipt.ru/en/projects/physics#mounMonitor) experiment set-up.
|
||||
|
||||
[More details](demo/muon-monitor/README.md)
|
||||
|
||||
**Example view:**
|
||||
|
||||
![](doc/resources/muon-monitor.png)
|
||||
![](docs/images/muon-monitor.png)
|
||||
|
||||
|
||||
### GDML Example
|
||||
|
||||
Visualization example for geometry defined as GDML file.
|
||||
Visualization example for geometry defined as GDML file.
|
||||
|
||||
[More details](demo/gdml/README.md)
|
||||
|
||||
##### Example view:
|
||||
|
||||
![](doc/resources/gdml-demo.png)
|
||||
![](docs/images/gdml-demo.png)
|
||||
|
||||
|
||||
## Thanks and references
|
||||
The original three.js bindings were made by [Lars Ivar Hatledal](https://github.com/markaren), but the project is discontinued right now.
|
||||
|
||||
All other libraries are explicitly shown as dependencies. We would like to express specific thanks to JetBrains Kotlin-JS team for consulting us during the work.
|
||||
|
@ -1,35 +1,34 @@
|
||||
import scientifik.useFx
|
||||
import scientifik.useSerialization
|
||||
|
||||
val dataforgeVersion by extra("0.1.8")
|
||||
|
||||
plugins {
|
||||
id("scientifik.mpp") apply false
|
||||
id("scientifik.jvm") apply false
|
||||
id("scientifik.js") apply false
|
||||
id("scientifik.publish") apply false
|
||||
id("org.jetbrains.changelog") version "0.4.0"
|
||||
id("ru.mipt.npm.gradle.project")
|
||||
id("org.jetbrains.kotlinx.kover") version "0.5.0-RC"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||
maven("http://maven.jzy3d.org/releases")
|
||||
}
|
||||
val dataforgeVersion by extra("0.5.2")
|
||||
val fxVersion by extra("11")
|
||||
|
||||
group = "hep.dataforge"
|
||||
version = "0.1.5-dev"
|
||||
allprojects{
|
||||
group = "space.kscience"
|
||||
version = "0.2.0"
|
||||
}
|
||||
|
||||
val githubProject by extra("visionforge")
|
||||
val bintrayRepo by extra("dataforge")
|
||||
val fxVersion by extra("14")
|
||||
|
||||
subprojects {
|
||||
if(name.startsWith("visionforge")) {
|
||||
apply(plugin = "scientifik.publish")
|
||||
if (name.startsWith("visionforge")) apply<MavenPublishPlugin>()
|
||||
|
||||
repositories {
|
||||
maven("https://repo.kotlin.link")
|
||||
mavenCentral()
|
||||
maven("https://maven.jzy3d.org/releases")
|
||||
}
|
||||
useSerialization()
|
||||
useFx(scientifik.FXModule.CONTROLS, version = fxVersion)
|
||||
}
|
||||
}
|
||||
|
||||
ksciencePublish {
|
||||
github("visionforge")
|
||||
space()
|
||||
sonatype()
|
||||
}
|
||||
|
||||
apiValidation {
|
||||
ignoredPackages.add("info.laht.threekt")
|
||||
}
|
||||
|
||||
readme.readmeTemplate = file("docs/templates/README-TEMPLATE.md")
|
4
cern-root-loader/README.md
Normal file
4
cern-root-loader/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Module cern-root-loader
|
||||
|
||||
|
||||
|
926
cern-root-loader/api/cern-root-loader.api
Normal file
926
cern-root-loader/api/cern-root-loader.api
Normal file
@ -0,0 +1,926 @@
|
||||
public final class ru/mipt/npm/root/DGeoBoolNode : ru/mipt/npm/root/DObject {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFLeft ()Lru/mipt/npm/root/DGeoShape;
|
||||
public final fun getFLeftMat ()Lru/mipt/npm/root/DGeoMatrix;
|
||||
public final fun getFRight ()Lru/mipt/npm/root/DGeoShape;
|
||||
public final fun getFRightMat ()Lru/mipt/npm/root/DGeoMatrix;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoManager : ru/mipt/npm/root/DNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/DGeoManager$Companion;
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFMatrices ()Ljava/util/List;
|
||||
public final fun getFNodes ()Ljava/util/List;
|
||||
public final fun getFShapes ()Ljava/util/List;
|
||||
public final fun getFVolumes ()Ljava/util/List;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoManager$Companion {
|
||||
public final fun parse (Ljava/lang/String;)Lru/mipt/npm/root/DGeoManager;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoMaterial : ru/mipt/npm/root/DNamed {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/DGeoMatrix : ru/mipt/npm/root/DNamed {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoMedium : ru/mipt/npm/root/DNamed {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFMaterial ()Lru/mipt/npm/root/DGeoMaterial;
|
||||
public final fun getFParams ()[D
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoNode : ru/mipt/npm/root/DNamed {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFVolume ()Lru/mipt/npm/root/DGeoVolume;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/DGeoScale : ru/mipt/npm/root/DGeoMatrix {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFScale ()[D
|
||||
public final fun getX ()D
|
||||
public final fun getY ()D
|
||||
public final fun getZ ()D
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoShape : ru/mipt/npm/root/DNamed {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFDX ()D
|
||||
public final fun getFDY ()D
|
||||
public final fun getFDZ ()D
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DGeoVolume : ru/mipt/npm/root/DNamed, space/kscience/dataforge/misc/Named {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFFillColor ()Ljava/lang/Integer;
|
||||
public final fun getFMedium ()Lru/mipt/npm/root/DGeoMedium;
|
||||
public final fun getFNodes ()Ljava/util/List;
|
||||
public final fun getFShape ()Lru/mipt/npm/root/DGeoShape;
|
||||
public fun getName ()Lspace/kscience/dataforge/names/Name;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/DNamed : ru/mipt/npm/root/DObject {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getFName ()Ljava/lang/String;
|
||||
public final fun getFTitle ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/DObject {
|
||||
public fun <init> (Lspace/kscience/dataforge/meta/Meta;Lru/mipt/npm/root/DObjectCache;)V
|
||||
public final fun getMeta ()Lspace/kscience/dataforge/meta/Meta;
|
||||
public final fun getRefCache ()Lru/mipt/npm/root/DObjectCache;
|
||||
public final fun getTypename ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DObjectCache {
|
||||
public static final field Companion Lru/mipt/npm/root/DObjectCache$Companion;
|
||||
public fun <init> (Ljava/util/List;Ljava/util/List;)V
|
||||
public synthetic fun <init> (Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun get (I)Lspace/kscience/dataforge/meta/Meta;
|
||||
public final fun getRefStack ()Ljava/util/List;
|
||||
public final fun stack (I)Lru/mipt/npm/root/DObjectCache;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DObjectCache$Companion {
|
||||
public final fun getEmpty ()Lru/mipt/npm/root/DObjectCache;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DObjectKt {
|
||||
public static final fun doubleArray (Lspace/kscience/dataforge/meta/MetaProvider;[DLspace/kscience/dataforge/names/Name;)Lkotlin/properties/ReadOnlyProperty;
|
||||
public static synthetic fun doubleArray$default (Lspace/kscience/dataforge/meta/MetaProvider;[DLspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/DRootToSolidKt {
|
||||
public static final fun toSolid (Lru/mipt/npm/root/DGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/RootColors {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/RootColors;
|
||||
public final fun get (I)Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/JsonToRootKt {
|
||||
public static final fun decodeFromJson (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/KSerializer;Lkotlinx/serialization/json/JsonElement;)Lru/mipt/npm/root/serialization/TObject;
|
||||
public static final fun decodeFromString (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/KSerializer;Ljava/lang/String;)Lru/mipt/npm/root/serialization/TObject;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/RootToSolidKt {
|
||||
public static final fun toSolid (Lru/mipt/npm/root/serialization/TGeoManager;)Lspace/kscience/visionforge/solid/SolidGroup;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoBBox : ru/mipt/npm/root/serialization/TGeoShape {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoBBox$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFDX ()D
|
||||
public final fun getFDY ()D
|
||||
public final fun getFDZ ()D
|
||||
public final fun getFOrigin ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoBBox;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoBBox$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoBBox$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoBBox;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoBBox;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoBBox$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract class ru/mipt/npm/root/serialization/TGeoBoolNode : ru/mipt/npm/root/serialization/TObject {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoBoolNode$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public abstract fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public final fun getFLeftMat ()Lru/mipt/npm/root/serialization/TGeoMatrix;
|
||||
public abstract fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public final fun getFRightMat ()Lru/mipt/npm/root/serialization/TGeoMatrix;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoBoolNode$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoCombiTrans : ru/mipt/npm/root/serialization/TGeoMatrix {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoCombiTrans$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLru/mipt/npm/root/serialization/TGeoRotation;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> ([DLru/mipt/npm/root/serialization/TGeoRotation;)V
|
||||
public synthetic fun <init> ([DLru/mipt/npm/root/serialization/TGeoRotation;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFRotation ()Lru/mipt/npm/root/serialization/TGeoRotation;
|
||||
public final fun getFTranslation ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoCombiTrans;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoCombiTrans$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoCombiTrans$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoCombiTrans;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoCombiTrans;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoCombiTrans$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoCompositeShape : ru/mipt/npm/root/serialization/TGeoBBox {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoCompositeShape$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLru/mipt/npm/root/serialization/TGeoBoolNode;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Lru/mipt/npm/root/serialization/TGeoBoolNode;)V
|
||||
public final fun getFNode ()Lru/mipt/npm/root/serialization/TGeoBoolNode;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoCompositeShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoCompositeShape$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoCompositeShape$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoCompositeShape;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoCompositeShape;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoCompositeShape$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoHMatrix : ru/mipt/npm/root/serialization/TGeoMatrix {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoHMatrix$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> ([D[D[D)V
|
||||
public final fun getFRotationMatrix ()[D
|
||||
public final fun getFScale ()[D
|
||||
public final fun getFTranslation ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoHMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoHMatrix$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoHMatrix$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoHMatrix;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoHMatrix;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoHMatrix$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoIdentity : ru/mipt/npm/root/serialization/TGeoMatrix {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoIdentity$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoIdentity;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoIdentity$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoIdentity$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoIdentity;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoIdentity;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoIdentity$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoIntersection : ru/mipt/npm/root/serialization/TGeoBoolNode {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoIntersection$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V
|
||||
public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoIntersection;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoIntersection$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoIntersection$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoIntersection;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoIntersection;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoIntersection$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoManager : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoManager$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TObjArray;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFMatrices ()Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public final fun getFNodes ()Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public final fun getFShapes ()Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public final fun getFVolumes ()Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoManager;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoManager$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoManager$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoManager;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoManager;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoManager$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoMaterial : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoMaterial$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMaterial;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMaterial$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMaterial$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMaterial;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoMaterial;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMaterial$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract class ru/mipt/npm/root/serialization/TGeoMatrix : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoMatrix$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMatrix$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMedium : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoMedium$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;ILru/mipt/npm/root/serialization/TGeoMaterial;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (ILru/mipt/npm/root/serialization/TGeoMaterial;[D)V
|
||||
public final fun getFId ()I
|
||||
public final fun getFMaterial ()Lru/mipt/npm/root/serialization/TGeoMaterial;
|
||||
public final fun getFParams ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMedium;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMedium$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMedium$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMedium;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoMedium;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMedium$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMixture : ru/mipt/npm/root/serialization/TGeoMaterial {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoMixture$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoMixture;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMixture$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoMixture$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoMixture;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoMixture;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoMixture$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoNode : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoNode$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[ILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFGeoAtt-pVg5ArA ()I
|
||||
public final fun getFNovlp ()I
|
||||
public final fun getFNumber ()I
|
||||
public final fun getFOverlaps ()[I
|
||||
public final fun getFVolume ()Lru/mipt/npm/root/serialization/TGeoVolume;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNode;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNode$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNode$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNode;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoNode;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNode$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix : ru/mipt/npm/root/serialization/TGeoNode {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoNodeMatrix$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[ILru/mipt/npm/root/serialization/TGeoMatrix;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFMatrix ()Lru/mipt/npm/root/serialization/TGeoMatrix;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNodeMatrix;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNodeMatrix$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNodeMatrix;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoNodeMatrix;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNodeMatrix$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNodeOffset : ru/mipt/npm/root/serialization/TGeoNode {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoNodeOffset$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoVolume;II[IDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFOffset ()D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoNodeOffset;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNodeOffset$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoNodeOffset$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoNodeOffset;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoNodeOffset;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoNodeOffset$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoPcon : ru/mipt/npm/root/serialization/TGeoBBox {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoPcon$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIDD[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFDphi ()D
|
||||
public final fun getFNz ()I
|
||||
public final fun getFPhi1 ()D
|
||||
public final fun getFRmax ()[D
|
||||
public final fun getFRmin ()[D
|
||||
public final fun getFZ ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoPcon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoPcon$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoPcon$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoPcon;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoPcon;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoPcon$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoPgon : ru/mipt/npm/root/serialization/TGeoPcon {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoPgon$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIDD[D[D[DILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFNedges ()I
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoPgon;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoPgon$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoPgon$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoPgon;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoPgon;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoPgon$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoRotation : ru/mipt/npm/root/serialization/TGeoMatrix {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoRotation$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> ([D)V
|
||||
public final fun getFRotationMatrix ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoRotation;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoRotation$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoRotation$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoRotation;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoRotation;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoRotation$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract class ru/mipt/npm/root/serialization/TGeoShape : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoShape$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFShapeBits-pVg5ArA ()I
|
||||
public final fun getFShapeId ()I
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoShape$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly : ru/mipt/npm/root/serialization/TGeoBBox {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoShapeAssembly$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DLru/mipt/npm/root/serialization/TGeoVolumeAssembly;ZLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Z)V
|
||||
public synthetic fun <init> (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFBBoxOK ()Z
|
||||
public final fun getFVolume ()Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoShapeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoShapeAssembly$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoShapeAssembly;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoShapeAssembly;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoShapeAssembly$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoShapeRef : ru/mipt/npm/root/serialization/TGeoShape {
|
||||
public fun <init> (Lkotlin/jvm/functions/Function0;)V
|
||||
public final fun getValue ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoSubtraction : ru/mipt/npm/root/serialization/TGeoBoolNode {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoSubtraction$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V
|
||||
public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoSubtraction;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoSubtraction$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoSubtraction$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoSubtraction;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoSubtraction;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoSubtraction$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTranslation : ru/mipt/npm/root/serialization/TGeoMatrix {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoTranslation$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> ([D)V
|
||||
public final fun getFTranslation ()[D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTranslation;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTranslation$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTranslation$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTranslation;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoTranslation;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTranslation$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoTube : ru/mipt/npm/root/serialization/TGeoBBox {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoTube$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DDDDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFDz ()D
|
||||
public final fun getFRmax ()D
|
||||
public final fun getFRmin ()D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTube;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTube$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTube$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTube;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoTube;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTube$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTubeSeg : ru/mipt/npm/root/serialization/TGeoTube {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoTubeSeg$Companion;
|
||||
public fun <init> (DDDDDDDDD)V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DDDDDDDDDDDDDLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFC1 ()D
|
||||
public final fun getFC2 ()D
|
||||
public final fun getFCdfi ()D
|
||||
public final fun getFCm ()D
|
||||
public final fun getFPhi1 ()D
|
||||
public final fun getFPhi2 ()D
|
||||
public final fun getFS1 ()D
|
||||
public final fun getFS2 ()D
|
||||
public final fun getFSm ()D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoTubeSeg;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTubeSeg$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoTubeSeg$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoTubeSeg;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoTubeSeg;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoTubeSeg$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoUnion : ru/mipt/npm/root/serialization/TGeoBoolNode {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoUnion$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoMatrix;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoShape;)V
|
||||
public fun getFLeft ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public fun getFRight ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoUnion;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoUnion$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoUnion$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoUnion;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoUnion;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoUnion$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoVolume : ru/mipt/npm/root/serialization/TNamed {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoVolume$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILjava/lang/Integer;Lkotlin/UInt;Ljava/lang/Integer;Ljava/lang/Integer;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoMedium;IIILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFFillColor ()Ljava/lang/Integer;
|
||||
public final fun getFFillStyle ()Ljava/lang/Integer;
|
||||
public final fun getFGeoAtt-pVg5ArA ()I
|
||||
public final fun getFLineColor ()I
|
||||
public final fun getFLineStyle ()Ljava/lang/Integer;
|
||||
public final fun getFLineWidth-pVg5ArA ()I
|
||||
public final fun getFMedium ()Lru/mipt/npm/root/serialization/TGeoMedium;
|
||||
public final fun getFNodes ()Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public final fun getFNtotal ()I
|
||||
public final fun getFNumber ()I
|
||||
public final fun getFRefCount ()I
|
||||
public final fun getFShape ()Lru/mipt/npm/root/serialization/TGeoShape;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolume;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoVolume$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoVolume$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoVolume;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoVolume;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoVolume$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TGeoVolumeAssembly : ru/mipt/npm/root/serialization/TGeoVolume {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoVolumeAssembly$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;ILjava/lang/Integer;Lkotlin/UInt;Ljava/lang/Integer;Ljava/lang/Integer;Lru/mipt/npm/root/serialization/TObjArray;Lru/mipt/npm/root/serialization/TGeoShape;Lru/mipt/npm/root/serialization/TGeoMedium;IIILkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoVolumeAssembly$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoVolumeAssembly$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoVolumeAssembly$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoVolumeAssemblyRef : ru/mipt/npm/root/serialization/TGeoVolumeAssembly {
|
||||
public fun <init> (Lkotlin/jvm/functions/Function0;)V
|
||||
public final fun getValue ()Lru/mipt/npm/root/serialization/TGeoVolumeAssembly;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoVolumeRef : ru/mipt/npm/root/serialization/TGeoVolume {
|
||||
public fun <init> (Lkotlin/jvm/functions/Function0;)V
|
||||
public final fun getValue ()Lru/mipt/npm/root/serialization/TGeoVolume;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoXtru : ru/mipt/npm/root/serialization/TGeoBBox {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TGeoXtru$Companion;
|
||||
public fun <init> (IID[D[D[D[D[D[D)V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlin/UInt;IDDD[DIID[D[D[D[D[D[DLkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFNvert ()I
|
||||
public final fun getFNz ()I
|
||||
public final fun getFScale ()[D
|
||||
public final fun getFX ()[D
|
||||
public final fun getFX0 ()[D
|
||||
public final fun getFY ()[D
|
||||
public final fun getFY0 ()[D
|
||||
public final fun getFZ ()[D
|
||||
public final fun getFZcurrent ()D
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TGeoXtru;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoXtru$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TGeoXtru$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TGeoXtru;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TGeoXtru;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TGeoXtru$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/THashList : ru/mipt/npm/root/serialization/TObject {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/THashList$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Ljava/util/List;)V
|
||||
public final fun getArr ()Ljava/util/List;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/THashList;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/THashList$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/THashList$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/THashList;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/THashList;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/THashList$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TList : ru/mipt/npm/root/serialization/TObject {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TList$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Ljava/util/List;)V
|
||||
public final fun getArr ()Ljava/util/List;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TList;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TList$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TList$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TList;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TList;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TList$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public class ru/mipt/npm/root/serialization/TNamed : ru/mipt/npm/root/serialization/TObject {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TNamed$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/lang/String;Ljava/lang/String;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFName ()Ljava/lang/String;
|
||||
public final fun getFTitle ()Ljava/lang/String;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TNamed;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TNamed$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/root/serialization/TNamed$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TNamed;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TNamed;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TNamed$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TObjArray : ru/mipt/npm/root/serialization/TObject {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TObjArray$Companion;
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Ljava/util/List;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun <init> (Ljava/util/List;)V
|
||||
public final fun getArr ()Ljava/util/List;
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TObjArray;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;Lkotlinx/serialization/KSerializer;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TObjArray$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun <init> (Lkotlinx/serialization/KSerializer;)V
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/root/serialization/TObjArray;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TObjArray$Companion {
|
||||
public final fun getEmpty ()Lru/mipt/npm/root/serialization/TObjArray;
|
||||
public final fun serializer (Lkotlinx/serialization/KSerializer;)Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract class ru/mipt/npm/root/serialization/TObject {
|
||||
public static final field Companion Lru/mipt/npm/root/serialization/TObject$Companion;
|
||||
public fun <init> ()V
|
||||
public synthetic fun <init> (ILkotlin/UInt;Lkotlin/UInt;Lkotlinx/serialization/internal/SerializationConstructorMarker;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getFBits-pVg5ArA ()I
|
||||
public final fun getFUniqueID-pVg5ArA ()I
|
||||
public static final fun write$Self (Lru/mipt/npm/root/serialization/TObject;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/root/serialization/TObject$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
19
cern-root-loader/build.gradle.kts
Normal file
19
cern-root-loader/build.gradle.kts
Normal file
@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
id("ru.mipt.npm.gradle.mpp")
|
||||
}
|
||||
|
||||
kscience{
|
||||
useSerialization {
|
||||
json()
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(project(":visionforge-solid"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package ru.mipt.npm.root
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import space.kscience.dataforge.meta.*
|
||||
import space.kscience.dataforge.misc.Named
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.names.asName
|
||||
import space.kscience.dataforge.values.doubleArray
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
public fun MetaProvider.doubleArray(
|
||||
vararg default: Double,
|
||||
key: Name? = null,
|
||||
): ReadOnlyProperty<Any?, DoubleArray> = value(key) {
|
||||
it?.doubleArray ?: doubleArrayOf(*default)
|
||||
}
|
||||
|
||||
public class DObjectCache(private val cache: List<Meta>, public val refStack: List<Int> = emptyList()) {
|
||||
public operator fun get(index: Int): Meta = cache[index]
|
||||
|
||||
public fun stack(ref: Int): DObjectCache = DObjectCache(cache, refStack + ref)
|
||||
|
||||
public companion object {
|
||||
public val empty: DObjectCache = DObjectCache(emptyList(), emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
public open class DObject(public val meta: Meta, public val refCache: DObjectCache) {
|
||||
|
||||
public val typename: String by meta.string(key = "_typename".asName()) {
|
||||
error("Type is not defined")
|
||||
}
|
||||
|
||||
private fun <T : DObject> resolve(builder: (Meta, DObjectCache) -> T, meta: Meta): T? {
|
||||
meta["\$ref"]?.int?.let { refId ->
|
||||
if (refCache.refStack.contains(refId)) {
|
||||
println("Circular reference $refId in stack ${refCache.refStack}")
|
||||
return null
|
||||
}
|
||||
return builder(refCache[refId], refCache.stack(refId))
|
||||
}
|
||||
return builder(meta, refCache)
|
||||
}
|
||||
|
||||
internal fun <T : DObject> tObjectArray(
|
||||
builder: (Meta, DObjectCache) -> T
|
||||
): ReadOnlyProperty<Any?, List<T>> = ReadOnlyProperty { _, property ->
|
||||
meta.getIndexed(Name.of(property.name, "arr")).values.mapNotNull {
|
||||
resolve(builder, it)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T : DObject> dObject(
|
||||
builder: (Meta, DObjectCache) -> T,
|
||||
key: Name? = null
|
||||
): ReadOnlyProperty<Any?, T?> = ReadOnlyProperty { _, property ->
|
||||
meta[key ?: property.name.asName()]?.let { resolve(builder, it) }
|
||||
}
|
||||
}
|
||||
|
||||
public open class DNamed(meta: Meta, refCache: DObjectCache) : DObject(meta, refCache) {
|
||||
public val fName: String by meta.string("")
|
||||
public val fTitle: String by meta.string("")
|
||||
}
|
||||
|
||||
public class DGeoMaterial(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) {
|
||||
}
|
||||
|
||||
public class DGeoMedium(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) {
|
||||
public val fMaterial: DGeoMaterial? by dObject(::DGeoMaterial)
|
||||
public val fParams: DoubleArray by meta.doubleArray()
|
||||
}
|
||||
|
||||
public class DGeoShape(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) {
|
||||
public val fDX: Double by meta.double(0.0)
|
||||
public val fDY: Double by meta.double(0.0)
|
||||
public val fDZ: Double by meta.double(0.0)
|
||||
}
|
||||
|
||||
public class DGeoVolume(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache), Named {
|
||||
public val fNodes: List<DGeoNode> by tObjectArray(::DGeoNode)
|
||||
public val fShape: DGeoShape? by dObject(::DGeoShape)
|
||||
public val fMedium: DGeoMedium? by dObject(::DGeoMedium)
|
||||
|
||||
public val fFillColor: Int? by meta.int()
|
||||
|
||||
override val name: Name by lazy { Name.parse(fName.ifEmpty { "volume[${meta.hashCode().toUInt()}]" }) }
|
||||
}
|
||||
|
||||
public class DGeoNode(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) {
|
||||
public val fVolume: DGeoVolume? by dObject(::DGeoVolume)
|
||||
}
|
||||
|
||||
public open class DGeoMatrix(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache)
|
||||
|
||||
public open class DGeoScale(meta: Meta, refCache: DObjectCache) : DGeoMatrix(meta, refCache) {
|
||||
public val fScale: DoubleArray by meta.doubleArray(1.0, 1.0, 1.0)
|
||||
public val x: Double get() = fScale[0]
|
||||
public val y: Double get() = fScale[1]
|
||||
public val z: Double get() = fScale[2]
|
||||
}
|
||||
|
||||
|
||||
public class DGeoBoolNode(meta: Meta, refCache: DObjectCache) : DObject(meta, refCache) {
|
||||
public val fLeft: DGeoShape? by dObject(::DGeoShape)
|
||||
public val fLeftMat: DGeoMatrix? by dObject(::DGeoMatrix)
|
||||
|
||||
public val fRight: DGeoShape? by dObject(::DGeoShape)
|
||||
public val fRightMat: DGeoMatrix? by dObject(::DGeoMatrix)
|
||||
}
|
||||
|
||||
|
||||
public class DGeoManager(meta: Meta, refCache: DObjectCache) : DNamed(meta, refCache) {
|
||||
public val fMatrices: List<DGeoMatrix> by tObjectArray(::DGeoMatrix)
|
||||
|
||||
public val fShapes: List<DGeoShape> by tObjectArray(::DGeoShape)
|
||||
|
||||
public val fVolumes: List<DGeoVolume> by tObjectArray(::DGeoVolume)
|
||||
|
||||
public val fNodes: List<DGeoNode> by tObjectArray(::DGeoNode)
|
||||
|
||||
public companion object {
|
||||
|
||||
public fun parse(string: String): DGeoManager {
|
||||
val meta = Json.decodeFromString(MetaSerializer, string)
|
||||
val res = ArrayList<Meta>(4096)
|
||||
|
||||
fun fillCache(element: Meta) {
|
||||
if (element["\$ref"] == null) {
|
||||
res.add(element)
|
||||
element.items.values.forEach {
|
||||
if (!it.isLeaf) {
|
||||
fillCache(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fillCache(meta)
|
||||
|
||||
val refCache = DObjectCache(res)
|
||||
return DGeoManager(meta, refCache)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,362 @@
|
||||
package ru.mipt.npm.root
|
||||
|
||||
import space.kscience.dataforge.meta.*
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.names.plus
|
||||
import space.kscience.dataforge.values.doubleArray
|
||||
import space.kscience.visionforge.isEmpty
|
||||
import space.kscience.visionforge.solid.*
|
||||
import space.kscience.visionforge.solid.SolidMaterial.Companion.MATERIAL_COLOR_KEY
|
||||
import kotlin.math.*
|
||||
|
||||
private val volumesName = Name.EMPTY //"volumes".asName()
|
||||
|
||||
private operator fun Number.times(d: Double) = toDouble() * d
|
||||
|
||||
private operator fun Number.times(f: Float) = toFloat() * f
|
||||
|
||||
private fun degToRad(d: Double) = d * PI / 180.0
|
||||
|
||||
private data class RootToSolidContext(
|
||||
val prototypeHolder: PrototypeHolder,
|
||||
val currentLayer: Int = 0,
|
||||
val maxLayer: Int = 5
|
||||
)
|
||||
|
||||
// converting to XYZ to Tait–Bryan angles according to https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
private fun Solid.rotate(rot: DoubleArray) {
|
||||
val xAngle = atan2(-rot[5], rot[8])
|
||||
val yAngle = atan2(rot[2], sqrt(1.0 - rot[2].pow(2)))
|
||||
val zAngle = atan2(-rot[1], rot[0])
|
||||
rotation = Point3D(xAngle, yAngle, zAngle)
|
||||
}
|
||||
|
||||
private fun Solid.translate(trans: DoubleArray) {
|
||||
val (x, y, z) = trans
|
||||
position = Point3D(x, y, z)
|
||||
}
|
||||
|
||||
private fun Solid.useMatrix(matrix: DGeoMatrix?) {
|
||||
if (matrix == null) return
|
||||
when (matrix.typename) {
|
||||
"TGeoIdentity" -> {
|
||||
//do nothing
|
||||
}
|
||||
"TGeoTranslation" -> {
|
||||
val fTranslation by matrix.meta.doubleArray()
|
||||
translate(fTranslation)
|
||||
}
|
||||
"TGeoRotation" -> {
|
||||
val fRotationMatrix by matrix.meta.doubleArray()
|
||||
rotate(fRotationMatrix)
|
||||
}
|
||||
"TGeoCombiTrans" -> {
|
||||
val fTranslation by matrix.meta.doubleArray()
|
||||
|
||||
translate(fTranslation)
|
||||
matrix.meta["fRotation.fRotationMatrix"]?.value?.let {
|
||||
rotate(it.doubleArray)
|
||||
}
|
||||
}
|
||||
"TGeoHMatrix" -> {
|
||||
val fTranslation by matrix.meta.doubleArray()
|
||||
val fRotationMatrix by matrix.meta.doubleArray()
|
||||
val fScale by matrix.meta.doubleArray()
|
||||
translate(fTranslation)
|
||||
rotate(fRotationMatrix)
|
||||
scale = Point3D(fScale[0], fScale[1], fScale[2])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun SolidGroup.addShape(
|
||||
shape: DGeoShape,
|
||||
context: RootToSolidContext,
|
||||
name: String? = shape.fName.ifEmpty { null },
|
||||
block: Solid.() -> Unit = {}
|
||||
) {
|
||||
when (shape.typename) {
|
||||
"TGeoCompositeShape" -> {
|
||||
val fNode: DGeoBoolNode? by shape.dObject(::DGeoBoolNode)
|
||||
val node = fNode ?: error("Composite shape node not resolved")
|
||||
val compositeType = when (node.typename) {
|
||||
"TGeoIntersection" -> CompositeType.INTERSECT
|
||||
"TGeoSubtraction" -> CompositeType.SUBTRACT
|
||||
"TGeoUnion" -> CompositeType.GROUP
|
||||
else -> error("Unknown bool node type ${node.typename}")
|
||||
}
|
||||
smartComposite(compositeType, name = name) {
|
||||
addShape(node.fLeft!!, context, null) {
|
||||
this.useMatrix(node.fLeftMat)
|
||||
}
|
||||
addShape(node.fRight!!, context, null) {
|
||||
this.useMatrix(node.fRightMat)
|
||||
}
|
||||
}.apply(block)
|
||||
}
|
||||
"TGeoXtru" -> {
|
||||
val fNvert by shape.meta.int(0)
|
||||
val fX by shape.meta.doubleArray()
|
||||
val fY by shape.meta.doubleArray()
|
||||
val fNz by shape.meta.int(0)
|
||||
val fZ by shape.meta.doubleArray()
|
||||
val fX0 by shape.meta.doubleArray()
|
||||
val fY0 by shape.meta.doubleArray()
|
||||
val fScale by shape.meta.doubleArray()
|
||||
|
||||
extruded(name = name) {
|
||||
(0 until fNvert).forEach { index ->
|
||||
shape {
|
||||
point(fX[index], fY[index])
|
||||
}
|
||||
}
|
||||
|
||||
(0 until fNz).forEach { index ->
|
||||
layer(
|
||||
fZ[index],
|
||||
fX0[index],
|
||||
fY0[index],
|
||||
fScale[index]
|
||||
)
|
||||
}
|
||||
}.apply(block)
|
||||
}
|
||||
"TGeoTube" -> {
|
||||
val fRmax by shape.meta.double(0.0)
|
||||
val fDz by shape.meta.double(0.0)
|
||||
val fRmin by shape.meta.double(0.0)
|
||||
|
||||
tube(
|
||||
radius = fRmax,
|
||||
height = fDz * 2,
|
||||
innerRadius = fRmin,
|
||||
name = name,
|
||||
block = block
|
||||
)
|
||||
}
|
||||
"TGeoTubeSeg" -> {
|
||||
val fRmax by shape.meta.double(0.0)
|
||||
val fDz by shape.meta.double(0.0)
|
||||
val fRmin by shape.meta.double(0.0)
|
||||
val fPhi1 by shape.meta.double(0.0)
|
||||
val fPhi2 by shape.meta.double(0.0)
|
||||
|
||||
tube(
|
||||
radius = fRmax,
|
||||
height = fDz * 2,
|
||||
innerRadius = fRmin,
|
||||
startAngle = degToRad(fPhi1),
|
||||
angle = degToRad(fPhi2 - fPhi1),
|
||||
name = name,
|
||||
block = block
|
||||
)
|
||||
}
|
||||
"TGeoPcon" -> {
|
||||
val fDphi by shape.meta.double(0.0)
|
||||
val fNz by shape.meta.int(2)
|
||||
val fPhi1 by shape.meta.double(360.0)
|
||||
val fRmax by shape.meta.doubleArray()
|
||||
val fRmin by shape.meta.doubleArray()
|
||||
val fZ by shape.meta.doubleArray()
|
||||
if (fNz == 2) {
|
||||
coneSurface(
|
||||
bottomOuterRadius = fRmax[0],
|
||||
bottomInnerRadius = fRmin[0],
|
||||
height = fZ[1] - fZ[0],
|
||||
topOuterRadius = fRmax[1],
|
||||
topInnerRadius = fRmin[1],
|
||||
startAngle = degToRad(fPhi1),
|
||||
angle = degToRad(fDphi),
|
||||
name = name,
|
||||
) {
|
||||
z = (fZ[1] + fZ[0]) / 2
|
||||
|
||||
}.apply(block)
|
||||
} else {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
"TGeoPgon" -> {
|
||||
//TODO add a inner polygone layer
|
||||
val fDphi by shape.meta.double(0.0)
|
||||
val fNz by shape.meta.int(2)
|
||||
val fPhi1 by shape.meta.double(360.0)
|
||||
val fRmax by shape.meta.doubleArray()
|
||||
val fRmin by shape.meta.doubleArray()
|
||||
val fZ by shape.meta.doubleArray()
|
||||
|
||||
val fNedges by shape.meta.int(1)
|
||||
|
||||
val startphi = degToRad(fPhi1)
|
||||
val deltaphi = degToRad(fDphi)
|
||||
|
||||
extruded(name) {
|
||||
//getting the radius of first
|
||||
require(fNz > 1) { "The polyhedron geometry requires at least two planes" }
|
||||
val baseRadius = fRmax[0]
|
||||
shape {
|
||||
(0..fNedges).forEach {
|
||||
val phi = deltaphi * fNedges * it + startphi
|
||||
(baseRadius * cos(phi) to baseRadius * sin(phi))
|
||||
}
|
||||
}
|
||||
(0 until fNz).forEach { index ->
|
||||
//scaling all radii relative to first layer radius
|
||||
layer(fZ[index], scale = fRmax[index] / baseRadius)
|
||||
}
|
||||
}.apply(block)
|
||||
}
|
||||
"TGeoShapeAssembly" -> {
|
||||
val fVolume by shape.dObject(::DGeoVolume)
|
||||
fVolume?.let { volume ->
|
||||
addRootVolume(volume, context, block = block)
|
||||
}
|
||||
}
|
||||
"TGeoBBox" -> {
|
||||
box(shape.fDX * 2, shape.fDY * 2, shape.fDZ * 2, name = name, block = block)
|
||||
}
|
||||
"TGeoTrap" -> {
|
||||
val fTheta by shape.meta.double(0.0)
|
||||
val fPhi by shape.meta.double(0.0)
|
||||
val fAlpha1 by shape.meta.double(0.0)
|
||||
val fAlpha2 by shape.meta.double(0.0)
|
||||
if (fAlpha1 != 0.0 || fAlpha2 != 0.0 || fTheta != 0.0 || fPhi != 0.0) {
|
||||
TODO("Angled trapezoid not implemented")
|
||||
}
|
||||
val fH1 by shape.meta.double(0.0)
|
||||
val fBl1 by shape.meta.double(0.0)
|
||||
val fTl1 by shape.meta.double(0.0)
|
||||
val fH2 by shape.meta.double(0.0)
|
||||
val fBl2 by shape.meta.double(0.0)
|
||||
val fTl2 by shape.meta.double(0.0)
|
||||
|
||||
val fDz by shape.meta.double(0.0)
|
||||
//TODO check proper node order
|
||||
val node1 = Point3D(-fBl1, -fH1, -fDz)
|
||||
val node2 = Point3D(fBl1, -fH1, -fDz)
|
||||
val node3 = Point3D(fTl1, fH1, -fDz)
|
||||
val node4 = Point3D(-fTl1, fH1, -fDz)
|
||||
val node5 = Point3D(-fBl2, -fH2, fDz)
|
||||
val node6 = Point3D(fBl2, -fH2, fDz)
|
||||
val node7 = Point3D(fTl2, fH2, fDz)
|
||||
val node8 = Point3D(-fTl2, fH2, fDz)
|
||||
hexagon(node1, node2, node3, node4, node5, node6, node7, node8, name)
|
||||
}
|
||||
"TGeoScaledShape" -> {
|
||||
val fShape by shape.dObject(::DGeoShape)
|
||||
val fScale by shape.dObject(::DGeoScale)
|
||||
fShape?.let { scaledShape ->
|
||||
group(name?.let { Name.parse(it) }) {
|
||||
scale = Point3D(fScale?.x ?: 1.0, fScale?.y ?: 1.0, fScale?.z ?: 1.0)
|
||||
addShape(scaledShape, context)
|
||||
apply(block)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
TODO("A shape with type ${shape.typename} not implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun SolidGroup.addRootNode(obj: DGeoNode, context: RootToSolidContext) {
|
||||
val volume = obj.fVolume ?: return
|
||||
addRootVolume(volume, context, obj.fName) {
|
||||
when (obj.typename) {
|
||||
"TGeoNodeMatrix" -> {
|
||||
val fMatrix by obj.dObject(::DGeoMatrix)
|
||||
this.useMatrix(fMatrix)
|
||||
}
|
||||
"TGeoNodeOffset" -> {
|
||||
val fOffset by obj.meta.double(0.0)
|
||||
x = fOffset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildVolume(volume: DGeoVolume, context: RootToSolidContext): Solid? {
|
||||
val group = SolidGroup {
|
||||
//set current layer
|
||||
layer = context.currentLayer
|
||||
val nodes = volume.fNodes
|
||||
|
||||
if (nodes.isEmpty() || context.currentLayer >= context.maxLayer) {
|
||||
//TODO add smart filter
|
||||
volume.fShape?.let { shape ->
|
||||
addShape(shape, context)
|
||||
}
|
||||
} else {
|
||||
val newLayer = if (nodes.size <= 2) {
|
||||
context.currentLayer
|
||||
} else if (nodes.size > 10) {
|
||||
context.currentLayer + 2
|
||||
} else {
|
||||
context.currentLayer + 1
|
||||
}
|
||||
val newContext = context.copy(currentLayer = newLayer)
|
||||
nodes.forEach { node ->
|
||||
//add children to the next layer
|
||||
addRootNode(node, newContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
return if (group.isEmpty()) {
|
||||
null
|
||||
} else 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
|
||||
|
||||
private fun SolidGroup.addRootVolume(
|
||||
volume: DGeoVolume,
|
||||
context: RootToSolidContext,
|
||||
name: String? = null,
|
||||
cache: Boolean = true,
|
||||
block: Solid.() -> Unit = {}
|
||||
) {
|
||||
val combinedName = if (volume.fName.isEmpty()) {
|
||||
name
|
||||
} else if (name == null) {
|
||||
volume.fName
|
||||
} else {
|
||||
"${name}_${volume.fName}"
|
||||
}
|
||||
|
||||
if (!cache) {
|
||||
val group = buildVolume(volume, context)?.apply {
|
||||
volume.fFillColor?.let {
|
||||
meta[MATERIAL_COLOR_KEY] = RootColors[it]
|
||||
}
|
||||
block()
|
||||
}
|
||||
set(combinedName?.let { Name.parse(it) }, group)
|
||||
} else {
|
||||
val templateName = volumesName + volume.name
|
||||
val existing = getPrototype(templateName)
|
||||
if (existing == null) {
|
||||
context.prototypeHolder.prototypes {
|
||||
val group = buildVolume(volume, context)
|
||||
set(templateName, group)
|
||||
}
|
||||
}
|
||||
|
||||
ref(templateName, name).apply {
|
||||
volume.fFillColor?.let {
|
||||
meta[MATERIAL_COLOR_KEY] = RootColors[it]
|
||||
}
|
||||
block()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public fun DGeoManager.toSolid(): SolidGroup = SolidGroup {
|
||||
val context = RootToSolidContext(this)
|
||||
fNodes.forEach { node ->
|
||||
addRootNode(node, context)
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ru.mipt.npm.root
|
||||
|
||||
public object RootColors {
|
||||
private val colorMap = Array<String>(924) { "white" }
|
||||
|
||||
//colorMap[110] = "white"
|
||||
|
||||
private val moreCol = listOf(
|
||||
11 to "c1b7ad4d4d4d6666668080809a9a9ab3b3b3cdcdcde6e6e6f3f3f3cdc8accdc8acc3c0a9bbb6a4b3a697b8a49cae9a8d9c8f83886657b1cfc885c3a48aa9a1839f8daebdc87b8f9a768a926983976e7b857d9ad280809caca6c0d4cf88dfbb88bd9f83c89a7dc08378cf5f61ac8f94a6787b946971d45a549300ff7b00ff6300ff4b00ff3300ff1b00ff0300ff0014ff002cff0044ff005cff0074ff008cff00a4ff00bcff00d4ff00ecff00fffd00ffe500ffcd00ffb500ff9d00ff8500ff6d00ff5500ff3d00ff2600ff0e0aff0022ff003aff0052ff006aff0082ff009aff00b1ff00c9ff00e1ff00f9ff00ffef00ffd700ffbf00ffa700ff8f00ff7700ff6000ff4800ff3000ff1800ff0000",
|
||||
201 to "5c5c5c7b7b7bb8b8b8d7d7d78a0f0fb81414ec4848f176760f8a0f14b81448ec4876f1760f0f8a1414b84848ec7676f18a8a0fb8b814ecec48f1f1768a0f8ab814b8ec48ecf176f10f8a8a14b8b848ecec76f1f1",
|
||||
390 to "ffffcdffff9acdcd9affff66cdcd669a9a66ffff33cdcd339a9a33666633ffff00cdcd009a9a00666600333300",
|
||||
406 to "cdffcd9aff9a9acd9a66ff6666cd66669a6633ff3333cd33339a3333663300ff0000cd00009a00006600003300",
|
||||
422 to "cdffff9affff9acdcd66ffff66cdcd669a9a33ffff33cdcd339a9a33666600ffff00cdcd009a9a006666003333",
|
||||
590 to "cdcdff9a9aff9a9acd6666ff6666cd66669a3333ff3333cd33339a3333660000ff0000cd00009a000066000033",
|
||||
606 to "ffcdffff9affcd9acdff66ffcd66cd9a669aff33ffcd33cd9a339a663366ff00ffcd00cd9a009a660066330033",
|
||||
622 to "ffcdcdff9a9acd9a9aff6666cd66669a6666ff3333cd33339a3333663333ff0000cd00009a0000660000330000",
|
||||
791 to "ffcd9acd9a669a66339a6600cd9a33ffcd66ff9a00ffcd33cd9a00ffcd00ff9a33cd66006633009a3300cd6633ff9a66ff6600ff6633cd3300ff33009aff3366cd00336600339a0066cd339aff6666ff0066ff3333cd0033ff00cdff9a9acd66669a33669a009acd33cdff669aff00cdff339acd00cdff009affcd66cd9a339a66009a6633cd9a66ffcd00ff6633ffcd00cd9a00ffcd33ff9a00cd66006633009a3333cd6666ff9a00ff9a33ff6600cd3300ff339acdff669acd33669a00339a3366cd669aff0066ff3366ff0033cd0033ff339aff0066cd00336600669a339acd66cdff009aff33cdff009acd00cdffcd9aff9a66cd66339a66009a9a33cdcd66ff9a00ffcd33ff9a00cdcd00ff9a33ff6600cd33006633009a6633cd9a66ff6600ff6633ff3300cd3300ffff339acd00666600339a0033cd3366ff669aff0066ff3366cd0033ff0033ff9acdcd669a9a33669a0066cd339aff66cdff009acd009aff33cdff009a",
|
||||
920 to "cdcdcd9a9a9a666666333333"
|
||||
)
|
||||
|
||||
init {
|
||||
colorMap[0] = "white"
|
||||
colorMap[1] = "black"
|
||||
colorMap[2] = "red"
|
||||
colorMap[3] = "green"
|
||||
colorMap[4] = "blue"
|
||||
colorMap[5] = "yellow"
|
||||
colorMap[6] = "magenta"
|
||||
colorMap[7] = "cyan"
|
||||
colorMap[8] = "rgb(89,212,84)"
|
||||
colorMap[9] = "rgb(89,84,217)"
|
||||
colorMap[10] = "white"
|
||||
|
||||
moreCol.forEach { (n, s) ->
|
||||
for (i in 0 until (s.length / 6)) {
|
||||
colorMap[n + i] = "#" + s.substring(i * 6, (i + 1) * 6)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public operator fun get(index: Int): String = colorMap[index]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoManager")
|
||||
public class TGeoManager : TNamed() {
|
||||
|
||||
public val fMatrices: TObjArray<TGeoMatrix> = TObjArray.getEmpty()
|
||||
|
||||
public val fShapes: TObjArray<TGeoShape> = TObjArray.getEmpty()
|
||||
|
||||
public val fVolumes: TObjArray<TGeoVolume> = TObjArray.getEmpty()
|
||||
|
||||
public val fNodes: TObjArray<TGeoNode> = TObjArray.getEmpty()
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoMaterial")
|
||||
public open class TGeoMaterial: TNamed()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoMixture")
|
||||
public class TGeoMixture: TGeoMaterial()
|
@ -0,0 +1,42 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoMatrix")
|
||||
public sealed class TGeoMatrix : TNamed()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoIdentity")
|
||||
public class TGeoIdentity : TGeoMatrix()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoHMatrix")
|
||||
public class TGeoHMatrix(
|
||||
public val fTranslation: DoubleArray,
|
||||
public val fRotationMatrix: DoubleArray,
|
||||
public val fScale: DoubleArray
|
||||
) : TGeoMatrix()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoTranslation")
|
||||
public class TGeoTranslation(
|
||||
public val fTranslation: DoubleArray
|
||||
) : TGeoMatrix()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoRotation")
|
||||
public class TGeoRotation(
|
||||
public val fRotationMatrix: DoubleArray
|
||||
) : TGeoMatrix()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoCombiTrans")
|
||||
public class TGeoCombiTrans(
|
||||
public val fTranslation: DoubleArray,
|
||||
@Contextual
|
||||
public val fRotation: TGeoRotation? = null,
|
||||
) : TGeoMatrix()
|
@ -0,0 +1,14 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoMedium")
|
||||
public class TGeoMedium(
|
||||
public val fId: Int,
|
||||
@Contextual
|
||||
public val fMaterial: TGeoMaterial,
|
||||
public val fParams: DoubleArray
|
||||
) : TNamed()
|
@ -0,0 +1,34 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoNode")
|
||||
public open class TGeoNode : TNamed() {
|
||||
public val fGeoAtt: UInt = 0u
|
||||
|
||||
@Contextual
|
||||
public val fVolume: TGeoVolume? = null
|
||||
|
||||
// @Contextual
|
||||
// public val fMother: TGeoVolume? = null
|
||||
|
||||
public val fNumber: Int = 0
|
||||
public val fNovlp: Int = 0
|
||||
public val fOverlaps: IntArray = intArrayOf()
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoNodeMatrix")
|
||||
public class TGeoNodeMatrix : TGeoNode() {
|
||||
@Contextual
|
||||
public val fMatrix: TGeoMatrix? = null
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoNodeOffset")
|
||||
public class TGeoNodeOffset : TGeoNode() {
|
||||
public val fOffset: Double = 0.0
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.math.PI
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoShape")
|
||||
public sealed class TGeoShape : TNamed() {
|
||||
public val fShapeBits: UInt = 0u
|
||||
public val fShapeId: Int = 0
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoBBox")
|
||||
public open class TGeoBBox : TGeoShape() {
|
||||
public val fDX: Double = 0.0
|
||||
public val fDY: Double = 0.0
|
||||
public val fDZ: Double = 0.0
|
||||
public val fOrigin: DoubleArray = doubleArrayOf(0.0, 0.0, 0.0)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoBoolNode")
|
||||
public sealed class TGeoBoolNode : TObject() {
|
||||
@Contextual
|
||||
public abstract val fLeft: TGeoShape
|
||||
|
||||
@Contextual
|
||||
public val fLeftMat: TGeoMatrix? = null
|
||||
|
||||
@Contextual
|
||||
public abstract val fRight: TGeoShape
|
||||
|
||||
@Contextual
|
||||
public val fRightMat: TGeoMatrix? = null
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoUnion")
|
||||
public class TGeoUnion(
|
||||
@Contextual
|
||||
override val fLeft: TGeoShape,
|
||||
@Contextual
|
||||
override val fRight: TGeoShape,
|
||||
) : TGeoBoolNode()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoSubtraction")
|
||||
public class TGeoSubtraction(
|
||||
@Contextual
|
||||
override val fLeft: TGeoShape,
|
||||
@Contextual
|
||||
override val fRight: TGeoShape,
|
||||
) : TGeoBoolNode()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoIntersection")
|
||||
public class TGeoIntersection(
|
||||
@Contextual
|
||||
override val fLeft: TGeoShape,
|
||||
@Contextual
|
||||
override val fRight: TGeoShape,
|
||||
) : TGeoBoolNode()
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoCompositeShape")
|
||||
public class TGeoCompositeShape(public val fNode: TGeoBoolNode) : TGeoBBox()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoXtru")
|
||||
public class TGeoXtru(
|
||||
public val fNvert: Int,
|
||||
public val fNz: Int,
|
||||
public val fZcurrent: Double,
|
||||
public val fX: DoubleArray,
|
||||
public val fY: DoubleArray,
|
||||
public val fZ: DoubleArray,
|
||||
public val fScale: DoubleArray,
|
||||
public val fX0: DoubleArray,
|
||||
public val fY0: DoubleArray
|
||||
) : TGeoBBox()
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoTube")
|
||||
public open class TGeoTube : TGeoBBox() {
|
||||
public val fRmin: Double = 0.0
|
||||
public val fRmax: Double = 0.0
|
||||
public val fDz: Double = 0.0
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoTubeSeg")
|
||||
public class TGeoTubeSeg(
|
||||
public val fPhi1: Double,
|
||||
public val fPhi2: Double,
|
||||
public val fS1: Double,
|
||||
public val fC1: Double,
|
||||
public val fS2: Double,
|
||||
public val fC2: Double,
|
||||
public val fSm: Double,
|
||||
public val fCm: Double,
|
||||
public val fCdfi: Double,
|
||||
) : TGeoTube()
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoPcon")
|
||||
public open class TGeoPcon : TGeoBBox() {
|
||||
public val fNz: Int = 0 // number of z planes (at least two)
|
||||
public val fPhi1: Double = 0.0 // lower phi limit (converted to [0,2*pi)
|
||||
public val fDphi: Double = PI * 2 // phi range
|
||||
public val fRmin: DoubleArray = doubleArrayOf() //[fNz] pointer to array of inner radii
|
||||
public val fRmax: DoubleArray = doubleArrayOf() //[fNz] pointer to array of outer radii
|
||||
public val fZ: DoubleArray = doubleArrayOf() //[fNz] pointer to array of Z planes positions
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoPgon")
|
||||
public open class TGeoPgon : TGeoPcon() {
|
||||
public val fNedges: Int = 0
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoShapeAssembly")
|
||||
public class TGeoShapeAssembly(
|
||||
@Contextual
|
||||
public val fVolume: TGeoVolumeAssembly,
|
||||
public val fBBoxOK: Boolean = true
|
||||
) : TGeoBBox()
|
||||
|
||||
public class TGeoShapeRef(provider: () -> TGeoShape) : TGeoShape() {
|
||||
public val value: TGeoShape by lazy(provider)
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoVolume")
|
||||
public open class TGeoVolume : TNamed() {
|
||||
public val fGeoAtt: UInt = 0u
|
||||
public val fLineColor: Int = 2
|
||||
public val fLineStyle: Int? = null
|
||||
public val fLineWidth: UInt = 1u
|
||||
public val fFillColor: Int? = null
|
||||
public val fFillStyle: Int? = null
|
||||
|
||||
@Contextual
|
||||
public val fNodes: TObjArray<@Contextual TGeoNode>? = null
|
||||
|
||||
@Contextual
|
||||
public val fShape: TGeoShape? = null
|
||||
|
||||
@Contextual
|
||||
public val fMedium: TGeoMedium? = null
|
||||
|
||||
public val fNumber: Int = 1
|
||||
public val fNtotal: Int = 1
|
||||
public val fRefCount: Int = 1
|
||||
}
|
||||
|
||||
public class TGeoVolumeRef(provider: () -> TGeoVolume) : TGeoVolume() {
|
||||
public val value: TGeoVolume by lazy(provider)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TGeoVolumeAssembly")
|
||||
public open class TGeoVolumeAssembly : TGeoVolume()
|
||||
|
||||
public class TGeoVolumeAssemblyRef(provider: () -> TGeoVolumeAssembly) : TGeoVolumeAssembly() {
|
||||
public val value: TGeoVolumeAssembly by lazy(provider)
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.Contextual
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
public abstract class TObject {
|
||||
public val fUniqueID: UInt = 0u
|
||||
public val fBits: UInt = 0u
|
||||
}
|
||||
|
||||
@Serializable
|
||||
public open class TNamed : TObject() {
|
||||
public val fName: String = ""
|
||||
public val fTitle: String = ""
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
@SerialName("TObjArray")
|
||||
public class TObjArray<T: TObject>(public val arr: List<@Contextual T>): TObject() {
|
||||
public companion object{
|
||||
public fun <T: TObject> getEmpty(): TObjArray<T> = TObjArray(emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("TList")
|
||||
public class TList(public val arr: List<@Contextual TObject>): TObject()
|
||||
|
||||
@Serializable
|
||||
@SerialName("THashList")
|
||||
public class THashList(public val arr: List<@Contextual TObject>): TObject()
|
@ -0,0 +1,236 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.json.*
|
||||
import kotlinx.serialization.modules.SerializersModule
|
||||
import kotlinx.serialization.modules.contextual
|
||||
import kotlinx.serialization.modules.polymorphic
|
||||
import kotlinx.serialization.modules.subclass
|
||||
|
||||
|
||||
private fun <T> jsonRootDeserializer(
|
||||
tSerializer: KSerializer<T>,
|
||||
builder: (JsonElement) -> T
|
||||
): DeserializationStrategy<T> = object :
|
||||
DeserializationStrategy<T> {
|
||||
private val jsonElementSerializer = JsonElement.serializer()
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = jsonElementSerializer.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
val json = decoder.decodeSerializableValue(jsonElementSerializer)
|
||||
return builder(json)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Json encoded TObject
|
||||
*/
|
||||
public fun <T : TObject> TObject.decodeFromJson(serializer: KSerializer<T>, jsonElement: JsonElement): T =
|
||||
RootDecoder.decode(serializer, jsonElement)
|
||||
|
||||
public fun <T : TObject> TObject.decodeFromString(serializer: KSerializer<T>, string: String): T {
|
||||
val json = Json.parseToJsonElement(string)
|
||||
return RootDecoder.decode(serializer, json)
|
||||
}
|
||||
|
||||
private object RootDecoder {
|
||||
|
||||
private class RootUnrefSerializer<T>(
|
||||
private val tSerializer: KSerializer<T>,
|
||||
private val refCache: List<RefEntry>,
|
||||
) : KSerializer<T> by tSerializer {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
val input = decoder as JsonDecoder
|
||||
val element = input.decodeJsonElement()
|
||||
val refId = (element as? JsonObject)?.get("\$ref")?.jsonPrimitive?.int
|
||||
val ref = if (refId != null) {
|
||||
println("Substituting ${tSerializer.descriptor.serialName} ref $refId")
|
||||
//Forward ref for shapes
|
||||
when (tSerializer.descriptor.serialName) {
|
||||
"TGeoShape" -> return TGeoShapeRef {
|
||||
refCache[refId].getOrPutValue {
|
||||
input.json.decodeFromJsonElement(tSerializer, it) as TGeoShape
|
||||
}
|
||||
} as T
|
||||
|
||||
"TGeoVolumeAssembly" -> return TGeoVolumeAssemblyRef {
|
||||
refCache[refId].getOrPutValue {
|
||||
input.json.decodeFromJsonElement(tSerializer, it) as TGeoVolumeAssembly
|
||||
}
|
||||
} as T
|
||||
|
||||
"TGeoVolume" -> return TGeoVolumeRef {
|
||||
refCache[refId].getOrPutValue {
|
||||
input.json.decodeFromJsonElement(tSerializer, it) as TGeoVolume
|
||||
}
|
||||
} as T
|
||||
|
||||
//Do unref
|
||||
else -> refCache[refId]
|
||||
}
|
||||
} else {
|
||||
refCache.find { it.element == element } ?: error("Element '$element' not found in the cache")
|
||||
}
|
||||
|
||||
return ref.getOrPutValue {
|
||||
// println("Decoding $it")
|
||||
val actualTypeName = it.jsonObject["_typename"]?.jsonPrimitive?.content
|
||||
input.json.decodeFromJsonElement(tSerializer, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T> KSerializer<T>.unref(refCache: List<RefEntry>): KSerializer<T> = RootUnrefSerializer(this, refCache)
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
fun unrefSerializersModule(
|
||||
refCache: List<RefEntry>
|
||||
): SerializersModule = SerializersModule {
|
||||
|
||||
contextual(TObjArray::class) {
|
||||
TObjArray.serializer(it[0]).unref(refCache)
|
||||
}
|
||||
|
||||
contextual(TGeoMedium.serializer().unref(refCache))
|
||||
|
||||
polymorphic(TGeoBoolNode::class) {
|
||||
subclass(TGeoIntersection.serializer().unref(refCache))
|
||||
subclass(TGeoUnion.serializer().unref(refCache))
|
||||
subclass(TGeoSubtraction.serializer().unref(refCache))
|
||||
}
|
||||
|
||||
polymorphic(TGeoShape::class) {
|
||||
subclass(TGeoBBox.serializer())
|
||||
subclass(TGeoXtru.serializer())
|
||||
subclass(TGeoTube.serializer())
|
||||
subclass(TGeoTubeSeg.serializer())
|
||||
subclass(TGeoPcon.serializer())
|
||||
subclass(TGeoPgon.serializer())
|
||||
|
||||
subclass(TGeoCompositeShape.serializer().unref(refCache))
|
||||
subclass(TGeoShapeAssembly.serializer().unref(refCache))
|
||||
|
||||
default {
|
||||
if (it == null) {
|
||||
TGeoShape.serializer().unref(refCache)
|
||||
} else {
|
||||
error("Unrecognized shape $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
polymorphic(TGeoMatrix::class) {
|
||||
subclass(TGeoIdentity.serializer())
|
||||
subclass(TGeoHMatrix.serializer().unref(refCache))
|
||||
subclass(TGeoTranslation.serializer())
|
||||
subclass(TGeoRotation.serializer())
|
||||
subclass(TGeoCombiTrans.serializer().unref(refCache))
|
||||
|
||||
|
||||
val unrefed = TGeoMatrix.serializer().unref(refCache)
|
||||
default {
|
||||
if (it == null) {
|
||||
unrefed
|
||||
} else {
|
||||
error("Unrecognized matrix $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
polymorphic(TGeoVolume::class, TGeoVolume.serializer().unref(refCache)) {
|
||||
subclass(TGeoVolumeAssembly.serializer().unref(refCache))
|
||||
|
||||
val unrefed = TGeoVolume.serializer().unref(refCache)
|
||||
default {
|
||||
if (it == null) {
|
||||
unrefed
|
||||
} else {
|
||||
error("Unrecognized volume $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
polymorphic(TGeoNode::class, TGeoNode.serializer().unref(refCache)) {
|
||||
subclass(TGeoNodeMatrix.serializer().unref(refCache))
|
||||
subclass(TGeoNodeOffset.serializer().unref(refCache))
|
||||
|
||||
val unrefed = TGeoNode.serializer().unref(refCache)
|
||||
default {
|
||||
if (it == null) {
|
||||
unrefed
|
||||
} else {
|
||||
error("Unrecognized node $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Json with unfolding Root references. This instance could not be reused because of the cache.
|
||||
*/
|
||||
private fun unrefJson(refCache: MutableList<RefEntry>): Json = Json {
|
||||
encodeDefaults = true
|
||||
ignoreUnknownKeys = true
|
||||
classDiscriminator = "_typename"
|
||||
serializersModule = unrefSerializersModule(refCache)
|
||||
}
|
||||
|
||||
|
||||
fun <T : TObject> decode(sourceDeserializer: KSerializer<T>, source: JsonElement): T {
|
||||
val refCache = ArrayList<RefEntry>()
|
||||
|
||||
fun fillCache(element: JsonElement) {
|
||||
when (element) {
|
||||
is JsonObject -> {
|
||||
if (element["_typename"] != null) {
|
||||
refCache.add(RefEntry(element))
|
||||
}
|
||||
element.values.forEach {
|
||||
fillCache(it)
|
||||
}
|
||||
}
|
||||
is JsonArray -> {
|
||||
element.forEach {
|
||||
fillCache(it)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
//ignore primitives
|
||||
}
|
||||
}
|
||||
}
|
||||
fillCache(source)
|
||||
|
||||
return unrefJson(refCache).decodeFromJsonElement(sourceDeserializer.unref(refCache), source)
|
||||
}
|
||||
|
||||
class RefEntry(val element: JsonElement) {
|
||||
|
||||
var value: Any? = null
|
||||
|
||||
fun <T> getOrPutValue(builder: (JsonElement) -> T): T {
|
||||
if (value == null) {
|
||||
value = builder(element)
|
||||
}
|
||||
return value as T
|
||||
}
|
||||
|
||||
override fun toString(): String = element.toString()
|
||||
}
|
||||
|
||||
// val json = Json {
|
||||
// encodeDefaults = true
|
||||
// ignoreUnknownKeys = true
|
||||
// classDiscriminator = "_typename"
|
||||
// serializersModule = this@RootDecoder.serializersModule
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
package ru.mipt.npm.root.serialization
|
||||
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.names.asName
|
||||
import space.kscience.dataforge.names.plus
|
||||
import space.kscience.visionforge.solid.*
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
|
||||
|
||||
private val solidsName = "solids".asName()
|
||||
private val volumesName = "volumes".asName()
|
||||
|
||||
private operator fun Number.times(d: Double) = toDouble() * d
|
||||
|
||||
private operator fun Number.times(f: Float) = toFloat() * f
|
||||
|
||||
private fun degToRad(d: Double) = d * PI / 180.0
|
||||
|
||||
// converting to XYZ to Tait–Bryan angles according to https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
private fun Solid.rotate(rot: DoubleArray) {
|
||||
val xAngle = atan2(-rot[5], rot[8])
|
||||
val yAngle = atan2(rot[2], sqrt(1.0 - rot[2].pow(2)))
|
||||
val zAngle = atan2(-rot[1], rot[0])
|
||||
rotation = Point3D(xAngle, yAngle, zAngle)
|
||||
}
|
||||
|
||||
private fun Solid.translate(trans: DoubleArray) {
|
||||
val (x, y, z) = trans
|
||||
position = Point3D(x, y, z)
|
||||
}
|
||||
|
||||
private fun Solid.useMatrix(matrix: TGeoMatrix?) {
|
||||
when (matrix) {
|
||||
null, is TGeoIdentity -> {
|
||||
//do nothing
|
||||
}
|
||||
is TGeoTranslation -> {
|
||||
translate(matrix.fTranslation)
|
||||
}
|
||||
is TGeoRotation -> {
|
||||
rotate(matrix.fRotationMatrix)
|
||||
}
|
||||
is TGeoCombiTrans -> {
|
||||
translate(matrix.fTranslation)
|
||||
matrix.fRotation?.let { rotate(it.fRotationMatrix) }
|
||||
}
|
||||
is TGeoHMatrix -> {
|
||||
translate(matrix.fTranslation)
|
||||
rotate(matrix.fRotationMatrix)
|
||||
val (xScale, yScale, zScale) = matrix.fScale
|
||||
scale = Point3D(xScale, yScale, zScale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun SolidGroup.addShape(shape: TGeoShape) {
|
||||
when (shape) {
|
||||
is TGeoShapeRef -> addShape(shape.value)
|
||||
is TGeoCompositeShape -> {
|
||||
val bool: TGeoBoolNode = shape.fNode
|
||||
val compositeType = when (bool) {
|
||||
is TGeoIntersection -> CompositeType.INTERSECT
|
||||
is TGeoSubtraction -> CompositeType.SUBTRACT
|
||||
is TGeoUnion -> CompositeType.UNION
|
||||
}
|
||||
composite(compositeType, name = shape.fName) {
|
||||
addShape(bool.fLeft).apply {
|
||||
useMatrix(bool.fLeftMat)
|
||||
}
|
||||
addShape(bool.fRight).apply {
|
||||
useMatrix(bool.fRightMat)
|
||||
}
|
||||
}
|
||||
}
|
||||
is TGeoXtru -> extruded(name = shape.fName) {
|
||||
|
||||
(0 until shape.fNvert).forEach { index ->
|
||||
shape {
|
||||
point(shape.fX[index], shape.fY[index])
|
||||
}
|
||||
}
|
||||
|
||||
(0 until shape.fNz).forEach { index ->
|
||||
layer(
|
||||
shape.fZ[index],
|
||||
shape.fX0[index],
|
||||
shape.fY0[index],
|
||||
shape.fScale[index]
|
||||
)
|
||||
}
|
||||
}
|
||||
is TGeoTube -> tube(
|
||||
radius = shape.fRmax,
|
||||
height = shape.fDz * 2,
|
||||
innerRadius = shape.fRmin,
|
||||
name = shape.fName
|
||||
)
|
||||
is TGeoTubeSeg -> tube(
|
||||
radius = shape.fRmax,
|
||||
height = shape.fDz * 2,
|
||||
innerRadius = shape.fRmin,
|
||||
startAngle = degToRad(shape.fPhi1),
|
||||
angle = degToRad(shape.fPhi2 - shape.fPhi1),
|
||||
name = shape.fName
|
||||
)
|
||||
is TGeoPcon -> TODO()
|
||||
is TGeoPgon -> TODO()
|
||||
is TGeoShapeAssembly -> volume(shape.fVolume)
|
||||
is TGeoBBox -> box(shape.fDX * 2, shape.fDY * 2, shape.fDZ * 2, name = shape.fName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun SolidGroup.node(obj: TGeoNode) {
|
||||
if (obj.fVolume != null) {
|
||||
volume(obj.fVolume, obj.fName).apply {
|
||||
when (obj) {
|
||||
is TGeoNodeMatrix -> {
|
||||
useMatrix(obj.fMatrix)
|
||||
}
|
||||
is TGeoNodeOffset -> {
|
||||
x = obj.fOffset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildGroup(volume: TGeoVolume): SolidGroup {
|
||||
return if (volume is TGeoVolumeAssemblyRef) {
|
||||
buildGroup(volume.value)
|
||||
} else {
|
||||
SolidGroup {
|
||||
volume.fShape?.let { addShape(it) }
|
||||
volume.fNodes?.let {
|
||||
it.arr.forEach { obj ->
|
||||
node(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val SolidGroup.rootPrototypes: SolidGroup get() = (parent as? SolidGroup)?.rootPrototypes ?: this
|
||||
|
||||
private fun SolidGroup.volume(volume: TGeoVolume, name: String? = null, cache: Boolean = true): Solid {
|
||||
val group = buildGroup(volume)
|
||||
val combinedName = if (volume.fName.isEmpty()) {
|
||||
name
|
||||
} else if (name == null) {
|
||||
volume.fName
|
||||
} else {
|
||||
"${name}_${volume.fName}"
|
||||
}
|
||||
return if (!cache) {
|
||||
group
|
||||
} else newRef(
|
||||
name = combinedName,
|
||||
obj = group,
|
||||
prototypeHolder = rootPrototypes,
|
||||
templateName = volumesName + Name.parse(combinedName ?: "volume[${group.hashCode()}]")
|
||||
)
|
||||
}
|
||||
|
||||
// private fun load(geo: TGeoManager): SolidGroup {
|
||||
//// /**
|
||||
//// * A special group for local templates
|
||||
//// */
|
||||
//// val proto = SolidGroup()
|
||||
////
|
||||
//// val solids = proto.group(solidsName) {
|
||||
//// setPropertyNode("edges.enabled", false)
|
||||
//// }
|
||||
////
|
||||
//// val volumes = proto.group(volumesName)
|
||||
////
|
||||
//// val referenceStore = HashMap<Name, MutableList<SolidReferenceGroup>>()
|
||||
// }
|
||||
|
||||
|
||||
public fun TGeoManager.toSolid(): SolidGroup = SolidGroup {
|
||||
fNodes.arr.forEach {
|
||||
node(it)
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
import org.jetbrains.kotlin.gradle.frontend.KotlinFrontendExtension
|
||||
import org.jetbrains.kotlin.gradle.frontend.npm.NpmExtension
|
||||
import org.jetbrains.kotlin.gradle.frontend.webpack.WebPackExtension
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
|
||||
plugins {
|
||||
id("kotlin2js")
|
||||
id("kotlin-dce-js")
|
||||
id("org.jetbrains.kotlin.frontend")
|
||||
}
|
||||
|
||||
val kotlinVersion: String by rootProject.extra
|
||||
|
||||
dependencies {
|
||||
implementation(project(":visionforge-spatial-js"))
|
||||
testCompile(kotlin("test-js"))
|
||||
}
|
||||
|
||||
configure<KotlinFrontendExtension> {
|
||||
downloadNodeJsVersion = "latest"
|
||||
|
||||
configure<NpmExtension> {
|
||||
dependency("three","0.106.2")
|
||||
dependency("@hi-level/three-csg")
|
||||
dependency("style-loader")
|
||||
dependency("element-resize-event")
|
||||
devDependency("karma")
|
||||
}
|
||||
|
||||
sourceMaps = true
|
||||
|
||||
bundle<WebPackExtension>("webpack") {
|
||||
this as WebPackExtension
|
||||
bundleName = "main"
|
||||
contentPath = file("src/main/web")
|
||||
sourceMapEnabled = true
|
||||
//mode = "production"
|
||||
mode = "development"
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
"compileKotlin2Js"(Kotlin2JsCompile::class) {
|
||||
kotlinOptions {
|
||||
metaInfo = true
|
||||
outputFile = "${project.buildDir.path}/js/${project.name}.js"
|
||||
sourceMap = true
|
||||
moduleKind = "commonjs"
|
||||
main = "call"
|
||||
kotlinOptions.sourceMapEmbedSources = "always"
|
||||
}
|
||||
}
|
||||
|
||||
"compileTestKotlin2Js"(Kotlin2JsCompile::class) {
|
||||
kotlinOptions {
|
||||
metaInfo = true
|
||||
outputFile = "${project.buildDir.path}/js/${project.name}-test.js"
|
||||
sourceMap = true
|
||||
moduleKind = "commonjs"
|
||||
kotlinOptions.sourceMapEmbedSources = "always"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
external val module: Module
|
||||
|
||||
external interface Module {
|
||||
val hot: Hot?
|
||||
}
|
||||
|
||||
external interface Hot {
|
||||
val data: dynamic
|
||||
|
||||
fun accept()
|
||||
fun accept(dependency: String, callback: () -> Unit)
|
||||
fun accept(dependencies: Array<String>, callback: (updated: Array<String>) -> Unit)
|
||||
|
||||
fun dispose(callback: (data: dynamic) -> Unit)
|
||||
}
|
||||
|
||||
external fun require(name: String): dynamic
|
@ -1,6 +0,0 @@
|
||||
@file:JsModule("JSRootUtils")
|
||||
@file:JsNonModule
|
||||
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
external fun parse(obj: String): dynamic
|
@ -1,78 +0,0 @@
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.meta.EmptyMeta
|
||||
import hep.dataforge.vis.spatial.render
|
||||
import hep.dataforge.vis.spatial.three.ThreePlugin
|
||||
import hep.dataforge.vis.spatial.three.output
|
||||
import org.w3c.dom.HTMLDivElement
|
||||
import org.w3c.dom.events.Event
|
||||
import org.w3c.files.FileList
|
||||
import org.w3c.files.FileReader
|
||||
import org.w3c.files.get
|
||||
import kotlin.browser.document
|
||||
import kotlin.dom.clear
|
||||
|
||||
|
||||
class JSRootDemoApp : ApplicationBase() {
|
||||
|
||||
override val stateKeys: List<String> = emptyList()
|
||||
|
||||
override fun start(state: Map<String, Any>) {
|
||||
|
||||
|
||||
//TODO remove after DI fix
|
||||
// Global.plugins.load(ThreePlugin())
|
||||
// Global.plugins.load(JSRootPlugin())
|
||||
|
||||
Global.plugins.load(JSRootPlugin)
|
||||
|
||||
|
||||
|
||||
(document.getElementById("drop_zone") as? HTMLDivElement)?.apply {
|
||||
addEventListener("dragover", { handleDragOver(it) }, false)
|
||||
addEventListener("drop", { loadData(it) }, false)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle mouse drag according to https://www.html5rocks.com/en/tutorials/file/dndfiles/
|
||||
*/
|
||||
private fun handleDragOver(event: Event) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
event.asDynamic().dataTransfer.dropEffect = "copy"
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data from text file
|
||||
*/
|
||||
private fun loadData(event: Event) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
|
||||
|
||||
val file = (event.asDynamic().dataTransfer.files as FileList)[0]
|
||||
?: throw RuntimeException("Failed to load file");
|
||||
FileReader().apply {
|
||||
onload = {
|
||||
val string = result as String
|
||||
val renderer = Global.plugins.fetch(ThreePlugin).output()
|
||||
val canvas = document.getElementById("canvas")!!
|
||||
canvas.clear()
|
||||
renderer.attach(canvas)
|
||||
println("started")
|
||||
|
||||
renderer.render {
|
||||
val json = parse(string)
|
||||
JSRootObject(this, EmptyMeta, json).also { add(it) }
|
||||
}
|
||||
}
|
||||
readAsText(file)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() = emptyMap<String, Any>()//mapOf("lines" put presenter.dispose())
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
@file:JsModule("JSRootGeoBase")
|
||||
@file:JsNonModule
|
||||
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
external fun createGeometry(shape: dynamic, limit: Int): BufferGeometry
|
||||
|
||||
external fun createCubeBuffer(shape: dynamic, limit: Int): BufferGeometry
|
||||
|
||||
external fun createTubeBuffer(shape: dynamic, limit: Int): BufferGeometry
|
||||
|
||||
external fun createXtruBuffer(shape: dynamic, limit: Int): BufferGeometry
|
||||
|
||||
external fun build(obj: dynamic, opt: dynamic): Object3D
|
@ -1,82 +0,0 @@
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
import hep.dataforge.meta.EmptyMeta
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import hep.dataforge.meta.toDynamic
|
||||
import hep.dataforge.vis.common.*
|
||||
import hep.dataforge.vis.spatial.three.MeshThreeFactory
|
||||
import info.laht.threekt.core.BufferGeometry
|
||||
|
||||
class JSRootGeometry(parent: VisualObject?, meta: Meta) : DisplayLeaf(parent, meta) {
|
||||
|
||||
var shape by node()
|
||||
|
||||
var facesLimit by int(0)
|
||||
|
||||
fun box(xSize: Number, ySize: Number, zSize: Number) = buildMeta {
|
||||
"_typename" put "TGeoBBox"
|
||||
"fDX" put xSize
|
||||
"fDY" put ySize
|
||||
"fDZ" put zSize
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GDML union
|
||||
*/
|
||||
operator fun Meta.plus(other: Meta) = buildMeta {
|
||||
"fNode.fLeft" put this
|
||||
"fNode.fRight" put other
|
||||
"fNode._typename" put "TGeoUnion"
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GDML subtraction
|
||||
*/
|
||||
operator fun Meta.minus(other: Meta) = buildMeta {
|
||||
"fNode.fLeft" put this
|
||||
"fNode.fRight" put other
|
||||
"fNode._typename" put "TGeoSubtraction"
|
||||
}
|
||||
|
||||
/**
|
||||
* Intersect two GDML geometries
|
||||
*/
|
||||
infix fun Meta.intersect(other: Meta) = buildMeta {
|
||||
"fNode.fLeft" put this
|
||||
"fNode.fRight" put other
|
||||
"fNode._typename" put "TGeoIntersection"
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE = "geometry.spatial.jsRoot.geometry"
|
||||
}
|
||||
}
|
||||
|
||||
fun VisualGroup.jsRootGeometry(meta: Meta = EmptyMeta, action: JSRootGeometry.() -> Unit = {}) =
|
||||
JSRootGeometry(this, meta).apply(action).also { add(it) }
|
||||
|
||||
//fun Meta.toDynamic(): dynamic {
|
||||
// fun MetaItem<*>.toDynamic(): dynamic = when (this) {
|
||||
// is MetaItem.ValueItem -> this.value.value.asDynamic()
|
||||
// is MetaItem.NodeItem -> this.node.toDynamic()
|
||||
// }
|
||||
//
|
||||
// val res = js("{}")
|
||||
// this.items.entries.groupBy { it.key.body }.forEach { (key, value) ->
|
||||
// val list = value.map { it.value }
|
||||
// res[key] = when (list.size) {
|
||||
// 1 -> list.first().toDynamic()
|
||||
// else -> list.map { it.toDynamic() }
|
||||
// }
|
||||
// }
|
||||
// return res
|
||||
//}
|
||||
|
||||
|
||||
object ThreeJSRootGeometryFactory : MeshThreeFactory<JSRootGeometry>(JSRootGeometry::class) {
|
||||
override fun buildGeometry(obj: JSRootGeometry): BufferGeometry {
|
||||
val shapeMeta = obj.shape?.toDynamic() ?: error("The shape not defined")
|
||||
return createGeometry(shapeMeta, obj.facesLimit)
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
import hep.dataforge.meta.EmptyMeta
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.toDynamic
|
||||
import hep.dataforge.vis.common.VisualGroup
|
||||
import hep.dataforge.vis.common.DisplayLeaf
|
||||
import hep.dataforge.vis.common.VisualObject
|
||||
import hep.dataforge.vis.common.node
|
||||
import hep.dataforge.vis.spatial.three.ThreeFactory
|
||||
import info.laht.threekt.core.Object3D
|
||||
|
||||
class JSRootObject(parent: VisualObject?, meta: Meta, val data: dynamic) : DisplayLeaf(parent, meta) {
|
||||
|
||||
var options by node()
|
||||
|
||||
companion object {
|
||||
const val TYPE = "geometry.spatial.jsRoot.object"
|
||||
}
|
||||
}
|
||||
|
||||
object ThreeJSRootObjectFactory : ThreeFactory<JSRootObject> {
|
||||
|
||||
override val type = JSRootObject::class
|
||||
|
||||
override fun invoke(obj: JSRootObject): Object3D {
|
||||
return build(obj.data, obj.options?.toDynamic())
|
||||
}
|
||||
}
|
||||
|
||||
fun VisualGroup.jsRootObject(str: String) {
|
||||
val json = JSON.parse<Any>(str)
|
||||
JSRootObject(this, EmptyMeta, json).also { add(it) }
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
import hep.dataforge.context.AbstractPlugin
|
||||
import hep.dataforge.context.PluginFactory
|
||||
import hep.dataforge.context.PluginTag
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.vis.spatial.three.ThreeFactory
|
||||
import hep.dataforge.vis.spatial.three.ThreePlugin
|
||||
|
||||
class JSRootPlugin : AbstractPlugin() {
|
||||
override val tag: PluginTag get() = Companion.tag
|
||||
|
||||
override fun dependsOn() = listOf(ThreePlugin)
|
||||
|
||||
override fun provideTop(target: String): Map<Name, Any> {
|
||||
return when(target){
|
||||
ThreeFactory.TYPE -> mapOf(
|
||||
"jsRoot.geometry".toName() to ThreeJSRootGeometryFactory,
|
||||
"jsRoot.object".toName() to ThreeJSRootObjectFactory
|
||||
)
|
||||
else -> emptyMap()
|
||||
}
|
||||
}
|
||||
|
||||
companion object: PluginFactory<JSRootPlugin> {
|
||||
override val tag = PluginTag("vis.jsroot", "hep.dataforge")
|
||||
override val type = JSRootPlugin::class
|
||||
override fun invoke(meta: Meta) = JSRootPlugin()
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package hep.dataforge.vis.jsroot
|
||||
|
||||
import kotlin.browser.document
|
||||
import kotlin.dom.hasClass
|
||||
|
||||
|
||||
abstract class ApplicationBase {
|
||||
abstract val stateKeys: List<String>
|
||||
|
||||
abstract fun start(state: Map<String, Any>)
|
||||
abstract fun dispose(): Map<String, Any>
|
||||
}
|
||||
|
||||
|
||||
fun main() {
|
||||
var application: ApplicationBase? = null
|
||||
|
||||
val state: dynamic = module.hot?.let { hot ->
|
||||
hot.accept()
|
||||
|
||||
hot.dispose { data ->
|
||||
data.appState = application?.dispose()
|
||||
application = null
|
||||
}
|
||||
|
||||
hot.data
|
||||
}
|
||||
|
||||
if (document.body != null) {
|
||||
application = start(state)
|
||||
} else {
|
||||
application = null
|
||||
document.addEventListener("DOMContentLoaded", { application = start(state) })
|
||||
}
|
||||
}
|
||||
|
||||
fun start(state: dynamic): ApplicationBase? {
|
||||
return if (document.body?.hasClass("application") == true) {
|
||||
val application = JSRootDemoApp()
|
||||
|
||||
@Suppress("UnsafeCastFromDynamic")
|
||||
application.start(state?.appState ?: emptyMap<String, Any>())
|
||||
|
||||
application
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
3577
dataforge-vis-jsroot/src/main/resources/JSRootGeoBase.js
vendored
3577
dataforge-vis-jsroot/src/main/resources/JSRootGeoBase.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,765 +0,0 @@
|
||||
|
||||
/** Generate mask for given bit
|
||||
*
|
||||
* @param {number} n bit number
|
||||
* @returns {Number} produced make
|
||||
* @private */
|
||||
export function BIT(n) {
|
||||
return 1 << (n);
|
||||
}
|
||||
|
||||
/** Wrapper for console.log, let redirect output to specified div element
|
||||
* @private */
|
||||
function console(value, divid) {
|
||||
if ((typeof divid == 'string') && document.getElementById(divid))
|
||||
document.getElementById(divid).innerHTML = value;
|
||||
else if ((typeof console != 'undefined') && (typeof console.log == 'function'))
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
|
||||
/** @summary Wrapper for alert, throws Error in Node.js
|
||||
* @private */
|
||||
export function alert(msg) {
|
||||
if (this.nodeis) throw new Error(msg);
|
||||
if (typeof alert === 'function') alert(msg);
|
||||
else console('ALERT: ' + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Seed simple random generator
|
||||
*
|
||||
* @private
|
||||
* @param {number} i seed value
|
||||
*/
|
||||
export function seed(i) {
|
||||
i = Math.abs(i);
|
||||
if (i > 1e8) i = Math.abs(1e8 * Math.sin(i)); else if (i < 1) i *= 1e8;
|
||||
this.m_w = Math.round(i);
|
||||
this.m_z = 987654321;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Simple random generator
|
||||
*
|
||||
* @desc Works like Math.random(), but with configurable seed - see {@link JSROOT.seed}
|
||||
* @private
|
||||
* @returns {number} random value between 0 (inclusive) and 1.0 (exclusive)
|
||||
*/
|
||||
export function random() {
|
||||
if (this.m_z === undefined) return Math.random();
|
||||
this.m_z = (36969 * (this.m_z & 65535) + (this.m_z >> 16)) & 0xffffffff;
|
||||
this.m_w = (18000 * (this.m_w & 65535) + (this.m_w >> 16)) & 0xffffffff;
|
||||
var result = ((this.m_z << 16) + this.m_w) & 0xffffffff;
|
||||
result /= 4294967296;
|
||||
return result + 0.5;
|
||||
}
|
||||
|
||||
|
||||
/** @summary Should be used to reintroduce objects references, produced by TBufferJSON.
|
||||
*
|
||||
* @desc Replace all references inside object, object should not be null
|
||||
* Idea of the code taken from JSON-R code, found on
|
||||
* https://github.com/graniteds/jsonr
|
||||
* Only unref part was used, arrays are not accounted as objects
|
||||
* @param {object} obj object where references will be replaced
|
||||
* @returns {object} same object with replaced references
|
||||
* @private */
|
||||
function JSONR_unref(obj) {
|
||||
|
||||
let map = [], newfmt = undefined;
|
||||
|
||||
function unref_value(value) {
|
||||
if ((value === null) || (value === undefined)) return;
|
||||
|
||||
/*
|
||||
if object is a reference string in "old format"
|
||||
Old format seems to be single string with "$ref:" prefix. New format is an object
|
||||
*/
|
||||
if (typeof value === 'string') {
|
||||
if (newfmt || (value.length < 6) || (value.indexOf("$ref:") !== 0)) return; //switch to "new format" if needed
|
||||
let ref = parseInt(value.substr(5)); // get ref number
|
||||
if (isNaN(ref) || (ref < 0) || (ref >= map.length)) return; //skip if not a ref
|
||||
newfmt = false;
|
||||
return map[ref]; //return an object from cache
|
||||
}
|
||||
|
||||
if (typeof value !== 'object') return;
|
||||
|
||||
let i, k, res, proto = Object.prototype.toString.apply(value);
|
||||
|
||||
// scan array - it can contain other objects
|
||||
if ((proto.indexOf('[object') === 0) && (proto.indexOf('Array]') > 0)) {
|
||||
for (i = 0; i < value.length; ++i) {
|
||||
res = unref_value(value[i]);
|
||||
if (res !== undefined) value[i] = res;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let ks = Object.keys(value), len = ks.length;
|
||||
|
||||
if ((newfmt !== false) && (len === 1) && (ks[0] === '$ref')) {
|
||||
let ref = parseInt(value['$ref']);
|
||||
if (isNaN(ref) || (ref < 0) || (ref >= map.length)) return;
|
||||
newfmt = true;
|
||||
return map[ref];
|
||||
}
|
||||
|
||||
if ((newfmt !== false) && (len > 1) && (ks[0] === '$arr') && (ks[1] === 'len')) {
|
||||
// this is ROOT-coded array
|
||||
var arr = null, dflt = (value.$arr === "Bool") ? false : 0;
|
||||
switch (value.$arr) {
|
||||
case "Int8" :
|
||||
arr = new Int8Array(value.len);
|
||||
break;
|
||||
case "Uint8" :
|
||||
arr = new Uint8Array(value.len);
|
||||
break;
|
||||
case "Int16" :
|
||||
arr = new Int16Array(value.len);
|
||||
break;
|
||||
case "Uint16" :
|
||||
arr = new Uint16Array(value.len);
|
||||
break;
|
||||
case "Int32" :
|
||||
arr = new Int32Array(value.len);
|
||||
break;
|
||||
case "Uint32" :
|
||||
arr = new Uint32Array(value.len);
|
||||
break;
|
||||
case "Float32" :
|
||||
arr = new Float32Array(value.len);
|
||||
break;
|
||||
case "Int64" :
|
||||
case "Uint64" :
|
||||
case "Float64" :
|
||||
arr = new Float64Array(value.len);
|
||||
break;
|
||||
default :
|
||||
arr = new Array(value.len);
|
||||
break;
|
||||
}
|
||||
for (let k = 0; k < value.len; ++k) arr[k] = dflt;
|
||||
|
||||
var nkey = 2, p = 0;
|
||||
while (nkey < len) {
|
||||
if (ks[nkey][0] === "p") p = value[ks[nkey++]]; // position
|
||||
if (ks[nkey][0] !== 'v') throw new Error('Unexpected member ' + ks[nkey] + ' in array decoding');
|
||||
let v = value[ks[nkey++]]; // value
|
||||
if (typeof v === 'object') {
|
||||
for (let k = 0; k < v.length; ++k) arr[p++] = v[k];
|
||||
} else {
|
||||
arr[p++] = v;
|
||||
if ((nkey < len) && (ks[nkey][0] === 'n')) {
|
||||
let cnt = value[ks[nkey++]]; // counter
|
||||
while (--cnt) arr[p++] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
if ((newfmt !== false) && (len === 3) && (ks[0] === '$pair') && (ks[1] === 'first') && (ks[2] === 'second')) {
|
||||
newfmt = true;
|
||||
let f1 = unref_value(value.first),
|
||||
s1 = unref_value(value.second);
|
||||
if (f1 !== undefined) value.first = f1;
|
||||
if (s1 !== undefined) value.second = s1;
|
||||
value._typename = value['$pair'];
|
||||
delete value['$pair'];
|
||||
return; // pair object is not counted in the objects map
|
||||
}
|
||||
|
||||
// debug code, can be commented out later
|
||||
if (map.indexOf(value) >= 0) {
|
||||
console('should never happen - object already in the map');
|
||||
return;
|
||||
}
|
||||
|
||||
// add object to object map
|
||||
map.push(value);
|
||||
|
||||
// add methods to all objects, where _typename is specified
|
||||
//if ('_typename' in value) JSROOT.addMethods(value);
|
||||
|
||||
for (let k = 0; k < len; ++k) {
|
||||
i = ks[k];
|
||||
res = unref_value(value[i]);
|
||||
if (res !== undefined) value[i] = res;
|
||||
}
|
||||
}
|
||||
|
||||
unref_value(obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/** @summary Just copies (not clone) all fields from source to the target object
|
||||
* @desc This is simple replacement of jQuery.extend method
|
||||
* @private */
|
||||
function extend(tgt, src) {
|
||||
if ((src === null) || (typeof src !== 'object')) return tgt;
|
||||
if ((tgt === null) || (typeof tgt !== 'object')) tgt = {};
|
||||
|
||||
for (var k in src)
|
||||
tgt[k] = src[k];
|
||||
|
||||
return tgt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @summary Parse JSON code produced with TBufferJSON.
|
||||
*
|
||||
* @param {string} json string to parse
|
||||
* @return {object|null} returns parsed object
|
||||
*/
|
||||
export function parse(json) {
|
||||
if (!json) return null;
|
||||
let obj = JSON.parse(json);
|
||||
if (obj) obj = JSONR_unref(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @summary Parse multi.json request results
|
||||
* @desc Method should be used to parse JSON code, produced by multi.json request of THttpServer
|
||||
*
|
||||
* @param {string} json string to parse
|
||||
* @return {Array|null} returns array of parsed elements
|
||||
*/
|
||||
export function parse_multi(json) {
|
||||
if (!json) return null;
|
||||
let arr = JSON.parse(json);
|
||||
if (arr && arr.length)
|
||||
for (let i = 0; i < arr.length; ++i)
|
||||
arr[i] = JSONR_unref(arr[i]);
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Method converts JavaScript object into ROOT-like JSON
|
||||
*
|
||||
* @desc Produced JSON can be used in JSROOT.parse() again
|
||||
* When performed properly, JSON can be used in TBufferJSON to read data back with C++
|
||||
*/
|
||||
export function toJSON(obj) {
|
||||
if (!obj || typeof obj !== 'object') return "";
|
||||
|
||||
var map = []; // map of stored objects
|
||||
|
||||
function copy_value(value) {
|
||||
if (typeof value === "function") return undefined;
|
||||
|
||||
if ((value === undefined) || (value === null) || (typeof value !== 'object')) return value;
|
||||
|
||||
var proto = Object.prototype.toString.apply(value);
|
||||
|
||||
// typed array need to be converted into normal array, otherwise looks strange
|
||||
if ((proto.indexOf('[object ') === 0) && (proto.indexOf('Array]') === proto.length - 6)) {
|
||||
var arr = new Array(value.length);
|
||||
for (var i = 0; i < value.length; ++i)
|
||||
arr[i] = copy_value(value[i]);
|
||||
return arr;
|
||||
}
|
||||
|
||||
// this is how reference is code
|
||||
var refid = map.indexOf(value);
|
||||
if (refid >= 0) return {$ref: refid};
|
||||
|
||||
var ks = Object.keys(value), len = ks.length, tgt = {};
|
||||
|
||||
if ((len === 3) && (ks[0] === '$pair') && (ks[1] === 'first') && (ks[2] === 'second')) {
|
||||
// special handling of pair objects which does not included into objects map
|
||||
tgt.$pair = value.$pair;
|
||||
tgt.first = copy_value(value.first);
|
||||
tgt.second = copy_value(value.second);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
map.push(value);
|
||||
|
||||
for (var k = 0; k < len; ++k) {
|
||||
var name = ks[k];
|
||||
tgt[name] = copy_value(value[name]);
|
||||
}
|
||||
|
||||
return tgt;
|
||||
}
|
||||
|
||||
var tgt = copy_value(obj);
|
||||
|
||||
return JSON.stringify(tgt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @summary Parse string value as array.
|
||||
*
|
||||
* @desc It could be just simple string: "value" or
|
||||
* array with or without string quotes: [element], ['elem1',elem2]
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function ParseAsArray(val) {
|
||||
|
||||
var res = [];
|
||||
|
||||
if (typeof val != 'string') return res;
|
||||
|
||||
val = val.trim();
|
||||
if (val === "") return res;
|
||||
|
||||
// return as array with single element
|
||||
if ((val.length < 2) || (val[0] !== '[') || (val[val.length - 1] !== ']')) {
|
||||
res.push(val);
|
||||
return res;
|
||||
}
|
||||
|
||||
// try to split ourself, checking quotes and brackets
|
||||
var nbr = 0, nquotes = 0, ndouble = 0, last = 1;
|
||||
|
||||
for (var indx = 1; indx < val.length; ++indx) {
|
||||
if (nquotes > 0) {
|
||||
if (val[indx] === "'") nquotes--;
|
||||
continue;
|
||||
}
|
||||
if (ndouble > 0) {
|
||||
if (val[indx] === '"') ndouble--;
|
||||
continue;
|
||||
}
|
||||
switch (val[indx]) {
|
||||
case "'":
|
||||
nquotes++;
|
||||
break;
|
||||
case '"':
|
||||
ndouble++;
|
||||
break;
|
||||
case "[":
|
||||
nbr++;
|
||||
break;
|
||||
case "]":
|
||||
if (indx < val.length - 1) {
|
||||
nbr--;
|
||||
break;
|
||||
}
|
||||
case ",":
|
||||
if (nbr === 0) {
|
||||
var sub = val.substring(last, indx).trim();
|
||||
if ((sub.length > 1) && (sub[0] === sub[sub.length - 1]) && ((sub[0] === '"') || (sub[0] === "'")))
|
||||
sub = sub.substr(1, sub.length - 2);
|
||||
res.push(sub);
|
||||
last = indx + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (res.length === 0)
|
||||
res.push(val.substr(1, val.length - 2).trim());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Find function with given name.
|
||||
*
|
||||
* @desc Function name may include several namespaces like 'JSROOT.Painter.drawFrame'
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function findFunction(name) {
|
||||
if (typeof name === 'function') return name;
|
||||
if (typeof name !== 'string') return null;
|
||||
var names = name.split('.'), elem = null;
|
||||
if (typeof window === 'object') elem = window;
|
||||
if (names[0] === 'JSROOT') {
|
||||
elem = this;
|
||||
names.shift();
|
||||
}
|
||||
|
||||
for (var n = 0; elem && (n < names.length); ++n)
|
||||
elem = elem[names[n]];
|
||||
|
||||
return (typeof elem == 'function') ? elem : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Generic method to invoke callback function.
|
||||
*
|
||||
* @param {object|function} func either normal function or container like
|
||||
* { obj: object_pointer, func: name of method to call }
|
||||
* @param arg1 first optional argument of callback
|
||||
* @param arg2 second optional argument of callback
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function callBack(func, arg1, arg2) {
|
||||
|
||||
if (typeof func == 'string') func = findFunction(func);
|
||||
|
||||
if (!func) return;
|
||||
|
||||
if (typeof func == 'function') return func(arg1, arg2);
|
||||
|
||||
if (typeof func != 'object') return;
|
||||
|
||||
if (('obj' in func) && ('func' in func) &&
|
||||
(typeof func.obj == 'object') && (typeof func.func == 'string') &&
|
||||
(typeof func.obj[func.func] == 'function')) {
|
||||
return func.obj[func.func](arg1, arg2);
|
||||
}
|
||||
}
|
||||
|
||||
let methodsCache = {}; // variable used to keep methods for known classes
|
||||
|
||||
|
||||
/** @summary Returns methods for given typename
|
||||
* @private
|
||||
*/
|
||||
function getMethods(typename, obj) {
|
||||
|
||||
var m = methodsCache[typename],
|
||||
has_methods = (m !== undefined);
|
||||
|
||||
if (!has_methods) m = {};
|
||||
|
||||
// Due to binary I/O such TObject methods may not be set for derived classes
|
||||
// Therefore when methods requested for given object, check also that basic methods are there
|
||||
if ((typename === "TObject") || (typename === "TNamed") || (obj && (obj.fBits !== undefined)))
|
||||
if (m.TestBit === undefined) {
|
||||
m.TestBit = function (f) {
|
||||
return (this.fBits & f) !== 0;
|
||||
};
|
||||
m.InvertBit = function (f) {
|
||||
this.fBits = this.fBits ^ (f & 0xffffff);
|
||||
};
|
||||
}
|
||||
|
||||
if (has_methods) return m;
|
||||
|
||||
if ((typename === 'TList') || (typename === 'THashList')) {
|
||||
m.Clear = function () {
|
||||
this.arr = [];
|
||||
this.opt = [];
|
||||
};
|
||||
m.Add = function (obj, opt) {
|
||||
this.arr.push(obj);
|
||||
this.opt.push((opt && typeof opt == 'string') ? opt : "");
|
||||
};
|
||||
m.AddFirst = function (obj, opt) {
|
||||
this.arr.unshift(obj);
|
||||
this.opt.unshift((opt && typeof opt == 'string') ? opt : "");
|
||||
};
|
||||
m.RemoveAt = function (indx) {
|
||||
this.arr.splice(indx, 1);
|
||||
this.opt.splice(indx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// if ((typename === "TPaveText") || (typename === "TPaveStats")) {
|
||||
// m.AddText = function (txt) {
|
||||
// // this.fLines.Add({ _typename: 'TLatex', fTitle: txt, fTextColor: 1 });
|
||||
// var line = JSROOT.Create("TLatex");
|
||||
// line.fTitle = txt;
|
||||
// this.fLines.Add(line);
|
||||
// };
|
||||
// m.Clear = function () {
|
||||
// this.fLines.Clear();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if ((typename.indexOf("TF1") === 0) || (typename === "TF2")) {
|
||||
// m.addFormula = function (obj) {
|
||||
// if (!obj) return;
|
||||
// if (this.formulas === undefined) this.formulas = [];
|
||||
// this.formulas.push(obj);
|
||||
// };
|
||||
//
|
||||
// m.evalPar = function (x, y) {
|
||||
// if (!('_func' in this) || (this._title !== this.fTitle)) {
|
||||
//
|
||||
// var _func = this.fTitle, isformula = false, pprefix = "[";
|
||||
// if (_func === "gaus") _func = "gaus(0)";
|
||||
// if (this.fFormula && typeof this.fFormula.fFormula == "string") {
|
||||
// if (this.fFormula.fFormula.indexOf("[](double*x,double*p)") === 0) {
|
||||
// isformula = true;
|
||||
// pprefix = "p[";
|
||||
// _func = this.fFormula.fFormula.substr(21);
|
||||
// } else {
|
||||
// _func = this.fFormula.fFormula;
|
||||
// pprefix = "[p";
|
||||
// }
|
||||
// if (this.fFormula.fClingParameters && this.fFormula.fParams) {
|
||||
// for (var i = 0; i < this.fFormula.fParams.length; ++i) {
|
||||
// var regex = new RegExp('(\\[' + this.fFormula.fParams[i].first + '\\])', 'g'),
|
||||
// parvalue = this.fFormula.fClingParameters[this.fFormula.fParams[i].second];
|
||||
// _func = _func.replace(regex, (parvalue < 0) ? "(" + parvalue + ")" : parvalue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if ('formulas' in this)
|
||||
// for (var i = 0; i < this.formulas.length; ++i)
|
||||
// while (_func.indexOf(this.formulas[i].fName) >= 0)
|
||||
// _func = _func.replace(this.formulas[i].fName, this.formulas[i].fTitle);
|
||||
// _func = _func.replace(/\b(abs)\b/g, 'TMath::Abs')
|
||||
// .replace(/TMath::Exp\(/g, 'Math.exp(')
|
||||
// .replace(/TMath::Abs\(/g, 'Math.abs(');
|
||||
// if (typeof JSROOT.Math == 'object') {
|
||||
// this._math = JSROOT.Math;
|
||||
// _func = _func.replace(/TMath::Prob\(/g, 'this._math.Prob(')
|
||||
// .replace(/TMath::Gaus\(/g, 'this._math.Gaus(')
|
||||
// .replace(/TMath::BreitWigner\(/g, 'this._math.BreitWigner(')
|
||||
// .replace(/xygaus\(/g, 'this._math.gausxy(this, x, y, ')
|
||||
// .replace(/gaus\(/g, 'this._math.gaus(this, x, ')
|
||||
// .replace(/gausn\(/g, 'this._math.gausn(this, x, ')
|
||||
// .replace(/expo\(/g, 'this._math.expo(this, x, ')
|
||||
// .replace(/landau\(/g, 'this._math.landau(this, x, ')
|
||||
// .replace(/landaun\(/g, 'this._math.landaun(this, x, ')
|
||||
// .replace(/ROOT::Math::/g, 'this._math.');
|
||||
// }
|
||||
// for (var i = 0; i < this.fNpar; ++i) {
|
||||
// var parname = pprefix + i + "]";
|
||||
// while (_func.indexOf(parname) !== -1)
|
||||
// _func = _func.replace(parname, '(' + this.GetParValue(i) + ')');
|
||||
// }
|
||||
// _func = _func.replace(/\b(sin)\b/gi, 'Math.sin')
|
||||
// .replace(/\b(cos)\b/gi, 'Math.cos')
|
||||
// .replace(/\b(tan)\b/gi, 'Math.tan')
|
||||
// .replace(/\b(exp)\b/gi, 'Math.exp')
|
||||
// .replace(/\b(pow)\b/gi, 'Math.pow')
|
||||
// .replace(/pi/g, 'Math.PI');
|
||||
// for (var n = 2; n < 10; ++n)
|
||||
// _func = _func.replace('x^' + n, 'Math.pow(x,' + n + ')');
|
||||
//
|
||||
// if (isformula) {
|
||||
// _func = _func.replace(/x\[0\]/g, "x");
|
||||
// if (this._typename === "TF2") {
|
||||
// _func = _func.replace(/x\[1\]/g, "y");
|
||||
// this._func = new Function("x", "y", _func).bind(this);
|
||||
// } else {
|
||||
// this._func = new Function("x", _func).bind(this);
|
||||
// }
|
||||
// } else if (this._typename === "TF2")
|
||||
// this._func = new Function("x", "y", "return " + _func).bind(this);
|
||||
// else
|
||||
// this._func = new Function("x", "return " + _func).bind(this);
|
||||
//
|
||||
// this._title = this.fTitle;
|
||||
// }
|
||||
//
|
||||
// return this._func(x, y);
|
||||
// };
|
||||
// m.GetParName = function (n) {
|
||||
// if (this.fFormula && this.fFormula.fParams) return this.fFormula.fParams[n].first;
|
||||
// if (this.fNames && this.fNames[n]) return this.fNames[n];
|
||||
// return "p" + n;
|
||||
// };
|
||||
// m.GetParValue = function (n) {
|
||||
// if (this.fFormula && this.fFormula.fClingParameters) return this.fFormula.fClingParameters[n];
|
||||
// if (this.fParams) return this.fParams[n];
|
||||
// return undefined;
|
||||
// };
|
||||
// m.GetParError = function (n) {
|
||||
// return this.fParErrors ? this.fParErrors[n] : undefined;
|
||||
// };
|
||||
// m.GetNumPars = function () {
|
||||
// return this.fNpar;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (((typename.indexOf("TGraph") === 0) || (typename === "TCutG")) && (typename !== "TGraphPolargram") && (typename !== "TGraphTime")) {
|
||||
// check if point inside figure specified by the TGraph
|
||||
m.IsInside = function (xp, yp) {
|
||||
var i, j = this.fNpoints - 1, x = this.fX, y = this.fY, oddNodes = false;
|
||||
|
||||
for (i = 0; i < this.fNpoints; ++i) {
|
||||
if ((y[i] < yp && y[j] >= yp) || (y[j] < yp && y[i] >= yp)) {
|
||||
if (x[i] + (yp - y[i]) / (y[j] - y[i]) * (x[j] - x[i]) < xp) {
|
||||
oddNodes = !oddNodes;
|
||||
}
|
||||
}
|
||||
j = i;
|
||||
}
|
||||
|
||||
return oddNodes;
|
||||
};
|
||||
}
|
||||
|
||||
if (typename.indexOf("TH1") === 0 ||
|
||||
typename.indexOf("TH2") === 0 ||
|
||||
typename.indexOf("TH3") === 0) {
|
||||
m.getBinError = function (bin) {
|
||||
// -*-*-*-*-*Return value of error associated to bin number bin*-*-*-*-*
|
||||
// if the sum of squares of weights has been defined (via Sumw2),
|
||||
// this function returns the sqrt(sum of w2).
|
||||
// otherwise it returns the sqrt(contents) for this bin.
|
||||
if (bin >= this.fNcells) bin = this.fNcells - 1;
|
||||
if (bin < 0) bin = 0;
|
||||
if (bin < this.fSumw2.length)
|
||||
return Math.sqrt(this.fSumw2[bin]);
|
||||
return Math.sqrt(Math.abs(this.fArray[bin]));
|
||||
};
|
||||
m.setBinContent = function (bin, content) {
|
||||
// Set bin content - only trivial case, without expansion
|
||||
this.fEntries++;
|
||||
this.fTsumw = 0;
|
||||
if ((bin >= 0) && (bin < this.fArray.length))
|
||||
this.fArray[bin] = content;
|
||||
};
|
||||
}
|
||||
|
||||
if (typename.indexOf("TH1") === 0) {
|
||||
m.getBin = function (x) {
|
||||
return x;
|
||||
};
|
||||
m.getBinContent = function (bin) {
|
||||
return this.fArray[bin];
|
||||
};
|
||||
m.Fill = function (x, weight) {
|
||||
var axis = this.fXaxis,
|
||||
bin = 1 + Math.floor((x - axis.fXmin) / (axis.fXmax - axis.fXmin) * axis.fNbins);
|
||||
if (bin < 0) bin = 0; else if (bin > axis.fNbins + 1) bin = axis.fNbins + 1;
|
||||
this.fArray[bin] += ((weight === undefined) ? 1 : weight);
|
||||
}
|
||||
}
|
||||
|
||||
if (typename.indexOf("TH2") === 0) {
|
||||
m.getBin = function (x, y) {
|
||||
return (x + (this.fXaxis.fNbins + 2) * y);
|
||||
};
|
||||
m.getBinContent = function (x, y) {
|
||||
return this.fArray[this.getBin(x, y)];
|
||||
};
|
||||
m.Fill = function (x, y, weight) {
|
||||
var axis1 = this.fXaxis, axis2 = this.fYaxis,
|
||||
bin1 = 1 + Math.floor((x - axis1.fXmin) / (axis1.fXmax - axis1.fXmin) * axis1.fNbins),
|
||||
bin2 = 1 + Math.floor((y - axis2.fXmin) / (axis2.fXmax - axis2.fXmin) * axis2.fNbins);
|
||||
if (bin1 < 0) bin1 = 0; else if (bin1 > axis1.fNbins + 1) bin1 = axis1.fNbins + 1;
|
||||
if (bin2 < 0) bin2 = 0; else if (bin2 > axis2.fNbins + 1) bin2 = axis2.fNbins + 1;
|
||||
this.fArray[bin1 + (axis1.fNbins + 2) * bin2] += ((weight === undefined) ? 1 : weight);
|
||||
}
|
||||
}
|
||||
|
||||
if (typename.indexOf("TH3") === 0) {
|
||||
m.getBin = function (x, y, z) {
|
||||
return (x + (this.fXaxis.fNbins + 2) * (y + (this.fYaxis.fNbins + 2) * z));
|
||||
};
|
||||
m.getBinContent = function (x, y, z) {
|
||||
return this.fArray[this.getBin(x, y, z)];
|
||||
};
|
||||
m.Fill = function (x, y, z, weight) {
|
||||
var axis1 = this.fXaxis, axis2 = this.fYaxis, axis3 = this.fZaxis,
|
||||
bin1 = 1 + Math.floor((x - axis1.fXmin) / (axis1.fXmax - axis1.fXmin) * axis1.fNbins),
|
||||
bin2 = 1 + Math.floor((y - axis2.fXmin) / (axis2.fXmax - axis2.fXmin) * axis2.fNbins),
|
||||
bin3 = 1 + Math.floor((z - axis3.fXmin) / (axis3.fXmax - axis3.fXmin) * axis3.fNbins);
|
||||
if (bin1 < 0) bin1 = 0; else if (bin1 > axis1.fNbins + 1) bin1 = axis1.fNbins + 1;
|
||||
if (bin2 < 0) bin2 = 0; else if (bin2 > axis2.fNbins + 1) bin2 = axis2.fNbins + 1;
|
||||
if (bin3 < 0) bin3 = 0; else if (bin3 > axis3.fNbins + 1) bin3 = axis3.fNbins + 1;
|
||||
this.fArray[bin1 + (axis1.fNbins + 2) * (bin2 + (axis2.fNbins + 2) * bin3)] += ((weight === undefined) ? 1 : weight);
|
||||
}
|
||||
}
|
||||
|
||||
if (typename.indexOf("TProfile") === 0) {
|
||||
if (typename.indexOf("TProfile2D") === 0) {
|
||||
m.getBin = function (x, y) {
|
||||
return (x + (this.fXaxis.fNbins + 2) * y);
|
||||
};
|
||||
m.getBinContent = function (x, y) {
|
||||
var bin = this.getBin(x, y);
|
||||
if (bin < 0 || bin >= this.fNcells) return 0;
|
||||
if (this.fBinEntries[bin] < 1e-300) return 0;
|
||||
if (!this.fArray) return 0;
|
||||
return this.fArray[bin] / this.fBinEntries[bin];
|
||||
};
|
||||
m.getBinEntries = function (x, y) {
|
||||
var bin = this.getBin(x, y);
|
||||
if (bin < 0 || bin >= this.fNcells) return 0;
|
||||
return this.fBinEntries[bin];
|
||||
}
|
||||
} else {
|
||||
m.getBin = function (x) {
|
||||
return x;
|
||||
};
|
||||
m.getBinContent = function (bin) {
|
||||
if (bin < 0 || bin >= this.fNcells) return 0;
|
||||
if (this.fBinEntries[bin] < 1e-300) return 0;
|
||||
if (!this.fArray) return 0;
|
||||
return this.fArray[bin] / this.fBinEntries[bin];
|
||||
};
|
||||
}
|
||||
m.getBinEffectiveEntries = function (bin) {
|
||||
if (bin < 0 || bin >= this.fNcells) return 0;
|
||||
var sumOfWeights = this.fBinEntries[bin];
|
||||
if (!this.fBinSumw2 || this.fBinSumw2.length !== this.fNcells) {
|
||||
// this can happen when reading an old file
|
||||
return sumOfWeights;
|
||||
}
|
||||
var sumOfWeightsSquare = this.fBinSumw2[bin];
|
||||
return (sumOfWeightsSquare > 0) ? sumOfWeights * sumOfWeights / sumOfWeightsSquare : 0;
|
||||
};
|
||||
m.getBinError = function (bin) {
|
||||
if (bin < 0 || bin >= this.fNcells) return 0;
|
||||
var cont = this.fArray[bin], // sum of bin w *y
|
||||
sum = this.fBinEntries[bin], // sum of bin weights
|
||||
err2 = this.fSumw2[bin], // sum of bin w * y^2
|
||||
neff = this.getBinEffectiveEntries(bin); // (sum of w)^2 / (sum of w^2)
|
||||
if (sum < 1e-300) return 0; // for empty bins
|
||||
var EErrorType = {kERRORMEAN: 0, kERRORSPREAD: 1, kERRORSPREADI: 2, kERRORSPREADG: 3};
|
||||
// case the values y are gaussian distributed y +/- sigma and w = 1/sigma^2
|
||||
if (this.fErrorMode === EErrorType.kERRORSPREADG)
|
||||
return 1.0 / Math.sqrt(sum);
|
||||
// compute variance in y (eprim2) and standard deviation in y (eprim)
|
||||
var contsum = cont / sum, eprim = Math.sqrt(Math.abs(err2 / sum - contsum * contsum));
|
||||
if (this.fErrorMode === EErrorType.kERRORSPREADI) {
|
||||
if (eprim !== 0) return eprim / Math.sqrt(neff);
|
||||
// in case content y is an integer (so each my has an error +/- 1/sqrt(12)
|
||||
// when the std(y) is zero
|
||||
return 1.0 / Math.sqrt(12 * neff);
|
||||
}
|
||||
// if approximate compute the sums (of w, wy and wy2) using all the bins
|
||||
// when the variance in y is zero
|
||||
// case option "S" return standard deviation in y
|
||||
if (this.fErrorMode === EErrorType.kERRORSPREAD) return eprim;
|
||||
// default case : fErrorMode = kERRORMEAN
|
||||
// return standard error on the mean of y
|
||||
return (eprim / Math.sqrt(neff));
|
||||
};
|
||||
}
|
||||
|
||||
if (typename === "TAxis") {
|
||||
m.GetBinLowEdge = function (bin) {
|
||||
if (this.fNbins <= 0) return 0;
|
||||
if ((this.fXbins.length > 0) && (bin > 0) && (bin <= this.fNbins)) return this.fXbins[bin - 1];
|
||||
return this.fXmin + (bin - 1) * (this.fXmax - this.fXmin) / this.fNbins;
|
||||
};
|
||||
m.GetBinCenter = function (bin) {
|
||||
if (this.fNbins <= 0) return 0;
|
||||
if ((this.fXbins.length > 0) && (bin > 0) && (bin < this.fNbins)) return (this.fXbins[bin - 1] + this.fXbins[bin]) / 2;
|
||||
return this.fXmin + (bin - 0.5) * (this.fXmax - this.fXmin) / this.fNbins;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof getMoreMethods == "function")
|
||||
getMoreMethods(m, typename, obj);
|
||||
|
||||
methodsCache[typename] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/** @summary Adds specific methods to the object.
|
||||
*
|
||||
* JSROOT implements some basic methods for different ROOT classes.
|
||||
* @param {object} obj - object where methods are assigned
|
||||
* @param {string} typename - optional typename, if not specified, obj._typename will be used
|
||||
* @private
|
||||
*/
|
||||
function addMethods(obj, typename) {
|
||||
this.extend(obj, getMethods(typename || obj._typename, obj));
|
||||
}
|
869
dataforge-vis-jsroot/src/main/resources/ThreeCSG.js
vendored
869
dataforge-vis-jsroot/src/main/resources/ThreeCSG.js
vendored
@ -1,869 +0,0 @@
|
||||
import * as THREE from "three"
|
||||
|
||||
const EPSILON = 1e-5,
|
||||
COPLANAR = 0,
|
||||
FRONT = 1,
|
||||
BACK = 2,
|
||||
SPANNING = 3;
|
||||
|
||||
export function Geometry(geometry, transfer_matrix, nodeid, flippedMesh) {
|
||||
// Convert THREE.Geometry to ThreeBSP
|
||||
|
||||
if (geometry instanceof THREE.Geometry) {
|
||||
this.matrix = null; // new THREE.Matrix4; not create matrix when do not needed
|
||||
} else if (geometry instanceof THREE.Mesh) {
|
||||
// #todo: add hierarchy support
|
||||
geometry.updateMatrix();
|
||||
transfer_matrix = this.matrix = geometry.matrix.clone();
|
||||
geometry = geometry.geometry;
|
||||
} else if (geometry instanceof Node) {
|
||||
this.tree = geometry;
|
||||
this.matrix = null; // new THREE.Matrix4;
|
||||
return this;
|
||||
} else if (geometry instanceof THREE.BufferGeometry) {
|
||||
var pos_buf = geometry.getAttribute('position').array,
|
||||
norm_buf = geometry.getAttribute('normal').array,
|
||||
polygons = [], polygon, vert1, vert2, vert3;
|
||||
|
||||
for (var i = 0; i < pos_buf.length; i += 9) {
|
||||
polygon = new Polygon;
|
||||
|
||||
vert1 = new Vertex(pos_buf[i], pos_buf[i + 1], pos_buf[i + 2], norm_buf[i], norm_buf[i + 1], norm_buf[i + 2]);
|
||||
if (transfer_matrix) vert1.applyMatrix4(transfer_matrix);
|
||||
|
||||
vert2 = new Vertex(pos_buf[i + 3], pos_buf[i + 4], pos_buf[i + 5], norm_buf[i + 3], norm_buf[i + 4], norm_buf[i + 5]);
|
||||
if (transfer_matrix) vert2.applyMatrix4(transfer_matrix);
|
||||
|
||||
vert3 = new Vertex(pos_buf[i + 6], pos_buf[i + 7], pos_buf[i + 8], norm_buf[i + 6], norm_buf[i + 7], norm_buf[i + 8]);
|
||||
if (transfer_matrix) vert3.applyMatrix4(transfer_matrix);
|
||||
|
||||
if (flippedMesh) polygon.vertices.push(vert1, vert3, vert2);
|
||||
else polygon.vertices.push(vert1, vert2, vert3);
|
||||
|
||||
polygon.calculateProperties();
|
||||
polygons.push(polygon);
|
||||
}
|
||||
|
||||
this.tree = new Node(polygons, nodeid);
|
||||
if (nodeid !== undefined) this.maxid = this.tree.maxnodeid;
|
||||
return this;
|
||||
|
||||
} else if (geometry.polygons && (geometry.polygons[0] instanceof Polygon)) {
|
||||
var polygons = geometry.polygons;
|
||||
|
||||
for (var i = 0; i < polygons.length; ++i) {
|
||||
var polygon = polygons[i];
|
||||
if (transfer_matrix) {
|
||||
for (var n = 0; n < polygon.vertices.length; ++n)
|
||||
polygon.vertices[n].applyMatrix4(transfer_matrix);
|
||||
}
|
||||
|
||||
polygon.calculateProperties();
|
||||
}
|
||||
|
||||
this.tree = new Node(polygons, nodeid);
|
||||
if (nodeid !== undefined) this.maxid = this.tree.maxnodeid;
|
||||
return this;
|
||||
|
||||
} else {
|
||||
throw 'ThreeBSP: Given geometry is unsupported';
|
||||
}
|
||||
|
||||
var polygons = [],
|
||||
nfaces = geometry.faces.length,
|
||||
face, polygon, vertex;
|
||||
|
||||
for (var i = 0; i < nfaces; ++i) {
|
||||
face = geometry.faces[i];
|
||||
// faceVertexUvs = geometry.faceVertexUvs[0][i];
|
||||
polygon = new Polygon;
|
||||
|
||||
if (face instanceof THREE.Face3) {
|
||||
vertex = geometry.vertices[face.a];
|
||||
// uvs = faceVertexUvs ? new THREE.Vector2( faceVertexUvs[0].x, faceVertexUvs[0].y ) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[0].x, face.vertexNormals[0].y, face.vertexNormals[0].z /*face.normal , uvs */);
|
||||
if (transfer_matrix) vertex.applyMatrix4(transfer_matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
|
||||
vertex = geometry.vertices[face.b];
|
||||
//uvs = faceVertexUvs ? new THREE.Vector2( faceVertexUvs[1].x, faceVertexUvs[1].y ) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[1].x, face.vertexNormals[1].y, face.vertexNormals[1].z/*face.normal , uvs */);
|
||||
if (transfer_matrix) vertex.applyMatrix4(transfer_matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
|
||||
vertex = geometry.vertices[face.c];
|
||||
// uvs = faceVertexUvs ? new THREE.Vector2( faceVertexUvs[2].x, faceVertexUvs[2].y ) : null;
|
||||
vertex = new Vertex(vertex.x, vertex.y, vertex.z, face.vertexNormals[2].x, face.vertexNormals[2].y, face.vertexNormals[2].z /*face.normal, uvs */);
|
||||
if (transfer_matrix) vertex.applyMatrix4(transfer_matrix);
|
||||
polygon.vertices.push(vertex);
|
||||
} else {
|
||||
throw 'Invalid face type at index ' + i;
|
||||
}
|
||||
|
||||
polygon.calculateProperties();
|
||||
polygons.push(polygon);
|
||||
}
|
||||
|
||||
this.tree = new Node(polygons, nodeid);
|
||||
if (nodeid !== undefined) this.maxid = this.tree.maxnodeid;
|
||||
}
|
||||
|
||||
Geometry.prototype.subtract = function (other_tree) {
|
||||
var a = this.tree.clone(),
|
||||
b = other_tree.tree.clone();
|
||||
|
||||
a.invert();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.build(b.allPolygons());
|
||||
a.invert();
|
||||
a = new Geometry(a);
|
||||
a.matrix = this.matrix;
|
||||
return a;
|
||||
};
|
||||
|
||||
Geometry.prototype.union = function (other_tree) {
|
||||
var a = this.tree.clone(),
|
||||
b = other_tree.tree.clone();
|
||||
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.build(b.allPolygons());
|
||||
a = new Geometry(a);
|
||||
a.matrix = this.matrix;
|
||||
return a;
|
||||
};
|
||||
|
||||
Geometry.prototype.intersect = function (other_tree) {
|
||||
var a = this.tree.clone(),
|
||||
b = other_tree.tree.clone();
|
||||
|
||||
a.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
a.build(b.allPolygons());
|
||||
a.invert();
|
||||
a = new Geometry(a);
|
||||
a.matrix = this.matrix;
|
||||
return a;
|
||||
};
|
||||
|
||||
Geometry.prototype.tryToCompress = function (polygons) {
|
||||
|
||||
if (this.maxid === undefined) return;
|
||||
|
||||
var arr = [], parts, foundpair,
|
||||
nreduce = 0, n, len = polygons.length,
|
||||
p, p1, p2, i1, i2;
|
||||
|
||||
// sort out polygons
|
||||
for (n = 0; n < len; ++n) {
|
||||
p = polygons[n];
|
||||
if (p.id === undefined) continue;
|
||||
if (arr[p.id] === undefined) arr[p.id] = [];
|
||||
|
||||
arr[p.id].push(p);
|
||||
}
|
||||
|
||||
for (n = 0; n < arr.length; ++n) {
|
||||
parts = arr[n];
|
||||
if (parts === undefined) continue;
|
||||
|
||||
len = parts.length;
|
||||
|
||||
foundpair = (len > 1);
|
||||
|
||||
while (foundpair) {
|
||||
foundpair = false;
|
||||
|
||||
for (i1 = 0; i1 < len - 1; ++i1) {
|
||||
p1 = parts[i1];
|
||||
if (!p1 || !p1.parent) continue;
|
||||
for (i2 = i1 + 1; i2 < len; ++i2) {
|
||||
p2 = parts[i2];
|
||||
if (p2 && (p1.parent === p2.parent) && (p1.nsign === p2.nsign)) {
|
||||
|
||||
if (p1.nsign !== p1.parent.nsign) p1.parent.flip();
|
||||
|
||||
nreduce++;
|
||||
parts[i1] = p1.parent;
|
||||
parts[i2] = null;
|
||||
if (p1.parent.vertices.length < 3) console.log('something wrong with parent');
|
||||
foundpair = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nreduce > 0) {
|
||||
polygons.splice(0, polygons.length);
|
||||
|
||||
for (n = 0; n < arr.length; ++n) {
|
||||
parts = arr[n];
|
||||
if (parts !== undefined)
|
||||
for (i1 = 0, len = parts.length; i1 < len; ++i1)
|
||||
if (parts[i1]) polygons.push(parts[i1]);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Geometry.prototype.direct_subtract = function (other_tree) {
|
||||
var a = this.tree,
|
||||
b = other_tree.tree;
|
||||
a.invert();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.build(b.collectPolygons([]));
|
||||
a.invert();
|
||||
return this;
|
||||
};
|
||||
|
||||
Geometry.prototype.direct_union = function (other_tree) {
|
||||
var a = this.tree,
|
||||
b = other_tree.tree;
|
||||
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.build(b.collectPolygons([]));
|
||||
return this;
|
||||
};
|
||||
|
||||
Geometry.prototype.direct_intersect = function (other_tree) {
|
||||
var a = this.tree,
|
||||
b = other_tree.tree;
|
||||
|
||||
a.invert();
|
||||
b.clipTo(a);
|
||||
b.invert();
|
||||
a.clipTo(b);
|
||||
b.clipTo(a);
|
||||
a.build(b.collectPolygons([]));
|
||||
a.invert();
|
||||
return this;
|
||||
};
|
||||
|
||||
export function CreateNormal(axis_name, pos, size) {
|
||||
// create geometry to make cut on specified axis
|
||||
|
||||
var vert1, vert2, vert3;
|
||||
|
||||
if (!size || (size < 10000)) size = 10000;
|
||||
|
||||
switch (axis_name) {
|
||||
case "x":
|
||||
vert1 = new Vertex(pos, -3 * size, size, 1, 0, 0),
|
||||
vert3 = new Vertex(pos, size, size, 1, 0, 0),
|
||||
vert2 = new Vertex(pos, size, -3 * size, 1, 0, 0);
|
||||
break;
|
||||
case "y":
|
||||
vert1 = new Vertex(-3 * size, pos, size, 0, 1, 0),
|
||||
vert2 = new Vertex(size, pos, size, 0, 1, 0),
|
||||
vert3 = new Vertex(size, pos, -3 * size, 0, 1, 0);
|
||||
break;
|
||||
case "z":
|
||||
vert1 = new Vertex(-3 * size, size, pos, 0, 0, 1),
|
||||
vert3 = new Vertex(size, size, pos, 0, 0, 1),
|
||||
vert2 = new Vertex(size, -3 * size, pos, 0, 0, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
var polygon = new Polygon([vert1, vert2, vert3]);
|
||||
polygon.calculateProperties();
|
||||
|
||||
var node = new Node([polygon]);
|
||||
|
||||
return new Geometry(node);
|
||||
}
|
||||
|
||||
Geometry.prototype.cut_from_plane = function (other_tree) {
|
||||
// just cut peaces from second geometry, which just simple plane
|
||||
|
||||
var a = this.tree,
|
||||
b = other_tree.tree;
|
||||
|
||||
a.invert();
|
||||
b.clipTo(a);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Geometry.prototype.toGeometry = function () {
|
||||
var i, j,
|
||||
matrix = this.matrix ? new THREE.Matrix4().getInverse(this.matrix) : null,
|
||||
geometry = new THREE.Geometry(),
|
||||
polygons = this.tree.collectPolygons([]),
|
||||
polygon_count = polygons.length,
|
||||
polygon, polygon_vertice_count,
|
||||
vertice_dict = {},
|
||||
vertex_idx_a, vertex_idx_b, vertex_idx_c,
|
||||
vertex, face;
|
||||
|
||||
for (i = 0; i < polygon_count; ++i) {
|
||||
polygon = polygons[i];
|
||||
polygon_vertice_count = polygon.vertices.length;
|
||||
|
||||
for (j = 2; j < polygon_vertice_count; ++j) {
|
||||
// verticeUvs = [];
|
||||
|
||||
vertex = polygon.vertices[0];
|
||||
// verticeUvs.push( new THREE.Vector2( vertex.uv.x, vertex.uv.y ) );
|
||||
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
|
||||
if (matrix) vertex.applyMatrix4(matrix);
|
||||
|
||||
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined') {
|
||||
vertex_idx_a = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z];
|
||||
} else {
|
||||
geometry.vertices.push(vertex);
|
||||
vertex_idx_a = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
|
||||
}
|
||||
|
||||
vertex = polygon.vertices[j - 1];
|
||||
// verticeUvs.push( new THREE.Vector2( vertex.uv.x, vertex.uv.y ) );
|
||||
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
|
||||
if (matrix) vertex.applyMatrix4(matrix);
|
||||
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined') {
|
||||
vertex_idx_b = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z];
|
||||
} else {
|
||||
geometry.vertices.push(vertex);
|
||||
vertex_idx_b = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
|
||||
}
|
||||
|
||||
vertex = polygon.vertices[j];
|
||||
// verticeUvs.push( new THREE.Vector2( vertex.uv.x, vertex.uv.y ) );
|
||||
vertex = new THREE.Vector3(vertex.x, vertex.y, vertex.z);
|
||||
if (matrix) vertex.applyMatrix4(matrix);
|
||||
if (typeof vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] !== 'undefined') {
|
||||
vertex_idx_c = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z];
|
||||
} else {
|
||||
geometry.vertices.push(vertex);
|
||||
vertex_idx_c = vertice_dict[vertex.x + ',' + vertex.y + ',' + vertex.z] = geometry.vertices.length - 1;
|
||||
}
|
||||
|
||||
face = new THREE.Face3(
|
||||
vertex_idx_a,
|
||||
vertex_idx_b,
|
||||
vertex_idx_c,
|
||||
new THREE.Vector3(polygon.normal.x, polygon.normal.y, polygon.normal.z)
|
||||
);
|
||||
|
||||
geometry.faces.push(face);
|
||||
// geometry.faceVertexUvs[0].push( verticeUvs );
|
||||
}
|
||||
|
||||
}
|
||||
return geometry;
|
||||
};
|
||||
|
||||
Geometry.prototype.scale = function (x, y, z) {
|
||||
// try to scale as THREE.BufferGeometry
|
||||
var polygons = this.tree.collectPolygons([]);
|
||||
|
||||
for (var i = 0; i < polygons.length; ++i) {
|
||||
var polygon = polygons[i];
|
||||
for (var k = 0; k < polygon.vertices.length; ++k) {
|
||||
var v = polygon.vertices[k];
|
||||
v.x *= x;
|
||||
v.y *= y;
|
||||
v.z *= z;
|
||||
}
|
||||
delete polygon.normal;
|
||||
polygon.calculateProperties();
|
||||
}
|
||||
};
|
||||
|
||||
Geometry.prototype.toPolygons = function () {
|
||||
var polygons = this.tree.collectPolygons([]);
|
||||
|
||||
this.tryToCompress(polygons);
|
||||
|
||||
for (var i = 0; i < polygons.length; ++i) {
|
||||
delete polygons[i].id;
|
||||
delete polygons[i].parent;
|
||||
}
|
||||
|
||||
return polygons;
|
||||
};
|
||||
|
||||
Geometry.prototype.toBufferGeometry = function () {
|
||||
return CreateBufferGeometry(this.toPolygons());
|
||||
};
|
||||
|
||||
export function CreateBufferGeometry(polygons) {
|
||||
var i, j, polygon_count = polygons.length, buf_size = 0;
|
||||
|
||||
for (i = 0; i < polygon_count; ++i)
|
||||
buf_size += (polygons[i].vertices.length - 2) * 9;
|
||||
|
||||
var positions_buf = new Float32Array(buf_size),
|
||||
normals_buf = new Float32Array(buf_size),
|
||||
iii = 0, polygon;
|
||||
|
||||
function CopyVertex(vertex) {
|
||||
|
||||
positions_buf[iii] = vertex.x;
|
||||
positions_buf[iii + 1] = vertex.y;
|
||||
positions_buf[iii + 2] = vertex.z;
|
||||
|
||||
normals_buf[iii] = polygon.nsign * vertex.nx;
|
||||
normals_buf[iii + 1] = polygon.nsign * vertex.ny;
|
||||
normals_buf[iii + 2] = polygon.nsign * vertex.nz;
|
||||
iii += 3;
|
||||
}
|
||||
|
||||
for (i = 0; i < polygon_count; ++i) {
|
||||
polygon = polygons[i];
|
||||
for (j = 2; j < polygon.vertices.length; ++j) {
|
||||
CopyVertex(polygon.vertices[0]);
|
||||
CopyVertex(polygon.vertices[j - 1]);
|
||||
CopyVertex(polygon.vertices[j]);
|
||||
}
|
||||
}
|
||||
|
||||
var geometry = new THREE.BufferGeometry();
|
||||
geometry.addAttribute('position', new THREE.BufferAttribute(positions_buf, 3));
|
||||
geometry.addAttribute('normal', new THREE.BufferAttribute(normals_buf, 3));
|
||||
|
||||
// geometry.computeVertexNormals();
|
||||
return geometry;
|
||||
}
|
||||
|
||||
Geometry.prototype.toMesh = function (material) {
|
||||
var geometry = this.toGeometry(),
|
||||
mesh = new THREE.Mesh(geometry, material);
|
||||
|
||||
if (this.matrix) {
|
||||
mesh.position.setFromMatrixPosition(this.matrix);
|
||||
mesh.rotation.setFromRotationMatrix(this.matrix);
|
||||
}
|
||||
|
||||
return mesh;
|
||||
};
|
||||
|
||||
export class Polygon {
|
||||
constructor(vertices, normal, w) {
|
||||
if (!(vertices instanceof Array)) {
|
||||
vertices = [];
|
||||
}
|
||||
|
||||
this.vertices = vertices;
|
||||
this.nsign = 1;
|
||||
if (vertices.length > 0) {
|
||||
this.calculateProperties();
|
||||
} else {
|
||||
this.normal = this.w = undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Polygon.prototype.copyProperties = function (parent, more) {
|
||||
this.normal = parent.normal; // .clone();
|
||||
this.w = parent.w;
|
||||
this.nsign = parent.nsign;
|
||||
if (more && (parent.id !== undefined)) {
|
||||
this.id = parent.id;
|
||||
this.parent = parent;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Polygon.prototype.calculateProperties = function () {
|
||||
if (this.normal) return;
|
||||
|
||||
var a = this.vertices[0],
|
||||
b = this.vertices[1],
|
||||
c = this.vertices[2];
|
||||
|
||||
this.nsign = 1;
|
||||
|
||||
this.normal = b.clone().subtract(a).cross(
|
||||
c.clone().subtract(a)
|
||||
).normalize();
|
||||
|
||||
this.w = this.normal.clone().dot(a);
|
||||
return this;
|
||||
};
|
||||
|
||||
Polygon.prototype.clone = function () {
|
||||
var vertice_count = this.vertices.length,
|
||||
polygon = new Polygon;
|
||||
|
||||
for (var i = 0; i < vertice_count; ++i)
|
||||
polygon.vertices.push(this.vertices[i].clone());
|
||||
|
||||
return polygon.copyProperties(this);
|
||||
};
|
||||
|
||||
Polygon.prototype.flip = function () {
|
||||
|
||||
/// normal is not changed, only sign variable
|
||||
//this.normal.multiplyScalar( -1 );
|
||||
//this.w *= -1;
|
||||
|
||||
this.nsign *= -1;
|
||||
|
||||
this.vertices.reverse();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Polygon.prototype.classifyVertex = function (vertex) {
|
||||
var side_value = this.nsign * (this.normal.dot(vertex) - this.w);
|
||||
|
||||
if (side_value < -EPSILON) return BACK;
|
||||
if (side_value > EPSILON) return FRONT;
|
||||
return COPLANAR;
|
||||
};
|
||||
|
||||
Polygon.prototype.classifySide = function (polygon) {
|
||||
var i, classification,
|
||||
num_positive = 0, num_negative = 0,
|
||||
vertice_count = polygon.vertices.length;
|
||||
|
||||
for (i = 0; i < vertice_count; ++i) {
|
||||
classification = this.classifyVertex(polygon.vertices[i]);
|
||||
if (classification === FRONT) {
|
||||
++num_positive;
|
||||
} else if (classification === BACK) {
|
||||
++num_negative;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_positive > 0 && num_negative === 0) return FRONT;
|
||||
if (num_positive === 0 && num_negative > 0) return BACK;
|
||||
if (num_positive === 0 && num_negative === 0) return COPLANAR;
|
||||
return SPANNING;
|
||||
};
|
||||
|
||||
Polygon.prototype.splitPolygon = function (polygon, coplanar_front, coplanar_back, front, back) {
|
||||
var classification = this.classifySide(polygon);
|
||||
|
||||
if (classification === COPLANAR) {
|
||||
|
||||
((this.nsign * polygon.nsign * this.normal.dot(polygon.normal) > 0) ? coplanar_front : coplanar_back).push(polygon);
|
||||
|
||||
} else if (classification === FRONT) {
|
||||
|
||||
front.push(polygon);
|
||||
|
||||
} else if (classification === BACK) {
|
||||
|
||||
back.push(polygon);
|
||||
|
||||
} else {
|
||||
|
||||
var vertice_count = polygon.vertices.length,
|
||||
nnx = this.normal.x,
|
||||
nny = this.normal.y,
|
||||
nnz = this.normal.z,
|
||||
i, j, ti, tj, vi, vj,
|
||||
t, v,
|
||||
f = [], b = [];
|
||||
|
||||
for (i = 0; i < vertice_count; ++i) {
|
||||
|
||||
j = (i + 1) % vertice_count;
|
||||
vi = polygon.vertices[i];
|
||||
vj = polygon.vertices[j];
|
||||
ti = this.classifyVertex(vi);
|
||||
tj = this.classifyVertex(vj);
|
||||
|
||||
if (ti != BACK) f.push(vi);
|
||||
if (ti != FRONT) b.push(vi);
|
||||
if ((ti | tj) === SPANNING) {
|
||||
// t = ( this.w - this.normal.dot( vi ) ) / this.normal.dot( vj.clone().subtract( vi ) );
|
||||
//v = vi.clone().lerp( vj, t );
|
||||
|
||||
t = (this.w - (nnx * vi.x + nny * vi.y + nnz * vi.z)) / (nnx * (vj.x - vi.x) + nny * (vj.y - vi.y) + nnz * (vj.z - vi.z));
|
||||
|
||||
v = vi.interpolate(vj, t);
|
||||
f.push(v);
|
||||
b.push(v);
|
||||
}
|
||||
}
|
||||
|
||||
//if ( f.length >= 3 ) front.push( new Polygon( f ).calculateProperties() );
|
||||
//if ( b.length >= 3 ) back.push( new Polygon( b ).calculateProperties() );
|
||||
if (f.length >= 3) front.push(new Polygon(f).copyProperties(polygon, true));
|
||||
if (b.length >= 3) back.push(new Polygon(b).copyProperties(polygon, true));
|
||||
}
|
||||
};
|
||||
|
||||
export class Vertex {
|
||||
constructor(x, y, z, nx, ny, nz) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.nx = nx;
|
||||
this.ny = ny;
|
||||
this.nz = nz;
|
||||
};
|
||||
}
|
||||
|
||||
Vertex.prototype.setnormal = function (nx, ny, nz) {
|
||||
this.nx = nx;
|
||||
this.ny = ny;
|
||||
this.nz = nz;
|
||||
};
|
||||
|
||||
Vertex.prototype.clone = function () {
|
||||
return new Vertex(this.x, this.y, this.z, this.nx, this.ny, this.nz);
|
||||
};
|
||||
|
||||
Vertex.prototype.add = function (vertex) {
|
||||
this.x += vertex.x;
|
||||
this.y += vertex.y;
|
||||
this.z += vertex.z;
|
||||
return this;
|
||||
};
|
||||
|
||||
Vertex.prototype.subtract = function (vertex) {
|
||||
this.x -= vertex.x;
|
||||
this.y -= vertex.y;
|
||||
this.z -= vertex.z;
|
||||
return this;
|
||||
};
|
||||
|
||||
Vertex.prototype.multiplyScalar = function (scalar) {
|
||||
this.x *= scalar;
|
||||
this.y *= scalar;
|
||||
this.z *= scalar;
|
||||
return this;
|
||||
};
|
||||
|
||||
Vertex.prototype.cross = function (vertex) {
|
||||
var x = this.x,
|
||||
y = this.y,
|
||||
z = this.z;
|
||||
|
||||
this.x = y * vertex.z - z * vertex.y;
|
||||
this.y = z * vertex.x - x * vertex.z;
|
||||
this.z = x * vertex.y - y * vertex.x;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Vertex.prototype.normalize = function () {
|
||||
var length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
|
||||
|
||||
this.x /= length;
|
||||
this.y /= length;
|
||||
this.z /= length;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Vertex.prototype.dot = function (vertex) {
|
||||
return this.x * vertex.x + this.y * vertex.y + this.z * vertex.z;
|
||||
};
|
||||
|
||||
Vertex.prototype.diff = function (vertex) {
|
||||
var dx = (this.x - vertex.x),
|
||||
dy = (this.y - vertex.y),
|
||||
dz = (this.z - vertex.z),
|
||||
len2 = this.x * this.x + this.y * this.y + this.z * this.z;
|
||||
|
||||
return (dx * dx + dy * dy + dz * dz) / (len2 > 0 ? len2 : 1e-10);
|
||||
};
|
||||
|
||||
/*
|
||||
Vertex.prototype.lerp = function( a, t ) {
|
||||
this.add(
|
||||
a.clone().subtract( this ).multiplyScalar( t )
|
||||
);
|
||||
|
||||
this.normal.add(
|
||||
a.normal.clone().sub( this.normal ).multiplyScalar( t )
|
||||
);
|
||||
|
||||
//this.uv.add(
|
||||
// a.uv.clone().sub( this.uv ).multiplyScalar( t )
|
||||
//);
|
||||
|
||||
return this;
|
||||
};
|
||||
Vertex.prototype.interpolate = function( other, t ) {
|
||||
return this.clone().lerp( other, t );
|
||||
};
|
||||
*/
|
||||
|
||||
Vertex.prototype.interpolate = function (a, t) {
|
||||
var t1 = 1 - t;
|
||||
return new Vertex(this.x * t1 + a.x * t, this.y * t1 + a.y * t, this.z * t1 + a.z * t,
|
||||
this.nx * t1 + a.nx * t, this.ny * t1 + a.ny * t, this.nz * t1 + a.nz * t);
|
||||
};
|
||||
|
||||
Vertex.prototype.applyMatrix4 = function (m) {
|
||||
|
||||
// input: THREE.Matrix4 affine matrix
|
||||
|
||||
var x = this.x, y = this.y, z = this.z, e = m.elements;
|
||||
|
||||
this.x = e[0] * x + e[4] * y + e[8] * z + e[12];
|
||||
this.y = e[1] * x + e[5] * y + e[9] * z + e[13];
|
||||
this.z = e[2] * x + e[6] * y + e[10] * z + e[14];
|
||||
|
||||
x = this.nx;
|
||||
y = this.ny;
|
||||
z = this.nz;
|
||||
|
||||
this.nx = e[0] * x + e[4] * y + e[8] * z;
|
||||
this.ny = e[1] * x + e[5] * y + e[9] * z;
|
||||
this.nz = e[2] * x + e[6] * y + e[10] * z;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// ================================================================================================
|
||||
|
||||
export class Node {
|
||||
constructor(polygons, nodeid) {
|
||||
this.polygons = [];
|
||||
this.front = this.back = undefined;
|
||||
|
||||
if (!(polygons instanceof Array) || polygons.length === 0) return;
|
||||
|
||||
this.divider = polygons[0].clone();
|
||||
|
||||
var polygon_count = polygons.length,
|
||||
front = [], back = [];
|
||||
|
||||
for (var i = 0; i < polygon_count; ++i) {
|
||||
if (nodeid !== undefined) {
|
||||
polygons[i].id = nodeid++;
|
||||
delete polygons[i].parent;
|
||||
}
|
||||
|
||||
this.divider.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
|
||||
}
|
||||
|
||||
if (nodeid !== undefined) this.maxnodeid = nodeid;
|
||||
|
||||
if (front.length > 0)
|
||||
this.front = new Node(front);
|
||||
|
||||
if (back.length > 0)
|
||||
this.back = new Node(back);
|
||||
};
|
||||
}
|
||||
|
||||
Node.isConvex = function (polygons) {
|
||||
var i, j, len = polygons.length;
|
||||
for (i = 0; i < len; ++i)
|
||||
for (j = 0; j < len; ++j)
|
||||
if (i !== j && polygons[i].classifySide(polygons[j]) !== BACK) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
Node.prototype.build = function (polygons) {
|
||||
var polygon_count = polygons.length,
|
||||
front = [], back = [];
|
||||
|
||||
if (!this.divider)
|
||||
this.divider = polygons[0].clone();
|
||||
|
||||
for (var i = 0; i < polygon_count; ++i)
|
||||
this.divider.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
|
||||
|
||||
if (front.length > 0) {
|
||||
if (!this.front) this.front = new Node();
|
||||
this.front.build(front);
|
||||
}
|
||||
|
||||
if (back.length > 0) {
|
||||
if (!this.back) this.back = new Node();
|
||||
this.back.build(back);
|
||||
}
|
||||
};
|
||||
|
||||
Node.prototype.collectPolygons = function (arr) {
|
||||
var len = this.polygons.length;
|
||||
for (var i = 0; i < len; ++i) arr.push(this.polygons[i]);
|
||||
if (this.front) this.front.collectPolygons(arr);
|
||||
if (this.back) this.back.collectPolygons(arr);
|
||||
return arr;
|
||||
};
|
||||
|
||||
Node.prototype.allPolygons = function () {
|
||||
var polygons = this.polygons.slice();
|
||||
if (this.front) polygons = polygons.concat(this.front.allPolygons());
|
||||
if (this.back) polygons = polygons.concat(this.back.allPolygons());
|
||||
return polygons;
|
||||
};
|
||||
|
||||
Node.prototype.numPolygons = function () {
|
||||
var res = this.polygons.length;
|
||||
if (this.front) res += this.front.numPolygons();
|
||||
if (this.back) res += this.back.numPolygons();
|
||||
return res;
|
||||
};
|
||||
|
||||
Node.prototype.clone = function () {
|
||||
var node = new Node();
|
||||
|
||||
node.divider = this.divider.clone();
|
||||
node.polygons = this.polygons.map(function (polygon) {
|
||||
return polygon.clone();
|
||||
});
|
||||
node.front = this.front && this.front.clone();
|
||||
node.back = this.back && this.back.clone();
|
||||
|
||||
return node;
|
||||
};
|
||||
|
||||
Node.prototype.invert = function () {
|
||||
var polygon_count = this.polygons.length;
|
||||
|
||||
for (var i = 0; i < polygon_count; ++i)
|
||||
this.polygons[i].flip();
|
||||
|
||||
this.divider.flip();
|
||||
if (this.front) this.front.invert();
|
||||
if (this.back) this.back.invert();
|
||||
|
||||
var temp = this.front;
|
||||
this.front = this.back;
|
||||
this.back = temp;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.clipPolygons = function (polygons) {
|
||||
|
||||
if (!this.divider) return polygons.slice();
|
||||
|
||||
var polygon_count = polygons.length, front = [], back = [];
|
||||
|
||||
for (var i = 0; i < polygon_count; ++i)
|
||||
this.divider.splitPolygon(polygons[i], front, back, front, back);
|
||||
|
||||
if (this.front) front = this.front.clipPolygons(front);
|
||||
if (this.back) back = this.back.clipPolygons(back);
|
||||
else back = [];
|
||||
|
||||
return front.concat(back);
|
||||
};
|
||||
|
||||
Node.prototype.clipTo = function (node) {
|
||||
this.polygons = node.clipPolygons(this.polygons);
|
||||
if (this.front) this.front.clipTo(node);
|
||||
if (this.back) this.back.clipTo(node);
|
||||
};
|
@ -1,33 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>Three js demo for particle physics</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
<script type="text/javascript" src="visionforge-spatial-gdml-0.1.0-dev.js"></script>
|
||||
</head>
|
||||
<body class="application">
|
||||
<div class="container" id="drop_zone" data-toggle="tooltip" data-placement="right"
|
||||
title="Для загрузки данных в текстовом формате, надо перетащить файл сюда">
|
||||
Загрузить данные
|
||||
<br/>
|
||||
(перетащить файл сюда)
|
||||
</div>
|
||||
<div class="container">
|
||||
<h1>Demo grid</h1>
|
||||
</div>
|
||||
<div class="container" id="canvas"></div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
||||
crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
4
demo/README.md
Normal file
4
demo/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Module demo
|
||||
|
||||
|
||||
|
@ -1,15 +1,4 @@
|
||||
# Module gdml
|
||||
|
||||
### GDML Example
|
||||
|
||||
Visualization example for geometry defined as GDML file.
|
||||
|
||||
##### Building project
|
||||
|
||||
To build the app, run `demo/gdml/Tasks/distribution/jsBrowserDistribution` Gradle task, then open
|
||||
`demo/gdml/build/distribuions/gdml-js-0.1.3-dev/index.html` file in your browser, and
|
||||
drag-and-drop GDML file to the window to see visualization. For an example file, you can use
|
||||
`demo/gdml/src/jsMain/resources/cubes.gdml`.
|
||||
|
||||
##### Example view:
|
||||
|
||||
![](../../doc/resources/gdml-demo.png)
|
||||
|
27
demo/gdml/api/gdml.api
Normal file
27
demo/gdml/api/gdml.api
Normal file
@ -0,0 +1,27 @@
|
||||
public final class space/kscience/visionforge/gdml/demo/GDMLDemoApp : tornadofx/App {
|
||||
public fun <init> ()V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/gdml/demo/GDMLView : tornadofx/View {
|
||||
public static final field Companion Lspace/kscience/visionforge/gdml/demo/GDMLView$Companion;
|
||||
public fun <init> ()V
|
||||
public fun getRoot ()Ljavafx/scene/Parent;
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/gdml/demo/GDMLView$Companion {
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/gdml/demo/GdmlFxDemoAppKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/gdml/demo/ReadFileKt {
|
||||
public static final fun readFile (Lspace/kscience/visionforge/VisionManager;Ljava/io/File;)Lspace/kscience/visionforge/Vision;
|
||||
public static final fun readFile (Lspace/kscience/visionforge/VisionManager;Ljava/lang/String;)Lspace/kscience/visionforge/Vision;
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/gdml/demo/SaveToJsonKt {
|
||||
public static final fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
@ -1,23 +1,29 @@
|
||||
import scientifik.DependencyConfiguration
|
||||
import scientifik.FXModule
|
||||
import scientifik.useFx
|
||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
||||
import ru.mipt.npm.gradle.FXModule
|
||||
|
||||
plugins {
|
||||
id("scientifik.mpp")
|
||||
id("application")
|
||||
id("ru.mipt.npm.gradle.mpp")
|
||||
application
|
||||
}
|
||||
|
||||
val fxVersion: String by rootProject.extra
|
||||
useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION)
|
||||
kscience {
|
||||
val fxVersion: String by rootProject.extra
|
||||
useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION)
|
||||
application()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
|
||||
js {
|
||||
useCommonJs()
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@ -27,9 +33,16 @@ kotlin {
|
||||
implementation(project(":visionforge-gdml"))
|
||||
}
|
||||
}
|
||||
jsMain{
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation(project(":ui:bootstrap"))
|
||||
implementation(project(":visionforge-fx"))
|
||||
implementation("ch.qos.logback:logback-classic:1.2.5")
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation(project(":ui:ring"))
|
||||
implementation(project(":visionforge-threejs"))
|
||||
implementation(npm("react-file-drop", "3.0.6"))
|
||||
}
|
||||
}
|
||||
@ -37,11 +50,11 @@ kotlin {
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "hep.dataforge.vision.gdml.demo.GDMLDemoAppKt"
|
||||
mainClass.set("space.kscience.visionforge.gdml.demo.GdmlFxDemoAppKt")
|
||||
}
|
||||
|
||||
val convertGdmlToJson by tasks.creating(JavaExec::class) {
|
||||
group = "application"
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
main = "hep.dataforge.vis.spatial.gdml.demo.SaveToJsonKt"
|
||||
mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt")
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
|
||||
import scientifik.gdml.*
|
||||
|
||||
|
||||
fun cubes(): GDML = GDML {
|
||||
val center = define.position("center")
|
||||
structure {
|
||||
val air = ref<GDMLMaterial>("G4_AIR")
|
||||
val tubeMaterial = ref<GDMLMaterial>("tube")
|
||||
val boxMaterial = ref<GDMLMaterial>("box")
|
||||
val segment = solids.tube("segment", 20, 5.0) {
|
||||
rmin = 17
|
||||
deltaphi = 60
|
||||
aunit = AUnit.DEG.title
|
||||
}
|
||||
val worldBox = solids.box("LargeBox", 200, 200, 200)
|
||||
val smallBox = solids.box("smallBox", 30, 30, 30)
|
||||
val segmentVolume = volume("segment", tubeMaterial, segment.ref()) {}
|
||||
val circle = volume("composite", boxMaterial, smallBox.ref()) {
|
||||
for (i in 0 until 6) {
|
||||
physVolume(segmentVolume) {
|
||||
name = "segment$i"
|
||||
positionref = center.ref()
|
||||
rotation {
|
||||
z = 60 * i
|
||||
unit = AUnit.DEG.title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
world = volume("world", air, worldBox.ref()) {
|
||||
for (i in 0 until 3) {
|
||||
for (j in 0 until 3) {
|
||||
for (k in 0 until 3) {
|
||||
physVolume(circle) {
|
||||
name = "composite$i$j$k"
|
||||
position {
|
||||
x = (-50 + i * 50)
|
||||
y = (-50 + j * 50)
|
||||
z = (-50 + k * 50)
|
||||
}
|
||||
rotation {
|
||||
x = i * 120
|
||||
y = j * 120
|
||||
z = 120 * k
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package hep.dataforge.vision.gdml
|
||||
|
||||
import hep.dataforge.meta.setItem
|
||||
import hep.dataforge.meta.string
|
||||
import hep.dataforge.names.toName
|
||||
import hep.dataforge.values.asValue
|
||||
import hep.dataforge.vision.gdml.demo.cubes
|
||||
import hep.dataforge.vision.solid.SolidMaterial
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class GDMLVisualTest {
|
||||
@Test
|
||||
fun testPrototypeProperty() {
|
||||
val gdml = cubes()
|
||||
val visual = gdml.toVision()
|
||||
visual["composite000.segment0".toName()]?.setItem(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue())
|
||||
assertEquals("red", visual["composite000.segment0".toName()]?.getItem(SolidMaterial.MATERIAL_COLOR_KEY).string)
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package space.kscience.visionforge.gdml
|
||||
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.dataforge.values.asValue
|
||||
import space.kscience.dataforge.values.string
|
||||
import space.kscience.gdml.GdmlShowCase
|
||||
import space.kscience.visionforge.Vision
|
||||
import space.kscience.visionforge.computeProperties
|
||||
import space.kscience.visionforge.get
|
||||
import space.kscience.visionforge.setProperty
|
||||
import space.kscience.visionforge.solid.Solid
|
||||
import space.kscience.visionforge.solid.SolidMaterial
|
||||
import space.kscience.visionforge.solid.material
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class GDMLVisionTest {
|
||||
private val cubes = GdmlShowCase.cubes().toVision()
|
||||
|
||||
@Test
|
||||
fun testCubesStyles(){
|
||||
val segment = cubes["composite-000.segment-0"] as Solid
|
||||
println(segment.computeProperties().getValue(Vision.STYLE_KEY))
|
||||
// println(segment.computePropertyNode(SolidMaterial.MATERIAL_KEY))
|
||||
// println(segment.computeProperty(SolidMaterial.MATERIAL_COLOR_KEY))
|
||||
|
||||
println(segment.material?.meta)
|
||||
|
||||
//println(Solids.encodeToString(cubes))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testPrototypeProperty() {
|
||||
val child = cubes[Name.of("composite-000","segment-0")]
|
||||
assertNotNull(child)
|
||||
child.setProperty(SolidMaterial.MATERIAL_COLOR_KEY, "red".asValue())
|
||||
assertEquals("red", child.getPropertyValue(SolidMaterial.MATERIAL_COLOR_KEY)?.string)
|
||||
}
|
||||
}
|
@ -5,7 +5,9 @@ package drop
|
||||
|
||||
import org.w3c.dom.DragEvent
|
||||
import org.w3c.files.FileList
|
||||
import react.*
|
||||
import react.Component
|
||||
import react.Props
|
||||
import react.State
|
||||
|
||||
external enum class DropEffects {
|
||||
copy,
|
||||
@ -14,7 +16,7 @@ external enum class DropEffects {
|
||||
none
|
||||
}
|
||||
|
||||
external interface FileDropProps: RProps {
|
||||
external interface FileDropProps: Props {
|
||||
var className: String?
|
||||
var targetClassName: String?
|
||||
var draggingOverFrameClassName: String?
|
||||
@ -30,7 +32,7 @@ external interface FileDropProps: RProps {
|
||||
var dropEffect: DropEffects?
|
||||
}
|
||||
|
||||
external interface FileDropState: RState {
|
||||
external interface FileDropState: State {
|
||||
var draggingOverFrame: Boolean
|
||||
var draggingOverTarget: Boolean
|
||||
}
|
||||
|
@ -1,154 +0,0 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.isEmpty
|
||||
import hep.dataforge.vision.Vision
|
||||
import hep.dataforge.vision.VisionGroup
|
||||
import hep.dataforge.vision.bootstrap.*
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.react.component
|
||||
import hep.dataforge.vision.react.configEditor
|
||||
import hep.dataforge.vision.react.flexColumn
|
||||
import hep.dataforge.vision.react.state
|
||||
import hep.dataforge.vision.solid.Solid
|
||||
import hep.dataforge.vision.solid.SolidGroup
|
||||
import hep.dataforge.vision.solid.specifications.Camera
|
||||
import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvas
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvasComponent
|
||||
import hep.dataforge.vision.solid.three.canvasControls
|
||||
import kotlinx.css.FlexBasis
|
||||
import kotlinx.css.Overflow
|
||||
import kotlinx.css.flex
|
||||
import kotlinx.css.overflow
|
||||
import org.w3c.files.FileReader
|
||||
import org.w3c.files.get
|
||||
import react.RProps
|
||||
import react.dom.h1
|
||||
import scientifik.gdml.GDML
|
||||
import scientifik.gdml.parse
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
import kotlin.browser.window
|
||||
import kotlin.math.PI
|
||||
|
||||
interface GDMLAppProps : RProps {
|
||||
var context: Context
|
||||
var rootObject: Vision?
|
||||
var selected: Name?
|
||||
}
|
||||
|
||||
private val canvasConfig = Canvas3DOptions {
|
||||
camera = Camera {
|
||||
distance = 2100.0
|
||||
latitude = PI / 6
|
||||
azimuth = PI + PI / 6
|
||||
}
|
||||
}
|
||||
|
||||
val GDMLApp = component<GDMLAppProps> { props ->
|
||||
var selected by state { props.selected }
|
||||
var canvas: ThreeCanvas? by state { null }
|
||||
var visual: Vision? by state { props.rootObject }
|
||||
|
||||
val select: (Name?) -> Unit = {
|
||||
selected = it
|
||||
}
|
||||
|
||||
fun loadData(name: String, data: String) {
|
||||
visual = when {
|
||||
name.endsWith(".gdml") || name.endsWith(".xml") -> {
|
||||
val gdml = GDML.parse(data)
|
||||
gdml.toVision(gdmlConfiguration)
|
||||
}
|
||||
name.endsWith(".json") -> SolidGroup.parseJson(data)
|
||||
else -> {
|
||||
window.alert("File extension is not recognized: $name")
|
||||
error("File extension is not recognized: $name")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flexColumn {
|
||||
css {
|
||||
flex(1.0, 1.0, FlexBasis.auto)
|
||||
}
|
||||
h1 { +"GDML/JSON loader demo" }
|
||||
styledDiv {
|
||||
css {
|
||||
classes.add("row")
|
||||
classes.add("p-1")
|
||||
overflow = Overflow.auto
|
||||
}
|
||||
gridColumn(3, maxSize= GridMaxSize.XL, classes = "order-2 order-xl-1") {
|
||||
card("Load data") {
|
||||
fileDrop("(drag file here)") { files ->
|
||||
val file = files?.get(0)
|
||||
if (file != null) {
|
||||
|
||||
FileReader().apply {
|
||||
onload = {
|
||||
val string = result as String
|
||||
loadData(file.name, string)
|
||||
}
|
||||
readAsText(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//tree
|
||||
card("Object tree", "overflow-auto") {
|
||||
visual?.let {
|
||||
objectTree(it, selected, select)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gridColumn(6, maxSize= GridMaxSize.XL, classes = "order-1 order-xl-2") {
|
||||
//canvas
|
||||
(visual as? Solid)?.let { visual3D ->
|
||||
child(ThreeCanvasComponent::class) {
|
||||
attrs {
|
||||
this.context = props.context
|
||||
this.obj = visual3D
|
||||
this.selected = selected
|
||||
this.clickCallback = select
|
||||
this.canvasCallback = {
|
||||
canvas = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gridColumn(3, maxSize= GridMaxSize.XL, classes = "order-3") {
|
||||
container {
|
||||
//settings
|
||||
canvas?.let {
|
||||
card("Canvas configuration") {
|
||||
canvasControls(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
container {
|
||||
namecrumbs(selected, "World") { selected = it }
|
||||
}
|
||||
container {
|
||||
//properties
|
||||
card("Properties") {
|
||||
selected.let { selected ->
|
||||
val selectedObject: Vision? = when {
|
||||
selected == null -> null
|
||||
selected.isEmpty() -> visual
|
||||
else -> (visual as? VisionGroup)?.get(selected)
|
||||
}
|
||||
if (selectedObject != null) {
|
||||
configEditor(selectedObject, default = selectedObject.getAllProperties(), key = selected)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.js.Application
|
||||
import hep.dataforge.js.startApplication
|
||||
import hep.dataforge.vision.gdml.GDMLTransformer
|
||||
import hep.dataforge.vision.gdml.LUnit
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.solid.SolidMaterial.Companion.MATERIAL_OPACITY_KEY
|
||||
import kotlinx.css.*
|
||||
import react.child
|
||||
import react.dom.render
|
||||
import styled.injectGlobal
|
||||
import kotlin.browser.document
|
||||
|
||||
|
||||
val gdmlConfiguration: GDMLTransformer.() -> Unit = {
|
||||
lUnit = LUnit.CM
|
||||
volumeAction = { volume ->
|
||||
when {
|
||||
volume.name.startsWith("ecal01lay") -> GDMLTransformer.Action.REJECT
|
||||
volume.name.startsWith("UPBL") -> GDMLTransformer.Action.REJECT
|
||||
volume.name.startsWith("USCL") -> GDMLTransformer.Action.REJECT
|
||||
volume.name.startsWith("VPBL") -> GDMLTransformer.Action.REJECT
|
||||
volume.name.startsWith("VSCL") -> GDMLTransformer.Action.REJECT
|
||||
else -> GDMLTransformer.Action.CACHE
|
||||
}
|
||||
}
|
||||
|
||||
solidConfiguration = { parent, solid ->
|
||||
if (
|
||||
solid.name.startsWith("Yoke")
|
||||
|| solid.name.startsWith("Pole")
|
||||
|| parent.physVolumes.isNotEmpty()
|
||||
) {
|
||||
useStyle("opaque") {
|
||||
MATERIAL_OPACITY_KEY put 0.3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class GDMLDemoApp : Application {
|
||||
|
||||
override fun start(state: Map<String, Any>) {
|
||||
|
||||
injectGlobal {
|
||||
body {
|
||||
height = 100.pct
|
||||
width = 100.pct
|
||||
margin(0.px)
|
||||
padding(0.px)
|
||||
}
|
||||
}
|
||||
|
||||
val context = Global.context("demo") {}
|
||||
val element = document.getElementById("app") ?: error("Element with id 'app' not found on page")
|
||||
|
||||
render(element) {
|
||||
child(GDMLApp) {
|
||||
attrs {
|
||||
this.context = context
|
||||
this.rootObject = cubes().toVision(gdmlConfiguration)
|
||||
}
|
||||
}
|
||||
}
|
||||
// (document.getElementById("file_load_button") as? HTMLInputElement)?.apply {
|
||||
// addEventListener("change", {
|
||||
// (it.target as HTMLInputElement).files?.asList()?.first()?.let { file ->
|
||||
// FileReader().apply {
|
||||
// onload = {
|
||||
// val string = result as String
|
||||
// action(file.name, string)
|
||||
// }
|
||||
// readAsText(file)
|
||||
// }
|
||||
// }
|
||||
// }, false)
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
startApplication(::GDMLDemoApp)
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package space.kscience.visionforge.gdml.demo
|
||||
|
||||
import kotlinx.browser.window
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.css.*
|
||||
import org.w3c.files.File
|
||||
import org.w3c.files.FileReader
|
||||
import org.w3c.files.get
|
||||
import react.Props
|
||||
import react.dom.h2
|
||||
import react.fc
|
||||
import react.useMemo
|
||||
import react.useState
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.context.fetch
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.gdml.Gdml
|
||||
import space.kscience.gdml.decodeFromString
|
||||
import space.kscience.visionforge.gdml.markLayers
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.ring.ThreeCanvasWithControls
|
||||
import space.kscience.visionforge.ring.tab
|
||||
import space.kscience.visionforge.setAsRoot
|
||||
import space.kscience.visionforge.solid.Solid
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
|
||||
external interface GDMLAppProps : Props {
|
||||
var context: Context
|
||||
var vision: Solid?
|
||||
var selected: Name?
|
||||
}
|
||||
|
||||
@JsExport
|
||||
val GDMLApp = fc<GDMLAppProps>("GDMLApp") { props ->
|
||||
val visionManager = useMemo(props.context) { props.context.fetch(Solids).visionManager }
|
||||
var deferredVision: Deferred<Solid?> by useState {
|
||||
CompletableDeferred(props.vision)
|
||||
}
|
||||
|
||||
fun readFileAsync(file: File): Deferred<Solid?> {
|
||||
val deferred = CompletableDeferred<Solid?>()
|
||||
FileReader().apply {
|
||||
onload = {
|
||||
val data = result as String
|
||||
val name = file.name
|
||||
val parsedVision = when {
|
||||
name.endsWith(".gdml") || name.endsWith(".xml") -> {
|
||||
val gdml = Gdml.decodeFromString(data)
|
||||
gdml.toVision().apply {
|
||||
setAsRoot(visionManager)
|
||||
console.info("Marking layers for file $name")
|
||||
markLayers()
|
||||
}
|
||||
}
|
||||
name.endsWith(".json") -> visionManager.decodeFromString(data)
|
||||
else -> {
|
||||
window.alert("File extension is not recognized: $name")
|
||||
error("File extension is not recognized: $name")
|
||||
}
|
||||
}
|
||||
deferred.complete(parsedVision as? Solid ?: error("Parsed vision is not a solid"))
|
||||
}
|
||||
readAsText(file)
|
||||
}
|
||||
|
||||
return deferred
|
||||
}
|
||||
|
||||
styledDiv {
|
||||
css {
|
||||
height = 100.vh - 12.pt
|
||||
width = 100.vw
|
||||
}
|
||||
child(ThreeCanvasWithControls) {
|
||||
attrs {
|
||||
this.context = props.context
|
||||
this.builderOfSolid = deferredVision
|
||||
this.selected = props.selected
|
||||
tab("Load") {
|
||||
h2 {
|
||||
+"Drag and drop .gdml or .json VisionForge files here"
|
||||
}
|
||||
fileDrop("(drag file here)") { files ->
|
||||
val file = files?.get(0)
|
||||
if (file != null) {
|
||||
deferredVision = readFileAsync(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
package space.kscience.visionforge.gdml.demo
|
||||
|
||||
import kotlinx.browser.document
|
||||
import kotlinx.css.*
|
||||
import react.dom.render
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.gdml.GdmlShowCase
|
||||
import space.kscience.visionforge.Application
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.solid.three.ThreePlugin
|
||||
import space.kscience.visionforge.startApplication
|
||||
import styled.injectGlobal
|
||||
|
||||
|
||||
private class GDMLDemoApp : Application {
|
||||
|
||||
override fun start(state: Map<String, Any>) {
|
||||
val context = Context("gdml-demo"){
|
||||
plugin(ThreePlugin)
|
||||
}
|
||||
|
||||
injectGlobal {
|
||||
html{
|
||||
height = 100.pct
|
||||
}
|
||||
|
||||
body{
|
||||
height = 100.pct
|
||||
display = Display.flex
|
||||
alignItems = Align.stretch
|
||||
}
|
||||
|
||||
"#application"{
|
||||
width = 100.pct
|
||||
display = Display.flex
|
||||
alignItems = Align.stretch
|
||||
}
|
||||
}
|
||||
|
||||
val element = document.getElementById("application") ?: error("Element with id 'application' not found on page")
|
||||
|
||||
render(element) {
|
||||
child(GDMLApp) {
|
||||
val vision = GdmlShowCase.cubes().toVision()
|
||||
//println(context.plugins.fetch(VisionManager).encodeToString(vision))
|
||||
attrs {
|
||||
this.context = context
|
||||
this.vision = vision
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
startApplication(::GDMLDemoApp)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
package space.kscience.visionforge.gdml.demo
|
||||
|
||||
import drop.FileDrop
|
||||
import kotlinx.css.*
|
||||
@ -14,6 +14,7 @@ fun RBuilder.fileDrop(title: String, action: (files: FileList?) -> Unit) {
|
||||
styledDiv {
|
||||
css {
|
||||
border(style = BorderStyle.dashed, width = 1.px, color = Color.orange)
|
||||
flexGrow = 0.0
|
||||
alignContent = Align.center
|
||||
}
|
||||
|
@ -2,16 +2,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Three js demo for particle physics</title>
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<script type="text/javascript" src="gdml.js"></script>
|
||||
<link rel="stylesheet" href="css/fileDrop.css">
|
||||
<script type="text/javascript" src="main.bundle.js"></script>
|
||||
<script type="text/javascript" src ="js/jquery-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src ="js/bootstrap.bundle.min.js"></script>
|
||||
</head>
|
||||
<body class="application">
|
||||
<div class="container-fluid" id = "app"> </div>
|
||||
<div id = "application"></div>
|
||||
</body>
|
||||
</html>
|
@ -1,54 +0,0 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
|
||||
import hep.dataforge.meta.DFExperimental
|
||||
import hep.dataforge.meta.setItem
|
||||
import hep.dataforge.values.asValue
|
||||
import hep.dataforge.vision.gdml.LUnit
|
||||
import hep.dataforge.vision.gdml.readFile
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.solid.SolidGroup
|
||||
import hep.dataforge.vision.solid.SolidManager
|
||||
import hep.dataforge.vision.solid.SolidMaterial
|
||||
import scientifik.gdml.GDML
|
||||
import java.io.File
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
@OptIn(DFExperimental::class)
|
||||
fun SolidManager.Companion.readFile(file: File): SolidGroup = when {
|
||||
file.extension == "gdml" || file.extension == "xml" -> {
|
||||
GDML.readFile(file.toPath()).toVision {
|
||||
lUnit = LUnit.CM
|
||||
|
||||
solidConfiguration = { parent, solid ->
|
||||
if (solid.name == "cave") {
|
||||
setItem(SolidMaterial.MATERIAL_WIREFRAME_KEY, true.asValue())
|
||||
}
|
||||
if (parent.physVolumes.isNotEmpty()) {
|
||||
useStyle("opaque") {
|
||||
SolidMaterial.MATERIAL_OPACITY_KEY put 0.3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
file.extension == "json" -> SolidGroup.parseJson(file.readText())
|
||||
file.name.endsWith("json.zip") -> {
|
||||
file.inputStream().use {
|
||||
val unzip = ZipInputStream(it, Charsets.UTF_8)
|
||||
val text = unzip.readBytes().decodeToString()
|
||||
SolidGroup.parseJson(text)
|
||||
}
|
||||
}
|
||||
file.name.endsWith("json.gz") -> {
|
||||
file.inputStream().use {
|
||||
val unzip = GZIPInputStream(it)
|
||||
val text = unzip.readBytes().decodeToString()
|
||||
SolidGroup.parseJson(text)
|
||||
}
|
||||
}
|
||||
else -> error("Unknown extension ${file.extension}")
|
||||
}
|
||||
|
||||
@OptIn(DFExperimental::class)
|
||||
fun SolidManager.Companion.readFile(fileName: String): SolidGroup = readFile(File(fileName))
|
@ -1,28 +0,0 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
|
||||
import hep.dataforge.vision.gdml.LUnit
|
||||
import hep.dataforge.vision.gdml.readFile
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.solid.stringify
|
||||
import scientifik.gdml.GDML
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
require(args.isNotEmpty()){"At least one argument is required"}
|
||||
val inputFileName = args[0]
|
||||
require(inputFileName.endsWith(".gdml")){"GDML required"}
|
||||
val outputFileName = args.getOrNull(1)?:inputFileName.replace(".gdml",".json")
|
||||
|
||||
val gdml = GDML.readFile(Paths.get(inputFileName))
|
||||
//GDML.readFile(Paths.get("D:\\Work\\Projects\\visionforge\\visionforge-spatial-gdml\\src\\jvmTest\\resources\\gdml\\simple1.gdml"))
|
||||
|
||||
val visual = gdml.toVision {
|
||||
lUnit = LUnit.CM
|
||||
}
|
||||
|
||||
val json = visual.stringify()
|
||||
println(json)
|
||||
File(outputFileName).writeText(json)
|
||||
//File("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.json").writeText(json)
|
||||
}
|
@ -1,47 +1,51 @@
|
||||
package hep.dataforge.vision.gdml.demo
|
||||
package space.kscience.visionforge.gdml.demo
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.vision.editor.VisualObjectEditorFragment
|
||||
import hep.dataforge.vision.editor.VisualObjectTreeFragment
|
||||
import hep.dataforge.vision.gdml.toVision
|
||||
import hep.dataforge.vision.solid.SolidManager
|
||||
import hep.dataforge.vision.solid.SolidMaterial
|
||||
import hep.dataforge.vision.solid.fx.FX3DPlugin
|
||||
import hep.dataforge.vision.solid.fx.FXCanvas3D
|
||||
import javafx.geometry.Orientation
|
||||
import javafx.scene.Parent
|
||||
import javafx.stage.FileChooser
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.context.fetch
|
||||
import space.kscience.gdml.GdmlShowCase
|
||||
import space.kscience.visionforge.VisionManager
|
||||
import space.kscience.visionforge.editor.VisionEditorFragment
|
||||
import space.kscience.visionforge.editor.VisionTreeFragment
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.solid.FX3DPlugin
|
||||
import space.kscience.visionforge.solid.FXCanvas3D
|
||||
import space.kscience.visionforge.solid.Solid
|
||||
import space.kscience.visionforge.solid.SolidMaterial
|
||||
import tornadofx.*
|
||||
|
||||
class GDMLDemoApp : App(GDMLView::class)
|
||||
|
||||
class GDMLView : View() {
|
||||
private val fx3d = Global.plugins.fetch(FX3DPlugin)
|
||||
private val context = Context {
|
||||
plugin(FX3DPlugin)
|
||||
}
|
||||
|
||||
private val fx3d = context.fetch(FX3DPlugin)
|
||||
private val visionManager = context.fetch(VisionManager)
|
||||
private val canvas = FXCanvas3D(fx3d)
|
||||
|
||||
private val treeFragment = VisualObjectTreeFragment().apply {
|
||||
private val treeFragment = VisionTreeFragment().apply {
|
||||
this.itemProperty.bind(canvas.rootObjectProperty)
|
||||
}
|
||||
|
||||
private val propertyEditor = VisualObjectEditorFragment {
|
||||
it.getAllProperties()
|
||||
}.apply {
|
||||
private val propertyEditor = VisionEditorFragment().apply {
|
||||
descriptorProperty.set(SolidMaterial.descriptor)
|
||||
itemProperty.bind(treeFragment.selectedProperty)
|
||||
visionProperty.bind(treeFragment.selectedProperty)
|
||||
}
|
||||
|
||||
|
||||
override val root: Parent = borderpane {
|
||||
top {
|
||||
buttonbar {
|
||||
button("Load GDML/json") {
|
||||
action {
|
||||
runAsync {
|
||||
val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull()
|
||||
?: return@runAsync null
|
||||
SolidManager.readFile(file)
|
||||
} ui {
|
||||
if (it != null) {
|
||||
val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull()
|
||||
if (file != null) {
|
||||
runAsync {
|
||||
visionManager.readFile(file) as Solid
|
||||
} ui {
|
||||
canvas.render(it)
|
||||
}
|
||||
}
|
||||
@ -58,7 +62,7 @@ class GDMLView : View() {
|
||||
|
||||
init {
|
||||
runAsync {
|
||||
cubes().toVision()
|
||||
GdmlShowCase.cubes().toVision()
|
||||
} ui {
|
||||
canvas.render(it)
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package space.kscience.visionforge.gdml.demo
|
||||
|
||||
import space.kscience.dataforge.misc.DFExperimental
|
||||
import space.kscience.gdml.Gdml
|
||||
import space.kscience.gdml.decodeFromFile
|
||||
import space.kscience.visionforge.Vision
|
||||
import space.kscience.visionforge.VisionManager
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import java.io.File
|
||||
import java.util.zip.GZIPInputStream
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
@OptIn(DFExperimental::class)
|
||||
fun VisionManager.readFile(file: File): Vision = when {
|
||||
file.extension == "gdml" || file.extension == "xml" -> {
|
||||
Gdml.decodeFromFile(file.toPath(),true).toVision()
|
||||
}
|
||||
file.extension == "json" -> decodeFromString(file.readText())
|
||||
file.name.endsWith("json.zip") -> {
|
||||
file.inputStream().use {
|
||||
val unzip = ZipInputStream(it, Charsets.UTF_8)
|
||||
val text = unzip.readBytes().decodeToString()
|
||||
decodeFromString(text)
|
||||
}
|
||||
}
|
||||
file.name.endsWith("json.gz") -> {
|
||||
file.inputStream().use {
|
||||
val unzip = GZIPInputStream(it)
|
||||
val text = unzip.readBytes().decodeToString()
|
||||
decodeFromString(text)
|
||||
}
|
||||
}
|
||||
else -> error("Unknown extension ${file.extension}")
|
||||
}
|
||||
|
||||
@OptIn(DFExperimental::class)
|
||||
fun VisionManager.readFile(fileName: String): Vision = readFile(File(fileName))
|
@ -0,0 +1,28 @@
|
||||
package space.kscience.visionforge.gdml.demo
|
||||
|
||||
import space.kscience.gdml.Gdml
|
||||
import space.kscience.gdml.LUnit
|
||||
import space.kscience.gdml.decodeFromFile
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
require(args.isNotEmpty()) { "At least one argument is required" }
|
||||
val inputFileName = args[0]
|
||||
require(inputFileName.endsWith(".gdml")) { "GDML required" }
|
||||
val outputFileName = args.getOrNull(1) ?: inputFileName.replace(".gdml", ".json")
|
||||
|
||||
val gdml = Gdml.decodeFromFile(Paths.get(inputFileName), true)
|
||||
//GDML.readFile(Paths.get("D:\\Work\\Projects\\visionforge\\visionforge-spatial-gdml\\src\\jvmTest\\resources\\gdml\\simple1.gdml"))
|
||||
|
||||
val vision = gdml.toVision {
|
||||
lUnit = LUnit.CM
|
||||
}
|
||||
|
||||
val json = Solids.encodeToString(vision)
|
||||
println(json)
|
||||
File(outputFileName).writeText(json)
|
||||
//File("D:\\Work\\Projects\\gdml.kt\\gdml-source\\cubes.json").writeText(json)
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package hep.dataforge.vision.solid
|
||||
package space.kscience.visionforge.solid
|
||||
|
||||
import hep.dataforge.names.asName
|
||||
import org.junit.jupiter.api.Test
|
||||
import space.kscience.dataforge.names.asName
|
||||
import kotlin.test.Ignore
|
||||
|
||||
class FileSerializationTest {
|
||||
@ -9,7 +9,7 @@ class FileSerializationTest {
|
||||
@Ignore
|
||||
fun testFileRead(){
|
||||
val text = this::class.java.getResourceAsStream("/cubes.json").readBytes().decodeToString()
|
||||
val visual = SolidGroup.parseJson(text)
|
||||
val visual = Solids.decodeFromString(text) as SolidGroup
|
||||
visual["composite_001".asName()]
|
||||
}
|
||||
}
|
3
demo/gdml/webpack.config.d/01.ring.js
vendored
Normal file
3
demo/gdml/webpack.config.d/01.ring.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const ringConfig = require('@jetbrains/ring-ui/webpack.config').config;
|
||||
|
||||
config.module.rules.push(...ringConfig.module.rules)
|
4
demo/js-playground/README.md
Normal file
4
demo/js-playground/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Module js-playground
|
||||
|
||||
|
||||
|
28
demo/js-playground/build.gradle.kts
Normal file
28
demo/js-playground/build.gradle.kts
Normal file
@ -0,0 +1,28 @@
|
||||
plugins {
|
||||
id("ru.mipt.npm.gradle.js")
|
||||
}
|
||||
|
||||
kscience{
|
||||
useCoroutines()
|
||||
application()
|
||||
}
|
||||
|
||||
kotlin{
|
||||
js(IR){
|
||||
useCommonJs()
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies{
|
||||
implementation(projects.visionforge.visionforgeGdml)
|
||||
implementation(projects.visionforge.visionforgePlotly)
|
||||
implementation(projects.visionforge.visionforgeMarkdown)
|
||||
implementation(projects.visionforge.visionforgeThreejs)
|
||||
implementation(projects.ui.ring)
|
||||
}
|
112
demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt
Normal file
112
demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt
Normal file
@ -0,0 +1,112 @@
|
||||
import kotlinx.browser.document
|
||||
import kotlinx.css.*
|
||||
import react.child
|
||||
import react.dom.render
|
||||
import ringui.SmartTabs
|
||||
import ringui.Tab
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.plotly.models.Trace
|
||||
import space.kscience.plotly.scatter
|
||||
import space.kscience.visionforge.Application
|
||||
import space.kscience.visionforge.VisionClient
|
||||
import space.kscience.visionforge.plotly.PlotlyPlugin
|
||||
import space.kscience.visionforge.ring.ThreeCanvasWithControls
|
||||
import space.kscience.visionforge.ring.ThreeWithControlsPlugin
|
||||
import space.kscience.visionforge.ring.solid
|
||||
import space.kscience.visionforge.solid.*
|
||||
import space.kscience.visionforge.startApplication
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
import kotlin.random.Random
|
||||
|
||||
fun Trace.appendXYLatest(x: Number, y: Number, history: Int = 400, xErr: Number? = null, yErr: Number? = null) {
|
||||
this.x.numbers = (this.x.numbers + x).takeLast(history)
|
||||
this.y.numbers = (this.y.numbers + y).takeLast(history)
|
||||
xErr?.let { error_x.array = (error_x.array + xErr).takeLast(history) }
|
||||
yErr?.let { error_y.array = (error_y.array + yErr).takeLast(history) }
|
||||
}
|
||||
|
||||
private class JsPlaygroundApp : Application {
|
||||
|
||||
override fun start(state: Map<String, Any>) {
|
||||
|
||||
val playgroundContext = Context {
|
||||
plugin(ThreeWithControlsPlugin)
|
||||
plugin(VisionClient)
|
||||
plugin(PlotlyPlugin)
|
||||
}
|
||||
|
||||
val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page")
|
||||
|
||||
render(element) {
|
||||
styledDiv {
|
||||
css {
|
||||
padding(0.pt)
|
||||
margin(0.pt)
|
||||
height = 100.vh
|
||||
width = 100.vw
|
||||
}
|
||||
SmartTabs("gravity") {
|
||||
Tab("gravity") {
|
||||
GravityDemo{
|
||||
attrs {
|
||||
this.context = playgroundContext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tab("D0") {
|
||||
// child(ThreeCanvasWithControls) {
|
||||
// attrs {
|
||||
// context = playgroundContext
|
||||
// solid = GdmlShowCase.babyIaxo().toVision()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Tab("spheres") {
|
||||
styledDiv {
|
||||
css {
|
||||
height = 100.vh - 50.pt
|
||||
}
|
||||
child(ThreeCanvasWithControls) {
|
||||
val random = Random(112233)
|
||||
attrs {
|
||||
context = playgroundContext
|
||||
solid {
|
||||
repeat(100) {
|
||||
sphere(5, name = "sphere[$it]") {
|
||||
x = random.nextDouble(-300.0, 300.0)
|
||||
y = random.nextDouble(-300.0, 300.0)
|
||||
z = random.nextDouble(-300.0, 300.0)
|
||||
material {
|
||||
color(random.nextInt())
|
||||
}
|
||||
detail = 16
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Tab("plotly") {
|
||||
Plotly {
|
||||
attrs {
|
||||
plot = space.kscience.plotly.Plotly.plot {
|
||||
scatter {
|
||||
x(1, 2, 3)
|
||||
y(5, 8, 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public fun main() {
|
||||
startApplication(::JsPlaygroundApp)
|
||||
}
|
106
demo/js-playground/src/main/kotlin/gravityDemo.kt
Normal file
106
demo/js-playground/src/main/kotlin/gravityDemo.kt
Normal file
@ -0,0 +1,106 @@
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.css.*
|
||||
import react.Props
|
||||
import react.fc
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.plotly.layout
|
||||
import space.kscience.plotly.models.Trace
|
||||
import space.kscience.visionforge.markup.VisionOfMarkup
|
||||
import space.kscience.visionforge.react.flexRow
|
||||
import space.kscience.visionforge.ring.ThreeCanvasWithControls
|
||||
import space.kscience.visionforge.ring.solid
|
||||
import space.kscience.visionforge.solid.*
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
import kotlin.math.sqrt
|
||||
|
||||
external interface DemoProps : Props {
|
||||
var context: Context
|
||||
}
|
||||
|
||||
val GravityDemo = fc<DemoProps> { props ->
|
||||
val velocityTrace = Trace{
|
||||
name = "velocity"
|
||||
}
|
||||
val energyTrace = Trace{
|
||||
name = "energy"
|
||||
}
|
||||
val markup = VisionOfMarkup()
|
||||
|
||||
styledDiv {
|
||||
css {
|
||||
height = 100.vh - 50.pt
|
||||
}
|
||||
styledDiv {
|
||||
css {
|
||||
height = 50.vh
|
||||
}
|
||||
child(ThreeCanvasWithControls) {
|
||||
attrs {
|
||||
context = props.context
|
||||
solid {
|
||||
sphere(5.0, "ball") {
|
||||
detail = 16
|
||||
color("red")
|
||||
val h = 100.0
|
||||
y = h
|
||||
context.launch {
|
||||
val g = 10.0
|
||||
val dt = 0.1
|
||||
var time = 0.0
|
||||
var velocity = 0.0
|
||||
while (isActive) {
|
||||
delay(20)
|
||||
time += dt
|
||||
velocity -= g * dt
|
||||
val energy = g * y.toDouble() + velocity * velocity / 2
|
||||
y = y.toDouble() + velocity * dt
|
||||
|
||||
velocityTrace.appendXYLatest(time, y)
|
||||
energyTrace.appendXYLatest(time, energy)
|
||||
|
||||
if (y.toDouble() <= 2.5) {
|
||||
//conservation of energy
|
||||
velocity = sqrt(2 * g * h)
|
||||
}
|
||||
|
||||
markup.content = """
|
||||
## Bouncing sphere parameters
|
||||
|
||||
**velocity** = $velocity
|
||||
|
||||
**energy** = $energy
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
box(200, 5, 200, name = "floor") {
|
||||
y = -2.5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
flexRow {
|
||||
css {
|
||||
alignContent = Align.stretch
|
||||
alignItems = Align.stretch
|
||||
height = 50.vh - 50.pt
|
||||
}
|
||||
plotly {
|
||||
traces(velocityTrace,energyTrace)
|
||||
layout {
|
||||
xaxis.title = "time"
|
||||
}
|
||||
}
|
||||
Markup {
|
||||
attrs {
|
||||
this.markup = markup
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
demo/js-playground/src/main/kotlin/markupComponent.kt
Normal file
56
demo/js-playground/src/main/kotlin/markupComponent.kt
Normal file
@ -0,0 +1,56 @@
|
||||
import kotlinx.css.*
|
||||
import kotlinx.css.properties.border
|
||||
import kotlinx.dom.clear
|
||||
import kotlinx.html.dom.append
|
||||
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
|
||||
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
|
||||
import org.w3c.dom.Element
|
||||
import org.w3c.dom.HTMLElement
|
||||
import react.Props
|
||||
import react.fc
|
||||
import react.useEffect
|
||||
import react.useRef
|
||||
import space.kscience.visionforge.markup.VisionOfMarkup
|
||||
import space.kscience.visionforge.markup.markdown
|
||||
import space.kscience.visionforge.useProperty
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
|
||||
external interface MarkupProps : Props {
|
||||
var markup: VisionOfMarkup?
|
||||
}
|
||||
|
||||
val Markup = fc<MarkupProps>("Markup") { props ->
|
||||
val elementRef = useRef<Element>(null)
|
||||
|
||||
useEffect(props.markup, elementRef) {
|
||||
val element = elementRef.current as? HTMLElement ?: error("Markup element not found")
|
||||
props.markup?.let { vision ->
|
||||
val flavour = when (vision.format) {
|
||||
VisionOfMarkup.COMMONMARK_FORMAT -> CommonMarkFlavourDescriptor()
|
||||
VisionOfMarkup.GFM_FORMAT -> GFMFlavourDescriptor()
|
||||
//TODO add new formats via plugins
|
||||
else -> error("Format ${vision.format} not recognized")
|
||||
}
|
||||
vision.useProperty(VisionOfMarkup::content) { content: String? ->
|
||||
element.clear()
|
||||
element.append {
|
||||
markdown(flavour) { content ?: "" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
styledDiv {
|
||||
css {
|
||||
width = 100.pct
|
||||
height = 100.pct
|
||||
border(2.pt, BorderStyle.solid, Color.blue)
|
||||
padding(left = 8.pt)
|
||||
backgroundColor = Color.white
|
||||
flex(1.0)
|
||||
zIndex = 10000
|
||||
}
|
||||
ref = elementRef
|
||||
}
|
||||
}
|
44
demo/js-playground/src/main/kotlin/plotlyComponent.kt
Normal file
44
demo/js-playground/src/main/kotlin/plotlyComponent.kt
Normal file
@ -0,0 +1,44 @@
|
||||
import kotlinx.css.*
|
||||
import kotlinx.css.properties.border
|
||||
import org.w3c.dom.Element
|
||||
import org.w3c.dom.HTMLElement
|
||||
import react.*
|
||||
import space.kscience.plotly.Plot
|
||||
import space.kscience.plotly.PlotlyConfig
|
||||
import space.kscience.plotly.plot
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
|
||||
external interface PlotlyProps : Props {
|
||||
var plot: Plot?
|
||||
}
|
||||
|
||||
|
||||
val Plotly = fc<PlotlyProps>("Plotly") { props ->
|
||||
val elementRef = useRef<Element>(null)
|
||||
|
||||
useEffect(props.plot, elementRef) {
|
||||
val element = elementRef.current as? HTMLElement ?: error("Plotly element not found")
|
||||
props.plot?.let {
|
||||
element.plot(it, PlotlyConfig {
|
||||
responsive = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
styledDiv {
|
||||
css {
|
||||
width = 100.pct
|
||||
height = 100.pct
|
||||
border(2.pt, BorderStyle.solid, Color.blue)
|
||||
flex(1.0)
|
||||
}
|
||||
ref = elementRef
|
||||
}
|
||||
}
|
||||
|
||||
fun RBuilder.plotly(plotbuilder: Plot.() -> Unit) = Plotly {
|
||||
attrs {
|
||||
this.plot = Plot().apply(plotbuilder)
|
||||
}
|
||||
}
|
12
demo/js-playground/src/main/resources/index.html
Normal file
12
demo/js-playground/src/main/resources/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>js-playground</title>
|
||||
<script src="js-playground.js"></script>
|
||||
</head>
|
||||
<body class="application">
|
||||
<div id="playground"></div>
|
||||
</body>
|
||||
</html>
|
3
demo/js-playground/webpack.config.d/01.ring.js
vendored
Normal file
3
demo/js-playground/webpack.config.d/01.ring.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const ringConfig = require('@jetbrains/ring-ui/webpack.config').config;
|
||||
|
||||
config.module.rules.push(...ringConfig.module.rules)
|
@ -1,34 +1,4 @@
|
||||
# Module muon-monitor
|
||||
|
||||
### Muon Monitor Visualization
|
||||
|
||||
This directory contains a full-stack application example built with `visionforge`.
|
||||
It is visualizing the
|
||||
[Muon Monitor](http://npm.mipt.ru/projects/physics.html#mounMonitor) experiment set-up,
|
||||
including experiment's geometry and events (particle tracks).
|
||||
|
||||
#### Reusing code and going Full-Stack with Kotlin Multiplatform
|
||||
|
||||
The application includes both server back-end generating events, as well as client
|
||||
visualization front-end.
|
||||
|
||||
As is common for Kotlin multiplatform projects, the code base of this simple application
|
||||
is put in the following main directories:
|
||||
* `commonMain` - common code, used by both JS client and JVM server. For example, the `Monitor`
|
||||
object describes general geometry definitions needed in all parts of the application.
|
||||
* `jsMain` - JavaScript client code. It performs visualization and reads events from the server.
|
||||
* `jvmMain` - JVM server code. It runs `ktor` HTTP server, responding with event data when
|
||||
client requests them.
|
||||
|
||||
Note that in a more traditional approach when client and server are developed separately
|
||||
and possibly using different languages, there would be no common code and benefits associated
|
||||
with it.
|
||||
|
||||
##### Building project
|
||||
|
||||
To run full-stack Muon Monitor Visualization application (both JVM server and Web browser front-end),
|
||||
run `demo/muon-monitor/application/run` task.
|
||||
|
||||
##### Example view:
|
||||
|
||||
![](../../doc/resources/muon-monitor.png)
|
||||
|
||||
|
148
demo/muon-monitor/api/muon-monitor.api
Normal file
148
demo/muon-monitor/api/muon-monitor.api
Normal file
@ -0,0 +1,148 @@
|
||||
public final class ru/mipt/npm/muon/monitor/Event {
|
||||
public static final field Companion Lru/mipt/npm/muon/monitor/Event$Companion;
|
||||
public synthetic fun <init> (IILjava/util/List;Ljava/util/Collection;Lkotlinx/serialization/internal/SerializationConstructorMarker;)V
|
||||
public fun <init> (ILjava/util/List;Ljava/util/Collection;)V
|
||||
public final fun component1 ()I
|
||||
public final fun component2 ()Ljava/util/List;
|
||||
public final fun component3 ()Ljava/util/Collection;
|
||||
public final fun copy (ILjava/util/List;Ljava/util/Collection;)Lru/mipt/npm/muon/monitor/Event;
|
||||
public static synthetic fun copy$default (Lru/mipt/npm/muon/monitor/Event;ILjava/util/List;Ljava/util/Collection;ILjava/lang/Object;)Lru/mipt/npm/muon/monitor/Event;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getHits ()Ljava/util/Collection;
|
||||
public final fun getId ()I
|
||||
public final fun getTrack ()Ljava/util/List;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
public static final fun write$Self (Lru/mipt/npm/muon/monitor/Event;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/Event$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Lru/mipt/npm/muon/monitor/Event$$serializer;
|
||||
public static final synthetic field descriptor Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lru/mipt/npm/muon/monitor/Event;
|
||||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lru/mipt/npm/muon/monitor/Event;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/Event$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/Model {
|
||||
public fun <init> (Lspace/kscience/visionforge/VisionManager;)V
|
||||
public final fun displayEvent (Lru/mipt/npm/muon/monitor/Event;)V
|
||||
public final fun encodeToString ()Ljava/lang/String;
|
||||
public final fun getManager ()Lspace/kscience/visionforge/VisionManager;
|
||||
public final fun getRoot ()Lspace/kscience/visionforge/solid/SolidGroup;
|
||||
public final fun getTracks ()Lspace/kscience/visionforge/solid/SolidGroup;
|
||||
public final fun reset ()V
|
||||
public final fun setTracks (Lspace/kscience/visionforge/solid/SolidGroup;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/Monitor {
|
||||
public static final field CENTRAL_LAYER_Z F
|
||||
public static final field GEOMETRY_TOLERANCE D
|
||||
public static final field INSTANCE Lru/mipt/npm/muon/monitor/Monitor;
|
||||
public static final field LOWER_LAYER_Z F
|
||||
public static final field PIXEL_XY_SIZE F
|
||||
public static final field PIXEL_XY_SPACING F
|
||||
public static final field PIXEL_Z_SIZE F
|
||||
public static final field UPPER_LAYER_Z F
|
||||
public final fun getDetectors ()Ljava/util/Collection;
|
||||
public final fun getPixels ()Ljava/util/Collection;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/ReadResourceKt {
|
||||
public static final fun readResource (Ljava/lang/String;)Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/SC1 {
|
||||
public fun <init> (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;FFF)V
|
||||
public synthetic fun <init> (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;FFFILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getCenter ()Lspace/kscience/visionforge/solid/Point3D;
|
||||
public final fun getName ()Ljava/lang/String;
|
||||
public final fun getXSize ()F
|
||||
public final fun getYSize ()F
|
||||
public final fun getZSize ()F
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/SC16 {
|
||||
public fun <init> (Ljava/lang/String;Lspace/kscience/visionforge/solid/Point3D;)V
|
||||
public final fun getCenter ()Lspace/kscience/visionforge/solid/Point3D;
|
||||
public final fun getName ()Ljava/lang/String;
|
||||
public final fun getPixels ()Ljava/util/Collection;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/server/MMServerKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
public static final fun module (Lio/ktor/application/Application;Lspace/kscience/dataforge/context/Context;)V
|
||||
public static synthetic fun module$default (Lio/ktor/application/Application;Lspace/kscience/dataforge/context/Context;ILjava/lang/Object;)V
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/Cos2TrackGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator {
|
||||
public fun <init> (Lorg/apache/commons/math3/random/RandomGenerator;DFF)V
|
||||
public synthetic fun <init> (Lorg/apache/commons/math3/random/RandomGenerator;DFFILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line;
|
||||
public final fun getMaxX ()F
|
||||
public final fun getMaxY ()F
|
||||
public final fun getPower ()D
|
||||
public fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/FixedAngleGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator {
|
||||
public fun <init> (Lorg/apache/commons/math3/random/RandomGenerator;DDFF)V
|
||||
public synthetic fun <init> (Lorg/apache/commons/math3/random/RandomGenerator;DDFFILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line;
|
||||
public final fun getMaxX ()F
|
||||
public final fun getMaxY ()F
|
||||
public final fun getPhi ()D
|
||||
public fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator;
|
||||
public final fun getTheta ()D
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/LineKt {
|
||||
public static final fun getPhi (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D
|
||||
public static final fun getTheta (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D
|
||||
public static final fun getX (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D
|
||||
public static final fun getY (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)D
|
||||
public static final fun makeTrack (DDDD)Lorg/apache/commons/math3/geometry/euclidean/threed/Line;
|
||||
public static final fun makeTrack (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lorg/apache/commons/math3/geometry/euclidean/threed/Line;
|
||||
public static final fun toPoint (Lorg/apache/commons/math3/geometry/euclidean/threed/Vector3D;)Lspace/kscience/visionforge/solid/Point3D;
|
||||
public static final fun toPoints (Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)Ljava/util/List;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/MonitorKt {
|
||||
public static final fun buildEventByTrack (ILorg/apache/commons/math3/geometry/euclidean/threed/Line;Lkotlin/jvm/functions/Function1;)Lru/mipt/npm/muon/monitor/Event;
|
||||
public static synthetic fun buildEventByTrack$default (ILorg/apache/commons/math3/geometry/euclidean/threed/Line;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lru/mipt/npm/muon/monitor/Event;
|
||||
public static final fun findLayer (F)Lorg/apache/commons/math3/geometry/euclidean/threed/Plane;
|
||||
public static final fun getDefaultHitResolver ()Lkotlin/jvm/functions/Function1;
|
||||
public static final fun readEffs ()Ljava/util/Map;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/PixelKt {
|
||||
public static final fun isHit (Lru/mipt/npm/muon/monitor/SC1;Lorg/apache/commons/math3/geometry/euclidean/threed/Line;)Z
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/SimulationKt {
|
||||
public static final fun simulateOne (Lru/mipt/npm/muon/monitor/sim/TrackGenerator;)Lru/mipt/npm/muon/monitor/Event;
|
||||
}
|
||||
|
||||
public abstract interface class ru/mipt/npm/muon/monitor/sim/TrackGenerator {
|
||||
public abstract fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line;
|
||||
public abstract fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator;
|
||||
}
|
||||
|
||||
public final class ru/mipt/npm/muon/monitor/sim/UniformTrackGenerator : ru/mipt/npm/muon/monitor/sim/TrackGenerator {
|
||||
public fun <init> (Lorg/apache/commons/math3/random/RandomGenerator;FF)V
|
||||
public synthetic fun <init> (Lorg/apache/commons/math3/random/RandomGenerator;FFILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun generate ()Lorg/apache/commons/math3/geometry/euclidean/threed/Line;
|
||||
public final fun getMaxX ()F
|
||||
public final fun getMaxY ()F
|
||||
public fun getRnd ()Lorg/apache/commons/math3/random/RandomGenerator;
|
||||
}
|
||||
|
@ -1,43 +1,39 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||
import scientifik.jsDistDirectory
|
||||
|
||||
plugins {
|
||||
id("scientifik.mpp")
|
||||
id("application")
|
||||
id("ru.mipt.npm.gradle.mpp")
|
||||
application
|
||||
}
|
||||
|
||||
group = "ru.mipt.npm"
|
||||
|
||||
val ktorVersion = "1.3.2"
|
||||
val ktorVersion: String = npmlibs.versions.ktor.get()
|
||||
|
||||
kscience {
|
||||
useCoroutines()
|
||||
useSerialization()
|
||||
application()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
val installJS = tasks.getByName("jsBrowserDistribution")
|
||||
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
js {
|
||||
useCommonJs()
|
||||
browser {
|
||||
dceTask {
|
||||
dceOptions {
|
||||
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
|
||||
}
|
||||
}
|
||||
webpackTask {
|
||||
mode = org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode.PRODUCTION
|
||||
commonWebpackConfig {
|
||||
cssSupport.enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jvm {
|
||||
withJava()
|
||||
compilations[MAIN_COMPILATION_NAME]?.apply {
|
||||
tasks.getByName<ProcessResources>(processResourcesTaskName) {
|
||||
dependsOn(installJS)
|
||||
afterEvaluate {
|
||||
from(project.jsDistDirectory)
|
||||
}
|
||||
}
|
||||
}
|
||||
afterEvaluate {
|
||||
val jsBrowserDistribution by tasks.getting
|
||||
|
||||
tasks.getByName<ProcessResources>("jvmProcessResources") {
|
||||
dependsOn(jsBrowserDistribution)
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(jsBrowserDistribution)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@ -49,39 +45,31 @@ kotlin {
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation("org.apache.commons:commons-math3:3.6.1")
|
||||
implementation("io.ktor:ktor-server-cio:$ktorVersion")
|
||||
implementation("io.ktor:ktor-serialization:$ktorVersion")
|
||||
implementation(npmlibs.ktor.server.cio)
|
||||
implementation(npmlibs.ktor.serialization)
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation(project(":ui:bootstrap"))
|
||||
implementation("io.ktor:ktor-client-js:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-serialization-js:$ktorVersion")
|
||||
implementation(npm("text-encoding"))
|
||||
implementation(npm("abort-controller"))
|
||||
implementation(npm("bufferutil"))
|
||||
implementation(npm("utf-8-validate"))
|
||||
implementation(npm("fs"))
|
||||
// implementation(npm("jquery"))
|
||||
// implementation(npm("popper.js"))
|
||||
// implementation(npm("react-is"))
|
||||
implementation(project(":ui:ring"))
|
||||
implementation(project(":visionforge-threejs"))
|
||||
//implementation(devNpm("webpack-bundle-analyzer", "4.4.0"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "ru.mipt.npm.muon.monitor.server.MMServerKt"
|
||||
mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt")
|
||||
}
|
||||
|
||||
distributions {
|
||||
main {
|
||||
contents {
|
||||
from("$buildDir/libs") {
|
||||
rename("${rootProject.name}-jvm", rootProject.name)
|
||||
into("lib")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//distributions {
|
||||
// main {
|
||||
// contents {
|
||||
// from("$buildDir/libs") {
|
||||
// rename("${rootProject.name}-jvm", rootProject.name)
|
||||
// into("lib")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,10 +1,7 @@
|
||||
@file:UseSerializers(Point3DSerializer::class)
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import hep.dataforge.vision.solid.Point3D
|
||||
import hep.dataforge.vision.solid.Point3DSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.UseSerializers
|
||||
import space.kscience.visionforge.solid.Point3D
|
||||
|
||||
typealias Track = List<Point3D>
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import hep.dataforge.vision.removeAll
|
||||
import hep.dataforge.vision.solid.*
|
||||
import ru.mipt.npm.muon.monitor.Monitor.CENTRAL_LAYER_Z
|
||||
import ru.mipt.npm.muon.monitor.Monitor.LOWER_LAYER_Z
|
||||
import ru.mipt.npm.muon.monitor.Monitor.UPPER_LAYER_Z
|
||||
import space.kscience.visionforge.VisionManager
|
||||
import space.kscience.visionforge.removeAll
|
||||
import space.kscience.visionforge.setAsRoot
|
||||
import space.kscience.visionforge.setProperty
|
||||
import space.kscience.visionforge.solid.*
|
||||
import kotlin.math.PI
|
||||
|
||||
class Model {
|
||||
class Model(val manager: VisionManager) {
|
||||
private val map = HashMap<String, SolidGroup>()
|
||||
private val events = HashSet<Event>()
|
||||
|
||||
@ -34,6 +37,11 @@ class Model {
|
||||
var tracks: SolidGroup
|
||||
|
||||
val root: SolidGroup = SolidGroup().apply {
|
||||
setAsRoot(this@Model.manager)
|
||||
material {
|
||||
wireframe
|
||||
color("darkgreen")
|
||||
}
|
||||
rotationX = PI / 2
|
||||
group("bottom") {
|
||||
Monitor.detectors.filter { it.center.z == LOWER_LAYER_Z }.forEach {
|
||||
@ -52,23 +60,23 @@ class Model {
|
||||
detector(it)
|
||||
}
|
||||
}
|
||||
|
||||
tracks = group("tracks")
|
||||
}
|
||||
|
||||
private fun highlight(pixel: String) {
|
||||
map[pixel]?.color("blue")
|
||||
println("highlight $pixel")
|
||||
map[pixel]?.color?.invoke("blue")
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
map.values.forEach {
|
||||
it.config
|
||||
it.setItem(SolidMaterial.MATERIAL_COLOR_KEY, null)
|
||||
it.setProperty(SolidMaterial.MATERIAL_COLOR_KEY, null)
|
||||
}
|
||||
tracks.removeAll()
|
||||
}
|
||||
|
||||
fun displayEvent(event: Event) {
|
||||
println("Received event: $event")
|
||||
events.add(event)
|
||||
event.hits.forEach {
|
||||
highlight(it)
|
||||
@ -76,11 +84,10 @@ class Model {
|
||||
event.track?.let {
|
||||
tracks.polyline(*it.toTypedArray(), name = "track[${event.id}]") {
|
||||
thickness = 4
|
||||
color("red")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun buildGeometry() = Model().root
|
||||
}
|
||||
fun encodeToString(): String = manager.encodeToString(this.root)
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import hep.dataforge.vision.solid.Point3D
|
||||
import hep.dataforge.vision.solid.plus
|
||||
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
|
||||
@ -11,7 +11,7 @@ import ru.mipt.npm.muon.monitor.Monitor.PIXEL_Z_SIZE
|
||||
class SC1(
|
||||
val name: String,
|
||||
val center: Point3D,
|
||||
val xSize: Double = PIXEL_XY_SIZE, val ySize: Double = PIXEL_XY_SIZE, val zSize: Double = PIXEL_Z_SIZE
|
||||
val xSize: Float = PIXEL_XY_SIZE, val ySize: Float = PIXEL_XY_SIZE, val zSize: Float = PIXEL_Z_SIZE
|
||||
)
|
||||
|
||||
class SC16(
|
||||
@ -98,7 +98,7 @@ class SC16(
|
||||
}
|
||||
val offset = Point3D(-y, x, 0)//rotateDetector(Point3D(x, y, 0.0));
|
||||
val pixelName = "${name}_${index}"
|
||||
SC1(pixelName, center + offset)
|
||||
SC1(pixelName, offset + center)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,12 +121,12 @@ internal expect fun readMonitorConfig(): String
|
||||
object Monitor {
|
||||
|
||||
const val GEOMETRY_TOLERANCE = 0.01
|
||||
const val PIXEL_XY_SIZE = 122.0
|
||||
const val PIXEL_XY_SPACING = 123.2
|
||||
const val PIXEL_Z_SIZE = 30.0
|
||||
const val CENTRAL_LAYER_Z = 0.0
|
||||
const val UPPER_LAYER_Z = -166.0
|
||||
const val LOWER_LAYER_Z = 180.0
|
||||
const val PIXEL_XY_SIZE = 122.0f
|
||||
const val PIXEL_XY_SPACING = 123.2f
|
||||
const val PIXEL_Z_SIZE = 30.0f
|
||||
const val CENTRAL_LAYER_Z = 0.0f
|
||||
const val UPPER_LAYER_Z = -166.0f
|
||||
const val LOWER_LAYER_Z = 180.0f
|
||||
|
||||
/**
|
||||
* Build map for the whole monitor
|
||||
|
@ -1,166 +1,274 @@
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.names.Name
|
||||
import hep.dataforge.names.NameToken
|
||||
import hep.dataforge.names.isEmpty
|
||||
import hep.dataforge.vision.Vision
|
||||
import hep.dataforge.vision.bootstrap.card
|
||||
import hep.dataforge.vision.bootstrap.objectTree
|
||||
import hep.dataforge.vision.react.component
|
||||
import hep.dataforge.vision.react.configEditor
|
||||
import hep.dataforge.vision.react.state
|
||||
import hep.dataforge.vision.solid.specifications.Camera
|
||||
import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvas
|
||||
import hep.dataforge.vision.solid.three.ThreeCanvasComponent
|
||||
import hep.dataforge.vision.solid.three.canvasControls
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.get
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.browser.window
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.await
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.css.*
|
||||
import kotlinx.html.js.onClickFunction
|
||||
import react.RProps
|
||||
import react.dom.*
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.w3c.fetch.RequestInit
|
||||
import react.Props
|
||||
import react.dom.attrs
|
||||
import react.dom.button
|
||||
import react.dom.p
|
||||
import react.fc
|
||||
import react.useMemo
|
||||
import react.useState
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.names.Name
|
||||
import space.kscience.visionforge.react.flexColumn
|
||||
import space.kscience.visionforge.react.flexRow
|
||||
import space.kscience.visionforge.ring.ThreeCanvasWithControls
|
||||
import space.kscience.visionforge.ring.tab
|
||||
import space.kscience.visionforge.solid.specifications.Camera
|
||||
import space.kscience.visionforge.solid.specifications.Canvas3DOptions
|
||||
import space.kscience.visionforge.solid.three.edges
|
||||
import styled.css
|
||||
import styled.styledDiv
|
||||
import styled.styledSpan
|
||||
import kotlin.math.PI
|
||||
|
||||
interface MMAppProps : RProps {
|
||||
external interface MMAppProps : Props {
|
||||
var model: Model
|
||||
var context: Context
|
||||
var connection: HttpClient
|
||||
var selected: Name?
|
||||
}
|
||||
|
||||
private val canvasConfig = Canvas3DOptions {
|
||||
camera = Camera {
|
||||
distance = 2100.0
|
||||
latitude = PI / 6
|
||||
azimuth = PI + PI / 6
|
||||
}
|
||||
}
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@JsExport
|
||||
val MMApp = fc<MMAppProps>("Muon monitor") { props ->
|
||||
|
||||
val MMApp = component<MMAppProps> { props ->
|
||||
var selected by state { props.selected }
|
||||
var canvas: ThreeCanvas? by state { null }
|
||||
|
||||
val select: (Name?) -> Unit = {
|
||||
selected = it
|
||||
}
|
||||
|
||||
val visual = props.model.root
|
||||
|
||||
div("row") {
|
||||
h1("mx-auto") {
|
||||
+"Muon monitor demo"
|
||||
}
|
||||
}
|
||||
div("row") {
|
||||
div("col-lg-3 px-0 overflow-auto") {
|
||||
//tree
|
||||
card("Object tree") {
|
||||
objectTree(visual, selected, select)
|
||||
val mmOptions = useMemo {
|
||||
Canvas3DOptions {
|
||||
camera = Camera {
|
||||
distance = 2100.0
|
||||
latitude = PI / 6
|
||||
azimuth = PI + PI / 6
|
||||
}
|
||||
}
|
||||
div("col-lg-6") {
|
||||
//canvas
|
||||
child(ThreeCanvasComponent::class) {
|
||||
attrs {
|
||||
this.context = props.context
|
||||
this.obj = visual
|
||||
this.options = canvasConfig
|
||||
this.selected = selected
|
||||
this.clickCallback = select
|
||||
this.canvasCallback = {
|
||||
canvas = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val root = useMemo(props.model) {
|
||||
props.model.root.apply {
|
||||
edges()
|
||||
}
|
||||
div("col-lg-3") {
|
||||
div("row") {
|
||||
//settings
|
||||
canvas?.let {
|
||||
card("Canvas configuration") {
|
||||
canvasControls(it)
|
||||
}
|
||||
}
|
||||
card("Events") {
|
||||
button {
|
||||
+"Next"
|
||||
attrs {
|
||||
onClickFunction = {
|
||||
GlobalScope.launch {
|
||||
val event = props.connection.get<Event>("http://localhost:8080/event")
|
||||
props.model.displayEvent(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
button {
|
||||
+"Clear"
|
||||
attrs {
|
||||
onClickFunction = {
|
||||
props.model.reset()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div("row") {
|
||||
div("container-fluid p-0") {
|
||||
nav {
|
||||
attrs {
|
||||
attributes["aria-label"] = "breadcrumb"
|
||||
}
|
||||
ol("breadcrumb") {
|
||||
li("breadcrumb-item") {
|
||||
button(classes = "btn btn-link p-0") {
|
||||
+"World"
|
||||
attrs {
|
||||
onClickFunction = {
|
||||
selected = hep.dataforge.names.Name.EMPTY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selected != null) {
|
||||
val tokens = ArrayList<NameToken>(selected?.length ?: 1)
|
||||
selected?.tokens?.forEach { token ->
|
||||
tokens.add(token)
|
||||
val fullName = Name(tokens.toList())
|
||||
li("breadcrumb-item") {
|
||||
button(classes = "btn btn-link p-0") {
|
||||
+token.toString()
|
||||
attrs {
|
||||
onClickFunction = {
|
||||
console.log("Selected = $fullName")
|
||||
selected = fullName
|
||||
}
|
||||
|
||||
var events: Set<Event> by useState(emptySet())
|
||||
|
||||
styledDiv {
|
||||
css {
|
||||
height = 100.vh - 12.pt
|
||||
}
|
||||
child(ThreeCanvasWithControls) {
|
||||
attrs {
|
||||
this.context = props.context
|
||||
this.builderOfSolid = CompletableDeferred(root)
|
||||
this.selected = props.selected
|
||||
this.options = mmOptions
|
||||
tab("Events") {
|
||||
flexColumn {
|
||||
flexRow {
|
||||
button {
|
||||
+"Next"
|
||||
attrs {
|
||||
onClickFunction = {
|
||||
context.launch {
|
||||
val event = window.fetch(
|
||||
"http://localhost:8080/event",
|
||||
RequestInit("GET")
|
||||
).then { response ->
|
||||
if (response.ok) {
|
||||
response.text()
|
||||
} else {
|
||||
error("Failed to get event")
|
||||
}
|
||||
}
|
||||
}.then { body ->
|
||||
Json.decodeFromString(Event.serializer(), body)
|
||||
}.await()
|
||||
events = events + event
|
||||
props.model.displayEvent(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
button {
|
||||
+"Clear"
|
||||
attrs {
|
||||
onClickFunction = {
|
||||
events = emptySet()
|
||||
props.model.reset()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div("row") {
|
||||
//properties
|
||||
card("Properties") {
|
||||
selected.let { selected ->
|
||||
val selectedObject: Vision? = when {
|
||||
selected == null -> null
|
||||
selected.isEmpty() -> visual
|
||||
else -> visual[selected]
|
||||
}
|
||||
if (selectedObject != null) {
|
||||
configEditor(selectedObject, default = selectedObject.getAllProperties(), key = selected)
|
||||
events.forEach { event ->
|
||||
p {
|
||||
styledSpan {
|
||||
+event.id.toString()
|
||||
}
|
||||
+" : "
|
||||
styledSpan {
|
||||
css {
|
||||
color = Color.blue
|
||||
}
|
||||
+event.hits.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// var selected by useState { props.selected }
|
||||
//
|
||||
// val onSelect: (Name?) -> Unit = {
|
||||
// selected = it
|
||||
// }
|
||||
//
|
||||
|
||||
//
|
||||
// gridRow {
|
||||
// flexColumn {
|
||||
// css {
|
||||
// +"col-lg-3"
|
||||
// +"order-lg-1"
|
||||
// +"order-2"
|
||||
// padding(0.px)
|
||||
// overflowY = Overflow.auto
|
||||
// height = 100.vh
|
||||
// }
|
||||
// //tree
|
||||
// card("Object tree") {
|
||||
// css {
|
||||
// flex(1.0, 1.0, FlexBasis.auto)
|
||||
// }
|
||||
// visionTree(root, selected, onSelect)
|
||||
// }
|
||||
// }
|
||||
// flexColumn {
|
||||
// css {
|
||||
// +"col-lg-6"
|
||||
// +"order-lg-2"
|
||||
// +"order-1"
|
||||
// height = 100.vh
|
||||
// }
|
||||
// h1("mx-auto page-header") {
|
||||
// +"Muon monitor demo"
|
||||
// }
|
||||
// //canvas
|
||||
//
|
||||
// child(ThreeCanvasComponent) {
|
||||
// attrs {
|
||||
// this.context = props.context
|
||||
// this.solid = root
|
||||
// this.selected = selected
|
||||
// this.options = mmOptions
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// flexColumn {
|
||||
// css {
|
||||
// +"col-lg-3"
|
||||
// +"order-3"
|
||||
// padding(0.px)
|
||||
// height = 100.vh
|
||||
// }
|
||||
// styledDiv {
|
||||
// css {
|
||||
// flex(0.0, 1.0, FlexBasis.zero)
|
||||
// }
|
||||
// //settings
|
||||
// card("Canvas configuration") {
|
||||
// canvasControls(mmOptions, root)
|
||||
// }
|
||||
//
|
||||
// card("Events") {
|
||||
// button {
|
||||
// +"Next"
|
||||
// attrs {
|
||||
// onClickFunction = {
|
||||
// GlobalScope.launch {
|
||||
// val event = props.connection.get<Event>("http://localhost:8080/event")
|
||||
// props.model.displayEvent(event)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// button {
|
||||
// +"Clear"
|
||||
// attrs {
|
||||
// onClickFunction = {
|
||||
// props.model.reset()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// styledDiv {
|
||||
// css {
|
||||
// padding(0.px)
|
||||
// }
|
||||
// nav {
|
||||
// attrs {
|
||||
// attributes["aria-label"] = "breadcrumb"
|
||||
// }
|
||||
// ol("breadcrumb") {
|
||||
// li("breadcrumb-item") {
|
||||
// button(classes = "btn btn-link p-0") {
|
||||
// +"World"
|
||||
// attrs {
|
||||
// onClickFunction = {
|
||||
// selected = Name.EMPTY
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (selected != null) {
|
||||
// val tokens = ArrayList<NameToken>(selected?.length ?: 1)
|
||||
// selected?.tokens?.forEach { token ->
|
||||
// tokens.add(token)
|
||||
// val fullName = Name(tokens.toList())
|
||||
// li("breadcrumb-item") {
|
||||
// button(classes = "btn btn-link p-0") {
|
||||
// +token.toString()
|
||||
// attrs {
|
||||
// onClickFunction = {
|
||||
// console.log("Selected = $fullName")
|
||||
// selected = fullName
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// styledDiv {
|
||||
// css {
|
||||
// overflowY = Overflow.auto
|
||||
// }
|
||||
// //properties
|
||||
// card("Properties") {
|
||||
// selected.let { selected ->
|
||||
// val selectedObject: Vision? = when {
|
||||
// selected == null -> null
|
||||
// selected.isEmpty() -> root
|
||||
// else -> root[selected]
|
||||
// }
|
||||
// if (selectedObject != null) {
|
||||
// visionPropertyEditor(selectedObject, key = selected)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
@ -1,43 +1,31 @@
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.js.Application
|
||||
import hep.dataforge.js.startApplication
|
||||
import hep.dataforge.vision.solid.SolidManager
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.features.json.JsonFeature
|
||||
import io.ktor.client.features.json.serializer.KotlinxSerializer
|
||||
import kotlinx.serialization.json.Json
|
||||
import react.child
|
||||
import react.dom.div
|
||||
import kotlinx.browser.document
|
||||
import react.dom.render
|
||||
import kotlin.browser.document
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.context.fetch
|
||||
import space.kscience.visionforge.Application
|
||||
import space.kscience.visionforge.VisionManager
|
||||
import space.kscience.visionforge.solid.three.ThreePlugin
|
||||
import space.kscience.visionforge.startApplication
|
||||
|
||||
private class MMDemoApp : Application {
|
||||
|
||||
private val model = Model()
|
||||
|
||||
private val connection = HttpClient {
|
||||
install(JsonFeature) {
|
||||
serializer = KotlinxSerializer(Json(context = SolidManager.serialModule))
|
||||
}
|
||||
}
|
||||
|
||||
//TODO introduce react application
|
||||
|
||||
override fun start(state: Map<String, Any>) {
|
||||
|
||||
val context = Global.context("demo") {}
|
||||
val element = document.getElementById("app") ?: error("Element with id 'app' not found on page")
|
||||
val context = Context("MM-demo") {
|
||||
plugin(ThreePlugin)
|
||||
}
|
||||
val visionManager = context.fetch(VisionManager)
|
||||
|
||||
val model = Model(visionManager)
|
||||
|
||||
val element = document.getElementById("app") ?: error("Element with id 'app' not found on page")
|
||||
render(element) {
|
||||
div("container-fluid h-100") {
|
||||
child(MMApp) {
|
||||
attrs {
|
||||
model = this@MMDemoApp.model
|
||||
connection = this@MMDemoApp.connection
|
||||
this.context = context
|
||||
}
|
||||
child(MMApp) {
|
||||
attrs {
|
||||
this.model = model
|
||||
this.context = context
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import hep.dataforge.js.requireJS
|
||||
|
||||
actual fun readResource(path: String): String {
|
||||
return requireJS(path) as String
|
||||
return kotlinext.js.require(path) as String
|
||||
}
|
||||
|
||||
// TODO replace by resource
|
||||
|
@ -4,13 +4,10 @@
|
||||
<meta charset="utf-8">
|
||||
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">-->
|
||||
<title>Three js demo for particle physics</title>
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<script type="text/javascript" src="main.bundle.js"></script>
|
||||
<script type="text/javascript" src ="js/jquery-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src ="js/bootstrap.bundle.min.js"></script>
|
||||
<script type="text/javascript" src="muon-monitor.js"></script>
|
||||
<link rel="stylesheet" href="css/custom-bootstrap.css">
|
||||
</head>
|
||||
<body class="application">
|
||||
<div class="container-fluid" id = "app"> </div>
|
||||
<div class="container-fluid max-vh-100" id = "app"> </div>
|
||||
</body>
|
||||
</html>
|
@ -1,7 +1,6 @@
|
||||
package ru.mipt.npm.muon.monitor.server
|
||||
|
||||
|
||||
import hep.dataforge.vision.solid.SolidManager
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.application.call
|
||||
import io.ktor.application.install
|
||||
@ -9,34 +8,42 @@ import io.ktor.application.log
|
||||
import io.ktor.features.CallLogging
|
||||
import io.ktor.features.ContentNegotiation
|
||||
import io.ktor.features.DefaultHeaders
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.http.content.resources
|
||||
import io.ktor.http.content.static
|
||||
import io.ktor.response.respond
|
||||
import io.ktor.response.respondText
|
||||
import io.ktor.routing.Routing
|
||||
import io.ktor.routing.get
|
||||
import io.ktor.serialization.json
|
||||
import io.ktor.server.cio.CIO
|
||||
import io.ktor.server.engine.embeddedServer
|
||||
import io.ktor.util.KtorExperimentalAPI
|
||||
import org.apache.commons.math3.random.JDKRandomGenerator
|
||||
import ru.mipt.npm.muon.monitor.Model
|
||||
import ru.mipt.npm.muon.monitor.sim.Cos2TrackGenerator
|
||||
import ru.mipt.npm.muon.monitor.sim.simulateOne
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.context.Global
|
||||
import space.kscience.dataforge.context.fetch
|
||||
import space.kscience.dataforge.misc.DFExperimental
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
import java.awt.Desktop
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
|
||||
private val generator = Cos2TrackGenerator(JDKRandomGenerator(223))
|
||||
|
||||
fun Application.module() {
|
||||
@OptIn(DFExperimental::class)
|
||||
fun Application.module(context: Context = Global) {
|
||||
val currentDir = File(".").absoluteFile
|
||||
environment.log.info("Current directory: $currentDir")
|
||||
|
||||
val solidManager = context.fetch(Solids)
|
||||
|
||||
install(DefaultHeaders)
|
||||
install(CallLogging)
|
||||
install(ContentNegotiation) {
|
||||
json(module = SolidManager.serialModule)
|
||||
json()
|
||||
}
|
||||
install(Routing) {
|
||||
get("/event") {
|
||||
@ -44,7 +51,11 @@ fun Application.module() {
|
||||
call.respond(event)
|
||||
}
|
||||
get("/geometry") {
|
||||
call.respond(Model.buildGeometry())
|
||||
call.respondText(
|
||||
Model(solidManager.visionManager).encodeToString(),
|
||||
contentType = ContentType.Application.Json,
|
||||
status = HttpStatusCode.OK
|
||||
)
|
||||
}
|
||||
static("/") {
|
||||
resources()
|
||||
@ -57,7 +68,6 @@ fun Application.module() {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(KtorExperimentalAPI::class)
|
||||
fun main() {
|
||||
embeddedServer(CIO, 8080, host = "localhost", module = Application::module).start(wait = true)
|
||||
}
|
@ -16,20 +16,20 @@ 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 / 2.0)//Layer("${name}_up", center.z + zSize / 2.0);
|
||||
private val bottomLayer =
|
||||
findLayer(sc.center.z - sc.zSize / 2.0)//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, sc.center.y, sc.center.z)
|
||||
private val center = Vector3D(sc.center.x.toDouble(), sc.center.y.toDouble(), sc.center.z.toDouble())
|
||||
|
||||
private val sideLayers: Array<Plane> = arrayOf(
|
||||
Plane(center.add(Vector3D(PIXEL_XY_SIZE / 2, 0.0, 0.0)), Vector3D(1.0, 0.0, 0.0), GEOMETRY_TOLERANCE),
|
||||
Plane(center.add(Vector3D(-PIXEL_XY_SIZE / 2, 0.0, 0.0)), Vector3D(-1.0, 0.0, 0.0), GEOMETRY_TOLERANCE),
|
||||
Plane(center.add(Vector3D(0.0, PIXEL_XY_SIZE / 2, 0.0)), Vector3D(0.0, 1.0, 0.0), GEOMETRY_TOLERANCE),
|
||||
Plane(center.add(Vector3D(0.0, -PIXEL_XY_SIZE / 2, 0.0)), Vector3D(0.0, -1.0, 0.0), GEOMETRY_TOLERANCE)
|
||||
);
|
||||
Plane(center.add(Vector3D(PIXEL_XY_SIZE / 2.0, 0.0, 0.0)), Vector3D(1.0, 0.0, 0.0), GEOMETRY_TOLERANCE),
|
||||
Plane(center.add(Vector3D(-PIXEL_XY_SIZE / 2.0, 0.0, 0.0)), Vector3D(-1.0, 0.0, 0.0), GEOMETRY_TOLERANCE),
|
||||
Plane(center.add(Vector3D(0.0, PIXEL_XY_SIZE / 2.0, 0.0)), Vector3D(0.0, 1.0, 0.0), GEOMETRY_TOLERANCE),
|
||||
Plane(center.add(Vector3D(0.0, -PIXEL_XY_SIZE / 2.0, 0.0)), Vector3D(0.0, -1.0, 0.0), GEOMETRY_TOLERANCE)
|
||||
)
|
||||
|
||||
//TODO add efficiency
|
||||
private fun containsPoint(x: Double, y: Double, z: Double, tolerance: Double = GEOMETRY_TOLERANCE): Boolean {
|
||||
@ -63,11 +63,11 @@ internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
|
||||
* The layer number from up to bottom
|
||||
*/
|
||||
fun getLayerNumber(): Int {
|
||||
return when (this.center.z) {
|
||||
UPPER_LAYER_Z -> 1;
|
||||
return when (this.center.z.toFloat()) {
|
||||
UPPER_LAYER_Z -> 1
|
||||
CENTRAL_LAYER_Z -> 2;
|
||||
LOWER_LAYER_Z -> 3;
|
||||
else -> throw RuntimeException("Unknown layer");
|
||||
else -> error("Unknown layer");
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,8 +115,8 @@ internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) {
|
||||
|
||||
private val auxCache = HashMap<SC1, SC1Aux>()
|
||||
|
||||
fun SC1.isHit(track: Line): Boolean{
|
||||
return auxCache.getOrPut(this){
|
||||
fun SC1.isHit(track: Line): Boolean {
|
||||
return auxCache.getOrPut(this) {
|
||||
SC1Aux(this)
|
||||
}.isHit(track)
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package ru.mipt.npm.muon.monitor.sim
|
||||
|
||||
import hep.dataforge.vision.solid.Point3D
|
||||
import org.apache.commons.math3.geometry.euclidean.threed.Line
|
||||
import org.apache.commons.math3.geometry.euclidean.threed.Plane
|
||||
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D
|
||||
import ru.mipt.npm.muon.monitor.Monitor.CENTRAL_LAYER_Z
|
||||
import ru.mipt.npm.muon.monitor.Monitor.GEOMETRY_TOLERANCE
|
||||
import space.kscience.visionforge.solid.Point3D
|
||||
|
||||
/**
|
||||
* Created by darksnake on 11-May-16.
|
||||
@ -45,7 +45,7 @@ fun makeTrack(start: Vector3D, direction: Vector3D): Line {
|
||||
fun makeTrack(x: Double, y: Double, theta: Double, phi: Double): Line {
|
||||
//TODO check angle definitions
|
||||
return makeTrack(
|
||||
Vector3D(x, y, CENTRAL_LAYER_Z),
|
||||
Vector3D(x, y, CENTRAL_LAYER_Z.toDouble()),
|
||||
Vector3D(phi, theta)
|
||||
)
|
||||
}
|
||||
|
@ -7,19 +7,18 @@ import ru.mipt.npm.muon.monitor.Event
|
||||
import ru.mipt.npm.muon.monitor.Monitor
|
||||
import ru.mipt.npm.muon.monitor.SC1
|
||||
import ru.mipt.npm.muon.monitor.readResource
|
||||
import java.util.*
|
||||
|
||||
|
||||
// minimal track length in detector
|
||||
internal const val MINIMAL_TRACK_LENGTH = 10.0
|
||||
|
||||
|
||||
private val layerCache = HashMap<Double, Plane>()
|
||||
private val layerCache = HashMap<Float, Plane>()
|
||||
|
||||
fun findLayer(z: Double): Plane = layerCache.getOrPut(z) {
|
||||
fun findLayer(z: Float): Plane = layerCache.getOrPut(z) {
|
||||
Plane(
|
||||
Vector3D(0.0, 0.0, z), Vector3D(0.0, 0.0, 1.0),
|
||||
Monitor.GEOMETRY_TOLERANCE
|
||||
Vector3D(0.0, 0.0, z.toDouble()), Vector3D(0.0, 0.0, 1.0),
|
||||
Monitor.GEOMETRY_TOLERANCE.toDouble()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@ interface TrackGenerator {
|
||||
*/
|
||||
class UniformTrackGenerator(
|
||||
override val rnd: RandomGenerator,
|
||||
val maxX: Double = 4 * PIXEL_XY_SIZE,
|
||||
val maxY: Double = 4 * PIXEL_XY_SIZE
|
||||
val maxX: Float = 4 * PIXEL_XY_SIZE,
|
||||
val maxY: Float = 4 * PIXEL_XY_SIZE
|
||||
) :
|
||||
TrackGenerator {
|
||||
override fun generate(): Line {
|
||||
@ -44,8 +44,8 @@ class UniformTrackGenerator(
|
||||
class FixedAngleGenerator(
|
||||
override val rnd: RandomGenerator,
|
||||
val phi: Double, val theta: Double,
|
||||
val maxX: Double = 4 * PIXEL_XY_SIZE,
|
||||
val maxY: Double = 4 * PIXEL_XY_SIZE
|
||||
val maxX: Float = 4 * PIXEL_XY_SIZE,
|
||||
val maxY: Float = 4 * PIXEL_XY_SIZE
|
||||
) : TrackGenerator {
|
||||
override fun generate(): Line {
|
||||
val x = (1 - rnd.nextDouble() * 2.0) * maxX
|
||||
@ -60,8 +60,8 @@ class FixedAngleGenerator(
|
||||
class Cos2TrackGenerator(
|
||||
override val rnd: RandomGenerator,
|
||||
val power: Double = 2.0,
|
||||
val maxX: Double = 4 * PIXEL_XY_SIZE,
|
||||
val maxY: Double = 4 * PIXEL_XY_SIZE
|
||||
val maxX: Float = 4 * PIXEL_XY_SIZE,
|
||||
val maxY: Float = 4 * PIXEL_XY_SIZE
|
||||
) :
|
||||
TrackGenerator {
|
||||
override fun generate(): Line {
|
||||
@ -78,6 +78,6 @@ class Cos2TrackGenerator(
|
||||
return makeTrack(x, y, thetaCandidate, phi)
|
||||
}
|
||||
}
|
||||
throw RuntimeException("Failed to generate theta from distribution")
|
||||
error("Failed to generate theta from distribution")
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package ru.mipt.npm.muon.monitor
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class GeometryTest {
|
||||
|
||||
|
3
demo/muon-monitor/webpack.config.d/01.ring.js
vendored
Normal file
3
demo/muon-monitor/webpack.config.d/01.ring.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const ringConfig = require('@jetbrains/ring-ui/webpack.config').config;
|
||||
|
||||
config.module.rules.push(...ringConfig.module.rules)
|
4
demo/playground/README.md
Normal file
4
demo/playground/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Module playground
|
||||
|
||||
|
||||
|
60
demo/playground/api/playground.api
Normal file
60
demo/playground/api/playground.api
Normal file
@ -0,0 +1,60 @@
|
||||
public final class space/kscience/visionforge/examples/AllThingsDemoKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/FormServerKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/GdmlCubesKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/GdmlCurveKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/GdmlIaxoKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/GenerateSchemaKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/PlotlyVisionKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/RandomSpheresKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/RootParserKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/ServerExtensionsKt {
|
||||
public static final fun makeVisionFile (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;)V
|
||||
public static synthetic fun makeVisionFile$default (Ljava/nio/file/Path;Ljava/lang/String;Lspace/kscience/visionforge/html/ResourceLocation;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/SimpleCubeKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class space/kscience/visionforge/examples/TablesKt {
|
||||
public static final fun main ()V
|
||||
public static synthetic fun main ([Ljava/lang/String;)V
|
||||
}
|
||||
|
90
demo/playground/build.gradle.kts
Normal file
90
demo/playground/build.gradle.kts
Normal file
@ -0,0 +1,90 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
kotlin("jupyter.api")
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.kotlin.link")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
js(IR) {
|
||||
useCommonJs()
|
||||
browser {
|
||||
webpackTask {
|
||||
this.outputFileName = "js/visionforge-playground.js"
|
||||
}
|
||||
commonWebpackConfig {
|
||||
sourceMaps = true
|
||||
cssSupport.enabled = false
|
||||
}
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
jvm {
|
||||
withJava()
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
freeCompilerArgs =
|
||||
freeCompilerArgs + "-Xjvm-default=all" + "-Xopt-in=kotlin.RequiresOptIn" + "-Xlambdas=indy"
|
||||
}
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(projects.visionforgeSolid)
|
||||
implementation(projects.visionforgeGdml)
|
||||
implementation(projects.visionforgePlotly)
|
||||
implementation(projects.visionforgeMarkdown)
|
||||
implementation(projects.visionforgeTables)
|
||||
implementation(projects.cernRootLoader)
|
||||
implementation(projects.jupyter)
|
||||
}
|
||||
}
|
||||
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(projects.ui.ring)
|
||||
implementation(projects.visionforgeThreejs)
|
||||
compileOnly(npm("webpack-bundle-analyzer","4.5.0"))
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(projects.visionforgeServer)
|
||||
implementation("ch.qos.logback:logback-classic:1.2.3")
|
||||
implementation("com.github.Ricky12Awesome:json-schema-serialization:0.6.6")
|
||||
}
|
||||
}
|
||||
all {
|
||||
languageSettings.optIn("space.kscience.dataforge.misc.DFExperimental")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val jsBrowserDistribution = tasks.getByName("jsBrowserDistribution")
|
||||
|
||||
tasks.getByName<ProcessResources>("jvmProcessResources") {
|
||||
dependsOn(jsBrowserDistribution)
|
||||
from(jsBrowserDistribution) {
|
||||
exclude("**/*.js.map")
|
||||
}
|
||||
}
|
||||
|
||||
val processJupyterApiResources by tasks.getting(org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask::class) {
|
||||
libraryProducers = listOf("space.kscience.visionforge.examples.VisionForgePlayGroundForJupyter")
|
||||
}
|
||||
|
||||
tasks.findByName("shadowJar")?.dependsOn(processJupyterApiResources)
|
14
demo/playground/src/jsMain/kotlin/playgroundMain.kt
Normal file
14
demo/playground/src/jsMain/kotlin/playgroundMain.kt
Normal file
@ -0,0 +1,14 @@
|
||||
import space.kscience.dataforge.misc.DFExperimental
|
||||
import space.kscience.visionforge.markup.MarkupPlugin
|
||||
import space.kscience.visionforge.plotly.PlotlyPlugin
|
||||
import space.kscience.visionforge.ring.ThreeWithControlsPlugin
|
||||
import space.kscience.visionforge.runVisionClient
|
||||
import space.kscience.visionforge.tables.TableVisionJsPlugin
|
||||
|
||||
@DFExperimental
|
||||
fun main() = runVisionClient {
|
||||
plugin(ThreeWithControlsPlugin)
|
||||
plugin(PlotlyPlugin)
|
||||
plugin(MarkupPlugin)
|
||||
plugin(TableVisionJsPlugin)
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import org.jetbrains.kotlinx.jupyter.api.libraries.resources
|
||||
import space.kscience.dataforge.context.Context
|
||||
import space.kscience.dataforge.misc.DFExperimental
|
||||
import space.kscience.gdml.Gdml
|
||||
import space.kscience.plotly.Plot
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.jupyter.JupyterPluginBase
|
||||
import space.kscience.visionforge.plotly.PlotlyPlugin
|
||||
import space.kscience.visionforge.plotly.asVision
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
|
||||
@DFExperimental
|
||||
internal class VisionForgePlayGroundForJupyter : JupyterPluginBase(
|
||||
Context("VisionForge") {
|
||||
plugin(Solids)
|
||||
plugin(PlotlyPlugin)
|
||||
}
|
||||
) {
|
||||
|
||||
override fun Builder.afterLoaded() {
|
||||
resources {
|
||||
js("VisionForge") {
|
||||
classPath("js/visionforge-playground.js")
|
||||
}
|
||||
}
|
||||
|
||||
import(
|
||||
"space.kscience.gdml.*",
|
||||
"space.kscience.plotly.*",
|
||||
"space.kscience.plotly.models.*",
|
||||
"space.kscience.visionforge.solid.*",
|
||||
)
|
||||
|
||||
|
||||
render<Gdml> { gdmlModel ->
|
||||
handler.produceHtml {
|
||||
vision { gdmlModel.toVision() }
|
||||
}
|
||||
}
|
||||
|
||||
render<Plot> { plot ->
|
||||
handler.produceHtml {
|
||||
vision { plot.asVision() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
174
demo/playground/src/jvmMain/kotlin/allThingsDemo.kt
Normal file
174
demo/playground/src/jvmMain/kotlin/allThingsDemo.kt
Normal file
@ -0,0 +1,174 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import kotlinx.html.h2
|
||||
import space.kscience.dataforge.values.ValueType
|
||||
import space.kscience.plotly.layout
|
||||
import space.kscience.plotly.models.ScatterMode
|
||||
import space.kscience.plotly.models.TextPosition
|
||||
import space.kscience.plotly.scatter
|
||||
import space.kscience.tables.ColumnHeader
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.markup.markdown
|
||||
import space.kscience.visionforge.plotly.plotly
|
||||
import space.kscience.visionforge.solid.box
|
||||
import space.kscience.visionforge.solid.solid
|
||||
import space.kscience.visionforge.solid.z
|
||||
import space.kscience.visionforge.tables.columnTable
|
||||
import java.nio.file.Paths
|
||||
|
||||
|
||||
fun main() = makeVisionFile(
|
||||
Paths.get("VisionForgeDemo.html"),
|
||||
resourceLocation = ResourceLocation.EMBED
|
||||
) {
|
||||
markdown {
|
||||
//language=markdown
|
||||
"""
|
||||
# VisionForge
|
||||
|
||||
This is a demo for current VisionForge features. This text is written in [MarkDown](https://github.com/JetBrains/markdown)
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
h2 { +"3D visualization with Three-js" }
|
||||
vision("3D") {
|
||||
solid {
|
||||
box(100, 100, 100, name = "aBox"){
|
||||
z = 50.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
h2 { +"Interactive plots with Plotly" }
|
||||
vision("plot") {
|
||||
plotly {
|
||||
scatter {
|
||||
x(1, 2, 3, 4)
|
||||
y(10, 15, 13, 17)
|
||||
mode = ScatterMode.markers
|
||||
name = "Team A"
|
||||
text("A-1", "A-2", "A-3", "A-4", "A-5")
|
||||
textposition = TextPosition.`top center`
|
||||
textfont {
|
||||
family = "Raleway, sans-serif"
|
||||
}
|
||||
marker { size = 12 }
|
||||
}
|
||||
|
||||
scatter {
|
||||
x(2, 3, 4, 5)
|
||||
y(10, 15, 13, 17)
|
||||
mode = ScatterMode.lines
|
||||
name = "Team B"
|
||||
text("B-a", "B-b", "B-c", "B-d", "B-e")
|
||||
textposition = TextPosition.`bottom center`
|
||||
textfont {
|
||||
family = "Times New Roman"
|
||||
}
|
||||
marker { size = 12 }
|
||||
}
|
||||
|
||||
layout {
|
||||
title = "Data Labels Hover"
|
||||
xaxis {
|
||||
range(0.75..5.25)
|
||||
}
|
||||
legend {
|
||||
y = 0.5
|
||||
font {
|
||||
family = "Arial, sans-serif"
|
||||
size = 20
|
||||
color("grey")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
h2 { +"Interactive tables with Tabulator" }
|
||||
vision("table") {
|
||||
val x by ColumnHeader.value(ValueType.NUMBER)
|
||||
val y by ColumnHeader.value(ValueType.NUMBER)
|
||||
columnTable(
|
||||
x to listOf(2, 3, 4, 5),
|
||||
y to listOf(10, 15, 13, 17)
|
||||
)
|
||||
}
|
||||
markdown {
|
||||
//language=markdown
|
||||
"""
|
||||
## The code for everything above
|
||||
```kotlin
|
||||
markdown {
|
||||
//language=markdown
|
||||
""${'"'}
|
||||
# VisionForge
|
||||
|
||||
This is a demo for current VisionForge features. This text is written in [MarkDown](https://github.com/JetBrains/markdown)
|
||||
""${'"'}.trimIndent()
|
||||
}
|
||||
|
||||
h2 { +"3D visualization with Three-js" }
|
||||
vision("3D") {
|
||||
solid {
|
||||
box(100, 100, 100, name = "aBox")
|
||||
}
|
||||
}
|
||||
|
||||
h2 { +"Interactive plots with Plotly" }
|
||||
vision("plot") {
|
||||
plotly {
|
||||
scatter {
|
||||
x(1, 2, 3, 4)
|
||||
y(10, 15, 13, 17)
|
||||
mode = ScatterMode.markers
|
||||
name = "Team A"
|
||||
text("A-1", "A-2", "A-3", "A-4", "A-5")
|
||||
textposition = TextPosition.`top center`
|
||||
textfont {
|
||||
family = "Raleway, sans-serif"
|
||||
}
|
||||
marker { size = 12 }
|
||||
}
|
||||
|
||||
scatter {
|
||||
x(2, 3, 4, 5)
|
||||
y(10, 15, 13, 17)
|
||||
mode = ScatterMode.lines
|
||||
name = "Team B"
|
||||
text("B-a", "B-b", "B-c", "B-d", "B-e")
|
||||
textposition = TextPosition.`bottom center`
|
||||
textfont {
|
||||
family = "Times New Roman"
|
||||
}
|
||||
marker { size = 12 }
|
||||
}
|
||||
|
||||
layout {
|
||||
title = "Data Labels Hover"
|
||||
xaxis {
|
||||
range(0.75..5.25)
|
||||
}
|
||||
legend {
|
||||
y = 0.5
|
||||
font {
|
||||
family = "Arial, sans-serif"
|
||||
size = 20
|
||||
color("grey")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
h2 { +"Interactive tables with Tabulator" }
|
||||
vision("table") {
|
||||
val x by ColumnHeader.value(ValueType.NUMBER)
|
||||
val y by ColumnHeader.value(ValueType.NUMBER)
|
||||
columnTable(
|
||||
x to listOf(2, 3, 4, 5),
|
||||
y to listOf(10, 15, 13, 17)
|
||||
)
|
||||
}
|
||||
```
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
65
demo/playground/src/jvmMain/kotlin/formServer.kt
Normal file
65
demo/playground/src/jvmMain/kotlin/formServer.kt
Normal file
@ -0,0 +1,65 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import kotlinx.html.*
|
||||
import space.kscience.dataforge.context.Global
|
||||
import space.kscience.dataforge.context.fetch
|
||||
import space.kscience.visionforge.VisionManager
|
||||
import space.kscience.visionforge.html.Page
|
||||
import space.kscience.visionforge.html.formFragment
|
||||
import space.kscience.visionforge.onPropertyChange
|
||||
import space.kscience.visionforge.server.close
|
||||
import space.kscience.visionforge.server.openInBrowser
|
||||
import space.kscience.visionforge.server.serve
|
||||
|
||||
fun main() {
|
||||
val visionManager = Global.fetch(VisionManager)
|
||||
|
||||
val server = visionManager.serve {
|
||||
page(header = Page.scriptHeader("js/visionforge-playground.js")) {
|
||||
val form = formFragment("form") {
|
||||
label {
|
||||
htmlFor = "fname"
|
||||
+"First name:"
|
||||
}
|
||||
br()
|
||||
input {
|
||||
type = InputType.text
|
||||
id = "fname"
|
||||
name = "fname"
|
||||
value = "John"
|
||||
}
|
||||
br()
|
||||
label {
|
||||
htmlFor = "lname"
|
||||
+"Last name:"
|
||||
}
|
||||
br()
|
||||
input {
|
||||
type = InputType.text
|
||||
id = "lname"
|
||||
name = "lname"
|
||||
value = "Doe"
|
||||
}
|
||||
br()
|
||||
br()
|
||||
input {
|
||||
type = InputType.submit
|
||||
value = "Submit"
|
||||
}
|
||||
}
|
||||
|
||||
vision("form") { form }
|
||||
form.onPropertyChange {
|
||||
println(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server.openInBrowser()
|
||||
|
||||
while (readln() != "exit") {
|
||||
|
||||
}
|
||||
|
||||
server.close()
|
||||
}
|
13
demo/playground/src/jvmMain/kotlin/gdmlCubes.kt
Normal file
13
demo/playground/src/jvmMain/kotlin/gdmlCubes.kt
Normal file
@ -0,0 +1,13 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import space.kscience.gdml.GdmlShowCase
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
|
||||
fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM){
|
||||
vision("canvas") {
|
||||
requirePlugin(Solids)
|
||||
GdmlShowCase.cubes().toVision()
|
||||
}
|
||||
}
|
240
demo/playground/src/jvmMain/kotlin/gdmlCurve.kt
Normal file
240
demo/playground/src/jvmMain/kotlin/gdmlCurve.kt
Normal file
@ -0,0 +1,240 @@
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import space.kscience.gdml.*
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
import space.kscience.visionforge.solid.color
|
||||
import space.kscience.visionforge.solid.invoke
|
||||
import space.kscience.visionforge.visible
|
||||
import java.nio.file.Path
|
||||
|
||||
fun main() = makeVisionFile(Path.of("curves.html"), resourceLocation = ResourceLocation.EMBED) {
|
||||
vision("canvas") {
|
||||
requirePlugin(Solids)
|
||||
Gdml {
|
||||
// geometry variables
|
||||
val worldSize = 500
|
||||
// chamber
|
||||
val chamberHeight = 30 // length of the chamber
|
||||
val chamberDiameter = 102 // inner diameter of the copper chamber
|
||||
val chamberOuterSquareSide = 134 // chamber has a square footprint
|
||||
val chamberBackplateThickness = 15 // thickness of the backplate of the chamber
|
||||
// teflon disk
|
||||
val cathodeTeflonDiskHoleRadius = 15
|
||||
val cathodeTeflonDiskThickness = 5
|
||||
val cathodeCopperSupportOuterRadius = 45
|
||||
val cathodeCopperSupportInnerRadius = 8.5
|
||||
val cathodeCopperSupportThickness = 1
|
||||
// mylar cathode
|
||||
val mylarCathodeThickness = 0.004
|
||||
// patern
|
||||
val cathodePatternLineWidth = 0.3
|
||||
val cathodePatternDiskRadius = 4.25
|
||||
// readout
|
||||
val chamberTeflonWallThickness = 1
|
||||
val readoutKaptonThickness = 0.5
|
||||
val readoutCopperThickness = 0.2
|
||||
val readoutPlaneSide = 60
|
||||
|
||||
structure {
|
||||
val worldMaterial = materials.composite("G4_AIR")
|
||||
val worldBox = solids.box(worldSize, worldSize, worldSize, name = "world")
|
||||
|
||||
val shieldingMaterial = materials.composite("G4_Pb")
|
||||
val scintillatorMaterial = materials.composite("BC408")
|
||||
val captureMaterial = materials.composite("G4_Cd")
|
||||
|
||||
// chamber
|
||||
val copperMaterial = materials.composite("G4_Cu")
|
||||
val chamberSolidBase = solids.box(chamberOuterSquareSide, chamberOuterSquareSide, chamberHeight)
|
||||
val chamberSolidHole = solids.tube(chamberDiameter / 2, chamberHeight)
|
||||
val chamberSolid = solids.subtraction(chamberSolidBase, chamberSolidHole)
|
||||
val chamberBodyVolume = volume(copperMaterial, chamberSolid)
|
||||
val chamberBackplateSolid =
|
||||
solids.box(chamberOuterSquareSide, chamberOuterSquareSide, chamberBackplateThickness)
|
||||
val chamberBackplateVolume = volume(copperMaterial, chamberBackplateSolid)
|
||||
// chamber teflon walls
|
||||
val teflonMaterial = materials.composite("G4_TEFLON")
|
||||
val chamberTeflonWallSolid = solids.tube(chamberDiameter / 2, chamberHeight) {
|
||||
rmin = chamberDiameter / 2.0 - chamberTeflonWallThickness
|
||||
}
|
||||
val chamberTeflonWallVolume = volume(teflonMaterial, chamberTeflonWallSolid)
|
||||
// cathode
|
||||
val cathodeCopperDiskMaterial = materials.composite("G4_Cu")
|
||||
val cathodeWindowMaterial = materials.composite("G4_MYLAR")
|
||||
|
||||
val cathodeTeflonDiskSolidBase =
|
||||
solids.tube(chamberOuterSquareSide / 2, cathodeTeflonDiskThickness) {
|
||||
rmin = cathodeTeflonDiskHoleRadius
|
||||
}
|
||||
val cathodeCopperDiskSolid =
|
||||
solids.tube(cathodeCopperSupportOuterRadius, cathodeCopperSupportThickness) {
|
||||
rmin = cathodeCopperSupportInnerRadius
|
||||
}
|
||||
|
||||
val cathodeTeflonDiskSolid = solids.subtraction(cathodeTeflonDiskSolidBase, cathodeCopperDiskSolid)
|
||||
val cathodeTeflonDiskVolume = volume(teflonMaterial, cathodeTeflonDiskSolid)
|
||||
|
||||
val cathodeWindowSolid = solids.tube(cathodeTeflonDiskHoleRadius, mylarCathodeThickness)
|
||||
val cathodeWindowVolume = volume(cathodeWindowMaterial, cathodeWindowSolid)
|
||||
|
||||
val cathodeFillingMaterial = materials.composite("G4_Galactic")
|
||||
val cathodeFillingSolidBase = solids.tube(cathodeTeflonDiskHoleRadius, cathodeTeflonDiskThickness)
|
||||
|
||||
val cathodeFillingSolid = solids.subtraction(cathodeFillingSolidBase, cathodeCopperDiskSolid) {
|
||||
position(z = chamberHeight / 2 - mylarCathodeThickness / 2)
|
||||
}
|
||||
val cathodeFillingVolume = volume(cathodeFillingMaterial, cathodeFillingSolid)
|
||||
|
||||
// pattern
|
||||
val cathodePatternLineAux = solids.box(
|
||||
cathodePatternLineWidth,
|
||||
cathodeCopperSupportInnerRadius * 2,
|
||||
cathodeCopperSupportThickness
|
||||
)
|
||||
val cathodePatternCentralHole = solids.tube(
|
||||
cathodePatternDiskRadius - 0 * cathodePatternLineWidth,
|
||||
cathodeCopperSupportThickness * 1.1
|
||||
)
|
||||
val cathodePatternLine = solids.subtraction(cathodePatternLineAux, cathodePatternCentralHole)
|
||||
|
||||
val cathodePatternDisk = solids.tube(
|
||||
cathodePatternDiskRadius,
|
||||
cathodeCopperSupportThickness
|
||||
) { rmin = cathodePatternDiskRadius - cathodePatternLineWidth }
|
||||
|
||||
|
||||
val cathodeCopperDiskSolidAux0 =
|
||||
solids.union(cathodeCopperDiskSolid, cathodePatternLine) {
|
||||
rotation(x = 0, y = 0, z = 0)
|
||||
}
|
||||
val cathodeCopperDiskSolidAux1 =
|
||||
solids.union(cathodeCopperDiskSolidAux0, cathodePatternLine) {
|
||||
rotation = GdmlRotation(
|
||||
"cathodePatternRotation1", x = 0, y = 0, z = 45
|
||||
)
|
||||
}
|
||||
val cathodeCopperDiskSolidAux2 =
|
||||
solids.union(cathodeCopperDiskSolidAux1, cathodePatternLine) {
|
||||
rotation = GdmlRotation(
|
||||
"cathodePatternRotation2", x = 0, y = 0, z = 90
|
||||
)
|
||||
}
|
||||
val cathodeCopperDiskSolidAux3 =
|
||||
solids.union(cathodeCopperDiskSolidAux2, cathodePatternLine) {
|
||||
rotation = GdmlRotation(
|
||||
"cathodePatternRotation3", x = 0, y = 0, z = 135
|
||||
)
|
||||
}
|
||||
|
||||
val cathodeCopperDiskFinal =
|
||||
solids.union(cathodeCopperDiskSolidAux3, cathodePatternDisk)
|
||||
|
||||
|
||||
val cathodeCopperDiskVolume =
|
||||
volume(cathodeCopperDiskMaterial, cathodeCopperDiskFinal)
|
||||
|
||||
val gasSolidOriginal = solids.tube(
|
||||
chamberDiameter / 2 - chamberTeflonWallThickness,
|
||||
chamberHeight
|
||||
)
|
||||
|
||||
val kaptonReadoutMaterial = materials.composite("G4_KAPTON")
|
||||
val kaptonReadoutSolid = solids.box(
|
||||
chamberOuterSquareSide,
|
||||
chamberOuterSquareSide,
|
||||
readoutKaptonThickness)
|
||||
val kaptonReadoutVolume = volume( kaptonReadoutMaterial, kaptonReadoutSolid)
|
||||
|
||||
val copperReadoutSolid =
|
||||
solids.box(readoutPlaneSide, readoutPlaneSide, readoutCopperThickness)
|
||||
val copperReadoutVolume = volume(copperMaterial, copperReadoutSolid)
|
||||
|
||||
val gasSolidAux =
|
||||
solids.subtraction(gasSolidOriginal, copperReadoutSolid) {
|
||||
position(z = -chamberHeight / 2 + readoutCopperThickness / 2)
|
||||
}
|
||||
|
||||
val gasMaterial = materials.composite("G4_Ar")
|
||||
val gasSolid =
|
||||
solids.subtraction( gasSolidAux, cathodeWindowSolid) {
|
||||
position(z = chamberHeight / 2 - mylarCathodeThickness / 2)
|
||||
rotation(z = 45)
|
||||
}
|
||||
val gasVolume = volume(gasMaterial, gasSolid)
|
||||
|
||||
// world setup
|
||||
world = volume(worldMaterial, worldBox) {
|
||||
physVolume(gasVolume) {
|
||||
name = "gas"
|
||||
}
|
||||
physVolume(kaptonReadoutVolume) {
|
||||
name = "kaptonReadout"
|
||||
position {
|
||||
z = -chamberHeight / 2 - readoutKaptonThickness / 2
|
||||
}
|
||||
}
|
||||
physVolume(copperReadoutVolume) {
|
||||
name = "copperReadout"
|
||||
position {
|
||||
z = -chamberHeight / 2 + readoutCopperThickness / 2
|
||||
}
|
||||
rotation { z = 45 }
|
||||
}
|
||||
physVolume(chamberBodyVolume) {
|
||||
name = "chamberBody"
|
||||
}
|
||||
physVolume(chamberBackplateVolume) {
|
||||
name = "chamberBackplate"
|
||||
position {
|
||||
z = -chamberHeight / 2 - readoutKaptonThickness - chamberBackplateThickness / 2
|
||||
}
|
||||
}
|
||||
physVolume(chamberTeflonWallVolume) {
|
||||
name = "chamberTeflonWall"
|
||||
}
|
||||
physVolume(cathodeTeflonDiskVolume) {
|
||||
name = "cathodeTeflonDisk"
|
||||
position {
|
||||
z = chamberHeight / 2 + cathodeTeflonDiskThickness / 2
|
||||
}
|
||||
}
|
||||
physVolume(cathodeCopperDiskVolume) {
|
||||
name = "cathodeCopperDisk"
|
||||
position {
|
||||
z = chamberHeight / 2 + cathodeCopperSupportThickness / 2
|
||||
}
|
||||
}
|
||||
physVolume(cathodeWindowVolume) {
|
||||
name = "cathodeWindow"
|
||||
position {
|
||||
z = chamberHeight / 2 - mylarCathodeThickness / 2
|
||||
}
|
||||
}
|
||||
physVolume(cathodeFillingVolume) {
|
||||
name = "cathodeFilling"
|
||||
position {
|
||||
z = chamberHeight / 2 + cathodeTeflonDiskThickness / 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.toVision {
|
||||
configure { _, solid, _ ->
|
||||
//disable visibility for the world box
|
||||
if(solid.name == "world"){
|
||||
visible = false
|
||||
}
|
||||
if(solid.name.startsWith("gas")){
|
||||
color("green")
|
||||
} else {
|
||||
//make all solids semi-transparent
|
||||
transparent()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt
Normal file
12
demo/playground/src/jvmMain/kotlin/gdmlIaxo.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import space.kscience.gdml.GdmlShowCase
|
||||
import space.kscience.visionforge.gdml.toVision
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
|
||||
fun main() = makeVisionFile {
|
||||
vision("canvas") {
|
||||
requirePlugin(Solids)
|
||||
GdmlShowCase.babyIaxo().toVision()
|
||||
}
|
||||
}
|
23
demo/playground/src/jvmMain/kotlin/generateSchema.kt
Normal file
23
demo/playground/src/jvmMain/kotlin/generateSchema.kt
Normal file
@ -0,0 +1,23 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import com.github.ricky12awesome.jss.encodeToSchema
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.Json
|
||||
import space.kscience.visionforge.solid.SolidGroup
|
||||
import space.kscience.visionforge.solid.Solids
|
||||
|
||||
private val json = Json {
|
||||
serializersModule = Solids.serializersModuleForSolids
|
||||
prettyPrintIndent = " "
|
||||
prettyPrint = true
|
||||
ignoreUnknownKeys = true
|
||||
isLenient = true
|
||||
coerceInputValues = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
fun main() {
|
||||
val schema = json.encodeToSchema(SolidGroup.serializer(), generateDefinitions = false)
|
||||
println(schema)
|
||||
}
|
16
demo/playground/src/jvmMain/kotlin/plotlyVision.kt
Normal file
16
demo/playground/src/jvmMain/kotlin/plotlyVision.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import space.kscience.plotly.scatter
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.plotly.plotly
|
||||
|
||||
fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
|
||||
vision {
|
||||
plotly {
|
||||
scatter {
|
||||
x(1, 2, 3)
|
||||
y(5, 8, 7)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
demo/playground/src/jvmMain/kotlin/randomSpheres.kt
Normal file
34
demo/playground/src/jvmMain/kotlin/randomSpheres.kt
Normal file
@ -0,0 +1,34 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import kotlinx.html.div
|
||||
import kotlinx.html.h1
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.solid.*
|
||||
import java.nio.file.Paths
|
||||
import kotlin.random.Random
|
||||
|
||||
private val random = Random(112233)
|
||||
|
||||
fun main() = makeVisionFile(
|
||||
Paths.get("randomSpheres.html"),
|
||||
resourceLocation = ResourceLocation.SYSTEM
|
||||
) {
|
||||
h1 { +"Happy new year!" }
|
||||
div {
|
||||
vision {
|
||||
solid {
|
||||
repeat(100) {
|
||||
sphere(5, name = "sphere[$it]") {
|
||||
x = random.nextDouble(-300.0, 300.0)
|
||||
y = random.nextDouble(-300.0, 300.0)
|
||||
z = random.nextDouble(-300.0, 300.0)
|
||||
material {
|
||||
color(random.nextInt())
|
||||
}
|
||||
detail = 16
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
106
demo/playground/src/jvmMain/kotlin/rootParser.kt
Normal file
106
demo/playground/src/jvmMain/kotlin/rootParser.kt
Normal file
@ -0,0 +1,106 @@
|
||||
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
|
||||
import java.nio.file.Paths
|
||||
import java.util.zip.ZipInputStream
|
||||
import kotlin.io.path.writeText
|
||||
|
||||
|
||||
private fun Meta.countTypes(): Sequence<String> = sequence {
|
||||
if (!isLeaf) {
|
||||
get("_typename")?.value?.let { yield(it.string) }
|
||||
items.forEach { yieldAll(it.value.countTypes()) }
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val string = ZipInputStream(TGeoManager::class.java.getResourceAsStream("/root/BM@N_geometry.zip")!!).use {
|
||||
it.nextEntry
|
||||
it.readAllBytes().decodeToString()
|
||||
}
|
||||
|
||||
val geo = DGeoManager.parse(string)
|
||||
|
||||
|
||||
val sizes = geo.meta.countTypes().groupBy { it }.mapValues { it.value.size }
|
||||
sizes.forEach {
|
||||
println(it)
|
||||
}
|
||||
|
||||
val solid = geo.toSolid()
|
||||
|
||||
Paths.get("BM@N.vf.json").writeText(Solids.encodeToString(solid))
|
||||
//println(Solids.encodeToString(solid))
|
||||
|
||||
makeVisionFile {
|
||||
vision("canvas") {
|
||||
requirePlugin(Solids)
|
||||
solid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* 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)
|
||||
}
|
||||
}*//*
|
||||
}*/
|
35
demo/playground/src/jvmMain/kotlin/serverExtensions.kt
Normal file
35
demo/playground/src/jvmMain/kotlin/serverExtensions.kt
Normal file
@ -0,0 +1,35 @@
|
||||
package space.kscience.visionforge.examples
|
||||
|
||||
import space.kscience.dataforge.context.Global
|
||||
import space.kscience.visionforge.html.HtmlVisionFragment
|
||||
import space.kscience.visionforge.html.Page
|
||||
import space.kscience.visionforge.html.ResourceLocation
|
||||
import space.kscience.visionforge.html.importScriptHeader
|
||||
import space.kscience.visionforge.makeFile
|
||||
import java.awt.Desktop
|
||||
import java.nio.file.Path
|
||||
|
||||
public fun makeVisionFile(
|
||||
path: Path? = null,
|
||||
title: String = "VisionForge page",
|
||||
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
||||
show: Boolean = true,
|
||||
content: HtmlVisionFragment,
|
||||
): Unit {
|
||||
val actualPath = Page(Global, content = content).makeFile(path) { actualPath ->
|
||||
mapOf(
|
||||
"title" to Page.title(title),
|
||||
"playground" to Page.importScriptHeader("js/visionforge-playground.js", resourceLocation, actualPath),
|
||||
)
|
||||
}
|
||||
if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI())
|
||||
}
|
||||
|
||||
//@DFExperimental
|
||||
//public fun Context.makeVisionFile(
|
||||
// vision: Vision,
|
||||
// path: Path? = null,
|
||||
// title: String = "VisionForge page",
|
||||
// resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
||||
// show: Boolean = true,
|
||||
//): Unit = makeVisionFile({ vision(vision) }, path, title, resourceLocation, show)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user