Salome HOME
Issue #1369: moved Wire feature to new Build plug-in.
authordbv <dbv@opencascade.com>
Mon, 18 Apr 2016 12:57:20 +0000 (15:57 +0300)
committerdbv <dbv@opencascade.com>
Mon, 18 Apr 2016 12:59:58 +0000 (15:59 +0300)
20 files changed:
CMakeLists.txt
src/BuildPlugin/BuildPlugin.h [new file with mode: 0644]
src/BuildPlugin/BuildPlugin_Plugin.cpp [new file with mode: 0644]
src/BuildPlugin/BuildPlugin_Plugin.h [new file with mode: 0644]
src/BuildPlugin/BuildPlugin_Validators.cpp [new file with mode: 0644]
src/BuildPlugin/BuildPlugin_Validators.h [new file with mode: 0644]
src/BuildPlugin/BuildPlugin_Wire.cpp [new file with mode: 0644]
src/BuildPlugin/BuildPlugin_Wire.h [new file with mode: 0644]
src/BuildPlugin/CMakeLists.txt [new file with mode: 0644]
src/BuildPlugin/icons/feature_wire.png [new file with mode: 0644]
src/BuildPlugin/plugin-Build.xml [new file with mode: 0644]
src/BuildPlugin/wire_widget.xml [new file with mode: 0644]
src/Config/plugins.xml.in
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_Wire.cpp [deleted file]
src/FeaturesPlugin/FeaturesPlugin_Wire.h [deleted file]
src/FeaturesPlugin/icons/feature_wire.png [deleted file]
src/FeaturesPlugin/plugin-Features.xml
src/FeaturesPlugin/wire_widget.xml [deleted file]

index 649cf98c0b7ac766fed17fb5cee86f7def5faadf..4f430b1c60f704a85eafbc133d4acf18cd23ecaa 100644 (file)
@@ -78,6 +78,7 @@ ADD_SUBDIRECTORY (src/GeomData)
 ADD_SUBDIRECTORY (src/GeomDataAPI)
 ADD_SUBDIRECTORY (src/PartSetPlugin)
 ADD_SUBDIRECTORY (src/ConstructionPlugin)
+ADD_SUBDIRECTORY (src/BuildPlugin)
 ADD_SUBDIRECTORY (src/FeaturesPlugin)
 ADD_SUBDIRECTORY (src/SamplePanelPlugin)
 ADD_SUBDIRECTORY (src/SketcherPrs)
