diff --git a/GeoModelExamples/HelloGeoRead/main1.cpp b/GeoModelExamples/HelloGeoRead/main1.cpp index 52412297c496614969aa2ddca6d6f1be061b3563..0d037fd5cf6c9b42c3997fce915ded31b25c80b4 100644 --- a/GeoModelExamples/HelloGeoRead/main1.cpp +++ b/GeoModelExamples/HelloGeoRead/main1.cpp @@ -39,7 +39,7 @@ int main(int argc, char* argv[]) { // Get the 'world' volume from the GeoModel DB std::cout << "Picking the 'World' volume from the geometry DB file..." << std::endl; - GeoVPhysVol *world = GeoModelIO::IO::loadDB(fileName); + const GeoVPhysVol *world = GeoModelIO::IO::loadDB(fileName); if(world == nullptr) { std::cout << "---ERROR! 'World' is a 'nullptr'! exiting...\n\n"; exit(1); diff --git a/GeoModelExamples/HelloGeoRead/main2.cpp b/GeoModelExamples/HelloGeoRead/main2.cpp index 1b31d43068830e515e0fbe446188400b6b5a2cc5..3c34d9c2a9019fd4fdf96935f1626084621f33c1 100644 --- a/GeoModelExamples/HelloGeoRead/main2.cpp +++ b/GeoModelExamples/HelloGeoRead/main2.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) { // Get the 'world' volume from the GeoModel DB std::cout << "Picking the 'World' volume from the geometry DB file..." << std::endl; - GeoVPhysVol *world = GeoModelIO::IO::loadDB(fileName); + const GeoVPhysVol *world = GeoModelIO::IO::loadDB(fileName); std::cout << "'World' volume loaded." << std::endl; if(world == nullptr) { std::cout << "---ERROR! 'World' is a 'nullptr'! exiting...\n\n"; diff --git a/GeoModelExamples/HelloGeoRead/main3.cpp b/GeoModelExamples/HelloGeoRead/main3.cpp index 871ed160f42acf210a9fbb08a7821803aca057a8..f71b81f680580dbc11103ae2d62eab6cac0c0ff5 100644 --- a/GeoModelExamples/HelloGeoRead/main3.cpp +++ b/GeoModelExamples/HelloGeoRead/main3.cpp @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) { /* build the GeoModel tree and load it in memory */ - GeoVPhysVol* world = geoReader.buildGeoModel(); + const GeoVPhysVol* world = geoReader.buildGeoModel(); // --- Reading the properties of the 'world' volume retrieved from the .db file diff --git a/GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMIO.h b/GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMIO.h index d8a4c3a371c972cfed3a7ca1d871149a2cd38754..a854576fad291760f4e284df022d6e0bb71469d7 100644 --- a/GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMIO.h +++ b/GeoModelIO/GeoModelIOHelpers/GeoModelIOHelpers/GMIO.h @@ -19,11 +19,11 @@ class IO { static GMDBManager saveToDB(const GeoVPhysVol* world, const std::string path, unsigned loglevel = 0) { // check if DB file exists. If yes, delete it. - std::ifstream infile(path.c_str()); - if (infile.good()) { + std::ifstream inputfile(path.c_str()); + if (inputfile.good()) { std::remove(path.c_str()); // delete file } - infile.close(); + inputfile.close(); // open the DB connection GMDBManager db(path); @@ -49,7 +49,7 @@ class IO { return db; } - static GeoVPhysVol* loadDB(const std::string path, unsigned loglevel = 0) { + static const GeoVPhysVol* loadDB(const std::string path, unsigned loglevel = 0) { // check if DB file exists. // If not, print a warning message and return a nullptr. std::ifstream inputfile(path.c_str()); @@ -82,7 +82,7 @@ class IO { /* build the GeoModel geometry */ // builds the whole GeoModel tree in memory - GeoVPhysVol* rootVolume = geoReader.buildGeoModel(); + const GeoVPhysVol* rootVolume = geoReader.buildGeoModel(); delete db; db = nullptr; diff --git a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h index f1a3209404d112959fc71decfc5242087575ffbc..d71a76a74b6b20ff31bfb19e9ec1f25ffc298d83 100644 --- a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h +++ b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h @@ -101,7 +101,7 @@ class ReadGeoModel { ReadGeoModel(GMDBManager* db, unsigned long* progress = nullptr); virtual ~ReadGeoModel(); - GeoVPhysVol* buildGeoModel(); + const GeoVPhysVol* buildGeoModel(); /// Set the 'loglevel', that is the level of output messages. /// The loglevel is set to 0 by default, but it can be set diff --git a/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp b/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp index 9c3b62c8ddd4aa65842dde25b36aa6ca185472f3..3cd0838f6b34bd2d0ff1d23efb98a8c2d4c7b33d 100644 --- a/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp +++ b/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp @@ -210,7 +210,7 @@ std::string ReadGeoModel::getEnvVar(std::string const& key) const { return val == NULL ? std::string("") : std::string(val); } -GeoVPhysVol* ReadGeoModel::buildGeoModel() { +const GeoVPhysVol* ReadGeoModel::buildGeoModel() { if (m_loglevel >= 2) std::cout << "ReadGeoModel::buildGeoModel()" << std::endl; diff --git a/GeoModelVisualization/VP1GeometrySystems/src/VP1GeometrySystem.cxx b/GeoModelVisualization/VP1GeometrySystems/src/VP1GeometrySystem.cxx index db261694c49d4c414eacc571c86621c5a75525d2..c88140d15d63969d6f3bd6f41c62aa3ddbb6c2fa 100644 --- a/GeoModelVisualization/VP1GeometrySystems/src/VP1GeometrySystem.cxx +++ b/GeoModelVisualization/VP1GeometrySystems/src/VP1GeometrySystem.cxx @@ -128,7 +128,7 @@ public: //Might be needed later: std::map<GeoPVConstLink,VolumeHandle*> pv2volhandle; GeoVPhysVol* getGeometry(); - GeoVPhysVol* createTheWorld(GeoVPhysVol* world = nullptr); + GeoVPhysVol* createTheWorld(const GeoVPhysVol* world = nullptr); GeoVPhysVol* getGeometryFromLocalDB(); SoTexture2* getDummyTexture(); @@ -502,7 +502,7 @@ GeoVPhysVol* VP1GeometrySystem::Imp::getGeometry() } //_____________________________________________________________________________________ -GeoVPhysVol* VP1GeometrySystem::Imp::createTheWorld(GeoVPhysVol* world) +GeoVPhysVol* VP1GeometrySystem::Imp::createTheWorld(const GeoVPhysVol* world) { if (world == nullptr) { @@ -513,7 +513,7 @@ GeoVPhysVol* VP1GeometrySystem::Imp::createTheWorld(GeoVPhysVol* world) const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, worldMat); world = new GeoPhysVol(worldLog); } - return world; + return const_cast<GeoVPhysVol*>(world); } @@ -572,7 +572,7 @@ GeoVPhysVol* VP1GeometrySystem::Imp::getGeometryFromLocalDB() GeoModelIO::ReadGeoModel readInGeo = GeoModelIO::ReadGeoModel(db); /* build the GeoModel geometry */ - GeoVPhysVol* dbPhys = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory + const GeoVPhysVol* dbPhys = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory if (world) {