ROOT logo
// @(#)root/g3d:$Id: TBRIK.cxx 31624 2009-12-08 09:58:40Z couet $
// Author: Nenad Buncic 17/09/95 

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TBRIK.h"
#include "TNode.h"
#include "TVirtualPad.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TGeometry.h"

ClassImp(TBRIK)


//______________________________________________________________________________
// Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/brik.gif"> </P> End_Html
// BRIK is a box with faces perpendicular to the axes. It has 6 parameters:
//
//     - name       name of the shape
//     - title      shape's title
//     - material  (see TMaterial)
//     - dx         half-length of the box along the x-axis
//     - dy         half-length of the box along the y-axis
//     - dz         half-length of the box along the z-axis


//______________________________________________________________________________
TBRIK::TBRIK()
{
   // BRIK shape default constructor

   fDx = 0.;
   fDy = 0.;
   fDz = 0.;
}


//______________________________________________________________________________
TBRIK::TBRIK(const char *name, const char *title, const char *material, Float_t dx, Float_t dy, Float_t dz)
      : TShape (name, title,material)
{
   // BRIK shape normal constructor

   fDx = dx;
   fDy = dy;
   fDz = dz;
}


//______________________________________________________________________________
TBRIK::~TBRIK()
{
  // BRIK shape default destructor
}


//______________________________________________________________________________
Int_t TBRIK::DistancetoPrimitive(Int_t px, Int_t py)
{
   // Compute distance from point px,py to a BRIK
   //
   // Compute the closest distance of approach from point px,py to each corner
   // point of the BRIK.

   const Int_t numPoints = 8;
   return ShapeDistancetoPrimitive(numPoints,px,py);
}


//______________________________________________________________________________
void TBRIK::SetPoints(Double_t *points) const
{
   // Create BRIK points

   if (points) {
      points[ 0] = -fDx ; points[ 1] = -fDy ; points[ 2] = -fDz;
      points[ 3] = -fDx ; points[ 4] =  fDy ; points[ 5] = -fDz;
      points[ 6] =  fDx ; points[ 7] =  fDy ; points[ 8] = -fDz;
      points[ 9] =  fDx ; points[10] = -fDy ; points[11] = -fDz;
      points[12] = -fDx ; points[13] = -fDy ; points[14] =  fDz;
      points[15] = -fDx ; points[16] =  fDy ; points[17] =  fDz;
      points[18] =  fDx ; points[19] =  fDy ; points[20] =  fDz;
      points[21] =  fDx ; points[22] = -fDy ; points[23] =  fDz;
   }
}


//______________________________________________________________________________
void TBRIK::Sizeof3D() const
{
   // Return total X3D needed by TNode::ls (when called with option "x")

   gSize3D.numPoints += 8;
   gSize3D.numSegs   += 12;
   gSize3D.numPolys  += 6;
}