diff --git a/src/BuildPlugin/BuildPlugin.h b/src/BuildPlugin/BuildPlugin.h
new file mode 100644 (file)
index 0000000..da80217
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        BuildPlugin.h
+// Created:     18 April 2016
+// Author:      Dmitry Bobylev
+
+#ifndef BuildPlugin_H_
+#define BuildPlugin_H_
+
+#if defined BUILDPLUGIN_EXPORTS
+# if defined WIN32
+#  define BUILDPLUGIN_EXPORT __declspec( dllexport )
+# else
+#  define BUILDPLUGIN_EXPORT
+# endif
+#else
+# if defined WIN32
+#  define BUILDPLUGIN_EXPORT __declspec( dllimport )
+# else
+#  define BUILDPLUGIN_EXPORT
+# endif
+#endif
+
+#endif
diff --git a/src/BuildPlugin/BuildPlugin_Plugin.cpp b/src/BuildPlugin/BuildPlugin_Plugin.cpp
new file mode 100644 (file)
index 0000000..5cd553d
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildPlugin_Plugin.cpp
+// Created:     18 April 2016
+// Author:      Dmitry Bobylev
+
+#include "BuildPlugin_Plugin.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <BuildPlugin_Wire.h>
+#include <BuildPlugin_Validators.h>
+
+// the only created instance of this plugin
+static BuildPlugin_Plugin* MY_INSTANCE = new BuildPlugin_Plugin();
+
+//=================================================================================================
+BuildPlugin_Plugin::BuildPlugin_Plugin()
+{
+  // Register validators.
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  aFactory->registerValidator("BuildPlugin_ValidatorBaseForWire",
+                              new BuildPlugin_ValidatorBaseForWire());
+
+  // Register this plugin.
+  ModelAPI_Session::get()->registerPlugin(this);
+}
+
+//=================================================================================================
+FeaturePtr BuildPlugin_Plugin::createFeature(std::string theFeatureID)
+{
+  if (theFeatureID == BuildPlugin_Wire::ID()) {
+    return FeaturePtr(new BuildPlugin_Wire());
+  }
+
+  // Feature of such kind is not found.
+  return FeaturePtr();
+}
diff --git a/src/BuildPlugin/BuildPlugin_Plugin.h b/src/BuildPlugin/BuildPlugin_Plugin.h
new file mode 100644 (file)
index 0000000..b36f445
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildPlugin_Plugin.h
+// Created:     18 April 2016
+// Author:      Dmitry Bobylev
+
+#ifndef BuildPlugin_Plugin_H_
+#define BuildPlugin_Plugin_H_
+
+#include "BuildPlugin.h"
+
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+/// \class BuildPlugin_Plugin
+/// \ingroup Plugins
+/// \brief The main class for management the build features as plugin.
+class BUILDPLUGIN_EXPORT BuildPlugin_Plugin: public ModelAPI_Plugin
+{
+public:
+  /// Default constructor
+  BuildPlugin_Plugin();
+
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual FeaturePtr createFeature(std::string theFeatureID);
+};
+
+#endif
diff --git a/src/BuildPlugin/BuildPlugin_Validators.cpp b/src/BuildPlugin/BuildPlugin_Validators.cpp
new file mode 100644 (file)
index 0000000..0bd5885
--- /dev/null
@@ -0,0 +1,100 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildPlugin_Validators.cpp
+// Created:     22 March 2016
+// Author:      Dmitry Bobylev
+
+#include "BuildPlugin_Validators.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultConstruction.h>
+
+#include <GeomAPI_PlanarEdges.h>
+
+#include <GeomAlgoAPI_WireBuilder.h>
+
+#include <Events_Error.h>
+
+//=================================================================================================
+bool BuildPlugin_ValidatorBaseForWire::isValid(const AttributePtr& theAttribute,
+                                               const std::list<std::string>& theArguments,
+                                               std::string& theError) const
+{
+  // Get base objects list.
+  if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
+    Events_Error::send("Validator does not support attribute type \"" + theAttribute->attributeType()
+      + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId() + "\" supported.");
+    return false;
+  }
+  AttributeSelectionListPtr aSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+  if(!aSelectionList.get()) {
+    theError = "Could not get selection list.";
+    return false;
+  }
+  if(aSelectionList->size() == 0) {
+    theError = "Empty selection list.";
+    return false;
+  }
+
+  // Collect base shapes.
+  ListOfShape aListOfShapes;
+  for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+    AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+    if(!aSelection.get()) {
+      theError = "Could not get selection.";
+      return false;
+    }
+    ResultPtr aContext = aSelection->context();
+    if(!aContext.get()) {
+      theError = "Attribute have empty context.";
+      return false;
+    }
+
+    GeomShapePtr aShape = aSelection->value();
+    GeomShapePtr aContextShape = aContext->shape();
+    if(!aShape.get()) {
+      aShape = aContextShape;
+    }
+    if(!aShape.get()) {
+      theError = "Empty shape selected.";
+      return false;
+    }
+
+    // Check that shape has acceptable type.
+    if(aShape->shapeType() != GeomAPI_Shape::EDGE && aShape->shapeType() != GeomAPI_Shape::WIRE) {
+      theError = "Selected shape has wrong type. Only edges and wires acceptable.";
+      return false;
+    }
+
+    // Check that it is edge on sketch.
+    ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+    if(aConstruction.get()) {
+      if(aConstruction->isInfinite()) {
+        theError = "Inifinte objects not acceptable.";
+        return false;
+      }
+
+      std::shared_ptr<GeomAPI_PlanarEdges> anEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContextShape);
+      if(!anEdges.get()) {
+        // It is not an edge on the sketch.
+        // Check that it is not local selection.
+        if(!aShape->isEqual(aContextShape)) {
+          // Local selection on body does not allowed.
+          theError = "Selected shape is in the local selection. Only global selection is allowed.";
+          return false;
+        }
+      }
+    }
+
+    aListOfShapes.push_back(aShape);
+  }
+
+  // Create wire.
+  GeomShapePtr aWire = GeomAlgoAPI_WireBuilder::wire(aListOfShapes);
+  if(!aWire.get()) {
+    theError = "Result wire empty. Probably it has disconnected edges or non-manifold.";
+    return false;
+  }
+
+  return true;
+}
\ No newline at end of file
diff --git a/src/BuildPlugin/BuildPlugin_Validators.h b/src/BuildPlugin/BuildPlugin_Validators.h
new file mode 100644 (file)
index 0000000..5156ae6
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildPlugin_Validators.h
+// Created:     22 March 2016
+// Author:      Dmitry Bobylev
+
+#ifndef BuildPlugin_Validators_H_
+#define BuildPlugin_Validators_H_
+
+#include <ModelAPI_AttributeValidator.h>
+#include <ModelAPI_FeatureValidator.h>
+
+/// \class BuildPlugin_ValidatorBaseForWire
+/// \ingroup Validators
+/// \brief A validator for selection base shapes for wire. Allows to select edges on sketch and
+/// wires objects that are connected to already selected shapes.
+class BuildPlugin_ValidatorBaseForWire: public ModelAPI_AttributeValidator
+{
+public:
+  //! Returns true if attribute is ok.
+  //! \param[in] theAttribute the checked attribute.
+  //! \param[in] theArguments arguments of the attribute.
+  //! \param[out] theError error message.
+   virtual bool isValid(const AttributePtr& theAttribute,
+                        const std::list<std::string>& theArguments,
+                        std::string& theError) const;
+};
+
+#endif
diff --git a/src/BuildPlugin/BuildPlugin_Wire.cpp b/src/BuildPlugin/BuildPlugin_Wire.cpp
new file mode 100644 (file)
index 0000000..a66975f
--- /dev/null
@@ -0,0 +1,202 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        BuildPlugin_Wire.cpp
+// Created:     14 April 2016
+// Author:      Dmitry Bobylev
+
+#include "BuildPlugin_Wire.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+
+#include <Events_Error.h>
+
+#include <GeomAPI_DataMapOfShapeShape.h>
+#include <GeomAPI_PlanarEdges.h>
+#include <GeomAPI_ShapeExplorer.h>
+
+#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_WireBuilder.h>
+
+#include <algorithm>
+
+//=================================================================================================
+BuildPlugin_Wire::BuildPlugin_Wire()
+{
+}
+
+//=================================================================================================
+void BuildPlugin_Wire::initAttributes()
+{
+  data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+//=================================================================================================
+void BuildPlugin_Wire::execute()
+{
+  // Get base objects list.
+  AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
+  if(!aSelectionList.get()) {
+    setError("Error: Could not get selection list.");
+    return;
+  }
+  if(aSelectionList->size() == 0) {
+    setError("Error: Empty selection list.");
+    return;
+  }
+
+  // Collect base shapes.
+  ListOfShape aListOfShapes;
+  for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+    AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+    GeomShapePtr aShape = aSelection->value();
+    if(!aShape.get()) {
+      setError("Error: Empty shape selected.");
+      return;
+    }
+
+    if(aShape->shapeType() != GeomAPI_Shape::EDGE && aShape->shapeType() != GeomAPI_Shape::WIRE) {
+      setError("Error: Selected shape has wrong type. Only edges and wires acceptable.");
+      return;
+    }
+
+    aListOfShapes.push_back(aShape);
+  }
+
+  // Create wire.
+  GeomShapePtr aWire = GeomAlgoAPI_WireBuilder::wire(aListOfShapes);
+  if(!aWire.get()) {
+    setError("Error: Result wire empty. Probably it has disconnected edges or non-manifold.");
+    return;
+  }
+
+  // Store result.
+  ResultBodyPtr aResultBody = document()->createBody(data());
+  aResultBody->store(aWire);
+  setResult(aResultBody);
+}
+
+//=================================================================================================
+bool BuildPlugin_Wire::customAction(const std::string& theActionId)
+{
+  if(theActionId == "add_contour") {
+    return addContour();
+  } else {
+    Events_Error::send("Error: Feature \"" + getKind() + "\" does not support action \"" + theActionId + "\".");
+  }
+
+  return false;
+}
+
+//=================================================================================================
+bool BuildPlugin_Wire::addContour()
+{
+  // Get base objects list.
+  AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
+  if(aSelectionList->size() == 0) {
+    Events_Error::send("Error: Empty selection list.");
+    return false;
+  }
+
+  // Collect attributes to check.
+  std::list<AttributeSelectionPtr> anAttributesToCheck;
+  for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+    AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+    GeomShapePtr anEdgeInList = aSelection->value();
+    if(!anEdgeInList.get()) {
+      continue;
+    }
+
+    // Check that it is edge.
+    if(anEdgeInList->shapeType() != GeomAPI_Shape::EDGE) {
+      continue;
+    }
+
+    // Check that it is edge on sketch.
+    ResultPtr aContext = aSelection->context();
+    ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+    if(!aConstruction.get()) {
+      continue;
+    }
+    GeomShapePtr aContextShape = aConstruction->shape();
+    std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContextShape);
+    if(!aPlanarEdges.get()) {
+      continue;
+    }
+
+    // Check that sketch have faces.
+    if(aConstruction->facesNum() == 0) {
+      continue;
+    }
+
+    anAttributesToCheck.push_back(aSelection);
+  }
+
+  // Check if edges have contours.
+  ListOfShape anAddedEdges;
+  bool isAnyContourFound = false;
+  for(std::list<AttributeSelectionPtr>::const_iterator aListIt = anAttributesToCheck.cbegin();
+      aListIt != anAttributesToCheck.cend();
+      ++aListIt) {
+    AttributeSelectionPtr aSelection = *aListIt;
+    std::shared_ptr<GeomAPI_Edge> anEdgeInList(new GeomAPI_Edge(aSelection->value()));
+
+    ListOfShape::const_iterator anEdgesIt = anAddedEdges.cbegin();
+    for(; anEdgesIt != anAddedEdges.cend(); ++anEdgesIt) {
+      if(anEdgeInList->isEqual(*anEdgesIt)) {
+        break;
+      }
+    }
+    if(anEdgesIt != anAddedEdges.cend()) {
+      // This edge is already in list.
+      continue;
+    }
+
+    ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSelection->context());
+    std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aConstruction->shape());
+
+    // Iterate on faces and add face with this edge.
+    std::shared_ptr<GeomAPI_Face> aFoundFace;
+    for(int anIndex = 0; anIndex < aConstruction->facesNum(); ++anIndex) {
+      std::shared_ptr<GeomAPI_Face> aFace = aConstruction->face(anIndex);
+      for(GeomAPI_ShapeExplorer anExp(aFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
+        std::shared_ptr<GeomAPI_Edge> anEdgeOnFace(new GeomAPI_Edge(anExp.current()));
+        if(anEdgeInList->isEqual(anEdgeOnFace)) {
+          aFoundFace = aFace;
+          break;
+        }
+      }
+
+      if(aFoundFace.get()) {
+        break;
+      }
+    }
+
+    // If face with the same edge found. Add all other edges to list.
+    if(aFoundFace.get()) {
+      isAnyContourFound = true;
+      anAddedEdges.push_back(anEdgeInList);
+      for(GeomAPI_ShapeExplorer anExp(aFoundFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
+        std::shared_ptr<GeomAPI_Edge> anEdgeOnFace(new GeomAPI_Edge(anExp.current()));
+        anEdgesIt = anAddedEdges.cbegin();
+        for(; anEdgesIt != anAddedEdges.cend(); ++anEdgesIt) {
+          if(anEdgeOnFace->isEqual(*anEdgesIt)) {
+            break;
+          }
+        }
+        if(anEdgesIt == anAddedEdges.cend()) {
+          anAddedEdges.push_back(anEdgeOnFace);
+          aSelectionList->append(aConstruction, anEdgeOnFace);
+        }
+      }
+    }
+  }
+
+  if(!isAnyContourFound) {
+    Events_Error::send("Error: Contours already closed or no contours found for selected edges.");
+    return false;
+  }
+
+  return true;
+}
diff --git a/src/BuildPlugin/BuildPlugin_Wire.h b/src/BuildPlugin/BuildPlugin_Wire.h
new file mode 100644 (file)
index 0000000..39128be
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        BuildPlugin_Wire.h
+// Created:     14 April 2016
+// Author:      Dmitry Bobylev
+
+#ifndef BuildPlugin_Wire_H_
+#define BuildPlugin_Wire_H_
+
+#include "BuildPlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/// \class BuildPlugin_Wire
+/// \ingroup Plugins
+/// \brief Feature for creation of wire from sketch edges or existing wires.
+class BuildPlugin_Wire: public ModelAPI_Feature
+{
+public:
+  /// Use plugin manager for features creation
+  BuildPlugin_Wire();
+
+  /// Feature kind.
+  inline static const std::string& ID()
+  {
+    static const std::string MY_ID("Wire");
+    return MY_ID;
+  }
+
+  /// Attribute name of base objects.
+  inline static const std::string& BASE_OBJECTS_ID()
+  {
+    static const std::string MY_BASE_OBJECTS_ID("base_objects");
+    return MY_BASE_OBJECTS_ID;
+  }
+
+  /// \return the kind of a feature.
+  BUILDPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = BuildPlugin_Wire::ID();
+    return MY_KIND;
+  }
+
+  /// Request for initialization of data model of the feature: adding all attributes.
+  BUILDPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Creates a new part document if needed.
+  BUILDPLUGIN_EXPORT virtual void execute();
+
+  /// Performs some functionality by action id.
+  /// \param[in] theAttributeId action key id.
+  /// \return false in case if action not perfomed.
+  BUILDPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
+
+private:
+  /// Action: Adds to the list of segments other segments of the sketcher connected to
+  /// the already selected ones to create a closed contour.
+  /// \return false in case if no countours have been added.
+  bool addContour();
+};
+
+#endif
diff --git a/src/BuildPlugin/CMakeLists.txt b/src/BuildPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..17e1105
--- /dev/null
@@ -0,0 +1,48 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+INCLUDE(UnitTest)
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
+                    ${PROJECT_SOURCE_DIR}/src/Config
+                    ${PROJECT_SOURCE_DIR}/src/ModelAPI
+                    ${PROJECT_SOURCE_DIR}/src/GeomAPI
+                    ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+)
+
+SET(PROJECT_HEADERS
+    BuildPlugin.h
+    BuildPlugin_Plugin.h
+    BuildPlugin_Wire.h
+    BuildPlugin_Validators.h
+)
+
+SET(PROJECT_SOURCES
+    BuildPlugin_Plugin.cpp
+    BuildPlugin_Wire.cpp
+    BuildPlugin_Validators.cpp
+)
+
+SET(XML_RESOURCES
+    plugin-Build.xml
+    wire_widget.xml
+)
+
+SET(PROJECT_LIBRARIES
+    Events
+    Config
+    ModelAPI
+    GeomAPI
+    GeomAlgoAPI
+)
+
+ADD_DEFINITIONS(-DBUILDPLUGIN_EXPORTS)
+ADD_LIBRARY(BuildPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+
+TARGET_LINK_LIBRARIES(BuildPlugin ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS BuildPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
+INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
+INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Build)
+
+# ADD_UNIT_TESTS()
diff --git a/src/BuildPlugin/icons/feature_wire.png b/src/BuildPlugin/icons/feature_wire.png
new file mode 100644 (file)
index 0000000..87b8556
Binary files /dev/null and b/src/BuildPlugin/icons/feature_wire.png differ
diff --git a/src/BuildPlugin/plugin-Build.xml b/src/BuildPlugin/plugin-Build.xml
new file mode 100644 (file)
index 0000000..f710019
--- /dev/null
@@ -0,0 +1,11 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugin>
+  <workbench id="Build" document="Part">
+    <group id="Shape">
+      <feature id="Wire" title="Wire" tooltip ="Create a wire from sketch edges and wires objects" icon="icons/Build/feature_wire.png">
+        <source path="wire_widget.xml"/>
+      </feature>
+    </group>
+   </workbench>
+</plugin>
diff --git a/src/BuildPlugin/wire_widget.xml b/src/BuildPlugin/wire_widget.xml
new file mode 100644 (file)
index 0000000..967ba23
--- /dev/null
@@ -0,0 +1,14 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+  <multi_selector id="base_objects"
+                  label="Segments and wires:"
+                  tooltip="Select an edges on sketch or wires objects."
+                  type_choice="edges objects">
+    <validator id="BuildPlugin_ValidatorBaseForWire"/>
+  </multi_selector>
+  <action id="add_contour"
+          label="Add contour"
+          tooltip="Adds to the list of segments other segments of the sketcher
+                   connected to the already selected ones to create a closed contour."/>
+</source>
index 328bb5fff1ac2c4bc2aed71dcf5fce1effcc959d..a1d2354cb483719f68e99dcedd952bce4df2c5fd 100644 (file)
@@ -6,6 +6,7 @@
   <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
   <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
+  <plugin library="BuildPlugin" configuration="plugin-Build.xml"/>
   <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
   <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
   <plugin script="addons_Features" configuration="addons_Features.xml"/>
index 0c8d1dfefbf249979aa59176ad0c62cc2fc1ea83..89429c4d122e8df4775985a030d23096db84c23f 100644 (file)
@@ -26,7 +26,6 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_RevolutionFuse.h
     FeaturesPlugin_ValidatorTransform.h
     FeaturesPlugin_Validators.h
-    FeaturesPlugin_Wire.h
 )
 
 SET(PROJECT_SOURCES
@@ -51,7 +50,6 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_RevolutionFuse.cpp
     FeaturesPlugin_ValidatorTransform.cpp
     FeaturesPlugin_Validators.cpp
-    FeaturesPlugin_Wire.cpp
 )
 
 SET(XML_RESOURCES
@@ -70,7 +68,6 @@ SET(XML_RESOURCES
   placement_widget.xml
   intersection_widget.xml
   pipe_widget.xml
-  wire_widget.xml
 )
 
 INCLUDE_DIRECTORIES(
index b83fc3339275026dce948b383f70086bdbfda212..efb079e151c6b5243141c50f8c29d950320516e0 100644 (file)
@@ -18,7 +18,6 @@
 #include <FeaturesPlugin_Rotation.h>
 #include <FeaturesPlugin_ValidatorTransform.h>
 #include <FeaturesPlugin_Validators.h>
-#include <FeaturesPlugin_Wire.h>
 
 #include <ModelAPI_Session.h>
 
@@ -45,8 +44,6 @@ FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
                               new FeaturesPlugin_ValidatorPipeLocations);
   aFactory->registerValidator("FeaturesPlugin_ValidatorCanBeEmpty",
                               new FeaturesPlugin_ValidatorCanBeEmpty);
-  aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForWire",
-                              new FeaturesPlugin_ValidatorBaseForWire);
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
@@ -82,9 +79,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_RevolutionCut);
   } else if (theFeatureID == FeaturesPlugin_RevolutionFuse::ID()) {
     return FeaturePtr(new FeaturesPlugin_RevolutionFuse);
-  } else if (theFeatureID == FeaturesPlugin_Wire::ID()) {
-    return FeaturePtr(new FeaturesPlugin_Wire);
   }
