]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#20442 : Add default value for tolerance and remove transparency in API
authorJérôme <jerome.lucas@cesgenslab.fr>
Thu, 10 Dec 2020 18:52:18 +0000 (19:52 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Thu, 10 Dec 2020 18:52:18 +0000 (19:52 +0100)
src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.cpp
src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.h
src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp
src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py
src/FeaturesPlugin/doc/checkDuplicatedFaceFeature.rst
src/FeaturesPlugin/doc/examples/checkDuplicatedFaces.py
src/FeaturesPlugin/duplicated_faces_macro_widget.xml
src/FeaturesPlugin/duplicated_faces_widget.xml

index 4e26e46950b2d2189647c2c06a0ef7d99a01d137..4ec1971d9c4a72ded12b96828ae9b4f011e8a902 100644 (file)
@@ -45,14 +45,12 @@ FeaturesAPI_DuplicatedFaces::~FeaturesAPI_DuplicatedFaces()
 FeaturesAPI_DuplicatedFaces::FeaturesAPI_DuplicatedFaces(
                              const std::shared_ptr<ModelAPI_Feature>& theFeature,
                              const ModelHighAPI_Selection& theObject,
-                             const ModelHighAPI_Integer& theTransparency,
                              const ModelHighAPI_Double& theTolerance,
                              const std::string & theNameGroup)
 :ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
     fillAttribute(theObject, myobjectselected);
-    fillAttribute(theTransparency, mytransparency);
     fillAttribute(theTolerance, mytolerance);
     fillAttribute(theNameGroup, mygroupname);
 
@@ -70,7 +68,6 @@ void FeaturesAPI_DuplicatedFaces::dump(ModelHighAPI_Dumper& theDumper) const
     anAttrObject = aBase->selection(FeaturesPlugin_GroupDuplicatedFaces::OBJECT_ID());
 
   theDumper << aBase << " = model.getDuplicatedFaces(" << aDocName << ", " << anAttrObject;
-  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;
@@ -79,7 +76,6 @@ void FeaturesAPI_DuplicatedFaces::dump(ModelHighAPI_Dumper& theDumper) const
 //=================================================================================================
 DuplicatedFacesPtr getDuplicatedFaces(const std::shared_ptr<ModelAPI_Document>& thePart,
                                       const ModelHighAPI_Selection& theObject,
-                                      const ModelHighAPI_Integer& theTransparency,
                                       const ModelHighAPI_Double& theTolerance,
                                       const std::string & theNameGroup)
 {
@@ -90,7 +86,6 @@ DuplicatedFacesPtr getDuplicatedFaces(const std::shared_ptr<ModelAPI_Document>&
 
   aDuplicatedFaces.reset(new FeaturesAPI_DuplicatedFaces(aFeature,
                                                          theObject,
-                                                         theTransparency,
                                                          theTolerance,
                                                          theNameGroup));
 
index 12705dbe44b23295d40cd2fa80ca5188548ef571..eb0764633161e24fd6d792c4fe3ceff93756e94e 100644 (file)
@@ -47,7 +47,6 @@ public:
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_DuplicatedFaces(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                        const ModelHighAPI_Selection& theobject,
-                                       const ModelHighAPI_Integer& theTransparency,
                                        const ModelHighAPI_Double& theTolerance,
                                        const std::string & theNameGroup);
 
@@ -55,13 +54,10 @@ public:
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_DuplicatedFaces();
 
-    INTERFACE_4(FeaturesPlugin_GroupDuplicatedFaces::ID(),
+    INTERFACE_3(FeaturesPlugin_GroupDuplicatedFaces::ID(),
                 objectselected, FeaturesPlugin_GroupDuplicatedFaces::OBJECT_ID(),
                               ModelAPI_AttributeSelection,
                               /** object selected*/,
-                transparency, FeaturesPlugin_GroupDuplicatedFaces::TRANSPARENCY_ID(),
-                              ModelAPI_AttributeInteger,
-                              /** transparency*/,
                 tolerance, FeaturesPlugin_GroupDuplicatedFaces::TOLERANCE_ID(),
                               ModelAPI_AttributeDouble,
                               /** tolerance*/,
@@ -85,7 +81,6 @@ typedef std::shared_ptr<FeaturesAPI_DuplicatedFaces> DuplicatedFacesPtr;
 FEATURESAPI_EXPORT
 DuplicatedFacesPtr getDuplicatedFaces(const std::shared_ptr<ModelAPI_Document>& thePart,
                                       const ModelHighAPI_Selection& theObject,
-                                      const ModelHighAPI_Integer& theTransparency,
                                       const ModelHighAPI_Double& theTolerance,
                                       const std::string & theNameGroup);
 
index 147ab3abfed075229078a99222fa3d8c32ad53c6..bcfa8364820354b260e1fd19631edd6f7a9155bf 100644 (file)
@@ -61,6 +61,8 @@ void FeaturesPlugin_GroupDuplicatedFaces::initAttributes()
   data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId());
 
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TRANSPARENCY_ID());
+
 }
 
 
@@ -112,15 +114,18 @@ void FeaturesPlugin_GroupDuplicatedFaces::execute()
     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);
+    if(integer(TRANSPARENCY_ID())->isInitialized()){
+      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);
+      }
     }
   }
 }
