]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#20442 Viusalization of faces found and add tolerance
authorJérôme <jerome.lucas@cesgenslab.fr>
Wed, 9 Dec 2020 16:10:17 +0000 (17:10 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Wed, 9 Dec 2020 16:10:17 +0000 (17:10 +0100)
20 files changed:
src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.cpp
src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h
src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestCheckDuplictedFaces.py [deleted file]
src/FeaturesPlugin/doc/checkDuplicatedFaceFeature.rst
src/FeaturesPlugin/doc/examples/checkDuplicatedFaces.py
src/FeaturesPlugin/doc/images/checkduplicatedFacesPropertyPanel.png
src/FeaturesPlugin/duplicatedFaces_widget.xml [deleted file]
src/FeaturesPlugin/duplicated_faces_macro_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/duplicated_faces_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/ModelHighAPI/CMakeLists.txt

index 5b86cb56ec0842915ce599dcf88f530af3ab7468..4e26e46950b2d2189647c2c06a0ef7d99a01d137 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "FeaturesAPI_DuplicatedFaces.h"
 
-#include <FeaturesPlugin_DuplicatedFaces.h>
-#include <ModelAPI_AttributeDoubleArray.h>
+#include <FeaturesPlugin_GroupDuplicatedFaces.h>
+
 #include <ModelHighAPI_Services.h>
 #include <ModelHighAPI_Tools.h>
 
@@ -45,17 +45,17 @@ FeaturesAPI_DuplicatedFaces::~FeaturesAPI_DuplicatedFaces()
 FeaturesAPI_DuplicatedFaces::FeaturesAPI_DuplicatedFaces(
                              const std::shared_ptr<ModelAPI_Feature>& theFeature,
                              const ModelHighAPI_Selection& theObject,
-                             const double theTransparency,
+                             const ModelHighAPI_Integer& theTransparency,
+                             const ModelHighAPI_Double& theTolerance,
                              const std::string & theNameGroup)
 :ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
     fillAttribute(theObject, myobjectselected);
     fillAttribute(theTransparency, mytransparency);
-    if (theNameGroup != "") {
-      fillAttribute(true,feature()->boolean(FeaturesPlugin_DuplicatedFaces::CREATE_GROUP_ID()));
-      fillAttribute(theNameGroup, mygroupname);
-    }
+    fillAttribute(theTolerance, mytolerance);
+    fillAttribute(theNameGroup, mygroupname);
+
     execute();
   }
 }
@@ -67,31 +67,31 @@ void FeaturesAPI_DuplicatedFaces::dump(ModelHighAPI_Dumper& theDumper) const
   const std::string& aDocName = theDumper.name(aBase->document());
 
   AttributeSelectionPtr anAttrObject;
-    anAttrObject = aBase->selection(FeaturesPlugin_DuplicatedFaces::OBJECT_ID());
+    anAttrObject = aBase->selection(FeaturesPlugin_GroupDuplicatedFaces::OBJECT_ID());
 
   theDumper << aBase << " = model.getDuplicatedFaces(" << aDocName << ", " << anAttrObject;
-  theDumper << ", " << aBase->integer(FeaturesPlugin_DuplicatedFaces::TRANSPARENCY_ID());
-
-  if(aBase->boolean(FeaturesPlugin_DuplicatedFaces::CREATE_GROUP_ID())->value() )
-    theDumper << ", " << aBase->string(FeaturesPlugin_DuplicatedFaces::GROUP_NAME_ID());
-
+  theDumper << ", " << aBase->integer(FeaturesPlugin_GroupDuplicatedFaces::TRANSPARENCY_ID());
+  theDumper << ", " << aBase->real(FeaturesPlugin_GroupDuplicatedFaces::TOLERANCE_ID());
+  theDumper << ", " << aBase->string(FeaturesPlugin_GroupDuplicatedFaces::GROUP_NAME_ID());
   theDumper << ")" << std::endl;
 }
 
 //=================================================================================================
 DuplicatedFacesPtr getDuplicatedFaces(const std::shared_ptr<ModelAPI_Document>& thePart,
                                       const ModelHighAPI_Selection& theObject,
-                                      const double theTransparency,
+                                      const ModelHighAPI_Integer& theTransparency,
+                                      const ModelHighAPI_Double& theTolerance,
                                       const std::string & theNameGroup)
 {
 
-  FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_DuplicatedFaces::ID());
+  FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_GroupDuplicatedFaces::ID());
 
   DuplicatedFacesPtr aDuplicatedFaces;
 
   aDuplicatedFaces.reset(new FeaturesAPI_DuplicatedFaces(aFeature,
                                                          theObject,
                                                          theTransparency,
+                                                         theTolerance,
                                                          theNameGroup));
 
   return aDuplicatedFaces;
index 4924a0597648c50b4252e055415daf18e0a866db..12705dbe44b23295d40cd2fa80ca5188548ef571 100644 (file)
 
 #include "FeaturesAPI.h"
 
-#include "FeaturesPlugin_DuplicatedFaces.h"
+#include "FeaturesPlugin_GroupDuplicatedFaces.h"
 
 #include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Integer.h>
+#include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Macro.h>
 
 #include <memory>
@@ -45,21 +47,25 @@ public:
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_DuplicatedFaces(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                        const ModelHighAPI_Selection& theobject,
-                                       const double theTransparency,
+                                       const ModelHighAPI_Integer& theTransparency,
+                                       const ModelHighAPI_Double& theTolerance,
                                        const std::string & theNameGroup);
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_DuplicatedFaces();
 
