Skip to content
Snippets Groups Projects
Commit f36b2019 authored by Riccardo Maria Bianchi's avatar Riccardo Maria Bianchi :sunny:
Browse files

Update GMCAT to use the new GeoModelIO.

parent 234c9fc1
No related branches found
No related tags found
No related merge requests found
Pipeline #1699921 failed
...@@ -31,21 +31,21 @@ int main(int argc, char ** argv) { ...@@ -31,21 +31,21 @@ int main(int argc, char ** argv) {
// //
// Usage message: // Usage message:
// //
std::string gmcat= argv[0]; std::string gmcat= argv[0];
std::string usage= "usage: " + gmcat + " [plugin1"+shared_obj_extension std::string usage= "usage: " + gmcat + " [plugin1"+shared_obj_extension
+ "] [plugin2" + shared_obj_extension + "] [plugin2" + shared_obj_extension
+ "] ...[file1.db] [file2.db].. -o outputFile]"; + "] ...[file1.db] [file2.db].. -o outputFile]";
// //
// Print usage message if no args given: // Print usage message if no args given:
// //
if (argc==1) { if (argc==1) {
std::cerr << usage << std::endl; std::cerr << usage << std::endl;
return 0; return 0;
} }
// //
// Parse the command line: // Parse the command line:
// //
std::vector<std::string> inputFiles; std::vector<std::string> inputFiles;
std::vector<std::string> inputPlugins; std::vector<std::string> inputPlugins;
std::string outputFile; std::string outputFile;
...@@ -88,21 +88,21 @@ int main(int argc, char ** argv) { ...@@ -88,21 +88,21 @@ int main(int argc, char ** argv) {
} }
} }
// //
// Create elements and materials: // Create elements and materials:
// //
const double gr = SYSTEM_OF_UNITS::gram; const double gr = SYSTEM_OF_UNITS::gram;
const double mole = SYSTEM_OF_UNITS::mole; const double mole = SYSTEM_OF_UNITS::mole;
const double cm3 = SYSTEM_OF_UNITS::cm3; const double cm3 = SYSTEM_OF_UNITS::cm3;
// Define the chemical elements // Define the chemical elements
GeoElement* Nitrogen = new GeoElement ("Nitrogen" ,"N" , 7.0 , 14.0067 *gr/mole); GeoElement* Nitrogen = new GeoElement ("Nitrogen" ,"N" , 7.0 , 14.0067 *gr/mole);
GeoElement* Oxygen = new GeoElement ("Oxygen" ,"O" , 8.0 , 15.9995 *gr/mole); GeoElement* Oxygen = new GeoElement ("Oxygen" ,"O" , 8.0 , 15.9995 *gr/mole);
GeoElement* Argon = new GeoElement ("Argon" ,"Ar" , 18.0 , 39.948 *gr/mole); GeoElement* Argon = new GeoElement ("Argon" ,"Ar" , 18.0 , 39.948 *gr/mole);
GeoElement* Hydrogen = new GeoElement ("Hydrogen" ,"H" , 1.0 , 1.00797 *gr/mole); GeoElement* Hydrogen = new GeoElement ("Hydrogen" ,"H" , 1.0 , 1.00797 *gr/mole);
double densityOfAir=0.001214 *gr/cm3; double densityOfAir=0.001214 *gr/cm3;
GeoMaterial *air = new GeoMaterial("Air", densityOfAir); GeoMaterial *air = new GeoMaterial("Air", densityOfAir);
air->add(Nitrogen , 0.7494); air->add(Nitrogen , 0.7494);
...@@ -131,26 +131,25 @@ int main(int argc, char ** argv) { ...@@ -131,26 +131,25 @@ int main(int argc, char ** argv) {
} }
factory->create(world); factory->create(world);
} }
// //
// Loop over files, create the geometry and put it under the world: // Loop over files, create the geometry and put it under the world:
// //
for (const std::string & file : inputFiles) { for (const std::string & file : inputFiles) {
QString fString=file.c_str(); GMDBManager* db = new GMDBManager(file);
GMDBManager* db = new GMDBManager(fString); if (!db->checkIsDBOpen()){
if (!db->isOpen()){
std::cerr << "Error opening input file " << file << std::endl; std::cerr << "Error opening input file " << file << std::endl;
return 6; return 6;
} }
/* set the GeoModel reader */ /* set the GeoModel reader */
GeoModelIO::ReadGeoModel readInGeo = GeoModelIO::ReadGeoModel(db); GeoModelIO::ReadGeoModel readInGeo = GeoModelIO::ReadGeoModel(db);
/* build the GeoModel geometry */ /* build the GeoModel geometry */
GeoPhysVol* dbPhys = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory GeoPhysVol* dbPhys = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory
GeoVolumeCursor aV(dbPhys); GeoVolumeCursor aV(dbPhys);
while (!aV.atEnd()) { while (!aV.atEnd()) {
GeoNameTag *nameTag=new GeoNameTag(aV.getName()); GeoNameTag *nameTag=new GeoNameTag(aV.getName());
GeoTransform *transform= new GeoTransform(aV.getTransform()); GeoTransform *transform= new GeoTransform(aV.getTransform());
...@@ -164,11 +163,11 @@ int main(int argc, char ** argv) { ...@@ -164,11 +163,11 @@ int main(int argc, char ** argv) {
// //
// Open a new database: // Open a new database:
// //
GMDBManager db(outputFile.c_str()); GMDBManager db(outputFile);
// //
// check the DB connection // check the DB connection
// //
if (!db.isOpen()) { if (!db.checkIsDBOpen()) {
std::cerr << "Error opening output file " << outputFile << std::endl; std::cerr << "Error opening output file " << outputFile << std::endl;
return 7; return 7;
} }
...@@ -176,10 +175,9 @@ int main(int argc, char ** argv) { ...@@ -176,10 +175,9 @@ int main(int argc, char ** argv) {
GeoModelIO::WriteGeoModel dumpGeoModelGraph(db); GeoModelIO::WriteGeoModel dumpGeoModelGraph(db);
world->exec(&dumpGeoModelGraph); world->exec(&dumpGeoModelGraph);
dumpGeoModelGraph.saveToDB(); dumpGeoModelGraph.saveToDB();
world->unref(); world->unref();
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment