]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Partition feature definition.
authornds <natalia.donis@opencascade.com>
Fri, 31 Jul 2015 12:13:26 +0000 (15:13 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 31 Jul 2015 12:13:26 +0000 (15:13 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp [new file with mode: 0755]
src/FeaturesPlugin/FeaturesPlugin_Partition.h [new file with mode: 0755]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/partition_widget.xml [new file with mode: 0755]
src/FeaturesPlugin/plugin-Features.xml
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/partition.png [new file with mode: 0755]

index 77f89e52c6e2c17682c78aba1ec3017b81cfac0d..1fa7948da49c58c12a79e10e47df1c28cad9713b 100644 (file)
@@ -12,6 +12,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_Movement.h
     FeaturesPlugin_Boolean.h
     FeaturesPlugin_Group.h
+    FeaturesPlugin_Partition.h
     FeaturesPlugin_Placement.h
     FeaturesPlugin_CompositeBoolean.h
     FeaturesPlugin_ExtrusionBoolean.h
@@ -30,6 +31,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_Movement.cpp
     FeaturesPlugin_Boolean.cpp
     FeaturesPlugin_Group.cpp
+    FeaturesPlugin_Partition.cpp
     FeaturesPlugin_Placement.cpp
     FeaturesPlugin_CompositeBoolean.cpp
     FeaturesPlugin_ExtrusionBoolean.cpp
@@ -52,6 +54,7 @@ SET(XML_RESOURCES
   movement_widget.xml
   boolean_widget.xml
   group_widget.xml
+  partition_widget.xml
   placement_widget.xml
 )
 
index 092b3740641c66e42421f35e341f1ca09bd20073..26cb739e9ee9c01cb887505c624732b10f35c92a 100644 (file)
@@ -28,7 +28,7 @@
 #define _LAST_TAG 3
 #define EDGE 6
 
-#define DEBUG_COMPSOLID
+//#define DEBUG_COMPSOLID
 //#define DEBUG_COMPSOLID_SHAPE
 
 //=================================================================================================
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
new file mode 100755 (executable)
index 0000000..284acd1
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesPlugin_Partition.cpp
+// Created:     31 Jul 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "FeaturesPlugin_Partition.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_BodyBuilder.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+//=================================================================================================
+FeaturesPlugin_Partition::FeaturesPlugin_Partition()
+{
+}
+
+//=================================================================================================
+void FeaturesPlugin_Partition::initAttributes()
+{
+
+  AttributeSelectionListPtr aSelection = 
+    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
+    FeaturesPlugin_Partition::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+  aSelection->setSelectionType("SOLID");
+
+  aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
+    FeaturesPlugin_Partition::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+  aSelection->setSelectionType("SOLID");
+
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Partition::getShape(const std::string& theAttrName)
+{
+  std::shared_ptr<ModelAPI_AttributeReference> aObjRef = std::dynamic_pointer_cast<
+      ModelAPI_AttributeReference>(data()->attribute(theAttrName));
+  if (aObjRef) {
+    std::shared_ptr<ModelAPI_ResultBody> aConstr = std::dynamic_pointer_cast<
+        ModelAPI_ResultBody>(aObjRef->value());
+    if (aConstr)
+      return aConstr->shape();
+  }
+  return std::shared_ptr<GeomAPI_Shape>();
+}
+
+//=================================================================================================
+void FeaturesPlugin_Partition::execute()
+{
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.h b/src/FeaturesPlugin/FeaturesPlugin_Partition.h
new file mode 100755 (executable)
index 0000000..444d3e8
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesPlugin_Partition.h
+// Created:     31 Jul 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef FeaturesPlugin_Partition_H_
+#define FeaturesPlugin_Partition_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+/**\class FeaturesPlugin_Partition
+ * \ingroup Plugins
+ * \brief Feature for applying of Partition operations on Solids. Partition makes conjunctional
+ * faces of solids as shared. The result of partitions is a compsolid.
+ * Main objects are solids, tool objects are solids or faces
+ */
+class FeaturesPlugin_Partition : public ModelAPI_Feature
+{
+public:
+  /// Extrusion kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_ID("Partition");
+    return MY_ID;
+  }
+  /// attribute name of referenced object
+  inline static const std::string& OBJECT_LIST_ID()
+  {
+    static const std::string MY_OBJECT_LIST_ID("main_objects");
+    return MY_OBJECT_LIST_ID;
+  }
+  /// attribute name of tool object
+  inline static const std::string& TOOL_LIST_ID()
+  {
+    static const std::string MY_TOOL_LIST_ID("tool_objects");
+    return MY_TOOL_LIST_ID;
+  }
+
+  /// Returns the kind of a feature
+  FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = FeaturesPlugin_Partition::ID();
+    return MY_KIND;
+  }
+
+  /// Creates a new part document if needed
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_Partition();
+
+private:
+  std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
+
+};
+
+#endif
index 12ed913422eaf7541d7e1c7b70be8b03d1b92fbd..d3d243a4ad7d78f8a89b7a1a86ca41266e2ed484 100644 (file)
@@ -8,6 +8,7 @@
 #include <FeaturesPlugin_ExtrusionFuse.h>
 #include <FeaturesPlugin_Group.h>
 #include <FeaturesPlugin_Movement.h>
+#include <FeaturesPlugin_Partition.h>
 #include <FeaturesPlugin_Placement.h>
 #include <FeaturesPlugin_Revolution.h>
 #include <FeaturesPlugin_RevolutionCut.h>
@@ -45,6 +46,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_Boolean);
   } else if (theFeatureID == FeaturesPlugin_Group::ID()) {
     return FeaturePtr(new FeaturesPlugin_Group);
+  } else if (theFeatureID == FeaturesPlugin_Partition::ID()) {
+    return FeaturePtr(new FeaturesPlugin_Partition);
   } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
     return FeaturePtr(new FeaturesPlugin_Placement);
   } else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
