From: Nicolas RECHATIN Date: Fri, 10 Mar 2023 14:41:10 +0000 (+0100) Subject: feat : Translation on base volume X-Git-Tag: OPERA_v0.6-s990 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dc52d4c9dd7efa719fb229906f51f60bd74f53a9;p=modules%2Fshaper.git feat : Translation on base volume --- diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index a00b1b113..378b2a442 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -703,7 +703,7 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName) // Handling data std::list aListOfMedias; - std::list aListOfVolumes; + std::map aListOfVolumes; std::map>> aCopyData; // Add feature in the file @@ -743,8 +743,8 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName) anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex); } - // Add volume to known ones - aListOfVolumes.push_back(anObjectName); + // Add volume to known ones with no translation + aListOfVolumes[anObjectName] = ""; } else if (aFeature->getKind() == "AddNode") { @@ -753,9 +753,9 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName) std::wstring anObjectName = aFeature->firstResult()->data()->name(); //Filter copied volumes - std::list::iterator anIter = std::find(aListOfVolumes.begin(), aListOfVolumes.end(), aFeatureDimensions["tool"]); + auto anIter = aListOfVolumes.find(aFeatureDimensions["tool"]); if (anIter != aListOfVolumes.end()) - anAlgo->buildAddNode(aFeatureDimensions, aCopyData); + anAlgo->buildAddNode(aFeatureDimensions, anIter->second, aCopyData); } else if (aFeature->getKind() == "Copy") { @@ -770,12 +770,19 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName) if (aFeatureDimensions.size()) { std::map::iterator it; - for (std::map::iterator it = aFeatureDimensions.begin(); it != aFeatureDimensions.end(); it++) - for (auto jt = aCopyData.begin(); jt != aCopyData.end(); jt++) - for (int k = 0; k < jt->second.size(); k++ ) - if (jt->second[k][0] == it->first) - jt->second[k][1] = it->second; + { + std::wstring aWStr(it->first.begin(), it->first.end()); + if (aListOfVolumes.find(aWStr) != aListOfVolumes.end()) + aListOfVolumes[aWStr] = it->second; + else + { + for (auto jt = aCopyData.begin(); jt != aCopyData.end(); jt++) + for (int k = 0; k < jt->second.size(); k++ ) + if (jt->second[k][0] == it->first) + jt->second[k][1] = it->second; + } + } } else {std::cout << "Ignoring translation" << std::endl;} //Filter translation not on volume or addNode } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp index 2f18438c8..451568a38 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp @@ -148,6 +148,7 @@ void GeomAlgoAPI_ROOTExport::buildVolume(const std::wstring &theObjectName, //================================================================================================= void GeomAlgoAPI_ROOTExport::buildAddNode(const std::map theFeatureDim, + const std::string theVolumeTranslation, const std::map>> theCopyData) { static int theAddNodeIndex = 0; @@ -158,9 +159,19 @@ void GeomAlgoAPI_ROOTExport::buildAddNode(const std::mapAddNode(" << aToolName << ", " << ++theAddNodeIndex << ");" - << std::endl; + if (theVolumeTranslation.empty()) + { + myContent << "\t" + << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ");" + << std::endl; + } + else + { + myContent << "\t" + << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ", " + << "new TGeoTranslation(" << theVolumeTranslation << "));" + << std::endl; + } for (auto const &[key, val] : theCopyData){ if (key == aToolName){ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h index 6851d53d7..85b572093 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h @@ -64,6 +64,7 @@ public: /// Build AddNode GEOMALGOAPI_EXPORT void buildAddNode(const std::map theFeatureDim, + const std::string theVolumeTranslation, const std::map>> theCopyData); /// Build Medium GEOMALGOAPI_EXPORT void addMedium(const std::string theMediumName);