Skip to content

Commit 485b9b5

Browse files
committed
Fix - add missing factor in TGepPgon shape
All pgon shapes will be slightly expanded
1 parent 2ee8d73 commit 485b9b5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

scripts/JSRootGeoBase.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,12 +1107,14 @@
11071107
JSROOT.GEO.createPolygonBuffer = function( shape, faces_limit ) {
11081108
var thetaStart = shape.fPhi1,
11091109
thetaLength = shape.fDphi,
1110-
radiusSegments = 60;
1110+
radiusSegments = 60, factor = 1;
11111111

1112-
if ( shape._typename == "TGeoPgon" )
1112+
if (shape._typename == "TGeoPgon") {
11131113
radiusSegments = shape.fNedges;
1114-
else
1114+
factor = 1. / Math.cos(Math.PI/180 * thetaLength / radiusSegments / 2);
1115+
} else {
11151116
radiusSegments = Math.max(5, Math.round(thetaLength/JSROOT.GEO.GradPerSegm));
1117+
}
11161118

11171119
var usage = new Int16Array(2*shape.fNz), numusedlayers = 0, hasrmin = false;
11181120

@@ -1153,10 +1155,9 @@
11531155

11541156
if (pnts !== null) {
11551157
if (side === 0) {
1156-
pnts.push(new THREE.Vector2(rad, layerz));
1157-
} else
1158-
if (rad < shape.fRmax[layer]) {
1159-
pnts.unshift(new THREE.Vector2(rad, layerz));
1158+
pnts.push(new THREE.Vector2(factor*rad, layerz));
1159+
} else if (rad < shape.fRmax[layer]) {
1160+
pnts.unshift(new THREE.Vector2(factor*rad, layerz));
11601161
}
11611162
}
11621163
}
@@ -1202,14 +1203,14 @@
12021203
// add sides
12031204
for (var side = 0; side < 2; ++side) {
12041205
var rside = (side === 0) ? 'fRmax' : 'fRmin',
1205-
z1 = shape.fZ[0], r1 = shape[rside][0],
1206+
z1 = shape.fZ[0], r1 = factor*shape[rside][0],
12061207
d1 = 1 - side, d2 = side;
12071208

12081209
for (var layer=0; layer < shape.fNz; ++layer) {
12091210

12101211
if (usage[layer*2+side] === 0) continue;
12111212

1212-
var z2 = shape.fZ[layer], r2 = shape[rside][layer],
1213+
var z2 = shape.fZ[layer], r2 = factor*shape[rside][layer],
12131214
nxy = 1, nz = 0;
12141215

12151216
if ((r2 !== r1)) {
@@ -1235,7 +1236,7 @@
12351236
// add top/bottom
12361237
for (var layer=0; layer < shape.fNz; layer += (shape.fNz-1)) {
12371238

1238-
var rmin = shape.fRmin[layer], rmax = shape.fRmax[layer];
1239+
var rmin = factor*shape.fRmin[layer], rmax = factor*shape.fRmax[layer];
12391240

12401241
if (rmin === rmax) continue;
12411242

0 commit comments

Comments
 (0)