-    INTERFACE_3(FeaturesPlugin_DuplicatedFaces::ID(),
-              objectselected, FeaturesPlugin_DuplicatedFaces::OBJECT_ID(),
+    INTERFACE_4(FeaturesPlugin_GroupDuplicatedFaces::ID(),
+                objectselected, FeaturesPlugin_GroupDuplicatedFaces::OBJECT_ID(),
                               ModelAPI_AttributeSelection,
                               /** object selected*/,
-              transparency, FeaturesPlugin_DuplicatedFaces::TRANSPARENCY_ID(),
+                transparency, FeaturesPlugin_GroupDuplicatedFaces::TRANSPARENCY_ID(),
                               ModelAPI_AttributeInteger,
                               /** transparency*/,
-              groupname, FeaturesPlugin_DuplicatedFaces::GROUP_NAME_ID(),
+                tolerance, FeaturesPlugin_GroupDuplicatedFaces::TOLERANCE_ID(),
+                              ModelAPI_AttributeDouble,
+                              /** tolerance*/,
+                groupname, FeaturesPlugin_GroupDuplicatedFaces::GROUP_NAME_ID(),
                               ModelAPI_AttributeString,
                               /** group name*/)
 
@@ -79,7 +85,8 @@ typedef std::shared_ptr<FeaturesAPI_DuplicatedFaces> DuplicatedFacesPtr;
 FEATURESAPI_EXPORT
 DuplicatedFacesPtr getDuplicatedFaces(const std::shared_ptr<ModelAPI_Document>& thePart,
                                       const ModelHighAPI_Selection& theObject,
-                                      const double theTransparency = 0.0,
-                                      const std::string & theNameGroup = "");
+                                      const ModelHighAPI_Integer& theTransparency,
+                                      const ModelHighAPI_Double& theTolerance,
+                                      const std::string & theNameGroup);
 
 #endif // FeaturesAPI_DuplicatedFaces_H_
index 39470e1f5d8972fa5ab11eec11aa28bd21987a14..0cf4cabcc5ec56e6a48ca365be7be21d309c728f 100644 (file)
@@ -24,7 +24,6 @@ INCLUDE(UseQtExt)
 # additional include directories
 INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
                      ${PROJECT_SOURCE_DIR}/src/Locale
-                     ${PROJECT_SOURCE_DIR}/src/PrimitivesPlugin
                      ${QT_INCLUDES})
 
 # additional preprocessor / compiler flags
@@ -71,6 +70,8 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_Fillet1D.h
     FeaturesPlugin_Measurement.h
     FeaturesPlugin_DuplicatedFaces.h
+    FeaturesPlugin_CommonDuplicatedFaces.h
+    FeaturesPlugin_GroupDuplicatedFaces.h
     FeaturesPlugin_FusionFaces.h
     FeaturesPlugin_RemoveResults.h
     FeaturesPlugin_Chamfer.h
@@ -119,6 +120,8 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_Fillet1D.cpp
     FeaturesPlugin_Measurement.cpp
     FeaturesPlugin_DuplicatedFaces.cpp
+    FeaturesPlugin_CommonDuplicatedFaces.cpp
+    FeaturesPlugin_GroupDuplicatedFaces.cpp
     FeaturesPlugin_FusionFaces.cpp
     FeaturesPlugin_RemoveResults.cpp
     FeaturesPlugin_Chamfer.cpp
@@ -157,7 +160,8 @@ SET(XML_RESOURCES
   fillet_widget.xml
   fillet1d_widget.xml
   measurement_widget.xml
-  duplicatedFaces_widget.xml
+  duplicated_faces_widget.xml
+  duplicated_faces_macro_widget.xml
   fusion_faces_widget.xml
   chamfer_widget.xml
   copy_widget.xml
@@ -708,5 +712,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestFillet1D_Wire_3.py
                TestFillet1D_Wire_4.py
                TestFillet1D_Wire_5.py
-               TestCheckDuplictedFaces.py
+               TestCheckDuplicatedFaces.py
 )
diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp
new file mode 100644 (file)
index 0000000..93e7f4a
--- /dev/null
@@ -0,0 +1,136 @@
+// Copyright (C) 2018-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
+//
+
+#include "FeaturesPlugin_CommonDuplicatedFaces.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Attribute.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+#include <Locale_Convert.h>
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+
+#include <Config_PropManager.h>
+
+#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_DuplicatedFaces.h>
+#include <GeomAPI_ShapeIterator.h>
+#include <ModelAPI_Tools.h>
+#include <iomanip>
+#include <sstream>
+
+//=================================================================================================
+void explode(const GeomShapePtr& theCompound, ListOfShape& theSubs)
+{
+  if (theCompound->isCompound() || theCompound->isCompSolid()) {
+    GeomAPI_ShapeIterator anIt(theCompound);
+    for (; anIt.more(); anIt.next())
+      explode(anIt.current(), theSubs);
+  } else
+    theSubs.push_back(theCompound);
+}
+
+//=================================================================================================
+void FeaturesPlugin_CommonDuplicatedFaces::updateFaces()
+{
+  AttributeSelectionPtr ancompSolidAttr =
+              std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(attributObject());
+
+  AttributeSelectionListPtr aFacesListAttr =
+              std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
+                                                (attributListFaces());
+
+  if (aFacesListAttr->isInitialized())
+      aFacesListAttr->clear();
+  
+  AttributeDoublePtr aToleranceAttr =
+              std::dynamic_pointer_cast<ModelAPI_AttributeDouble>
+                                                (attributTolerance());
+
+  GeomShapePtr aShape = ancompSolidAttr->value();
+  if (aShape.get() && ancompSolidAttr->context().get() && aToleranceAttr.get()) {
+
+    aShape = ancompSolidAttr->context()->shape();
+    if (aShape) {
+      std::string anError;
+      ListOfShape aFaces;
+      ListOfShape theSubs;
+      explode(aShape, theSubs);
+
+      if (!GetDuplicatedFaces(theSubs,
+                              aToleranceAttr->value(),
+                              aFaces,
+                              anError))
+        setError("Error in duplicated faces calculation :" +  anError);
+
+      aFacesListAttr->setSelectionType("face");
+
+      ListOfShape::const_iterator anIt = aFaces.cbegin();
+      for (; anIt != aFaces.cend(); ++anIt) {
+
+        GeomShapePtr aFacePtr = *anIt;
+
+        if (!aFacePtr.get()) {
+          setError("GetDuplicatedFaces : An invalid face found " +  anError);
+        }
+        aFacesListAttr->append(ancompSolidAttr->context(), aFacePtr);
+      }
+      std::stringstream alabel;
+      alabel << "Number of duplicated faces : " << aFacesListAttr->size();
+      AttributeStringPtr aNumberFacesAttr =
+                  std::dynamic_pointer_cast<ModelAPI_AttributeString>
+                                                      (attributNumberFaces());
+      aNumberFacesAttr->setValue(alabel.str());
+    }
+  }
+}
+
+//=================================================================================================
+void FeaturesPlugin_CommonDuplicatedFaces::setFacesGroup(const std::wstring& theName)
+{
+  std::vector<int> aColor;
+  ResultGroupPtr aGroup = document()->createGroup(data());
+  // clean the result of the operation
+  aGroup->data()->setName(theName);
+  aGroup->store(GeomShapePtr());
+
+  // shapes containing in group
+  ListOfShape aFaces;
+  AttributeSelectionListPtr aFacesListAttr =
+                    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
+                                                        (attributListFaces());
+
+  for (int anI =0; anI< aFacesListAttr->size(); anI++) {
+    AttributeSelectionPtr aAtt = aFacesListAttr->value(anI);
+    aFaces.push_back(aAtt->value());
+  }
+  GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+
+  aGroup->store(aCompound);
+  aColor = {255,0,0};
+  setResult(aGroup);
+  ModelAPI_Tools::setColor(lastResult(),aColor);
+}
+
diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h
new file mode 100644 (file)
index 0000000..4333f34
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright (C) 2018-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
+//
+
+#ifndef FeaturesPlugin_CommonDuplicatedFaces_H_
+#define FeaturesPlugin_CommonDuplicatedFaces_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultGroup.h>
+
+#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_IScreenParams.h>
+
+
+/// \class FeaturesPlugin_CommonDuplicatedFaces
+/// \ingroup Plugins
+/// \brief Feature to check the duplicated faces of solid
+
+class FeaturesPlugin_CommonDuplicatedFaces : public ModelAPI_Feature
+{
+public:
+
+  /// Performs the algorithm and stores results it in the data structure.
+  FEATURESPLUGIN_EXPORT virtual void execute(){};
+
+  /// Return Attribut values of result.
+  virtual AttributePtr attributObject() = 0;
+
+  /// Return Attribut values of result.
+  virtual AttributePtr attributListFaces() = 0;
+
+  /// Return Attribut values of result.
+  virtual AttributePtr attributNumberFaces() = 0;
+
+  /// Return Attribut values of tolerance.
+  virtual AttributePtr attributTolerance() = 0;
+
+  protected:
+  FeaturesPlugin_CommonDuplicatedFaces() {}
+
+  //Set group of faces
+  void setFacesGroup(const std::wstring& theName);
+
+  // Update the list of faces
+  void updateFaces();
+
+};
+
+#endif
index 9442b55538029fd9530851881fecfb8fdc96efb2..6a409fee63043cda4d1b4a5caa61ed0e98b61a83 100644 (file)
 
 #include "FeaturesPlugin_DuplicatedFaces.h"
 
+#include <FeaturesPlugin_GroupDuplicatedFaces.h>
 #include <ModelAPI_AttributeSelection.h>
-#include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_Attribute.h>
 
 #include <Config_PropManager.h>
 #include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultGroup.h>
 #include <GeomAlgoAPI_ShapeTools.h>
-#include <GeomAlgoAPI_DuplicatedFaces.h>
-#include <GeomAPI_ShapeIterator.h>
 #include <ModelAPI_Tools.h>
 #include <iomanip>
 #include <sstream>
-#include <iostream>
 
 //=================================================================================================
 FeaturesPlugin_DuplicatedFaces::FeaturesPlugin_DuplicatedFaces()
@@ -59,48 +56,73 @@ void FeaturesPlugin_DuplicatedFaces::initAttributes()
 
   data()->addAttribute(NUMBER_FACES_ID(), ModelAPI_AttributeString::typeId());
   data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
+  data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(CREATE_GROUP_ID(), ModelAPI_AttributeBoolean::typeId());
   data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), GROUP_NAME_ID());
-  boolean(CREATE_GROUP_ID())->setValue(false);
 }
 
+
 //=================================================================================================
-void explode(const GeomShapePtr& theCompound, ListOfShape& theSubs)
+AttributePtr FeaturesPlugin_DuplicatedFaces::attributObject()
 {
-  if (theCompound->isCompound() || theCompound->isCompSolid()) {
-    GeomAPI_ShapeIterator anIt(theCompound);
-    for (; anIt.more(); anIt.next())
-      explode(anIt.current(), theSubs);
-  }
-  else
-    theSubs.push_back(theCompound);
+  return attribute(OBJECT_ID());
+}
+
+//=================================================================================================
+AttributePtr FeaturesPlugin_DuplicatedFaces::attributListFaces()
+{
+  return attribute(LIST_FACES_ID());
+}
+
+//=================================================================================================
+AttributePtr FeaturesPlugin_DuplicatedFaces::attributNumberFaces()
+{
+  return attribute(NUMBER_FACES_ID());
 }
 
