我正在尝试为在 Geant4 中重命名为 TrackerLogical 的 LogicalVolume 添加颜色。我收到 fVisAttributes 和 visAttributes 未定义的错误,尽管我已在 #include 部分将它们定义为 .hh 文件。
我使用的主要框架是 exampleB1 的框架,我试图通过应用 G4VisAttributes 使用 exampleB5 的方法添加颜色。我将此称为指南:https ://github.com/Geant4/geant4/blob/master/examples/basic/B5/src/B5DetectorConstruction.cc
如示例 B5 所示,我在 #include 部分中包含了必要的位,并在 B1DetectorConstruction::B1DetectorConstruction() 部分中包含了 fVisAttributes 行,但是在添加以下部分后运行 -jN 时出现错误消息最后一行之前的代码(return physWorld):
visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9));
visAttributes->SetVisibility(false);
trackerLogical->SetVisAttributes(visAttributes);
fVisAttributes.push_back(visAttributes);
这是我收到的错误消息:
home/neha/G4WORk/B1/src/B1DetectorConstruction.cc: In constructor ‘B1DetectorConstruction::B1DetectorConstruction()’:
/home/neha/G4WORk/B1/src/B1DetectorConstruction.cc:53:3: error: class ‘B1DetectorConstruction’ does not have any field named ‘fVisAttributes’
53 | fVisAttributes()
| ^~~~~~~~~~~~~~
/home/neha/G4WORk/B1/src/B1DetectorConstruction.cc: In member function ‘virtual G4VPhysicalVolume* B1DetectorConstruction::Construct()’:
/home/neha/G4WORk/B1/src/B1DetectorConstruction.cc:202:2: error: ‘visAttributes’ was not declared in this scope; did you mean ‘G4VisAttributes’?
202 | visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9));
| ^~~~~~~~~~~~~
| G4VisAttributes
/home/neha/G4WORk/B1/src/B1DetectorConstruction.cc:205:2: error: ‘fVisAttributes’ was not declared in this scope; did you mean ‘G4VisAttributes’?
205 | fVisAttributes.push_back(visAttributes);
| ^~~~~~~~~~~~~~
| G4VisAttributes
make[2]: *** [CMakeFiles/exampleB1.dir/build.make:89: CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/exampleB1.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
是什么导致了这个问题,我该如何解决这个问题?我仍然是 Geant4 的初学者,可能需要一些基本的解释(最好用简单/外行的术语)。谢谢!