From 79769838d18d8eea9070d07b23614ea7247e0514 Mon Sep 17 00:00:00 2001 From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch> Date: Fri, 31 May 2024 12:33:08 +0200 Subject: [PATCH] Add UnidentifiedShape to new DB schema and I/O --- ...ep1_create_store_geo_and_publish_nodes.cpp | 10 ++++ .../GeoModelDBManager/src/GMDBManager.cpp | 19 +++++++ .../GeoModelRead/GeoModelRead/ReadGeoModel.h | 12 ++--- .../GeoModelRead/src/BuildGeoShapes_Box.cpp | 10 ++-- .../src/BuildGeoShapes_UnidentifiedShape.cpp | 35 +++++++++++++ .../src/BuildGeoShapes_UnidentifiedShape.h | 28 +++++++++++ GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp | 50 ++++++++++++++++--- GeoModelIO/GeoModelWrite/CMakeLists.txt | 2 +- .../GeoModelWrite/WriteGeoModel.h | 4 ++ .../GeoModelWrite/src/WriteGeoModel.cpp | 46 ++++++++++++----- 10 files changed, 182 insertions(+), 34 deletions(-) create mode 100644 GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp create mode 100644 GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h diff --git a/GeoModelExamples/HelloToy/step1_create_store_geo_and_publish_nodes.cpp b/GeoModelExamples/HelloToy/step1_create_store_geo_and_publish_nodes.cpp index e78e377a8..f99792ae8 100644 --- a/GeoModelExamples/HelloToy/step1_create_store_geo_and_publish_nodes.cpp +++ b/GeoModelExamples/HelloToy/step1_create_store_geo_and_publish_nodes.cpp @@ -25,6 +25,7 @@ #include "GeoModelKernel/GeoSimplePolygonBrep.h" #include "GeoModelKernel/GeoPcon.h" #include "GeoModelKernel/GeoPgon.h" +#include "GeoModelKernel/GeoUnidentifiedShape.h" #include "GeoModelKernel/GeoShapeShift.h" #include "GeoModelKernel/GeoShapeIntersection.h" @@ -430,6 +431,15 @@ int main(int argc, char *argv[]) + // Add a test "UnidentifiedShape" shape node + const std::string nameUnidentifiedShape = "LAr::Example"; + GeoUnidentifiedShape* sUnidentifiedShape = new GeoUnidentifiedShape("LArCustomShape",nameUnidentifiedShape); + GeoLogVol* lUnidentifiedShape = new GeoLogVol("UnidentifiedShape", sUnidentifiedShape, steel); + GeoPhysVol *pUnidentifiedShape = new GeoPhysVol(lUnidentifiedShape); + GeoNameTag *nUnidentifiedShape = new GeoNameTag("UnidentifiedShape"); + toyPhys->add(nUnidentifiedShape); + toyPhys->add(pUnidentifiedShape); + diff --git a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp index 1dbf6fb0b..efa6b441d 100644 --- a/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp +++ b/GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp @@ -2128,6 +2128,25 @@ bool GMDBManager::createTables() { } tab.clear(); + // Shapes-Box table + // ID, XHalfLength, YHalfLength, ZHalfLength + geoNode = "GeoUnidentifiedShape"; + tableName = "Shapes_UnidentifiedShape"; + m_childType_tableName[geoNode] = tableName; + tab.push_back(tableName); + tab.push_back("id"); + tab.push_back("computedVolume"); + tab.push_back("name"); + tab.push_back("asciiData"); + storeTableColumnNames(tab); + queryStr = fmt::format( + "create table {0}({1} integer primary key, {2} real, {3} varchar, {4} varchar )", + tab[0], tab[1], tab[2], tab[3], tab[4]); + if (0 == (rc = execQuery(queryStr))) { + storeNodeType(geoNode, tableName); + } + tab.clear(); + // SerialDenominators table geoNode = "GeoSerialDenominator"; tableName = "SerialDenominators"; diff --git a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h index d30fa9ac8..993198e63 100644 --- a/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h +++ b/GeoModelIO/GeoModelRead/GeoModelRead/ReadGeoModel.h @@ -96,10 +96,10 @@ class BuildGeoShapes_Trap; class BuildGeoShapes_Trd; class BuildGeoShapes_Tubs; class BuildGeoShapes_TwistedTrap; - class BuildGeoShapes_Pcon; class BuildGeoShapes_Pgon; class BuildGeoShapes_SimplePolygonBrep; +class BuildGeoShapes_UnidentifiedShape; // type definitions typedef const GeoXF::Function& TRANSFUNCTION; @@ -178,6 +178,7 @@ class ReadGeoModel { }; private: + void buildAllShapes(); // TODO: OLD METHOD, TO BE REMOVED WHEN READY void buildAllShapes_Box(); void buildAllShapes_Tube(); void buildAllShapes_Cons(); @@ -186,15 +187,13 @@ class ReadGeoModel { void buildAllShapes_Trd(); void buildAllShapes_Tubs(); void buildAllShapes_TwistedTrap(); - void buildAllShapes_Pcon(); void buildAllShapes_Pgon(); void buildAllShapes_SimplePolygonBrep(); - + void buildAllShapes_UnidentifiedShape(); void buildAllShapes_Operators(); - void buildAllShapes(); void buildAllElements(); void buildAllMaterials(); void buildAllLogVols(); @@ -384,11 +383,10 @@ class ReadGeoModel { BuildGeoShapes_Trd* m_builderShape_Trd; BuildGeoShapes_Tubs* m_builderShape_Tubs; BuildGeoShapes_TwistedTrap* m_builderShape_TwistedTrap; - BuildGeoShapes_Pcon* m_builderShape_Pcon; BuildGeoShapes_Pgon* m_builderShape_Pgon; BuildGeoShapes_SimplePolygonBrep* m_builderShape_SimplePolygonBrep; - + BuildGeoShapes_UnidentifiedShape* m_builderShape_UnidentifiedShape; //! containers to store the list of GeoModel nodes coming from the DB std::vector<std::vector<std::string>> m_physVols; @@ -417,10 +415,10 @@ class ReadGeoModel { DBRowsList m_shapes_Trd; DBRowsList m_shapes_Tubs; DBRowsList m_shapes_TwistedTrap; - DBRowsList m_shapes_Pcon; DBRowsList m_shapes_Pgon; DBRowsList m_shapes_SimplePolygonBrep; + DBRowsList m_shapes_UnidentifiedShape; // containers to store shapes' data, // for those shapes with a variable number of build parameters diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp index e352753e0..bd9176330 100644 --- a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_Box.cpp @@ -19,13 +19,13 @@ void BuildGeoShapes_Box::buildShape(const std::vector<std::variant<int, long, fl { // === get shape numeric data from the DB row // shape ID - const unsigned shapeId = GeoModelHelpers::variantHelper::getFromVariant_Int(row[0], "Tube:shapeID"); + const unsigned shapeId = GeoModelHelpers::variantHelper::getFromVariant_Int(row[0], "Box:shapeID"); // shape volume - const double shapeVolume = GeoModelHelpers::variantHelper::getFromVariant_Double(row[1], "Tube:shapeVolume"); + const double shapeVolume = GeoModelHelpers::variantHelper::getFromVariant_Double(row[1], "Box:shapeVolume"); // shape parameters - const double XHalfLength = GeoModelHelpers::variantHelper::getFromVariant_Double(row[2], "Tube:XHalfLength"); - const double YHalfLength = GeoModelHelpers::variantHelper::getFromVariant_Double(row[3], "Tube:YHalfLength"); - const double ZHalfLength = GeoModelHelpers::variantHelper::getFromVariant_Double(row[4], "Tube:ZHalfLength"); + const double XHalfLength = GeoModelHelpers::variantHelper::getFromVariant_Double(row[2], "Box:XHalfLength"); + const double YHalfLength = GeoModelHelpers::variantHelper::getFromVariant_Double(row[3], "Box:YHalfLength"); + const double ZHalfLength = GeoModelHelpers::variantHelper::getFromVariant_Double(row[4], "Box:ZHalfLength"); GeoBox *shape = new GeoBox(XHalfLength, YHalfLength, ZHalfLength); diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp new file mode 100644 index 000000000..ef31a5811 --- /dev/null +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.cpp @@ -0,0 +1,35 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +/* + * Created on: May 7, 2024 + * Author: Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch> + */ + +#include "BuildGeoShapes_UnidentifiedShape.h" + +#include "GeoModelKernel/GeoUnidentifiedShape.h" +#include "GeoModelHelpers/variantHelpers.h" + +#include <vector> +#include <iostream> + +void BuildGeoShapes_UnidentifiedShape::buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) +{ + // === get shape numeric data from the DB row + // shape ID + const unsigned shapeId = GeoModelHelpers::variantHelper::getFromVariant_Int(row[0], "UnidentifiedShape:shapeID"); + // shape volume + const double shapeVolume = GeoModelHelpers::variantHelper::getFromVariant_Double(row[1], "UnidentifiedShape:shapeVolume"); + // shape parameters + const std::string type = GeoModelHelpers::variantHelper::getFromVariant_String(row[2], "UnidentifiedShape:type"); + const std::string name = GeoModelHelpers::variantHelper::getFromVariant_String(row[2], "UnidentifiedShape:name"); + + GeoUnidentifiedShape *shape = new GeoUnidentifiedShape(type, name); + + storeBuiltShape(shapeId, shape); + + // return shape; + return; +} diff --git a/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h new file mode 100644 index 000000000..d076b39a2 --- /dev/null +++ b/GeoModelIO/GeoModelRead/src/BuildGeoShapes_UnidentifiedShape.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +/* + * BuildGeoShapes_UnidentifiedShape.h + * + * Created on: May 7, 2024 + * Author: Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch> + * + */ + +#ifndef GEOMODELREAD_BUILDGEOSHAPES_UnidentifiedShape_H +#define GEOMODELREAD_BUILDGEOSHAPES_UnidentifiedShape_H + +#include "BuildGeoShapes.h" + +#include <vector> +#include <variant> + +class BuildGeoShapes_UnidentifiedShape : public BuildGeoShapes +{ +public: + BuildGeoShapes_UnidentifiedShape(const unsigned size):BuildGeoShapes("UnidentifiedShape", size){}; + void buildShape(const std::vector<std::variant<int, long, float, double, std::string>> row) override; +}; + +#endif diff --git a/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp b/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp index 43bb3e963..605e32432 100644 --- a/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp +++ b/GeoModelIO/GeoModelRead/src/ReadGeoModel.cpp @@ -39,6 +39,7 @@ #include "BuildGeoShapes_Tubs.h" #include "BuildGeoShapes_TwistedTrap.h" #include "BuildGeoShapes_SimplePolygonBrep.h" +#include "BuildGeoShapes_UnidentifiedShape.h" #include "GeoModelRead/ReadGeoModel.h" @@ -233,6 +234,7 @@ ReadGeoModel::~ReadGeoModel() { delete m_builderShape_Tubs; delete m_builderShape_TwistedTrap; delete m_builderShape_SimplePolygonBrep; + delete m_builderShape_UnidentifiedShape; m_builderShape_Box = nullptr; m_builderShape_Tube = nullptr; m_builderShape_Pcon = nullptr; @@ -243,6 +245,7 @@ ReadGeoModel::~ReadGeoModel() { m_builderShape_Tubs = nullptr; m_builderShape_TwistedTrap = nullptr; m_builderShape_SimplePolygonBrep = nullptr; + m_builderShape_UnidentifiedShape = nullptr; } // FIXME: TODO: move to an utility class @@ -311,6 +314,7 @@ void ReadGeoModel::loadDB() { m_shapes_Pcon = m_dbManager->getTableFromNodeType_VecVecData("GeoPcon"); m_shapes_Pgon = m_dbManager->getTableFromNodeType_VecVecData("GeoPgon"); m_shapes_SimplePolygonBrep = m_dbManager->getTableFromNodeType_VecVecData("GeoSimplePolygonBrep"); + m_shapes_UnidentifiedShape = m_dbManager->getTableFromNodeType_VecVecData("GeoUnidentifiedShape"); // shapes' data, when needed by shapes that have variable numbers of build parameters m_shapes_Pcon_data = m_dbManager->getTableFromTableName_VecVecData("Shapes_Pcon_Data"); @@ -368,7 +372,7 @@ GeoVPhysVol* ReadGeoModel::buildGeoModelPrivate() { t9.join(); // ok, all AlignableTransforms have been built // needs Transforms and AlignableTransforms for Shift boolean shapes - // std::thread t1(&ReadGeoModel::buildAllShapes, this); + // std::thread t1(&ReadGeoModel::buildAllShapes, this); // TODO: old, to be removed std::thread t15(&ReadGeoModel::buildAllShapes_Box, this); std::thread t16(&ReadGeoModel::buildAllShapes_Tube, this); std::thread t17(&ReadGeoModel::buildAllShapes_Pcon, this); @@ -380,10 +384,11 @@ GeoVPhysVol* ReadGeoModel::buildGeoModelPrivate() { std::thread t23(&ReadGeoModel::buildAllShapes_Tubs, this); std::thread t24(&ReadGeoModel::buildAllShapes_TwistedTrap, this); std::thread t25(&ReadGeoModel::buildAllShapes_SimplePolygonBrep, this); + std::thread t26(&ReadGeoModel::buildAllShapes_UnidentifiedShape, this); t2.join(); // ok, all Elements have been built - // needs Elements + // This below needs Elements to be built std::thread t3(&ReadGeoModel::buildAllMaterials, this); // t1.join(); // ok, all Shapes have been built @@ -398,10 +403,12 @@ GeoVPhysVol* ReadGeoModel::buildGeoModelPrivate() { t23.join(); // ok, all Shapes-Tubs have been built t24.join(); // ok, all Shapes-TwistedTrap have been built t25.join(); // ok, all Shapes-SimplePolygonBrep have been built + t26.join(); // ok, all Shapes-UnidentifiedShape have been built - // Needs more primitive shapes: - std::thread t26(&ReadGeoModel::buildAllShapes_Operators, this); - t26.join(); // ok, all Shapes-Operators have been built + // Build boolean shapes and shape operators, + // this needs Shapes to be built + std::thread t99(&ReadGeoModel::buildAllShapes_Operators, this); + t99.join(); // ok, all Shapes-Operators have been built t3.join(); // ok, all Materials have been built // needs Shapes and Materials @@ -442,6 +449,7 @@ GeoVPhysVol* ReadGeoModel::buildGeoModelPrivate() { buildAllShapes_Pcon(); buildAllShapes_Pgon(); buildAllShapes_SimplePolygonBrep(); + buildAllShapes_UnidentifiedShape(); buildAllShapes_Cons(); buildAllShapes_Para(); buildAllShapes_Trap(); @@ -810,6 +818,25 @@ void ReadGeoModel::buildAllShapes_SimplePolygonBrep() } } +//! Iterate over the list of GeoTube shape nodes, build them all, +//! and store their pointers +void ReadGeoModel::buildAllShapes_UnidentifiedShape() +{ + // create a builder and reserve size of memory map + size_t nSize = m_shapes_UnidentifiedShape.size(); + m_builderShape_UnidentifiedShape = new BuildGeoShapes_UnidentifiedShape(nSize); + // loop over the DB rows and build the shapes + for (const auto &row : m_shapes_UnidentifiedShape) + { + // GeoModelIO::CppHelper::printStdVectorVariants(row); // DEBUG MSG + m_builderShape_UnidentifiedShape->buildShape(row); + } + m_builderShape_UnidentifiedShape->printBuiltShapes(); // DEBUG MSG + if (nSize > 0) { + std::cout << "All " << nSize << " Shapes-UnidentifiedShape have been built!\n"; + } +} + //! Iterate over the list of GeoSerialDenominator nodes, build them all, and //! store their pointers void ReadGeoModel::buildAllSerialDenominators() { @@ -2577,6 +2604,7 @@ GeoShape* ReadGeoModel::buildShape(const unsigned int shapeId, // } // } // LAr custom shape + /* else if (type == "CustomShape") { std::string name = ""; // check parameters @@ -2609,7 +2637,8 @@ GeoShape* ReadGeoModel::buildShape(const unsigned int shapeId, exit(EXIT_FAILURE); } shape = new GeoUnidentifiedShape("LArCustomShape", name); - } else if (type == "UnidentifiedShape") { + } + else if (type == "UnidentifiedShape") { std::string name = ""; std::string asciiData = ""; @@ -2678,7 +2707,8 @@ GeoShape* ReadGeoModel::buildShape(const unsigned int shapeId, } shape = new GeoUnidentifiedShape(name, asciiData); - } else { + }*/ + else { m_unknown_shapes.insert( type); // save unknwon shapes for later warning message shape = buildDummyShape(); @@ -3686,7 +3716,7 @@ void ReadGeoModel::storeBuiltShapeOperators_Union(const unsigned id, GeoShape* n GeoShape *ReadGeoModel::getBuiltShape(const unsigned shapeId, std::string_view shapeType) { - const std::set<std::string> shapesNewDB{"Box", "Tube", "Pcon", "Cons", "Para", "Pgon", "Trap", "Trd", "Tubs", "TwistedTrap", "SimplePolygonBrep", "Shift", "Intersection", "Subtraction", "Union"}; + const std::set<std::string> shapesNewDB{"Box", "Tube", "Pcon", "Cons", "Para", "Pgon", "Trap", "Trd", "Tubs", "TwistedTrap", "SimplePolygonBrep", "Shift", "Intersection", "Subtraction", "Union", "UnidentifiedShape"}; // get shape parameters if (std::count(shapesNewDB.begin(), shapesNewDB.end(), shapeType)) { @@ -3734,6 +3764,10 @@ GeoShape *ReadGeoModel::getBuiltShape(const unsigned shapeId, std::string_view s { return m_builderShape_SimplePolygonBrep->getBuiltShape(shapeId); } + else if ("UnidentifiedShape" == shapeType) + { + return m_builderShape_UnidentifiedShape->getBuiltShape(shapeId); + } else if ("Shift" == shapeType) { return m_memMapShapes_Shift[shapeId]; diff --git a/GeoModelIO/GeoModelWrite/CMakeLists.txt b/GeoModelIO/GeoModelWrite/CMakeLists.txt index b9696304f..9ac2827fc 100644 --- a/GeoModelIO/GeoModelWrite/CMakeLists.txt +++ b/GeoModelIO/GeoModelWrite/CMakeLists.txt @@ -7,7 +7,7 @@ file( GLOB HEADERS GeoModelWrite/*.h ) # Set up the library. add_library( GeoModelWrite SHARED ${HEADERS} ${SOURCES} ) target_link_libraries( GeoModelWrite PUBLIC - GeoModelKernel GeoModelDBManager TFPersistification GeoModelCppHelpers) + GeoModelKernel GeoModelDBManager TFPersistification GeoModelCppHelpers GeoModelHelpers) target_include_directories( GeoModelWrite PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ) diff --git a/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h b/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h index a98fb53d4..1e58bbe23 100644 --- a/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h +++ b/GeoModelIO/GeoModelWrite/GeoModelWrite/WriteGeoModel.h @@ -382,6 +382,10 @@ class WriteGeoModel : public GeoNodeAction { DBRowsList m_shapes_Subtraction; DBRowsList m_shapes_Union; + DBRowsList m_shapes_UnidentifiedShape; + + + // std::vector<std::vector<std::string>> m_functions; DBRowsList m_functions; // operators used in Function's expression diff --git a/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp b/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp index 3aae3d595..cbd87ebf5 100644 --- a/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp +++ b/GeoModelIO/GeoModelWrite/src/WriteGeoModel.cpp @@ -59,6 +59,8 @@ #include "GeoModelCppHelpers/GMCppHelpers.h" +#include "GeoModelHelpers/throwExcept.h" + // C++ includes #include <sstream> @@ -699,7 +701,7 @@ std::pair<std::string, unsigned> WriteGeoModel::storeShape(const GeoShape* shape // LArCustomShape is deprecated. Write it out as a GeoUnidentifiedShape; if (shapeType == "CustomShape") shapeType = "UnidentifiedShape"; - const std::set<std::string> shapesNewDB{"Box", "Tube", "Cons", "Para", "Trap", "Trd", "Tubs", "TwistedTrap", "Pcon", "Pgon", "SimplePolygonBrep", "Intersection", "Shift", "Subtraction", "Union"}; + const std::set<std::string> shapesNewDB{"Box", "Tube", "Cons", "Para", "Trap", "Trd", "Tubs", "TwistedTrap", "Pcon", "Pgon", "SimplePolygonBrep", "Intersection", "Shift", "Subtraction", "Union", "UnidentifiedShape"}; // get shape parameters if (std::count(shapesNewDB.begin(), shapesNewDB.end(), shapeType)) @@ -973,6 +975,7 @@ WriteGeoModel::getShapeParametersV(const GeoShape *shape, const bool data) std::vector<std::vector<std::variant<int, long, float, double, std::string>>> shapeData; std::pair<std::vector<std::variant<int, long, float, double, std::string>>, std::vector<std::vector<std::variant<int, long, float, double, std::string>>>> shapePair; std::vector<std::variant<int, long, float, double, std::string>> dataRow; + // init the 'computedVolume' column with a dummy value: '-1' // the real value will be added later, when the DB will be passed throug // the tool to compute the volume for the shapes and store them @@ -1196,6 +1199,11 @@ WriteGeoModel::getShapeParametersV(const GeoShape *shape, const bool data) shapePars.push_back(shapeTypeB); shapePars.push_back(shapeIdB); + } else if (shapeType == "UnidentifiedShape") { + const GeoUnidentifiedShape* shapeIn = + dynamic_cast<const GeoUnidentifiedShape*>(shape); + shapePars.push_back(shapeIn->name()); + shapePars.push_back(shapeIn->asciiData()); } else { @@ -1208,6 +1216,9 @@ WriteGeoModel::getShapeParametersV(const GeoShape *shape, const bool data) shapePair.second = shapeData; return shapePair; } + + +// OLD VERSIONS!!!! TO BE REMOVED WHEN ALL SHAPES ARE MIGRATED!! // Get shape parameters std::string WriteGeoModel::getShapeParameters(const GeoShape* shape) { const std::string shapeType = shape->type(); @@ -1498,12 +1509,13 @@ std::string WriteGeoModel::getShapeParameters(const GeoShape* shape) { pars.push_back( "Y=" + CppHelper::to_string_with_precision(shapeIn->getVertices()[i](1))); } - } else if (shapeType == "UnidentifiedShape") { - const GeoUnidentifiedShape* shapeIn = - dynamic_cast<const GeoUnidentifiedShape*>(shape); - pars.push_back("name=" + shapeIn->name()); - pars.push_back("asciiData=" + shapeIn->asciiData()); - } + } + // else if (shapeType == "UnidentifiedShape") { + // const GeoUnidentifiedShape* shapeIn = + // dynamic_cast<const GeoUnidentifiedShape*>(shape); + // pars.push_back("name=" + shapeIn->name()); + // pars.push_back("asciiData=" + shapeIn->asciiData()); + // } // LAr custom shape // else if(shapeType == "CustomShape") { // std::cout << "\n\tWARNING!!! - Use of LArCustomShape is deprecated, @@ -1515,9 +1527,11 @@ std::string WriteGeoModel::getShapeParameters(const GeoShape* shape) { // shapePars=pars.join(";"); // } else { - std::cout << "\n\tGeoModelWrite -- ERROR!!! - Shape '" << shapeType - << "' needs to be persistified!!\n\n"; + std::string errMsg = "GeoModelWrite -- ERROR!!! - Shape '" + shapeType + + "' needs to be persistified!!"; + std::cout << "\n\nobject to be persistified:" << std::endl; CppHelper::printStdVectorStrings(m_objectsNotPersistified); + THROW_EXCEPTION(errMsg); } shapePars = joinVectorStrings(pars, ";"); @@ -2464,12 +2478,15 @@ unsigned int WriteGeoModel::addShape(const std::string &type, { container = &m_shapes_Shift; } + else if ("UnidentifiedShape" == type) + { + container = &m_shapes_UnidentifiedShape; + } else { - std::cout << "\nERROR! Shape type '" << type - << "' still needs to be ported to the new DB schema. Ask to 'geomodel-developers@cern.ch.\n" - << std::endl; - exit(EXIT_FAILURE); + const std::string errMsg = "ERROR!!! Shape type '" + type + + "' still needs to be ported to the new DB schema. Ask to 'geomodel-developers@cern.ch."; + THROW_EXCEPTION(errMsg); } return addRecord(container, parameters); } @@ -2603,6 +2620,9 @@ void WriteGeoModel::saveToDB(std::vector<GeoPublisher*>& publishers) { m_dbManager->addListOfRecords("GeoShapeSubtraction", m_shapes_Subtraction); // new version, with shape's parameters as numbers m_dbManager->addListOfRecords("GeoShapeUnion", m_shapes_Union); // new version, with shape's parameters as numbers + m_dbManager->addListOfRecords("GeoUnidentifiedShape", m_shapes_UnidentifiedShape); // new version, with shape's parameters as numbers + + m_dbManager->addListOfChildrenPositions(m_childrenPositions); m_dbManager->addRootVolume(m_rootVolume); -- GitLab