1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_ZeroOffset.h
4 // Created: 13 May 2015
5 // Author: Dmitry Bobylev
7 #include <GeomValidators_ZeroOffset.h>
9 #include <GeomAPI_Shape.h>
10 #include <ModelAPI_AttributeDouble.h>
11 #include <ModelAPI_AttributeSelection.h>
13 //=================================================================================================
14 bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
15 const std::list<std::string>& theArguments) const
17 if(theArguments.size() < 4) {
21 std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
23 std::shared_ptr<GeomAPI_Shape> aFromShape;
24 std::shared_ptr<GeomAPI_Shape> aToShape;
26 std::shared_ptr<ModelAPI_AttributeSelection> anAttrSel = theFeature->selection(*anIt);
28 aFromShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anAttrSel->value());
31 anAttrSel = theFeature->selection(*anIt);
33 aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(anAttrSel->value());
37 double aFromOffset = 0.0;
38 double aToOffset = 0.0;
40 std::shared_ptr<ModelAPI_AttributeDouble> anAttrDouble = theFeature->real(*anIt);
42 aFromOffset = anAttrDouble->value();
45 anAttrDouble = theFeature->real(*anIt);
47 aToOffset = anAttrDouble->value();
50 if(((!aFromShape && !aToShape) || ((aFromShape && aToShape) && aFromShape->isEqual(aToShape)))
51 && (aFromOffset == 0.0 && aToOffset == 0.0)) {
58 //=================================================================================================
59 bool GeomValidators_ZeroOffset::isNotObligatory(std::string theFeature, std::string theAttribute)
61 if(theAttribute == "from_object" || theAttribute == "to_object") {