Divided node path of a TGeoVolume

thank you so much, Andrei. That works!

Actually, the next step is to set different colors of individual ‘cells’ split by “geovolume->Divide(…)”. I looked through your post replies at:
[url]Q: Is there any way to get pointer to a node by using path?
and it addressed that it is not possible to set different colors. However, by using TGeoIteratorPlugin, it did the trick. I try to use the following code


  TGeoManager * gGeoManager = new TGeoManager("top","");
  TGeoVolume *vbox = gGeoManager->MakeBox("vbox", 0, 20,30,40);
  gGeoManager->SetTopVolume(vbox);

  cout << gGeoManager->AddVolume(vbox) << endl;
  vbox->Draw("ogl");

  TView *view = gPad->GetView();  
  view->ShowAxis();
  
  TGeoVolume *divx = (TGeoVolume *)vbox->Divide("SLICEX",1, 5, -10, 2);
  TGeoVolume *divy = (TGeoVolume *)divx->Divide("SLICEY",2, 20, -10, 2);
  TGeoVolume *divz = (TGeoVolume *)divy->Divide("SLICEZ",3, 20, -10, 2);
  gGeoManager->CloseGeometry();

  gPad->Update();
  gPad->Modified();

  iterplugin *plugin = new iterplugin();
  cout << "Total nodes: " << divy->GetNtotal() << endl;

  TGeoNode *node;
  int index = 0;
  TString name("/vbox_1/SLICEX_5/SLICEY_20/SLICEZ_20");
  gGeoManager->cd(name.Data());
  TGeoIterator * next = new TGeoIterator(gGeoManager->GetCurrentNode()->GetVolume());
  gGeoManager->GetGeomPainter()->SetIteratorPlugin(plugin);
  plugin->SetIterator(next);
  plugin->Select(2);
  gGeoManager->GetGeomPainter()->ModifiedPad();  
}

with the attached modified class “iterplugin”. However, it is not successful. Could you give me some hints why it failed?

Thank you,
Zhiyi.
iterplugin_zyliu.cxx (921 Bytes)