library: libGraf3d #include "TXTRU.h"

# TXTRU

class description - source file - inheritance tree (.pdf)

## class TXTRU : public TShape

| Inheritance Chart:
`TObject`
| <- | `TNamed`
`TAttLine`
`TAttFill`
`TAtt3D`
| <- | `TShape`
| <- | `TXTRU` |

        private:

          void DumpPoints(int npoints, float* pointbuff) const
          void DumpPolygons(int npolygons, int* polybuff, int buffsize) const
          void DumpSegments(int nsegments, int* segbuff) const

        protected:

                  void CheckOrdering()
          virtual void SetPoints(Double_t* points) const

        public:

                                   TXTRU()
                                   TXTRU(const Text_t* name, const Text_t* title, const Text_t* material, Int_t nyx, Int_t nz)
                                   TXTRU(const TXTRU& xtru)
                           virtual ~TXTRU()
                    static TClass* Class()
                      virtual void Copy(TObject& xtru) const
                      virtual void DefineSection(Int_t secNum, Float_t z, Float_t scale = 1., Float_t x0 = 0., Float_t y0 = 0.)
                      virtual void DefineVertex(Int_t pointNum, Float_t x, Float_t y)
                     virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
          virtual const TBuffer3D& GetBuffer3D(Int_t) const
                     virtual Int_t GetNxy() const
                     virtual Int_t GetNz() const
                   virtual Float_t GetOutlinePointX(Int_t pointNum) const
                   virtual Float_t GetOutlinePointY(Int_t pointNum) const
                  virtual Float_t* GetScale() const
                   virtual Float_t GetSectionScale(Int_t secNum) const
                   virtual Float_t GetSectionX0(Int_t secNum) const
                   virtual Float_t GetSectionY0(Int_t secNum) const
                   virtual Float_t GetSectionZ(Int_t secNum) const
                  virtual Float_t* GetX0() const
                  virtual Float_t* GetXvtx() const
                  virtual Float_t* GetY0() const
                  virtual Float_t* GetYvtx() const
                  virtual Float_t* GetZ() const
                   virtual TClass* IsA() const
                            TXTRU& operator=(const TXTRU& rhs)
                      virtual void Print(Option_t* option = "") const
                      virtual void ShowMembers(TMemberInspector& insp, char* parent)
                      virtual void Sizeof3D() const
                              void SplitConcavePolygon(Bool_t split = kTRUE)
                      virtual void Streamer(TBuffer& b)
                              void StreamerNVirtual(TBuffer& b)
                      virtual void TruncateNxy(Int_t npts)
                      virtual void TruncateNz(Int_t npts)

### Data Members

        protected:

                      Int_t fNxy           number of x-y points in the cross section
                      Int_t fNxyAlloc      number of x-y points allocated
                      Int_t fNz            number of z planes
                      Int_t fNzAlloc       number of z planes allocated
                   Float_t* fXvtx          [fNxyAlloc] array of x positions
                   Float_t* fYvtx          [fNxyAlloc] array of y positions
                   Float_t* fZ             [fNzAlloc] array of z planes
                   Float_t* fScale         [fNzAlloc] array of scale factors (for each z)
                   Float_t* fX0            [fNzAlloc] array of x offsets (for each z)
                   Float_t* fY0            [fNzAlloc] array of y offsets (for each z)
          TXTRU::EXYChecked fPolygonShape  CCW vs. CW, convex vs. concave
           TXTRU::EZChecked fZOrdering     increasing or decreasing
                     Bool_t fSplitConcave

        public:

          static const TXTRU::EXYChecked kUncheckedXY
          static const TXTRU::EXYChecked kMalformedXY
          static const TXTRU::EXYChecked kConvexCCW
          static const TXTRU::EXYChecked kConvexCW
          static const TXTRU::EXYChecked kConcaveCCW
          static const TXTRU::EXYChecked kConcaveCW
           static const TXTRU::EZChecked kUncheckedZ
           static const TXTRU::EZChecked kMalformedZ
           static const TXTRU::EZChecked kConvexIncZ
           static const TXTRU::EZChecked kConvexDecZ
           static const TXTRU::EZChecked kConcaveIncZ
           static const TXTRU::EZChecked kConcaveDecZ

