Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBRIK.cxx
Go to the documentation of this file.
1// @(#)root/g3d:$Id$
2// Author: Nenad Buncic 17/09/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TBRIK.h"
13#include "TNode.h"
14#include "TBuffer3D.h"
15#include "TBuffer3DTypes.h"
16#include "TGeometry.h"
17
19
20/** \class TBRIK
21\ingroup g3d
22A box with faces perpendicular to the axes.
23
24\image html g3d_brik.png
25It has 6 parameters:
26
27 - name: name of the shape
28 - title: shape's title
29 - material: (see TMaterial)
30 - dx: half-length of the box along the x-axis
31 - dy: half-length of the box along the y-axis
32 - dz: half-length of the box along the z-axis
33*/
34
35////////////////////////////////////////////////////////////////////////////////
36/// BRIK shape default constructor
37
39{
40 fDx = 0.;
41 fDy = 0.;
42 fDz = 0.;
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// BRIK shape normal constructor
47
48TBRIK::TBRIK(const char *name, const char *title, const char *material, Float_t dx, Float_t dy, Float_t dz)
49 : TShape (name, title,material)
50{
51 fDx = dx;
52 fDy = dy;
53 fDz = dz;
54}
55
56////////////////////////////////////////////////////////////////////////////////
57/// BRIK shape default destructor
58
60{
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Compute distance from point px,py to a BRIK
65///
66/// Compute the closest distance of approach from point px,py to each corner
67/// point of the BRIK.
68
70{
71 const Int_t numPoints = 8;
72 return ShapeDistancetoPrimitive(numPoints,px,py);
73}
74
75////////////////////////////////////////////////////////////////////////////////
76/// Create BRIK points
77
79{
80 if (points) {
81 points[ 0] = -fDx ; points[ 1] = -fDy ; points[ 2] = -fDz;
82 points[ 3] = -fDx ; points[ 4] = fDy ; points[ 5] = -fDz;
83 points[ 6] = fDx ; points[ 7] = fDy ; points[ 8] = -fDz;
84 points[ 9] = fDx ; points[10] = -fDy ; points[11] = -fDz;
85 points[12] = -fDx ; points[13] = -fDy ; points[14] = fDz;
86 points[15] = -fDx ; points[16] = fDy ; points[17] = fDz;
87 points[18] = fDx ; points[19] = fDy ; points[20] = fDz;
88 points[21] = fDx ; points[22] = -fDy ; points[23] = fDz;
89 }
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Return total X3D needed by TNode::ls (when called with option "x")
94
95void TBRIK::Sizeof3D() const
96{
97 gSize3D.numPoints += 8;
98 gSize3D.numSegs += 12;
99 gSize3D.numPolys += 6;
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Get buffer 3D
104
105const TBuffer3D & TBRIK::GetBuffer3D(Int_t reqSections) const
106{
107 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
108
109 TShape::FillBuffer3D(buffer, reqSections);
110
111 // No kShapeSpecific or kBoundingBox
112
113 if (reqSections & TBuffer3D::kRawSizes) {
114 Int_t nbPnts = 8;
115 Int_t nbSegs = 12;
116 Int_t nbPols = 6;
117 if (buffer.SetRawSizes(nbPnts, nbPnts*3, nbSegs, nbSegs*3, nbPols, nbPols*6)) {
119 }
120 }
121 if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
122 // Points
123 SetPoints(buffer.fPnts);
124 if (!buffer.fLocalFrame) {
125 TransformPoints(buffer.fPnts, buffer.NbPnts());
126 }
127
129
130 // Segments
131 buffer.fSegs[ 0] = c ; buffer.fSegs[ 1] = 0 ; buffer.fSegs[ 2] = 1 ;
132 buffer.fSegs[ 3] = c+1 ; buffer.fSegs[ 4] = 1 ; buffer.fSegs[ 5] = 2 ;
133 buffer.fSegs[ 6] = c+1 ; buffer.fSegs[ 7] = 2 ; buffer.fSegs[ 8] = 3 ;
134 buffer.fSegs[ 9] = c ; buffer.fSegs[10] = 3 ; buffer.fSegs[11] = 0 ;
135 buffer.fSegs[12] = c+2 ; buffer.fSegs[13] = 4 ; buffer.fSegs[14] = 5 ;
136 buffer.fSegs[15] = c+2 ; buffer.fSegs[16] = 5 ; buffer.fSegs[17] = 6 ;
137 buffer.fSegs[18] = c+3 ; buffer.fSegs[19] = 6 ; buffer.fSegs[20] = 7 ;
138 buffer.fSegs[21] = c+3 ; buffer.fSegs[22] = 7 ; buffer.fSegs[23] = 4 ;
139 buffer.fSegs[24] = c ; buffer.fSegs[25] = 0 ; buffer.fSegs[26] = 4 ;
140 buffer.fSegs[27] = c+2 ; buffer.fSegs[28] = 1 ; buffer.fSegs[29] = 5 ;
141 buffer.fSegs[30] = c+1 ; buffer.fSegs[31] = 2 ; buffer.fSegs[32] = 6 ;
142 buffer.fSegs[33] = c+3 ; buffer.fSegs[34] = 3 ; buffer.fSegs[35] = 7 ;
143
144 // Polygons
145 buffer.fPols[ 0] = c ; buffer.fPols[ 1] = 4 ; buffer.fPols[ 2] = 0 ;
146 buffer.fPols[ 3] = 9 ; buffer.fPols[ 4] = 4 ; buffer.fPols[ 5] = 8 ;
147 buffer.fPols[ 6] = c+1 ; buffer.fPols[ 7] = 4 ; buffer.fPols[ 8] = 1 ;
148 buffer.fPols[ 9] = 10 ; buffer.fPols[10] = 5 ; buffer.fPols[11] = 9 ;
149 buffer.fPols[12] = c ; buffer.fPols[13] = 4 ; buffer.fPols[14] = 2 ;
150 buffer.fPols[15] = 11 ; buffer.fPols[16] = 6 ; buffer.fPols[17] = 10 ;
151 buffer.fPols[18] = c+1 ; buffer.fPols[19] = 4 ; buffer.fPols[20] = 3 ;
152 buffer.fPols[21] = 8 ; buffer.fPols[22] = 7 ; buffer.fPols[23] = 11 ;
153 buffer.fPols[24] = c+2 ; buffer.fPols[25] = 4 ; buffer.fPols[26] = 0 ;
154 buffer.fPols[27] = 3 ; buffer.fPols[28] = 2 ; buffer.fPols[29] = 1 ;
155 buffer.fPols[30] = c+3 ; buffer.fPols[31] = 4 ; buffer.fPols[32] = 4 ;
156 buffer.fPols[33] = 5 ; buffer.fPols[34] = 6 ; buffer.fPols[35] = 7 ;
157
159 }
160 return buffer;
161}
#define c(i)
Definition RSha256.hxx:101
float Float_t
Definition RtypesCore.h:57
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
char name[80]
Definition TGX11.cxx:110
#define gSize3D
Definition X3DBuffer.h:40
A box with faces perpendicular to the axes.
Definition TBRIK.h:26
Float_t fDz
Definition TBRIK.h:31
const TBuffer3D & GetBuffer3D(Int_t reqSections) const override
Get buffer 3D.
Definition TBRIK.cxx:105
void SetPoints(Double_t *points) const override
Create BRIK points.
Definition TBRIK.cxx:78
Float_t fDy
Definition TBRIK.h:30
~TBRIK() override
BRIK shape default destructor.
Definition TBRIK.cxx:59
Float_t fDx
Definition TBRIK.h:29
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a BRIK.
Definition TBRIK.cxx:69
TBRIK()
BRIK shape default constructor.
Definition TBRIK.cxx:38
void Sizeof3D() const override
Return total X3D needed by TNode::ls (when called with option "x")
Definition TBRIK.cxx:95
Generic 3D primitive description class.
Definition TBuffer3D.h:18
Int_t * fPols
Definition TBuffer3D.h:115
UInt_t NbPnts() const
Definition TBuffer3D.h:80
Bool_t SectionsValid(UInt_t mask) const
Definition TBuffer3D.h:67
void SetSectionsValid(UInt_t mask)
Definition TBuffer3D.h:65
Int_t * fSegs
Definition TBuffer3D.h:114
Bool_t fLocalFrame
Definition TBuffer3D.h:90
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.
Double_t * fPnts
Definition TBuffer3D.h:113
This is the base class for all geometry shapes.
Definition TShape.h:35
Int_t GetBasicColor() const
Get basic color.
Definition TShape.cxx:241
Int_t ShapeDistancetoPrimitive(Int_t numPoints, Int_t px, Int_t py)
Distance to primitive.
Definition TShape.cxx:117
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.
Definition TShape.cxx:211
void TransformPoints(Double_t *points, UInt_t NbPnts) const
Transform points (LocalToMaster)
Definition TShape.cxx:190