]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
It removes excessive code. The problem is Placement feature: it is not possible to...
authornds <nds@opencascade.com>
Fri, 28 Aug 2015 19:33:18 +0000 (22:33 +0300)
committernds <nds@opencascade.com>
Fri, 28 Aug 2015 19:33:18 +0000 (22:33 +0300)
Also, the regression of the issue #359 is corrected[Axis with the same point on both ends]

src/ModelAPI/ModelAPI_ShapeValidator.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h

index 1bd2e50c52995527dd0eebebdd6220970be6e29c..2348819b0a986bee02e7017aaa4960841486c70d 100644 (file)
@@ -17,6 +17,11 @@ bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
   AttributeSelectionPtr aSelectionAttribute = 
                      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
   GeomShapePtr aShape = aSelectionAttribute->value();
+  if (!aShape.get()) {
+    ResultPtr aResult = aSelectionAttribute->context();
+    if (aResult.get())
+      aShape = aResult->shape();
+  }
 
   std::string aCurrentAttributeId = theAttribute->id();
   // get all feature attributes
@@ -28,11 +33,19 @@ bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
       AttributePtr anAttribute = *anAttr;
       // take into concideration only other attributes
       if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
-        AttributeSelectionPtr aSelectionAttribute = 
+        aSelectionAttribute = 
           std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
         // the shape of the attribute should be not the same
-        if (aSelectionAttribute.get() != NULL && aShape->isEqual(aSelectionAttribute->value())) {
-          return false;
+        if (aSelectionAttribute.get() != NULL) {
+          GeomShapePtr anAttrShape = aSelectionAttribute->value();
+          if (!anAttrShape.get()) {
+            ResultPtr aResult = aSelectionAttribute->context();
+            if (aResult.get())
+              anAttrShape = aResult->shape();
+            }
+            if (aShape->isEqual(anAttrShape)) {
+            return false;
+          }
         }
       }
     }
index 4bb729366c33b57bdbe75754f77dca7d5b3ccd79..8c5bd25ed41fb12eb6624a0f0f88d937431ea46a 100755 (executable)
@@ -320,37 +320,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
       }
     }
   }
-  return !featureHasReferences(theAttribute);
-}
-
-bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const
-{
-  std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
-  if (theAttribute->owner().get() && theAttribute->owner()->data()->isValid())
-    theAttribute->owner()->data()->referencesToObjects(allRefs);
-  // collect object referenced by theAttribute
-  std::list<ObjectPtr>* anAttrObjs = 0;
-  std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRefIter = allRefs.begin();
-  for(; aRefIter != allRefs.end(); aRefIter++) {
-    if (theAttribute->id() == aRefIter->first)
-      anAttrObjs = &(aRefIter->second);
-  }
-  if (!anAttrObjs || anAttrObjs->empty())
-    return false; // theAttribute does not references to anything
-  // check with all others
-  for(aRefIter = allRefs.begin(); aRefIter != allRefs.end(); aRefIter++) {
-    if (theAttribute->id() == aRefIter->first)
-      continue; // do not check with myself
-    std::list<ObjectPtr>::iterator aReferenced = aRefIter->second.begin();
-    for(; aReferenced != aRefIter->second.end(); aReferenced++) {
-      std::list<ObjectPtr>::iterator aReferencedByMe = anAttrObjs->begin();
-      for(; aReferencedByMe != anAttrObjs->end(); aReferencedByMe++) {
-        if (*aReferenced == *aReferencedByMe) // found same objects!
-          return true;
-      }
-    }
-  }
-  return false;
+  return true;
 }
 
 bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
index de46a76605cd87e330b00fe2d3205fd41b4fa415..6ba2896afa755eb293542d36752dcb7e519f2683 100644 (file)
@@ -122,12 +122,6 @@ class PartSet_DifferentObjectsValidator : public ModelAPI_AttributeValidator
   virtual bool isValid(const AttributePtr& theAttribute,
                        const std::list<std::string>& theArguments,
                        std::string& theError) const;
-
-protected:
-  //! Checks whethe other feature attributes has a reference to the given attribute
-  //! \param theAttribute a source attribute to find object
-  //! \return a boolean value
-  bool featureHasReferences(const AttributePtr& theAttribute) const;
 };
 
 /**