From: Jérôme Date: Thu, 10 Dec 2020 18:52:18 +0000 (+0100) Subject: #20442 : Add default value for tolerance and remove transparency in API X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b852bcba9a1d836fe34e431b7e6ee9df244efa75;p=modules%2Fshaper.git #20442 : Add default value for tolerance and remove transparency in API --- diff --git a/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.cpp b/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.cpp index 4e26e4695..4ec1971d9 100644 --- a/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.cpp +++ b/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.cpp @@ -45,14 +45,12 @@ FeaturesAPI_DuplicatedFaces::~FeaturesAPI_DuplicatedFaces() FeaturesAPI_DuplicatedFaces::FeaturesAPI_DuplicatedFaces( const std::shared_ptr& 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& 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& aDuplicatedFaces.reset(new FeaturesAPI_DuplicatedFaces(aFeature, theObject, - theTransparency, theTolerance, theNameGroup)); diff --git a/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.h b/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.h index 12705dbe4..eb0764633 100644 --- a/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.h +++ b/src/FeaturesAPI/FeaturesAPI_DuplicatedFaces.h @@ -47,7 +47,6 @@ public: FEATURESAPI_EXPORT explicit FeaturesAPI_DuplicatedFaces(const std::shared_ptr& 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 DuplicatedFacesPtr; FEATURESAPI_EXPORT DuplicatedFacesPtr getDuplicatedFaces(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theObject, - const ModelHighAPI_Integer& theTransparency, const ModelHighAPI_Double& theTolerance, const std::string & theNameGroup); diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp index 147ab3abf..bcfa83648 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp @@ -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(aResult); - std::list allRes; - ModelAPI_Tools::allSubs(aResultBody, allRes); - std::list::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(aResult); + std::list allRes; + ModelAPI_Tools::allSubs(aResultBody, allRes); + std::list::iterator aRes; + for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) { + ModelAPI_Tools::setTransparency(*aRes, aTranparency); + } } } } diff --git a/src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py b/src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py index 6c08bcb45..b5d18f47f 100644 --- a/src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py +++ b/src/FeaturesPlugin/Test/TestCheckDuplicatedFaces.py @@ -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 diff --git a/src/FeaturesPlugin/doc/checkDuplicatedFaceFeature.rst b/src/FeaturesPlugin/doc/checkDuplicatedFaceFeature.rst index 181b1682f..744d75e4e 100644 --- a/src/FeaturesPlugin/doc/checkDuplicatedFaceFeature.rst +++ b/src/FeaturesPlugin/doc/checkDuplicatedFaceFeature.rst @@ -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. diff --git a/src/FeaturesPlugin/doc/examples/checkDuplicatedFaces.py b/src/FeaturesPlugin/doc/examples/checkDuplicatedFaces.py index 40be3117c..b12dc2d09 100644 --- a/src/FeaturesPlugin/doc/examples/checkDuplicatedFaces.py +++ b/src/FeaturesPlugin/doc/examples/checkDuplicatedFaces.py @@ -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() diff --git a/src/FeaturesPlugin/duplicated_faces_macro_widget.xml b/src/FeaturesPlugin/duplicated_faces_macro_widget.xml index 4b94b1109..df02d0131 100644 --- a/src/FeaturesPlugin/duplicated_faces_macro_widget.xml +++ b/src/FeaturesPlugin/duplicated_faces_macro_widget.xml @@ -30,8 +30,8 @@ + step="0.00001" + default="1e-7"> diff --git a/src/FeaturesPlugin/duplicated_faces_widget.xml b/src/FeaturesPlugin/duplicated_faces_widget.xml index 1d01b3c0a..ccd2c420a 100644 --- a/src/FeaturesPlugin/duplicated_faces_widget.xml +++ b/src/FeaturesPlugin/duplicated_faces_widget.xml @@ -30,8 +30,8 @@ + step="0.00001" + default="1e-7">