56 TTUBS::TTUBS(
const char *name,
const char *title,
const char *material, Float_t rmin,
57 Float_t rmax, Float_t dz, Float_t phi1, Float_t phi2)
58 : TTUBE(name,title,material,rmin,rmax,dz)
68 TTUBS::TTUBS(
const char *name,
const char *title,
const char *material, Float_t rmax, Float_t dz,
69 Float_t phi1, Float_t phi2)
70 : TTUBE(name,title,material,rmax,dz)
80 void TTUBS::MakeTableOfCoSin()
const
82 const Double_t pi = TMath::ATan(1) * 4.0;
83 const Double_t ragrad = pi/180.0;
86 Int_t n = GetNumberOfDivisions () + 1;
88 if (fCoTab)
delete [] fCoTab;
89 fCoTab =
new Double_t [n];
92 if (fSiTab)
delete [] fSiTab;
93 fSiTab =
new Double_t [n];
96 Double_t phi1 = Double_t(fPhi1 * ragrad);
97 Double_t phi2 = Double_t(fPhi2 * ragrad);
99 if (phi1 > phi2 ) phi2 += 2*pi;
101 Double_t range = phi2- phi1;
103 Double_t angstep = range/(n-1);
106 for (j = 0; j < n; j++) {
107 ph = phi1 + j*angstep;
108 fCoTab[j] = TMath::Cos(ph);
109 fSiTab[j] = TMath::Sin(ph);
126 Int_t TTUBS::DistancetoPrimitive(Int_t px, Int_t py)
128 Int_t n = GetNumberOfDivisions()+1;
129 Int_t numPoints = n*4;
130 return ShapeDistancetoPrimitive(numPoints,px,py);
136 void TTUBS::SetPoints(Double_t *points)
const
140 Float_t dz = TTUBE::fDz;
142 n = GetNumberOfDivisions()+1;
145 if (!fCoTab) MakeTableOfCoSin();
146 for (j = 0; j < n; j++) {
147 points[indx+6*n] = points[indx] = fRmin * fCoTab[j];
149 points[indx+6*n] = points[indx] = fAspectRatio*fRmin * fSiTab[j];
151 points[indx+6*n] = dz;
155 for (j = 0; j < n; j++) {
156 points[indx+6*n] = points[indx] = fRmax * fCoTab[j];
158 points[indx+6*n] = points[indx] = fAspectRatio*fRmax * fSiTab[j];
160 points[indx+6*n]= dz;
170 void TTUBS::Sizeof3D()
const
172 Int_t n = GetNumberOfDivisions()+1;
174 gSize3D.numPoints += n*4;
175 gSize3D.numSegs += n*8;
176 gSize3D.numPolys += n*4-2;
182 const TBuffer3D & TTUBS::GetBuffer3D(Int_t reqSections)
const
184 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
186 TShape::FillBuffer3D(buffer, reqSections);
196 if (reqSections & TBuffer3D::kRawSizes) {
197 const Int_t n = GetNumberOfDivisions()+1;
199 Int_t nbSegs = 2*nbPnts;
200 Int_t nbPols = nbPnts-2;
202 if (buffer.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
203 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
206 if (reqSections & TBuffer3D::kRaw) {
208 SetPoints(buffer.fPnts);
209 if (!buffer.fLocalFrame) {
210 TransformPoints(buffer.fPnts, buffer.NbPnts());
213 const Int_t n = GetNumberOfDivisions()+1;
215 Int_t c = GetBasicColor();
218 memset(buffer.fSegs, 0, buffer.NbSegs()*3*
sizeof(Int_t));
219 for (i = 0; i < 4; i++) {
220 for (j = 1; j < n; j++) {
221 buffer.fSegs[(i*n+j-1)*3 ] = c;
222 buffer.fSegs[(i*n+j-1)*3+1] = i*n+j-1;
223 buffer.fSegs[(i*n+j-1)*3+2] = i*n+j;
226 for (i = 4; i < 6; i++) {
227 for (j = 0; j < n; j++) {
228 buffer.fSegs[(i*n+j)*3 ] = c+1;
229 buffer.fSegs[(i*n+j)*3+1] = (i-4)*n+j;
230 buffer.fSegs[(i*n+j)*3+2] = (i-2)*n+j;
233 for (i = 6; i < 8; i++) {
234 for (j = 0; j < n; j++) {
235 buffer.fSegs[(i*n+j)*3 ] = c;
236 buffer.fSegs[(i*n+j)*3+1] = 2*(i-6)*n+j;
237 buffer.fSegs[(i*n+j)*3+2] = (2*(i-6)+1)*n+j;
243 memset(buffer.fPols, 0, buffer.NbPols()*6*
sizeof(Int_t));
245 for (j = 0; j < n-1; j++) {
246 buffer.fPols[indx++] = c;
247 buffer.fPols[indx++] = 4;
248 buffer.fPols[indx++] = (4+i)*n+j+1;
249 buffer.fPols[indx++] = (2+i)*n+j;
250 buffer.fPols[indx++] = (4+i)*n+j;
251 buffer.fPols[indx++] = i*n+j;
254 for (j = 0; j < n-1; j++) {
255 buffer.fPols[indx++] = c;
256 buffer.fPols[indx++] = 4;
257 buffer.fPols[indx++] = i*n+j;
258 buffer.fPols[indx++] = (4+i)*n+j;
259 buffer.fPols[indx++] = (2+i)*n+j;
260 buffer.fPols[indx++] = (4+i)*n+j+1;
263 for (j = 0; j < n-1; j++) {
264 buffer.fPols[indx++] = c+i;
265 buffer.fPols[indx++] = 4;
266 buffer.fPols[indx++] = (i-2)*2*n+j;
267 buffer.fPols[indx++] = (4+i)*n+j;
268 buffer.fPols[indx++] = ((i-2)*2+1)*n+j;
269 buffer.fPols[indx++] = (4+i)*n+j+1;
272 for (j = 0; j < n-1; j++) {
273 buffer.fPols[indx++] = c+i;
274 buffer.fPols[indx++] = 4;
275 buffer.fPols[indx++] = (4+i)*n+j+1;
276 buffer.fPols[indx++] = ((i-2)*2+1)*n+j;
277 buffer.fPols[indx++] = (4+i)*n+j;
278 buffer.fPols[indx++] = (i-2)*2*n+j;
280 buffer.fPols[indx++] = c+2;
281 buffer.fPols[indx++] = 4;
282 buffer.fPols[indx++] = 6*n;
283 buffer.fPols[indx++] = 4*n;
284 buffer.fPols[indx++] = 7*n;
285 buffer.fPols[indx++] = 5*n;
286 buffer.fPols[indx++] = c+2;
287 buffer.fPols[indx++] = 4;
288 buffer.fPols[indx++] = 6*n-1;
289 buffer.fPols[indx++] = 8*n-1;
290 buffer.fPols[indx++] = 5*n-1;
291 buffer.fPols[indx++] = 7*n-1;
293 buffer.SetSectionsValid(TBuffer3D::kRaw);