]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
feat : Export ROOT v1.0 exportRoot
authorNicolas RECHATIN <nicolas.rechatin@cea.fr>
Wed, 8 Mar 2023 10:07:46 +0000 (11:07 +0100)
committerNicolas RECHATIN <nicolas.rechatin@cea.fr>
Wed, 8 Mar 2023 10:09:26 +0000 (11:09 +0100)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp

index 4e202d44941a6e0dc430d68bb663694ca8357309..a00b1b1138acff498865f7d5ce07526679d3c948 100644 (file)
@@ -678,8 +678,6 @@ void ExchangePlugin_ExportFeature::exportXAO(const std::string &theFileName)
     // LCOV_EXCL_STOP
 }
 
-#include <iostream>
-
 void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
 {
     // Get data from feature
@@ -697,20 +695,20 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
     // Create the head of file
     anAlgo->buildHead(listNames.front(), aName, aTitle);
 
-    // // Materials and mediums
+    // TODO : Use material files for media list
     // std::map<std::string, std::vector<std::string> > aMaterials;
     // std::map<std::string, std::vector<std::string> > aMedias;
     // readFileMat(aFileMat, aMaterials, aMedias);
     // anAlgo->buildMaterialsMedias(aMaterials, aMedias);
 
     // Handling data
+    std::list<std::string> aListOfMedias;
     std::list<std::wstring> aListOfVolumes;
     std::map<std::string, std::vector <std::array<std::string, 2>>> aCopyData;
 
     // Add feature in the file
     std::list<FeaturePtr> aFeatures = document()->allFeatures();
     std::list<FeaturePtr>::iterator itFeature = aFeatures.begin();
-    std::map<std::wstring, std::string> aMapFeauturesObject;
     int aMediumIndex = 0;
     for (; itFeature != aFeatures.end(); ++itFeature)
     {
@@ -734,7 +732,16 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
             std::map<std::string, std::string> aFeatureDimensions;
             aFeatureDimensions = ExchangePlugin_ExportRoot::computeVolume(aFeature);
             std::wstring anObjectName = aFeature->firstResult()->data()->name();
-            anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex);
+
+            //Filter on already created medias
+            std::list<std::string>::iterator anIter = std::find(aListOfMedias.begin(), aListOfMedias.end(), aFeatureDimensions["medium"]);
+            if (anIter != aListOfMedias.end())
+                anAlgo->buildVolume(anObjectName, aFeatureDimensions, -1);
+            else
+            {
+                aListOfMedias.push_back(aFeatureDimensions["medium"]);
+                anAlgo->buildVolume(anObjectName, aFeatureDimensions, ++aMediumIndex);
+            }
 
             // Add volume to known ones
             aListOfVolumes.push_back(anObjectName);
@@ -769,8 +776,7 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
                         for (int k = 0; k < jt->second.size(); k++ )
                             if (jt->second[k][0] == it->first)
                                 jt->second[k][1] = it->second;
-                // TODO : Add TR TO ACopyData the AddNode get the TR value
-            } else {std::cout << "Ignoring translation" << std::endl;}
+            } else {std::cout << "Ignoring translation" << std::endl;} //Filter translation not on volume or addNode
         }
     }
 
@@ -780,9 +786,7 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
     aFeature = anObjectAttr->contextFeature();
     std::string aNameShape = "";
     if (aFeature.get())
