57 TTUBE::TTUBE(
const char *name,
const char *title,
const char *material, Float_t rmin, Float_t rmax, Float_t dz,Float_t aspect)
58 : TShape(name, title,material)
69 fAspectRatio = aspect;
77 TTUBE::TTUBE(
const char *name,
const char *title,
const char *material, Float_t rmax, Float_t dz)
78 : TShape(name, title,material)
97 TTUBE::TTUBE(
const TTUBE& tu) :
103 fAspectRatio(tu.fAspectRatio),
112 TTUBE& TTUBE::operator=(
const TTUBE& tu)
115 TShape::operator=(tu);
120 fAspectRatio=tu.fAspectRatio;
130 void TTUBE::MakeTableOfCoSin() const
132 const Double_t pi = TMath::ATan(1) * 4.0;
135 Int_t n = GetNumberOfDivisions ();
136 if (fCoTab)
delete [] fCoTab;
137 fCoTab =
new Double_t [n];
139 Error(
"MakeTableOfCoSin()",
"No cos table done");
143 if (fSiTab)
delete [] fSiTab;
144 fSiTab =
new Double_t [n];
146 Error(
"MakeTableOfCoSin()",
"No sin table done");
150 Double_t range = 2*pi;
152 Double_t angstep = range/n;
155 for (j = 0; j < n; j++) {
157 fCoTab[j] = TMath::Cos(ph);
158 fSiTab[j] = TMath::Sin(ph);
177 Int_t TTUBE::DistancetoPrimitive(Int_t px, Int_t py)
179 Int_t n = GetNumberOfDivisions();
180 Int_t numPoints = n*4;
181 return ShapeDistancetoPrimitive(numPoints,px,py);
187 void TTUBE::SetNumberOfDivisions (Int_t ndiv)
196 void TTUBE::SetPoints(Double_t *points)
const
201 n = GetNumberOfDivisions();
204 if (!fCoTab) MakeTableOfCoSin();
205 for (j = 0; j < n; j++) {
206 points[indx+6*n] = points[indx] = fRmin * fCoTab[j];
208 points[indx+6*n] = points[indx] = fAspectRatio*fRmin * fSiTab[j];
210 points[indx+6*n] = fDz;
214 for (j = 0; j < n; j++) {
215 points[indx+6*n] = points[indx] = fRmax * fCoTab[j];
217 points[indx+6*n] = points[indx] = fAspectRatio*fRmax * fSiTab[j];
219 points[indx+6*n]= fDz;
229 void TTUBE::SetSegsAndPols(TBuffer3D & buffer)
const
232 Int_t n = GetNumberOfDivisions();
233 Int_t c = GetBasicColor();
235 for (i = 0; i < 4; i++) {
236 for (j = 0; j < n; j++) {
237 buffer.fSegs[(i*n+j)*3 ] = c;
238 buffer.fSegs[(i*n+j)*3+1] = i*n+j;
239 buffer.fSegs[(i*n+j)*3+2] = i*n+j+1;
241 buffer.fSegs[(i*n+j-1)*3+2] = i*n;
243 for (i = 4; i < 6; i++) {
244 for (j = 0; j < n; j++) {
245 buffer.fSegs[(i*n+j)*3 ] = c+1;
246 buffer.fSegs[(i*n+j)*3+1] = (i-4)*n+j;
247 buffer.fSegs[(i*n+j)*3+2] = (i-2)*n+j;
250 for (i = 6; i < 8; i++) {
251 for (j = 0; j < n; j++) {
252 buffer.fSegs[(i*n+j)*3 ] = c;
253 buffer.fSegs[(i*n+j)*3+1] = 2*(i-6)*n+j;
254 buffer.fSegs[(i*n+j)*3+2] = (2*(i-6)+1)*n+j;
260 for (j = 0; j < n; j++) {
262 buffer.fPols[indx ] = c;
263 buffer.fPols[indx+1] = 4;
264 buffer.fPols[indx+5] = i*n+j;
265 buffer.fPols[indx+4] = (4+i)*n+j;
266 buffer.fPols[indx+3] = (2+i)*n+j;
267 buffer.fPols[indx+2] = (4+i)*n+j+1;
269 buffer.fPols[indx+2] = (4+i)*n;
271 for (j = 0; j < n; j++) {
273 buffer.fPols[indx ] = c;
274 buffer.fPols[indx+1] = 4;
275 buffer.fPols[indx+2] = i*n+j;
276 buffer.fPols[indx+3] = (4+i)*n+j;
277 buffer.fPols[indx+4] = (2+i)*n+j;
278 buffer.fPols[indx+5] = (4+i)*n+j+1;
280 buffer.fPols[indx+5] = (4+i)*n;
282 for (j = 0; j < n; j++) {
284 buffer.fPols[indx ] = c+i;
285 buffer.fPols[indx+1] = 4;
286 buffer.fPols[indx+2] = (i-2)*2*n+j;
287 buffer.fPols[indx+3] = (4+i)*n+j;
288 buffer.fPols[indx+4] = ((i-2)*2+1)*n+j;
289 buffer.fPols[indx+5] = (4+i)*n+j+1;
291 buffer.fPols[indx+5] = (4+i)*n;
293 for (j = 0; j < n; j++) {
295 buffer.fPols[indx ] = c+i;
296 buffer.fPols[indx+1] = 4;
297 buffer.fPols[indx+5] = (i-2)*2*n+j;
298 buffer.fPols[indx+4] = (4+i)*n+j;
299 buffer.fPols[indx+3] = ((i-2)*2+1)*n+j;
300 buffer.fPols[indx+2] = (4+i)*n+j+1;
302 buffer.fPols[indx+2] = (4+i)*n;
308 void TTUBE::Sizeof3D()
const
310 Int_t n = GetNumberOfDivisions();
312 gSize3D.numPoints += n*4;
313 gSize3D.numSegs += n*8;
314 gSize3D.numPolys += n*4;
320 void TTUBE::Streamer(TBuffer &R__b)
322 if (R__b.IsReading()) {
324 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
326 R__b.ReadClassBuffer(TTUBE::Class(),
this, R__v, R__s, R__c);
330 TShape::Streamer(R__b);
335 if (R__v > 1) R__b >> fAspectRatio;
336 R__b.CheckByteCount(R__s, R__c, TTUBE::IsA());
339 R__b.WriteClassBuffer(TTUBE::Class(),
this);
346 const TBuffer3D & TTUBE::GetBuffer3D(Int_t reqSections)
const
348 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
350 TShape::FillBuffer3D(buffer, reqSections);
359 if (reqSections & TBuffer3D::kRawSizes) {
360 Int_t n = GetNumberOfDivisions();
364 if (buffer.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
365 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
368 if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
369 SetPoints(buffer.fPnts);
370 if (!buffer.fLocalFrame) {
371 TransformPoints(buffer.fPnts, buffer.NbPnts());
373 SetSegsAndPols(buffer);
374 buffer.SetSectionsValid(TBuffer3D::kRaw);