Salome HOME
Merge branch 'Dev_2.1.0' of salome:modules/shaper into Dev_2.1.0
[modules/shaper.git] / src / GeomValidators / GeomValidators_Different.cpp
index 85921c0d43a67620fc8800a9eff5e50397c9621c..94c369c5a516f796d1c6f4f8fe9023901ddd3a25 100644 (file)
@@ -37,10 +37,16 @@ bool isEqualAttributes(const AttributePtr& theLeft, const AttributePtr& theRight
   return false;
 }
 
+/** \class IsEqual
+ *  \ingroup Validators
+ *  \brief Auxiliary class used in std::find_if
+ */
 class IsEqual {
   AttributePtr myAttribute;
 public:
+  /// Constructor
   IsEqual(const AttributePtr& theAttribute) : myAttribute(theAttribute) {}
+  /// \return true in case if AttributePtr is equal with myAttribute
   bool operator()(const AttributePtr& theAttribute) {
     return isEqualAttributes(myAttribute, theAttribute);
   }
@@ -69,8 +75,12 @@ bool GeomValidators_Different::isValid(const std::shared_ptr<ModelAPI_Feature>&
       std::list<AttributePtr>::const_iterator aNextIt = anAttributeIt; ++aNextIt;
       while (aNextIt != anAttributes.end()) {
         // if equal attribute is found then all attributes are not different
-        if (std::find_if(aNextIt, anAttributes.end(), IsEqual(*anAttributeIt)) != anAttributes.end()) 
+        std::list<AttributePtr>::const_iterator aFindIt =
+            std::find_if(aNextIt, anAttributes.end(), IsEqual(*anAttributeIt));
+        if (aFindIt != anAttributes.end()) {
+          theError = "Attributes " + (*anAttributeIt)->id() + " and " + (*aFindIt)->id() + " are equal." ;
           return false;
+        }
         ++anAttributeIt;
         ++aNextIt; 
       }