X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Interface.cpp;h=8e35b13be1b88f0fec6a144d58b11d7bcdf38f82;hb=d2034a988bc73596aab1bb256ddb02ce9ad2bd5a;hp=401ba5467ed6f5a64f615c07ecb271b77b7dfd7e;hpb=540e8b84d9123ec7b3f0603b38df6ed8f8e86516;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.cpp b/src/ModelHighAPI/ModelHighAPI_Interface.cpp index 401ba5467..8e35b13be 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Interface.cpp @@ -1,10 +1,23 @@ -// Name : ModelHighAPI_Interface.cpp -// Purpose: +// Copyright (C) 2014-2017 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 // -// History: -// 17/05/16 - Sergey POKHODENKO - Creation of the file -//-------------------------------------------------------------------------------------- #include "ModelHighAPI_Interface.h" //-------------------------------------------------------------------------------------- #include @@ -14,10 +27,12 @@ #include #include #include +#include #include "ModelHighAPI_Selection.h" //-------------------------------------------------------------------------------------- -ModelHighAPI_Interface::ModelHighAPI_Interface(const std::shared_ptr & theFeature) +ModelHighAPI_Interface::ModelHighAPI_Interface( + const std::shared_ptr & theFeature) : myFeature(theFeature) { @@ -36,7 +51,8 @@ std::shared_ptr ModelHighAPI_Interface::feature() const std::shared_ptr ModelHighAPI_Interface::subFeature(const int theIndex) const { - CompositeFeaturePtr aCompositeFeature = std::dynamic_pointer_cast(myFeature); + CompositeFeaturePtr aCompositeFeature = + std::dynamic_pointer_cast(myFeature); if(!aCompositeFeature.get()) { return InterfacePtr(); } @@ -54,14 +70,15 @@ const std::string& ModelHighAPI_Interface::getKind() const return feature()->getKind(); } -void ModelHighAPI_Interface::execute() +void ModelHighAPI_Interface::execute(bool isForce) { - //SessionPtr aMgr = ModelAPI_Session::get(); - //ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - //FeaturePtr aFeature = feature(); - //if(aFactory->validate(aFeature)) { - // aFeature->execute(); - //} + if (isForce) { + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + FeaturePtr aFeature = feature(); + if(aFactory->validate(aFeature)) + aFeature->execute(); + } Events_Loop* aLoop = Events_Loop::loop(); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); @@ -75,16 +92,29 @@ void ModelHighAPI_Interface::setName(const std::string& theName) feature()->data()->setName(theName); } -std::list ModelHighAPI_Interface::result() const +std::string ModelHighAPI_Interface::name() const +{ + return feature()->data()->name(); +} + +ModelHighAPI_Selection ModelHighAPI_Interface::result() const +{ + std::list aResults = results(); + if (aResults.empty()) + return ModelHighAPI_Selection(std::shared_ptr()); + return aResults.front(); +} + +std::list ModelHighAPI_Interface::results() const { - // TODO(spo): should I use more common function for the whole model to prepare results? const_cast(this)->execute(); std::list aSelectionList; std::list > aResults = feature()->results(); for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) { - aSelectionList.push_back(ModelHighAPI_Selection(*it)); + if (!(*it)->isDisabled()) + aSelectionList.push_back(ModelHighAPI_Selection(*it)); } return aSelectionList;