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=34aec623f19c73f82b40afca3c36832132c64af2;hpb=87474d56199326bace66da349e9dc2c44e02d3a7;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index 34aec623f..8375e1ad5 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -1,8 +1,21 @@ -// 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 @@ -17,6 +30,7 @@ #include #include #include +#include #include #include @@ -25,36 +39,41 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& const std::list& theArguments, 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 = + 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::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++) { @@ -70,7 +89,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(!aContextShape.get()) { break; } - ResultConstructionPtr aConstruction = + ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aContext); if(!aConstruction.get()) { break; @@ -117,6 +136,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { aToShape = anAttrSel->context()->shape(); } + if (aToShape->isCompound()) { + GeomAPI_ShapeIterator aSIt(aToShape); + aToShape = aSIt.current(); + } } anIt++; @@ -132,6 +155,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { aFromShape = anAttrSel->context()->shape(); } + if (aFromShape->isCompound()) { + GeomAPI_ShapeIterator aSIt(aFromShape); + aFromShape = aSIt.current(); + } } anIt++; @@ -178,7 +205,7 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& } std::shared_ptr aPln = aFace->getPlane(); if(aPln.get()) { - for(ListOfShape::const_iterator + for(ListOfShape::const_iterator anIter = aFacesList.cbegin(); anIter != aFacesList.cend(); anIter++) { std::shared_ptr aSketchShape = *anIter; std::shared_ptr aSketchFace(new GeomAPI_Face(aSketchShape)); @@ -200,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") { @@ -208,3 +236,4 @@ bool GeomValidators_ZeroOffset::isNotObligatory(std::string theFeature, std::str return false; } +// LCOV_EXCL_STOP