index 6c08bcb45d7e8c89b103be260f76bd51cab4a7db..b5d18f47f4ee60dcf38b58d6811284c69403d6cc 100644 (file)
@@ -60,7 +60,7 @@ if __name__ == '__main__':
                           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")
+    Duplicated_faces_1 = model.getDuplicatedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 0.001, "mygroup")
 
     model.do()
      # Check results
index 181b1682f295bc23c981527f63addb77e51da24a..744d75e4e64e722c03d8aaff817df3b26e527cd1 100644 (file)
@@ -33,11 +33,10 @@ Input fields:
 
 **TUI Command**:
 
-.. py:function:: model.getDuplicatedFaces(Part_doc, shape, transparency, tolerance, nameGroup)
+.. py:function:: model.getDuplicatedFaces(Part_doc, shape, tolerance, nameGroup)
  
     :param part: The current part object.
     :param object: A composolid or compound in format *model.selection("Type", shape)*.
-    :param number: value of the transparency.
     :param number: value of the tolerance.
     :param string: name of group created. 
     :return: Created group.
index 40be3117c4fd3ba3b62eb225ceedd513ea87028d..b12dc2d09ea1caf231c8d21662a440dbf314fe6e 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, 0.001, "mygroup")
+Duplicated_faces_1 = model.getDuplicatedFaces(Part_1_doc, model.selection("COMPOUND", "Compound_1_1"), 0.001, "mygroup")
 
 model.do()
 model.end()
index 4b94b1109266f93d5dd2692a8e34543673c6edf4..df02d0131220f4fb51554a7dd0ceb23294aa0df8 100644 (file)
@@ -30,8 +30,8 @@
   <doublevalue id="tolerance"
                     label="Tolerance"
                     min="0"
-                    step="0.001"
-                    default="0.001">
+                    step="0.00001"
+                    default="1e-7">
   </doublevalue>
   <optionalbox id="create_group" title="Create group" show_title="true">
     <stringvalue id="group_name" label="Group Name"/>
index 1d01b3c0a03447e488fdd9061e833ebd79fbbb42..ccd2c420a37ee8637ca2995aa144a2cfdf68a581 100644 (file)
@@ -30,8 +30,8 @@
   <doublevalue id="tolerance"
                     label="Tolerance"
                     min="0"
-                    step="0.001"
-                    default="0.001">
+                    step="0.00001"
+                    default="1e-7">
   </doublevalue>
   <stringvalue id="group_name" label="Group Name"/>
 </source>