Re: Re: Different displays of TGeo Union in TPad/X3D and OpenGL

From: Brett Viren <bv_at_bnl.gov>
Date: Thu, 15 Feb 2007 11:54:28 -0500


Andrei Gheata <Andrei.Gheata_at_cern.ch> writes:

> No, this is not a feature, but a bug related to the visualization of
> this shape in GL. Visualization of TGeo composite shapes was
> implemented quite long ago by Timur Pocheptsov (the end remark in the
> class docs is no longer valid). Looks like some matrix it passed in a
> wrong way to GL interface, this is why you see the gap. I wonder if
> Timur can look into it. A geometry definition made with a simple macro
> (not by conversion via VGM) would also help.

I believe the appended macro should produce an equivalent geometry, or at least equivalent to the one I intended. It does NOT show the OpenGL artifact. So it does look like I have a bug in my geometry generation that only tickles OpenGL.

-Brett.

// --------------------------------------------------

void pmt() {

    const double pi = 3.14159268;

    const double bulb_radius = 125;
    const double bulb_thickness = 10;
    const double bulb_offset = 50; // dist between sphere centers

    const double base_radius = 50;

    const double base_thickness = bulb_thickness;     const double base_half_height = 35;

    const double base_offset =

	bulb_offset - base_half_height
	- sqrt(bulb_radius*bulb_radius-base_radius*base_radius);
    const double bulb_angle = 180/pi*acos(bulb_offset/bulb_radius);     const double base_angle = 180/pi*asin(base_radius/bulb_radius);

    gSystem->Load("libGeom");
    new TGeoManager("world","Union test");     TGeoMaterial *mat = new TGeoMaterial ("Vacuum",0,0,0);     TGeoMedium *med = new TGeoMedium("Vacuum",1,mat);     

    TGeoVolume* top = gGeoManager->MakeBox("Top",med,200,200,200);     gGeoManager->SetTopVolume(top);

    TGeoSphere* bulb = new TGeoSphere("BULB",

				      bulb_radius-bulb_thickness,
				      bulb_radius,
				      0,bulb_angle,
				      0,360);

    cerr << "bulb: (0 --> " << bulb_angle << ")\n";

    TGeoSphere* butt = new TGeoSphere("BUTT",

				      bulb_radius-bulb_thickness,
				      bulb_radius,
				      180-bulb_angle,180-base_angle,
				      0,360);

    cerr << "butt: (" << 180-bulb_angle << " --> " << 180-base_angle << ")\n";

    TGeoTube* base = new TGeoTube("BASE",

				  base_radius-base_thickness,
				  base_radius,
				  base_half_height);


    TGeoTranslation* tbulb = new TGeoTranslation("B",0,0,-bulb_offset);     tbulb->RegisterYourself();
    TGeoTranslation* tbutt = new TGeoTranslation("T",0,0,+bulb_offset);     tbutt->RegisterYourself();
    TGeoTranslation* tbase = new TGeoTranslation("E",0,0,+base_offset);     tbase->RegisterYourself();

    TGeoCompositeShape* pmt = new TGeoCompositeShape("PMT","BULB:B+BUTT:T+BASE:E");

    TGeoVolume* pmt_vol = new TGeoVolume("PMT",pmt);     pmt_vol->SetLineColor(2);
    top->AddNode(pmt_vol,1);

    gGeoManager->CloseGeometry();
    top->SetLineColor(4);
    //gGeoManager->SetTopVisible();
    top->Draw();
} Received on Thu Feb 15 2007 - 17:54:35 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 15 2007 - 23:50:01 CET