From 88974c1159f63c89299b837f640b8e973dbd213d Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Tue, 13 Jun 2006 12:11:45 +0000 Subject: [PATCH] From Andrei: New method in TGeoPatternFinder to retrieve division axis - modifications in TGeoPainter to load automatically the plugin for geometry editors git-svn-id: http://root.cern.ch/svn/root/trunk@15402 27541ba8-7e3a-0410-8455-c3a389f83636 --- geom/inc/TGeoPatternFinder.h | 18 +++++++++- geom/src/TGeoPatternFinder.cxx | 62 +++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/geom/inc/TGeoPatternFinder.h b/geom/inc/TGeoPatternFinder.h index 13ab116763a..4b8838a3518 100644 --- a/geom/inc/TGeoPatternFinder.h +++ b/geom/inc/TGeoPatternFinder.h @@ -1,4 +1,4 @@ -// @(#)root/geom:$Name: v5-11-02 $:$Id: TGeoPatternFinder.h,v 1.12 2006/04/03 16:19:31 brun Exp $ +// @(#)root/geom:$Name: $:$Id: TGeoPatternFinder.h,v 1.13 2006/05/23 04:47:37 brun Exp $ // Author: Andrei Gheata 30/10/01 /************************************************************************* @@ -56,6 +56,7 @@ public: virtual Int_t GetByteCount() const {return 36;} Int_t GetCurrent() {return fCurrent;} Int_t GetDivIndex() {return fDivIndex;} + virtual Int_t GetDivAxis() {return 1;} virtual TGeoMatrix *GetMatrix() {return fMatrix;} Int_t GetNdiv() const {return fNdivisions;} TGeoNode *GetNodeOffset(Int_t idiv) {return fVolume->GetNode(fDivIndex+idiv);} @@ -92,6 +93,8 @@ public: virtual void cd(Int_t idiv) {fCurrent=idiv; ((TGeoTranslation*)fMatrix)->SetDx(fStart+idiv*fStep+0.5*fStep);} virtual TGeoNode *FindNode(Double_t *point); + virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext); + virtual Int_t GetDivAxis() {return 1;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternX, 1) // X division pattern @@ -115,6 +118,8 @@ public: // methods virtual void cd(Int_t idiv) {fCurrent=idiv; ((TGeoTranslation*)fMatrix)->SetDy(fStart+idiv*fStep+0.5*fStep);} virtual TGeoNode *FindNode(Double_t *point); + virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext); + virtual Int_t GetDivAxis() {return 2;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternY, 1) // Y division pattern @@ -138,6 +143,8 @@ public: // methods virtual void cd(Int_t idiv) {fCurrent=idiv; ((TGeoTranslation*)fMatrix)->SetDz(fStart+idiv*fStep+0.5*fStep);} virtual TGeoNode *FindNode(Double_t *point); + virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext); + virtual Int_t GetDivAxis() {return 3;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternZ, 1) // Z division pattern @@ -163,6 +170,7 @@ public: virtual void cd(Int_t idiv) {fCurrent=idiv; ((TGeoTranslation*)fMatrix)->SetDx(fStart+idiv*fStep+0.5*fStep);} virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 1;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternParaX, 1) // Para X division pattern @@ -190,6 +198,7 @@ public: // methods virtual void cd(Int_t idiv); virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 2;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternParaY, 1) // Para Y division pattern @@ -218,6 +227,7 @@ public: // methods virtual void cd(Int_t idiv); virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 3;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternParaZ, 1) // Para Z division pattern @@ -248,6 +258,7 @@ public: Double_t GetTyz() const {return fTyz;} virtual void cd(Int_t idiv); virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 3;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternTrapZ, 1) // Trap od Gtra Z division pattern @@ -272,6 +283,7 @@ public: // methods virtual void cd(Int_t idiv) {fCurrent=idiv;} virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 1;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternCylR, 1) // Cylindrical R division pattern @@ -306,6 +318,7 @@ public: // methods virtual void cd(Int_t idiv); virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 2;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternCylPhi, 1) // Cylindrical phi division pattern @@ -329,6 +342,7 @@ public: // methods virtual void cd(Int_t idiv) {fCurrent=idiv;} virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 1;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternSphR, 1) // spherical R division pattern @@ -355,6 +369,7 @@ public: // methods virtual void cd(Int_t idiv) {fCurrent=idiv;} virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 2;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternSphTheta, 1) // spherical theta division pattern @@ -380,6 +395,7 @@ public: // methods virtual void cd(Int_t idiv) {fCurrent=idiv;} virtual TGeoNode *FindNode(Double_t *point); + virtual Int_t GetDivAxis() {return 3;} virtual void SavePrimitive(ofstream &out, Option_t *option); ClassDef(TGeoPatternSphPhi, 1) // Spherical phi division pattern diff --git a/geom/src/TGeoPatternFinder.cxx b/geom/src/TGeoPatternFinder.cxx index 1fa7b27840a..850c8351c8f 100644 --- a/geom/src/TGeoPatternFinder.cxx +++ b/geom/src/TGeoPatternFinder.cxx @@ -1,4 +1,4 @@ -// @(#)root/geom:$Name: $:$Id: TGeoPatternFinder.cxx,v 1.15 2006/05/23 04:47:37 brun Exp $ +// @(#)root/geom:$Name: $:$Id: TGeoPatternFinder.cxx,v 1.16 2006/05/24 17:11:54 brun Exp $ // Author: Andrei Gheata 30/10/01 /************************************************************************* @@ -158,6 +158,26 @@ TGeoNode *TGeoPatternX::FindNode(Double_t *point) return node; } +//______________________________________________________________________________ +Double_t TGeoPatternX::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext) +{ +// Compute distance to next division layer returning the index of next section. +// Point is in the frame of the divided volume. + indnext = -1; + Double_t dist = TGeoShape::Big(); + if (TMath::Abs(dir[0])<TGeoShape::Tolerance()) return dist; + if (fCurrent<0) { + Error("FindNextBoundary", "Must call FindNode first"); + return dist; + } + Int_t inc = (dir[0]>0)?1:0; + dist = (fStep*(fCurrent+inc)-point[0])/dir[0]; + if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist); + if (!inc) inc = -1; + indnext = fCurrent+inc; + return dist; +} + //______________________________________________________________________________ void TGeoPatternX::SavePrimitive(ofstream &out, Option_t * /*option*/) { @@ -229,6 +249,26 @@ TGeoNode *TGeoPatternY::FindNode(Double_t *point) return node; } +//______________________________________________________________________________ +Double_t TGeoPatternY::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext) +{ +// Compute distance to next division layer returning the index of next section. +// Point is in the frame of the divided volume. + indnext = -1; + Double_t dist = TGeoShape::Big(); + if (TMath::Abs(dir[1])<TGeoShape::Tolerance()) return dist; + if (fCurrent<0) { + Error("FindNextBoundary", "Must call FindNode first"); + return dist; + } + Int_t inc = (dir[1]>0)?1:0; + dist = (fStep*(fCurrent+inc)-point[1])/dir[1]; + if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist); + if (!inc) inc = -1; + indnext = fCurrent+inc; + return dist; +} + //______________________________________________________________________________ void TGeoPatternY::SavePrimitive(ofstream &out, Option_t * /*option*/) { @@ -301,6 +341,26 @@ TGeoNode *TGeoPatternZ::FindNode(Double_t *point) } +//______________________________________________________________________________ +Double_t TGeoPatternZ::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext) +{ +// Compute distance to next division layer returning the index of next section. +// Point is in the frame of the divided volume. + indnext = -1; + Double_t dist = TGeoShape::Big(); + if (TMath::Abs(dir[2])<TGeoShape::Tolerance()) return dist; + if (fCurrent<0) { + Error("FindNextBoundary", "Must call FindNode first"); + return dist; + } + Int_t inc = (dir[2]>0)?1:0; + dist = (fStep*(fCurrent+inc)-point[2])/dir[2]; + if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist); + if (!inc) inc = -1; + indnext = fCurrent+inc; + return dist; +} + //______________________________________________________________________________ void TGeoPatternZ::SavePrimitive(ofstream &out, Option_t * /*option*/) { -- GitLab