00001
00002
00003
00004
00005
00007
00008
00009
00010
00011
00012
00013 #ifndef BFLWINGEDEDGE_H
00014 #define BFLWINGEDEDGE_H
00015
00016 #include <TObjArray.h>
00017
00018 #include "BField/BFLNode.h"
00019 #include "BField/BFLVtx.h"
00020 #include "BField/BFLEdge.h"
00021 #include "BField/BFLPolyg.h"
00022 #include "BField/BFLAnsysLookup.h"
00023 #include "BField/TIntList.h"
00024 #include "BField/BfldGrid.h"
00025
00026 const Int_t kStartEdgeID = 1;
00027 const Int_t kStartVtxID = 1;
00028 const Int_t kStartPolygID = 0;
00029
00030 const Int_t kALL = 0;
00031 const Int_t kEDGES = 1;
00032 const Int_t kVERTICES = 2;
00033 const Int_t kPOLYGONS = 3;
00034
00035 class BFLNode;
00036 class BFLVtx;
00037 class BFLEdge;
00038 class BFLPolyg;
00039 class TIntList;
00040
00041 class BFLWingedEdge: public TObject
00042 {
00043 public:
00044
00045 BFLWingedEdge(Long_t ngens = 0);
00046 ~BFLWingedEdge();
00047 virtual void SetGenerators(TObjArray * gens) { fGenerators = gens; }
00048
00049 Long_t Size(void);
00050 void Load(const Char_t * filename);
00051 void Save(const Char_t * filename = "default.vor");
00052 void LoadNodalSet(const Char_t * filename);
00053 void SaveNodalSet(const Char_t * filename = "default-nodes.vor");
00054
00055 void LoadANSYSLookupTable(BfldGrid::Grid_t grid);
00056
00057
00058
00059 virtual TObjArray * GetGenerators(void) { return fGenerators; }
00060
00061 virtual Int_t GetEdgeID(Int_t EdgeSlot) const {
00062 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetEdgeID();
00063 }
00064 virtual Int_t GetRightPolyg(Int_t EdgeSlot) const {
00065 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetRightPolyg();
00066 }
00067 virtual Int_t GetLeftPolyg(Int_t EdgeSlot) const {
00068 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetLeftPolyg();
00069 }
00070 virtual Int_t GetStartVtx(Int_t EdgeSlot) const {
00071 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetStartVtx();
00072 }
00073 virtual Int_t GetEndVtx(Int_t EdgeSlot) const {
00074 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetEndVtx();
00075 }
00076 virtual Int_t GetCwPredecessor(Int_t EdgeSlot) const {
00077 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetCwPredecessor();
00078 }
00079 virtual Int_t GetCcwPredecessor(Int_t EdgeSlot) const {
00080 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetCcwPredecessor();
00081 }
00082 virtual Int_t GetCwSuccessor(Int_t EdgeSlot) const {
00083 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetCwSuccessor();
00084 }
00085 virtual Int_t GetCcwSuccessor(Int_t EdgeSlot) const {
00086 return ((BFLEdge *)fEdges->At(EdgeSlot))->GetCcwSuccessor();
00087 }
00088 virtual Int_t GetPolygID(Int_t PolySlot) const {
00089 return ((BFLPolyg *)fPolygons->At(PolySlot))->GetPolygID();
00090 }
00091 virtual Int_t GetEdgeAroundPolyg(Int_t PolySlot) const {
00092 return ((BFLPolyg *)fPolygons->At(PolySlot))->GetEdgeAroundPolyg();
00093 }
00094 virtual BFLNode * GetVtx(Int_t VtxSlot) const {
00095 return new BFLNode(GetX(VtxSlot),GetY(VtxSlot));
00096 }
00097 virtual Int_t GetVtxID(Int_t VtxSlot) const {
00098 return ((BFLVtx *)fVertices->At(VtxSlot))->GetVtxID();
00099 }
00100 virtual Int_t GetEdgeAroundVtx(Int_t VtxSlot) const {
00101 return ((BFLVtx *)fVertices->At(VtxSlot))->GetEdgeAroundVtx();
00102 }
00103 virtual Bool_t GetWeight(Int_t VtxSlot) const {
00104 return ((BFLVtx *)fVertices->At(VtxSlot))->GetWeight();
00105 }
00106 virtual Float_t GetX(Int_t VtxSlot) const {
00107 return ((BFLVtx *)fVertices->At(VtxSlot))->GetX();
00108 }
00109 virtual Float_t GetY(Int_t VtxSlot) const {
00110 return ((BFLVtx *)fVertices->At(VtxSlot))->GetY();
00111 }
00112
00113 virtual Int_t GetNofPolygons(void) { return fPolygons->GetEntries(); }
00114 virtual Int_t GetNofVertices(void) { return fVertices->GetEntries(); }
00115 virtual Int_t GetNofEdges(void) { return fEdges->GetEntries(); }
00116
00117 virtual TObjArray * GetPolygons(void) { return fPolygons; }
00118 virtual TObjArray * GetVertices(void) { return fVertices; }
00119 virtual TObjArray * GetEdges(void) { return fEdges; }
00120
00121 virtual BFLPolyg * GetPolygObj(Int_t slot) {
00122 return (BFLPolyg *) fPolygons->At(slot);
00123 }
00124 virtual BFLVtx * GetVtxObj(Int_t slot) {
00125 return (BFLVtx *) fVertices->At(slot);
00126 }
00127 virtual BFLEdge * GetEdgeObj(Int_t slot) {
00128 return (BFLEdge *) fEdges->At(slot);
00129 }
00130
00131 virtual BFLAnsysLookup GetAnsysLookupTable(void) { return *fANSYSTable; }
00132
00133 virtual Int_t GetLastPolygID(void) { return fPolygons->GetLast(); }
00134 virtual Int_t GetLastVtxID(void) { return fVertices->GetLast(); }
00135 virtual Int_t GetLastEdgeID(void) { return fEdges->GetLast(); }
00136
00137 virtual Int_t PolygonToGenerator(Int_t polygon) const { return polygon; }
00138 virtual Int_t GeneratorToPolygon(Int_t generator) const { return generator; }
00139
00140 virtual Float_t GetGeneratorX(Int_t igen) const {
00141 return ((BFLNode *)(fGenerators->At(igen-1)))->GetX();
00142 }
00143 virtual Float_t GetGeneratorY(Int_t igen) const {
00144 return ((BFLNode *)(fGenerators->At(igen-1)))->GetY();
00145 }
00146 virtual Int_t GetGeneratorID(Int_t igen) const {
00147 return ((BFLNode *)(fGenerators->At(igen-1)))->GetNodeID();
00148 }
00149
00150
00151
00152 void SetEdge(Int_t edge) {
00153 fEdges->AddAtAndExpand(new BFLEdge(edge), edge);
00154 }
00155 virtual void SetPolyg(Int_t polyg) {
00156 fPolygons->AddAtAndExpand(new BFLPolyg(polyg), polyg);
00157 }
00158 virtual void SetVtx(Int_t vtx) {
00159 fVertices->AddAtAndExpand(new BFLVtx(vtx), vtx);
00160 }
00161
00162 virtual void SetEdgeID(Int_t EdgeSlot, Int_t EdgeID) {
00163 ((BFLEdge *)fEdges->At(EdgeSlot))->SetRightPolyg(EdgeID);
00164 }
00165 virtual void SetRightPolyg(Int_t EdgeSlot, Int_t rpolyg) {
00166 ((BFLEdge *)fEdges->At(EdgeSlot))->SetRightPolyg(rpolyg);
00167 }
00168 virtual void SetLeftPolyg(Int_t EdgeSlot, Int_t lpolyg) {
00169 ((BFLEdge *)fEdges->At(EdgeSlot))->SetLeftPolyg(lpolyg);
00170 }
00171 virtual void SetStartVtx(Int_t EdgeSlot, Int_t svtx) {
00172 ((BFLEdge *)fEdges->At(EdgeSlot))->SetStartVtx(svtx);
00173 }
00174 virtual void SetEndVtx(Int_t EdgeSlot, Int_t evtx) {
00175 ((BFLEdge *)fEdges->At(EdgeSlot))->SetEndVtx(evtx);
00176 }
00177 virtual void SetCwPredecessor(Int_t EdgeSlot, Int_t cwpred) {
00178 ((BFLEdge *)fEdges->At(EdgeSlot))->SetCwPredecessor(cwpred);
00179 }
00180 virtual void SetCcwPredecessor(Int_t EdgeSlot, Int_t ccwpred) {
00181 ((BFLEdge *)fEdges->At(EdgeSlot))->SetCcwPredecessor(ccwpred);
00182 }
00183 virtual void SetCwSuccessor(Int_t EdgeSlot, Int_t cwsucc) {
00184 ((BFLEdge *)fEdges->At(EdgeSlot))->SetCwSuccessor(cwsucc);
00185 }
00186 virtual void SetCcwSuccessor(Int_t EdgeSlot, Int_t ccwsucc) {
00187 ((BFLEdge *)fEdges->At(EdgeSlot))->SetCcwSuccessor(ccwsucc);
00188 }
00189 virtual void SetPolygID(Int_t PolySlot,Int_t PolyID) {
00190 ((BFLPolyg *)fPolygons->At(PolySlot))->SetPolygID(PolyID);
00191 }
00192 virtual void SetEdgeAroundPolyg(Int_t PolySlot, Int_t edge) {
00193 ((BFLPolyg *)fPolygons->At(PolySlot))->SetEdgeAroundPolyg(edge);
00194 }
00195 virtual void SetVtxID(Int_t VtxSlot, Int_t VtxID) {
00196 ((BFLVtx *)fVertices->At(VtxSlot))->SetVtxID(VtxID);
00197 }
00198 virtual void SetEdgeAroundVtx(Int_t VtxSlot, Int_t edge) {
00199 ((BFLVtx *)fVertices->At(VtxSlot))->SetEdgeAroundVtx(edge);
00200 }
00201 virtual void SetWeight(Int_t VtxSlot, Bool_t weight) {
00202 ((BFLVtx *)fVertices->At(VtxSlot))->SetWeight(weight);
00203 }
00204 virtual void SetX(Int_t VtxSlot, Float_t x) {
00205 ((BFLVtx *)fVertices->At(VtxSlot))->SetX(x);
00206 }
00207 virtual void SetY(Int_t VtxSlot, Float_t y) {
00208 ((BFLVtx *)fVertices->At(VtxSlot))->SetY(y);
00209 }
00210
00211 virtual void SetPolygObj(BFLPolyg * polyg, Int_t slot) {
00212 fPolygons->AddAt(polyg,slot);
00213 }
00214 virtual void SetVtxObj(BFLVtx * vtx, Int_t slot) {
00215 fVertices->AddAt(vtx,slot);
00216 }
00217 virtual void SetEdgeObj(BFLEdge * edge, Int_t slot) {
00218 fEdges->AddAt(edge,slot);
00219 }
00220
00221 void AddEdge(Int_t EdgeSlot);
00222 void AddPolyg(Int_t PolySlot);
00223 void AddVtx(Int_t VtxSlot);
00224
00225 virtual void DeleteVtx(Int_t vtx)
00226 {
00227 delete (BFLVtx *) fVertices->At(vtx);
00228 fVertices->RemoveAt(vtx);
00229 }
00230 virtual void DeleteEdge(Int_t edge)
00231 {
00232 delete (BFLEdge *) fEdges->At(edge);
00233 fEdges->RemoveAt(edge);
00234 }
00235 virtual void DeletePolygon(Int_t polyg)
00236 {
00237 delete (BFLPolyg *) fPolygons->At(polyg);
00238 fPolygons->RemoveAt(polyg);
00239 }
00240
00241 void PrintVoronoi(Int_t PrintWhat);
00242 void PrintPolygons(void);
00243 void PrintVertices(void);
00244 void PrintEdges(void);
00245 void Plot(void);
00246
00247 void AddAvailableEdgeID(Int_t id);
00248 void AddAvailableVtxID(Int_t id);
00249 Int_t FirstAvailableVtxID(void) const;
00250 Int_t FirstAvailableEdgeID(void) const;
00251 void DeleteFirstAvailableVtxID(void);
00252 void DeleteFirstAvailableEdgeID(void);
00253 Int_t MaxAvailableEdgeID(void) const;
00254 Int_t MaxAvailableVtxID(void) const;
00255
00256 private:
00257 Int_t fNEdges;
00258 Int_t fNVertices;
00259 Int_t fNPolygons;
00260 TObjArray* fEdges;
00261 TObjArray* fVertices;
00262 TObjArray* fPolygons;
00263 TObjArray* fGenerators;
00264 TIntList* fAvailableVtxIDs;
00265 TIntList* fAvailableEdgeIDs;
00266 BFLAnsysLookup* fANSYSTable;
00267
00268 ClassDef(BFLWingedEdge,0)
00269 };
00270
00271
00272 #endif