45 TGeoManager* init_geo_mangeur()
51 TGeoManager *old = gGeoManager;
52 TGeoIdentity *old_id = gGeoIdentity;
53 gGeoManager =
nullptr;
54 TGeoManager* mgr =
new TGeoManager();
55 mgr->SetNameTitle(
"REveGeoShape::fgGeoManager",
56 "Static geo manager used for wrapped TGeoShapes.");
57 gGeoIdentity =
new TGeoIdentity(
"Identity");
59 gGeoIdentity = old_id;
63 TGeoHMatrix localGeoHMatrixIdentity;
66 using namespace ROOT::Experimental;
67 namespace REX = ROOT::Experimental;
85 TGeoManager *REX::REveGeoShape::fgGeoManager = init_geo_mangeur();
93 TGeoManager *REveGeoShape::GetGeoManager()
104 TGeoHMatrix *REveGeoShape::GetGeoHMatrixIdentity()
106 return &localGeoHMatrixIdentity;
112 REveGeoShape::REveGeoShape(
const std::string &name,
const std::string &title)
113 : REveShape(name, title), fNSegments(0), fShape(nullptr), fCompositeShape(nullptr)
121 REveGeoShape::~REveGeoShape()
129 TGeoShape* REveGeoShape::MakePolyShape()
131 auto poly =
new REveGeoPolyShape();
132 poly->BuildFromComposite(fCompositeShape, fNSegments);
139 Int_t REveGeoShape::WriteCoreJson(nlohmann::json &j, Int_t rnr_offset)
141 return REveShape::WriteCoreJson(j, rnr_offset);
147 void REveGeoShape::BuildRenderData()
151 REveGeoPolyShape *egps =
nullptr;
152 std::unique_ptr<REveGeoPolyShape> tmp_egps;
154 if (fCompositeShape) {
156 egps =
dynamic_cast<REveGeoPolyShape *
>(fShape);
160 tmp_egps = std::make_unique<REveGeoPolyShape>();
162 tmp_egps->BuildFromShape(fShape, fNSegments);
164 egps = tmp_egps.get();
167 fRenderData = std::make_unique<REveRenderData>(
"makeEveGeoShape");
169 REveElement::BuildRenderData();
170 egps->FillRenderData(*fRenderData);
176 void REveGeoShape::SetNSegments(Int_t s)
178 if (s != fNSegments && fCompositeShape !=
nullptr) {
180 fShape = MakePolyShape();
195 void REveGeoShape::SetShape(TGeoShape *s)
197 REveGeoManagerHolder gmgr(fgGeoManager);
199 if (fCompositeShape) {
201 fShape = fCompositeShape;
205 fShape->SetUniqueID(fShape->GetUniqueID() - 1);
206 if (fShape->GetUniqueID() == 0) {
214 fShape->SetUniqueID(fShape->GetUniqueID() + 1);
215 fCompositeShape =
dynamic_cast<TGeoCompositeShape *
>(fShape);
216 if (fCompositeShape) {
217 fShape = MakePolyShape();
225 void REveGeoShape::ComputeBBox()
227 TGeoBBox *bb =
dynamic_cast<TGeoBBox *
>(fShape);
230 const Double_t *o = bb->GetOrigin();
231 BBoxCheckPoint(o[0] - bb->GetDX(), o[0] - bb->GetDY(), o[0] - bb->GetDZ());
232 BBoxCheckPoint(o[0] + bb->GetDX(), o[0] + bb->GetDY(), o[0] + bb->GetDZ());
242 void REveGeoShape::SaveExtract(
const char* file,
const char* name)
245 REveGeoShapeExtract* gse = DumpShapeTree(
this,
nullptr);
247 TFile f(file,
"RECREATE");
256 void REveGeoShape::WriteExtract(
const char* name)
259 REveGeoShapeExtract* gse = DumpShapeTree(
this,
nullptr);
266 REveGeoShapeExtract *REveGeoShape::DumpShapeTree(REveGeoShape* gsre,
267 REveGeoShapeExtract* parent)
269 REveGeoShapeExtract* she =
new REveGeoShapeExtract(gsre->GetCName(), gsre->GetCTitle());
270 she->SetTrans(gsre->RefMainTrans().Array());
272 Int_t ci = gsre->GetFillColor();
273 TColor *c = gROOT->GetColor(ci);
274 Float_t rgba[4] = { 1, 0, 0, Float_t(1 - gsre->GetMainTransparency()/100.) };
277 rgba[0] = c->GetRed();
278 rgba[1] = c->GetGreen();
279 rgba[2] = c->GetBlue();
284 Int_t ci = gsre->GetLineColor();
285 TColor *c = gROOT->GetColor(ci);
286 Float_t rgba[4] = { 1, 0, 0, 1 };
289 rgba[0] = c->GetRed();
290 rgba[1] = c->GetGreen();
291 rgba[2] = c->GetBlue();
293 she->SetRGBALine(rgba);
295 she->SetRnrSelf(gsre->GetRnrSelf());
296 she->SetRnrElements(gsre->GetRnrChildren());
297 she->SetRnrFrame(gsre->GetDrawFrame());
298 she->SetMiniFrame(gsre->GetMiniFrame());
299 she->SetShape(gsre->GetShape());
300 if (gsre->HasChildren())
302 TList* ele =
new TList();
303 she->SetElements(ele);
304 she->GetElements()->SetOwner(
true);
306 for (
auto &c: gsre->RefChildren())
307 DumpShapeTree(dynamic_cast<REveGeoShape *>(c), she);
310 parent->GetElements()->Add(she);
318 REveGeoShape *REveGeoShape::ImportShapeExtract(REveGeoShapeExtract* gse,
321 REveGeoManagerHolder gmgr(fgGeoManager);
322 REveManager::RRedrawDisabler redrawOff(REX::gEve);
323 REveGeoShape* gsre = SubImportShapeExtract(gse, parent);
324 gsre->StampObjProps();
331 REveGeoShape *REveGeoShape::SubImportShapeExtract(REveGeoShapeExtract* gse,
334 REveGeoShape* gsre =
new REveGeoShape(gse->GetName(), gse->GetTitle());
335 gsre->RefMainTrans().SetFromArray(gse->GetTrans());
336 const Float_t* rgba = gse->GetRGBA();
337 gsre->SetMainColorRGB(rgba[0], rgba[1], rgba[2]);
338 gsre->SetMainAlpha(rgba[3]);
339 rgba = gse->GetRGBALine();
340 gsre->SetLineColor(TColor::GetColor(rgba[0], rgba[1], rgba[2]));
341 gsre->SetRnrSelf(gse->GetRnrSelf());
342 gsre->SetRnrChildren(gse->GetRnrElements());
343 gsre->SetDrawFrame(gse->GetRnrFrame());
344 gsre->SetMiniFrame(gse->GetMiniFrame());
345 gsre->SetShape(gse->GetShape());
348 parent->AddElement(gsre);
350 if (gse->HasElements())
352 TIter next(gse->GetElements());
353 REveGeoShapeExtract* chld;
354 while ((chld = (REveGeoShapeExtract*) next()) !=
nullptr)
355 SubImportShapeExtract(chld, gsre);
367 TClass *REveGeoShape::ProjectedClass(
const REveProjection* p)
const
370 return TClass::GetClass<REvePolygonSetProjected>();
372 return TClass::GetClass<REveGeoShapeProjected>();
379 std::unique_ptr<TBuffer3D> REveGeoShape::MakeBuffer3D()
381 std::unique_ptr<TBuffer3D> buff;
383 if (!fShape)
return buff;
385 if (dynamic_cast<TGeoShapeAssembly*>(fShape)) {
390 REveGeoManagerHolder gmgr(fgGeoManager, fNSegments);
392 buff.reset(fShape->MakeBuffer3D());
393 REveTrans &mx = RefMainTrans();
394 if (mx.GetUseTrans()) {
395 Int_t n = buff->NbPnts();
396 Double_t *pnts = buff->fPnts;
397 for(Int_t k = 0; k < n; ++k) {
398 mx.MultiplyIP(&pnts[3*k]);
417 REveGeoShapeProjected::REveGeoShapeProjected() :
418 REveShape(
"REveGeoShapeProjected"),
426 REveGeoShapeProjected::~REveGeoShapeProjected()
438 void REveGeoShapeProjected::SetDepthLocal(Float_t )
440 Warning(
"SetDepthLocal",
"This function only exists to fulfill an abstract interface.");
446 void REveGeoShapeProjected::SetProjection(REveProjectionManager* mng,
447 REveProjectable* model)
449 REveProjected::SetProjection(mng, model);
451 REveGeoShape* gre =
dynamic_cast<REveGeoShape*
>(fProjectable);
458 void REveGeoShapeProjected::UpdateProjection()
460 REveGeoShape *gre =
dynamic_cast<REveGeoShape*
>(fProjectable);
461 REveProjection *prj = fManager->GetProjection();
463 fBuff = gre->MakeBuffer3D();
467 fBuff->SetSectionsValid(TBuffer3D::kCore | TBuffer3D::kRawSizes | TBuffer3D::kRaw);
469 Double_t *p = fBuff->fPnts;
470 for (UInt_t i = 0; i < fBuff->NbPnts(); ++i, p+=3)
472 prj->ProjectPointdv(p, 0);
482 void REveGeoShapeProjected::ComputeBBox()
484 if (fBuff && fBuff->NbPnts() > 0)
488 Double_t *p = fBuff->fPnts;
489 for (UInt_t i = 0; i < fBuff->NbPnts(); ++i, p+=3)
491 BBoxCheckPoint(p[0], p[1], p[2]);