Question about SetVisAttributes of support_log and segmentation error problem.
Hi,
In VisualizationGeant4Module.cpp at line 412-420, the visualization attributes of the support layers are applied.
auto supports_log = detector->getExternalObject<std::vector<std::shared_ptr<G4LogicalVolume>>>("supports_log");
for(auto& support_log : *supports_log) {
support_log->SetVisAttributes(supportVisAtt);
}
auto support_log = detector->getExternalObject<G4LogicalVolume>("support_log");
if(support_log != nullptr) {
support_log->SetVisAttributes(supportVisAtt);
}
Is there a specific reason why there are there two different support_log objects which get initialized? I tried to figure out the use of the bottom support_log, but I coulnd't find it (it doesn't give the VisAttributes to even a single support layer).
Also, the for(auto& support_log : *supports_log)
gives a segmentation error for detectors without a definition of it's support layer.
It works fine if your model (like timepix.conf) has no support layer specified, but if you don't define your
auto supports_log = std::make_shared<std::vector<std::shared_ptr<G4LogicalVolume>>>();
....
....
....
detector->setExternalObject("supports_log", supports_log);
in the GeometryConstructionG4.cpp, your code will give a segmentation error for this detector in VisualizationGeant4.
This problem can be fixed by adding a if(supports_log != nullptr)
statement to the top code, but I wanted to know both things before I started a merge request.