93 std::lock_guard<std::mutex> guard(
fMutex);
94 std::vector<ThreadData_t*>::iterator i =
fThreadData.begin();
109 std::lock_guard<std::mutex> guard(
fMutex);
112 for (
Int_t tid=0; tid<nthreads; tid++) {
184 Error(
"ctor",
"left shape is NULL");
188 Error(
"ctor",
"right shape is NULL");
209 TString sleft, sright, stransf;
212 Error(
"MakeBranch",
"invalid expression");
219 if (stransf.
Length() == 0) {
225 Error(
"MakeBranch",
"transformation %s not found", stransf.
Data());
233 Error(
"MakeBranch",
"shape %s not found", sleft.
Data());
259 if (boolop && (!shape || !shape->
IsValid())) {
260 Error(
"MakeBranch",
"Shape %s not valid", newshape.
Data());
261 if (shape)
delete shape;
335 Error(
"ReplaceMatrix",
"Matrices should not be gGeoIdentity. Use default matrix constructor to represent identities.");
338 if (!mat || !newmat) {
339 Error(
"ReplaceMatrix",
"Matrices should not be null pointers.");
388 for (
Int_t i=0; i<3*npoints; i++) points[i] =
fPoints[i];
418 Error(
"Paint",
"gPad->GetViewer3D() returned 0, cannot work with composite!\n");
449 Fatal(
"TGeoUnion",
"Unions with a half-space (%s + %s) not allowed", left->
GetName(), right->
GetName());
474 ((
TGeoBBox*)fLeft)->SetBoxPoints(&vert[0]);
475 ((
TGeoBBox*)fRight)->SetBoxPoints(&vert[24]);
476 for (i=0; i<8; i++) {
478 if (pt[0]<xmin) xmin=pt[0];
479 if (pt[0]>xmax) xmax=pt[0];
480 if (pt[1]<ymin) ymin=pt[1];
481 if (pt[1]>ymax) ymax=pt[1];
482 if (pt[2]<zmin) zmin=pt[2];
483 if (pt[2]>zmax) zmax=pt[2];
485 for (i=8; i<16; i++) {
487 if (pt[0]<xmin) xmin=pt[0];
488 if (pt[0]>xmax) xmax=pt[0];
489 if (pt[1]<ymin) ymin=pt[1];
490 if (pt[1]>ymax) ymax=pt[1];
491 if (pt[2]<zmin) zmin=pt[2];
492 if (pt[2]>zmax) zmax=pt[2];
494 dx = 0.5*(xmax-
xmin);
495 origin[0] = 0.5*(xmin+
xmax);
496 dy = 0.5*(ymax-
ymin);
497 origin[1] = 0.5*(ymin+
ymax);
498 dz = 0.5*(zmax-zmin);
499 origin[2] = 0.5*(zmin+zmax);
510 if (inside)
return kTRUE;
522 norm[0] = norm[1] = 0.;
555 local[0] = point[0] + 1
E-5*dir[0];
556 local[1] = point[1] + 1
E-5*dir[1];
557 local[2] = point[2] + 1
E-5*dir[2];
560 local[0] = point[0] - 1
E-5*dir[0];
561 local[1] = point[1] - 1
E-5*dir[1];
562 local[2] = point[2] - 1
E-5*dir[2];
582 if (iact<3 && safe) {
589 Double_t local[3], local1[3], master[3], ldir[3], rdir[3], pushed[3];
590 memcpy(master, point, 3*
sizeof(
Double_t));
593 Double_t d1=0., d2=0., snxt=0., eps=0.;
599 else memcpy(local1, local, 3*
sizeof(
Double_t));
603 if (!(inside1 | inside2)) {
608 for (i=0; i<3; i++) local1[i] += eps*ldir[i];
616 for (i=0; i<3; i++) local[i] += eps*rdir[i];
623 while (inside1 || inside2) {
624 if (inside1 && inside2) {
630 for (i=0; i<3; i++) master[i] += d1*dir[i];
634 if (!inside2)
return snxt;
642 for (i=0; i<3; i++) master[i] += d2*dir[i];
646 if (!inside1)
return snxt;
656 for (i=0; i<3; i++) {
657 master[i] += d1*dir[i];
663 if (!inside2)
return snxt;
673 for (i=0; i<3; i++) {
674 master[i] += d2*dir[i];
680 if (!inside1)
return snxt;
695 if (iact<3 && safe) {
702 Double_t local[3], ldir[3], rdir[3];
738 for (
Int_t i=0; i<nleft; i++) {
744 for (
Int_t i=0; i<nright; i++) {
769 Bool_t intrue = in1 | in2;
770 if (intrue^in)
return 0.0;
773 if (in1 && in2)
return TMath::Min(saf1, saf2);
774 if (in1)
return saf1;
775 if (in2)
return saf2;
785 out <<
" pBoolNode = new TGeoUnion(";
791 else out <<
"0);" << std::endl;
821 Error(
"Paint",
"gPad->GetViewer3D() returned 0, cannot work with composite!\n");
852 Fatal(
"TGeoSubstraction",
"Subtractions from a half-space (%s) not allowed", left->
GetName());
878 for (i=0; i<8; i++) {
880 if (pt[0]<xmin) xmin=pt[0];
881 if (pt[0]>xmax) xmax=pt[0];
882 if (pt[1]<ymin) ymin=pt[1];
883 if (pt[1]>ymax) ymax=pt[1];
884 if (pt[2]<zmin) zmin=pt[2];
885 if (pt[2]>zmax) zmax=pt[2];
887 dx = 0.5*(xmax-
xmin);
888 origin[0] = 0.5*(xmin+
xmax);
889 dy = 0.5*(ymax-
ymin);
890 origin[1] = 0.5*(ymin+
ymax);
891 dz = 0.5*(zmax-zmin);
892 origin[2] = 0.5*(zmin+zmax);
901 norm[0] = norm[1] = 0.;
903 Double_t local[3], ldir[3], lnorm[3];
933 local[0] = point[0]+1
E-5*dir[0];
934 local[1] = point[1]+1
E-5*dir[1];
935 local[2] = point[2]+1
E-5*dir[2];
937 local[0] = point[0]-1
E-5*dir[0];
938 local[1] = point[1]-1
E-5*dir[1];
939 local[2] = point[2]-1
E-5*dir[2];
953 if (!inside)
return kFALSE;
973 if (iact<3 && safe) {
980 Double_t local[3], ldir[3], rdir[3];
1004 if (iact<3 && safe) {
1011 Double_t local[3], master[3], ldir[3], rdir[3];
1012 memcpy(&master[0], point, 3*
sizeof(
Double_t));
1027 for (i=0; i<3; i++) master[i] += (d1+1
E-8)*dir[i];
1047 for (i=0; i<3; i++) master[i] += (d1+1
E-8)*dir[i];
1069 for (
Int_t i=0; i<nleft; i++) {
1077 for (
Int_t i=0; i<nright; i++) {
1102 Bool_t intrue = in1 && (!in2);
1103 if (in^intrue)
return 0.0;
1106 if (in1 && in2)
return saf2;
1118 out <<
" pBoolNode = new TGeoSubtraction(";
1124 else out <<
"0);" << std::endl;
1153 Error(
"Paint",
"gPad->GetViewer3D() returned 0, cannot work with composite!\n");
1185 if (hs1 && hs2)
Fatal(
"ctor",
"cannot intersect two half-spaces: %s * %s", left->
GetName(), right->
GetName());
1206 Double_t xmin1, xmax1, ymin1, ymax1, zmin1, zmax1;
1207 Double_t xmin2, xmax2, ymin2, ymax2, zmin2, zmax2;
1208 xmin1 = ymin1 = zmin1 = xmin2 = ymin2 = zmin2 =
TGeoShape::Big();
1209 xmax1 = ymax1 = zmax1 = xmax2 = ymax2 = zmax2 = -
TGeoShape::Big();
1212 ((
TGeoBBox*)fLeft)->SetBoxPoints(&vert[0]);
1213 for (i=0; i<8; i++) {
1215 if (pt[0]<xmin1) xmin1=pt[0];
1216 if (pt[0]>xmax1) xmax1=pt[0];
1217 if (pt[1]<ymin1) ymin1=pt[1];
1218 if (pt[1]>ymax1) ymax1=pt[1];
1219 if (pt[2]<zmin1) zmin1=pt[2];
1220 if (pt[2]>zmax1) zmax1=pt[2];
1225 ((
TGeoBBox*)fRight)->SetBoxPoints(&vert[24]);
1226 for (i=8; i<16; i++) {
1228 if (pt[0]<xmin2) xmin2=pt[0];
1229 if (pt[0]>xmax2) xmax2=pt[0];
1230 if (pt[1]<ymin2) ymin2=pt[1];
1231 if (pt[1]>ymax2) ymax2=pt[1];
1232 if (pt[2]<zmin2) zmin2=pt[2];
1233 if (pt[2]>zmax2) zmax2=pt[2];
1237 dx = 0.5*(xmax2-xmin2);
1238 origin[0] = 0.5*(xmax2+xmin2);
1239 dy = 0.5*(ymax2-ymin2);
1240 origin[1] = 0.5*(ymax2+ymin2);
1241 dz = 0.5*(zmax2-zmin2);
1242 origin[2] = 0.5*(zmax2+zmin2);
1246 dx = 0.5*(xmax1-xmin1);
1247 origin[0] = 0.5*(xmax1+xmin1);
1248 dy = 0.5*(ymax1-ymin1);
1249 origin[1] = 0.5*(ymax1+ymin1);
1250 dz = 0.5*(zmax1-zmin1);
1251 origin[2] = 0.5*(zmax1+zmin1);
1264 memset(origin, 0, 3*
sizeof(
Double_t));
1267 dx = 0.5*(sort[isort[2]]-sort[isort[1]]);
1268 origin[0] = 0.5*(sort[isort[1]]+sort[isort[2]]);
1277 memset(origin, 0, 3*
sizeof(
Double_t));
1280 dy = 0.5*(sort[isort[2]]-sort[isort[1]]);
1281 origin[1] = 0.5*(sort[isort[1]]+sort[isort[2]]);
1290 memset(origin, 0, 3*
sizeof(
Double_t));
1293 dz = 0.5*(sort[isort[2]]-sort[isort[1]]);
1294 origin[2] = 0.5*(sort[isort[1]]+sort[isort[2]]);
1303 Double_t local[3], ldir[3], lnorm[3];
1304 norm[0] = norm[1] = 0.;
1335 local[0] = point[0] + 1
E-5*dir[0];
1336 local[1] = point[1] + 1
E-5*dir[1];
1337 local[2] = point[2] + 1
E-5*dir[2];
1339 local[0] = point[0] - 1
E-5*dir[0];
1340 local[1] = point[1] - 1
E-5*dir[1];
1341 local[2] = point[2] - 1
E-5*dir[2];
1355 if (!inside)
return kFALSE;
1375 if (iact<3 && safe) {
1382 Double_t local[3], ldir[3], rdir[3];
1407 if (iact<3 && safe) {
1414 Double_t lpt[3], rpt[3], master[3], ldir[3], rdir[3];
1415 memcpy(master, point, 3*
sizeof(
Double_t));
1427 if (inleft && inright) {
1432 if (d1<1.
E-3) inleft =
kFALSE;
1433 if (d2<1.
E-3) inright =
kFALSE;
1434 if (inleft && inright)
return snext;
1455 for (i=0; i<3; i++) master[i] += d1*dir[i];
1458 for (i=0; i<3; i++) rpt[i] += tol*rdir[i];
1461 if (inright)
return snext;
1468 for (i=0; i<3; i++) master[i] += d2*dir[i];
1471 for (i=0; i<3; i++) lpt[i] += tol*ldir[i];
1474 if (inleft)
return snext;
1495 for (
Int_t i=0; i<nleft; i++) {
1503 for (
Int_t i=0; i<nright; i++) {
1528 Bool_t intrue = in1 & in2;
1529 if (in^intrue)
return 0.0;
1532 if (in1 && in2)
return TMath::Min(saf1, saf2);
1533 if (in1)
return saf2;
1534 if (in2)
return saf1;
1544 out <<
" pBoolNode = new TGeoIntersection(";
1550 else out <<
"0);" << std::endl;
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const
Compute distance from a given point inside to the shape boundary.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
virtual void Sizeof3D() const =0
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this subtraction. ...
TGeoUnion()
Default constructor.
virtual void MasterToLocalVect(const Double_t *master, Double_t *local) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix
virtual ~TGeoUnion()
Destructor — deletion of components handled by TGeoManager class.
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const
Compute distance from a given point inside to the shape boundary.
#define snext(osub1, osub2)
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a subtraction of two shapes.
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)=0
virtual TGeoBoolNode * MakeClone() const
Make a clone of this. Pointers are preserved.
Geometrical transformation package.
std::vector< ThreadData_t * > fThreadData
array of mesh points
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
virtual void CreateThreadData(Int_t)
void SetSelected(Int_t sel)
Set the selected branch.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void Paint(Option_t *option)
Paint method.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
TGeoIntersection()
Default constructor.
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual Int_t GetNpoints()=0
virtual void Sizeof3D() const
Register 3D size of this shape.
virtual Bool_t Contains(const Double_t *point) const
Find if a union of two shapes contains a given point.
Matrix class used for computing global transformations Should NOT be used for node definition...
void Multiply(const TGeoMatrix *right)
multiply to the right with an other transformation if right is identity matrix, just return ...
Short_t Min(Short_t a, Short_t b)
virtual void SetPoints(Double_t *points) const
Fill buffer with shape vertices.
static Int_t Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
Parse a string boolean expression and do a syntax check.
void RegisterMatrices()
Register all matrices of the boolean node and descendents.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
virtual void ComputeBBox()
Compute bounding box - nothing to do in this case.
virtual ~TGeoSubtraction()
Destructor — deletion of components handled by TGeoManager class.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
std::mutex fMutex
Size for the navigation data array.
static Double_t Tolerance()
virtual Bool_t Contains(const Double_t *point) const =0
Bool_t MakeBranch(const char *expr, Bool_t left)
Mutex for thread data access.
virtual void Paint(Option_t *option)
Special schema for feeding the 3D buffers to the painter client.
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual TGeoBoolNode * MakeClone() const
Make a clone of this. Pointers are preserved.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this union.
Bool_t IsIdentity() const
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const
Compute distance from a given point outside to the shape.
Abstract 3D shapes viewer.
virtual void LocalToMasterVect(const Double_t *local, Double_t *master) const
convert a vector by multiplying its column vector (x, y, z, 1) to matrix inverse
char * GetPointerName() const
Provide a pointer name containing uid.
TGeoBoolNode()
Default constructor.
virtual void SetPoints(Double_t *points) const =0
void SetBoxPoints(Double_t *points) const
Fill box vertices to an array.
const char * GetPointerName() const
Provide a pointer name containing uid.
virtual ~TGeoBoolNode()
Destructor.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Compute safety distance for a union node;.
Class handling Boolean composition of shapes.
virtual const char * GetName() const
Get the shape name.
TGeoSubtraction()
Default constructor.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const
Compute distance from a given outside point to the shape.
virtual Int_t GetNpoints()
Returns number of vertices for the composite shape described by this intersection.
Base abstract class for all shapes.
ThreadData_t()
Constructor.
Int_t fThreadSize
Navigation data per thread.
virtual Bool_t Contains(const Double_t *point) const
Find if a intersection of two shapes contains a given point.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const =0
virtual Bool_t IsComposite() const
virtual Bool_t Contains(const Double_t *point) const
Find if a subtraction of two shapes contains a given point.
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Stub implementation to avoid forcing implementation at this stage.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual Int_t GetNmeshVertices() const
TObjArray * GetListOfShapes() const
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const
Computes distance from a given point inside the shape to its boundary.
virtual Int_t AddObject(const TBuffer3D &buffer, Bool_t *addChildren=0)=0
~ThreadData_t()
Destructor.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Normal computation in POINT. The orientation is chosen so that DIR.dot.NORM>0.
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=0, Double_t *safe=0) const
Compute distance from a given point outside to the shape.
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a intersection of two shapes.
void CreateThreadData(Int_t nthreads)
Create thread data for n threads max.
Generic 3D primitive description class.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Bool_t ReplaceMatrix(TGeoMatrix *mat, TGeoMatrix *newmat)
Replace one of the matrices.
Double_t * fPoints
number of points on the mesh
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const =0
TObjArray * GetListOfMatrices() const
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
virtual Bool_t IsNullBox() const
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const =0
ThreadData_t & GetThreadData() const
virtual ~TGeoIntersection()
Destructor — deletion of components handled by TGeoManager class.
R__EXTERN TGeoManager * gGeoManager
virtual void MasterToLocal(const Double_t *master, Double_t *local) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix
Bool_t TestShapeBit(UInt_t f) const
virtual void Paint(Option_t *option)
Paint method.
virtual TGeoBoolNode * MakeClone() const
Make a clone of this. Pointers are preserved.
virtual void Sizeof3D() const
Register size of this 3D object.
virtual void AddCompositeOp(UInt_t operation)=0
virtual void ComputeBBox()=0
static TGeoMatrix * GetTransform()
Returns current transformation matrix that applies to shape.
R__EXTERN TGeoIdentity * gGeoIdentity
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
Base class for Boolean operations between two shapes.
Short_t Max(Short_t a, Short_t b)
void ClearThreadData() const
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void ComputeBBox(Double_t &dx, Double_t &dy, Double_t &dz, Double_t *origin)
Compute bounding box corresponding to a union of two shapes.
virtual Int_t DistanceToPrimitive(Int_t px, Int_t py)
Compute minimum distance to shape vertices.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Paint(Option_t *option)
Paint method.
const char * Data() const
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".