X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_ZeroOffset.cpp;h=8375e1ad57f9306e968325a1a552ce7655259e59;hb=refs%2Fheads%2FV9_11_BR;hp=f898a2297b219ba1f5b5066b754a95cfdabec6c6;hpb=bc13ffbc8c0dbdce3805bf9362ee8a3c05adf9b4;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index f898a2297..8375e1ad5 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -1,11 +1,26 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomValidators_ZeroOffset.cpp -// Created: 13 May 2015 -// Author: Dmitry Bobylev +// Copyright (C) 2014-2023 CEA, EDF +// +// 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 +#include + #include #include #include @@ -15,42 +30,50 @@ #include #include #include +#include #include #include //================================================================================================= bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& theFeature, const std::list& theArguments, - std::string& theError) const + Events_InfoMessage& theError) const { +// LCOV_EXCL_START if(theArguments.size() != 9) { - theError = "Wrong number of validator arguments in xml(expected 9)."; + theError = "Wrong number of validator arguments in xml (expected 9)."; return false; } +// LCOV_EXCL_STOP - std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); + std::list::const_iterator anIt = theArguments.begin(); std::string aSelectedMethod; if(theFeature->string(*anIt)) { aSelectedMethod = theFeature->string(*anIt)->value(); } + if (aSelectedMethod == "ThroughAll") return true; anIt++; std::string aCreationMethod = *anIt; anIt++; ListOfShape aFacesList; if(theFeature->selection(*anIt)) { +// LCOV_EXCL_START AttributeSelectionPtr aFaceSelection = theFeature->selection(*anIt); - ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aFaceSelection->context()); + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(aFaceSelection->context()); if(aConstruction.get()) { int aSketchFacesNum = aConstruction->facesNum(); for(int aFaceIndex = 0; aFaceIndex < aSketchFacesNum; aFaceIndex++) { - std::shared_ptr aFace = std::dynamic_pointer_cast(aConstruction->face(aFaceIndex)); + std::shared_ptr aFace = + std::dynamic_pointer_cast(aConstruction->face(aFaceIndex)); if(aFace->isFace() && aFace->isPlanar()) { aFacesList.push_back(aFace); } } } +// LCOV_EXCL_STOP } else if(theFeature->selectionList(*anIt)) { AttributeSelectionListPtr aFacesSelectionList = theFeature->selectionList(*anIt); for(int anIndex = 0; anIndex < aFacesSelectionList->size(); anIndex++) { @@ -66,7 +89,8 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(!aContextShape.get()) { break; } - ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aContext); + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(aContext); if(!aConstruction.get()) { break; } @@ -85,11 +109,11 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& double aToSize = 0.0; double aFromSize = 0.0; - if(theFeature->real(*anIt)) { + if(theFeature->real(*anIt) && theFeature->real(*anIt)->isInitialized()) { aToSize = theFeature->real(*anIt)->value(); } anIt++; - if(theFeature->real(*anIt)) { + if(theFeature->real(*anIt) && theFeature->real(*anIt)->isInitialized()) { aFromSize = theFeature->real(*anIt)->value(); } anIt++; @@ -107,31 +131,39 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& std::shared_ptr aFromShape; std::shared_ptr anAttrSel = theFeature->selection(*anIt); - if(anAttrSel) { + if(anAttrSel && anAttrSel->isInitialized()) { aToShape = std::dynamic_pointer_cast(anAttrSel->value()); if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { aToShape = anAttrSel->context()->shape(); } + if (aToShape->isCompound()) { + GeomAPI_ShapeIterator aSIt(aToShape); + aToShape = aSIt.current(); + } } anIt++; std::shared_ptr anAttrDouble = theFeature->real(*anIt); - if(anAttrDouble) { + if(anAttrDouble && anAttrDouble->isInitialized()) { aToSize = anAttrDouble->value(); } anIt++; anAttrSel = theFeature->selection(*anIt); - if(anAttrSel) { + if(anAttrSel && anAttrSel->isInitialized()) { aFromShape = std::dynamic_pointer_cast(anAttrSel->value()); if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { aFromShape = anAttrSel->context()->shape(); } + if (aFromShape->isCompound()) { + GeomAPI_ShapeIterator aSIt(aFromShape); + aFromShape = aSIt.current(); + } } anIt++; anAttrDouble = theFeature->real(*anIt); - if(anAttrDouble) { + if(anAttrDouble && anAttrDouble->isInitialized()) { aFromSize = anAttrDouble->value(); } @@ -173,7 +205,8 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& } std::shared_ptr aPln = aFace->getPlane(); if(aPln.get()) { - for(ListOfShape::const_iterator anIter = aFacesList.cbegin(); anIter != aFacesList.cend(); anIter++) { + for(ListOfShape::const_iterator + anIter = aFacesList.cbegin(); anIter != aFacesList.cend(); anIter++) { std::shared_ptr aSketchShape = *anIter; std::shared_ptr aSketchFace(new GeomAPI_Face(aSketchShape)); std::shared_ptr aSketchPln = aSketchFace->getPlane(); @@ -194,6 +227,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& } //================================================================================================= +// LCOV_EXCL_START bool GeomValidators_ZeroOffset::isNotObligatory(std::string theFeature, std::string theAttribute) { if(theAttribute == "from_object" || theAttribute == "to_object") { @@ -202,3 +236,4 @@ bool GeomValidators_ZeroOffset::isNotObligatory(std::string theFeature, std::str return false; } +// LCOV_EXCL_STOP