27 namespace REX = ROOT::Experimental;
29 REX::REveGeoPolyShape *eve_pshape =
nullptr;
30 REX::REveGeoShape *eve_shape =
nullptr;
38 if (gGeoManager)
delete gGeoManager;
40 new TGeoManager(
"xtru",
"poza12");
41 TGeoMaterial *mat =
new TGeoMaterial(
"Al", 26.98,13,2.7);
42 TGeoMedium *med =
new TGeoMedium(
"MED",1,mat);
43 TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
44 gGeoManager->SetTopVolume(top);
47 TGeoBBox *box =
new TGeoBBox(
"box", 20., 20., 20.);
48 TGeoBBox *box1 =
new TGeoBBox(
"box1", 5., 5., 5.);
49 TGeoSphere *sph =
new TGeoSphere(
"sph", 5., 25.);
50 TGeoSphere *sph1 =
new TGeoSphere(
"sph1", 1., 15.);
52 TGeoTranslation *tr =
new TGeoTranslation(0., 30., 0.);
53 TGeoTranslation *tr1 =
new TGeoTranslation(0., 40., 0.);
54 TGeoTranslation *tr2 =
new TGeoTranslation(0., 30., 0.);
55 TGeoTranslation *tr3 =
new TGeoTranslation(0., 30., 0.);
61 tr->RegisterYourself();
62 tr1->RegisterYourself();
63 tr2->RegisterYourself();
64 tr3->RegisterYourself();
66 auto cs =
new TGeoCompositeShape(
"mir",
"(sph * box) + (sph1:tr - box1:tr1)");
68 TGeoVolume *vol =
new TGeoVolume(
"COMP4", cs);
69 vol->SetLineColor(kMagenta);
71 gGeoManager->CloseGeometry();
77 REX::REveManager::Create();
79 REX::REveGeoPolyShape::SetAutoEnforceTriangles(
true);
81 auto node = gGeoManager->GetTopNode();
82 auto geo_cshape =
dynamic_cast<TGeoCompositeShape*
>(node->GetDaughter(0)->GetVolume()->GetShape());
84 if (!geo_cshape)
throw std::runtime_error(
"The first vshape is not a CSG shape.");
86 bool poly_first =
false;
89 eve_pshape =
new REX::REveGeoPolyShape;
90 eve_pshape->BuildFromComposite(geo_cshape, 40);
92 eve_shape =
new REX::REveGeoShape(
"CSG_Result");
93 eve_shape->SetShape(eve_pshape);
97 eve_shape =
new REX::REveGeoShape(
"CSG_Result");
98 eve_shape->SetNSegments(40);
99 eve_shape->SetShape(geo_cshape);
101 eve_pshape =
dynamic_cast<REX::REveGeoPolyShape*
>(eve_shape->GetShape());
103 eve_shape->SetMainColor(kMagenta);
108 eve_pshape->Draw(
"ogl");
110 eve_shape->SaveExtract(
"csg.root",
"CSG Demo");