X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Selection.cpp;h=025314d220d892737052dd43adbf215d56485e35;hb=9d8267a424a809d0f96593b13f8472666553ce2e;hp=ca9422c18b1152224f2f8306c803dd29f06c62a8;hpb=dc75c390f0aa6108d6983a8618dc4b9a4cd5949e;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index ca9422c18..025314d22 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -25,7 +25,10 @@ #include #include #include -#include +#include + + +#include //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- @@ -48,6 +51,21 @@ 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::string& theContextName, const int theIndex) + : myVariantType(VT_WeakNamingPair) + , myWeakNamingPair(theType, std::pair(theContextName, theIndex)) +{ +} + + ModelHighAPI_Selection::~ModelHighAPI_Selection() { } @@ -63,12 +81,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.")); } } @@ -85,6 +111,15 @@ 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; } } @@ -106,6 +141,12 @@ TypeSubShapeNamePair ModelHighAPI_Selection::typeSubShapeNamePair() const return myTypeSubShapeNamePair; } +//================================================================================================== +TypeInnerPointPair ModelHighAPI_Selection::typeInnerPointPair() const +{ + return myTypeInnerPointPair; +} + //================================================================================================== std::string ModelHighAPI_Selection::shapeType() const { @@ -114,6 +155,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"; @@ -181,12 +223,11 @@ int ModelHighAPI_Selection::numberOfSubs() const if (myVariantType != VT_ResultSubShapePair) return 0; - ResultCompSolidPtr aCompSolid = - std::dynamic_pointer_cast(myResultSubShapePair.first); - if (!aCompSolid) + ResultBodyPtr aBody = std::dynamic_pointer_cast(myResultSubShapePair.first); + if (!aBody.get()) return 0; - return aCompSolid->numberOfSubs(); + return aBody->numberOfSubs(); } ModelHighAPI_Selection ModelHighAPI_Selection::subResult(int theIndex) const @@ -194,13 +235,12 @@ ModelHighAPI_Selection ModelHighAPI_Selection::subResult(int theIndex) const if (myVariantType != VT_ResultSubShapePair) return ModelHighAPI_Selection(); - ResultCompSolidPtr aCompSolid = - std::dynamic_pointer_cast(myResultSubShapePair.first); - if (!aCompSolid) + ResultBodyPtr aBody = std::dynamic_pointer_cast(myResultSubShapePair.first); + if (!aBody) return ModelHighAPI_Selection(); - if (theIndex >= aCompSolid->numberOfSubs()) + if (theIndex >= aBody->numberOfSubs()) return ModelHighAPI_Selection(); - ResultBodyPtr aResult = aCompSolid->subResult(theIndex); + ResultBodyPtr aResult = aBody->subResult(theIndex); return ModelHighAPI_Selection(aResult, aResult->shape()); }