TBRIK.cxx

Go to the documentation of this file.
00001 // @(#)root/g3d:$Id: TBRIK.cxx 31624 2009-12-08 09:58:40Z couet $
00002 // Author: Nenad Buncic 17/09/95 
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TBRIK.h"
00013 #include "TNode.h"
00014 #include "TVirtualPad.h"
00015 #include "TBuffer3D.h"
00016 #include "TBuffer3DTypes.h"
00017 #include "TGeometry.h"
00018 
00019 ClassImp(TBRIK)
00020 
00021 
00022 //______________________________________________________________________________
00023 // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/brik.gif"> </P> End_Html
00024 // BRIK is a box with faces perpendicular to the axes. It has 6 parameters:
00025 //
00026 //     - name       name of the shape
00027 //     - title      shape's title
00028 //     - material  (see TMaterial)
00029 //     - dx         half-length of the box along the x-axis
00030 //     - dy         half-length of the box along the y-axis
00031 //     - dz         half-length of the box along the z-axis
00032 
00033 
00034 //______________________________________________________________________________
00035 TBRIK::TBRIK()
00036 {
00037    // BRIK shape default constructor
00038 
00039    fDx = 0.;
00040    fDy = 0.;
00041    fDz = 0.;
00042 }
00043 
00044 
00045 //______________________________________________________________________________
00046 TBRIK::TBRIK(const char *name, const char *title, const char *material, Float_t dx, Float_t dy, Float_t dz)
00047       : TShape (name, title,material)
00048 {
00049    // BRIK shape normal constructor
00050 
00051    fDx = dx;
00052    fDy = dy;
00053    fDz = dz;
00054 }
00055 
00056 
00057 //______________________________________________________________________________
00058 TBRIK::~TBRIK()
00059 {
00060   // BRIK shape default destructor
00061 }
00062 
00063 
00064 //______________________________________________________________________________
00065 Int_t TBRIK::DistancetoPrimitive(Int_t px, Int_t py)
00066 {
00067    // Compute distance from point px,py to a BRIK
00068    //
00069    // Compute the closest distance of approach from point px,py to each corner
00070    // point of the BRIK.
00071 
00072    const Int_t numPoints = 8;
00073    return ShapeDistancetoPrimitive(numPoints,px,py);
00074 }
00075 
00076 
00077 //______________________________________________________________________________
00078 void TBRIK::SetPoints(Double_t *points) const
00079 {
00080    // Create BRIK points
00081 
00082    if (points) {
00083       points[ 0] = -fDx ; points[ 1] = -fDy ; points[ 2] = -fDz;
00084       points[ 3] = -fDx ; points[ 4] =  fDy ; points[ 5] = -fDz;
00085       points[ 6] =  fDx ; points[ 7] =  fDy ; points[ 8] = -fDz;
00086       points[ 9] =  fDx ; points[10] = -fDy ; points[11] = -fDz;
00087       points[12] = -fDx ; points[13] = -fDy ; points[14] =  fDz;
00088       points[15] = -fDx ; points[16] =  fDy ; points[17] =  fDz;
00089       points[18] =  fDx ; points[19] =  fDy ; points[20] =  fDz;
00090       points[21] =  fDx ; points[22] = -fDy ; points[23] =  fDz;
00091    }
00092 }
00093 
00094 
00095 //______________________________________________________________________________
00096 void TBRIK::Sizeof3D() const
00097 {
00098    // Return total X3D needed by TNode::ls (when called with option "x")
00099 
00100    gSize3D.numPoints += 8;
00101    gSize3D.numSegs   += 12;
00102    gSize3D.numPolys  += 6;
00103 }
00104 
00105 
00106 //______________________________________________________________________________
00107 const TBuffer3D & TBRIK::GetBuffer3D(Int_t reqSections) const
00108 {
00109    // Get buffer 3D
00110 
00111    static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
00112 
00113    TShape::FillBuffer3D(buffer, reqSections);
00114 
00115    // No kShapeSpecific or kBoundingBox
00116 
00117    if (reqSections & TBuffer3D::kRawSizes) {
00118       Int_t nbPnts = 8;
00119       Int_t nbSegs = 12;
00120       Int_t nbPols = 6;
00121       if (buffer.SetRawSizes(nbPnts, nbPnts*3, nbSegs, nbSegs*3, nbPols, nbPols*6)) {
00122          buffer.SetSectionsValid(TBuffer3D::kRawSizes);
00123       }
00124    }
00125    if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
00126       // Points
00127       SetPoints(buffer.fPnts);
00128       if (!buffer.fLocalFrame) {
00129          TransformPoints(buffer.fPnts, buffer.NbPnts());
00130       }
00131 
00132       Int_t c = GetBasicColor();
00133 
00134       // Segments
00135       buffer.fSegs[ 0] = c   ; buffer.fSegs[ 1] = 0   ; buffer.fSegs[ 2] = 1   ;
00136       buffer.fSegs[ 3] = c+1 ; buffer.fSegs[ 4] = 1   ; buffer.fSegs[ 5] = 2   ;
00137       buffer.fSegs[ 6] = c+1 ; buffer.fSegs[ 7] = 2   ; buffer.fSegs[ 8] = 3   ;
00138       buffer.fSegs[ 9] = c   ; buffer.fSegs[10] = 3   ; buffer.fSegs[11] = 0   ;
00139       buffer.fSegs[12] = c+2 ; buffer.fSegs[13] = 4   ; buffer.fSegs[14] = 5   ;
00140       buffer.fSegs[15] = c+2 ; buffer.fSegs[16] = 5   ; buffer.fSegs[17] = 6   ;
00141       buffer.fSegs[18] = c+3 ; buffer.fSegs[19] = 6   ; buffer.fSegs[20] = 7   ;
00142       buffer.fSegs[21] = c+3 ; buffer.fSegs[22] = 7   ; buffer.fSegs[23] = 4   ;
00143       buffer.fSegs[24] = c   ; buffer.fSegs[25] = 0   ; buffer.fSegs[26] = 4   ;
00144       buffer.fSegs[27] = c+2 ; buffer.fSegs[28] = 1   ; buffer.fSegs[29] = 5   ;
00145       buffer.fSegs[30] = c+1 ; buffer.fSegs[31] = 2   ; buffer.fSegs[32] = 6   ;
00146       buffer.fSegs[33] = c+3 ; buffer.fSegs[34] = 3   ; buffer.fSegs[35] = 7   ;
00147 
00148       // Polygons
00149       buffer.fPols[ 0] = c   ; buffer.fPols[ 1] = 4   ;  buffer.fPols[ 2] = 0  ;
00150       buffer.fPols[ 3] = 9   ; buffer.fPols[ 4] = 4   ;  buffer.fPols[ 5] = 8  ;
00151       buffer.fPols[ 6] = c+1 ; buffer.fPols[ 7] = 4   ;  buffer.fPols[ 8] = 1  ;
00152       buffer.fPols[ 9] = 10  ; buffer.fPols[10] = 5   ;  buffer.fPols[11] = 9  ;
00153       buffer.fPols[12] = c   ; buffer.fPols[13] = 4   ;  buffer.fPols[14] = 2  ;
00154       buffer.fPols[15] = 11  ; buffer.fPols[16] = 6   ;  buffer.fPols[17] = 10 ;
00155       buffer.fPols[18] = c+1 ; buffer.fPols[19] = 4   ;  buffer.fPols[20] = 3  ;
00156       buffer.fPols[21] = 8   ; buffer.fPols[22] = 7   ;  buffer.fPols[23] = 11 ;
00157       buffer.fPols[24] = c+2 ; buffer.fPols[25] = 4   ;  buffer.fPols[26] = 0  ;
00158       buffer.fPols[27] = 3   ; buffer.fPols[28] = 2   ;  buffer.fPols[29] = 1  ;
00159       buffer.fPols[30] = c+3 ; buffer.fPols[31] = 4   ;  buffer.fPols[32] = 4  ;
00160       buffer.fPols[33] = 5   ; buffer.fPols[34] = 6   ;  buffer.fPols[35] = 7  ;
00161 
00162       buffer.SetSectionsValid(TBuffer3D::kRaw);
00163    }
00164    return buffer;
00165 }

Generated on Tue Jul 5 14:16:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1