]> git.uio.no Git - u/mrichter/AliRoot.git/blame - GEODB/AliGTRD1.cxx
New&delete used for array with variable size
[u/mrichter/AliRoot.git] / GEODB / AliGTRD1.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
18*/
19
ab2f6604 20// -*- C++ -*-
21//
22// 1998/10/19
23// ---------------------------------------------------------------------------
24//
25// AliGTRD1 Class
26//
27// This file is part of the ALICE Geometry Database .
28//
29// Author: Joana E. Santo & company...
30//
31// ---------------------------------------------------------------------------
32
33#include <TView.h>
34#include <TCanvas.h>
35#include <TVirtualPad.h>
36#include <iostream.h>
37#include <TGLKernelABC.h>
38#include "AliGTRD1.h"
39#include <TROOT.h>
40
41ClassImp(AliGTRD1)
42
43//-------------------------------------------------------------------------
44
45AliGTRD1::AliGTRD1(Text_t *name, Text_t *title, Float_t dx1, Float_t dx2, Float_t dy, Float_t dz) : AliGShape(name, title)
46{
47//*-*-*-*-*-*-*-*-*-*-*-*-*AliGTRD1 shape normal constructor*-*-*-*-*-*-*-*-*-*-*-*-*
48//*-* =============================
49
50 fDx2 = dx2;
51 fDx1 = dx1;
52 fDy = dy;
53 fDz = dz;
54}
55
56//-------------------------------------------------------------------------
57
58AliGTRD1::AliGTRD1()
59{
60 /* Default Constructor */
61
62 fDx2 = 0;
63 fName = "";
64 fTitle = "";
65}
66
67//-------------------------------------------------------------------------
68
69AliGTRD1::AliGTRD1( AliGTRD1* trd1 )
70{
71 /* Copy Constructor */
72 fColor = trd1->fColor;
73 fDx1 = trd1->fDx1;
74 fDx2 = trd1->fDx2;
75 fDy = trd1->fDy;
76 fDz = trd1->fDz;
77 fName = trd1->fName;
78 fTitle = trd1->fTitle;
79}
80
81//----------------------------------------------------------------------------
82
83void AliGTRD1::SetPoints(Float_t *buff)
84{
85//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*Create AliGTRD1 points*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
86//*-* ==================
87
88 Float_t dx1, dx2, dy, dz;
89
90 dx1 = fDx1;
91 dx2 = fDx2;
92 dy = fDy;
93 dz = fDz;
94
95 if (buff) {
96 buff[ 0] = -dx1; buff[ 1] = -dy; buff[ 2] = -dz;
97 buff[ 3] = dx1; buff[ 4] = -dy; buff[ 5] = -dz;
98 buff[ 6] = dx1; buff[ 7] = dy; buff[ 8] = -dz;
99 buff[ 9] = -dx1; buff[10] = dy; buff[11] = -dz;
100 buff[12] = -dx2; buff[13] = -dy; buff[14] = dz;
101 buff[15] = dx2; buff[16] = -dy; buff[17] = dz;
102 buff[18] = dx2; buff[19] = dy; buff[20] = dz;
103 buff[21] = -dx2; buff[22] = dy; buff[23] = dz;
104 }
105}
106
107//-------------------------------------------------------------------------
108
109void AliGTRD1::Paint(Option_t *option)
110{
111 SetLineColor( GetCol() );
112
113 const Int_t numpoints = 8;
114
115 //*-* Allocate memory for points *-*
116
117 Float_t *points = new Float_t[3*numpoints];
118 if (!points) return;
119
120 SetPoints(points);
121
122 if (gPad->GetView3D()) PaintGLPoints(points);
123
124 //== for (Int_t i = 0; i < numpoints; i++)
125 // gNode->Local2Master(&points[3*i],&points[3*i]);
126
127 Int_t c = ((GetLineColor() % 8) - 1) * 4; // Basic colors: 0, 1, ... 7
128 if (c < 0) c = 0;
129
130 //*-* Allocate memory for segments *-*
131
132 X3DBuffer *buff = new X3DBuffer;
133 if (buff) {
134 buff->numPoints = 8;
135 buff->numSegs = 12;
136 buff->numPolys = 6;
137 }
138
139//*-* Allocate memory for points *-*
140
141 buff->points = points;
142 buff->segs = new Int_t[buff->numSegs*3];
143
144 if (buff->segs) {
145 buff->segs[ 0] = c; buff->segs[ 1] = 0; buff->segs[ 2] = 1;
146 buff->segs[ 3] = c+1; buff->segs[ 4] = 1; buff->segs[ 5] = 2;
147 buff->segs[ 6] = c+1; buff->segs[ 7] = 2; buff->segs[ 8] = 3;
148 buff->segs[ 9] = c; buff->segs[10] = 3; buff->segs[11] = 0;
149 buff->segs[12] = c+2; buff->segs[13] = 4; buff->segs[14] = 5;
150 buff->segs[15] = c+2; buff->segs[16] = 5; buff->segs[17] = 6;
151 buff->segs[18] = c+3; buff->segs[19] = 6; buff->segs[20] = 7;
152 buff->segs[21] = c+3; buff->segs[22] = 7; buff->segs[23] = 4;
153 buff->segs[24] = c; buff->segs[25] = 0; buff->segs[26] = 4;
154 buff->segs[27] = c+2; buff->segs[28] = 1; buff->segs[29] = 5;
155 buff->segs[30] = c+1; buff->segs[31] = 2; buff->segs[32] = 6;
156 buff->segs[33] = c+3; buff->segs[34] = 3; buff->segs[35] = 7;
157 }
158
159//*-* Allocate memory for polygons *-*
160
161 buff->polys = new Int_t[buff->numPolys*6];
162
163 if (buff->polys) {
164 buff->polys[ 0] = c; buff->polys[ 1] = 4; buff->polys[ 2] = 0;
165 buff->polys[ 3] = 9; buff->polys[ 4] = 4; buff->polys[ 5] = 8;
166 buff->polys[ 6] = c+1; buff->polys[ 7] = 4; buff->polys[ 8] = 1;
167 buff->polys[ 9] = 10; buff->polys[10] = 5; buff->polys[11] = 9;
168 buff->polys[12] = c; buff->polys[13] = 4; buff->polys[14] = 2;
169 buff->polys[15] = 11; buff->polys[16] = 6; buff->polys[17] = 10;
170 buff->polys[18] = c+1; buff->polys[19] = 4; buff->polys[20] = 3;
171 buff->polys[21] = 8; buff->polys[22] = 7; buff->polys[23] = 11;
172 buff->polys[24] = c+2; buff->polys[25] = 4; buff->polys[26] = 0;
173 buff->polys[27] = 3; buff->polys[28] = 2; buff->polys[29] = 1;
174 buff->polys[30] = c+3; buff->polys[31] = 4; buff->polys[32] = 4;
175 buff->polys[33] = 5; buff->polys[34] = 6; buff->polys[35] = 7;
176 }
177
178 //*-* Paint in the pad
179 Bool_t rangeView = strcmp(option,"range")==0 ? kTRUE : kFALSE;
180 PaintShape(buff,rangeView);
181
182 if (strstr(option, "x3d")) {
183 if(buff && buff->points && buff->segs)
184 FillX3DBuffer(buff);
185 else {
186 gSize3D.numPoints -= buff->numPoints;
187 gSize3D.numSegs -= buff->numSegs;
188 gSize3D.numPolys -= buff->numPolys;
189 }
190 }
191
192 delete [] points;
193 if (buff->segs) delete [] buff->segs;
194 if (buff->polys) delete [] buff->polys;
195 if (buff) delete buff;
196}
197