X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_FeatureKind.cpp;h=746e184aad14144f20b3e9d4408e0e2551ad33b5;hb=97c06c5cd9fc736f9b5a1dacde369a9d7b5be703;hp=3ae8200825ad8bfc31ff61b7f77099efd3d6eeb9;hpb=5c0a5d1054fc9d185ab08b77583aa7cc4453d41a;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_FeatureKind.cpp b/src/GeomValidators/GeomValidators_FeatureKind.cpp old mode 100755 new mode 100644 index 3ae820082..746e184aa --- a/src/GeomValidators/GeomValidators_FeatureKind.cpp +++ b/src/GeomValidators/GeomValidators_FeatureKind.cpp @@ -1,14 +1,30 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomValidators_FeatureKind.cpp -// Created: 22 March 2015 -// Author: Natalia Ermolaeva +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "GeomValidators_FeatureKind.h" +#include + #include #include #include +#include #include #define DEBUG_EXTRUSION_INVALID_SKETCH @@ -18,7 +34,7 @@ bool GeomValidators_FeatureKind::isValid(const AttributePtr& theAttribute, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { bool isSketchEntities = true; std::set anEntityKinds; @@ -32,32 +48,8 @@ bool GeomValidators_FeatureKind::isValid(const AttributePtr& theAttribute, } std::string anAttributeType = theAttribute->attributeType(); - if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) { - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(theAttribute); - // all context objects should be sketch entities - for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) { - AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i); - ObjectPtr anObject = aSelectAttr->context(); - // a context of the selection attribute is a feature result. It can be a case when the result - // of the feature is null, e.g. the feature is modified and has not been executed yet. - // The validator returns an invalid result here. The case is an extrusion built on a sketch - // feature. A new sketch element creation leads to an empty result. - if (!anObject.get()) - isSketchEntities = false; - else { - FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); - isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end(); -#ifdef DEBUG_EXTRUSION_INVALID_SKETCH - CompositeFeaturePtr aComp = std::dynamic_pointer_cast(aFeature); - if (aComp.get() && aComp->numberOfSubs() == 1) - return false; -#endif - } - } - } if (anAttributeType == ModelAPI_AttributeSelection::typeId()) { - AttributeSelectionPtr aSelectAttr = + AttributeSelectionPtr aSelectAttr = std::dynamic_pointer_cast(theAttribute); ObjectPtr anObject = aSelectAttr->context(); // a context of the selection attribute is a feature result. It can be a case when the result @@ -71,37 +63,6 @@ bool GeomValidators_FeatureKind::isValid(const AttributePtr& theAttribute, isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end(); } } - if (anAttributeType == ModelAPI_AttributeRefList::typeId()) { - AttributeRefListPtr aRefListAttr = - std::dynamic_pointer_cast(theAttribute); - // all context objects should be sketch entities - for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) { - ObjectPtr anObject = aRefListAttr->object(i); - // a context of the selection attribute is a feature result. It can be a case when the result - // of the feature is null, e.g. the feature is modified and has not been executed yet. - // The validator returns an invalid result here. The case is an extrusion built on a sketch - // feature. A new sketch element creation leads to an empty result. - if (!anObject.get()) - isSketchEntities = false; - else { - FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); - isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end(); - } - } - } - if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) { - std::shared_ptr aRef = - std::dynamic_pointer_cast(theAttribute); - isSketchEntities = false; - if (aRef->isObject()) { - ObjectPtr anObject = aRef->object(); - if (anObject.get() != NULL) { - FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); - if (aFeature.get() != NULL) - isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end(); - } - } - } if (!isSketchEntities) { theError = "It refers to feature, which kind is not in the list: " + anEntityKindsStr; }