Salome HOME
Merge branch 'cadbld'
authormpv <mpv@opencascade.com>
Wed, 29 Dec 2021 14:14:45 +0000 (17:14 +0300)
committermpv <mpv@opencascade.com>
Wed, 29 Dec 2021 14:14:45 +0000 (17:14 +0300)
# Conflicts:
# src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
# src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
# src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
# src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
# src/FeaturesPlugin/FeaturesPlugin_Scale.cpp
# src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
# src/FeaturesPlugin/FeaturesPlugin_Translation.cpp

46 files changed:
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_Keywords.h
src/Config/Config_ModuleReader.cpp
src/Config/Config_ModuleReader.h
src/ExchangePlugin/ExchangePlugin_Import.cpp
src/ExchangePlugin/doc/exportFeature.rst
src/ExchangePlugin/doc/importFeature.rst
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.h
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
src/FeaturesPlugin/FeaturesPlugin_Defeaturing.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet1D.cpp
src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Scale.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Tools.cpp
src/FeaturesPlugin/FeaturesPlugin_Tools.h
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/FeaturesPlugin_Union.cpp
src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h
src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/ModelAPI/ModelAPI_Events.cpp
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Session.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/PartSet_Module.cpp
src/PythonAPI/model/__init__.py
src/PythonAPI/model/addons/__init__.py [new file with mode: 0644]

index 5f397d63842790722ab0d1ed789086cdc7e5c72a..3d53a63d604873b234866534bb79e555a1206617 100644 (file)
 
 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
                                            const std::string& theLibraryName,
+                                           const std::string& theDocSection,
                                            const char* theEventGenerated)
     : Config_XMLReader(theXmlFile),
       myLibraryName(theLibraryName),
+      myLibraryDocSection(theDocSection),
       myEventGenerated(theEventGenerated ? theEventGenerated : Config_FeatureMessage::GUI_EVENT()),
       myIsProcessWidgets(theEventGenerated != NULL)
 {
@@ -176,8 +178,11 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
   outFeatureMessage->setInternal(isInternal);
 
   std::string aHelpFile = getProperty(theFeatureNode, HELP_FILE);
-  if (!aHelpFile.empty())
-    outFeatureMessage->setHelpFileName(myLibraryName + "/" + aHelpFile);
+  if (!aHelpFile.empty()) {
+    aHelpFile =
+      (myLibraryDocSection.empty() ? myLibraryName : myLibraryDocSection) + "/" + aHelpFile;
+    outFeatureMessage->setHelpFileName(aHelpFile);
+  }
 
   bool isHideFaces = getBooleanAttribute(theFeatureNode, HIDEFACES_PANEL, false);
   outFeatureMessage->setHideFacesPanel(isHideFaces);
index 015090889c6cd075c05bc33a9a535b0e7dd85d22..e3d1098f9e8e419dd3a41765474610186dc058d6 100644 (file)
@@ -40,6 +40,7 @@ class Config_FeatureReader : public Config_XMLReader
   /// Constructor
   Config_FeatureReader(const std::string& theXmlFile,
                        const std::string& theLibraryName,
+                       const std::string& theDocSection = std::string(),
                        const char* theEventGenerated = 0);
   virtual ~Config_FeatureReader();
   /// Returns list of all features defined in reader's file
@@ -61,6 +62,7 @@ class Config_FeatureReader : public Config_XMLReader
 
  private:
   std::string myLibraryName;
+  std::string myLibraryDocSection;
 
   std::list<std::string> myFeatures;
   /// event generated on feature data sending, by default it is Config_FeatureMessage::GUI_EVENT()
index 9774c3519516e628d846c0fb4d46f0d7a52693a2..4149e38167aec4516cf9f620875710146773b28c 100644 (file)
@@ -145,6 +145,8 @@ MAYBE_UNUSED const static char* PLUGIN_LIBRARY = "library";
 MAYBE_UNUSED const static char* PLUGIN_SCRIPT = "script";
 MAYBE_UNUSED const static char* PLUGIN_DEPENDENCY = "dependency";
 MAYBE_UNUSED const static char* PLUGIN_USES = "uses";
+MAYBE_UNUSED const static char* PLUGIN_DOCSECTION = "docsection";
+MAYBE_UNUSED const static char* PLUGIN_LICENSE = "license";
 
 /*
  * Hardcoded xml entities of dataModel.xml
index 20ec732e98024c9b7bf320ec3b4feb054933ebd4..de4db1a3b491ddb4db2d3be31a6ef4136ee4c3f9 100644 (file)
@@ -62,6 +62,16 @@ const std::map<std::string, std::string>& Config_ModuleReader::featuresInFiles()
   return myFeaturesInFiles;
 }
 
+const std::map<std::string, std::string>& Config_ModuleReader::proprietaryFeatures() const
+{
+  return myProprietaryFeatures;
+}
+
+const std::set<std::string>& Config_ModuleReader::proprietaryPlugins() const
+{
+  return myProprietaryPlugins;
+}
+
 const std::set<std::string>& Config_ModuleReader::modulePluginFiles() const
 {
   return myPluginFiles;
@@ -81,6 +91,10 @@ std::string Config_ModuleReader::getModuleName()
 void Config_ModuleReader::addFeature(const std::string& theFeatureName,
                                      const std::string& thePluginConfig)
 {
+  if (myProprietaryFeatures.count(theFeatureName)) {
+    myProprietaryFeatures.erase(theFeatureName);
+  }
+
   if (myFeaturesInFiles.count(theFeatureName)) {
     std::string anErrorMsg = "Can not register feature '%1' in plugin '%2'."
       " There is a feature with the same ID.";
@@ -92,6 +106,21 @@ void Config_ModuleReader::addFeature(const std::string& theFeatureName,
   myFeaturesInFiles[theFeatureName] = thePluginConfig;
 }
 
+void Config_ModuleReader::addFeatureRequireLicense(const std::string& theFeatureName,
+                                                   const std::string& thePluginConfig)
+{
+  if (myFeaturesInFiles.count(theFeatureName) ||
+      myProprietaryFeatures.count(theFeatureName)) {
+    std::string anErrorMsg = "Can not register feature '%1' in plugin '%2'."
+      " There is a feature with the same ID.";
+    Events_InfoMessage("Config_ModuleReader", anErrorMsg)
+      .arg(theFeatureName).arg(thePluginConfig).send();
+    return;
+  }
+
+  myProprietaryFeatures[theFeatureName] = thePluginConfig;
+}
+
 void Config_ModuleReader::processNode(xmlNodePtr theNode)
 {
   if (isNode(theNode, NODE_PLUGIN, NULL)) {
@@ -103,6 +132,7 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode)
     std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
     std::string aPluginScript = getProperty(theNode, PLUGIN_SCRIPT);
     std::string aPluginName = addPlugin(aPluginLibrary, aPluginScript, aPluginConf);
+    std::string aPluginDocSection = getProperty(theNode, PLUGIN_DOCSECTION);
     std::string aUsesPlugin = getProperty(theNode, PLUGIN_USES);
     if (!aUsesPlugin.empty()) { // send information about the plugin dependencies
       std::shared_ptr<Config_PluginMessage> aMess(new Config_PluginMessage(
@@ -111,10 +141,19 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode)
       Events_Loop::loop()->send(aMess);
     }
 
-    std::list<std::string> aFeatures = importPlugin(aPluginName, aPluginConf);
+    std::string aLicense = getProperty(theNode, PLUGIN_LICENSE);
+    std::transform(aLicense.begin(), aLicense.end(), aLicense.begin(), ::tolower);
+    bool isLicensed = aLicense == "true";
+    if (isLicensed)
+      myProprietaryPlugins.insert(aPluginName);
+
+    std::list<std::string> aFeatures = importPlugin(aPluginName, aPluginConf, aPluginDocSection);
     std::list<std::string>::iterator it = aFeatures.begin();
     for (; it != aFeatures.end(); it++) {
-      addFeature(*it, aPluginConf);
+      if (isLicensed)
+        addFeatureRequireLicense(*it, aPluginConf);
+      else
+        addFeature(*it, aPluginConf);
     }
   }
 }
@@ -137,7 +176,8 @@ bool Config_ModuleReader::hasRequiredModules(xmlNodePtr theNode) const
 }
 
 std::list<std::string> Config_ModuleReader::importPlugin(const std::string& thePluginLibrary,
-                                                         const std::string& thePluginXmlConf)
+                                                         const std::string& thePluginXmlConf,
+                                                         const std::string& thePluginDocSection)
 {
   if (thePluginXmlConf.empty()) {  //probably a third party library
     loadLibrary(thePluginLibrary);
@@ -146,6 +186,7 @@ std::list<std::string> Config_ModuleReader::importPlugin(const std::string& theP
 
   Config_FeatureReader aReader = Config_FeatureReader(thePluginXmlConf,
                                                       thePluginLibrary,
+                                                      thePluginDocSection,
                                                       myEventGenerated);
   aReader.readAll();
   return aReader.features();
index b5533bda5577db99631a3a35a1a7ef1a5be16600..24ae9a3b12e6fdb3f8da44ac7db560b28683b960 100644 (file)
@@ -49,6 +49,12 @@ class Config_ModuleReader : public Config_XMLReader
   /// Returns map that describes which file contains a feature
   /// (the feature is key, the file is value)
   CONFIG_EXPORT const std::map<std::string, std::string>& featuresInFiles() const;
+  /// Returns map containing features, which have licensed.
+  /// The valid license should be confirmed first
+  /// (the feature is key, the file is value)
+  CONFIG_EXPORT const std::map<std::string, std::string>& proprietaryFeatures() const;
+  /// Returns proprietary plugins
+  CONFIG_EXPORT const std::set<std::string>& proprietaryPlugins() const;
   /// Returns list of module's xml files
   CONFIG_EXPORT const std::set<std::string>& modulePluginFiles() const;
   /// Returns module name: an xml attribute from the root of the plugins.xml:
@@ -77,7 +83,8 @@ class Config_ModuleReader : public Config_XMLReader
   bool hasRequiredModules(xmlNodePtr aNode) const;
   /// reads info about plugin's features from plugin xml description
   std::list<std::string> importPlugin(const std::string& thePluginLibrary,
-                                      const std::string& thePluginFile);
+                                      const std::string& thePluginFile,
+                                      const std::string& thePluginDocSection);
   /// stores information about plugin in the internal cache
   std::string addPlugin(const std::string& aPluginLibrary,
                         const std::string& aPluginScript,
@@ -85,14 +92,22 @@ class Config_ModuleReader : public Config_XMLReader
   /// Save feature in myFeaturesInFiles.
   /// Generates an error if the feature name is already registered.
   void addFeature(const std::string& theFeatureName, const std::string& thePluginConfig);
+  /// Save feature in myFeaturesRequireLicense.
+  /// Generates an error if the feature name is already registered.
+  void addFeatureRequireLicense(const std::string& theFeatureName,
+                                const std::string& thePluginConfig);
 
  private:
   std::map<std::string, std::string> myFeaturesInFiles; ///< a feature name is key, a file is value
+  /// list of features, which need a license, and their config files
+  std::map<std::string, std::string> myProprietaryFeatures;
   std::set<std::string> myPluginFiles; ///< a feature name is key, a file is value
   /// a plugin name is key, a plugin type is value
   static std::map<std::string, PluginType> myPluginTypes;
   static std::set<std::string> myDependencyModules; ///< set of loaded modules
   const char* myEventGenerated; ///< gives ability to send Feature_Messages to various listeners
+
+  std::set<std::string> myProprietaryPlugins; ///< list of plugins protected by license
 };
 
 #endif /* CONFIG_XMLMODULEREADER_H_ */
index 42601ee113c3817c736a6fcb96c45b79b3c7669e..ef4b3b5605ee5fcef963a95f0cb4d2efeedd753c 100644 (file)
@@ -31,6 +31,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_Validator.h>
 
 
 static const std::wstring THE_NEW_PART_STR(L"New Part");
@@ -88,6 +89,23 @@ void ExchangePlugin_Import::initAttributes()
   data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId());
   data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId());
   data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId());
