77 : fNxy(0), fNxyAlloc(0), fNz(0), fNzAlloc(0), fXvtx(0), fYvtx(0),
78 fZ(0), fScale(0), fX0(0), fY0(0)
80 fPolygonShape = kUncheckedXY;
81 fZOrdering = kUncheckedZ;
93 :
TShape (name,title,material)
112 Error(name,
"number of x-y points for %s must be at least three!",name);
116 Error(name,
"number of z points for %s must be at least two!",name);
172 if (
fZ)
delete []
fZ;
193 if (
this == &rhs)
return *
this;
205 ((
TXTRU&)rhs).Copy(*
this);
259 Int_t newNalloc = iz + 1;
265 for (i = 0; i < newNalloc; i++) {
312 Int_t newNalloc = ipt + 1;
316 for (i = 0; i < newNalloc; i++) {
355 if ((n < 0) || (n >=
fNxy)) {
366 if ((n < 0) || (n >=
fNxy)) {
377 if ((n < 0) || (n >=
fNz)) {
388 if ((n < 0) || (n >=
fNz)) {
399 if ((n < 0) || (n >=
fNz)) {
410 if ((n < 0) || (n >=
fNz)) {
429 printf(
"TXTRU %s Nxy=%d [of %d] Nz=%d [of %d] Option=%s\n",
432 const char *shape = 0;
433 const char *zorder = 0;
438 case kConvexCCW: shape =
"Convex CCW ";
break;
439 case kConvexCW: shape =
"Convex CW ";
break;
441 case kConcaveCW: shape =
"Concave CW ";
break;
447 case kConvexIncZ: zorder =
"Convex Increasing Z";
break;
448 case kConvexDecZ: zorder =
"Convex Decreasing Z";
break;
449 case kConcaveIncZ: zorder =
"Concave Increasing Z";
break;
450 case kConcaveDecZ: zorder =
"Concave Decreasing Z";
break;
453 printf(
" XY shape '%s', '%s'\n",shape,zorder);
465 const char *
name = 0;
472 for (ixyz=0; ixyz<6; ixyz++) {
474 case 0: p =
fXvtx; name =
"x"; nlimit = nxy;
break;
475 case 1: p =
fYvtx; name =
"y"; nlimit = nxy;
break;
476 case 2: p =
fZ; name =
"z"; nlimit = nz;
break;
477 case 3: p =
fScale; name =
"scale"; nlimit = nz;
break;
478 case 4: p =
fX0; name =
"x0"; nlimit = nz;
break;
479 case 5: p =
fY0; name =
"y0"; nlimit = nz;
break;
481 if (ixyz<=1 && !print_vtx)
continue;
482 if (ixyz>=2 && !print_z)
continue;
484 printf(
" Float_t %s[] = \n { %10g",name,*p++);
486 for (i=1;i<nlimit;i++) {
487 printf(
", %10g",*p++);
488 if (i%6==5) printf(
"\n ");
502 Int_t ipt, ixy, iz, ioff;
515 for (i=0; i<
fNz; i++) {
516 iz = (reversez) ? fNz-1 - i : i;
518 for (j=0; j<
fNxy; j++) {
519 ixy = (iscw) ? fNxy-1 - j : j;
525 points[ioff+2] =
fZ[iz];
558 <<
" TXTRU::SplitConcavePolygon is not yet implemented" << std::endl;
567 if ((npts < 0) || (npts >
fNxy)) {
579 if ((nz < 0) || (nz >
fNz)) {
580 Error(
fName,
"truncate to %d impossible on %d points",nz,
fNz);
598 plus = minus = zero = 0;
600 for (ixy=0; ixy<
fNxy; ixy++) {
604 Int_t ixyprev = (ixy + fNxy - 1)%fNxy;
605 Int_t ixynext = (ixy + fNxy + 1)%fNxy;
609 Float_t dxnext = fXvtx[ixynext] - fXvtx[ixy];
610 Float_t dynext = fYvtx[ixynext] - fYvtx[ixy];
612 Float_t xprod = dxprev*dynext - dxnext*dyprev;
616 }
else if (xprod < 0) {
627 if (plus==0 || minus==0) {
646 plus = minus = zero = 0;
649 for (iz=0; iz<
fNz; iz++) {
653 Int_t izprev = (iz + fNz - 1)%fNz;
654 Int_t iznext = (iz + fNz + 1)%fNz;
658 Float_t dznext = fZ[iznext] - fZ[iz];
659 Float_t dsnext = fScale[iznext] - fScale[iz];
665 }
else if (iz==fNz-1) {
667 dsnext = -fScale[iz];
670 Float_t xprod = dznext*dsprev - dzprev*dsnext;
674 }
else if (xprod < 0) {
680 if (fScale[iz]*fScale[iznext] < 0) scaleSignChange =
kTRUE;
683 if (fNz<1 || scaleSignChange) {
687 if (plus==0 || minus==0) {
710 std::cout <<
"TXTRU::DumpPoints - " << npoints <<
" points" << std::endl;
714 for (ipt=0; ipt<npoints; ipt++) {
715 x = pointbuff[ioff++];
716 y = pointbuff[ioff++];
717 z = pointbuff[ioff++];
718 printf(
" [%4d] %6.1f %6.1f %6.1f \n",ipt,x,y,z);
727 std::cout <<
"TXTRU::DumpSegments - " << nsegments <<
" segments" << std::endl;
731 for (iseg=0; iseg<nsegments; iseg++) {
732 icol = segbuff[ioff++];
733 p1 = segbuff[ioff++];
734 p2 = segbuff[ioff++];
735 printf(
" [%4d] %3d (%4d,%4d)\n",iseg,icol,p1,p2);
744 std::cout <<
"TXTRU::DumpPolygons - " << npolygons <<
" polygons" << std::endl;
746 int icol, nseg, iseg;
748 for (ipoly=0; ipoly<npolygons; ipoly++) {
749 icol = polybuff[ioff++];
750 nseg = polybuff[ioff++];
752 std::cout <<
" [" << std::setw(4) << ipoly <<
"] icol " << std::setw(3) << icol
753 <<
" nseg " << std::setw(3) << nseg <<
" (";
755 printf(
" [%d4] icol %d3 nseg %d3 (", ipoly, icol, nseg);
757 for (iseg=0; iseg<nseg-1; iseg++) {
758 std::cout << polybuff[ioff++] <<
",";
760 std::cout << polybuff[ioff++] <<
")" << std::endl;
762 std::cout <<
" buffer size " << buffsize <<
" last used " << --ioff << std::endl;
785 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*(nbPols-2)+2*(2+fNxy))) {
803 for (i=0; i<
fNz; i++) {
807 for (j=0; j<
fNxy; j++) {
810 buffer.
fSegs[indx++] = indx2+j;
811 buffer.
fSegs[indx++] = indx2+k;
814 for (i=0; i<fNz-1; i++) {
818 for (j=0; j<
fNxy; j++) {
821 buffer.
fSegs[indx++] = indx2+j;
822 buffer.
fSegs[indx++] = indx2+k;
830 for (i=0; i<fNz-1; i++) {
832 for (j=0; j<
fNxy; j++) {
834 buffer.
fPols[indx++] = c+j%3;
835 buffer.
fPols[indx++] = 4;
836 buffer.
fPols[indx++] = indx2+j;
837 buffer.
fPols[indx++] = fNz*fNxy+indx2+k;
838 buffer.
fPols[indx++] = indx2+fNxy+j;
839 buffer.
fPols[indx++] = fNz*fNxy+indx2+j;
842 buffer.
fPols[indx++] = c+2;
845 for (j =
fNxy - 1; j >= 0; --j) {
846 buffer.
fPols[indx++] = indx2+j;
851 indx2 = (fNz-1)*
fNxy;
853 for (j=0; j<
fNxy; j++) {
854 buffer.
fPols[indx++] = indx2+j;
virtual const char * GetName() const
Returns name of object.
virtual const TBuffer3D & GetBuffer3D(Int_t) const
Get buffer 3d.
virtual void Copy(TObject &xtru) const
TXTRU Copy method.
TXTRU & operator=(const TXTRU &rhs)
Deep assignment operator.
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...
virtual Float_t GetOutlinePointX(Int_t pointNum) const
Return x coordinate of a vertex point.
virtual void Print(Option_t *option="") const
Dump the info of this TXTRU shape Option:
void ToLower()
Change string to lower-case.
TXTRU()
TXTRU shape - default constructor.
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.
virtual void Sizeof3D() const
Return total X3D needed by TNode::ls (when called with option "x")
void DumpSegments(int nsegments, int *segbuff) const
Dump the segment info for visual inspection.
virtual void Copy(TObject &object) const
Copy this to obj.
virtual Float_t GetSectionX0(Int_t secNum) const
Return x0 shift of a z section.
static double p2(double t, double a, double b, double c)
virtual void SetPoints(Double_t *points) const
Create TXTRU points in buffer order as expected by other methods (counterclockwise xy...
void CheckOrdering()
Determine ordering over which to process points, segments, surfaces so that they render correctly...
void SetSectionsValid(UInt_t mask)
virtual ~TXTRU()
TXTRU destructor deallocates arrays.
Int_t ShapeDistancetoPrimitive(Int_t numPoints, Int_t px, Int_t py)
Distance to primitive.
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.
This is the base class for all geometry shapes.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute the distance from point px,py to a TXTRU by calculating the closest approach to each corner...
virtual void TruncateNxy(Int_t npts)
Truncate the vertex list.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
Generic 3D primitive description class.
virtual Float_t GetSectionZ(Int_t secNum) const
Return z of a z section.
static double p1(double t, double a, double b)
void DumpPolygons(int npolygons, int *polybuff, int buffsize) const
Dump the derived polygon info for visual inspection.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void DumpPoints(int npoints, float *pointbuff) const
Dump the vertex points for visual inspection.
Mother of all ROOT objects.
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.
Int_t GetBasicColor() const
Get basic color.
you should not use this method at all Int_t Int_t z
void SplitConcavePolygon(Bool_t split=kTRUE)
(Dis)Enable the splitting of concave polygon outlines into multiple convex polygons.
virtual void Copy(TObject &named) const
Copy this to obj.
Short_t Max(Short_t a, Short_t b)
void TransformPoints(Double_t *points, UInt_t NbPnts) const
Transform points (LocalToMaster)
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.