From 3bdbd37c0327d3152abe3d88ae3a9f28179c7045 Mon Sep 17 00:00:00 2001 From: Nicolas RECHATIN Date: Mon, 16 Jan 2023 11:55:53 +0100 Subject: [PATCH] WIP : Export AddNode --- .../ExchangePlugin_ExportFeature.cpp | 9 +++++ .../ExchangePlugin_ExportRoot.cpp | 34 ++++++++++++++++++- .../ExchangePlugin_ExportRoot.h | 1 + src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp | 15 ++++++++ src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h | 4 +++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 51f63021d..fbfddf29d 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -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 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 diff --git a/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp b/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp index 9066ee8cd..86e762345 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportRoot.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include #include @@ -149,4 +149,36 @@ return aFeatureDim; } + //=============================================================================================== + std::map 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 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 diff --git a/src/ExchangePlugin/ExchangePlugin_ExportRoot.h b/src/ExchangePlugin/ExchangePlugin_ExportRoot.h index 40c0b02d1..eb77693c4 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportRoot.h +++ b/src/ExchangePlugin/ExchangePlugin_ExportRoot.h @@ -29,6 +29,7 @@ namespace ExchangePlugin_ExportRoot EXCHANGEPLUGIN_EXPORT std::map computeBox(FeaturePtr theFeature); EXCHANGEPLUGIN_EXPORT std::map computeCylinder(FeaturePtr theFeature); EXCHANGEPLUGIN_EXPORT std::map computeVolume(FeaturePtr theFeature); + EXCHANGEPLUGIN_EXPORT std::map computeAddNode(FeaturePtr theFeature); } #endif /* EXCHANGEPLUGIN_EXPORTROOT_H_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp index e3bc1d294..fef6e62e6 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp @@ -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 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) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h index c4751517e..403f76f5a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h @@ -62,6 +62,10 @@ public: const std::map theFeatureDim, const int theMediumIndex); + /// Build AddNode + GEOMALGOAPI_EXPORT void buildAddNode(const std::wstring &theObjectName, + const std::map theFeatureDim); + /// Build Medium GEOMALGOAPI_EXPORT void addMedium(const std::string theMediumName); -- 2.39.2