Skip to content

Commit 37f0ed7

Browse files
committed
Provide experimental 'limit' draw option for geometry
One could use it to limit number of drawn values by 10000. It is seems to be realistic number, which can be handled in the browser
1 parent 99f2ef9 commit 37f0ed7

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

scripts/JSRootGeoPainter.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@
706706
JSROOT.TGeoPainter.prototype.drawNode = function(scene, toplevel, node, visible) {
707707
var container = toplevel;
708708
var volume = node['fVolume'];
709+
if (visible==0) return; // cut all volumes below 0 level
709710

710711
var translation_matrix = [0, 0, 0];
711712
var rotation_matrix = null;//[1, 0, 0, 0, 1, 0, 0, 0, 1];
@@ -961,20 +962,35 @@
961962

962963
var dom = this.select_main().node();
963964

964-
if (opt == 'count') {
965+
var maxlvl = opt=="all" ? 9999 : -1;
966+
967+
if ((opt == 'count') || (opt == 'limit')) {
965968
var arr = [];
966969
for (var lvl=0;lvl<100;++lvl) arr.push(0);
967970

968971
var cnt = this.CountVolumes(this._geometry, 0, arr);
969972

970-
var res = 'Total number: ' + cnt + '<br/>';
971-
for (var lvl=0;lvl<arr.length;++lvl) {
972-
if (arr[lvl] !== 0)
973-
res += (' lvl' + lvl + ': ' + arr[lvl] + '<br/>');
973+
if (opt == 'count') {
974+
var res = 'Total number: ' + cnt + '<br/>';
975+
for (var lvl=0;lvl<arr.length;++lvl) {
976+
if (arr[lvl] !== 0)
977+
res += (' lvl' + lvl + ': ' + arr[lvl] + '<br/>');
978+
}
979+
980+
dom.innerHTML = res;
981+
return this.DrawingReady();
982+
}
983+
984+
var sum = 0;
985+
for (var lvl=1;lvl<arr.length;++lvl) {
986+
sum += arr[lvl];
987+
if (sum > 10000) {
988+
maxlvl = lvl - 1;
989+
console.log('set level on ' + maxlvl);
990+
break;
991+
}
974992
}
975993

976-
dom.innerHTML = res;
977-
return this.DrawingReady();
978994
}
979995

980996
// three.js 3D drawing
@@ -1033,7 +1049,7 @@
10331049
visible: false, transparent: true, opacity: 0.0 } ) );
10341050
toplevel.add(cube);
10351051

1036-
this.drawNode(this._scene, cube, { _typename:"TGeoNode", fVolume:this._geometry, fName:"TopLevel" }, opt=="all" ? 9999 : 0);
1052+
this.drawNode(this._scene, cube, { _typename:"TGeoNode", fVolume:this._geometry, fName:"TopLevel" }, maxlvl);
10371053

10381054
top.computeBoundingBox();
10391055
var overall_size = 3 * Math.max( Math.max(Math.abs(top.boundingBox.max.x), Math.abs(top.boundingBox.max.y)),
@@ -1419,7 +1435,7 @@
14191435
return true;
14201436
}
14211437

1422-
JSROOT.addDrawFunc({ name: "TGeoVolumeAssembly", icon: 'img_geoassembly', func: JSROOT.Painter.drawGeometry, expand: "JSROOT.expandGeoVolume", painter_kind : "base", opt : "all;count;" });
1438+
JSROOT.addDrawFunc({ name: "TGeoVolumeAssembly", icon: 'img_geoassembly', func: JSROOT.Painter.drawGeometry, expand: "JSROOT.expandGeoVolume", painter_kind : "base", opt : "all;count;limit;" });
14231439

14241440

14251441
return JSROOT.Painter;

scripts/JSRootPainter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8314,8 +8314,8 @@
83148314
JSROOT.addDrawFunc({ name: "TLine", icon: 'img_graph', prereq: "more2d", func: "JSROOT.Painter.drawLine" });
83158315
JSROOT.addDrawFunc({ name: "TArrow", icon: 'img_graph', prereq: "more2d", func: "JSROOT.Painter.drawArrow" });
83168316
JSROOT.addDrawFunc({ name: "TLegend", icon: "img_pavelabel", prereq: "more2d", func: "JSROOT.Painter.drawLegend" });
8317-
JSROOT.addDrawFunc({ name: "TGeoVolume", icon: 'img_histo3d', prereq: "geom", func: "JSROOT.Painter.drawGeometry", expand: "JSROOT.expandGeoVolume", painter_kind : "base", opt:"all;count;" });
8318-
JSROOT.addDrawFunc({ name: "TEveGeoShapeExtract", icon: 'img_histo3d', prereq: "geom", func: "JSROOT.Painter.drawGeometry", painter_kind : "base", opt: ";count" });
8317+
JSROOT.addDrawFunc({ name: "TGeoVolume", icon: 'img_histo3d', prereq: "geom", func: "JSROOT.Painter.drawGeometry", expand: "JSROOT.expandGeoVolume", painter_kind : "base", opt:"all;count;limit;" });
8318+
JSROOT.addDrawFunc({ name: "TEveGeoShapeExtract", icon: 'img_histo3d', prereq: "geom", func: "JSROOT.Painter.drawGeometry", painter_kind : "base", opt: ";count;limit" });
83198319
JSROOT.addDrawFunc({ name: "TGeoManager", icon: 'img_histo3d', prereq: "geom", expand: "JSROOT.expandGeoManagerHierarchy" });
83208320
// these are not draw functions, but provide extra info about correspondent classes
83218321
JSROOT.addDrawFunc({ name: "kind:Command", icon: "img_execute", execute: true });

0 commit comments

Comments
 (0)