]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
WIP : Export AddNode
authorNicolas RECHATIN <nicolas.rechatin@cea.fr>
Mon, 16 Jan 2023 10:55:53 +0000 (11:55 +0100)
committerNicolas RECHATIN <nicolas.rechatin@cea.fr>
Mon, 16 Jan 2023 10:55:53 +0000 (11:55 +0100)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp
src/ExchangePlugin/ExchangePlugin_ExportRoot.h
src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h

index 51f63021d004caebbcca361bb58afd45c7943611..fbfddf29deb565e1546c39dbbfdc45840ef0be25 100644 (file)
@@ -737,6 +737,15 @@ void ExchangePlugin_ExportFeature::exportROOT(const std::string &theFileName)
             aListNamesOfFeatures.push_back(anObjectName);
             aListNamesOfFeatures.push_back(aFeature->data()->name());
         }
+        else if (aFeature->getKind() == "AddNode")
+        {
+            std::map<std::string, std::string> aFeatureDimensions;
+            aFeatureDimensions = ExchangePlugin_ExportRoot::computeAddNode(aFeature);
+            std::wstring anObjectName = aFeature->firstResult()->data()->name();
+            anAlgo->buildAddNode(anObjectName, aFeatureDimensions);
+            aListNamesOfFeatures.push_back(anObjectName);
+            aListNamesOfFeatures.push_back(aFeature->data()->name());
+        }
     }
 
     // Create the end of files
index 9066ee8cd495fb665ae856039bb137c25b00827d..86e762345227223104834e778071924091ff1559 100644 (file)
@@ -20,7 +20,7 @@
 #include <PrimitivesPlugin_Box.h>
 #include <PrimitivesPlugin_Cylinder.h>
 #include <OperaPlugin_Volume.h>
-
+#include <OperaPlugin_AddNode.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
 
         return aFeatureDim;
     }
 
+    //===============================================================================================
+    std::map<std::string, std::string> computeAddNode(FeaturePtr theFeature)
+    {
+        //Get attributes
+        std::string aMedium;
+
+        // Get attributes
+        AttributeSelectionPtr aMainSel = theFeature->data()->selection(OperaPlugin_AddNode::MAIN_OBJECT_ID());
+        AttributeSelectionPtr aToolSel = theFeature->data()->selection(OperaPlugin_AddNode::TOOL_OBJECT_ID());
+
+        // Get main data
+        ResultPtr aMainResult = aMainSel->context();
+        FeaturePtr aMainSelFeature = aMainResult->document()->feature(aMainResult);
+        std::wstring aWMainName = aMainResult ? aMainResult->data()->name() : aMainSelFeature->firstResult()->data()->name();
+
+        // Get tool data
+        ResultPtr aToolResult = aToolSel->context();
+        FeaturePtr aToolSelFeature = aToolResult->document()->feature(aToolResult);
+        std::wstring aWToolName = aToolResult ? aToolResult->data()->name() : aToolSelFeature->firstResult()->data()->name();
+
+        // Data out
+        std::map<std::string, std::string> aFeatureDim;
+
+        std::string aMainName(aWMainName.begin(), aWMainName.end());
+        aFeatureDim["main"] = aMainName;
+
+        std::string aToolName(aWToolName.begin(), aWToolName.end());
+        aFeatureDim["tool"] = aToolName;
+
+        return aFeatureDim;
+    }
+
 } // namespace ExchangePlugin_ExportRoot
index 40c0b02d1b0458811ff1b8b98044671db0b48e7a..eb77693c4834c342ae2706b748ba3f87ab209a77 100644 (file)
@@ -29,6 +29,7 @@ namespace ExchangePlugin_ExportRoot
   EXCHANGEPLUGIN_EXPORT std::map<std::string, double> computeBox(FeaturePtr theFeature);
   EXCHANGEPLUGIN_EXPORT std::map<std::string, double> computeCylinder(FeaturePtr theFeature);
   EXCHANGEPLUGIN_EXPORT std::map<std::string, std::string> computeVolume(FeaturePtr theFeature);
+  EXCHANGEPLUGIN_EXPORT std::map<std::string, std::string> computeAddNode(FeaturePtr theFeature);
 }
 
 #endif /* EXCHANGEPLUGIN_EXPORTROOT_H_ */
index e3bc1d2943fa62cc05426b9b207846e6061f188d..fef6e62e63e7cbf6f04a0ebe1569651e43f6bb57 100644 (file)
@@ -143,6 +143,21 @@ void GeomAlgoAPI_ROOTExport::buildVolume(const std::wstring &theObjectName,
               << std::endl;
 }
 
+//=================================================================================================
+void GeomAlgoAPI_ROOTExport::buildAddNode(const std::wstring &theObjectName,
+                                          const std::map<std::string, std::string> theFeatureDim)
+{
+    std::string anObjectName(theObjectName.begin(), theObjectName.end());
+
+    myContent << "\t"
+              << "//Exporting AddNode_" << anObjectName << std::endl;
+
+    myContent << "\t"
+              << theFeatureDim["main"] << "->AddNode(" << theFeatureDim["tool"] << ", 1);"
+              << std::endl
+              << std::endl;
+}
+
 //=================================================================================================
 void GeomAlgoAPI_ROOTExport::buildEnd(const std::string theSolidName,
                                       const std::string theExportName)
index c4751517ea763a70d582fd490960402ef021306b..403f76f5ac3430e4abbbf1c92284ddaa83aeeba9 100644 (file)
@@ -62,6 +62,10 @@ public:
                                         const std::map<std::string, std::string> theFeatureDim,
                                         const int theMediumIndex);
 
+    /// Build AddNode
+    GEOMALGOAPI_EXPORT void buildAddNode(const std::wstring &theObjectName,
+                                         const std::map<std::string, std::string> theFeatureDim);
+
     /// Build Medium
     GEOMALGOAPI_EXPORT void addMedium(const std::string theMediumName);