-    {
         aNameShape = Locale::Convert::toString(aFeature->firstResult()->data()->name());
-    }
     else
     {
         ObjectPtr anObject = anObjectAttr->contextObject();
index 172eaa236148dd3d242ec2fb46e6ab14e0c2da7f..d02c5deaf2c2900413aa60177433be48e51f9cb2 100644 (file)
 #include <ModelAPI_AttributeSelectionList.h>
 
 #include <string>
-#include <iostream>
 #include <iomanip>
 #include <sstream>
-
 #include "math.h"
 
                                                                                                                    namespace ExchangePlugin_ExportRoot
             AttributeSelectionPtr aSelection = aBaseObjectList->value(anIndex);
             ResultPtr aMainResult = aSelection->context();
             FeaturePtr aSelectionFeature = aMainResult->document()->feature(aMainResult);
-
-            std::cout << "Copy feature  kind is : " << aSelectionFeature->getKind() << std::endl;
-
             std::wstring aWSelName = aMainResult ? aMainResult->data()->name() : aSelectionFeature->firstResult()->data()->name();
             std::string aSelName(aWSelName.begin(), aWSelName.end());
             std::vector<std::array<std::string, 2>> aNewBaseCopies;
                 AttributeSelectionPtr aSelection = aBaseObjectList->value(anIndex);
                 ResultPtr aMainResult = aSelection->context();
                 FeaturePtr aSelectionFeature = aMainResult->document()->feature(aMainResult);
-
-                std::cout << "Translation feature kind is : " << aSelectionFeature->getKind() << std::endl;
-
                 std::wstring aWSelName = aMainResult ? aMainResult->data()->name() : aSelectionFeature->firstResult()->data()->name();
                 std::string aSelName(aWSelName.begin(), aWSelName.end());
                 //Add it to translated objects
             std::map<std::string, std::string> aFeatureDim;
             return aFeatureDim;
         }
-        // else if (aMethodType == FeaturesPlugin_Translation::CREATION_METHOD_BY_DISTANCE())
-        // {
-            // double anAxisOffset;
-            // AttributeSelectionPtr anAxis;
-
-            // anAxis = theFeature->data()->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
-            // anAxisOffset = (theFeature->data()->real(FeaturesPlugin_Translation::DISTANCE_ID())->value());
-
-            // // Get feature
-            // ResultPtr aResult = anAxis->context();
-            // FeaturePtr anAxisFeature = aResult->document()->feature(aResult);
-            // std::wstring anAxisName = aResult ? aResult->data()->name() : anAxisFeature->firstResult()->data()->name();
-
-            // std::map<std::string, std::string> aFeatureDim;
-            // return aFeatureDim;
-        // }
-        // else if (aMethodType == FeaturesPlugin_Translation::CREATION_METHOD_BY_TWO_POINTS())
-        // {
-        //     std::map<std::string, std::string> aFeatureDim;
-        //     return aFeatureDim;
-        // }
     }
 
 } // namespace ExchangePlugin_ExportRoot
-
-// std::map<std::string, std::vector<std::array<std : string, 2>>> aCopyData;
index 154d9dc226ed798c8d6064f8d0c3b8a87ddd1bf5..2f18438c82138a81434c00edb0b0715278c93a56 100644 (file)
@@ -127,12 +127,15 @@ void GeomAlgoAPI_ROOTExport::buildVolume(const std::wstring &theObjectName,
     myContent << "\t"
               << "//Exporting " << anObjectName << std::endl;
 
-    myContent << "\t"
-              << "TGeoMedium *" << theFeatureDim["medium"] << " = new TGeoMedium(\""
-              << theFeatureDim["medium"] << "\", "
-              << theMediumIndex << ", "
-              << "matDummy);"
-              << std::endl;
+    if (theMediumIndex != -1)
+    {
+        myContent << "\t"
+                << "TGeoMedium *" << theFeatureDim["medium"] << " = new TGeoMedium(\""
+                << theFeatureDim["medium"] << "\", "
+                << theMediumIndex << ", "
+                << "matDummy);"
+                << std::endl;
+    }
 
     myContent << "\t"
               << "TGeoVolume *" << anObjectName << " = new TGeoVolume(\""
@@ -157,7 +160,6 @@ void GeomAlgoAPI_ROOTExport::buildAddNode(const std::map<std::string, std::wstri
 
     myContent << "\t"
               << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ");"
-              << std::endl
               << std::endl;
 
     for (auto const &[key, val] : theCopyData){
@@ -166,11 +168,11 @@ void GeomAlgoAPI_ROOTExport::buildAddNode(const std::map<std::string, std::wstri
                 myContent << "\t"
                           << aMainName << "->AddNode(" << aToolName << ", " << ++theAddNodeIndex << ", "
                           << "new TGeoTranslation(" << el[1] <<"));"
-                          << std::endl
                           << std::endl;
             }
         }
     }
+    myContent << std::endl;
 }
 
 //=================================================================================================