//______________________________________________________________________________
const TBuffer3D & TBRIK::GetBuffer3D(Int_t reqSections) const
{
   // Get buffer 3D

   static TBuffer3D buffer(TBuffer3DTypes::kGeneric);

   TShape::FillBuffer3D(buffer, reqSections);

   // No kShapeSpecific or kBoundingBox

   if (reqSections & TBuffer3D::kRawSizes) {
      Int_t nbPnts = 8;
      Int_t nbSegs = 12;
      Int_t nbPols = 6;
      if (buffer.SetRawSizes(nbPnts, nbPnts*3, nbSegs, nbSegs*3, nbPols, nbPols*6)) {
         buffer.SetSectionsValid(TBuffer3D::kRawSizes);
      }
   }
   if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
      // Points
      SetPoints(buffer.fPnts);
      if (!buffer.fLocalFrame) {
         TransformPoints(buffer.fPnts, buffer.NbPnts());
      }

      Int_t c = GetBasicColor();

      // Segments
      buffer.fSegs[ 0] = c   ; buffer.fSegs[ 1] = 0   ; buffer.fSegs[ 2] = 1   ;
      buffer.fSegs[ 3] = c+1 ; buffer.fSegs[ 4] = 1   ; buffer.fSegs[ 5] = 2   ;
      buffer.fSegs[ 6] = c+1 ; buffer.fSegs[ 7] = 2   ; buffer.fSegs[ 8] = 3   ;
      buffer.fSegs[ 9] = c   ; buffer.fSegs[10] = 3   ; buffer.fSegs[11] = 0   ;
      buffer.fSegs[12] = c+2 ; buffer.fSegs[13] = 4   ; buffer.fSegs[14] = 5   ;
      buffer.fSegs[15] = c+2 ; buffer.fSegs[16] = 5   ; buffer.fSegs[17] = 6   ;
      buffer.fSegs[18] = c+3 ; buffer.fSegs[19] = 6   ; buffer.fSegs[20] = 7   ;
      buffer.fSegs[21] = c+3 ; buffer.fSegs[22] = 7   ; buffer.fSegs[23] = 4   ;
      buffer.fSegs[24] = c   ; buffer.fSegs[25] = 0   ; buffer.fSegs[26] = 4   ;
      buffer.fSegs[27] = c+2 ; buffer.fSegs[28] = 1   ; buffer.fSegs[29] = 5   ;
      buffer.fSegs[30] = c+1 ; buffer.fSegs[31] = 2   ; buffer.fSegs[32] = 6   ;
      buffer.fSegs[33] = c+3 ; buffer.fSegs[34] = 3   ; buffer.fSegs[35] = 7   ;

      // Polygons
      buffer.fPols[ 0] = c   ; buffer.fPols[ 1] = 4   ;  buffer.fPols[ 2] = 0  ;
      buffer.fPols[ 3] = 9   ; buffer.fPols[ 4] = 4   ;  buffer.fPols[ 5] = 8  ;
      buffer.fPols[ 6] = c+1 ; buffer.fPols[ 7] = 4   ;  buffer.fPols[ 8] = 1  ;
      buffer.fPols[ 9] = 10  ; buffer.fPols[10] = 5   ;  buffer.fPols[11] = 9  ;
      buffer.fPols[12] = c   ; buffer.fPols[13] = 4   ;  buffer.fPols[14] = 2  ;
      buffer.fPols[15] = 11  ; buffer.fPols[16] = 6   ;  buffer.fPols[17] = 10 ;
      buffer.fPols[18] = c+1 ; buffer.fPols[19] = 4   ;  buffer.fPols[20] = 3  ;
      buffer.fPols[21] = 8   ; buffer.fPols[22] = 7   ;  buffer.fPols[23] = 11 ;
      buffer.fPols[24] = c+2 ; buffer.fPols[25] = 4   ;  buffer.fPols[26] = 0  ;
      buffer.fPols[27] = 3   ; buffer.fPols[28] = 2   ;  buffer.fPols[29] = 1  ;
      buffer.fPols[30] = c+3 ; buffer.fPols[31] = 4   ;  buffer.fPols[32] = 4  ;
      buffer.fPols[33] = 5   ; buffer.fPols[34] = 6   ;  buffer.fPols[35] = 7  ;

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x:76
 TBRIK.cxx:77
 TBRIK.cxx:78
 TBRIK.cxx:79
 TBRIK.cxx:80
 TBRIK.cxx:81
 TBRIK.cxx:82
 TBRIK.cxx:83
 TBRIK.cxx:84
 TBRIK.cxx:85
 TBRIK.cxx:86
 TBRIK.cxx:87
 TBRIK.cxx:88
 TBRIK.cxx:89
 TBRIK.cxx:90
 TBRIK.cxx:91
 TBRIK.cxx:92
 TBRIK.cxx:93
 TBRIK.cxx:94
 TBRIK.cxx:95
 TBRIK.cxx:96
 TBRIK.cxx:97
 TBRIK.cxx:98
 TBRIK.cxx:99
 TBRIK.cxx:100
 TBRIK.cxx:101
 TBRIK.cxx:102
 TBRIK.cxx:103
 TBRIK.cxx:104
 TBRIK.cxx:105
 TBRIK.cxx:106
 TBRIK.cxx:107
 TBRIK.cxx:108
 TBRIK.cxx:109
 TBRIK.cxx:110
 TBRIK.cxx:111
 TBRIK.cxx:112
 TBRIK.cxx:113
 TBRIK.cxx:114
 TBRIK.cxx:115
 TBRIK.cxx:116
 TBRIK.cxx:117
 TBRIK.cxx:118
 TBRIK.cxx:119
 TBRIK.cxx:120
 TBRIK.cxx:121
 TBRIK.cxx:122
 TBRIK.cxx:123
 TBRIK.cxx:124
 TBRIK.cxx:125
 TBRIK.cxx:126
 TBRIK.cxx:127
 TBRIK.cxx:128
 TBRIK.cxx:129
 TBRIK.cxx:130
 TBRIK.cxx:131
 TBRIK.cxx:132
 TBRIK.cxx:133
 TBRIK.cxx:134
 TBRIK.cxx:135
 TBRIK.cxx:136
 TBRIK.cxx:137
 TBRIK.cxx:138
 TBRIK.cxx:139
 TBRIK.cxx:140
 TBRIK.cxx:141
 TBRIK.cxx:142
 TBRIK.cxx:143
 TBRIK.cxx:144
 TBRIK.cxx:145
 TBRIK.cxx:146
 TBRIK.cxx:147
 TBRIK.cxx:148
 TBRIK.cxx:149
 TBRIK.cxx:150
 TBRIK.cxx:151
 TBRIK.cxx:152
 TBRIK.cxx:153
 TBRIK.cxx:154
 TBRIK.cxx:155
 TBRIK.cxx:156
 TBRIK.cxx:157
 TBRIK.cxx:158
 TBRIK.cxx:159
 TBRIK.cxx:160
 TBRIK.cxx:161
 TBRIK.cxx:162
 TBRIK.cxx:163
 TBRIK.cxx:164
 TBRIK.cxx:165