I have a TGeoVolumeAssembly built from various obj files, for which I use the TGeoTessellated::ImportFromObjFormat() method. Is there a method to recenter the full assembly to the origin of the world geometry?
I tried finding a BoundingBox method, so I could get the center and work from there, but couldn’t find anything related to that.
Hello,
I don’t know much about the geometry interface but it looks to me like you need to play with the fLocalMaster field of TBuffer3D to translate the whole geometry rigidly. I don’t think you can change directly the shape’s local coordinates themselves.
But I might be wrong and @agheata can definitely give you a more accurate answer.
Hi,
Once imported from .obj, you can center and rescale the tessellated object to a different size. The object vertices will be recalculated such that the new bounding box will be in (0, 0, 0), and the maximum size of the new bounding box on any axis will match the value you pass to TGeoTessellated::ResizeCenter(double maxsize). There is no way to center in a different origin; you will need to create a volume out of this object and place it where you want in the top geometry volume. Like:
auto top = new TGeoVolume("world", new TGeoBBox(1000., 1000., 1000.), medium);
auto tsl = new TGeoVolume("tessellated", your_imported_obj, other_medium);
top->AddNode(tsl, 1, new TGeoTranslation(100., 0., 0.));
gGeoManager->SetTopVolume(top);
top->CloseGeometry();
Edited: Just realized you want to move the ful assembly, just do: top→AddNode(assembly, 1, new TGeoTranslation(…));