From: lucasjerome Date: Wed, 23 Dec 2020 18:21:08 +0000 (+0100) Subject: #20441 : Improved algo performance and add translation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f1a3e1b54f91bd87dc9d8c980b8fe6ff1f07558f;p=modules%2Fshaper.git #20441 : Improved algo performance and add translation --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.cpp index 0cd9bc0df..f3fe8ca04 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -51,11 +52,18 @@ void FeaturesPlugin_CommonSharedFaces::updateFaces() std::dynamic_pointer_cast (attributListFaces()); - if (aFacesListAttr->isInitialized()) - aFacesListAttr->clear(); - GeomShapePtr aShape = ancompSolidAttr->value(); - if (aShape.get() && ancompSolidAttr->context().get()) { + + AttributeBooleanPtr anIsCompute = + std::dynamic_pointer_cast(attributIsCompute()); + if (!anIsCompute->value()) { + myShape = aShape; + anIsCompute->setValue(true); + } + if (aShape.get() && ancompSolidAttr->context().get() && !aShape->isEqual(myShape)) { + + if (aFacesListAttr->isInitialized()) + aFacesListAttr->clear(); aShape = ancompSolidAttr->context()->shape(); if (aShape) { @@ -70,6 +78,7 @@ void FeaturesPlugin_CommonSharedFaces::updateFaces() anError)) setError("Error in GetSharedFaces calculation :" + anError); + myShape = aShape; aFacesListAttr->setSelectionType("face"); ListOfShape::const_iterator anIt = aFaces.cbegin(); @@ -83,7 +92,7 @@ void FeaturesPlugin_CommonSharedFaces::updateFaces() aFacesListAttr->append( ancompSolidAttr->context(), aFacePtr); } std::stringstream alabel; - alabel << "Number of shared faces : " << aFacesListAttr->size(); + alabel << aFacesListAttr->size(); AttributeStringPtr aNumberFacesAttr = std::dynamic_pointer_cast (attributNumberFaces()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.h index dabe7c706..a3ad2b524 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.h @@ -49,6 +49,9 @@ public: /// Return Attribut values of result. virtual AttributePtr attributNumberFaces() = 0; + /// Return Attribut values of IsCompute. + virtual AttributePtr attributIsCompute() = 0; + protected: FeaturesPlugin_CommonSharedFaces() {} @@ -58,6 +61,9 @@ public: // Update the list of faces void updateFaces(); + // the shape studied + GeomShapePtr myShape; + }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp index 0bdc7208f..0dd6a3609 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp @@ -57,8 +57,12 @@ void FeaturesPlugin_GroupSharedFaces::initAttributes() data()->addAttribute(NUMBER_FACES_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::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(), COMPUTE_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), NUMBER_FACES_ID()); + data()->boolean(COMPUTE_ID())->setValue(true); } @@ -69,6 +73,12 @@ AttributePtr FeaturesPlugin_GroupSharedFaces::attributObject() return attribute(OBJECT_ID()); } +//================================================================================================= +AttributePtr FeaturesPlugin_GroupSharedFaces::attributIsCompute() +{ + return attribute(COMPUTE_ID()); +} + //================================================================================================= AttributePtr FeaturesPlugin_GroupSharedFaces::attributListFaces() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h index b243b43d9..fc51d79cb 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h @@ -76,6 +76,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(); @@ -100,6 +107,9 @@ public: /// Return Attribut values of number of faces. virtual AttributePtr attributNumberFaces(); + /// Return Attribut values of IsCompute. + virtual AttributePtr attributIsCompute(); + }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.cpp index e80ecf1a3..ba4b9be1d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.cpp @@ -60,10 +60,18 @@ void FeaturesPlugin_SharedFaces::initAttributes() data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::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_SharedFaces::attributIsCompute() +{ + return attribute(COMPUTE_ID()); +} //================================================================================================= AttributePtr FeaturesPlugin_SharedFaces::attributObject() @@ -161,15 +169,24 @@ void FeaturesPlugin_SharedFaces::createGroup() //================================================================================================= void FeaturesPlugin_SharedFaces::updateGroup() { + myCreateGroupFeature->boolean(FeaturesPlugin_GroupSharedFaces::COMPUTE_ID())->setValue(false); myCreateGroupFeature->string(FeaturesPlugin_GroupSharedFaces::GROUP_NAME_ID()) ->setValue( string(GROUP_NAME_ID())->value()); myCreateGroupFeature->selection(FeaturesPlugin_GroupSharedFaces::OBJECT_ID()) ->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_GroupSharedFaces::TRANSPARENCY_ID()) ->setValue( integer(TRANSPARENCY_ID())->value()); myCreateGroupFeature->execute(); + myCreateGroupFeature->boolean(FeaturesPlugin_GroupSharedFaces::COMPUTE_ID())->setValue(true); } \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h b/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h index 5fc5d45aa..815515c76 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h +++ b/src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h @@ -76,6 +76,13 @@ public: return MY_CREATE_GROUP_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; + } + /// Attribute name for group name. inline static const std::string& GROUP_NAME_ID() { @@ -110,6 +117,9 @@ public: /// Return Attribut values of number of faces. virtual AttributePtr attributNumberFaces(); + /// Return Attribut values of IsCompute. + virtual AttributePtr attributIsCompute(); + /// Create group void createGroup(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts index 6f821a2e2..55be09ba6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts @@ -131,6 +131,10 @@ Rotation Rotation + + Check shared faces + Vérifier les faces partagées + Symmetry Symétrie @@ -4853,6 +4857,124 @@ + + + Shared_faces_macro + + Check shared faces + Vérifier les faces partagées + + + Shared faces + Faces partagées + + + Number of shared faces : + Nombre de face partagées : + + + + Shared_faces_macro:create_group + + Create group + Créer un groupe + + + + Shared_faces_macro:group_name + + Group name + Nom du groupe + + + + Shared_faces_macro:main_object + + Object + Objet + + + Shared faces + Faces partagées + + + + Shared_faces_macro:group_list + + Shared faces + Faces partagées + + + List of faces : + Liste des faces : + + + + Shared_faces_macro:transparency + + Transparency + Transparence + + + + Shared_faces + + Check shared faces + Vérifier les faces partagées + + + Shared faces + Faces partagées + + + Number of shared faces : + Nombre de face partagées : + + + + Shared_faces:create_group + + Create group + Créer un groupe + + + + Shared_faces:group_name + + Group name + Nom du groupe + + + + Shared_faces:main_object + + Object + Objet + + + Shared faces + Faces partagées + + + + Shared_faces:group_list + + Shared faces + Faces partagées + + + List of faces : + Liste des faces : + + + + Shared_faces:transparency + + Transparency + Transparence + + + Symmetry diff --git a/src/FeaturesPlugin/shared_Faces_macro_widget.xml b/src/FeaturesPlugin/shared_Faces_macro_widget.xml index 9fc5197f5..99dd120ce 100644 --- a/src/FeaturesPlugin/shared_Faces_macro_widget.xml +++ b/src/FeaturesPlugin/shared_Faces_macro_widget.xml @@ -9,9 +9,9 @@ -