+
+#ifndef HAVE_SALOME
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::IMPORT_TYPE_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::STEP_FILE_PATH_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::STEP_TARGET_PART_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::STEP_TARGET_PARTS_LIST_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::STEP_MATERIALS_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::STEP_COLORS_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(
+    getKind(), ExchangePlugin_Import::STEP_SCALE_INTER_UNITS_ID());
+#endif
 }
 
 /*
index e4deafb4f346a9d5e566f97ee7771bcf64e1e314..1773c9bf940c81c46bbe96d6c1d28eda0036eeb0 100644 (file)
@@ -136,7 +136,7 @@ In this case, the following property panel will be opened:
    **Dialog box to export in STL format**
 
 
-The file name and path can be defined in **Export file**  field by direct input or browsing with â€˜â€¦â€™ button, which opens Export file dialog box.
+The file name and path can be defined in **Export file**  field by direct input or browsing with '...' button, which opens Export file dialog box.
 
 **Object** field contains an exported object which can be selected in a viewer or object browser.
 
index e76131a4243cc7b440783eba1592813ca35c2d66..817c5c1cb6d89e139f50b11732a26ce072bf95df 100644 (file)
@@ -115,7 +115,7 @@ In this case, the following property panel will be opened:
    **Dialog box to import file in STEP format**
 
 
-The file name and path can be defined in **Import file** field by direct input or browsing with â€˜â€¦â€™ button, which opens **Import file** dialog box.
+The file name and path can be defined in **Import file** field by direct input or browsing with '...' button, which opens **Import file** dialog box.
 The **Import to** combobox provides the list of destinations (one of existing Parts or a new Part).
 **STEP options** provide the possibility to **Scale to International System Units** as well as to create groups from **Materials** and/or **Colors** if defined in assemblies of the file to import.
 
index ed051dc00015ad7034cbe7fe24cce215e82c4df5..e10cc331c831916fdbe6ba2fc1931a8dec5b675c 100644 (file)
@@ -111,7 +111,7 @@ void FeaturesPlugin_Boolean::storeResult(
     const GeomShapePtr theResultShape,
     int& theResultIndex,
     std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList,
-    std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList)
+    std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList)
 {
   if (!theResultShape)
     return;
@@ -119,7 +119,7 @@ void FeaturesPlugin_Boolean::storeResult(
   std::shared_ptr<ModelAPI_ResultBody> aResultBody =
       document()->createBody(data(), theResultIndex);
 
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+  ModelAPI_Tools::loadModifiedShapes(aResultBody,
                                            theObjects,
                                            theTools,
                                            theMakeShapeList,
@@ -127,10 +127,10 @@ void FeaturesPlugin_Boolean::storeResult(
   setResult(aResultBody, theResultIndex++);
 
   // merge algorithms
-  FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+  ModelAPI_Tools::ResultBaseAlgo aRBA;
   aRBA.resultBody = aResultBody;
   aRBA.baseShape = theObjects.front();
-  for (std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>::iterator
+  for (std::vector<ModelAPI_Tools::ResultBaseAlgo>::iterator
        aRBAIt = theResultBaseAlgoList.begin();
        aRBAIt != theResultBaseAlgoList.end(); ++aRBAIt) {
     theMakeShapeList->appendAlgo(aRBAIt->makeShape);
index f6bf522665117ede34710d71038165f30819739f..3a8986a246f57a9bf266131877f6d10a3278b6bd 100644 (file)
@@ -75,7 +75,7 @@ protected:
                    const GeomShapePtr theResultShape,
                    int& theResultIndex,
                    std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList,
-                   std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList);
+                   std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList);
 
 private:
   OperationType myOperationType;
index 085107edb431bd23ece7571978a4b23b0d632188..60b3581b37a6cb6096f35a0e29c70faaa2756680 100644 (file)
@@ -94,7 +94,7 @@ void FeaturesPlugin_BooleanCommon::execute()
 
   std::string anError;
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
-  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+  std::vector<ModelAPI_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
 
   if (isSimpleMode) {
@@ -128,7 +128,7 @@ void FeaturesPlugin_BooleanCommon::execute()
 
       ListOfShape anObjectList = anObjects.objects();
       ListOfShape aToolsList;
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+      ModelAPI_Tools::loadModifiedShapes(aResultBody,
                                                anObjectList,
                                                aToolsList,
                                                aMakeShapeList,
@@ -139,7 +139,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       aResultIndex++;
 
       aToolsList = anObjectList;
-      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+      ModelAPI_Tools::ResultBaseAlgo aRBA;
       aRBA.resultBody = aResultBody;
       aRBA.baseShape = aBaseShape;
       aRBA.makeShape = aMakeShapeList;
@@ -194,7 +194,7 @@ void FeaturesPlugin_BooleanCommon::execute()
   // result shape has been deleted, but in another it was modified or stayed.
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
+  ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
                                           aTools.objects(),
                                           aResultCompound);
 
index f24d6f78bb7d322edfbe041f6256b3b4806b23ff..fe831bec36bf650739bebd7b3874ebccfb349439 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "FeaturesPlugin_BooleanCut.h"
 
-#include "FeaturesPlugin_Tools.h"
-
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
@@ -67,7 +65,7 @@ void FeaturesPlugin_BooleanCut::execute()
     return;
   }
 
-  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+  std::vector<ModelAPI_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
   std::string anError;
 
@@ -120,7 +118,7 @@ void FeaturesPlugin_BooleanCut::execute()
   // result shape has been deleted, but in another it was modified or stayed.
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
+  ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
                                           aTools.objects(),
                                           aResultCompound);
 
index de0c313baa9bf5c62ddb8a4043b67d9dcc854413..cbab08a645a056ba516c868be9597e6f996c0c73 100644 (file)
@@ -18,7 +18,6 @@
 //
 
 #include "FeaturesPlugin_BooleanFill.h"
-#include "FeaturesPlugin_Tools.h"
 
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
@@ -78,7 +77,7 @@ void FeaturesPlugin_BooleanFill::execute()
     return;
   }
 
-  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+  std::vector<ModelAPI_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
 
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
@@ -122,7 +121,7 @@ void FeaturesPlugin_BooleanFill::execute()
   // result shape has been deleted, but in another it was modified or stayed.
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
+  ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
                                           aTools.objects(),
                                           aResultCompound);
 
index 1214bb2147d2c0ffdf712727fb27c44dc5e20313..dd7f59d685fffec09e5f6bf0577d961ef2406562 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "FeaturesPlugin_BooleanFuse.h"
 
-#include "FeaturesPlugin_Tools.h"
-
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeInteger.h>
@@ -271,19 +269,19 @@ void FeaturesPlugin_BooleanFuse::execute()
   ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
 
   ListOfShape anEmptyTools;
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                           anOriginalShapes,
-                                           anEmptyTools,
-                                           aMakeShapeList,
-                                           aShape);
+  ModelAPI_Tools::loadModifiedShapes(aResultBody,
+                                     anOriginalShapes,
+                                     anEmptyTools,
+                                     aMakeShapeList,
+                                     aShape);
   setResult(aResultBody, aResultIndex);
   aResultIndex++;
 
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
-                                          GeomShapePtr(),
-                                          anOriginalShapes,
-                                          aMakeShapeList,
-                                          aShape);
+  ModelAPI_Tools::loadDeletedShapes(aResultBody,
+                                    GeomShapePtr(),
+                                    anOriginalShapes,
+                                    aMakeShapeList,
+                                    aShape);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index 2eb3753cccdbad18049892826a866ba343f87438..f8336b240b22b06d604c52197c83c014f714bae4 100644 (file)
@@ -19,8 +19,6 @@
 
 #include "FeaturesPlugin_BooleanSmash.h"
 
-#include "FeaturesPlugin_Tools.h"
-
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
@@ -175,20 +173,20 @@ void FeaturesPlugin_BooleanSmash::execute()
 
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
 
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                           anOriginalShapes,
-                                           anOriginalShapes,
-                                           aMakeShapeList,
-                                           aShape);
+  ModelAPI_Tools::loadModifiedShapes(aResultBody,
+                                     anOriginalShapes,
+                                     anOriginalShapes,
+                                     aMakeShapeList,
+                                     aShape);
 
   setResult(aResultBody, aResultIndex);
   aResultIndex++;
 
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
-                                          GeomShapePtr(),
-                                          anOriginalShapes,
-                                          aMakeShapeList,
-                                          aShape);
+  ModelAPI_Tools::loadDeletedShapes(aResultBody,
+                                    GeomShapePtr(),
+                                    anOriginalShapes,
+                                    aMakeShapeList,
+                                    aShape);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index ac60462ce6316acef4cd59863d275629795eb745..47291b11d3eac772c39691b6e727babb306beac2 100644 (file)
@@ -18,7 +18,6 @@
 //
 
 #include <FeaturesPlugin_Defeaturing.h>
-#include <FeaturesPlugin_Tools.h>
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
@@ -72,7 +71,7 @@ void FeaturesPlugin_Defeaturing::execute()
   int aResultIndex = 0;
   std::string anError;
 
-  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+  std::vector<ModelAPI_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape anOriginalShapesList, aResultShapesList;
 
   for (SolidFaces::iterator anIt = aBodiesAndFacesToRemove.begin();
@@ -90,13 +89,13 @@ void FeaturesPlugin_Defeaturing::execute()
       aBaseShapes.push_back(anExp.current());
 
     std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
-                                             anAlgo, aResult, "Defeaturing");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, aBaseShapes, ListOfShape(),
+                                       anAlgo, aResult, "Defeaturing");
 
     setResult(aResultBody, aResultIndex);
     aResultIndex++;
 
-    FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+    ModelAPI_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
     aRBA.baseShape = aParent;
     aRBA.makeShape = anAlgo;
@@ -108,7 +107,7 @@ void FeaturesPlugin_Defeaturing::execute()
   // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one
   // result shape has been deleted, but in another it was modified or stayed.
   GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
+  ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
       anOriginalShapesList, aResultShapesCompound);
 
   removeResults(aResultIndex);
index aa95790a54b023b4933f02153e0aaeb567288a9c..436462796606444f0f464522f301f0153fbc27f0 100644 (file)
 //
 
 #include "FeaturesPlugin_Extrusion.h"
-#include "FeaturesPlugin_Tools.h"
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAlgoAPI_Prism.h>
 #include <GeomAlgoAPI_Tools.h>
@@ -173,8 +173,8 @@ void FeaturesPlugin_Extrusion::storeResultWithBoundaries(
   ResultBodyPtr aResultBody = document()->createBody(data(), theIndex);
 
   // Store modified shapes.
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theBoundaryShapes, ListOfShape(),
-                                           theMakeShape, theMakeShape->shape());
+  ModelAPI_Tools::loadModifiedShapes(aResultBody, theBoundaryShapes, ListOfShape(),
+                                     theMakeShape, theMakeShape->shape());
 
   // Store generated edges/faces.
   storeGenerationHistory(aResultBody, theBaseShape, theMakeShape);
index b3b4b8493e54a56a7c55f10c48dc3188a0c89bbd..e1145fb52bb79fd1149f47b78c2dc9c7ef8416d5 100644 (file)
@@ -18,7 +18,6 @@
 //
 
 #include <FeaturesPlugin_Fillet1D.h>
-#include <FeaturesPlugin_Tools.h>
 
 #include <GeomAlgoAPI_Fillet1D.h>
 #include <GeomAlgoAPI_MapShapesAndAncestors.h>
@@ -33,6 +32,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_Tools.h>
 
 void sendMessageWithFailedShapes(const ListOfShape& theVertices)
 {
@@ -190,8 +190,8 @@ bool FeaturesPlugin_Fillet1D::performFillet(const GeomShapePtr& theWire,
   ResultBodyPtr aResult = document()->createBody(data(), theResultIndex);
   ListOfShape anOriginal;
   anOriginal.push_back(theWire);
-  FeaturesPlugin_Tools::loadModifiedShapes(aResult, anOriginal, ListOfShape(),
-                                           aFilletBuilder, aFilletBuilder->shape(), THE_PREFIX);
+  ModelAPI_Tools::loadModifiedShapes(aResult, anOriginal, ListOfShape(),
+                                     aFilletBuilder, aFilletBuilder->shape(), THE_PREFIX);
   setResult(aResult, theResultIndex);
   // store new edges generated from vertices
   for (ListOfShape::const_iterator anIt = theVertices.begin(); anIt != theVertices.end(); ++anIt)
index 1ded92cbecf35142b7e4d72a88e5446e08829143..b01ab3a49117620027b28caf325056810610c3f8 100644 (file)
@@ -18,7 +18,6 @@
 //
 
 #include "FeaturesPlugin_FusionFaces.h"
-#include "FeaturesPlugin_Tools.h"
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
@@ -26,6 +25,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -73,7 +73,7 @@ void FeaturesPlugin_FusionFaces::execute()
 
   ListOfShape aBaseShapesList;
   aBaseShapesList.push_back(aBaseShape);
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShapesList, ListOfShape(),
-                                           anAlgo, aResultShape);
+  ModelAPI_Tools::loadModifiedShapes(aResultBody, aBaseShapesList, ListOfShape(),
+                                     anAlgo, aResultShape);
   setResult(aResultBody);
 }
index aa95218e08e118772d62fac93e579602d6afd92f..4a2c31715024abc290416df69d80a357a58217ba 100644 (file)
@@ -24,6 +24,7 @@
 #include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Tools.h>
 
 #include <GeomAlgoAPI_Intersection.h>
 #include <GeomAlgoAPI_MakeShapeList.h>
@@ -84,19 +85,19 @@ void FeaturesPlugin_Intersection::execute()
   }
 
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                           anObjects,
-                                           ListOfShape(),
-                                           aMakeShapeList,
-                                           aResShape);
+  ModelAPI_Tools::loadModifiedShapes(aResultBody,
+                                     anObjects,
+                                     ListOfShape(),
+                                     aMakeShapeList,
+                                     aResShape);
   setResult(aResultBody, aResultIndex);
   aResultIndex++;
 
-  FeaturesPlugin_Tools::loadDeletedShapes(aResultBody,
-                                          GeomShapePtr(),
-                                          anObjects,
-                                          aMakeShapeList,
-                                          aResShape);
+  ModelAPI_Tools::loadDeletedShapes(aResultBody,
+                                    GeomShapePtr(),
+                                    anObjects,
+                                    aMakeShapeList,
+                                    aResShape);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index a3f08292a9234dc0fcb43208d934e485ad129f41..4e3d05ba23f41abe7458901cd29e9c10c768062e 100644 (file)
@@ -224,8 +224,8 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
   anObjects.topLevelObjects(aTopLevel);
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Rotated");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Rotated");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
index 5fafcb11a144315bba93ec574b948a943422252c..8ee89a08f6003f9e18344ecb939cb1a6b5e3624a 100644 (file)
@@ -170,8 +170,8 @@ void FeaturesPlugin_MultiTranslation::execute()
   anObjects.topLevelObjects(aTopLevel);
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Translated");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Translated");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
index 8b109aed114fa416b21a60de1fc908363bb61f6a..a357658f5cae9cfa316f4aa7e2215ba10ca56952 100644 (file)
@@ -179,8 +179,8 @@ void FeaturesPlugin_Placement::execute()
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     //LoadNamingDS
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Placed");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Placed");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
index 8627c4c64aed5d9b961ed1a9dcfddd6ea0710c5a..473d5964a3cedece2e8b960c44fbc0155dfe64f9 100644 (file)
@@ -225,8 +225,8 @@ void FeaturesPlugin_Rotation::performRotation(const GeomTrsfPtr& theTrsf)
   anObjects.topLevelObjects(aTopLevel);
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Rotated");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Rotated");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
index 6766e10dc39f59c1bcafae58e8529363cce4c249..f53834fc5ba0507ef52f0a57055083b487ecc614 100644 (file)
@@ -142,8 +142,8 @@ void FeaturesPlugin_Scale::performScaleByFactor()
   anObjects.topLevelObjects(aTopLevel);
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Scaled");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Scaled");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
@@ -215,8 +215,8 @@ void FeaturesPlugin_Scale::performScaleByDimensions()
   anObjects.topLevelObjects(aTopLevel);
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Scaled");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Scaled");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
index 9a5830bcfdb1dad80651494f3ee2a049d7ec61dc..5ad5d61a2d7e4460ce430a5fc7135f4254bc5a07 100644 (file)
@@ -209,8 +209,8 @@ void FeaturesPlugin_Symmetry::buildResult(
 {
   // Store and name the result.
   ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
-  FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theOriginalShapes, ListOfShape(),
-                                           theAlgo, theTargetShape, "Symmetried");
+  ModelAPI_Tools::loadModifiedShapes(aResultBody, theOriginalShapes, ListOfShape(),
+                                     theAlgo, theTargetShape, "Symmetried");
   // Copy image data, if any
   ModelAPI_Tools::copyImageAttribute(theTextureSource, aResultBody);
   setResult(aResultBody, theResultIndex++);
index d1a690ce1abeb1069d4db39ab36cb62637025b8d..a777af3b594e83200626979cbb82db53b0e14980 100644 (file)
 
 #include <GeomValidators_ShapeType.h>
 
-//==================================================================================================
-void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
-                                              const ListOfShape& theBaseShapes,
-                                              const ListOfShape& theTools,
-                                              const GeomMakeShapePtr& theMakeShape,
-                                              const GeomShapePtr theResultShape,
-                                              const std::string& theNamePrefix)
-{
-  theResultBody->storeModified(theBaseShapes, theResultShape, theMakeShape);
-
-  ListOfShape aShapes = theBaseShapes;
-  ListOfShape::const_iterator aToolIter = theTools.cbegin();
-  for(; aToolIter != theTools.cend(); aToolIter++)
-    aShapes.push_back(*aToolIter);
-
-  for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
-  {
-    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX, theNamePrefix);
-    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE, theNamePrefix);
-    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE, theNamePrefix);
-  }
-}
-
-//==================================================================================================
-void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
-                                              const GeomShapePtr& theBaseShape,
-                                              const GeomMakeShapePtr& theMakeShape,
-                                              const std::string theName)
-{
-  switch(theBaseShape->shapeType()) {
-    case GeomAPI_Shape::COMPOUND: {
-      for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next())
-      {
-        loadModifiedShapes(theResultBody,
-                           anIt.current(),
-                           theMakeShape,
-                           theName);
-      }
-      break;
-    }
-    case GeomAPI_Shape::COMPSOLID:
-    case GeomAPI_Shape::SOLID:
-    case GeomAPI_Shape::SHELL: {
-      theResultBody->loadModifiedShapes(theMakeShape,
-                                        theBaseShape,
-                                        GeomAPI_Shape::FACE,
-                                        theName);
-    }
-    case GeomAPI_Shape::FACE:
-    case GeomAPI_Shape::WIRE: {
-      theResultBody->loadModifiedShapes(theMakeShape,
-                                        theBaseShape,
-                                        GeomAPI_Shape::EDGE,
-                                        theName);
-    }
-    case GeomAPI_Shape::EDGE: {
-      theResultBody->loadModifiedShapes(theMakeShape,
-                                        theBaseShape,
-                                        GeomAPI_Shape::VERTEX,
-                                        theName);
-    }
-    default: // [to avoid compilation warning]
-      break;
-  }
-}
-
-//==================================================================================================
-void FeaturesPlugin_Tools::loadDeletedShapes(ResultBodyPtr theResultBody,
-  const GeomShapePtr theBaseShape,
-  const ListOfShape& theTools,
-  const GeomMakeShapePtr& theMakeShape,
-  const GeomShapePtr theResultShapesCompound)
-{
-  ListOfShape aShapes = theTools;
-  if (theBaseShape.get())
-    aShapes.push_front(theBaseShape);
-
-  for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++)
-  {
-    theResultBody->loadDeletedShapes(theMakeShape,
-                                     *anIter,
-                                     GeomAPI_Shape::VERTEX,
-                                     theResultShapesCompound);
-    theResultBody->loadDeletedShapes(theMakeShape,
-                                     *anIter,
-                                     GeomAPI_Shape::EDGE,
-                                     theResultShapesCompound);
-    theResultBody->loadDeletedShapes(theMakeShape,
-                                     *anIter,
-                                     GeomAPI_Shape::FACE,
-                                     theResultShapesCompound);
-    // store information about deleted solids because of unittest TestBooleanCommon_SolidsHistory
-    // on OCCT 7.4.0 : common produces modified compsolid, so, move to the end for removed solids
-    // starts to produce whole compsolid
-    theResultBody->loadDeletedShapes(theMakeShape,
-                                     *anIter,
-                                     GeomAPI_Shape::SOLID,
-                                     theResultShapesCompound);
-  }
-}
-
-//==================================================================================================
-void FeaturesPlugin_Tools::loadDeletedShapes(
-  std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
-  const ListOfShape& theTools,
-  const GeomShapePtr theResultShapesCompound)
-{
-  for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
-       anIt != theResultBaseAlgoList.end();
-       ++anIt)
-  {
-    ResultBaseAlgo& aRCA = *anIt;
-    loadDeletedShapes(aRCA.resultBody,
-                      aRCA.baseShape,
-                      theTools,
-                      aRCA.makeShape,
-                      theResultShapesCompound);
-  }
-}
-
 //==================================================================================================
 bool FeaturesPlugin_Tools::getShape(const AttributeSelectionListPtr theSelectionList,
                                     const bool theShareTopology,
index e901063fd9949fb55f43445fa7c72e6b88d11c69..306d00db8ecffe30164b59c82e30a07dff39f118 100644 (file)
 
 class FeaturesPlugin_Tools {
 public:
-  struct ResultBaseAlgo {
-    ResultBodyPtr resultBody;
-    GeomShapePtr baseShape;
-    GeomMakeShapePtr makeShape;
-  };
-
-public:
-  static void loadModifiedShapes(ResultBodyPtr theResultBody,
-                                 const ListOfShape& theBaseShapes,
-                                 const ListOfShape& theTools,
-                                 const GeomMakeShapePtr& theMakeShape,
-                                 const GeomShapePtr theResultShape,
-                                 const std::string& theNamePrefix = "");
-
-  static void loadModifiedShapes(ResultBodyPtr theResultBody,
-                                 const GeomShapePtr& theBaseShape,
-                                 const GeomMakeShapePtr& theMakeShape,
-                                 const std::string theName);
-  /// Stores deleted shapes.
-  static void loadDeletedShapes(ResultBodyPtr theResultBody,
-                                const GeomShapePtr theBaseShape,
-                                const ListOfShape& theTools,
-                                const GeomMakeShapePtr& theMakeShape,
-                                const GeomShapePtr theResultShapesCompound);
-
-  /// Stores deleted shapes.
-  static void loadDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
-                                const ListOfShape& theTools,
-                                const GeomShapePtr theResultShapesCompound);
-
   /// Obtain shapes from the selection list attribute.
   static bool getShape(const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
                        const bool theShareTopology,
index 9586fea926fe33a8cd88196856d5def7581ccf41..93aa595ede7ce85efe36bed1a960925cc58119eb 100644 (file)
@@ -240,8 +240,8 @@ void FeaturesPlugin_Translation::performTranslation(const GeomTrsfPtr& theTrsf)
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     //LoadNamingDS
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
-                                             aMakeShapeList, *anIt, "Translated");
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
+                                       aMakeShapeList, *anIt, "Translated");
     // Copy image data, if any
     ModelAPI_Tools::copyImageAttribute(aTextureSource, aResultBody);
     setResult(aResultBody, aResultIndex++);
index ad7a638de10fa2e6effa1ff9bb2e8f63a78fbc58..8120f025dbb4a4176e7820d6355daec0055dea31 100644 (file)
@@ -62,7 +62,7 @@ void FeaturesPlugin_Union::execute()
 
   std::string anError;
   int aResultIndex = 0;
-  std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
+  std::vector<ModelAPI_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
 
   GeomShapePtr aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(ListOfShape());
@@ -93,7 +93,7 @@ void FeaturesPlugin_Union::execute()
   }
 
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
-  for (std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>::iterator
+  for (std::vector<ModelAPI_Tools::ResultBaseAlgo>::iterator
        aRBAIt = aResultBaseAlgoList.begin();
        aRBAIt != aResultBaseAlgoList.end(); ++aRBAIt) {
     aMakeShapeList->appendAlgo(aRBAIt->makeShape);
index 50dd45bcbcc5a26f4fdc4a123bbd7af1f98dd4c1..d2fe447f336e40d9477c5c830b4a84cb61f2db24 100644 (file)
@@ -123,7 +123,7 @@ bool FeaturesPlugin_VersionedBoolean::processObject(
     const ListOfShape& theTools,
     const ListOfShape& thePlanes,
     int& theResultIndex,
-    std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
+    std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     ListOfShape& theResultShapesList,
     GeomShapePtr theResultCompound)
 {
@@ -187,7 +187,7 @@ bool FeaturesPlugin_VersionedBoolean::processObject(
       ListOfShape aUsedTools = theTools;
       aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
 
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+      ModelAPI_Tools::loadModifiedShapes(aResultBody,
                                                aListWithObject,
                                                aUsedTools,
                                                aMakeShapeList,
@@ -197,7 +197,7 @@ bool FeaturesPlugin_VersionedBoolean::processObject(
     }
 
 
-    FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+    ModelAPI_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
     aRBA.baseShape = theObject;
     aRBA.makeShape = aMakeShapeList;
@@ -215,7 +215,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompsolid(
     const ListOfShape& theTools,
     const ListOfShape& thePlanes,
     int& theResultIndex,
-    std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
+    std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     ListOfShape& theResultShapesList,
     GeomShapePtr theResultCompound)
 {
@@ -283,7 +283,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompsolid(
       ListOfShape aUsedTools = theTools;
       aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
 
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+      ModelAPI_Tools::loadModifiedShapes(aResultBody,
                                                aCompSolidList,
                                                aUsedTools,
                                                aMakeShapeList,
@@ -292,7 +292,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompsolid(
       ++theResultIndex;
     }
 
-    FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+    ModelAPI_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
     aRBA.baseShape = theCompsolid;
     aRBA.makeShape = aMakeShapeList;
@@ -309,7 +309,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompound(
     const GeomShapePtr& theCompound,
     const ListOfShape& theTools,
     int& theResultIndex,
-    std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
+    std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     ListOfShape& theResultShapesList,
     GeomShapePtr theResultCompound)
 {
@@ -372,7 +372,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompound(
 
       ListOfShape aCompoundList;
       aCompoundList.push_back(theCompound);
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
+      ModelAPI_Tools::loadModifiedShapes(aResultBody,
                                                aCompoundList,
                                                theTools,
                                                aMakeShapeList,
@@ -381,7 +381,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompound(
       ++theResultIndex;
     }
 
-    FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
+    ModelAPI_Tools::ResultBaseAlgo aRBA;
     aRBA.resultBody = aResultBody;
     aRBA.baseShape = theCompound;
     aRBA.makeShape = aMakeShapeList;
index f244542b9200a0142eb11735abf10a425cbb5090..62fecd361af3ec187f92bb2802fd66cf004fd018 100644 (file)
@@ -27,6 +27,7 @@
 #include <GeomAlgoAPI_Tools.h>
 
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Tools.h>
 
 class ModelAPI_Attribute;
 class ModelAPI_Result;
@@ -70,7 +71,7 @@ protected:
                      const ListOfShape& theTools,
                      const ListOfShape& thePlanes,
                      int& theResultIndex,
-                     std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
+                     std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                      ListOfShape& theResultShapesList,
                      GeomShapePtr theResulCompound = GeomShapePtr());
 
@@ -84,7 +85,7 @@ protected:
                         const ListOfShape& theTools,
                         const ListOfShape& thePlanes,
                         int& theResultIndex,
-                        std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
+                        std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                         ListOfShape& theResultShapesList,
                         GeomShapePtr theResulCompound = GeomShapePtr());
 
@@ -97,7 +98,7 @@ protected:
                        const GeomShapePtr& theCompound,
                        const ListOfShape& theTools,
                        int& theResultIndex,
-                       std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
+                       std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                        ListOfShape& theResultShapesList,
                        GeomShapePtr theResulCompound = GeomShapePtr());
 
index 7417bf570c64986fbd01f2722bb007217c0b8fa4..0239b2221ad1863d1b1fc3339dc903f420211965 100644 (file)
@@ -18,7 +18,6 @@
 //
 
 #include "FeaturesPlugin_VersionedChFi.h"
-#include "FeaturesPlugin_Tools.h"
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
@@ -89,8 +88,8 @@ void FeaturesPlugin_VersionedChFi::execute()
   anObjectHierarchy.topLevelObjects(aTopLevel);
   for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt) {
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalSolids, ListOfShape(),
-                                             aMakeShapeList, *anIt, aPrefix);
+    ModelAPI_Tools::loadModifiedShapes(aResultBody, anOriginalSolids, ListOfShape(),
+                                       aMakeShapeList, *anIt, aPrefix);
     setResult(aResultBody, aResultIndex++);
 
     for (ListOfShape::iterator aEIt = anEdges.begin(); aEIt != anEdges.end(); ++aEIt) {
@@ -99,8 +98,8 @@ void FeaturesPlugin_VersionedChFi::execute()
       aResultBody->loadGeneratedShapes(aMakeShapeList, aBase, GeomAPI_Shape::EDGE, aPrefix, true);
     }
 
-    FeaturesPlugin_Tools::loadDeletedShapes(aResultBody, GeomShapePtr(), anOriginalSolids,
-                                            aMakeShapeList, *anIt);
+    ModelAPI_Tools::loadDeletedShapes(aResultBody, GeomShapePtr(), anOriginalSolids,
+                                      aMakeShapeList, *anIt);
   }
 
   removeResults(aResultIndex);
index c8b558e375705d666043ae49df1cb9bae4929984..f928eedda2c0dcdc0889473c57dcf9000ba442bb 100644 (file)
@@ -149,15 +149,15 @@ public:
 protected:
   /// \brief Sets builder type.
   /// \param[in] theBuilderType new builder type.
-  void setBuilderType(const BuilderType theBuilderType);
+  GEOMALGOAPI_EXPORT void setBuilderType(const BuilderType theBuilderType);
 
   /// \brief Sets status of builder.
   /// \param[in] theFlag new status.
-  void setDone(const bool theFlag);
+  GEOMALGOAPI_EXPORT void setDone(const bool theFlag);
 
   /// \brief Sets result shape.
   /// \param[in] theShape new shape.
-  void setShape(const GeomShapePtr theShape);
+  GEOMALGOAPI_EXPORT void setShape(const GeomShapePtr theShape);
 
   /// \return true if passed shape is valid for history.
   bool isValidForHistory(const GeomShapePtr theShape);
index eb4ab5ff98229ea4a7fc46074a9352c61c304bc8..38ed84cfcc6d40a097513abb121253bbfa88eb5d 100644 (file)
@@ -179,6 +179,11 @@ std::list<std::string> Model_Session::redoList()
   return ROOT_DOC->redoList();
 }
 
+bool Model_Session::checkLicense(const std::string& thePluginName)
+{
+  return getPlugin(thePluginName);
+}
+
 ModelAPI_Plugin* Model_Session::getPlugin(const std::string& thePluginName)
 {
   if (myPluginObjs.find(thePluginName) == myPluginObjs.end()) {
index 218659d5a887dc4c5734fa32ad4eaf9435df82e3..88397ec4ce886b058126db18cd2aa9551345a7a0 100644 (file)
@@ -127,6 +127,9 @@ class Model_Session : public ModelAPI_Session, public Events_Listener
   /// the plugin manager on call of the feature)
   MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
 
+  /// Verifies the license for the plugin is valid
+  MODEL_EXPORT virtual bool checkLicense(const std::string& thePluginName);
+
   /// Processes the configuration file reading
   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
index bfe2cdb2aa034db6f9b89327c98553fb8aa13eb5..82d4c8e22b51c624ad164f7085c5678c384efd5d 100644 (file)
@@ -470,3 +470,23 @@ const ListOfShape& ModelAPI_ShapesFailedMessage::shapes() const
 {
   return myShapes;
 }
+
+
+// =====   ModelAPI_FeaturesLicenseValidMessage   =====
+ModelAPI_FeaturesLicenseValidMessage::ModelAPI_FeaturesLicenseValidMessage(
+    const Events_ID theID, const void* theSender)
+  : Events_Message(theID, theSender)
+{}
+
+ModelAPI_FeaturesLicenseValidMessage::~ModelAPI_FeaturesLicenseValidMessage()
+{}
+
+void ModelAPI_FeaturesLicenseValidMessage::setFeatures(const std::set<std::string>& theFeatures)
+{
+  myFeatures = theFeatures;
+}
+
+const std::set<std::string>& ModelAPI_FeaturesLicenseValidMessage::features() const
+{
+  return myFeatures;
+}
index 61b4d7bf09aed0c84a794cd33a41bb6f70400647..247f51bc3cb1422429b60b19077425c8d8a4d466 100644 (file)
@@ -119,10 +119,12 @@ MAYBE_UNUSED static const char * EVENT_DOF_OBJECTS = "DoFObjects";
 /// Event ID that requests updates visual attributes for presentations
 MAYBE_UNUSED static const char * EVENT_VISUAL_ATTRIBUTES = "UpdateVisualAttributes";
 
-
 /// Event ID that 1D-fillet failed (comes with ModelAPI_ShapesFailedMessage)
 MAYBE_UNUSED static const char * EVENT_OPERATION_SHAPES_FAILED = "OperationShapesFailed";
 
+/// Event ID that license of specified features is checked and valid
+MAYBE_UNUSED static const char * EVENT_FEATURE_LICENSE_VALID = "FeaturesLicenseValid";
+
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
 {
@@ -657,4 +659,28 @@ private:
   std::list< std::shared_ptr<GeomAPI_Shape> > myShapes;
 };
 
+/// Message that sends the features which license is checked and valid
+class ModelAPI_FeaturesLicenseValidMessage : public Events_Message
+{
+public:
+  /// Creates an message
+  MODELAPI_EXPORT
+  ModelAPI_FeaturesLicenseValidMessage(const Events_ID theID, const void* theSender = 0);
+  /// Default destructor
+  MODELAPI_EXPORT virtual ~ModelAPI_FeaturesLicenseValidMessage();
+  /// Static. Returns EventID of the message.
+  MODELAPI_EXPORT static Events_ID eventId()
+  {
+    return Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID);
+  }
+
+  /// Sets list of features with valid license
+  MODELAPI_EXPORT void setFeatures(const std::set<std::string>& theFeatures);
+  /// Returns list of features with valid license
+  MODELAPI_EXPORT const std::set<std::string>& features() const;
+
+private:
+  std::set<std::string> myFeatures;
+};
+
 #endif
index 339263fb0f0ceccd48008f63fdf2829226396c6f..7a1b2f40deb85da888ff3a020e4cf07e1447311b 100644 (file)
@@ -97,6 +97,9 @@ class MODELAPI_EXPORT ModelAPI_Session
   /// the plugin manager on call of the feature)
   virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
 
+  /// Verifies the license for the plugin is valid
+  virtual bool checkLicense(const std::string& thePluginName) = 0;
+
   /// Returns the root document of the application (that may contains sub-documents)
   virtual std::shared_ptr<ModelAPI_Document> moduleDocument() = 0;
 
index 9554d1e1068b0ac9021f8c493b059c8408c2b79b..282a40de4e74c423ab8ba172ca5c74005c9c1706 100644 (file)
@@ -40,6 +40,7 @@
 #include <Events_Loop.h>
 #include <Locale_Convert.h>
 
+#include <GeomAlgoAPI_MakeShape.h>
 #include <GeomAPI_ShapeHierarchy.h>
 #include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -199,6 +200,125 @@ ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGro
   return ObjectPtr();
 }
 
+//==================================================================================================
+void loadModifiedShapes(ResultBodyPtr theResultBody,
+                        const ListOfShape& theBaseShapes,
+                        const ListOfShape& theTools,
+                        const GeomMakeShapePtr& theMakeShape,
+                        const GeomShapePtr theResultShape,
+                        const std::string& theNamePrefix)
+{
+  theResultBody->storeModified(theBaseShapes, theResultShape, theMakeShape);
+
+  ListOfShape aShapes = theBaseShapes;
+  ListOfShape::const_iterator aToolIter = theTools.cbegin();
+  for (; aToolIter != theTools.cend(); aToolIter++)
+    aShapes.push_back(*aToolIter);
+
+  for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter)
+  {
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX, theNamePrefix);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE, theNamePrefix);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE, theNamePrefix);
+  }
+}
+
+//==================================================================================================
+void loadModifiedShapes(ResultBodyPtr theResultBody,
+                        const GeomShapePtr& theBaseShape,
+                        const GeomMakeShapePtr& theMakeShape,
+                        const std::string theName)
+{
+  switch (theBaseShape->shapeType()) {
+  case GeomAPI_Shape::COMPOUND: {
+    for (GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next())
+    {
+      loadModifiedShapes(theResultBody,
+        anIt.current(),
+        theMakeShape,
+        theName);
+    }
+    break;
+  }
+  case GeomAPI_Shape::COMPSOLID:
+  case GeomAPI_Shape::SOLID:
+  case GeomAPI_Shape::SHELL: {
+    theResultBody->loadModifiedShapes(theMakeShape,
+      theBaseShape,
+      GeomAPI_Shape::FACE,
+      theName);
+  }
+  case GeomAPI_Shape::FACE:
+  case GeomAPI_Shape::WIRE: {
+    theResultBody->loadModifiedShapes(theMakeShape,
+      theBaseShape,
+      GeomAPI_Shape::EDGE,
+      theName);
+  }
+  case GeomAPI_Shape::EDGE: {
+    theResultBody->loadModifiedShapes(theMakeShape,
+      theBaseShape,
+      GeomAPI_Shape::VERTEX,
+      theName);
+  }
+  default: // [to avoid compilation warning]
+    break;
+  }
+}
+
+//==================================================================================================
+void loadDeletedShapes(ResultBodyPtr theResultBody,
+                      const GeomShapePtr theBaseShape,
+                      const ListOfShape& theTools,
+                      const GeomMakeShapePtr& theMakeShape,
+                      const GeomShapePtr theResultShapesCompound)
+{
+  ListOfShape aShapes = theTools;
+  if (theBaseShape.get())
+    aShapes.push_front(theBaseShape);
+
+  for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++)
+  {
+    theResultBody->loadDeletedShapes(theMakeShape,
+      *anIter,
+      GeomAPI_Shape::VERTEX,
+      theResultShapesCompound);
+    theResultBody->loadDeletedShapes(theMakeShape,
+      *anIter,
+      GeomAPI_Shape::EDGE,
+      theResultShapesCompound);
+    theResultBody->loadDeletedShapes(theMakeShape,
+      *anIter,
+      GeomAPI_Shape::FACE,
+      theResultShapesCompound);
+    // store information about deleted solids because of unittest TestBooleanCommon_SolidsHistory
+    // on OCCT 7.4.0 : common produces modified compsolid, so, move to the end for removed solids
+    // starts to produce whole compsolid
+    theResultBody->loadDeletedShapes(theMakeShape,
+      *anIter,
+      GeomAPI_Shape::SOLID,
+      theResultShapesCompound);
+  }
+}
+
+//==================================================================================================
+void loadDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+                        const ListOfShape& theTools,
+                        const GeomShapePtr theResultShapesCompound)
+{
+  for (std::vector<ResultBaseAlgo>::iterator anIt = theResultBaseAlgoList.begin();
+    anIt != theResultBaseAlgoList.end();
+    ++anIt)
+  {
+    ResultBaseAlgo& aRCA = *anIt;
+    loadDeletedShapes(aRCA.resultBody,
+      aRCA.baseShape,
+      theTools,
+      aRCA.makeShape,
+      theResultShapesCompound);
+  }
+}
+
 bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
                   const std::wstring& theName, double& outValue, ResultParameterPtr& theParam)
 {
index 68545c09cf5848a63c625b81d76cdcebd1289ddb..904b82132671fdd1dc329b2ed8d697ff6fcf7f40 100644 (file)
@@ -30,6 +30,7 @@ class ModelAPI_Result;
 class ModelAPI_ResultParameter;
 class ModelAPI_ResultBody;
 
+class GeomAlgoAPI_MakeShape;
 class GeomAPI_Shape;
 class GeomAPI_ShapeHierarchy;
 
@@ -50,6 +51,35 @@ MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(
  */
 MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Feature>& theFeature);
 
