Problem with translation and rotation of obj parts - TGeoManager

Dear all,

I have been cracking my head for the last couple of days with this issue. Finally gave up and trying to ask here:

I have a bunch of parts in .obj format, and I’m using TGeoTessellated::ImportFromObjFormat to upload them to TGeoManager. All the information for each part (name, mother, type [assembly or part], colors, translation, rotation) is contained in a text file that I read inside my code. My rationale for adding each to the geometry is the following:

TGeoVolume *volume;
if(type == "ASSEMBLY"){
    volume = new TGeoVolume(part, shape, Vacuum);
    volume->SetVisibility(kFALSE);
}
else if(type == "PART"){
    volume = new TGeoVolume(part, shape, Aluminium);
    volume->SetFillColor(colorIndex);
}

if(mother == "NONE"){
    world->AddNode(volume, 1, new TGeoTranslation(0.0, 0.0, 0.0));
}
else{
    gGeoManager->GetVolume(mother)->AddNode(
        volume, 1, TGeoTranslation(0.0, 0.0, 0.0));
        }

I’m not adding any translation or rotation as it seems that each of the obj files has it’s transformations embedded (they do not show up in the origin of the geometry). The thing is that the geometry ends up getting completely scrambled. I do have the translation and rotation elements of the parts (global values i.e. values in “world”), but when I add them in TGeoTranslation or TGeoCombiTrans, it’s all scrambled again.

The things that I’m not sure of are:

  • When I’m creating a volume that is an assembly for other parts, should I still create it with TGeoVolume? Or TGeoVolumeAssembly?
  • For a given volume, maybe I should add another transformation in regard to its mother so I get the correct positioning?

Super thanks in advance.

_ROOT Version: 6.26
_Platform: GNU/Linux - conda env
_Compiler: 10.4.0-19


Hi,

I am adding in the loop @agheata , our expert of the geometry package.

Best,
D

Hi, this shows how to use assemblies

void teddy_family()
{
   // Input a file in .obj format (https://en.wikipedia.org/wiki/Wavefront_.obj_file)
   // The file should have a single object inside, only vertex and faces information is used

   TString sfile = gROOT->GetTutorialsDir();
   sfile += "/geom/teddy.obj";
   gROOT->GetListOfCanvases()->Delete();
   new TGeoManager("multi_teddy", "Imported from .obj file");
   TGeoMedium *med = new TGeoMedium("MED", 1, new TGeoMaterial());
   TGeoVolume *top = gGeoManager->MakeBox("TOP", med, 50, 50, 50);
   gGeoManager->SetTopVolume(top);

   auto teddy1 = TGeoTessellated::ImportFromObjFormat(sfile.Data());
   teddy1->ResizeCenter(8.);
   auto teddy2 = TGeoTessellated::ImportFromObjFormat(sfile.Data());
   teddy2->ResizeCenter(5.);
   auto teddy3 = TGeoTessellated::ImportFromObjFormat(sfile.Data());
   teddy3->ResizeCenter(10.);

   auto vol1 = new TGeoVolume("teddy1", teddy1, med);
   vol1->SetLineColor(kOrange - 8);
   auto vol2 = new TGeoVolume("teddy2", teddy2, med);
   vol2->SetLineColor(kOrange - 7);
   auto vol3 = new TGeoVolume("teddy3", teddy3, med);
   vol3->SetLineColor(kOrange + 3);

   auto teddy_family = new TGeoVolumeAssembly("teddy_family");
   teddy_family->AddNode(vol1, 1);
   teddy_family->AddNode(vol2, 1, new TGeoTranslation(10, -3, 5));
   teddy_family->AddNode(vol3, 1, new TGeoTranslation(20, 2, 0));

   top->AddNode(teddy_family, 1);

   gGeoManager->CloseGeometry();
   if (!gROOT->IsBatch()) top->Draw("ogl");
}

teddy_family
teddy_family.C (1.8 KB)

1 Like

Thank you very much!

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