]>
Commit | Line | Data |
---|---|---|
8db3cd07 | 1 | // $Id$ |
2 | ||
3 | void NLT_geo_demo(Int_t type = Reve::NLTProjection::CFishEye, Float_t distortion = 0) | |
4 | { | |
5 | Reve::LoadMacro("region_marker.C"); | |
6 | region_marker(); | |
7 | ||
8 | Reve::NLTProjector* pr = new Reve::NLTProjector(); | |
9 | pr->SetProjection(type, distortion); | |
10 | ||
11 | make_geo(pr); | |
12 | TGLViewer* glv = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->GetViewer3D()); | |
13 | glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); | |
14 | } | |
15 | ||
16 | /**************************************************************************/ | |
17 | void draw_node(const Text_t* path) | |
18 | { | |
19 | gGeoManager->cd(path); | |
20 | TGeoMatrix* mx = gGeoManager->GetCurrentMatrix(); | |
21 | ||
22 | Reve::GeoTopNodeRnrEl* currn_re = new Reve::GeoTopNodeRnrEl | |
23 | (gGeoManager, gGeoManager->GetCurrentNode()); | |
24 | currn_re->SetGlobalTrans(mx); | |
25 | gReve->AddGlobalRenderElement(currn_re); | |
26 | } | |
27 | ||
28 | /**************************************************************************/ | |
29 | TBuffer3D* make_buffer(const Text_t* path) | |
30 | { | |
31 | TBuffer3D* buff = 0; | |
32 | Bool_t valid = gGeoManager->cd(path); | |
33 | if(valid) | |
34 | { | |
35 | TBuffer3D* buff = gGeoManager->GetCurrentVolume()->GetShape()->MakeBuffer3D(); | |
36 | TGeoMatrix* mx = gGeoManager->GetCurrentMatrix(); | |
37 | ||
38 | Int_t N = buff->NbPnts(); | |
39 | Double_t* pnts = buff->fPnts; | |
40 | Double_t master[4]; | |
41 | for(Int_t i = 0; i<N; i++) | |
42 | { | |
43 | mx->LocalToMaster(&pnts[3*i], master); | |
44 | pnts[3*i] = master[0]; | |
45 | pnts[3*i+1] = master[1]; | |
46 | pnts[3*i+2] = master[2]; | |
47 | } | |
48 | buff->fColor = gGeoManager->GetCurrentVolume()->GetLineColor(); | |
49 | } | |
50 | return buff; | |
51 | } | |
52 | ||
53 | /**************************************************************************/ | |
54 | Reve::NLTPolygonSet* project_node(Reve::NLTProjector* nlt, const Text_t* path, Int_t useBP) | |
55 | { | |
56 | Reve::NLTPolygonSet* ps = 0; | |
57 | TBuffer3D* buff = make_buffer(path); | |
58 | if(buff) { | |
59 | ps = nlt->ProjectGeoShape(buff, useBP); | |
60 | if(ps) | |
61 | { | |
62 | ps->SetName(Form("NLTPolygonSet %s",path)); | |
63 | ps->SetFillColor(Color_t(buff->fColor)); | |
64 | ps->SetLineColor((Color_t)TColor::GetColorBright(buff->fColor)); | |
65 | //ps->SetLineColor((Color_t)TColor::GetColorDark(buff->fColor)); | |
66 | } | |
67 | } | |
68 | return ps; | |
69 | } | |
70 | ||
71 | /**************************************************************************/ | |
72 | void project_nodes(Reve::NLTProjector* nlt, const Text_t* parent_path, Int_t useBP) | |
73 | { | |
74 | gGeoManager->cd(parent_path); | |
75 | TGeoNode* holder = gGeoManager->GetCurrentNode(); | |
76 | holder->ls(); | |
77 | TIter next_node(holder->GetNodes()); | |
78 | TGeoNode* geon; | |
79 | ||
80 | Reve::RenderElementList* el = new Reve::RenderElementList(parent_path); | |
81 | gReve->AddGlobalRenderElement(el); | |
82 | while((geon = (TGeoNode*)next_node())) | |
83 | { | |
84 | TGeoVolume* v = geon->GetVolume(); | |
85 | if(v) { | |
86 | TString path = Form("%s/%s",parent_path, geon->GetName()); | |
87 | Reve::NLTPolygonSet* ps = project_node(nlt, path.Data(), useBP); | |
88 | if(ps) { | |
89 | ps->SetName(geon->GetName()); | |
90 | gReve->AddGlobalRenderElement(el, ps); | |
91 | } | |
92 | } | |
93 | } | |
94 | } | |
95 | ||
96 | /**************************************************************************/ | |
97 | void project_to_pointset(Reve::NLTProjector* nlt, const Text_t* path) | |
98 | { | |
99 | TBuffer3D* buff = make_buffer(path); | |
100 | if(buff) | |
101 | { | |
102 | PointSet* ps = new PointSet(buff->NbPnts()); | |
103 | ps->SetMarkerColor(buff->fColor); | |
104 | for(Int_t i = 0; i<buff->NbPnts() ; i++) | |
105 | ps->SetPoint(i, buff->fPnts[3*i], buff->fPnts[3*i+1], buff->fPnts[3*i+2]); | |
106 | ||
107 | PointSet* pps = nlt->ProjectPointSet(ps); | |
108 | gReve->AddGlobalRenderElement(pps); | |
109 | } | |
110 | } | |
111 | /**************************************************************************/ | |
112 | void make_geo(Reve::NLTProjector* nlt) | |
113 | { | |
114 | gGeoManager = gReve->GetGeometry("$REVESYS/alice-data/simple_geo.root"); | |
115 | Int_t useBuffPols = -1; | |
116 | Reve::NLTPolygonSet* ps; | |
117 | ||
118 | project_nodes( nlt, "/ALIC_1/ITSV_holder_1/ITSV_1", useBuffPols); | |
119 | ps = project_node( nlt, "/ALIC_1/TPC_holder_1/TPC_1/TDGN_1", useBuffPols); | |
120 | if(ps) gReve->AddGlobalRenderElement(ps); | |
121 | ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/B077_1", useBuffPols); | |
122 | if(ps) gReve->AddGlobalRenderElement(ps); | |
123 | ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BRS4_1", useBuffPols); | |
124 | if(ps) gReve->AddGlobalRenderElement(ps); | |
125 | ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BRS4_2", useBuffPols); | |
126 | if(ps) gReve->AddGlobalRenderElement(ps); | |
127 | ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BFMO_1", useBuffPols); | |
128 | if(ps) gReve->AddGlobalRenderElement(ps); | |
129 | ps = project_node(nlt, "/ALIC_1/TRD TOF_holder_1/BBMO_1", useBuffPols); | |
130 | if(ps) gReve->AddGlobalRenderElement(ps); | |
131 | ||
132 | for(Int_t i = 1; i<6; i++) { | |
133 | ps = project_node(nlt, Form("/ALIC_1/PHOS_holder_1/PHOS_%d", i), useBuffPols); | |
134 | ps->SetFillColor((Color_t)(kOrange-4)); | |
135 | if(ps) gReve->AddGlobalRenderElement(ps); | |
136 | } | |
137 | project_nodes( nlt, "/ALIC_1/FMD_holder_1", useBuffPols); | |
138 | project_nodes( nlt, "/ALIC_1/RICH_holder_1", useBuffPols); | |
139 | } |