00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014 #include "BField/BfldMeshVoronoi.h"
00015
00016 #include "MessageService/MsgService.h"
00017 CVSID("$Id: BfldMeshVoronoi.cxx,v 1.11 2005/02/03 23:00:29 rhatcher Exp $");
00018
00019
00020 #include "TClass.h"
00021
00022 #include "TSystem.h"
00023
00024 #include <iostream>
00025 #include <fstream>
00026 #include <iomanip>
00027
00028 ClassImp(BfldMeshVoronoi)
00029
00030
00031 BfldMeshVoronoi::BfldMeshVoronoi()
00032 : BfldMesh()
00033 {
00034
00035 }
00036
00037
00038 BfldMeshVoronoi::BfldMeshVoronoi(BfldGrid::Grid_t grid, Int_t variant)
00039 : BfldMesh(grid,variant)
00040 {
00041
00042
00043
00044 switch (grid) {
00045 case BfldGrid::kNearCoarseV: fFilename = "NearDetMesh.default";
00046 break;
00047 default:
00048 MSG("Bfld",Msg::kWarning)
00049 << "BfldMeshVoronoi not yet supported for grid " <<
00050 BfldGrid::AsString(grid) << endl;
00051 return;
00052 break;
00053 }
00054
00055 Msg::LogLevel_t verbosity = Msg::kDebug;
00056
00057 MSG("Bfld",verbosity) << "BfldMeshVoronoi::ctor "
00058 << fFilename << endl;
00059
00060 Int_t ngen = 0;
00061 Int_t i = 0;
00062 Int_t NodeID = 0;
00063 Int_t VorCell;
00064 Int_t VorCellLast = -999;
00065 Float_t x, y;
00066
00067 ifstream DATA(fFilename.c_str(),ios::in);
00068 if(!DATA) {
00069 MSG("Bfld",Msg::kWarning) << "BfldMeshVoronoi No such file: "
00070 << fFilename << endl;
00071 return;
00072 }
00073
00074 DATA >> ngen;
00075
00076 fPositions = new TClonesArray("TVector3",ngen);
00077
00078 while(!DATA.eof()){
00079 DATA >> NodeID >> VorCell >> x >> y;
00080 if (NodeID>=0 && VorCell != VorCellLast) {
00081
00082 new((*fPositions)[NodeID]) TVector3(x,y,VorCell);
00083 VorCellLast = VorCell;
00084 } else {
00085 MSG("Bfld",verbosity)
00086 << "BfldMeshVoronoi::ctor NodeID<0 "
00087 << NodeID << " ( VorCell " << VorCell << " ) " << endl;
00088 }
00089 i++;
00090 }
00091 DATA.close();
00092
00093 MSG("Bfld",verbosity) << "BfldMeshVoronoi file read in "
00094 << i << " nodes " << endl;
00095
00096 fReadOk = kTRUE;
00097
00098 }
00099
00100
00101 BfldMeshVoronoi::~BfldMeshVoronoi()
00102 {
00103 MSG("Bfld",Msg::kDebug)
00104 << "~BfldMeshVoroni grid " << BfldGrid::AsString(fGrid)
00105 << endl;
00106 }
00107
00108
00109 TVector3 BfldMeshVoronoi::GetGeneratorPosition(Int_t )
00110 {
00111
00112
00113 Float_t x = 0;
00114 Float_t y = 0;
00115 return TVector3(x,y,0.);
00116 }
00117
00118
00119 Int_t BfldMeshVoronoi::FindANSYSGenerator(Int_t VoronCellID)
00120 {
00121 Int_t NodeID = 1;
00122 TIter next(fPositions);
00123 TVector3 * genVec3;
00124
00125 while( (genVec3 = (TVector3*)next()) ) {
00126 if( genVec3->Z() == VoronCellID ) return NodeID;
00127 NodeID++;
00128 }
00129
00130 return -1;
00131 }
00132
00133