X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_ZeroOffset.cpp;h=f2857f935bee26f0f55f7f702796e1e20dd4e8a0;hb=45fcac308a927f173b4cf7a5c705776be26c687f;hp=2aa3cf45a28949462727348b99420c41c5a1063f;hpb=64e9d01b48f8c4e6e22919ebceeed715d613485e;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index 2aa3cf45a..f2857f935 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// File: GeomValidators_ZeroOffset.h +// File: GeomValidators_ZeroOffset.cpp // Created: 13 May 2015 // Author: Dmitry Bobylev @@ -9,46 +9,81 @@ #include #include #include +#include //================================================================================================= bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& theFeature, - const std::list& theArguments) const + const std::list& theArguments, + std::string& theError) const { - if(theArguments.size() < 4) { + if(theArguments.size() != 8) { return false; } std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); - std::shared_ptr aFromShape; - std::shared_ptr aToShape; + std::string aSelectedMethod; + if(theFeature->string(*anIt)) { + aSelectedMethod = theFeature->string(*anIt)->value(); + } + anIt++; + std::string aCreationMethod = *anIt; + anIt++; + + double aToSize = 0.0; + double aFromSize = 0.0; - std::shared_ptr anAttrSel = theFeature->selection(*anIt); - if(anAttrSel) { - aFromShape = std::dynamic_pointer_cast(anAttrSel->value()); + if(theFeature->real(*anIt)) { + aToSize = theFeature->real(*anIt)->value(); } anIt++; - anAttrSel = theFeature->selection(*anIt); + if(theFeature->real(*anIt)) { + aFromSize = theFeature->real(*anIt)->value(); + } + anIt++; + + if(aSelectedMethod == aCreationMethod) { + if(aToSize == -aFromSize) { + return false; + } else { + return true; + } + } + + std::shared_ptr aToShape; + std::shared_ptr aFromShape; + + std::shared_ptr anAttrSel = theFeature->selection(*anIt); if(anAttrSel) { aToShape = std::dynamic_pointer_cast(anAttrSel->value()); + if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { + aToShape = anAttrSel->context()->shape(); + } } anIt++; - double aFromOffset = 0.0; - double aToOffset = 0.0; - std::shared_ptr anAttrDouble = theFeature->real(*anIt); if(anAttrDouble) { - aFromOffset = anAttrDouble->value(); + aToSize = anAttrDouble->value(); } anIt++; + + anAttrSel = theFeature->selection(*anIt); + if(anAttrSel) { + aFromShape = std::dynamic_pointer_cast(anAttrSel->value()); + if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { + aFromShape = anAttrSel->context()->shape(); + } + } + anIt++; + anAttrDouble = theFeature->real(*anIt); if(anAttrDouble) { - aToOffset = anAttrDouble->value(); + aFromSize = anAttrDouble->value(); } if(((!aFromShape && !aToShape) || ((aFromShape && aToShape) && aFromShape->isEqual(aToShape))) - && (aFromOffset == 0.0 && aToOffset == 0.0)) { + && (aFromSize == -aToSize)) { return false; }