diff --git a/src/FeaturesPlugin/partition_widget.xml b/src/FeaturesPlugin/partition_widget.xml
new file mode 100755 (executable)
index 0000000..33e2c01
--- /dev/null
@@ -0,0 +1,22 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+  <multi_selector id="main_objects"
+    label="Main objects"
+    icon=":icons/cut_shape.png"
+    tooltip="Select a solid objects"
+    type_choice="Solids"
+    use_choice="false"
+    concealment="true">
+    <validator id="PartSet_DifferentObjects"/>
+    <validator id="GeomValidators_ShapeType" parameters="empty,solid"/>
+  </multi_selector>
+  <multi_selector id="tool_objects" 
+    label="Tool object" 
+    icon=":icons/cut_tool.png" 
+    tooltip="Select a tool solid"
+    type_choice="Faces"
+    concealment="true" >
+    <validator id="PartSet_DifferentObjects"/>
+  </multi_selector>
+</source>
index b5dc47317a03b2f7c34a0e817c5281b4807cdf15..0140d4fca974edd5560a1e76716c925ff0658bee 100644 (file)
@@ -28,6 +28,9 @@
       <feature id="Boolean" title="Boolean" tooltip="Perform boolean operations with solids" icon=":icons/cut.png">
           <source path="boolean_widget.xml"/>
       </feature>
+      <feature id="Partition" title="Partition" tooltip="Perform partition operations with solids" icon=":icons/partition.png">
+          <source path="partition_widget.xml"/>
+      </feature>
     </group>
     <group id="Collections">
       <feature id="Group"
index b7b7d0f649d64cd94d971a5a40c55ae6ef8b7f36..06706b7cd73fc6bad29897e2e9822e05d56eec1a 100644 (file)
@@ -30,6 +30,7 @@
      <file>icons/radius.png</file>
      <file>icons/perpendicular.png</file>
      <file>icons/parallel.png</file>
+     <file>icons/partition.png</file>
      <file>icons/length.png</file>
      <file>icons/distance.png</file>
      <file>icons/radius_constr.png</file>
diff --git a/src/PartSet/icons/partition.png b/src/PartSet/icons/partition.png
new file mode 100755 (executable)
index 0000000..bc3ce01
Binary files /dev/null and b/src/PartSet/icons/partition.png differ