X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Selection.cpp;h=30f92c2223cdf4d2038aeee867879080eb1ae5eb;hb=86f8397a0cc86e83d5f963aaadffb3d765fc836a;hp=c87b99fe9a078dd0e9c81a09ef52869521e35872;hpb=5a82acff74697623112b76b67c0200945a3e9976;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index c87b99fe9..30f92c222 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// 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 @@ -12,10 +12,9 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "ModelHighAPI_Selection.h" @@ -27,6 +26,8 @@ #include #include + +#include //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- @@ -49,6 +50,35 @@ ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType, { } +ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType, + const GeomPointPtr& theSubShapeInnerPoint) +: myVariantType(VT_TypeInnerPointPair) +, myTypeInnerPointPair(theType, theSubShapeInnerPoint) +{ +} + +ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType, + const std::list& theSubShapeInnerPoint) +: myVariantType(VT_TypeInnerPointPair) +{ + double aCoordinates[3] = { 0.0, 0.0, 0.0 }; + double* aCIt = aCoordinates; + std::list::const_iterator aPIt = theSubShapeInnerPoint.begin(); + for (; aPIt != theSubShapeInnerPoint.end(); ++aPIt, ++aCIt) + *aCIt = *aPIt; + + GeomPointPtr anInnerPoint(new GeomAPI_Pnt(aCoordinates[0], aCoordinates[1], aCoordinates[2])); + myTypeInnerPointPair = std::pair(theType, anInnerPoint); +} + +ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType, + const std::string& theContextName, const int theIndex) + : myVariantType(VT_WeakNamingPair) + , myWeakNamingPair(theType, std::pair(theContextName, theIndex)) +{ +} + + ModelHighAPI_Selection::~ModelHighAPI_Selection() { } @@ -64,12 +94,20 @@ void ModelHighAPI_Selection::fillAttribute( return; case VT_TypeSubShapeNamePair: theAttribute->selectSubShape(myTypeSubShapeNamePair.first, myTypeSubShapeNamePair.second); - if(theAttribute->isInvalid()) { - FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); - aFeature->setError( - std::string("Error: attribute \"") + theAttribute->id() + std::string("\" is invalid.")); - } + break; + case VT_TypeInnerPointPair: + theAttribute->selectSubShape(myTypeInnerPointPair.first, myTypeInnerPointPair.second); return; + case VT_WeakNamingPair: + theAttribute->selectSubShape( + myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); + break; + } + + if (theAttribute->isInvalid()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); + aFeature->setError( + std::string("Error: attribute \"") + theAttribute->id() + std::string("\" is invalid.")); } } @@ -86,6 +124,18 @@ void ModelHighAPI_Selection::appendToList( // Note: the reverse order (first - type, second - sub-shape name) theAttribute->append(myTypeSubShapeNamePair.second, myTypeSubShapeNamePair.first); return; + case VT_TypeInnerPointPair: + // Note: the reverse order (first - type, second - selected point) + theAttribute->append(myTypeInnerPointPair.second, myTypeInnerPointPair.first); + return; + case VT_WeakNamingPair: + // Note: the reverse order (first - type, second - selected point) + theAttribute->append( + myWeakNamingPair.first, myWeakNamingPair.second.first, myWeakNamingPair.second.second); + return; + case VT_Filtering: + theAttribute->setFilters(myFilterFeature); + return; } } @@ -107,6 +157,18 @@ TypeSubShapeNamePair ModelHighAPI_Selection::typeSubShapeNamePair() const return myTypeSubShapeNamePair; } +//================================================================================================== +TypeInnerPointPair ModelHighAPI_Selection::typeInnerPointPair() const +{ + return myTypeInnerPointPair; +} + +//================================================================================================== +TypeWeakNamingPair ModelHighAPI_Selection::typeWeakNamingPair() const +{ + return myWeakNamingPair; +} + //================================================================================================== std::string ModelHighAPI_Selection::shapeType() const { @@ -115,6 +177,7 @@ std::string ModelHighAPI_Selection::shapeType() const return myResultSubShapePair.second.get() ? myResultSubShapePair.second->shapeTypeStr() : myResultSubShapePair.first->shape()->shapeTypeStr(); case VT_TypeSubShapeNamePair: return myTypeSubShapeNamePair.first; + case VT_TypeInnerPointPair: return myTypeInnerPointPair.first; } return "SHAPE"; @@ -166,6 +229,7 @@ void ModelHighAPI_Selection::setDeflection(double theValue) aDeflectionAttr->setValue(theValue); } +// LCOV_EXCL_START void ModelHighAPI_Selection::setTransparency(double theValue) { if (myVariantType != VT_ResultSubShapePair) @@ -176,6 +240,7 @@ void ModelHighAPI_Selection::setTransparency(double theValue) aTransparencyAttr->setValue(theValue); } +// LCOV_EXCL_STOP int ModelHighAPI_Selection::numberOfSubs() const {