Skip to content
4 changes: 2 additions & 2 deletions graf2d/graf/src/TGaxis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ void TGaxis::PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t yma

if (fFunction) axis_length0 = binLow-wmin;
if ((!optionNoopt || optionInt) && axis_length0) {
nticks0 = Int_t(axis_length0/dxtick);
nticks0 = Int_t(axis_length0/dxtick + epsilon);
if (nticks0 > 1000) nticks0 = 1000;
xtick0 -= dxtick; // skip first major tick which already was drawn
for (k=1; k<=nticks0; k++) {
Expand Down Expand Up @@ -1775,7 +1775,7 @@ void TGaxis::PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t yma

if (fFunction) axis_length1 = wmax-binHigh;
if ((!optionNoopt || optionInt) && axis_length1) {
nticks1 = int(axis_length1/dxtick);
nticks1 = int(axis_length1/dxtick + epsilon);
if (nticks1 > 1000) nticks1 = 1000;
xtick1 += dxtick; // skip last major tick which was already drawn
for (k=1; k<=nticks1; k++) {
Expand Down
14 changes: 14 additions & 0 deletions graf2d/postscript/src/TSVG.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
Int_t TSVG::fgLineJoin = 0;
Int_t TSVG::fgLineCap = 0;

const Double_t kEpsilon = 1e-9;

/** \class TSVG
\ingroup PS

Expand Down Expand Up @@ -468,6 +470,10 @@ void TSVG::DrawPolyLine(Int_t nn, TPoints *xy)
iydi = YtoSVG(xy[i].GetY());
ix = ixdi - ixd0;
iy = iydi - iyd0;
if (fCompact && (TMath::Abs(ix) < kEpsilon))
ix = 0;
if (fCompact && (TMath::Abs(iy) < kEpsilon))
iy = 0;
ixd0 = ixdi;
iyd0 = iydi;
if( ix && iy) {
Expand Down Expand Up @@ -538,6 +544,10 @@ void TSVG::DrawPolyLineNDC(Int_t nn, TPoints *xy)
iydi = VtoSVG(xy[i].GetY());
ix = ixdi - ixd0;
iy = iydi - iyd0;
if (fCompact && (TMath::Abs(ix) < kEpsilon))
ix = 0;
if (fCompact && (TMath::Abs(iy) < kEpsilon))
iy = 0;
ixd0 = ixdi;
iyd0 = iydi;
if( ix && iy) {
Expand Down Expand Up @@ -1442,6 +1452,10 @@ void TSVG::DrawPS(Int_t nn, Double_t *xw, Double_t *yw)
iydi = YtoSVG(yw[i]);
ix = ixdi - ixd0;
iy = iydi - iyd0;
if (fCompact && (TMath::Abs(ix) < kEpsilon))
ix = 0;
if (fCompact && (TMath::Abs(iy) < kEpsilon))
iy = 0;
ixd0 = ixdi;
iyd0 = iydi;
if( ix && iy) {
Expand Down
25 changes: 13 additions & 12 deletions hist/histpainter/src/TGraphPainter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4696,13 +4696,13 @@ void TGraphPainter::PaintPolyLineHatches(TGraph *theGraph, Int_t n, const Double
} else {
a1 = TMath::ATan((yi1-yi0)/(xi1-xi0));
}
if (xi1<xi0) a1 = a1+3.14159;
if (xi1<xi0) a1 = a1+TMath::Pi();
if (xi2==xi0) {
a2 = TMath::PiOver2();
} else {
a2 = TMath::ATan((yi0-yi2)/(xi0-xi2));
}
if (xi0<xi2) a2 = a2+3.14159;
if (xi0<xi2) a2 = a2+TMath::Pi();
x1 = xi0-w*TMath::Sin(a1);
y1 = yi0+w*TMath::Cos(a1);
x2 = xi0-w*TMath::Sin(a2);
Expand All @@ -4714,8 +4714,8 @@ void TGraphPainter::PaintPolyLineHatches(TGraph *theGraph, Int_t n, const Double
} else {
a3 = TMath::ATan((ym-yi0)/(xm-xi0));
}
x3 = xi0-w*TMath::Sin(a3+1.57079);
y3 = yi0+w*TMath::Cos(a3+1.57079);
x3 = xi0-w*TMath::Sin(a3+TMath::PiOver2());
y3 = yi0+w*TMath::Cos(a3+TMath::PiOver2());
// Rotate (x3,y3) by PI around (xi0,yi0) if it is not on the (xm,ym) side.
if ((xm-xi0)*(x3-xi0)<0 && (ym-yi0)*(y3-yi0)<0) {
x3 = 2*xi0-x3;
Expand All @@ -4738,8 +4738,8 @@ void TGraphPainter::PaintPolyLineHatches(TGraph *theGraph, Int_t n, const Double
} else {
a3 = TMath::ATan((ym-yf[0])/(xm-xf[0]));
}
x3 = xf[0]+w*TMath::Sin(a3+1.57079);
y3 = yf[0]-w*TMath::Cos(a3+1.57079);
x3 = xf[0]+w*TMath::Sin(a3+TMath::PiOver2());
y3 = yf[0]-w*TMath::Cos(a3+TMath::PiOver2());
if ((xm-xf[0])*(x3-xf[0])<0 && (ym-yf[0])*(y3-yf[0])<0) {
x3 = 2*xf[0]-x3;
y3 = 2*yf[0]-y3;
Expand All @@ -4754,20 +4754,21 @@ void TGraphPainter::PaintPolyLineHatches(TGraph *theGraph, Int_t n, const Double
Double_t xc, yc, c1, b1, c2, b2;
Bool_t cross = kFALSE;
Int_t nf2 = nf;
const Double_t eps = 1e-12; // float precision
for (i=nf2; i>0; i--) {
for (j=i-1; j>0; j--) {
if (xt[i-1]==xt[i] || xt[j-1]==xt[j]) continue;
if (TMath::Abs(xt[i-1]-xt[i]) < eps || TMath::Abs(xt[j-1]-xt[j]) < eps) continue;
c1 = (yt[i-1]-yt[i])/(xt[i-1]-xt[i]);
b1 = yt[i]-c1*xt[i];
c2 = (yt[j-1]-yt[j])/(xt[j-1]-xt[j]);
b2 = yt[j]-c2*xt[j];
if (c1 != c2) {
if (TMath::Abs(c1 - c2) > eps) {
xc = (b2-b1)/(c1-c2);
yc = c1*xc+b1;
if (xc>TMath::Min(xt[i],xt[i-1]) && xc<TMath::Max(xt[i],xt[i-1]) &&
xc>TMath::Min(xt[j],xt[j-1]) && xc<TMath::Max(xt[j],xt[j-1]) &&
yc>TMath::Min(yt[i],yt[i-1]) && yc<TMath::Max(yt[i],yt[i-1]) &&
yc>TMath::Min(yt[j],yt[j-1]) && yc<TMath::Max(yt[j],yt[j-1])) {
if (xc>TMath::Min(xt[i],xt[i-1])+eps && xc<TMath::Max(xt[i],xt[i-1])-eps &&
xc>TMath::Min(xt[j],xt[j-1])+eps && xc<TMath::Max(xt[j],xt[j-1])-eps &&
yc>TMath::Min(yt[i],yt[i-1])+eps && yc<TMath::Max(yt[i],yt[i-1])-eps &&
yc>TMath::Min(yt[j],yt[j-1])+eps && yc<TMath::Max(yt[j],yt[j-1])-eps) {
nf++; xf[nf] = xt[i]; yf[nf] = yt[i];
nf++; xf[nf] = xc ; yf[nf] = yc;
i = j;
Expand Down
19 changes: 14 additions & 5 deletions hist/histpainter/src/TPainter3dAlgorithms.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class by Rene Brun.
const Double_t kRad = TMath::ATan(1)*Double_t(4)/Double_t(180);
const Double_t kFdel = 0.;
const Double_t kDel = 0.0001;
const Double_t kEps = 1e-9; // exclude such small segments
const Double_t kEpsFaceMode2 = 1e-12; // minimal Z change in DrawFaceMode2
const Int_t kNiso = 4;
const Int_t kNmaxp = kNiso*13;
const Int_t kNmaxt = kNiso*12;
Expand Down Expand Up @@ -477,7 +479,10 @@ void TPainter3dAlgorithms::DrawFaceMode2(Int_t *, Double_t *xyz, Int_t np, Int_t
Int_t k1 = 0, k2 = 2;
Double_t z1 = (x[k1+1] - x[k1+0])*(y[k1+2] - y[k1+1]) - (y[k1+1] - y[k1+0])*(x[k1+2] - x[k1+1]);
Double_t z2 = (x[k2+1] - x[k2+0])*(y[k2+2] - y[k2+1]) - (y[k2+1] - y[k2+0])*(x[k2+2] - x[k2+1]);
if (z1 > z2) { k1 = 2; k2 = 0; }
// S.Linev Exclude flipping around same z
// only by 'significant' difference change rendering order
if (z1 > z2 + kEpsFaceMode2) { k1 = 2; k2 = 0; }

FillPolygon(3, &p3[3*k1], &ttt[k1]);
if (fMesh == 1) { // Draw border
gPad->PaintPolyLine(3, &x[k1], &y[k1]);
Expand Down Expand Up @@ -593,7 +598,8 @@ void TPainter3dAlgorithms::DrawFaceMove1(Int_t *icodes, Double_t *xyz, Int_t np,
y[0] = p1[1] + ydel*fT[2*it + 0];
x[1] = p1[0] + xdel*fT[2*it + 1];
y[1] = p1[1] + ydel*fT[2*it + 1];
gPad->PaintPolyLine(2, x, y);
if (TMath::Abs(fT[2*it + 0] - fT[2*it + 1]) > kEps)
gPad->PaintPolyLine(2, x, y);
}
}

Expand Down Expand Up @@ -621,7 +627,8 @@ void TPainter3dAlgorithms::DrawFaceMove1(Int_t *icodes, Double_t *xyz, Int_t np,
y[0] = p1[1] + ydel*fT[2*it + 0];
x[1] = p1[0] + xdel*fT[2*it + 1];
y[1] = p1[1] + ydel*fT[2*it + 1];
gPad->PaintPolyLine(2, x, y);
if (TMath::Abs(fT[2*it + 0] - fT[2*it + 1]) > kEps)
gPad->PaintPolyLine(2, x, y);
}
}

Expand Down Expand Up @@ -681,7 +688,8 @@ void TPainter3dAlgorithms::DrawFaceMove2(Int_t *icodes, Double_t *xyz, Int_t np,
y[0] = p1[1] + ydel*fT[2*it + 0];
x[1] = p1[0] + xdel*fT[2*it + 1];
y[1] = p1[1] + ydel*fT[2*it + 1];
gPad->PaintPolyLine(2, x, y);
if (TMath::Abs(fT[2*it + 0] - fT[2*it + 1]) > kEps)
gPad->PaintPolyLine(2, x, y);
}
}

Expand Down Expand Up @@ -763,7 +771,8 @@ void TPainter3dAlgorithms::DrawFaceMove3(Int_t *icodes, Double_t *xyz, Int_t np,
y[0] = p1[1] + ydel*fT[2*it + 0];
x[1] = p1[0] + xdel*fT[2*it + 1];
y[1] = p1[1] + ydel*fT[2*it + 1];
gPad->PaintPolyLine(2, x, y);
if (TMath::Abs(fT[2*it + 0] - fT[2*it + 1]) > kEps)
gPad->PaintPolyLine(2, x, y);
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions roottest/graphics/stress_svg/svg01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading