]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into DumpWithGeom
authorazv <azv@opencascade.com>
Fri, 31 Aug 2018 05:49:09 +0000 (08:49 +0300)
committerazv <azv@opencascade.com>
Fri, 31 Aug 2018 05:49:09 +0000 (08:49 +0300)
24 files changed:
doc/gui/FeaturesPlugin/fusionFacesFeature.rst [new file with mode: 0644]
env.sh
env_linux.sh
env_salome.sh
src/BuildPlugin/Test/TestInterpolation.py
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_FusionFaces.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_FusionFaces.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_FusionFaces.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_msg_en.ts
src/FeaturesPlugin/Test/TestFusionFaces.py [new file with mode: 0644]
src/FeaturesPlugin/boolean_fill_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/fusion_faces_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/icons/fusion_faces.png [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/GeomValidators/GeomValidators_NotSelfIntersected.cpp
src/ModuleBase/ModuleBase_WidgetIntValue.cpp
src/PythonAPI/model/features/__init__.py
src/SketchPlugin/plugin-Sketch.xml

diff --git a/doc/gui/FeaturesPlugin/fusionFacesFeature.rst b/doc/gui/FeaturesPlugin/fusionFacesFeature.rst
new file mode 100644 (file)
index 0000000..1fd7f2f
--- /dev/null
@@ -0,0 +1,6 @@
+
+Fusion faces
+============
+
+.. centered::
+  Fusion faces
diff --git a/env.sh b/env.sh
index 7091b84af286c4275bef6ce7b116b480f388c5e3..2edade92ef00645a635170049d39de9208a0fe72 100644 (file)
--- a/env.sh
+++ b/env.sh
@@ -11,11 +11,12 @@ export AUT_DIR=$(pwd)
 export TOOLS_DIR=$(pwd)
 
 export HOME_OLD=$HOME
-source /dn46/SALOME/series9x/current-2018-08-22/start.sh
+source /dn46/SALOME/series9x/current-2018-08-30/start.sh
 export HOME=$HOME_OLD
 
-# Path to solvespace-2
+# Path to special products dir (lcov, cpplint)
 export SHAPER_PDIR=/dn48/newgeom/common/products
+
 # Path to install directory
 export SHAPER_ROOT_DIR=$(cd ${SOURCES_DIR}/.. && pwd)/install
 
index 5beff47b467a1e0e9ed4e2ac1a26a76f05fcac9d..d6cf38269b8046626dac346450c1e0ec19024966 100644 (file)
@@ -2,7 +2,7 @@
 
 # This script uses:
 #
-# SHAPER_PDIR - path of PRODUCTS for SHAPER (SolveSpace, lcov, cpplint)
+# SHAPER_PDIR - path of PRODUCTS for SHAPER (lcov, cpplint)
 # SHAPER_ROOT_DIR - path of SHAPER installation
 
 for path in SHAPER_PDIR SHAPER_ROOT_DIR; do
@@ -13,24 +13,6 @@ for path in SHAPER_PDIR SHAPER_ROOT_DIR; do
   fi
 done
 
-#------ SolveSpace ------
-export SOLVESPACE_ROOT_DIR=${SHAPER_PDIR}/solvespace-2.1
-export LD_LIBRARY_PATH=${SOLVESPACE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-
-#------ PlaneGCS ------
-export PLANEGCS_ROOT_DIR=${SHAPER_PDIR}/planegcs-0.16
-export LD_LIBRARY_PATH=${PLANEGCS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-
-#------ Eigen ------
-export EIGEN_ROOT_DIR=${SHAPER_PDIR}/eigen-3.2.7
-##
-
-#------ Boost ------
-export BOOST_ROOT_DIR=${SHAPER_PDIR}/boost-1.52.0
-##
-
 #------ lcov ------
 export LCOV_ROOT_DIR=${SHAPER_PDIR}/lcov-1.11
 export PATH=${LCOV_ROOT_DIR}/bin:${PATH}
@@ -41,16 +23,7 @@ export CPPLINT_ROOT_DIR=${SHAPER_PDIR}/cpplint-1.3.0
 export PATH=${CPPLINT_ROOT_DIR}:${PATH}
 ##
 
-#------ OCCT ------
-# Defaults
-export CSF_PluginDefaults=${CAS_ROOT_DIR}/share/opencascade/resources/StdResource
-export CSF_StandardDefaults=${CAS_ROOT_DIR}/share/opencascade/resources/StdResource
-# For CMake
-export LIB=${LD_LIBRARY_PATH}
-export PATH=${CASROOT}:${PATH}
-##
-
 #------ SHAPER ------
 export PATH=${SHAPER_ROOT_DIR}/bin/salome:${PATH}
-export PYTHONPATH=${SHAPER_ROOT_DIR}/bin/salome:${SHAPER_ROOT_DIR}/lib/python2.7/site-packages/salome:${PYTHONPATH}
+export PYTHONPATH=${SHAPER_ROOT_DIR}/bin/salome:${SHAPER_ROOT_DIR}/lib/python3.6/site-packages/salome:${PYTHONPATH}
 export LD_LIBRARY_PATH=${SHAPER_ROOT_DIR}/lib/salome:${LD_LIBRARY_PATH}
index ccaf3aebc577af9acc86c18e6e56c9568c3e99b4..60752255b29bfeb9d05746f58b85636c7c45a1fa 100644 (file)
@@ -1,5 +1,4 @@
 #!/bin/bash
 
-# Correcting path which defined with error
-export LD_LIBRARY_PATH=${KERNEL_ROOT_DIR}/lib/salome:${LD_LIBRARY_PATH}
+# Config path correction
 export SalomeAppConfig=${SHAPER_ROOT_DIR}/share/salome/resources/shaper:${GUI_ROOT_DIR}/share/salome/resources/gui
index abeda239349856b97d96145129032d03b6468d1f..656351a488264cbf118aaaafa9a8965802cb7b52 100644 (file)
@@ -60,17 +60,17 @@ model.do()
 
 model.checkResult(Interpolation_1, model, 1, [0], [0], [0], [1], [2])
 
-# =============================================================================
-# Test 2. Create curve 1-2-3-4-5-1, closed on, reorder off, without tangents
-# =============================================================================
+# =============================================================================
+# Test 2. Create curve 1-2-3-4-5-1, closed on, reorder off, without tangents
+# =============================================================================
 Interpolation_2 = model.addInterpolation(Part_1_doc, [p_1, p_2, p_3, p_4, p_5], True, False)
 model.do()
 
 model.checkResult(Interpolation_2, model, 1, [0], [0], [0], [1], [2])
 
-# =============================================================================
-# Test 3. Create curve 1-2-3-4, closed off, reorder on, without tangents
-# =============================================================================
+# =============================================================================
+# Test 3. Create curve 1-2-3-4, closed off, reorder on, without tangents
+# =============================================================================
 Interpolation_3 = model.addInterpolation(Part_1_doc, [p_1, p_2, p_3, p_4], False, True)
 model.do()
 
index b4ac9a4bbd1bbba63e8300020b4b0fc1115d5bff..166375166037771c42b9356649cdd6e648f34f28 100644 (file)
@@ -46,6 +46,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_Symmetry.h
   FeaturesAPI_Translation.h
   FeaturesAPI_Union.h
+  FeaturesAPI_FusionFaces.h
 )
 
 SET(PROJECT_SOURCES
@@ -73,6 +74,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_Symmetry.cpp
   FeaturesAPI_Translation.cpp
   FeaturesAPI_Union.cpp
+  FeaturesAPI_FusionFaces.cpp
 )
 
 SET(PROJECT_LIBRARIES
index dd6b5897ff2cc212c8d7c5d16c23d7ecd41c9547..e9668c42c29f38eeafd9125a7a93442166aa8ed8 100644 (file)
@@ -66,6 +66,7 @@
 %shared_ptr(FeaturesAPI_Symmetry)
 %shared_ptr(FeaturesAPI_Translation)
 %shared_ptr(FeaturesAPI_Union)
+%shared_ptr(FeaturesAPI_FusionFaces)
 
 // all supported interfaces
 %include "FeaturesAPI_BooleanCut.h"
@@ -92,3 +93,4 @@
 %include "FeaturesAPI_Symmetry.h"
 %include "FeaturesAPI_Translation.h"
 %include "FeaturesAPI_Union.h"
+%include "FeaturesAPI_FusionFaces.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_FusionFaces.cpp b/src/FeaturesAPI/FeaturesAPI_FusionFaces.cpp
new file mode 100644 (file)
index 0000000..0a2efc8
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "FeaturesAPI_FusionFaces.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_FusionFaces::FeaturesAPI_FusionFaces(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_FusionFaces::FeaturesAPI_FusionFaces(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const ModelHighAPI_Selection& theBase)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setBase(theBase);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_FusionFaces::~FeaturesAPI_FusionFaces()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_FusionFaces::setBase(const ModelHighAPI_Selection& theBase)
+{
+  fillAttribute(theBase, mybase);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_FusionFaces::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aPartName = theDumper.name(aBase->document());
+
+  AttributeSelectionPtr anAttrBaseShape =
+    aBase->selection(FeaturesPlugin_FusionFaces::BASE_SHAPE_ID());
+
+  theDumper << aBase << " = model.addFusionFaces("
+            << aPartName << ", " << anAttrBaseShape << ")" << std::endl;
+}
+
+//==================================================================================================
+FusionFacesPtr addFusionFaces(const std::shared_ptr<ModelAPI_Document>& thePart,
+                              const ModelHighAPI_Selection& theBase)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesAPI_FusionFaces::ID());
+  return FusionFacesPtr(new FeaturesAPI_FusionFaces(aFeature, theBase));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_FusionFaces.h b/src/FeaturesAPI/FeaturesAPI_FusionFaces.h
new file mode 100644 (file)
index 0000000..054f7ac
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef FeaturesAPI_FusionFaces_H_
+#define FeaturesAPI_FusionFaces_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_FusionFaces.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_FusionFaces
+/// \ingroup CPPHighAPI
+/// \brief Interface for FusionFaces feature.
+class FeaturesAPI_FusionFaces: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+    explicit FeaturesAPI_FusionFaces(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+    explicit FeaturesAPI_FusionFaces(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                       const ModelHighAPI_Selection& theBase);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+    virtual ~FeaturesAPI_FusionFaces();
+
+  INTERFACE_1(FeaturesPlugin_FusionFaces::ID(),
+              base, FeaturesPlugin_FusionFaces::BASE_SHAPE_ID(),
+              ModelAPI_AttributeSelection, /** Base */)
+
+  /// Modify base object attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setBase(const ModelHighAPI_Selection& theBase);
+
+  /// Dump wrapped feature
+  FEATURESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on FusionFaces object.
+typedef std::shared_ptr<FeaturesAPI_FusionFaces> FusionFacesPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create FusionFaces feature.
+FEATURESAPI_EXPORT
+FusionFacesPtr addFusionFaces(const std::shared_ptr<ModelAPI_Document>& thePart,
+                              const ModelHighAPI_Selection& theBase);
+
+#endif // FeaturesAPI_FusionFaces_H_
index 1c7d2d40b3d643e239f228543875246de580d1bd..e6e4435a16705b3f43743e94e624f942591d9d39 100644 (file)
@@ -48,5 +48,6 @@
   #include "FeaturesAPI_Symmetry.h"
   #include "FeaturesAPI_Translation.h"
   #include "FeaturesAPI_Union.h"
+  #include "FeaturesAPI_FusionFaces.h"
 
 #endif // FeaturesAPI_swig_H_
index 11a8377a2561039dc887955bfe079f0e98360715..c173fe22a6c6b161216beb1ce1953127c3030eaa 100644 (file)
@@ -58,6 +58,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_MultiRotation.h
     FeaturesPlugin_Fillet.h
     FeaturesPlugin_Measurement.h
+    FeaturesPlugin_FusionFaces.h
 )
 
 SET(PROJECT_SOURCES
@@ -95,6 +96,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_MultiRotation.cpp
     FeaturesPlugin_Fillet.cpp
     FeaturesPlugin_Measurement.cpp
+    FeaturesPlugin_FusionFaces.cpp
 )
 
 SET(XML_RESOURCES
@@ -110,6 +112,7 @@ SET(XML_RESOURCES
   boolean_widget.xml
   boolean_fuse_widget.xml
   boolean_common_widget.xml
+  boolean_fill_widget.xml
   boolean_smash_widget.xml
   recover_widget.xml
   partition_widget.xml
@@ -124,6 +127,7 @@ SET(XML_RESOURCES
   multirotation_widget.xml
   fillet_widget.xml
   measurement_widget.xml
+  fusion_faces_widget.xml
 )
 
 SET(TEXT_RESOURCES
@@ -243,6 +247,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestMeasurementDistance.py
                TestMeasurementRadius.py
                TestMeasurementAngle.py
+               TestFusionFaces.py
                Test1379.py
                Test1922.py
                Test1942.py
diff --git a/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp
new file mode 100644 (file)
index 0000000..b3cc312
--- /dev/null
@@ -0,0 +1,95 @@
+// Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "FeaturesPlugin_FusionFaces.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_ShapeExplorer.h>
+
+#include <GeomAlgoAPI_UnifySameDomain.h>
+
+
+//==================================================================================================
+FeaturesPlugin_FusionFaces::FeaturesPlugin_FusionFaces()
+{
+}
+
+//==================================================================================================
+void FeaturesPlugin_FusionFaces::initAttributes()
+{
+  data()->addAttribute(BASE_SHAPE_ID(), ModelAPI_AttributeSelection::typeId());
+}
+
+//==================================================================================================
+void FeaturesPlugin_FusionFaces::execute()
+{
+  // Get selection.
+  AttributeSelectionPtr aShapeAttrSelection = selection(BASE_SHAPE_ID());
+  if (!aShapeAttrSelection.get()) {
+    return;
+  }
+
+  // Get shape.
+  GeomShapePtr aBaseShape = aShapeAttrSelection->value();
+
+  // Make fusion
+  std::shared_ptr<GeomAlgoAPI_UnifySameDomain> anAlgo(new GeomAlgoAPI_UnifySameDomain(aBaseShape));
+
+  // Check algo status
+  if (!anAlgo->isDone()) {
+    setError("Error: Fusion algorithm failed.");
+    return;
+  }
+  if (anAlgo->shape()->isNull()) {
+    setError("Error: Resulting shape is Null.");
+    return;
+  }
+  if (!anAlgo->isValid()) {
+    setError("Error: Resulting shape is not valid.");
+    return;
+  }
+
+  // Store result
+  GeomShapePtr aResultShape = anAlgo->shape();
+  ResultBodyPtr aResultBody = document()->createBody(data());
+  if (aResultShape->isEqual(aBaseShape)) {
+    aResultBody->store(aResultShape);
+  } else {
+    aResultBody->storeModified(aBaseShape, aResultShape);
+
+    const int aModifyEdgeTag = 1;
+    const int aModifyFaceTag = 2;
+    const std::string aModEName = "Modified_Edge";
+    const std::string aModFName = "Modified_Face";
+    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = anAlgo->mapOfSubShapes();
+    aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::EDGE,
+      aModifyEdgeTag, aModEName, *aMapOfShapes.get(), true);
+    aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::FACE,
+      aModifyFaceTag, aModFName, *aMapOfShapes.get(), true);
+  }
+  setResult(aResultBody);
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.h b/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.h
new file mode 100644 (file)
index 0000000..3b91925
--- /dev/null
@@ -0,0 +1,65 @@
+// Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef FeaturesPlugin_FusionFaces_H_
+#define FeaturesPlugin_FusionFaces_H_
+
+#include "FeaturesPlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/// \class FeaturesPlugin_FusionFaces
+/// \ingroup Plugins
+/// \brief Feature for fusion of connected faces.
+class FeaturesPlugin_FusionFaces : public ModelAPI_Feature
+{
+public:
+  /// Use plugin manager for features creation
+  FeaturesPlugin_FusionFaces();
+
+  /// Feature kind.
+  inline static const std::string& ID()
+  {
+    static const std::string MY_ID("FusionFaces");
+    return MY_ID;
+  }
+
+  /// Attribute name of base shape.
+  inline static const std::string& BASE_SHAPE_ID()
+  {
+    static const std::string MY_BASE_SHAPE_ID("base_shape");
+    return MY_BASE_SHAPE_ID;
+  }
+
+  /// \return the kind of a feature.
+  FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = FeaturesPlugin_FusionFaces::ID();
+    return MY_KIND;
+  }
+
+  /// Request for initialization of data model of the feature: adding all attributes.
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Executes the faces fusion and stores the modififed shape.
+  FEATURESPLUGIN_EXPORT virtual void execute();
+};
+
+#endif
index 89c83bbef9e2a451187e4e8f0da9866fc31814ef..f39e5fc1e8741ec56ac0f9d31e132988647c5b1b 100644 (file)
@@ -46,6 +46,7 @@
 #include <FeaturesPlugin_Symmetry.h>
 #include <FeaturesPlugin_Translation.h>
 #include <FeaturesPlugin_Union.h>
+#include <FeaturesPlugin_FusionFaces.h>
 #include <FeaturesPlugin_ValidatorTransform.h>
 #include <FeaturesPlugin_Validators.h>
 
@@ -155,6 +156,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_RemoveSubShapes);
   } else if (theFeatureID == FeaturesPlugin_Union::ID()) {
     return FeaturePtr(new FeaturesPlugin_Union);
+  } else if (theFeatureID == FeaturesPlugin_FusionFaces::ID()) {
+    return FeaturePtr(new FeaturesPlugin_FusionFaces);
   } else if (theFeatureID == FeaturesPlugin_Symmetry::ID()) {
     return FeaturePtr(new FeaturesPlugin_Symmetry);
   } else if (theFeatureID == FeaturesPlugin_Scale::ID()) {
index 5a46be2543c0b999757c6df18206e92966c247f5..aa489e3434478293e2c113f0f86cb64313399a84 100644 (file)
       <translation>"Base objects" should contain at least 2 items.</translation>
     </message>
   </context>
+  <context>
+    <name>FusionFaces:Model_FeatureValidator</name>
+    <message>
+      <source>Attribute "base_shape" is not initialized.</source >
+      <translation>Base shape is not selected.</translation >
+    </message>
+  </context>
 </TS>
diff --git a/src/FeaturesPlugin/Test/TestFusionFaces.py b/src/FeaturesPlugin/Test/TestFusionFaces.py
new file mode 100644 (file)
index 0000000..810d548
--- /dev/null
@@ -0,0 +1,137 @@
+## Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+# Create document
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+# =============================================================================
+# Test 1. Fusion faces for shell of 2 adjacent faces lying on plane
+# =============================================================================
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OX"), 10)
+
+Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Translation_1_1/Translated_Face_1")])
+model.do()
+
+model.checkResult(Shell_1, model, 1, [0], [0], [2], [8], [16])
+
+FusionFaces_1 = model.addFusionFaces(Part_1_doc, model.selection("SHELL", "Shell_1_1"))
+model.do()
+
+model.checkResult(FusionFaces_1, model, 1, [0], [0], [1], [4], [8])
+
+# =============================================================================
+# Test 2. Fusion faces for solid of 2 adjacent boxes
+# =============================================================================
+Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Translation_1_1")], [])
+model.do()
+
+model.checkResult(Fuse_1, model, 1, [0], [1], [10], [40], [80])
+
+FusionFaces_2 = model.addFusionFaces(Part_1_doc, model.selection("SOLID", "Fuse_1_1"))
+model.do()
+
+model.checkResult(FusionFaces_2, model, 1, [0], [1], [6], [24], [48])
+
+# =============================================================================
+# Test 3. Fusion faces for shell of adjacent faces lying on cylindrical surface
+# =============================================================================
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_1")])
+Point_1 = model.addPoint(Part_1_doc, 0, 0, 5)
+Plane_1 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OZ"), model.selection("VERTEX", "Point_1"), True)
+
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("FACE", "Plane_1")])
+model.do()
+
+model.checkResult(Partition_1, model, 1, [0], [0], [2], [8], [16])
+
+FusionFaces_3 = model.addFusionFaces(Part_1_doc, model.selection("SHELL", "Partition_1_1"))
+model.do()
+
+model.checkResult(FusionFaces_3, model, 1, [0], [0], [1], [4], [8])
+
+# =============================================================================
+# Test 4. Fusion faces for compsolid
+# =============================================================================
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(25, 40, -50, 40)
+SketchLine_2 = Sketch_1.addLine(-50, 40, -50, 0)
+SketchLine_3 = Sketch_1.addLine(-50, 0, 25, 0)
+SketchLine_4 = Sketch_1.addLine(25, 0, 25, 40)
+SketchLine_5 = Sketch_1.addLine(-20, 40, -20, 0)
+model.do()
+
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0)
+Box_3 = model.addBox(Part_1_doc, 10, 10, 10)
+
+Fuse_2 = model.addFuse(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("SOLID", "Box_3_1")])
+model.do()
+
+model.checkResult(Fuse_2, model, 1, [1], [1], [14], [64], [128])
+
+FusionFaces_4 = model.addFusionFaces(Part_1_doc, model.selection("COMPSOLID", "Fuse_2_1"))
+model.do()
+
+model.checkResult(FusionFaces_4, model, 1, [1], [1], [6], [24], [48])
+
+# =============================================================================
+# Test 5. Fusion faces for compound
+# =============================================================================
+Box_4 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_5 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], 0, 0, 5)
+Box_6 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_3 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], 20, 0, 0)
+Box_7 = model.addBox(Part_1_doc, 10, 10, 10)
+Translation_4 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], 20, 0, 5)
+Fuse_3 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Box_4_1"), model.selection("SOLID", "Translation_2_1")], [])
+Fuse_4 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Translation_3_1"), model.selection("SOLID", "Translation_4_1")], [])
+
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Fuse_3_1"), model.selection("SOLID", "Fuse_4_1")])
+model.do()
+
+model.checkResult(Compound_1, model, 1, [2], [2], [28], [112], [224])
+
+FusionFaces_5 = model.addFusionFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"))
+model.do()
+
+model.checkResult(FusionFaces_5, model, 1, [2], [2], [12], [48], [96])
+
+# =============================================================================
+# Test 6. Check subshapes naming
+# =============================================================================
+#model.testHaveNamingSubshapes(FusionFaces_1, model, Part_1_doc)
+model.testHaveNamingSubshapes(FusionFaces_2, model, Part_1_doc)
+#model.testHaveNamingSubshapes(FusionFaces_3, model, Part_1_doc)
+model.testHaveNamingSubshapes(FusionFaces_4, model, Part_1_doc)
+model.testHaveNamingSubshapes(FusionFaces_5, model, Part_1_doc)
+model.end()
+
+# =============================================================================
+# Test 7. Check Python dump
+# =============================================================================
+assert(model.checkPythonDump())
diff --git a/src/FeaturesPlugin/boolean_fill_widget.xml b/src/FeaturesPlugin/boolean_fill_widget.xml
new file mode 100644 (file)
index 0000000..e584a53
--- /dev/null
@@ -0,0 +1,44 @@
+<!--
+Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+-->
+
+<source>
+  <multi_selector id="main_objects"
+    label="Main objects"
+    icon=""
+    tooltip="Select objects"
+    type_choice="vertices edges wires faces shells solids compsolids compounds"
+    use_choice="false"
+    concealment="true">
+    <validator id="PartSet_DifferentObjects"/>
+    <validator id="FeaturesPlugin_ValidatorBooleanSelection"/>
+  </multi_selector>
+  <multi_selector id="tool_objects"
+    label="Tool objects"
+    icon=""
+    tooltip="Select tools"
+    type_choice="vertices edges wires faces shells solids compsolids compounds"
+    use_choice="false"
+    concealment="true" >
+    <validator id="PartSet_DifferentObjects"/>
+    <validator id="FeaturesPlugin_ValidatorBooleanSelection"/>
+  </multi_selector>
+  <validator id="FeaturesPlugin_ValidatorBooleanArguments" parameters="main_objects,tool_objects"/>
+</source>
diff --git a/src/FeaturesPlugin/fusion_faces_widget.xml b/src/FeaturesPlugin/fusion_faces_widget.xml
new file mode 100644 (file)
index 0000000..eb123bf
--- /dev/null
@@ -0,0 +1,32 @@
+<!--
+Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
+-->
+
+<source>
+  <shape_selector id="base_shape"
+                  label="Shape:"
+                  tooltip="Select a shape to modify."
+                  shape_types="objects"
+                  concealment="true"
+                  greed="true">
+    <validator id="GeomValidators_ShapeType" parameters="shell,solid,compsolid,compound"/>
+    <validator id="GeomValidators_BodyShapes" parameters="toplevel"/>
+  </shape_selector>
+</source>
diff --git a/src/FeaturesPlugin/icons/fusion_faces.png b/src/FeaturesPlugin/icons/fusion_faces.png
new file mode 100644 (file)
index 0000000..2020164
Binary files /dev/null and b/src/FeaturesPlugin/icons/fusion_faces.png differ
index bb13f70af3184c6c6cd50cc10e6832e59e40cc3c..0d7cb5fc17d3827d8ab0b9fb6ba18a5cc4b60e5d 100644 (file)
@@ -94,7 +94,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
       <feature id="Fill" title="Fill" tooltip="Perform boolean fill operation with objects"
                icon="icons/Features/bool_fill.png" helpfile="FeaturesPlugin/fillFeature.html"
                auto_preview="false">
-          <source path="boolean_widget.xml"/>
+          <source path="boolean_fill_widget.xml"/>
       </feature>
       <feature id="Union" title="Union" tooltip="Perform union operations with shapes"
                icon="icons/Features/union.png" helpfile="FeaturesPlugin/unionFeature.html">
@@ -120,6 +120,12 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         <source path="fillet_widget.xml"/>
       </feature>
     </group>
+    <group id="Fusion">
+      <feature id="FusionFaces" title="Fusion of faces" tooltip="Performs fusion of connected faces"
+               icon="icons/Features/fusion_faces.png" auto_preview="true" helpfile="FeaturesPlugin/fusionFacesFeature.html">
+        <source path="fusion_faces_widget.xml"/>
+      </feature>
+    </group>
   </workbench>
   <workbench id="Part">
     <group id="Movement">
index e3032b6244fb6436260ddbb6e082ed6ce3a7255f..dc83cd1966bd8bc5c898e1e10d944fe88391b2a8 100644 (file)
@@ -74,17 +74,19 @@ bool GeomValidators_NotSelfIntersected::isValid(const std::shared_ptr<ModelAPI_F
           return false;
         }
 
-        if (aShape->isSelfIntersected()) {
+        if (aShape->isSelfIntersected(4)) {
           theError = "Error: One of selected shapes are self-intersected.";
           return false;
         }
       }
-    }
-    else {
+    } else {
       theError = std::string("Error: validator does not support attribute with type: ")
         + anAttribute->attributeType();
+      return false;
     }
   }
+
+  return true;
 }
 
 bool GeomValidators_NotSelfIntersected::isNotObligatory(std::string /*theFeature*/,
index b99e1d4ebabe7357c48008869f01e960710031fa..fa8a77159e5bff3469b4e816fa4e245c5359f3eb 100644 (file)
@@ -92,7 +92,7 @@ ModuleBase_WidgetIntValue::ModuleBase_WidgetIntValue(QWidget* theParent,
   }
 
   myDefVal = QString::fromStdString(getDefaultValue()).toInt(&myHasDefault);
-  if (isOk)
+  if (myHasDefault)
     mySpinBox->setValue(myDefVal);
 
   QString aTTip = translate(theData->widgetTooltip());
@@ -199,7 +199,7 @@ bool ModuleBase_WidgetIntValue::restoreValueCustom()
     ModuleBase_Tools::setSpinText(mySpinBox, aText);
   } else {
     ModuleBase_Tools::setSpinValue(mySpinBox,
-      anAttribute->isInitialized() ? anAttribute->value() : 0);
+      anAttribute->isInitialized() ? anAttribute->value() : myDefVal);
     if (anAttribute->isInitialized() && anAttribute->expressionInvalid()) {
       anAttribute->setExpressionError("");
       anAttribute->setExpressionInvalid(false);
index b74ad9b4e90c432c0716f1a83f2494953ec5d6f3..273a282d25caa4ad527da04c1342d77e6329df45 100644 (file)
@@ -10,4 +10,5 @@ from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addFill
 from FeaturesAPI import addIntersection, addPartition, addUnion, addRemoveSubShapes
 from FeaturesAPI import addRecover
 from FeaturesAPI import addFillet
+from FeaturesAPI import addFusionFaces
 from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
index 72e0ef18176ef33f4d593a26c5ce53f34145c5b7..82656539a5888d17bff8288200514acb204ae368 100644 (file)
@@ -623,7 +623,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                          label="Angle"
                          icon="icons/Sketch/angle.png"
                          tooltip="Rotation angle"
-                         default="270" min="0" max="360"
+                         default="360" min="0" max="360"
                          use_reset="false">
               <validator id="SketchPlugin_MultiRotationAngleValidator" />
             </doublevalue>
@@ -638,7 +638,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                          label="Angle"
                          icon="icons/Sketch/angle.png"
                          tooltip="Rotation angle"
-                         default="270" min="0" max="360"
+                         default="90" min="0" max="360"
                          use_reset="false">
               <validator id="SketchPlugin_MultiRotationAngleValidator" />
             </doublevalue>