Salome HOME
Copyright update 2022
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Dump.cpp
index 9ca46901b0afd9361f285cd821cd80a1615d06aa..aaee3f0034519034e97a43b25cbd67f1f66feeda 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_Validator.h>
 
 #include <ModelHighAPI_Dumper.h>
 
 #include <Config_ModuleReader.h>
 
+#include <GeomAlgoAPI_Tools.h>
+
+#ifdef EXCHANGEPLUGIN_DUMP_NAMING
+static const bool THE_DUMP_NAMING = true;
+#else
+static const bool THE_DUMP_NAMING = false;
+#endif
+
+#ifdef EXCHANGEPLUGIN_DUMP_GEO
+static const bool THE_DUMP_GEO = true;
+#else
+static const bool THE_DUMP_GEO = false;
+#endif
+
+#ifdef EXCHANGEPLUGIN_DUMP_WEAK
+static const bool THE_DUMP_WEAK = true;
+#else
+static const bool THE_DUMP_WEAK = false;
+#endif
+
 
 ExchangePlugin_Dump::ExchangePlugin_Dump()
 {
@@ -49,11 +70,15 @@ void ExchangePlugin_Dump::initAttributes()
 
   data()->addAttribute(EXPORT_VARIABLES_ID(), ModelAPI_AttributeBoolean::typeId());
 
+  data()->addAttribute(DUMP_DIR_ID(), ModelAPI_AttributeString::typeId());
+
   // default values
-  boolean(TOPOLOGICAL_NAMING_DUMP_ID())->setValue(true);
-  boolean(GEOMETRIC_DUMP_ID())->setValue(true);
-  boolean(WEAK_NAMING_DUMP_ID())->setValue(false);
+  boolean(TOPOLOGICAL_NAMING_DUMP_ID())->setValue(THE_DUMP_NAMING);
+  boolean(GEOMETRIC_DUMP_ID())->setValue(THE_DUMP_GEO);
+  boolean(WEAK_NAMING_DUMP_ID())->setValue(THE_DUMP_WEAK);
   boolean(EXPORT_VARIABLES_ID())->setValue(false);
+
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), DUMP_DIR_ID());
 }
 
 void ExchangePlugin_Dump::execute()
@@ -144,6 +169,16 @@ void ExchangePlugin_Dump::dump(const std::string& theFileName)
     aDumper->addCustomStorage(aWeakNamingStorage);
   }
 
+  // pass dump directory to the dumper
+  AttributeStringPtr aDumpDirAttr =
+    this->string(ExchangePlugin_Dump::DUMP_DIR_ID());
+  std::string aDumpDir;
+  if (aDumpDirAttr.get() && aDumpDirAttr->isInitialized())
+    aDumpDir = aDumpDirAttr->value();
+  else
+    aDumpDir = GeomAlgoAPI_Tools::File_Tools::path(theFileName);
+  aDumper->setDumpDir(aDumpDir);
+
   if (!aDumper->process(aDoc, theFileName)) {
     setError("An error occurred while dumping to " + theFileName);
   } else {