+
   // feature of such kind is not found
   return FeaturePtr();
 }
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Wire.cpp b/src/FeaturesPlugin/FeaturesPlugin_Wire.cpp
deleted file mode 100644 (file)
index c84f25c..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        FeaturesPlugin_Wire.cpp
-// Created:     14 April 2016
-// Author:      Dmitry Bobylev
-
-#include "FeaturesPlugin_Wire.h"
-
-#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
-
-#include <Events_Error.h>
-
-#include <GeomAPI_DataMapOfShapeShape.h>
-#include <GeomAPI_PlanarEdges.h>
-#include <GeomAPI_ShapeExplorer.h>
-
-#include <GeomAlgoAPI_ShapeTools.h>
-#include <GeomAlgoAPI_WireBuilder.h>
-
-#include <algorithm>
-
-//=================================================================================================
-FeaturesPlugin_Wire::FeaturesPlugin_Wire()
-{
-}
-
-//=================================================================================================
-void FeaturesPlugin_Wire::initAttributes()
-{
-  data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
-}
-
-//=================================================================================================
-void FeaturesPlugin_Wire::execute()
-{
-  // Get base objects list.
-  AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
-  if(!aSelectionList.get()) {
-    setError("Error: Could not get selection list.");
-    return;
-  }
-  if(aSelectionList->size() == 0) {
-    setError("Error: Empty selection list.");
-    return;
-  }
-
-  // Collect base shapes.
-  ListOfShape aListOfShapes;
-  for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
-    AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
-    GeomShapePtr aShape = aSelection->value();
-    if(!aShape.get()) {
-      setError("Error: Empty shape selected.");
-      return;
-    }
-
-    if(aShape->shapeType() != GeomAPI_Shape::EDGE && aShape->shapeType() != GeomAPI_Shape::WIRE) {
-      setError("Error: Selected shape has wrong type. Only edges and wires acceptable.");
-      return;
-    }
-
-    aListOfShapes.push_back(aShape);
-  }
-
-  // Create wire.
-  GeomShapePtr aWire = GeomAlgoAPI_WireBuilder::wire(aListOfShapes);
-  if(!aWire.get()) {
-    setError("Error: Result wire empty. Probably it has disconnected edges or non-manifold.");
-    return;
-  }
-
-  // Store result.
-  ResultBodyPtr aResultBody = document()->createBody(data());
-  aResultBody->store(aWire);
-  setResult(aResultBody);
-}
-
-//=================================================================================================
-bool FeaturesPlugin_Wire::customAction(const std::string& theActionId)
-{
-  if(theActionId == "add_contour") {
-    return addContour();
-  } else {
-    Events_Error::send("Error: Feature \"" + getKind() + "\" does not support action \"" + theActionId + "\".");
-  }
-
-  return false;
-}
-
-//=================================================================================================
-bool FeaturesPlugin_Wire::addContour()
-{
-  // Get base objects list.
-  AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
-  if(aSelectionList->size() == 0) {
-    Events_Error::send("Error: Empty selection list.");
-    return false;
-  }
-
-  // Collect attributes to check.
-  std::list<AttributeSelectionPtr> anAttributesToCheck;
-  for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
-    AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
-    GeomShapePtr anEdgeInList = aSelection->value();
-    if(!anEdgeInList.get()) {
-      continue;
-    }
-
-    // Check that it is edge.
-    if(anEdgeInList->shapeType() != GeomAPI_Shape::EDGE) {
-      continue;
-    }
-
-    // Check that it is edge on sketch.
-    ResultPtr aContext = aSelection->context();
-    ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
-    if(!aConstruction.get()) {
-      continue;
-    }
-    GeomShapePtr aContextShape = aConstruction->shape();
-    std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContextShape);
-    if(!aPlanarEdges.get()) {
-      continue;
-    }
-
-    // Check that sketch have faces.
-    if(aConstruction->facesNum() == 0) {
-      continue;
-    }
-
-    anAttributesToCheck.push_back(aSelection);
-  }
-
-  // Check if edges have contours.
-  ListOfShape anAddedEdges;
-  bool isAnyContourFound = false;
-  for(std::list<AttributeSelectionPtr>::const_iterator aListIt = anAttributesToCheck.cbegin();
-      aListIt != anAttributesToCheck.cend();
-      ++aListIt) {
-    AttributeSelectionPtr aSelection = *aListIt;
-    std::shared_ptr<GeomAPI_Edge> anEdgeInList(new GeomAPI_Edge(aSelection->value()));
-
-    ListOfShape::const_iterator anEdgesIt = anAddedEdges.cbegin();
-    for(; anEdgesIt != anAddedEdges.cend(); ++anEdgesIt) {
-      if(anEdgeInList->isEqual(*anEdgesIt)) {
-        break;
-      }
-    }
-    if(anEdgesIt != anAddedEdges.cend()) {
-      // This edge is already in list.
-      continue;
-    }
-
-    ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSelection->context());
-    std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges = std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aConstruction->shape());
-
-    // Iterate on faces and add face with this edge.
-    std::shared_ptr<GeomAPI_Face> aFoundFace;
-    for(int anIndex = 0; anIndex < aConstruction->facesNum(); ++anIndex) {
-      std::shared_ptr<GeomAPI_Face> aFace = aConstruction->face(anIndex);
-      for(GeomAPI_ShapeExplorer anExp(aFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
-        std::shared_ptr<GeomAPI_Edge> anEdgeOnFace(new GeomAPI_Edge(anExp.current()));
-        if(anEdgeInList->isEqual(anEdgeOnFace)) {
-          aFoundFace = aFace;
-          break;
-        }
-      }
-
-      if(aFoundFace.get()) {
-        break;
-      }
-    }
-
-    // If face with the same edge found. Add all other edges to list.
-    if(aFoundFace.get()) {
-      isAnyContourFound = true;
-      anAddedEdges.push_back(anEdgeInList);
-      for(GeomAPI_ShapeExplorer anExp(aFoundFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) {
-        std::shared_ptr<GeomAPI_Edge> anEdgeOnFace(new GeomAPI_Edge(anExp.current()));
-        anEdgesIt = anAddedEdges.cbegin();
-        for(; anEdgesIt != anAddedEdges.cend(); ++anEdgesIt) {
-          if(anEdgeOnFace->isEqual(*anEdgesIt)) {
-            break;
-          }
-        }
-        if(anEdgesIt == anAddedEdges.cend()) {
-          anAddedEdges.push_back(anEdgeOnFace);
-          aSelectionList->append(aConstruction, anEdgeOnFace);
-        }
-      }
-    }
-  }
-
-  if(!isAnyContourFound) {
-    Events_Error::send("Error: Contours already closed or no contours found for selected edges.");
-    return false;
-  }
-
-  return true;
-}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Wire.h b/src/FeaturesPlugin/FeaturesPlugin_Wire.h
deleted file mode 100644 (file)
index c456d1d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        FeaturesPlugin_Wire.h
-// Created:     14 April 2016
-// Author:      Dmitry Bobylev
-
-#ifndef FeaturesPlugin_Wire_H_
-#define FeaturesPlugin_Wire_H_
-
-#include "FeaturesPlugin.h"
-
-#include <ModelAPI_Feature.h>
-
-/// \class FeaturesPlugin_Wire
-/// \ingroup Plugins
-/// \brief Feature for creation of wire from sketch edges or existing wires.
-class FeaturesPlugin_Wire: public ModelAPI_Feature
-{
-public:
-  /// Use plugin manager for features creation
-  FeaturesPlugin_Wire();
-
-  /// Feature kind.
-  inline static const std::string& ID()
-  {
-    static const std::string MY_ID("Wire");
-    return MY_ID;
-  }
-
-  /// Attribute name of base objects.
-  inline static const std::string& BASE_OBJECTS_ID()
-  {
-    static const std::string MY_BASE_OBJECTS_ID("base_objects");
-    return MY_BASE_OBJECTS_ID;
-  }
-
-  /// \return the kind of a feature.
-  FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
-  {
-    static std::string MY_KIND = FeaturesPlugin_Wire::ID();
-    return MY_KIND;
-  }
-
-  /// Request for initialization of data model of the feature: adding all attributes.
-  FEATURESPLUGIN_EXPORT virtual void initAttributes();
-
-  /// Creates a new part document if needed.
-  FEATURESPLUGIN_EXPORT virtual void execute();
-
-  /// Performs some functionality by action id.
-  /// \param[in] theAttributeId action key id.
-  /// \return false in case if action not perfomed.
-  FEATURESPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
-
-private:
-  /// Action: Adds to the list of segments other segments of the sketcher connected to
-  /// the already selected ones to create a closed contour.
-  /// \return false in case if no countours have been added.
-  bool addContour();
-};
-
-#endif
diff --git a/src/FeaturesPlugin/icons/feature_wire.png b/src/FeaturesPlugin/icons/feature_wire.png
deleted file mode 100644 (file)
index 87b8556..0000000
Binary files a/src/FeaturesPlugin/icons/feature_wire.png and /dev/null differ
index a6e7f8bd152a993e6b4fcd0dbe4b5492da7979f9..411397b8f418bf7f4efccf51fd48237ab8e51df4 100644 (file)
@@ -2,11 +2,6 @@
 
 <plugin>
   <workbench id="Features" document="Part">
-    <group id="Shape">
-      <feature id="Wire" title="Wire" tooltip ="Create a wire from sketch edges and wires objects" icon="icons/Features/feature_wire.png">
-        <source path="wire_widget.xml"/>
-      </feature>
-    </group>
     <group id="Extrusion">
       <feature id="Extrusion" title="Extrusion" tooltip="Create a solid by extrusion of a face" icon="icons/Features/extrusion.png">
           <source path="extrusion_widget.xml"/>
diff --git a/src/FeaturesPlugin/wire_widget.xml b/src/FeaturesPlugin/wire_widget.xml
deleted file mode 100644 (file)
index 2b49cb9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-<source>
-  <multi_selector id="base_objects"
-                  label="Segments and wires:"
-                  tooltip="Select an edges on sketch or wires objects."
-                  type_choice="edges objects">
-    <validator id="FeaturesPlugin_ValidatorBaseForWire"/>
-  </multi_selector>
-  <action id="add_contour"
-          label="Add contour"
-          tooltip="Adds to the list of segments other segments of the sketcher
-                   connected to the already selected ones to create a closed contour."/>
-</source>