+//=================================================================================================
+AttributePtr FeaturesPlugin_DuplicatedFaces::attributTolerance()
+{
+  return attribute(TOLERANCE_ID());
+}
+
+
 //=================================================================================================
 void FeaturesPlugin_DuplicatedFaces::execute()
 {
-  if(boolean(CREATE_GROUP_ID())->value()
-    && selectionList(LIST_FACES_ID())->isInitialized()
-    && string(GROUP_NAME_ID())->value() != "" ){
+    if (boolean(CREATE_GROUP_ID())->value()) {
 
-    AttributeStringPtr aNameAtt = string(GROUP_NAME_ID());
-    std::wstring aNameFace = aNameAtt->isUValue() ?
-                            Locale::Convert::toWString(aNameAtt->valueU()) :
-                            Locale::Convert::toWString(aNameAtt->value());
+    if (string(GROUP_NAME_ID())->value() != ""
+      && selectionList(LIST_FACES_ID())->isInitialized()) {
 
-    if (myGroup.get())
-      eraseResults();
-    setFacesGroup(aNameFace);
+      if (lastResult().get()) {
+        eraseResultFromList(lastResult());
+      }
 
-  } else {
-    if (myGroup.get()) {
-      eraseResults();
-      myGroup.reset();
+      if (!myCreateGroupFeature.get())
+        createGroup();
+      updateGroup();
     }
 
+  } else {
+    if (selectionList(LIST_FACES_ID())->isInitialized()) {
+
+      if (myCreateGroupFeature.get()) {
+        myCreateGroupFeature->eraseResults();
+        SessionPtr aSession = ModelAPI_Session::get();
+        DocumentPtr aDoc =  aSession->activeDocument();
+        aDoc->removeFeature(myCreateGroupFeature);
+        myCreateGroupFeature.reset();
+      }
+
+      if (lastResult().get())
+        eraseResultFromList(lastResult());
+      setFacesGroup(L"Group_DuplicatedFaces");
+    }
   }
+
   if (selection(OBJECT_ID())->isInitialized()) {
     AttributeSelectionPtr ancompSolidAttr = selection(OBJECT_ID());
     ResultPtr aResult = ancompSolidAttr->context();
@@ -113,7 +135,7 @@ void FeaturesPlugin_DuplicatedFaces::execute()
     ModelAPI_Tools::allSubs(aResultBody, allRes);
     std::list<ResultPtr>::iterator aRes;
     for (aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
-        ModelAPI_Tools::setTransparency(*aRes, aTranparency);
+      ModelAPI_Tools::setTransparency(*aRes, aTranparency);
     }
   }
 }
@@ -121,77 +143,42 @@ void FeaturesPlugin_DuplicatedFaces::execute()
 //=================================================================================================
 void FeaturesPlugin_DuplicatedFaces::attributeChanged(const std::string& theID)
 {
-  if (theID == OBJECT_ID()) {
-    AttributeSelectionPtr ancompSolidAttr = selection(OBJECT_ID());
-
-    GeomShapePtr aShape = ancompSolidAttr->value();
-    if (aShape.get() && ancompSolidAttr->context().get()) {
-
-      aShape = ancompSolidAttr->context()->shape();
-      if (aShape) {
-        std::string anError;
-        ListOfShape aFaces;
-        ListOfShape theSubs;
-        explode(aShape, theSubs);
+  if (theID == OBJECT_ID()
+     || theID == TOLERANCE_ID()) {
 
-        if (!GetDuplicatedFaces(theSubs,
-                                0.001,
-                                aFaces,
-                                anError))
-          setError("Error in duplicated faces calculation :" +  anError);
-
-
-        AttributeSelectionListPtr aFacesListAttr =
-                    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
-                                                      (attribute(LIST_FACES_ID()));
-
-        if (aFacesListAttr->isInitialized())
-          aFacesListAttr->clear();
-
-        aFacesListAttr->setSelectionType("face");
+    updateFaces();
+    if (myCreateGroupFeature.get())
+      updateGroup();
+  }
+}
 
-        ListOfShape::const_iterator anIt = aFaces.cbegin();
-        for(; anIt != aFaces.cend(); ++anIt) {
+//=================================================================================================
+void FeaturesPlugin_DuplicatedFaces::createGroup()
+{
+  SessionPtr aSession = ModelAPI_Session::get();
 
-          GeomShapePtr aFacePtr = *anIt;
+  DocumentPtr aDoc =  aSession->activeDocument();
 
-          if (!aFacePtr.get()) {
-            setError("GetDuplicatedFaces : An invalid face found " +  anError);
-          }
-          aFacesListAttr->append( ancompSolidAttr->context(), aFacePtr);
-        }
-        std::stringstream alabel;
-        alabel << "Number of duplicated faces : " << aFacesListAttr->size();
-        string(NUMBER_FACES_ID() )->setValue( alabel.str() );
-      }
-    }
+  if (aDoc.get()) {
+    myCreateGroupFeature = aDoc->addFeature(FeaturesPlugin_GroupDuplicatedFaces::ID());
   }
 }
 
 //=================================================================================================
-void FeaturesPlugin_DuplicatedFaces::setFacesGroup(const std::wstring& theName )
+void FeaturesPlugin_DuplicatedFaces::updateGroup()
 {
-  std::vector<int> aColor;
-  myGroup = document()->createGroup(data());
-  // clean the result of the operation
-  myGroup->data()->setName(theName);
-  myGroup->store(GeomShapePtr());
-
-  // shapes containing in each group
-  ListOfShape aFaces;
-  AttributeSelectionListPtr aFacesListAttr =
-                    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
-                                                        (attribute(LIST_FACES_ID()));
-
-  for (int anI =0; anI< aFacesListAttr->size(); anI++) {
-    AttributeSelectionPtr aAtt = aFacesListAttr->value(anI);
-    aFaces.push_back( aAtt->value() );
-  }
+    myCreateGroupFeature->string(FeaturesPlugin_GroupDuplicatedFaces::GROUP_NAME_ID())
+                          ->setValue(string(GROUP_NAME_ID())->value());
 
-  GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-  myGroup->store(aCompound);
-  aColor = {255,0,0};
-  setResult(myGroup);
-  ModelAPI_Tools::setColor( lastResult(),aColor);
-}
+    myCreateGroupFeature->selection(FeaturesPlugin_GroupDuplicatedFaces::OBJECT_ID())
+                          ->setValue(selection(OBJECT_ID())->context() ,
+                                      selection(OBJECT_ID())->value());
+
+    myCreateGroupFeature->integer(FeaturesPlugin_GroupDuplicatedFaces::TRANSPARENCY_ID())
+                          ->setValue(integer(TRANSPARENCY_ID())->value());
+
+    myCreateGroupFeature->real(FeaturesPlugin_GroupDuplicatedFaces::TOLERANCE_ID())
+                          ->setValue(real(TOLERANCE_ID())->value());
 
+    myCreateGroupFeature->execute();
+}
\ No newline at end of file
index 490208992ab809b6116636c44339a7d1e716974d..61c7530588b81f2b7110724f9c3980a6654e80ab 100644 (file)
 #ifndef FeaturesPlugin_DuplicatedFaces_H_
 #define FeaturesPlugin_DuplicatedFaces_H_
 
-#include "FeaturesPlugin.h"
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_ResultGroup.h>
-
-#include <GeomAPI_IPresentable.h>
-#include <GeomAPI_IScreenParams.h>
-#include <GeomAlgoAPI_Box.h>
+#include <FeaturesPlugin_CommonDuplicatedFaces.h>
 
 /// \class FeaturesPlugin_DuplicatedFaces
 /// \ingroup Plugins
 /// \brief Feature to check the duplicated faces of solid
 
-class FeaturesPlugin_DuplicatedFaces : public ModelAPI_Feature
+class FeaturesPlugin_DuplicatedFaces : public FeaturesPlugin_CommonDuplicatedFaces
 {
 public:
    inline static const std::string& ID()
   {
-    static const std::string MY_ID("Duplicated_faces");
+    static const std::string MY_ID("Duplicated_faces_macro");
     return MY_ID;
   }
 
@@ -68,13 +62,20 @@ public:
     return MY_LIST_FACES_ID;
   }
 
-    /// Attribute name for transparency.
+  /// Attribute name for transparency.
   inline static const std::string& TRANSPARENCY_ID()
   {
     static const std::string MY_TRANSPARENCY_ID("transparency");
     return MY_TRANSPARENCY_ID;
   }
 
+  /// Attribute name for tolerance.
+  inline static const std::string& TOLERANCE_ID()
+  {
+    static const std::string MY_TOLERANCE_ID("tolerance");
+    return MY_TOLERANCE_ID;
+  }
+
   /// Attribute name for checkbox create group.
   inline static const std::string& CREATE_GROUP_ID()
   {
@@ -99,14 +100,34 @@ public:
   /// \param theID identifier of changed attribute
   FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
+  FEATURESPLUGIN_EXPORT virtual bool isMacro() const { return true; }
+
   /// Use plugin manager for features creation
   FeaturesPlugin_DuplicatedFaces();
 
   private:
-  //Set group of faces
-  void setFacesGroup(const std::wstring& theName );
 
-  ResultGroupPtr myGroup;
+  /// Return Attribut values of object.
+  virtual AttributePtr attributObject();
+
+  /// Return Attribut values of list of faces.
+  virtual AttributePtr attributListFaces();
+
+  /// Return Attribut values of number of faces.
+  virtual AttributePtr attributNumberFaces();
+
+  /// Return Attribut values of tolerance.
+  virtual AttributePtr attributTolerance();
+
+  /// Create group
+  void createGroup();
+
+  /// Update group
+  void updateGroup();
+
+  /// Feature to create group
+  FeaturePtr myCreateGroupFeature;
 };
 
 #endif
diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp
new file mode 100644 (file)
index 0000000..147ab3a
--- /dev/null
@@ -0,0 +1,135 @@
+// Copyright (C) 2018-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
+//
+
+#include "FeaturesPlugin_GroupDuplicatedFaces.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Attribute.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <Locale_Convert.h>
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+
+#include <Config_PropManager.h>
+#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAPI_ShapeIterator.h>
+#include <ModelAPI_Tools.h>
+#include <iomanip>
+#include <sstream>
+
+//=================================================================================================
+FeaturesPlugin_GroupDuplicatedFaces::FeaturesPlugin_GroupDuplicatedFaces()
+{
+}
+
+//=================================================================================================
+void FeaturesPlugin_GroupDuplicatedFaces::initAttributes()
+{
+  // attribute for object selected
+  data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  AttributeSelectionListPtr aList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(
+    data()->addAttribute(LIST_FACES_ID(), ModelAPI_AttributeSelectionList::typeId()));
+
+  data()->addAttribute(NUMBER_FACES_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
+  data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId());
+
+}
+
+
+//=================================================================================================
+AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributObject()
+{
+  return attribute(OBJECT_ID());
+}
+
+//=================================================================================================
+AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributListFaces()
+{
+  return attribute(LIST_FACES_ID());
+}
+
+//=================================================================================================
+AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributNumberFaces()
+{
+  return attribute(NUMBER_FACES_ID());
+}
+
+//=================================================================================================
+AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributTolerance()
+{
+  return attribute(TOLERANCE_ID());
+}
+
+//=================================================================================================
+void FeaturesPlugin_GroupDuplicatedFaces::execute()
+{
+  if (selectionList(LIST_FACES_ID())->isInitialized()
+    && string(GROUP_NAME_ID())->value() != "") {
+    AttributeStringPtr aNameAtt = string(GROUP_NAME_ID()) ;
+    std::wstring aNameFace = aNameAtt->isUValue() ?
+                            Locale::Convert::toWString(aNameAtt->valueU()) :
+                            Locale::Convert::toWString(aNameAtt->value());
+
+    if (lastResult().get())
+      eraseResultFromList(lastResult());
+    setFacesGroup(aNameFace);
+
+  } else {
+    if (lastResult().get()) {
+      eraseResultFromList(lastResult());
+    }
+
+  }
+  if (selection(OBJECT_ID())->isInitialized()) {
+    AttributeSelectionPtr ancompSolidAttr = selection(OBJECT_ID());
+    ResultPtr aResult = ancompSolidAttr->context();
+
+    double aTranparency = integer(TRANSPARENCY_ID())->value()/100.0;
+    ModelAPI_Tools::setTransparency(aResult, aTranparency);
+
+    ResultBodyPtr aResultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+    std::list<ResultPtr> allRes;
+    ModelAPI_Tools::allSubs(aResultBody, allRes);
+    std::list<ResultPtr>::iterator aRes;
+    for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+      ModelAPI_Tools::setTransparency(*aRes, aTranparency);
+    }
+  }
+}
+
+//=================================================================================================
+void FeaturesPlugin_GroupDuplicatedFaces::attributeChanged(const std::string& theID)
+{
+  if (theID == OBJECT_ID()
+     || theID == TOLERANCE_ID()) {
+    updateFaces();
+  }
+}
\ No newline at end of file
diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h
new file mode 100644 (file)
index 0000000..583b770
--- /dev/null
@@ -0,0 +1,115 @@
+// Copyright (C) 2018-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
+//
+
+#ifndef FeaturesPlugin_GroupDuplicatedFaces_H_
+#define FeaturesPlugin_GroupDuplicatedFaces_H_
+
+#include <FeaturesPlugin_CommonDuplicatedFaces.h>
+
+/// \class FeaturesPlugin_GroupDuplicatedFaces
+/// \ingroup Plugins
+/// \brief Feature to check the duplicated faces of solid
+
+class FeaturesPlugin_GroupDuplicatedFaces : public FeaturesPlugin_CommonDuplicatedFaces
+{
+public:
+   inline static const std::string& ID()
+  {
+    static const std::string MY_ID("Duplicated_faces");
+    return MY_ID;
+  }
+
+  /// \return the kind of a feature.
+  virtual const std::string& getKind()
+  {
+    return ID();
+  }
+
+  /// Attribute name for object selected.
+  inline static const std::string& OBJECT_ID()
+  {
+    static const std::string MY_OBJECT_ID("main_object");
+    return MY_OBJECT_ID;
+  }
+
+  /// Attribute name for number of faces.
+  inline static const std::string& NUMBER_FACES_ID()
+  {
+    static const std::string MY_NUMBER_FACES_ID("number_duplicated_faces");
+    return MY_NUMBER_FACES_ID;
+  }
+
+  /// Attribute name for z coodinate.
+  inline static const std::string& LIST_FACES_ID()
+  {
+    static const std::string MY_LIST_FACES_ID("faces");
+    return MY_LIST_FACES_ID;
+  }
+
+    /// Attribute name for transparency.
+  inline static const std::string& TRANSPARENCY_ID()
+  {
+    static const std::string MY_TRANSPARENCY_ID("transparency");
+    return MY_TRANSPARENCY_ID;
+  }
+
+  /// Attribute name for tolerance.
+  inline static const std::string& TOLERANCE_ID()
+  {
+    static const std::string MY_TOLERANCE_ID("tolerance");
+    return MY_TOLERANCE_ID;
+  }
+
+  /// Attribute name for group name.
+  inline static const std::string& GROUP_NAME_ID()
+  {
+    static const std::string MY_GROUP_NAME_ID("group_name");
+    return MY_GROUP_NAME_ID;
+  }
+
+  /// Performs the algorithm and stores results it in the data structure.
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_GroupDuplicatedFaces();
+
+  private:
+
+  /// Return Attribut values of object.
+  virtual AttributePtr attributObject();
+
+  /// Return Attribut values of list of faces.
+  virtual AttributePtr attributListFaces();
+
+  /// Return Attribut values of number of faces.
+  virtual AttributePtr attributNumberFaces();
+
+  /// Return Attribut values of tolerance.
+  virtual AttributePtr attributTolerance();
+
+};
+
+#endif
index 5914a064c4c4d7f74ba7b1e7a94021be201d6c85..02914017e20cccd7c92f14a7f271168c85609aea 100644 (file)
@@ -34,6 +34,7 @@
 #include <FeaturesPlugin_Intersection.h>
 #include <FeaturesPlugin_Measurement.h>
 #include <FeaturesPlugin_DuplicatedFaces.h>
+#include <FeaturesPlugin_GroupDuplicatedFaces.h>
 #include <FeaturesPlugin_MultiRotation.h>
 #include <FeaturesPlugin_MultiTranslation.h>
 #include <FeaturesPlugin_Partition.h>
@@ -190,6 +191,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_Measurement);
   } else if (theFeatureID == FeaturesPlugin_DuplicatedFaces::ID()) {
     return FeaturePtr(new FeaturesPlugin_DuplicatedFaces);
+  } else if (theFeatureID == FeaturesPlugin_GroupDuplicatedFaces::ID()) {
+    return FeaturePtr(new FeaturesPlugin_GroupDuplicatedFaces);
   } else if (theFeatureID == FeaturesPlugin_RemoveResults::ID()) {
     return FeaturePtr(new FeaturesPlugin_RemoveResults);
   } else if (theFeatureID == FeaturesPlugin_Chamfer::ID()) {
diff --git a/src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py b/src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py
new file mode 100644 (file)
index 0000000..6c08bcb
--- /dev/null
@@ -0,0 +1,92 @@
+# Copyright (C) 2014-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
+#
+
+"""
+      Unit test of Check Duplicated faces
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+
+import os
+import math
+
+from ModelAPI import *
+from GeomAPI import *
+from salome.shaper import model
+
+
+__updated__ = "2020-11-12"
+
+
+if __name__ == '__main__':
+
+    model.begin()
+    partSet = model.moduleDocument()
+    Part_1 = model.addPart(partSet)
+    Part_1_doc = Part_1.document()
+    ### Create Box
+    Box_1 = model.addBox(Part_1_doc, 100, 50, 100)
+    ### Create Point
+    Point_1 = model.addPoint(Part_1_doc, 100, 0, 0)
+    ### Create Point
+    Point_2 = model.addPoint(Part_1_doc, 250, 50, 100)
+    ### Create Box
+    Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "all-in-Point_1"), model.selection("VERTEX", "all-in-Point_2"))
+    ### Create Point
+    Point_3 = model.addPoint(Part_1_doc, 100, 50, 250)
+    ### Create Box
+    Box_3 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "Point_3"))
+    ### Create Compound
+    Compound_1_objects = [model.selection("SOLID", "Box_1_1"), 
+                          model.selection("SOLID", "Box_2_1"), 
+                          model.selection("SOLID", "Box_3_1")]
+    Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
+    ### Create Duplicated_faces
+    Duplicated_faces_1 = model.getDuplicatedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 50, 0.001, "mygroup")
+
+    model.do()
+     # Check results
+    Duplicated_faces_1_Feature = Duplicated_faces_1.feature()
+    assert Duplicated_faces_1_Feature.error() == ''
+    assert Duplicated_faces_1_Feature.name() == "Duplicated_faces_1"
+
+    aSelectionList = Duplicated_faces_1_Feature.selectionList("faces")
+    assert aSelectionList.size() == 2
+
+    assert(Part_1_doc.size("Groups") == 1)
+
+    #assert Part_1_doc.object("Groups", 0).name() == "mygroup"
+    resShape = modelAPI_Result(Part_1_doc.object("Groups", 0)).shape()
+    assert(not resShape.isNull())
+
+    # the group result is a face, check that this is one face
+    aShapeExplorer = GeomAPI_ShapeExplorer(resShape, GeomAPI_Shape.FACE)
+    assert(aShapeExplorer.more())
+    assert(aShapeExplorer.current().isFace())
+    aShapeExplorer.next()
+    aShapeExplorer.next()
+    assert(not aShapeExplorer.more())
+    
+    model.end()
+
+    #=========================================================================
+    # End of test
+    #=========================================================================
diff --git a/src/FeaturesPlugin/Test/TestCheckDuplictedFaces.py b/src/FeaturesPlugin/Test/TestCheckDuplictedFaces.py
deleted file mode 100644 (file)
index 50b8e44..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright (C) 2014-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
-#
-
-"""
-      Unit test of Check Duplicated faces
-"""
-#=========================================================================
-# Initialization of the test
-#=========================================================================
-
-
-import os
-import math
-
-from ModelAPI import *
-from GeomAPI import *
-from salome.shaper import model
-
-
-__updated__ = "2020-11-12"
-
-
-if __name__ == '__main__':
-
-    model.begin()
-    partSet = model.moduleDocument()
-    Part_1 = model.addPart(partSet)
-    Part_1_doc = Part_1.document()
-    ### Create Box
-    Box_1 = model.addBox(Part_1_doc, 100, 50, 100)
-    ### Create Point
-    Point_1 = model.addPoint(Part_1_doc, 100, 0, 0)
-    ### Create Point
-    Point_2 = model.addPoint(Part_1_doc, 250, 50, 100)
-    ### Create Box
-    Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "all-in-Point_1"), model.selection("VERTEX", "all-in-Point_2"))
-    ### Create Point
-    Point_3 = model.addPoint(Part_1_doc, 100, 50, 250)
-    ### Create Box
-    Box_3 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "Point_3"))
-    ### Create Compound
-    Compound_1_objects = [model.selection("SOLID", "Box_1_1"), 
-                          model.selection("SOLID", "Box_2_1"), 
-                          model.selection("SOLID", "Box_3_1")]
-    Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
-    ### Create Duplicated_faces
-    Duplicated_faces_1 = model.getDuplicatedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 50, "mygroup")
-
-    model.do()
-     # Check results
-    Duplicated_faces_1_Feature = Duplicated_faces_1.feature()
-    assert Duplicated_faces_1_Feature.error() == ''
-    assert Duplicated_faces_1_Feature.name() == "Duplicated_faces_1"
-
-    aSelectionList = Duplicated_faces_1_Feature.selectionList("faces")
-    assert aSelectionList.size() == 2
-
-    assert(Part_1_doc.size("Groups") == 1)
-
-    #assert Part_1_doc.object("Groups", 0).name() == "mygroup"
-    resShape = modelAPI_Result(Part_1_doc.object("Groups", 0)).shape()
-    assert(not resShape.isNull())
-
-    # the group result is a face, check that this is one face
-    aShapeExplorer = GeomAPI_ShapeExplorer(resShape, GeomAPI_Shape.FACE)
-    assert(aShapeExplorer.more())
-    assert(aShapeExplorer.current().isFace())
-    aShapeExplorer.next()
-    aShapeExplorer.next()
-    assert(not aShapeExplorer.more())
-    
-    model.end()
-
-    #=========================================================================
-    # End of test
-    #=========================================================================
index aba107ea555cbe10b3f3845be99431ab155f9646..181b1682f295bc23c981527f63addb77e51da24a 100644 (file)
@@ -26,17 +26,19 @@ Input fields:
 - **Number of duplicated faces** indicate the number of found faces. 
 - **List of faces** the list of found faces.
 - **Transparency** set the transparency of selected object.   
+- **Tolerance** set the tolerance for the algotithme. 
 - **Create group** check-box allow the creation of the group of found faces. 
 - **Group name**  specified the name of the group created. 
 
 
 **TUI Command**:
 
-.. py:function:: model.getDuplicatedFaces(Part_doc, shape, transparency, nameGroup)
+.. py:function:: model.getDuplicatedFaces(Part_doc, shape, transparency, tolerance, nameGroup)
  
     :param part: The current part object.
     :param object: A composolid or compound in format *model.selection("Type", shape)*.
-    :param number: value for the transparency.
+    :param number: value of the transparency.
+    :param number: value of the tolerance.
     :param string: name of group created. 
     :return: Created group.
 
index 1ccb4cb88e1819f41a23daca6c5789ceb80d706a..40be3117c4fd3ba3b62eb225ceedd513ea87028d 100644 (file)
@@ -23,7 +23,7 @@ Compound_1_objects = [model.selection("SOLID", "Box_1_1"),
                       model.selection("SOLID", "Box_3_1")]
 Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects)
 ### Create Duplicated_faces
-Duplicated_faces_1 = model.getDuplicatedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 50, "mygroup")
+Duplicated_faces_1 = model.getDuplicatedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 50, 0.001, "mygroup")
 
 model.do()
 model.end()
index 48700f68abf4a83800a308532faafd938527a39f..439d7508943ca8905214eb31b90592f4d93ae295 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/checkduplicatedFacesPropertyPanel.png and b/src/FeaturesPlugin/doc/images/checkduplicatedFacesPropertyPanel.png differ
diff --git a/src/FeaturesPlugin/duplicatedFaces_widget.xml b/src/FeaturesPlugin/duplicatedFaces_widget.xml
deleted file mode 100644 (file)
index c3a8c5b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<source>
-  <shape_selector id="main_object"
-                  label="Object"
-                  tooltip="Select a object"
-                  shape_types="compsolid compsolid object"
-                  default=""
-                  geometrical_selection="true">
-    <validator id="PartSet_DifferentObjects"/>
-    <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
-  </shape_selector>
-  <groupbox title="Duplicated faces">
-    <label id="number_duplicated_faces"/>
-    <multi_selector id="faces"
-                      label="Liste of faces :"
-                      icon=""
-                      shape_types="faces"
-                      Block_selection = "true"
-                      use_choice="false">
-          <validator id="PartSet_DifferentObjects"/>
-          <validator id="GeomValidators_ShapeType" parameters="faces"/>
-    </multi_selector>
-  </groupbox>
-  <integervalue id="transparency"
-                    label="Transparency"
-                    min="0"
-                    max="100"
-                    step="10"
-                    default="50">
-  </integervalue>
-  <optionalbox id="create_group" title="Create group" show_title="true">
-    <stringvalue id="group_name" label="Group Name"/>
-    <label/>
-  </optionalbox>
-</source>
diff --git a/src/FeaturesPlugin/duplicated_faces_macro_widget.xml b/src/FeaturesPlugin/duplicated_faces_macro_widget.xml
new file mode 100644 (file)
index 0000000..4b94b11
--- /dev/null
@@ -0,0 +1,40 @@
+<source>
+  <shape_selector id="main_object"
+                  label="Object"
+                  tooltip="Select a object"
+                  shape_types="compsolid compsolid object"
+                  default=""
+                  geometrical_selection="true">
+    <validator id="PartSet_DifferentObjects"/>
+    <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
+  </shape_selector>
+  <groupbox title="Duplicated faces">
+    <label id="number_duplicated_faces"/>
+    <multi_selector id="faces"
+                      label="List of faces :"
+                      icon=""
+                      shape_types="faces"
+                      Block_selection = "true"
+                      use_choice="false">
+      <validator id="PartSet_DifferentObjects"/>
+      <validator id="GeomValidators_ShapeType" parameters="faces"/>
+    </multi_selector>
+  </groupbox>
+  <integervalue id="transparency"
+                    label="Transparency"
+                    min="0"
+                    max="100"
+                    step="10"
+                    default="50">
+  </integervalue>
+  <doublevalue id="tolerance"
+                    label="Tolerance"
+                    min="0"
+                    step="0.001"
+                    default="0.001">
+  </doublevalue>
+  <optionalbox id="create_group" title="Create group" show_title="true">
+    <stringvalue id="group_name" label="Group Name"/>
+    <label/>
+  </optionalbox>
+</source>
diff --git a/src/FeaturesPlugin/duplicated_faces_widget.xml b/src/FeaturesPlugin/duplicated_faces_widget.xml
new file mode 100644 (file)
index 0000000..1d01b3c
--- /dev/null
@@ -0,0 +1,37 @@
+<source>
+  <shape_selector id="main_object"
+                  label="Object"
+                  tooltip="Select a object"
+                  shape_types="compsolid compsolid object"
+                  default=""
+                  geometrical_selection="true">
+    <validator id="PartSet_DifferentObjects"/>
+    <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
+  </shape_selector>
+  <groupbox title="Duplicated faces">
+    <label id="number_duplicated_faces"/>
+    <multi_selector id="faces"
+                      label="List of faces :"
+                      icon=""
+                      shape_types="faces"
+                      Block_selection = "true"
+                      use_choice="false">
+      <validator id="PartSet_DifferentObjects"/>
+      <validator id="GeomValidators_ShapeType" parameters="faces"/>
+    </multi_selector>
+  </groupbox>
+  <integervalue id="transparency"
+                    label="Transparency"
+                    min="0"
+                    max="100"
+                    step="10"
+                    default="50">
+  </integervalue>
+  <doublevalue id="tolerance"
+                    label="Tolerance"
+                    min="0"
+                    step="0.001"
+                    default="0.001">
+  </doublevalue>
+  <stringvalue id="group_name" label="Group Name"/>
+</source>
index 9a39b109fc56dc8e3e80952bc9e523caccf86771..1b71542fa1fa317398fbf4e19a8156d9657bd58c 100644 (file)
         <source path="fillet1d_widget.xml"/>
       </feature>
       <feature id="Fillet" title="Fillet" tooltip="Perform fillet on face or edge"
-               icon="icons/Features/fillet.png" auto_preview="false" helpfile="filletFeature.html">
+               icon="icons/Features/fillet.png" auto_preview="true" helpfile="filletFeature.html">
         <source path="fillet_widget.xml"/>
       </feature>
       <feature id="Chamfer" title="Chamfer" tooltip="Perform chamfer on face or edge"
       </feature>
     </group>
     <group id="Face">
-      <feature id="Duplicated_faces" title="Check duplicated faces" tooltip="Check the duplicated faces" auto_preview="true"
+      <feature id="Duplicated_faces_macro" title="Check duplicated faces" tooltip="Check the duplicated faces" auto_preview="true"
                icon="icons/Features/duplicatedFaces.png" helpfile="checkDuplicatedFaceFeature.html"> 
-        <source path="duplicatedFaces_widget.xml"/>
+        <source path="duplicated_faces_macro_widget.xml"/>
+      </feature>
+      <feature id="Duplicated_faces" title="Check duplicated faces" tooltip="Check the duplicated faces" auto_preview="true"
+               icon="icons/Features/duplicatedFaces.png" helpfile="checkDuplicatedFaceFeature.html" internal="1"> 
+        <source path="duplicated_faces_widget.xml"/>
       </feature>
     </group>
   </workbench>
index d94749f5c267c60eb8acc57259b838a20e7f7d92..e52c3807d8448c4a7148890c1fbe42f1d1ae4e30 100644 (file)
@@ -126,4 +126,7 @@ ADD_UNIT_TESTS(
   Test2488.py
   Test18451.py
   Test19031.py
+  Test19990_1.py
+  Test19990_2.py
+  Test20167.py
 )