@@ -4211,13 +4211,16 @@ void TPad::PaintFillAreaHatches(Int_t nn, Double_t *xx, Double_t *yy, Int_t Fill
42114211void TPad::PaintHatches (Double_t dy, Double_t angle,
42124212 Int_t nn, Double_t *xx, Double_t *yy)
42134213{
4214- Int_t i, i1, i2, nbi, m, inv ;
4214+ Int_t i, i1, i2, nbi;
42154215 Double_t ratiox, ratioy, ymin, ymax, yrot, ycur;
42164216 const Double_t angr = TMath::Pi ()*(180 .-angle)/180 .;
42174217 const Double_t epsil = 0.0001 ;
4218- const Int_t maxnbi = 100 ;
4219- Double_t xli[maxnbi], yli[maxnbi], xt1, xt2, yt1, yt2;
4220- Double_t ll, x, y, x1, x2, y1, y2, a, b, xi, xip, xin, yi, yip;
4218+
4219+ std::vector<Double_t> xli;
4220+ std::vector<Double_t> yli;
4221+
4222+ Double_t xt1, xt2, yt1, yt2;
4223+ Double_t x, y, x1, x2, y1, y2, a, b, xi, xip, xin, yi, yip;
42214224
42224225 Double_t rwxmin = gPad ->GetX1 ();
42234226 Double_t rwxmax = gPad ->GetX2 ();
@@ -4259,14 +4262,20 @@ void TPad::PaintHatches(Double_t dy, Double_t angle,
42594262 while (dy * yindx >= ymin) {
42604263 ycur = dy * yindx--;
42614264 nbi = 0 ;
4265+
4266+ xli.clear ();
4267+ yli.clear ();
4268+
42624269 for (i=2 ; i<=nn+1 ; i++) {
42634270 i2 = i;
42644271 i1 = i-1 ;
42654272 if (i == nn+1 ) i2=1 ;
4273+
42664274 x1 = wndc*ratiox*(xx[i1-1 ]-rwxmin);
42674275 y1 = hndc*ratioy*(yy[i1-1 ]-rwymin);
42684276 x2 = wndc*ratiox*(xx[i2-1 ]-rwxmin);
42694277 y2 = hndc*ratioy*(yy[i2-1 ]-rwymin);
4278+
42704279 xt1 = cosa*x1-sina*y1;
42714280 yt1 = sina*x1+cosa*y1;
42724281 xt2 = cosa*x2-sina*y2;
@@ -4283,8 +4292,7 @@ void TPad::PaintHatches(Double_t dy, Double_t angle,
42834292 }
42844293 if ((yi <= ycur) && (ycur < yip)) {
42854294 nbi++;
4286- if (nbi >= maxnbi) return ;
4287- xli[nbi-1 ] = xt1;
4295+ xli.push_back (xt1);
42884296 }
42894297 continue ;
42904298 }
@@ -4293,66 +4301,53 @@ void TPad::PaintHatches(Double_t dy, Double_t angle,
42934301 if (yt1 == yt2) {
42944302 if (yt1 == ycur) {
42954303 nbi++;
4296- if (nbi >= maxnbi) return ;
4297- xli[nbi-1 ] = xt1;
4304+ xli.push_back (xt1);
42984305 nbi++;
4299- if (nbi >= maxnbi) return ;
4300- xli[nbi-1 ] = xt2;
4306+ xli.push_back (xt2);
43014307 }
43024308 continue ;
43034309 }
43044310
43054311 // Other line segment
43064312 a = (yt1-yt2)/(xt1-xt2);
43074313 b = (yt2*xt1-xt2*yt1)/(xt1-xt2);
4314+
43084315 if (xt1 < xt2) {
43094316 xi = xt1;
43104317 xip = xt2;
43114318 } else {
43124319 xi = xt2;
43134320 xip = xt1;
43144321 }
4322+
43154323 xin = (ycur-b)/a;
4316- if ((xi <= xin) && (xin < xip) &&
4317- (TMath::Min (yt1,yt2) <= ycur) &&
4318- (ycur < TMath::Max (yt1,yt2))) {
4324+
4325+ if ((xi <= xin) && (xin < xip) &&
4326+ (TMath::Min (yt1,yt2) <= ycur) &&
4327+ (ycur < TMath::Max (yt1,yt2))) {
43194328 nbi++;
4320- if (nbi >= maxnbi) return ;
4321- xli[nbi-1 ] = xin;
4329+ xli.push_back (xin);
43224330 }
43234331 }
43244332
43254333 // Sorting of the x coordinates intersections
4326- inv = 0 ;
4327- m = nbi-1 ;
4328- L30:
4329- for (i=1 ; i<=m; i++) {
4330- if (xli[i] < xli[i-1 ]) {
4331- inv++;
4332- ll = xli[i-1 ];
4333- xli[i-1 ] = xli[i];
4334- xli[i] = ll;
4335- }
4336- }
4337- m--;
4338- if (inv == 0 ) goto L50;
4339- inv = 0 ;
4340- goto L30;
4334+ std::sort (xli.begin (), xli.end ());
43414335
43424336 // Draw the hatches
4343- L50:
43444337 if ((nbi%2 != 0 ) || (nbi == 0 ))
43454338 continue ;
43464339
43474340 for (i=0 ; i<nbi; ++i) {
43484341 // Rotate back the hatches - first calculate y coordinate
4349- yli[i] = sinb*xli[i] + cosb*ycur;
4342+ Double_t ytmp = sinb*xli[i] + cosb*ycur;
43504343 xli[i] = cosb*xli[i] - sinb*ycur;
43514344 // Convert hatches' positions from true NDC to WC to handle cliping
43524345 xli[i] = (xli[i]/wndc)*(rwxmax-rwxmin)+rwxmin;
4353- yli[i] = (yli[i]/hndc)*(rwymax-rwymin)+rwymin;
4346+ ytmp = (ytmp/hndc)*(rwymax-rwymin)+rwymin;
4347+ yli.push_back (ytmp);
43544348 }
4355- gPad ->PaintSegments (nbi/2 , xli, yli);
4349+
4350+ gPad ->PaintSegments (nbi/2 , xli.data (), yli.data ());
43564351 }
43574352}
43584353
0 commit comments