Skip to content

Commit

Permalink
[ng] More optimized central detector geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
DraTeots committed May 15, 2024
1 parent b6c877c commit 7665edf
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 4 deletions.
16 changes: 16 additions & 0 deletions firebird-ng/src/app/app-config.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { AppConfigService } from './app-config.service';

describe('AppConfigService', () => {
let service: AppConfigService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AppConfigService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
9 changes: 9 additions & 0 deletions firebird-ng/src/app/app-config.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class AppConfigService {

constructor() { }
}
9 changes: 7 additions & 2 deletions firebird-ng/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Routes } from '@angular/router';
import {MainDisplayComponent} from "./main-display/main-display.component";
import {FileBrowserComponent} from "./file-browser/file-browser.component";
import {InputConfigComponent} from "./input-config/input-config.component";

export const routes: Routes = [
{ path: '', redirectTo: '/config', pathMatch: 'full' },
{ path: 'config', component: InputConfigComponent },
{
path: 'display',
loadComponent: () => import('./main-display/main-display.component').then(m => m.MainDisplayComponent)
},
{ path: '', component: FileBrowserComponent }

{
path: 'files',
loadComponent: () => import('./file-browser/file-browser.component').then(m => m.FileBrowserComponent)
},
];
2 changes: 1 addition & 1 deletion firebird-ng/src/app/geometry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class GeometryService {

//
console.time('Build geometry');
let rootObject3d = build(rootGeoManager, { numfaces: 500000000, numnodes: 50000000, dflt_colors: false, vislevel: 100, doubleside:true, transparency:false});
let rootObject3d = build(rootGeoManager, { numfaces: 500000000, numnodes: 50000000, instancing:1, dflt_colors: false, vislevel: 100, doubleside:false, transparency:true});
console.timeEnd('Build geometry');
// >oO console.log(geo);

Expand Down
74 changes: 74 additions & 0 deletions firebird-ng/src/app/input-config/input-config.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!-- event-display-source.component.html -->
<div class="container mt-3">
<h3>Event display source control</h3>

<form [formGroup]="geoForm">
<div class="mt-4">
<h5>Geometry source</h5>
<select class="form-control" formControlName="selectedGeometry">
<option value="epic-central-optimized">EIC ePIC Central Detector optimized</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_bhcal.root">epic_bhcal.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_calorimeters.root">epic_calorimeters.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake.root">epic_craterlake.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_10x100.root">epic_craterlake_10x100.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_10x275.root">epic_craterlake_10x275.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_18x110_Au.root">epic_craterlake_18x110_Au.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_18x275.root">epic_craterlake_18x275.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_5x41.root">epic_craterlake_5x41.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_material_map.root">epic_craterlake_material_map.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_no_bhcal.root">epic_craterlake_no_bhcal.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_craterlake_tracking_only.root">epic_craterlake_tracking_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_dirc_only.root">epic_dirc_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_drich_only.root">epic_drich_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_forward_detectors.root">epic_forward_detectors.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_forward_detectors_with_inserts.root">epic_forward_detectors_with_inserts.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_full.root">epic_full.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_imaging_only.root">epic_imaging_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_inner_detector.root">epic_inner_detector.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_ip6.root">epic_ip6.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_ip6_extended.root">epic_ip6_extended.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_lfhcal_only.root">epic_lfhcal_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_lfhcal_with_insert.root">epic_lfhcal_with_insert.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_mrich_only.root">epic_mrich_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_pfrich_only.root">epic_pfrich_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_pid_only.root">epic_pid_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_tof_endcap_only.root">epic_tof_endcap_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_tof_only.root">epic_tof_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_vertex_only.root">epic_vertex_only.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_zdc_lyso_sipm.root">epic_zdc_lyso_sipm.root</option>
<option value="https://eic.github.io/epic/artifacts/tgeo/epic_zdc_sipm_on_tile_only.root">epic_zdc_sipm_on_tile_only.root</option>
</select>
</div>

<div class="mt-4">
<h5>Geometry optimization</h5>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="geoOptEnabled" formControlName="geoOptEnabled">
<label class="form-check-label" for="geoOptEnabled">Enabled</label>
</div>
<select class="form-control mt-2" formControlName="selectedGeoCutoff" [disabled]="!geoForm.get('geoOptEnabled')?.value ?? true">
<option value="Central detector">Central detector</option>
<option value="Far forward">Far forward</option>
<--

!-->
</select>
</div>

<div class="mt-4">
<h5>Geometry postprocessing</h5>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="geoPostEnabled" formControlName="geoPostEnabled">
<label class="form-check-label" for="geoPostEnabled">Enabled</label>
</div>
</div>

<div class="mt-4 text-center">
<button type="button" class="btn btn-lg btn-primary" [routerLink]="['/display']">DISPLAY</button>
</div>
<div class="mt-4 text-center">
<button type="button" class="btn btn-lg btn-primary" [routerLink]="['/display']">DISPLAY</button>
</div>

</form>
</div>
Empty file.
26 changes: 26 additions & 0 deletions firebird-ng/src/app/input-config/input-config.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule } from '@angular/forms';
import { InputConfigComponent } from './input-config.component';



describe('InputConfigComponent', () => {
let component: InputConfigComponent;
let fixture: ComponentFixture<InputConfigComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [InputConfigComponent]
})
.compileComponents();

fixture = TestBed.createComponent(InputConfigComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
40 changes: 40 additions & 0 deletions firebird-ng/src/app/input-config/input-config.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// event-display-source.component.ts
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { GeometryService } from '../geometry.service';
import { ReactiveFormsModule } from '@angular/forms';
import {RouterLink} from '@angular/router';

@Component({
selector: 'app-input-config',
standalone: true,
imports: [ReactiveFormsModule, RouterLink],
templateUrl: './input-config.component.html',
styleUrl: './input-config.component.scss'
})
export class InputConfigComponent implements OnInit {

geoForm: FormGroup;

constructor(private fb: FormBuilder, private geometryService: GeometryService) {
this.geoForm = this.fb.group({
selectedGeometry: ['eic geometry'],
geoOptEnabled: [false],
selectedGeoCutoff: ['Central detector'],
geoPostEnabled: [false]
});

this.geoForm.valueChanges.subscribe(value => {
//this.geometryService.save(value);
console.log(value);
});
}

ngOnInit(): void {
// const savedSettings = this.geometryService.load();
// if (savedSettings) {
// this.geoForm.setValue(savedSettings);
// }
}

}
57 changes: 56 additions & 1 deletion firebird-ng/src/app/main-display/main-display.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import { Component, OnInit } from '@angular/core';
import { EventDisplayService } from 'phoenix-ui-components';
import { Configuration, PhoenixLoader, PresetView, ClippingSetting, PhoenixMenuNode } from 'phoenix-event-display';
import { Color, DoubleSide, Mesh, LineSegments, LineBasicMaterial, MeshPhongMaterial, Material, ObjectLoader, FrontSide, Vector3, Matrix4, REVISION, } from "three";
import {
Color,
DoubleSide,
Mesh,
LineSegments,
LineBasicMaterial,
MeshPhongMaterial,
Material,
ObjectLoader,
FrontSide,
Vector3,
Matrix4,
REVISION,
MeshPhysicalMaterial,
} from "three";
import { PhoenixUIModule } from 'phoenix-ui-components';
import { GeometryService} from '../geometry.service';
import { Edm4hepRootEventLoader } from '../edm4hep-root-event-loader';
import { ActivatedRoute } from '@angular/router';
import {color} from "three/examples/jsm/nodes/shadernode/ShaderNode";
import {getGeoNodesByLevel} from "../utils/cern-root.utils";
import {produceRenderOrder} from "jsrootdi/geom";
import {wildCardCheck} from "../utils/wildcard";

interface Colorable {
color: Color;
Expand Down Expand Up @@ -72,6 +88,7 @@ export class MainDisplayComponent implements OnInit {
rootObject3d.scale.setScalar(scale);
}
sceneGeometry.add(rootObject3d);
console.log("CERN ROOT converted to Object3d: ", rootObject3d);
//rootGeometry.visible = initiallyVisible;

//sceneGeometry.add(rootGeometry);
Expand All @@ -93,6 +110,20 @@ export class MainDisplayComponent implements OnInit {
}
}

let renderer = openThreeManager.rendererManager;

const glassMaterial = new MeshPhysicalMaterial({
color: 0xffff00, // Yellow color
metalness: 0,
roughness: 0,
transmission: 0.7, // High transparency
opacity: 1,
transparent: true,
reflectivity: 0.5
});



// Now we want to change the materials
sceneGeometry.traverse( (child: any) => {

Expand Down Expand Up @@ -128,6 +159,26 @@ export class MainDisplayComponent implements OnInit {
clipShadows: false
});

// Material
let name:string = child.name;


if(name.startsWith("bar_") || name.startsWith("prism_")) {
child.material = glassMaterial;
}

if(! child.material?.clippingPlanes !== undefined) {
child.material.clippingPlanes = openThreeManager.clipPlanes;
}

if(! child.material?.clipIntersection !== undefined) {
child.material.clipIntersection = true;
}

if(! child.material?.clipShadows !== undefined) {
child.material.clipShadows = false;
}

// if (!(child instanceof Mesh)) {
// return;
// }
Expand Down Expand Up @@ -156,6 +207,10 @@ export class MainDisplayComponent implements OnInit {
// child.material.clipShadows = false;
});

let scene = threeManager.getSceneManager().getScene();
let camera = openThreeManager.controlsManager.getMainCamera();
produceRenderOrder(scene, camera.position, 'dflt');

}

ngOnInit() {
Expand Down

0 comments on commit 7665edf

Please sign in to comment.