Skip to content

Commit c30ca9a

Browse files
committed
Make common switch for all shapes kinds
1 parent 7280681 commit c30ca9a

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

scripts/JSRootGeoPainter.js

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -603,34 +603,25 @@
603603

604604
JSROOT.GEO.createGeometry = function( shape ) {
605605

606-
if (shape._typename == "TGeoBBox")
607-
return JSROOT.GEO.createCube( shape ); // Cube
608-
609-
if (shape._typename == "TGeoPara")
610-
return JSROOT.GEO.createPara( shape ); // Parallelepiped
611-
612-
if ((shape._typename == "TGeoArb8") || (shape._typename == "TGeoTrd1") ||
613-
(shape._typename == "TGeoTrd2") || (shape._typename == "TGeoTrap") || (shape._typename == "TGeoGtra"))
614-
return JSROOT.GEO.createTrapezoid( shape );
615-
616-
if ((shape._typename == "TGeoSphere"))
617-
return JSROOT.GEO.createSphere( shape );
618-
619-
if ((shape._typename == "TGeoCone") || (shape._typename == "TGeoConeSeg") ||
620-
(shape._typename == "TGeoTube") || (shape._typename == "TGeoTubeSeg"))
621-
return JSROOT.GEO.createTube( shape );
622-
623-
if (shape._typename == "TGeoEltu")
624-
return JSROOT.GEO.createEltu( shape );
625-
626-
if (shape._typename == "TGeoTorus")
627-
return JSROOT.GEO.createTorus( shape );
628-
629-
if ( shape._typename == "TGeoPcon" || shape._typename == "TGeoPgon" )
630-
return JSROOT.GEO.createPolygon( shape );
631-
632-
if ( shape._typename == "TGeoXtru")
633-
return JSROOT.GEO.createXtru(shape);
606+
switch (shape._typename) {
607+
case "TGeoBBox": return JSROOT.GEO.createCube( shape );
608+
case "TGeoPara": return JSROOT.GEO.createPara( shape );
609+
case "TGeoArb8":
610+
case "TGeoTrd1":
611+
case "TGeoTrd2":
612+
case "TGeoTrap":
613+
case "TGeoGtra": return JSROOT.GEO.createTrapezoid( shape );
614+
case "TGeoSphere": return JSROOT.GEO.createSphere( shape );
615+
case "TGeoCone":
616+
case "TGeoConeSeg":
617+
case "TGeoTube":
618+
case "TGeoTubeSeg": return JSROOT.GEO.createTube( shape );
619+
case "TGeoEltu": return JSROOT.GEO.createEltu( shape );
620+
case "TGeoTorus": return JSROOT.GEO.createTorus( shape );
621+
case "TGeoPcon":
622+
case "TGeoPgon": return JSROOT.GEO.createPolygon( shape );
623+
case "TGeoXtru": return JSROOT.GEO.createXtru(shape);
624+
}
634625

635626
return null;
636627
}

0 commit comments

Comments
 (0)