-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: Model_AttributeSelectionList.cpp
-// Created: 22 Oct 2014
-// Author: Mikhail PONIKAROV
+// 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<mailto:webmaster.salome@opencascade.com>
+//
#include "Model_AttributeSelectionList.h"
#include "Model_AttributeSelection.h"
#include <NCollection_List.hxx>
void Model_AttributeSelectionList::append(
- const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+ const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily)
{
// do not use the degenerated edge as a shape, a list is not incremented in this case
}
if (myIsCashed && !theTemporarily) {
- myCash[theContext].push_back(theSubShape);
+ ResultPtr aResContext = std::dynamic_pointer_cast<ModelAPI_Result>(theContext);
+ if (aResContext.get())
+ myCash[aResContext].push_back(theSubShape);
}
int aNewTag = mySize->Get() + 1;
return mySize->Get();
}
-bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext,
+bool Model_AttributeSelectionList::isInList(const ObjectPtr& theContext,
const std::shared_ptr<GeomAPI_Shape>& theSubShape,
const bool theTemporarily)
{
+ ResultPtr aResCont = std::dynamic_pointer_cast<ModelAPI_Result>(theContext);
if (myIsCashed) { // the cashing is active
- std::map<ResultPtr, std::list<std::shared_ptr<GeomAPI_Shape> > >::iterator aContext =
- myCash.find(theContext);
- if (aContext != myCash.end()) {
- // iterate shapes because "isSame" method must be called for each shape
- std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
- for(; aShapes != aContext->second.end(); aShapes++) {
- if (!theSubShape.get()) {
- if (!aShapes->get())
- return true;
- } else {
- // we need to call here isSame instead of isEqual to do not check shapes orientation
- if (theSubShape->isSame(*aShapes))
- return true;
+ if (aResCont.get()) {
+ std::map<ResultPtr, std::list<std::shared_ptr<GeomAPI_Shape> > >::iterator aContext =
+ myCash.find(aResCont);
+ if (aContext != myCash.end()) {
+ // iterate shapes because "isSame" method must be called for each shape
+ std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
+ for(; aShapes != aContext->second.end(); aShapes++) {
+ if (!theSubShape.get()) {
+ if (!aShapes->get() || (*aShapes)->isSame(aContext->first->shape()))
+ return true;
+ } else {
+ // we need to call here isSame instead of isEqual to do not check shapes orientation
+ if (theSubShape->isSame(*aShapes))
+ return true;
+ }
}
}
+ return false;
}
- return false;
}
// no-cash method
for(int anIndex = size() - 1; anIndex >= 0; anIndex--) {
if (anAttr.get()) {
if (anAttr->context() == theContext) { // contexts are equal, so, check that values are also
std::shared_ptr<GeomAPI_Shape> aValue = anAttr->value();
- if (!aValue.get()) {
- if (!theSubShape.get()) { // both are null
+ if (!theSubShape.get()) {
+ if (!aValue.get() || (aResCont.get() && aValue->isSame(aResCont->shape()))) {// both null
return true;
}
} else {
// we need to call here isSame instead of isEqual to do not check shapes orientation
- if (aValue->isSame(theSubShape)) // shapes are equal
+ if (theSubShape->isSame(aValue)) // shapes are equal
return true;
}
}