138 SetShapeBit(TGeoShape::kGeoBox);
140 fOrigin[0] = fOrigin[1] = fOrigin[2] = 0.0;
146 TGeoBBox::TGeoBBox(Double_t dx, Double_t dy, Double_t dz, Double_t *origin)
149 SetShapeBit(TGeoShape::kGeoBox);
150 fOrigin[0] = fOrigin[1] = fOrigin[2] = 0.0;
151 SetBoxDimensions(dx, dy, dz, origin);
157 TGeoBBox::TGeoBBox(
const char *name, Double_t dx, Double_t dy, Double_t dz, Double_t *origin)
160 SetShapeBit(TGeoShape::kGeoBox);
161 fOrigin[0] = fOrigin[1] = fOrigin[2] = 0.0;
162 SetBoxDimensions(dx, dy, dz, origin);
171 TGeoBBox::TGeoBBox(Double_t *param)
174 SetShapeBit(TGeoShape::kGeoBox);
175 fOrigin[0] = fOrigin[1] = fOrigin[2] = 0.0;
176 SetDimensions(param);
182 TGeoBBox::~TGeoBBox()
189 Bool_t TGeoBBox::AreOverlapping(
const TGeoBBox *box1,
const TGeoMatrix *mat1,
const TGeoBBox *box2,
const TGeoMatrix *mat2)
193 Double_t ldir1[3], ldir2[3];
194 const Double_t *o1 = box1->GetOrigin();
195 const Double_t *o2 = box2->GetOrigin();
197 mat1->LocalToMaster(o1, master);
198 mat2->MasterToLocal(master, local);
199 if (TGeoBBox::Contains(local,box2->GetDX(),box2->GetDY(),box2->GetDZ(),o2))
return kTRUE;
200 Double_t distsq = (local[0]-o2[0])*(local[0]-o2[0]) +
201 (local[1]-o2[1])*(local[1]-o2[1]) +
202 (local[2]-o2[2])*(local[2]-o2[2]);
204 Double_t rmaxsq = (box1->GetDX()+box2->GetDX())*(box1->GetDX()+box2->GetDX()) +
205 (box1->GetDY()+box2->GetDY())*(box1->GetDY()+box2->GetDY()) +
206 (box1->GetDZ()+box2->GetDZ())*(box1->GetDZ()+box2->GetDZ());
207 if (distsq > rmaxsq + TGeoShape::Tolerance())
return kFALSE;
211 mat1->LocalToMaster(o1, ldir1);
212 mat2->LocalToMaster(o2, ldir2);
213 distsq = 1./TMath::Sqrt(distsq);
214 dir[0] = (ldir2[0]-ldir1[0])*distsq;
215 dir[1] = (ldir2[1]-ldir1[1])*distsq;
216 dir[2] = (ldir2[2]-ldir1[2])*distsq;
217 mat1->MasterToLocalVect(dir, ldir1);
218 mat2->MasterToLocalVect(dir, ldir2);
220 Double_t dist1 = TGeoBBox::DistFromInside(o1,ldir1,box1->GetDX(),box1->GetDY(),box1->GetDZ(),o1);
222 Double_t dist2 = TGeoBBox::DistFromOutside(local,ldir2,box2->GetDX(),box2->GetDY(),box2->GetDZ(),o2);
223 if (dist1 > dist2)
return kTRUE;
230 Double_t TGeoBBox::Capacity()
const
232 return (8.*fDX*fDY*fDZ);
238 void TGeoBBox::ComputeNormal(
const Double_t *point,
const Double_t *dir, Double_t *norm)
240 memset(norm,0,3*
sizeof(Double_t));
243 saf[0]=TMath::Abs(TMath::Abs(point[0]-fOrigin[0])-fDX);
244 saf[1]=TMath::Abs(TMath::Abs(point[1]-fOrigin[1])-fDY);
245 saf[2]=TMath::Abs(TMath::Abs(point[2]-fOrigin[2])-fDZ);
246 i = TMath::LocMin(3,saf);
247 norm[i] = (dir[i]>0)?1:(-1);
253 Bool_t TGeoBBox::CouldBeCrossed(
const Double_t *point,
const Double_t *dir)
const
256 if (fDY<mind) mind=fDY;
257 if (fDZ<mind) mind=fDZ;
258 Double_t dx = fOrigin[0]-point[0];
259 Double_t dy = fOrigin[1]-point[1];
260 Double_t dz = fOrigin[2]-point[2];
261 Double_t do2 = dx*dx+dy*dy+dz*dz;
262 if (do2<=(mind*mind))
return kTRUE;
263 Double_t rmax2 = fDX*fDX+fDY*fDY+fDZ*fDZ;
264 if (do2<=rmax2)
return kTRUE;
266 Double_t doct = dx*dir[0]+dy*dir[1]+dz*dir[2];
268 if (doct<=0)
return kFALSE;
269 Double_t dirnorm=dir[0]*dir[0]+dir[1]*dir[1]+dir[2]*dir[2];
270 if ((doct*doct)>=(do2-rmax2)*dirnorm)
return kTRUE;
277 Int_t TGeoBBox::DistancetoPrimitive(Int_t px, Int_t py)
279 const Int_t numPoints = 8;
280 return ShapeDistancetoPrimitive(numPoints, px, py);
289 TGeoVolume *TGeoBBox::Divide(TGeoVolume *voldiv,
const char *divname, Int_t iaxis, Int_t ndiv,
290 Double_t start, Double_t step)
294 TGeoVolumeMulti *vmulti;
295 TGeoPatternFinder *finder;
297 Double_t end = start+ndiv*step;
300 shape =
new TGeoBBox(step/2., fDY, fDZ);
301 finder =
new TGeoPatternX(voldiv, ndiv, start, end);
305 shape =
new TGeoBBox(fDX, step/2., fDZ);
306 finder =
new TGeoPatternY(voldiv, ndiv, start, end);
310 shape =
new TGeoBBox(fDX, fDY, step/2.);
311 finder =
new TGeoPatternZ(voldiv, ndiv, start, end);
315 Error(
"Divide",
"Wrong axis type for division");
318 vol =
new TGeoVolume(divname, shape, voldiv->GetMedium());
319 vmulti = gGeoManager->MakeVolumeMulti(divname, voldiv->GetMedium());
320 vmulti->AddVolume(vol);
321 voldiv->SetFinder(finder);
322 finder->SetDivIndex(voldiv->GetNdaughters());
323 for (Int_t ic=0; ic<ndiv; ic++) {
324 voldiv->AddNodeOffset(vol, ic, start+step/2.+ic*step, opt.Data());
325 ((TGeoNodeOffset*)voldiv->GetNodes()->At(voldiv->GetNdaughters()-1))->SetFinder(finder);
333 void TGeoBBox::ComputeBBox()
340 Bool_t TGeoBBox::Contains(
const Double_t *point)
const
342 if (TMath::Abs(point[2]-fOrigin[2]) > fDZ)
return kFALSE;
343 if (TMath::Abs(point[0]-fOrigin[0]) > fDX)
return kFALSE;
344 if (TMath::Abs(point[1]-fOrigin[1]) > fDY)
return kFALSE;
352 Bool_t TGeoBBox::Contains(
const Double_t *point, Double_t dx, Double_t dy, Double_t dz,
const Double_t *origin)
354 if (TMath::Abs(point[2]-origin[2]) > dz)
return kFALSE;
355 if (TMath::Abs(point[0]-origin[0]) > dx)
return kFALSE;
356 if (TMath::Abs(point[1]-origin[1]) > dy)
return kFALSE;
364 Double_t TGeoBBox::DistFromInside(
const Double_t *point,
const Double_t *dir, Int_t iact, Double_t step, Double_t *safe)
const
366 Double_t s,smin,saf[6];
369 for (i=0; i<3; i++) newpt[i] = point[i] - fOrigin[i];
370 saf[0] = fDX+newpt[0];
371 saf[1] = fDX-newpt[0];
372 saf[2] = fDY+newpt[1];
373 saf[3] = fDY-newpt[1];
374 saf[4] = fDZ+newpt[2];
375 saf[5] = fDZ-newpt[2];
376 if (iact<3 && safe) {
379 for (i=1;i<6;i++)
if (saf[i] < smin) smin = saf[i];
381 if (smin<0) *safe = 0.0;
382 if (iact==0)
return TGeoShape::Big();
383 if (iact==1 && step<*safe)
return TGeoShape::Big();
386 smin=TGeoShape::Big();
387 for (i=0; i<3; i++) {
389 s = (dir[i]>0)?(saf[(i<<1)+1]/dir[i]):(-saf[i<<1]/dir[i]);
390 if (s < 0)
return 0.0;
391 if (s < smin) smin = s;
401 Double_t TGeoBBox::DistFromInside(
const Double_t *point,
const Double_t *dir,
402 Double_t dx, Double_t dy, Double_t dz,
const Double_t *origin, Double_t )
404 Double_t s,smin,saf[6];
407 for (i=0; i<3; i++) newpt[i] = point[i] - origin[i];
408 saf[0] = dx+newpt[0];
409 saf[1] = dx-newpt[0];
410 saf[2] = dy+newpt[1];
411 saf[3] = dy-newpt[1];
412 saf[4] = dz+newpt[2];
413 saf[5] = dz-newpt[2];
415 smin=TGeoShape::Big();
416 for (i=0; i<3; i++) {
418 s = (dir[i]>0)?(saf[(i<<1)+1]/dir[i]):(-saf[i<<1]/dir[i]);
419 if (s < 0)
return 0.0;
420 if (s < smin) smin = s;
430 Double_t TGeoBBox::DistFromOutside(
const Double_t *point,
const Double_t *dir, Int_t iact, Double_t step, Double_t *safe)
const
437 for (i=0; i<3; i++) newpt[i] = point[i] - fOrigin[i];
441 for (i=0; i<3; i++) {
442 saf[i] = TMath::Abs(newpt[i])-par[i];
443 if (saf[i]>=step)
return TGeoShape::Big();
444 if (in && saf[i]>0) in=kFALSE;
446 if (iact<3 && safe) {
452 if (saf[1] > *safe) *safe = saf[1];
453 if (saf[2] > *safe) *safe = saf[2];
455 if (iact==0)
return TGeoShape::Big();
456 if (iact==1 && step<*safe)
return TGeoShape::Big();
459 Double_t coord, snxt=TGeoShape::Big();
464 Double_t ss = saf[0];
469 if (saf[2]>ss) j = 2;
470 if (newpt[j]*dir[j]>0)
return TGeoShape::Big();
473 for (i=0; i<3; i++) {
474 if (saf[i]<0)
continue;
475 if (newpt[i]*dir[i] >= 0)
continue;
476 snxt = saf[i]/TMath::Abs(dir[i]);
478 for (j=0; j<3; j++) {
480 coord=newpt[j]+snxt*dir[j];
481 if (TMath::Abs(coord)>par[j]) {
486 if (!ibreak)
return snxt;
488 return TGeoShape::Big();
495 Double_t TGeoBBox::DistFromOutside(
const Double_t *point,
const Double_t *dir,
496 Double_t dx, Double_t dy, Double_t dz,
const Double_t *origin, Double_t stepmax)
503 for (i=0; i<3; i++) newpt[i] = point[i] - origin[i];
507 for (i=0; i<3; i++) {
508 saf[i] = TMath::Abs(newpt[i])-par[i];
509 if (saf[i]>=stepmax)
return TGeoShape::Big();
510 if (in && saf[i]>0) in=kFALSE;
514 Double_t coord, snxt=TGeoShape::Big();
516 for (i=0; i<3; i++) {
517 if (saf[i]<0)
continue;
518 if (newpt[i]*dir[i] >= 0)
continue;
519 snxt = saf[i]/TMath::Abs(dir[i]);
521 for (j=0; j<3; j++) {
523 coord=newpt[j]+snxt*dir[j];
524 if (TMath::Abs(coord)>par[j]) {
529 if (!ibreak)
return snxt;
531 return TGeoShape::Big();
537 const char *TGeoBBox::GetAxisName(Int_t iaxis)
const
554 Double_t TGeoBBox::GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi)
const
561 xlo = fOrigin[0]-fDX;
562 xhi = fOrigin[0]+fDX;
566 xlo = fOrigin[1]-fDY;
567 xhi = fOrigin[1]+fDY;
571 xlo = fOrigin[2]-fDZ;
572 xhi = fOrigin[2]+fDZ;
583 void TGeoBBox::GetBoundingCylinder(Double_t *param)
const
586 param[1] = fDX*fDX+fDY*fDY;
597 Double_t TGeoBBox::GetFacetArea(Int_t index)
const
602 area = 8.*(fDX*fDY + fDX*fDZ + fDY*fDZ);
628 Bool_t TGeoBBox::GetPointsOnFacet(Int_t index, Int_t npoints, Double_t *array)
const
630 if (index<0 || index>6)
return kFALSE;
634 for (Int_t isurf=0; isurf<6; isurf++) {
635 surf[isurf] = TGeoBBox::GetFacetArea(isurf+1);
636 if (isurf>0) surf[isurf] += surf[isurf-1];
641 for (Int_t i=0; i<npoints; i++) {
643 Double_t *point = &array[3*i];
644 Int_t surfindex = index;
646 Double_t val = area*gRandom->Rndm();
647 surfindex = 2+TMath::BinarySearch(6, surf, val);
648 if (surfindex>6) surfindex=6;
652 point[0] = -fDX + 2*fDX*gRandom->Rndm();
653 point[1] = -fDY + 2*fDY*gRandom->Rndm();
657 point[0] = -fDX + 2*fDX*gRandom->Rndm();
659 point[2] = -fDZ + 2*fDZ*gRandom->Rndm();
663 point[1] = -fDY + 2*fDY*gRandom->Rndm();
664 point[2] = -fDZ + 2*fDZ*gRandom->Rndm();
667 point[0] = -fDX + 2*fDX*gRandom->Rndm();
669 point[2] = -fDZ + 2*fDZ*gRandom->Rndm();
673 point[1] = -fDY + 2*fDY*gRandom->Rndm();
674 point[2] = -fDZ + 2*fDZ*gRandom->Rndm();
677 point[0] = -fDX + 2*fDX*gRandom->Rndm();
678 point[1] = -fDY + 2*fDY*gRandom->Rndm();
691 Bool_t TGeoBBox::GetPointsOnSegments(Int_t npoints, Double_t *array)
const
693 if (npoints<GetNmeshVertices()) {
694 Error(
"GetPointsOnSegments",
"You should require at least %d points", GetNmeshVertices());
697 TBuffer3D &buff = (TBuffer3D &)GetBuffer3D(TBuffer3D::kRawSizes | TBuffer3D::kRaw, kTRUE);
698 Int_t npnts = buff.NbPnts();
699 Int_t nsegs = buff.NbSegs();
701 memcpy(array, buff.fPnts, 3*npnts*
sizeof(Double_t));
702 Int_t ipoints = npoints - npnts;
703 Int_t icrt = 3*npnts;
704 Int_t nperseg = (Int_t)(Double_t(ipoints)/nsegs);
706 Double_t x,y,z, dx,dy,dz;
707 for (Int_t i=0; i<nsegs; i++) {
708 p0 = &array[3*buff.fSegs[3*i+1]];
709 p1 = &array[3*buff.fSegs[3*i+2]];
710 if (i==(nsegs-1)) nperseg = ipoints;
711 dx = (p1[0]-p0[0])/(nperseg+1);
712 dy = (p1[1]-p0[1])/(nperseg+1);
713 dz = (p1[2]-p0[2])/(nperseg+1);
714 for (Int_t j=0; j<nperseg; j++) {
715 x = p0[0] + (j+1)*dx;
716 y = p0[1] + (j+1)*dy;
717 z = p0[2] + (j+1)*dz;
718 array[icrt++] = x; array[icrt++] = y; array[icrt++] = z;
728 Int_t TGeoBBox::GetFittingBox(
const TGeoBBox *parambox, TGeoMatrix *mat, Double_t &dx, Double_t &dy, Double_t &dz)
const
731 if (mat->IsRotation()) {
732 Error(
"GetFittingBox",
"cannot handle parametrized rotated volumes");
737 mat->LocalToMaster(parambox->GetOrigin(), origin);
738 if (!Contains(origin)) {
739 Error(
"GetFittingBox",
"wrong matrix - parametrized box is outside this");
743 Double_t xlo=0, xhi=0;
745 dd[0] = parambox->GetDX();
746 dd[1] = parambox->GetDY();
747 dd[2] = parambox->GetDZ();
748 for (Int_t iaxis=0; iaxis<3; iaxis++) {
749 if (dd[iaxis]>=0)
continue;
750 TGeoBBox::GetAxisRange(iaxis+1, xlo, xhi);
752 dd[iaxis] = TMath::Min(origin[iaxis]-xlo, xhi-origin[iaxis]);
754 Error(
"GetFittingBox",
"wrong matrix");
768 TGeoShape *TGeoBBox::GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat)
const
770 if (!TestShapeBit(kGeoRunTimeShape))
return 0;
772 Int_t ierr = mother->GetFittingBox(
this, mat, dx, dy, dz);
774 Error(
"GetMakeRuntimeShape",
"cannot fit this to mother");
777 return (
new TGeoBBox(dx, dy, dz));
783 void TGeoBBox::GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols)
const
793 void TGeoBBox::InspectShape()
const
795 printf(
"*** Shape %s: TGeoBBox ***\n", GetName());
796 printf(
" dX = %11.5f\n", fDX);
797 printf(
" dY = %11.5f\n", fDY);
798 printf(
" dZ = %11.5f\n", fDZ);
799 printf(
" origin: x=%11.5f y=%11.5f z=%11.5f\n", fOrigin[0], fOrigin[1], fOrigin[2]);
806 TBuffer3D *TGeoBBox::MakeBuffer3D()
const
808 TBuffer3D* buff =
new TBuffer3D(TBuffer3DTypes::kGeneric, 8, 24, 12, 36, 6, 36);
811 SetPoints(buff->fPnts);
812 SetSegsAndPols(*buff);
821 void TGeoBBox::SetSegsAndPols(TBuffer3D &buff)
const
823 Int_t c = GetBasicColor();
825 buff.fSegs[ 0] = c ; buff.fSegs[ 1] = 0 ; buff.fSegs[ 2] = 1 ;
826 buff.fSegs[ 3] = c+1 ; buff.fSegs[ 4] = 1 ; buff.fSegs[ 5] = 2 ;
827 buff.fSegs[ 6] = c+1 ; buff.fSegs[ 7] = 2 ; buff.fSegs[ 8] = 3 ;
828 buff.fSegs[ 9] = c ; buff.fSegs[10] = 3 ; buff.fSegs[11] = 0 ;
829 buff.fSegs[12] = c+2 ; buff.fSegs[13] = 4 ; buff.fSegs[14] = 5 ;
830 buff.fSegs[15] = c+2 ; buff.fSegs[16] = 5 ; buff.fSegs[17] = 6 ;
831 buff.fSegs[18] = c+3 ; buff.fSegs[19] = 6 ; buff.fSegs[20] = 7 ;
832 buff.fSegs[21] = c+3 ; buff.fSegs[22] = 7 ; buff.fSegs[23] = 4 ;
833 buff.fSegs[24] = c ; buff.fSegs[25] = 0 ; buff.fSegs[26] = 4 ;
834 buff.fSegs[27] = c+2 ; buff.fSegs[28] = 1 ; buff.fSegs[29] = 5 ;
835 buff.fSegs[30] = c+1 ; buff.fSegs[31] = 2 ; buff.fSegs[32] = 6 ;
836 buff.fSegs[33] = c+3 ; buff.fSegs[34] = 3 ; buff.fSegs[35] = 7 ;
838 buff.fPols[ 0] = c ; buff.fPols[ 1] = 4 ; buff.fPols[ 2] = 0 ;
839 buff.fPols[ 3] = 9 ; buff.fPols[ 4] = 4 ; buff.fPols[ 5] = 8 ;
840 buff.fPols[ 6] = c+1 ; buff.fPols[ 7] = 4 ; buff.fPols[ 8] = 1 ;
841 buff.fPols[ 9] = 10 ; buff.fPols[10] = 5 ; buff.fPols[11] = 9 ;
842 buff.fPols[12] = c ; buff.fPols[13] = 4 ; buff.fPols[14] = 2 ;
843 buff.fPols[15] = 11 ; buff.fPols[16] = 6 ; buff.fPols[17] = 10 ;
844 buff.fPols[18] = c+1 ; buff.fPols[19] = 4 ; buff.fPols[20] = 3 ;
845 buff.fPols[21] = 8 ; buff.fPols[22] = 7 ; buff.fPols[23] = 11 ;
846 buff.fPols[24] = c+2 ; buff.fPols[25] = 4 ; buff.fPols[26] = 0 ;
847 buff.fPols[27] = 3 ; buff.fPols[28] = 2 ; buff.fPols[29] = 1 ;
848 buff.fPols[30] = c+3 ; buff.fPols[31] = 4 ; buff.fPols[32] = 4 ;
849 buff.fPols[33] = 5 ; buff.fPols[34] = 6 ; buff.fPols[35] = 7 ;
855 Double_t TGeoBBox::Safety(
const Double_t *point, Bool_t in)
const
857 Double_t safe, safy, safz;
859 safe = fDX - TMath::Abs(point[0]-fOrigin[0]);
860 safy = fDY - TMath::Abs(point[1]-fOrigin[1]);
861 safz = fDZ - TMath::Abs(point[2]-fOrigin[2]);
862 if (safy < safe) safe = safy;
863 if (safz < safe) safe = safz;
865 safe = -fDX + TMath::Abs(point[0]-fOrigin[0]);
866 safy = -fDY + TMath::Abs(point[1]-fOrigin[1]);
867 safz = -fDZ + TMath::Abs(point[2]-fOrigin[2]);
868 if (safy > safe) safe = safy;
869 if (safz > safe) safe = safz;
877 void TGeoBBox::SavePrimitive(std::ostream &out, Option_t * )
879 if (TObject::TestBit(kGeoSavePrimitive))
return;
880 out <<
" // Shape: " << GetName() <<
" type: " << ClassName() << std::endl;
881 out <<
" dx = " << fDX <<
";" << std::endl;
882 out <<
" dy = " << fDY <<
";" << std::endl;
883 out <<
" dz = " << fDZ <<
";" << std::endl;
884 if (!TGeoShape::IsSameWithinTolerance(fOrigin[0],0) ||
885 !TGeoShape::IsSameWithinTolerance(fOrigin[1],0) ||
886 !TGeoShape::IsSameWithinTolerance(fOrigin[2],0)) {
887 out <<
" origin[0] = " << fOrigin[0] <<
";" << std::endl;
888 out <<
" origin[1] = " << fOrigin[1] <<
";" << std::endl;
889 out <<
" origin[2] = " << fOrigin[2] <<
";" << std::endl;
890 out <<
" TGeoShape *" << GetPointerName() <<
" = new TGeoBBox(\"" << GetName() <<
"\", dx,dy,dz,origin);" << std::endl;
892 out <<
" TGeoShape *" << GetPointerName() <<
" = new TGeoBBox(\"" << GetName() <<
"\", dx,dy,dz);" << std::endl;
894 TObject::SetBit(TGeoShape::kGeoSavePrimitive);
900 void TGeoBBox::SetBoxDimensions(Double_t dx, Double_t dy, Double_t dz, Double_t *origin)
906 fOrigin[0] = origin[0];
907 fOrigin[1] = origin[1];
908 fOrigin[2] = origin[2];
910 if (TMath::Abs(fDX)<TGeoShape::Tolerance() &&
911 TMath::Abs(fDY)<TGeoShape::Tolerance() &&
912 TMath::Abs(fDZ)<TGeoShape::Tolerance())
return;
913 if ((fDX<0) || (fDY<0) || (fDZ<0)) SetShapeBit(kGeoRunTimeShape);
922 void TGeoBBox::SetDimensions(Double_t *param)
925 Error(
"SetDimensions",
"null parameters");
931 if (TMath::Abs(fDX)<TGeoShape::Tolerance() &&
932 TMath::Abs(fDY)<TGeoShape::Tolerance() &&
933 TMath::Abs(fDZ)<TGeoShape::Tolerance())
return;
934 if ((fDX<0) || (fDY<0) || (fDZ<0)) SetShapeBit(kGeoRunTimeShape);
940 void TGeoBBox::SetBoxPoints(Double_t *points)
const
942 TGeoBBox::SetPoints(points);
948 void TGeoBBox::SetPoints(Double_t *points)
const
951 Double_t xmin,xmax,ymin,ymax,zmin,zmax;
952 xmin = -fDX+fOrigin[0];
953 xmax = fDX+fOrigin[0];
954 ymin = -fDY+fOrigin[1];
955 ymax = fDY+fOrigin[1];
956 zmin = -fDZ+fOrigin[2];
957 zmax = fDZ+fOrigin[2];
958 points[ 0] = xmin; points[ 1] = ymin; points[ 2] = zmin;
959 points[ 3] = xmin; points[ 4] = ymax; points[ 5] = zmin;
960 points[ 6] = xmax; points[ 7] = ymax; points[ 8] = zmin;
961 points[ 9] = xmax; points[10] = ymin; points[11] = zmin;
962 points[12] = xmin; points[13] = ymin; points[14] = zmax;
963 points[15] = xmin; points[16] = ymax; points[17] = zmax;
964 points[18] = xmax; points[19] = ymax; points[20] = zmax;
965 points[21] = xmax; points[22] = ymin; points[23] = zmax;
971 void TGeoBBox::SetPoints(Float_t *points)
const
974 Double_t xmin,xmax,ymin,ymax,zmin,zmax;
975 xmin = -fDX+fOrigin[0];
976 xmax = fDX+fOrigin[0];
977 ymin = -fDY+fOrigin[1];
978 ymax = fDY+fOrigin[1];
979 zmin = -fDZ+fOrigin[2];
980 zmax = fDZ+fOrigin[2];
981 points[ 0] = xmin; points[ 1] = ymin; points[ 2] = zmin;
982 points[ 3] = xmin; points[ 4] = ymax; points[ 5] = zmin;
983 points[ 6] = xmax; points[ 7] = ymax; points[ 8] = zmin;
984 points[ 9] = xmax; points[10] = ymin; points[11] = zmin;
985 points[12] = xmin; points[13] = ymin; points[14] = zmax;
986 points[15] = xmin; points[16] = ymax; points[17] = zmax;
987 points[18] = xmax; points[19] = ymax; points[20] = zmax;
988 points[21] = xmax; points[22] = ymin; points[23] = zmax;
996 void TGeoBBox::Sizeof3D()
const
1003 const TBuffer3D & TGeoBBox::GetBuffer3D(Int_t reqSections, Bool_t localFrame)
const
1005 static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
1007 FillBuffer3D(buffer, reqSections, localFrame);
1011 if (reqSections & TBuffer3D::kRawSizes) {
1012 if (buffer.SetRawSizes(8, 3*8, 12, 3*12, 6, 6*6)) {
1013 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
1016 if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
1017 SetPoints(buffer.fPnts);
1018 if (!buffer.fLocalFrame) {
1019 TransformPoints(buffer.fPnts, buffer.NbPnts());
1022 SetSegsAndPols(buffer);
1023 buffer.SetSectionsValid(TBuffer3D::kRaw);
1033 void TGeoBBox::FillBuffer3D(TBuffer3D & buffer, Int_t reqSections, Bool_t localFrame)
const
1035 TGeoShape::FillBuffer3D(buffer, reqSections, localFrame);
1037 if (reqSections & TBuffer3D::kBoundingBox) {
1038 Double_t halfLengths[3] = { fDX, fDY, fDZ };
1039 buffer.SetAABoundingBox(fOrigin, halfLengths);
1041 if (!buffer.fLocalFrame) {
1042 TransformPoints(buffer.fBBVertex[0], 8);
1044 buffer.SetSectionsValid(TBuffer3D::kBoundingBox);
1053 void TGeoBBox::Contains_v(
const Double_t *points, Bool_t *inside, Int_t vecsize)
const
1055 for (Int_t i=0; i<vecsize; i++) inside[i] = Contains(&points[3*i]);
1063 void TGeoBBox::ComputeNormal_v(
const Double_t *points,
const Double_t *dirs, Double_t *norms, Int_t vecsize)
1065 for (Int_t i=0; i<vecsize; i++) ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
1071 void TGeoBBox::DistFromInside_v(
const Double_t *points,
const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step)
const
1073 for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
1079 void TGeoBBox::DistFromOutside_v(
const Double_t *points,
const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step)
const
1081 for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
1089 void TGeoBBox::Safety_v(
const Double_t *points,
const Bool_t *inside, Double_t *safe, Int_t vecsize)
const
1091 for (Int_t i=0; i<vecsize; i++) safe[i] = Safety(&points[3*i], inside[i]);