34 PolyTest1(
unsigned nVertices);
37 void Reset(
unsigned nVertices);
41 kNPointsDefault = 10000
44 std::vector<Double_t> fXs;
45 std::vector<Double_t> fYs;
49PolyTest1::PolyTest1(
unsigned nVertices) :
TNamed(
"polygon_compression_test1",
"polygon_compression_test1")
55void PolyTest1::Reset(
unsigned nVertices)
58 assert(
gPad !=
nullptr &&
"Reset, gPad is null");
60 assert(
gRandom !=
nullptr &&
"Reset, gRandom is null");
62 if (nVertices < kNPointsDefault) {
63 Warning(
"Reset",
"resetting nVertices parameter to %u",
unsigned(kNPointsDefault));
64 nVertices = kNPointsDefault;
67 fXs.resize(nVertices);
68 fYs.resize(nVertices);
70 Double_t xMin = 0., xMax = 0., yMin = 0., yMax = 0.;
71 gPad->GetRange(xMin, yMin, xMax, yMax);
72 assert(xMax - xMin > 0 && yMax - yMin > 0 &&
"Reset, invalid canvas' ranges");
74 const Double_t xCentre = xMin + 0.5 * (xMax - xMin);
75 const Double_t yCentre = yMin + 0.5 * (yMax - yMin);
80 for (
unsigned i = 0; i < nVertices - 1; ++i) {
86 fXs[nVertices - 1] = fXs[0];
87 fYs[nVertices - 1] = fYs[0];
91void PolyTest1::Paint(
const Option_t * )
93 assert(
gPad !=
nullptr &&
"Paint, gPad is null");
96 gPad->PaintFillArea((
Int_t)fXs.size(), &fXs[0], &fYs[0]);
99 gPad->PaintPolyLine((
Int_t)fXs.size(), &fXs[0], &fYs[0]);
107 PolyTest1 *polygon =
new PolyTest1(1000000);
108 polygon->SetLineColor(
kBlue);
109 polygon->SetFillColor(
kRed);
110 polygon->SetLineWidth(1);
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint angle
R__EXTERN TRandom * gRandom
Fill Area Attributes class.
virtual void Modify()
Change current fill area attributes if necessary.
virtual void Modify()
Change current line attributes if necessary.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
The TNamed class is the base class for all named ROOT classes.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Double_t Rndm() override
Machine independent random number generator.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
constexpr Double_t TwoPi()