## Class Description

     XTRU is an poly-extrusion with fixed outline shape in x-y,
     a sequence of z extents (segments) and two end faces perpendicular
     to the z axis.  The x-y outline is defined by an ordered list of
     points; the overall scale of the outline scales linearly between
     z points and the center can have an x-y offset specified
     at each segment end.

     A TXTRU has the following parameters:

         - name       name of the shape
         - title      shape's title
         - material  (see TMaterial)
         - nxy        number of x-y vertex points constituting the outline --
                      this number should be at least 3
         - nz         number of planes perpendicular to the z axis where
                      the scaling dimension of the section is given --
                      this number should be at least 2
         - Xvtx       array [nxy] of X coordinates of vertices
         - Yvtx       array [nxy] of Y coordinates of vertices
         - z          array [nz] of z plane positions
         - scale      array [nz] of scale factors
         - x0         array [nz] of x offsets
         - y0         array [nz] of y offsets

     Author:  R. Hatcher 2000.04.21

     All XTRU shapes are correctly rendered in wire mode but can encounter
     difficulty when rendered as a solid with hidden surfaces.  These
     exceptions occur if the outline shape is not a convex polygon.
     Both the X3D and OpenGL renderers expect polygons to be convex.
     The OpenGL spec specifies that points defining a polygon using the
     GL_POLYGON primitive may be rendered as the convex hull of that set.

     Solid rendering under X3D can also give unexpected artifacts if
     the combination of x-y-z offsets and scales for the segments are
     chosen in such a manner that they represent a concave shape when
     sliced along a plane parallel to the z axis.

     Choosing sets of point that represent a malformed polygon is
     not supported, but testing for such a condition is not implemented
     and thus it is left to the user to avoid this mistake.

TXTRU() : fNxy(0), fNxyAlloc(0), fNz(0), fNzAlloc(0), fXvtx(0), fYvtx(0), fZ(0), fScale(0), fX0(0), fY0(0)

     TXTRU shape - default constructor

TXTRU(const Text_t *name, const Text_t *title, const Text_t *material, Int_t nxy, Int_t nz) : TShape (name,title,material)

     TXTRU shape - normal constructor

     Parameters of Nxy positions must be entered via TXTRU::DefineVertex
     Parameters of Nz  positions must be entered via TXTRU::DefineSection

TXTRU(const TXTRU &xtru) : TShape(xtru)

     TXTRU copy constructor

~TXTRU()

     TXTRU destructor deallocates arrays

void Copy(TObject &obj) const

     TXTRU Copy method

void DefineSection(Int_t iz, Float_t z, Float_t scale, Float_t x0, Float_t y0)

     Set z section iz information
     expand size of array if necessary

void DefineVertex(Int_t ipt, Float_t x, Float_t y)

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

Float_t GetOutlinePointX(Int_t n) const

Float_t GetOutlinePointY(Int_t n) const

Float_t GetSectionX0(Int_t n) const

Float_t GetSectionY0(Int_t n) const

Float_t GetSectionScale(Int_t n) const

Float_t GetSectionZ(Int_t n) const

void Print(Option_t *option) const

     Dump the info of this TXTRU shape
     Option: "xy" to get x-y information
             "z"  to get z information
             "alloc" to show full allocated arrays (not just used values)

void SetPoints(Double_t *points) const

     Create TXTRU points in buffer
     order as expected by other methods (counterclockwise xy, increasing z)

void Sizeof3D() const

     Return total X3D needed by TNode::ls (when called with option "x")

void SplitConcavePolygon(Bool_t split)

     (Dis)Enable the splitting of concave polygon outlines into
     multiple convex polygons.  This would make for better rendering
     in solid mode, but introduces extra, potentially confusing, lines
     in wireframe mode.
     *** Not yet implemented ***

void TruncateNxy(Int_t npts)

void TruncateNz(Int_t nz)

void CheckOrdering()

     Determine ordering over which to process points, segments, surfaces
     so that they render correctly.  Generally this has to do
     with getting outward normals in the hidden/solid surface case.

void DumpPoints(int npoints, float *pointbuff) const

     Dump the vertex points for visual inspection

void DumpSegments(int nsegments, int *segbuff) const

     Dump the segment info for visual inspection

void DumpPolygons(int npolygons, int *polybuff, int buffsize) const

     Dump the derived polygon info for visual inspection

const TBuffer3D& GetBuffer3D(Int_t reqSections) const

### Inline Functions

                 TXTRU& operator=(const TXTRU& rhs)
                  Int_t GetNxy() const
                  Int_t GetNz() const
               Float_t* GetXvtx() const
               Float_t* GetYvtx() const
               Float_t* GetZ() const
               Float_t* GetScale() const
               Float_t* GetX0() const
               Float_t* GetY0() const
                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)

Author: Robert Hatcher (rhatcher@fnal.gov) 2000.09.06
Last update: Wed Jun 8 07:02:45 2005