From: lucasjerome Date: Wed, 23 Dec 2020 19:13:30 +0000 (+0100) Subject: #20442 : Improved algo performance and add translation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCEA_2020%2FLot2_DuplicatedFaces;p=modules%2Fshaper.git #20442 : Improved algo performance and add translation --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp index 93e7f4a66..4dbf10a12 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -62,15 +63,23 @@ void FeaturesPlugin_CommonDuplicatedFaces::updateFaces() std::dynamic_pointer_cast (attributListFaces()); - if (aFacesListAttr->isInitialized()) - aFacesListAttr->clear(); - + GeomShapePtr aShape = ancompSolidAttr->value(); + AttributeDoublePtr aToleranceAttr = std::dynamic_pointer_cast (attributTolerance()); - GeomShapePtr aShape = ancompSolidAttr->value(); - if (aShape.get() && ancompSolidAttr->context().get() && aToleranceAttr.get()) { + AttributeBooleanPtr anIsCompute = + std::dynamic_pointer_cast(attributIsCompute()); + if (!anIsCompute->value()) { + myShape = aShape; + anIsCompute->setValue(true); + } + if (aShape.get() && ancompSolidAttr->context().get() + && aToleranceAttr.get() && !aShape->isEqual(myShape)) { + + if (aFacesListAttr->isInitialized()) + aFacesListAttr->clear(); aShape = ancompSolidAttr->context()->shape(); if (aShape) { @@ -85,6 +94,7 @@ void FeaturesPlugin_CommonDuplicatedFaces::updateFaces() anError)) setError("Error in duplicated faces calculation :" + anError); + myShape = aShape; aFacesListAttr->setSelectionType("face"); ListOfShape::const_iterator anIt = aFaces.cbegin(); @@ -98,7 +108,7 @@ void FeaturesPlugin_CommonDuplicatedFaces::updateFaces() aFacesListAttr->append(ancompSolidAttr->context(), aFacePtr); } std::stringstream alabel; - alabel << "Number of duplicated faces : " << aFacesListAttr->size(); + alabel << aFacesListAttr->size(); AttributeStringPtr aNumberFacesAttr = std::dynamic_pointer_cast (attributNumberFaces()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h index 4333f34c4..30ae3211b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h @@ -52,6 +52,9 @@ public: /// Return Attribut values of tolerance. virtual AttributePtr attributTolerance() = 0; + /// Return Attribut values of IsCompute. + virtual AttributePtr attributIsCompute() = 0; + protected: FeaturesPlugin_CommonDuplicatedFaces() {} @@ -61,6 +64,9 @@ public: // Update the list of faces void updateFaces(); + // the shape studied + GeomShapePtr myShape; + }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.cpp index 6a409fee6..687ec225e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.cpp @@ -59,10 +59,19 @@ void FeaturesPlugin_DuplicatedFaces::initAttributes() data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(CREATE_GROUP_ID(), ModelAPI_AttributeBoolean::typeId()); data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), GROUP_NAME_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID()); + data()->boolean(COMPUTE_ID())->setValue(true); } +//================================================================================================= +AttributePtr FeaturesPlugin_DuplicatedFaces::attributIsCompute() +{ + return attribute(COMPUTE_ID()); +} //================================================================================================= AttributePtr FeaturesPlugin_DuplicatedFaces::attributObject() @@ -167,6 +176,8 @@ void FeaturesPlugin_DuplicatedFaces::createGroup() //================================================================================================= void FeaturesPlugin_DuplicatedFaces::updateGroup() { + myCreateGroupFeature-> + boolean(FeaturesPlugin_GroupDuplicatedFaces::COMPUTE_ID())->setValue(false); myCreateGroupFeature->string(FeaturesPlugin_GroupDuplicatedFaces::GROUP_NAME_ID()) ->setValue(string(GROUP_NAME_ID())->value()); @@ -174,6 +185,14 @@ void FeaturesPlugin_DuplicatedFaces::updateGroup() ->setValue(selection(OBJECT_ID())->context() , selection(OBJECT_ID())->value()); + AttributeSelectionListPtr aFacesFeatures = + std::dynamic_pointer_cast + (myCreateGroupFeature->attribute(LIST_FACES_ID())); + AttributeSelectionListPtr aFaces = + std::dynamic_pointer_cast(attribute(LIST_FACES_ID())); + + aFaces->copyTo(aFacesFeatures); + myCreateGroupFeature->integer(FeaturesPlugin_GroupDuplicatedFaces::TRANSPARENCY_ID()) ->setValue(integer(TRANSPARENCY_ID())->value()); @@ -181,4 +200,6 @@ void FeaturesPlugin_DuplicatedFaces::updateGroup() ->setValue(real(TOLERANCE_ID())->value()); myCreateGroupFeature->execute(); + myCreateGroupFeature + ->boolean(FeaturesPlugin_GroupDuplicatedFaces::COMPUTE_ID())->setValue(true); } \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h index b58172879..5081e8ee8 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h @@ -55,7 +55,7 @@ public: return MY_NUMBER_FACES_ID; } - /// Attribute name for list of faces. + /// Attribute name for z coodinate. inline static const std::string& LIST_FACES_ID() { static const std::string MY_LIST_FACES_ID("group_list"); @@ -90,6 +90,13 @@ public: return MY_GROUP_NAME_ID; } + /// Attribute name for indicate to launch the algo. + inline static const std::string& COMPUTE_ID() + { + static const std::string MY_COMPUTE_ID("compute"); + return MY_COMPUTE_ID; + } + /// Performs the algorithm and stores results it in the data structure. FEATURESPLUGIN_EXPORT virtual void execute(); @@ -120,6 +127,9 @@ public: /// Return Attribut values of tolerance. virtual AttributePtr attributTolerance(); + /// Return Attribut values of IsCompute. + virtual AttributePtr attributIsCompute(); + /// Create group void createGroup(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp index bcfa83648..7f0d05f1c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp @@ -60,9 +60,13 @@ void FeaturesPlugin_GroupDuplicatedFaces::initAttributes() data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TRANSPARENCY_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TRANSPARENCY_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), NUMBER_FACES_ID()); + data()->boolean(COMPUTE_ID())->setValue(true); } @@ -72,6 +76,12 @@ AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributObject() return attribute(OBJECT_ID()); } +//================================================================================================= +AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributIsCompute() +{ + return attribute(COMPUTE_ID()); +} + //================================================================================================= AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributListFaces() { @@ -117,7 +127,7 @@ void FeaturesPlugin_GroupDuplicatedFaces::execute() 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; diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h index e8d261cea..828137fae 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h @@ -83,6 +83,13 @@ public: return MY_GROUP_NAME_ID; } + /// Attribute name for indicate to launch the algo. + inline static const std::string& COMPUTE_ID() + { + static const std::string MY_COMPUTE_ID("compute"); + return MY_COMPUTE_ID; + } + /// Performs the algorithm and stores results it in the data structure. FEATURESPLUGIN_EXPORT virtual void execute(); @@ -110,6 +117,9 @@ public: /// Return Attribut values of tolerance. virtual AttributePtr attributTolerance(); + /// Return Attribut values of IsCompute. + virtual AttributePtr attributIsCompute(); + }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts index 6f821a2e2..f14f2fc0b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts @@ -131,6 +131,10 @@ Rotation Rotation + + Check duplicated faces + Vérifier les faces dupliquées + Symmetry Symétrie @@ -4853,6 +4857,138 @@ + + + Duplicated_faces_macro + + Check duplicated faces + Vérifier les faces dupliquées + + + Duplicated faces + Faces dupliquées + + + Number of duplicated faces : + Nombre de faces dupliquées : + + + + Duplicated_faces_macro:create_group + + Create group + Créer un groupe + + + + Duplicated_faces_macro:group_name + + Group name + Nom du groupe + + + + Duplicated_faces_macro:main_object + + Object + Objet + + + Duplicated faces + Faces dupliquées + + + + Duplicated_faces_macro:group_list + + Duplicated faces + Faces dupliquées + + + List of faces : + Liste des faces : + + + + Duplicated_faces_macro:transparency + + Transparency + Transparence + + + + Duplicated_faces_macro:tolerance + + Tolerance + Tolérance + + + + Duplicated_faces + + Check duplicated faces + Vérifier les faces dupliquées + + + Duplicated faces + Faces dupliquées + + + Number of duplicated faces : + Nombre de faces dupliquées : + + + + Duplicated_faces:create_group + + Create group + Créer un groupe + + + + Duplicated_faces:group_name + + Group name + Nom du groupe + + + + Duplicated_faces:main_object + + Object + Objet + + + Duplicated faces + Faces dupliquées + + + + Duplicated_faces:group_list + + Duplicatedfaces + Faces dupliquées + + + List of faces : + Liste des faces : + + + + Duplicated_faces:transparency + + Transparency + Transparence + + + + Duplicated_faces:tolerance + + Tolerance + Tolérance + + + Symmetry diff --git a/src/FeaturesPlugin/duplicated_faces_macro_widget.xml b/src/FeaturesPlugin/duplicated_faces_macro_widget.xml index 1e9c24505..532fcc37a 100644 --- a/src/FeaturesPlugin/duplicated_faces_macro_widget.xml +++ b/src/FeaturesPlugin/duplicated_faces_macro_widget.xml @@ -9,7 +9,7 @@ -