91 Error(
name,
"number of x-y points for %s must be at least three!",
name);
95 Error(
name,
"number of z points for %s must be at least two!",
name);
132 xtru.TXTRU::Copy(*
this);
147 if (
fZ)
delete []
fZ;
169 rhs.TXTRU::Copy(*
this);
179 auto &tgt =
static_cast<TXTRU &
>(obj);
181 delete [] tgt.fXvtx; tgt.fXvtx =
nullptr;
182 delete [] tgt.fYvtx; tgt.fYvtx =
nullptr;
183 delete [] tgt.fZ; tgt.fZ =
nullptr;
184 delete [] tgt.fScale; tgt.fScale =
nullptr;
185 delete [] tgt.fX0; tgt.fX0 =
nullptr;
186 delete [] tgt.fY0; tgt.fY0 =
nullptr;
194 tgt.fXvtx[i] =
fXvtx[i];
195 tgt.fYvtx[i] =
fYvtx[i];
206 tgt.fScale[j] =
fScale[j];
228 Int_t newNalloc = iz + 1;
234 for (i = 0; i < newNalloc; i++) {
281 Int_t newNalloc = ipt + 1;
285 for (i = 0; i < newNalloc; i++) {
324 if ((
n < 0) || (
n >=
fNxy)) {
335 if ((
n < 0) || (
n >=
fNxy)) {
346 if ((
n < 0) || (
n >=
fNz)) {
357 if ((
n < 0) || (
n >=
fNz)) {
368 if ((
n < 0) || (
n >=
fNz)) {
379 if ((
n < 0) || (
n >=
fNz)) {
398 printf(
"TXTRU %s Nxy=%d [of %d] Nz=%d [of %d] Option=%s\n",
401 const char *shape =
nullptr;
402 const char *zorder =
nullptr;
407 case kConvexCCW: shape =
"Convex CCW ";
break;
408 case kConvexCW: shape =
"Convex CW ";
break;
410 case kConcaveCW: shape =
"Concave CW ";
break;
416 case kConvexIncZ: zorder =
"Convex Increasing Z";
break;
417 case kConvexDecZ: zorder =
"Convex Decreasing Z";
break;
418 case kConcaveIncZ: zorder =
"Concave Increasing Z";
break;
419 case kConcaveDecZ: zorder =
"Concave Decreasing Z";
break;
422 printf(
" XY shape '%s', '%s'\n",shape,zorder);
434 const char *
name =
nullptr;
441 for (ixyz=0; ixyz<6; ixyz++) {
443 case 0: p =
fXvtx;
name =
"x"; nlimit = nxy;
break;
444 case 1: p =
fYvtx;
name =
"y"; nlimit = nxy;
break;
445 case 2: p =
fZ;
name =
"z"; nlimit = nz;
break;
446 case 3: p =
fScale;
name =
"scale"; nlimit = nz;
break;
447 case 4: p =
fX0;
name =
"x0"; nlimit = nz;
break;
448 case 5: p =
fY0;
name =
"y0"; nlimit = nz;
break;
450 if (ixyz<=1 && !print_vtx)
continue;
451 if (ixyz>=2 && !print_z)
continue;
453 printf(
" Float_t %s[] = \n { %10g",
name,*p++);
455 for (i=1;i<nlimit;i++) {
456 printf(
", %10g",*p++);
457 if (i%6==5) printf(
"\n ");
471 Int_t ipt, ixy, iz, ioff;
484 for (i=0; i<
fNz; i++) {
485 iz = (reversez) ?
fNz-1 - i : i;
487 for (j=0; j<
fNxy; j++) {
488 ixy = (iscw) ?
fNxy-1 - j : j;
527 <<
" TXTRU::SplitConcavePolygon is not yet implemented" << std::endl;
536 if ((npts < 0) || (npts >
fNxy)) {
548 if ((nz < 0) || (nz >
fNz)) {
549 Error(
fName,
"truncate to %d impossible on %d points",nz,
fNz);
567 plus = minus = zero = 0;
569 for (ixy=0; ixy<
fNxy; ixy++) {
581 Float_t xprod = dxprev*dynext - dxnext*dyprev;
585 }
else if (xprod < 0) {
596 if (plus==0 || minus==0) {
615 plus = minus = zero = 0;
618 for (iz=0; iz<
fNz; iz++) {
634 }
else if (iz==
fNz-1) {
639 Float_t xprod = dznext*dsprev - dzprev*dsnext;
643 }
else if (xprod < 0) {
652 if (
fNz<1 || scaleSignChange) {
656 if (plus==0 || minus==0) {
679 std::cout <<
"TXTRU::DumpPoints - " << npoints <<
" points" << std::endl;
683 for (ipt=0; ipt<npoints; ipt++) {
684 x = pointbuff[ioff++];
685 y = pointbuff[ioff++];
686 z = pointbuff[ioff++];
687 printf(
" [%4d] %6.1f %6.1f %6.1f \n",ipt,
x,
y,z);
696 std::cout <<
"TXTRU::DumpSegments - " << nsegments <<
" segments" << std::endl;
700 for (iseg=0; iseg<nsegments; iseg++) {
701 icol = segbuff[ioff++];
702 p1 = segbuff[ioff++];
703 p2 = segbuff[ioff++];
704 printf(
" [%4d] %3d (%4d,%4d)\n",iseg,icol,p1,p2);
713 std::cout <<
"TXTRU::DumpPolygons - " << npolygons <<
" polygons" << std::endl;
715 int icol, nseg, iseg;
717 for (ipoly=0; ipoly<npolygons; ipoly++) {
718 icol = polybuff[ioff++];
719 nseg = polybuff[ioff++];
721 std::cout <<
" [" << std::setw(4) << ipoly <<
"] icol " << std::setw(3) << icol
722 <<
" nseg " << std::setw(3) << nseg <<
" (";
724 printf(
" [%d4] icol %d3 nseg %d3 (", ipoly, icol, nseg);
726 for (iseg=0; iseg<nseg-1; iseg++) {
727 std::cout << polybuff[ioff++] <<
",";
729 std::cout << polybuff[ioff++] <<
")" << std::endl;
731 std::cout <<
" buffer size " << bufsize <<
" last used " << --ioff << std::endl;
754 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*(nbPols-2)+2*(2+
fNxy))) {
772 for (i=0; i<
fNz; i++) {
776 for (j=0; j<
fNxy; j++) {
779 buffer.
fSegs[indx++] = indx2+j;
780 buffer.
fSegs[indx++] = indx2+k;
783 for (i=0; i<
fNz-1; i++) {
787 for (j=0; j<
fNxy; j++) {
790 buffer.
fSegs[indx++] = indx2+j;
791 buffer.
fSegs[indx++] = indx2+k;
799 for (i=0; i<
fNz-1; i++) {
801 for (j=0; j<
fNxy; j++) {
803 buffer.
fPols[indx++] =
c+j%3;
804 buffer.
fPols[indx++] = 4;
805 buffer.
fPols[indx++] = indx2+j;
811 buffer.
fPols[indx++] =
c+2;
814 for (j =
fNxy - 1; j >= 0; --j) {
815 buffer.
fPols[indx++] = indx2+j;
822 for (j=0; j<
fNxy; j++) {
823 buffer.
fPols[indx++] = indx2+j;
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
Generic 3D primitive description class.
void SetSectionsValid(UInt_t mask)
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
const char * GetName() const override
Returns name of object.
virtual void Copy(TObject &object) const
Copy this to obj.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
Int_t GetBasicColor() const
Get basic color.
Int_t ShapeDistancetoPrimitive(Int_t numPoints, Int_t px, Int_t py)
Distance to primitive.
TShape()
Shape default constructor.
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections) const
We have to set kRawSize (unless already done) to allocate buffer space before kRaw can be filled.
void TransformPoints(Double_t *points, UInt_t NbPnts) const
Transform points (LocalToMaster).
void ToLower()
Change string to lower-case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void CheckOrdering()
Determine ordering over which to process points, segments, surfaces so that they render correctly.
virtual void DefineVertex(Int_t pointNum, Float_t x, Float_t y)
Set vertex point ipt to (x,y) expand size of array if necessary.
void SplitConcavePolygon(Bool_t split=kTRUE)
(Dis)Enable the splitting of concave polygon outlines into multiple convex polygons.
virtual Float_t GetSectionX0(Int_t secNum) const
Return x0 shift of a z section.
void DumpSegments(int nsegments, int *segbuff) const
Dump the segment info for visual inspection.
TXTRU & operator=(const TXTRU &rhs)
Deep assignment operator.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute the distance from point px,py to a TXTRU by calculating the closest approach to each corner.
virtual Float_t GetOutlinePointX(Int_t pointNum) const
Return x coordinate of a vertex point.
virtual Float_t GetSectionScale(Int_t secNum) const
Return scale factor for a z section.
virtual Float_t GetSectionY0(Int_t secNum) const
Return y0 shift of a z section.
void Copy(TObject &xtru) const override
TXTRU Copy method.
void DumpPoints(int npoints, float *pointbuff) const
Dump the vertex points for visual inspection.
void DumpPolygons(int npolygons, int *polybuff, int bufsize) const
Dump the derived polygon info for visual inspection.
virtual void TruncateNxy(Int_t npts)
Truncate the vertex list.
void Print(Option_t *option="") const override
Dump the info of this TXTRU shape Option:
virtual Float_t GetSectionZ(Int_t secNum) const
Return z of a z section.
const TBuffer3D & GetBuffer3D(Int_t) const override
Get buffer 3d.
virtual void DefineSection(Int_t secNum, Float_t z, Float_t scale=1., Float_t x0=0., Float_t y0=0.)
Set z section iz information expand size of array if necessary.
void SetPoints(Double_t *points) const override
Create TXTRU points in buffer order as expected by other methods (counterclockwise xy,...
void Sizeof3D() const override
Return total X3D needed by TNode::ls (when called with option "x").
TXTRU()
TXTRU shape - default constructor.
~TXTRU() override
TXTRU destructor deallocates arrays.
virtual void TruncateNz(Int_t npts)
Truncate the z section list.
virtual Float_t GetOutlinePointY(Int_t pointNum) const
Return y coordinate of a vertex point.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.