+MODELAPI_EXPORT struct ResultBaseAlgo {
+  std::shared_ptr<ModelAPI_ResultBody> resultBody;
+  std::shared_ptr<GeomAPI_Shape> baseShape;
+  std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape;
+};
+
+MODELAPI_EXPORT void loadModifiedShapes(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+  const std::list<std::shared_ptr<GeomAPI_Shape>>& theBaseShapes,
+  const std::list<std::shared_ptr<GeomAPI_Shape>>& theTools,
+  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
+  const std::shared_ptr<GeomAPI_Shape> theResultShape,
+  const std::string& theNamePrefix = "");
+
+MODELAPI_EXPORT void loadModifiedShapes(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+  const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
+  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
+  const std::string theName);
+/// Stores deleted shapes.
+MODELAPI_EXPORT void loadDeletedShapes(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+  const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+  const std::list<std::shared_ptr<GeomAPI_Shape>>& theTools,
+  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
+  const std::shared_ptr<GeomAPI_Shape> theResultShapesCompound);
+
+/// Stores deleted shapes.
+MODELAPI_EXPORT void loadDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
+  const std::list<std::shared_ptr<GeomAPI_Shape>>& theTools,
+  const std::shared_ptr<GeomAPI_Shape> theResultShapesCompound);
+
 /*!
  * Searches for variable with name \param theName in \param theDocument.
  * If found, set it value in the \param outValue and returns true.
index 678837a4db2023c5911493d20e5f44e6d41310f4..90124f8d9b4a38dd0629ce62a62a8c2fb3ffdf02 100644 (file)
@@ -34,6 +34,7 @@
 #include "ModuleBase_Dialog.h"
 #include "ModuleBase_IErrorMgr.h"
 
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 #include <Events_Message.h>
 
@@ -219,6 +220,33 @@ void ModuleBase_IModule::createFeatures()
   Config_ModuleReader aXMLReader = Config_ModuleReader();
   aXMLReader.readAll();
   myFeaturesInFiles = aXMLReader.featuresInFiles();
+  myProprietaryFeatures = aXMLReader.proprietaryFeatures();
+  myProprietaryPlugins = aXMLReader.proprietaryPlugins();
+}
+
+void ModuleBase_IModule::processProprietaryFeatures()
+{
+  std::set<std::string>::iterator it = myFeaturesValidLicense.begin();
+  while (it != myFeaturesValidLicense.end()) {
+    std::map<std::string, std::string>::iterator aFound = myProprietaryFeatures.find(*it);
+    if (aFound == myProprietaryFeatures.end())
+      ++it;
+    else {
+      myFeaturesInFiles[aFound->first] = aFound->second;
+      myProprietaryFeatures.erase(aFound);
+      std::set<std::string>::iterator aRemoveIt = it++;
+      myFeaturesValidLicense.erase(aRemoveIt);
+    }
+  }
+}
+
+void ModuleBase_IModule::loadProprietaryPlugins()
+{
+  for (std::set<std::string>::const_iterator itP = myProprietaryPlugins.begin();
+       itP != myProprietaryPlugins.end(); ++itP) {
+    if (!ModelAPI_Session::get()->checkLicense(*itP))
+      Events_InfoMessage(*itP, "License of %1 plugin is not valid or not exist!").arg(*itP).send();
+  }
 }
 
 
index 3c3544e11603ec16b3d3d8f64739d56944204cc8..6ab1badf267b0f3c36d37ed58177135229d01982 100644 (file)
@@ -443,12 +443,24 @@ protected:
   /// Returns new instance of operation object (used in createOperation for customization)
   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
 
+  /// Load plugins required license
+  void loadProprietaryPlugins();
+
+  /// Collect features, which have valid license
+  void processProprietaryFeatures();
+
 protected:
   /// Reference to workshop
   ModuleBase_IWorkshop* myWorkshop;
 
   /// Map of features in XML
   std::map<std::string, std::string> myFeaturesInFiles;
+  /// Map of features in XML, which require license but not confirmed yet
+  std::map<std::string, std::string> myProprietaryFeatures;
+  /// Proprietary plugins
+  std::set<std::string> myProprietaryPlugins;
+  /// Features, which have valid license
+  std::set<std::string> myFeaturesValidLicense;
 
   std::map<ModuleBase_SelectionFilterType, Handle(SelectMgr_Filter)> mySelectionFilters;
 
index 8add0208abd914e959b64cd0e701d210b09510c4..70935fa37dcf2b7ada4632aaeeb8182c8d87bebf 100644 (file)
@@ -186,6 +186,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LICENSE_VALID));
 
   registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
   registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
@@ -285,6 +286,7 @@ void PartSet_Module::createFeatures()
   ModuleBase_IModule::createFeatures();
   myRoot = new PartSet_RootNode();
   myRoot->setWorkshop(workshop());
+  ModuleBase_IModule::loadProprietaryPlugins();
 }
 
 
@@ -1767,6 +1769,12 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
         mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
     }
   }
+  else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LICENSE_VALID)) {
+    std::shared_ptr<ModelAPI_FeaturesLicenseValidMessage> aMsg =
+      std::dynamic_pointer_cast<ModelAPI_FeaturesLicenseValidMessage>(theMessage);
+    myFeaturesValidLicense.insert(aMsg->features().begin(), aMsg->features().end());
+    processProprietaryFeatures();
+  }
 }
 
 //******************************************************
index 6e2d15b704e802e28984f3da075e173c7a7b1b5f..a92957fdfbd380d8a247a24bd414eec71249a047 100644 (file)
@@ -44,3 +44,14 @@ from .partset import *
 from .primitives import *
 from .gdml import *
 from .tests import *
+
+# Add-on features
+
+from .addons import *
+# move functions from .addons to top level (model) package
+import inspect
+for attribute_name in dir(addons):
+    attribute = getattr(addons, attribute_name)
+    if inspect.isfunction(attribute):
+        globals()[attribute_name] = attribute
+del inspect
diff --git a/src/PythonAPI/model/addons/__init__.py b/src/PythonAPI/model/addons/__init__.py
new file mode 100644 (file)
index 0000000..cd91178
--- /dev/null
@@ -0,0 +1,33 @@
+# Copyright (C) 2015-2020  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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import pkgutil, inspect
+
+__all__ = []
+for loader, module_name, is_pkg in pkgutil.walk_packages(__path__):
+    __all__.append(module_name)
+    module = loader.find_module(module_name).load_module(module_name)
+    globals()[module_name] = module
+
+    for attribute_name in dir(module):
+        attribute = getattr(module, attribute_name)
+        if inspect.isfunction(attribute):
+            globals()[attribute_name] = attribute
+
+del pkgutil, inspect
\ No newline at end of file