]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
feat : Translation on base volume handlingTranslation OPERA_v0.6-s990
authorNicolas RECHATIN <nicolas.rechatin@cea.fr>
Fri, 10 Mar 2023 14:41:10 +0000 (15:41 +0100)
committerNicolas RECHATIN <nicolas.rechatin@cea.fr>
Fri, 10 Mar 2023 14:41:10 +0000 (15:41 +0100)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h

index a00b1b1138acff498865f7d5ce07526679d3c948..378b2a442a30890de5280bba10cf7f0108e408a6 100644 (file)
@@ -703,7 +703,7 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
 
     // Handling data
     std::list<std::string> aListOfMedias;
-    std::list<std::wstring> aListOfVolumes;
+    std::map<std::wstring, std::string> aListOfVolumes;
     std::map<std::string, std::vector <std::array<std::string, 2>>> 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<std::wstring>::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<std::string, std::string>::iterator it;
-
                 for (std::map<std::string, std::string>::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
         }
     }
index 2f18438c82138a81434c00edb0b0715278c93a56..451568a383dae46cae54ae476f437c01f7a41bbf 100644 (file)
@@ -148,6 +148,7 @@ void GeomAlgoAPI_ROOTExport::buildVolume(const std::wstring &theObjectName,
 
 //=================================================================================================
 void GeomAlgoAPI_ROOTExport::buildAddNode(const std::map<std::string, std::wstring> theFeatureDim,
+                                          const std::string theVolumeTranslation,
                                           const std::map<std::string, std::vector<std::array<std::string, 2>>> theCopyData)
 {
     static int theAddNodeIndex = 0;
@@ -158,9 +159,19 @@ void GeomAlgoAPI_ROOTExport::buildAddNode(const std::map<std::string, std::wstri
     myContent << "\t"
               << "//Exporting AddNode " << theAddNodeIndex << std::endl;
 
-    myContent << "\t"
-              << aMainName << "->AddNode(" << 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){
index 6851d53d72a16c418f6bcaedbd6d9a4a5bb675e4..85b572093f7c38335094cef1c93e01d289c4ecd2 100644 (file)
@@ -64,6 +64,7 @@ public:
 
     /// Build AddNode
     GEOMALGOAPI_EXPORT void buildAddNode(const std::map<std::string, std::wstring> theFeatureDim,
+                                         const std::string theVolumeTranslation,
                                          const std::map<std::string, std::vector<std::array<std::string, 2>>> theCopyData);
     /// Build Medium
     GEOMALGOAPI_EXPORT void addMedium(const std::string theMediumName);