Build a box using TGeoHalfSpace

Hello,

I’m trying to build a box using only 6 TGeoHalfSpace (not using others objects like TGeoBBox)… So, I define 6 points and 6 normal vectors. Then using a TGeoCompositeShape (with 5 intersections) I build a TGeoVolume, and finally I build the geometry (see below).

But the result looks strange : I’ve infinite dimensions and nothing to draw.

Does anyone have an idea ?

Thanks in advance,

Julien

#include "TGeoVolume.h"
#include "TGeoManager.h"
#include "TGeoHalfSpace.h"
#include "TGeoCompositeShape.h"

 void test_box()
 {
   //gSystem->Load("libGeom");
     
   ///
   /// Creation du TGeoManager
   ///
   TGeoManager *geom = new TGeoManager("GeoManager", "Geom_box");
   
   TString compos = "composition1" ;
   TGeoMaterial* compo          = new TGeoMaterial (ToUpper(compos),1,1,1);
   TGeoMedium  * Compo          = new TGeoMedium   (ToUpper(compos), 1 , compo) ; 

   compos = "composition2" ;
   TGeoMaterial* compo2          = new TGeoMaterial (ToUpper(compos),1,1,1);
   TGeoMedium  * Compo2          = new TGeoMedium   (ToUpper(compos), 1 , compo2) ; 
     
   ///
   /// Top Volume = World
   ///
   Double_t r_min  = 0.;
   Double_t r_max  = 500.;
   Double_t z_size = 2000.;
   TGeoVolume *world = geom -> MakeTube("World", Compo, r_min, r_max, z_size/2);
   
   Double_t A[3] = { -5., 0., 0. };
   Double_t B[3] = {  5., 0., 0. };
   Double_t C[3] = { 0., -5., 0. };
   Double_t D[3] = { 0.,  5., 0. };
   Double_t E[3] = { 0., 0., -5. };
   Double_t F[3] = { 0., 0.,  5. };
 
   Double_t pA[3] = { -1., 0., 0. };
   Double_t pB[3] = {  1., 0., 0. };
   Double_t pC[3] = {  0., -1., 0.};
   Double_t pD[3] = {  0.,  1., 0.};
   Double_t pE[3] = {  0., 0., -1.};
   Double_t pF[3] = {  0., 0.,  1.};

   /*
   Double_t pA[3] = { 1., 0., 0. };
   Double_t pB[3] = { -1., 0., 0. };
   Double_t pC[3] = {  0., -1., 0. };
   Double_t pD[3] = {  0.,  1., 0.};
   Double_t pE[3] = {  0., 0.,  1.};
   Double_t pF[3] = {  0., 0., -1.};
   */  
    
   TGeoHalfSpace * half1 = new TGeoHalfSpace ("Half1", A, pA);
   TGeoHalfSpace * half2 = new TGeoHalfSpace ("Half2", B, pB);
   TGeoHalfSpace * half3 = new TGeoHalfSpace ("Half3", C, pC);
   TGeoHalfSpace * half4 = new TGeoHalfSpace ("Half4", D, pD);
   TGeoHalfSpace * half5 = new TGeoHalfSpace ("Half5", E, pE);
   TGeoHalfSpace * half6 = new TGeoHalfSpace ("Half6", F, pF);
    
   TGeoCompositeShape *box_shape = new TGeoCompositeShape("Box_shape2", "Half1*Half2*Half3*Half4*Half5*Half6");
   TGeoVolume *box = new TGeoVolume("Box", box_shape, Compo2);
    
   world -> AddNode(box,0);
    
   geom -> SetVisLevel(0) ;
   geom  -> SetTopVolume     (world)       ;
   geom  -> CloseGeometry    ()            ;
   world -> SetVisContainers (kTRUE)       ;
   geom  -> SetTopVisible    (kFALSE)      ;
    
   world -> Draw("") ;
   geom->CheckOverlaps(0.0001) ;
   geom->PrintOverlaps()                   ;
    
   geom->Export("BOX.root"); 
  }

ROOT Version: 6.18.04
_Platform: linuxx8664gcc


Hi @jujuc31,

Maybe @agheata can help here.

Cheers,
J.

Hi,
The shape is valid, but unfortunately, the current utils cannot draw intersections of half-spaces
Cheers,
Andrei

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.