1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_Tools.cpp
4 // Created: 06 Aug 2014
5 // Author: Vitaly Smetannikov
7 #include "ModelAPI_Tools.h"
8 #include <ModelAPI_Session.h>
9 #include <ModelAPI_Document.h>
10 #include <ModelAPI_Object.h>
11 #include <ModelAPI_AttributeDouble.h>
12 #include <ModelAPI_ResultParameter.h>
13 #include <ModelAPI_ResultPart.h>
14 #include <ModelAPI_AttributeDocRef.h>
19 #include <Events_Loop.h>
20 #include <ModelAPI_Events.h>
22 #define RECURSE_TOP_LEVEL 50
24 //#define DEBUG_REMOVE_FEATURES
25 //#define DEBUG_REMOVE_FEATURES_RECURSE
26 //#define DEBUG_CYCLING_1550
28 #ifdef DEBUG_REMOVE_FEATURES_RECURSE
30 std::string getFeatureInfo(FeaturePtr theFeature)
32 if (!theFeature.get())
34 //std::ostringstream aPtrStr;
35 //aPtrStr << "[" << theFeature.get() << "] ";
36 std::string aFeatureInfo = /*aPtrStr.str() + */theFeature->name();
37 CompositeFeaturePtr aComposite = ModelAPI_Tools::compositeOwner(theFeature);
38 if (aComposite.get()) {
39 aFeatureInfo = aFeatureInfo + "[in " + aComposite->name() + "]";
45 #ifdef DEBUG_REMOVE_FEATURES
46 void printMapInfo(const std::map<FeaturePtr, std::set<FeaturePtr> >& theMainList,
47 const std::string& thePrefix)
49 std::map<FeaturePtr, std::set<FeaturePtr> >::const_iterator aMainIt = theMainList.begin(),
50 aMainLast = theMainList.end();
52 for (; aMainIt != aMainLast; aMainIt++) {
53 FeaturePtr aMainListFeature = aMainIt->first;
54 std::set<FeaturePtr> aMainRefList = aMainIt->second;
55 std::set<FeaturePtr>::const_iterator anIt = aMainRefList.begin(), aLast = aMainRefList.end();
56 std::string aRefsInfo;
57 for (; anIt != aLast; anIt++) {
58 aRefsInfo += (*anIt)->name().c_str();
62 if (!aRefsInfo.empty()) {
63 anInfo = anInfo + aMainListFeature->name().c_str() + ": " + aRefsInfo + "\n";
66 std::cout << thePrefix.c_str() << " [feature: references to]: \n" << anInfo.c_str() << std::endl;
69 void printListInfo(const std::set<FeaturePtr>& theMainList,
70 const std::string& thePrefix)
72 std::set<FeaturePtr>::const_iterator aMainIt = theMainList.begin(),
73 aMainLast = theMainList.end();
75 for (; aMainIt != aMainLast; aMainIt++) {
76 FeaturePtr aRefFeature = *aMainIt;
77 anInfo += aRefFeature->name().c_str();
78 if (aMainIt != aMainLast)
81 std::cout << thePrefix.c_str() << ": " << anInfo.c_str() << std::endl;
85 namespace ModelAPI_Tools {
87 std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult)
89 return theResult->shape();
92 void shapesOfType(const FeaturePtr& theFeature,
93 const GeomAPI_Shape::ShapeType& theType,
94 std::set<GeomShapePtr>& theShapes)
96 std::list<ResultPtr> aResults = theFeature->results();
97 std::list<ResultPtr>::const_iterator aRIter = aResults.cbegin();
98 for (; aRIter != aResults.cend(); aRIter++) {
99 ResultPtr aResult = *aRIter;
100 GeomShapePtr aShape = aResult->shape();
101 if (aShape.get() && aShape->shapeType() == theType)
102 theShapes.insert(aShape);
106 const char* toString(ModelAPI_ExecState theExecState)
108 #define TO_STRING(__NAME__) case __NAME__: return #__NAME__;
109 switch (theExecState) {
110 TO_STRING(ModelAPI_StateDone)
111 TO_STRING(ModelAPI_StateMustBeUpdated)
112 TO_STRING(ModelAPI_StateExecFailed)
113 TO_STRING(ModelAPI_StateInvalidArgument)
114 TO_STRING(ModelAPI_StateNothing)
115 default: return "Unknown ExecState.";
120 std::string getFeatureError(const FeaturePtr& theFeature)
123 if (!theFeature.get() || !theFeature->data()->isValid() || theFeature->isAction())
126 // to be removed later, this error should be got from the feature
127 if (theFeature->data()->execState() == ModelAPI_StateDone ||
128 theFeature->data()->execState() == ModelAPI_StateMustBeUpdated)
131 // set error indication
132 anError = theFeature->error();
133 if (anError.empty()) {
134 bool isDone = ( theFeature->data()->execState() == ModelAPI_StateDone
135 || theFeature->data()->execState() == ModelAPI_StateMustBeUpdated );
137 anError = toString(theFeature->data()->execState());
138 // If the feature is Composite and error is StateInvalidArgument,
139 // error text should include error of first invalid sub-feature. Otherwise
140 // it is not clear what is the reason of the invalid argument.
141 if (theFeature->data()->execState() == ModelAPI_StateInvalidArgument) {
142 CompositeFeaturePtr aComposite =
143 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
145 for (int i = 0, aSize = aComposite->numberOfSubs(); i < aSize; i++) {
146 FeaturePtr aSubFeature = aComposite->subFeature(i);
147 std::string aSubFeatureError = getFeatureError(aSubFeature);
148 if (!aSubFeatureError.empty()) {
149 anError = anError + " in " + aSubFeature->getKind() + ".\n" + aSubFeatureError;
161 ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup, const std::string& theName)
163 for (int anIndex = 0; anIndex < theDocument->size(theGroup); ++anIndex) {
164 ObjectPtr anObject = theDocument->object(theGroup, anIndex);
165 if (anObject->data()->name() == theName)
172 bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
173 const std::string& theName, double& outValue, ResultParameterPtr& theParam)
175 ObjectPtr aParamObj = objectByName(theDocument, ModelAPI_ResultParameter::group(), theName);
176 theParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aParamObj);
179 // avoid usage of parameters created later than the initial parameter
180 if (theSearcher.get() && theDocument->isLater(theDocument->feature(theParam), theSearcher))
182 AttributeDoublePtr aValueAttribute = theParam->data()->real(ModelAPI_ResultParameter::VALUE());
183 outValue = aValueAttribute->value();
187 bool findVariable(FeaturePtr theSearcher, const std::string& theName, double& outValue, ResultParameterPtr& theParam,
188 const DocumentPtr& theDocument)
190 SessionPtr aSession = ModelAPI_Session::get();
191 std::list<DocumentPtr> aDocList;
192 DocumentPtr aDocument = theDocument.get() ? theDocument : aSession->activeDocument();
193 if (findVariable(aDocument, theSearcher, theName, outValue, theParam))
195 DocumentPtr aRootDocument = aSession->moduleDocument();
196 if (aDocument != aRootDocument) {
197 // any parameters in PartSet is okindependently on the Part position (issu #1504)
198 if (findVariable(aRootDocument, FeaturePtr(), theName, outValue, theParam))
204 static std::map<int, std::vector<int> > myColorMap;
206 void appendValues(std::vector<int>& theRGB, const int theRed, const int theGreen, const int theBlue)
208 theRGB.push_back(theRed);
209 theRGB.push_back(theGreen);
210 theRGB.push_back(theBlue);
213 bool containsValues(std::map<int, std::vector<int> >& theColorMap, std::vector<int>& theValues)
215 std::map<int, std::vector<int> >::const_iterator anIt = theColorMap.begin(), aLast = theColorMap.end();
216 bool isFound = false;
217 for (; anIt != aLast && !isFound; anIt++) {
218 std::vector<int> aValues = anIt->second;
219 isFound = aValues[0] == theValues[0] &&
220 aValues[1] == theValues[1] &&
221 aValues[2] == theValues[2];
226 std::vector<int> HSVtoRGB(int theH, int theS, int theV)
228 std::vector<int> aRGB;
229 if (theH < 0 || theH > 360 ||
230 theS < 0 || theS > 100 ||
231 theV < 0 || theV > 100)
234 int aHi = (int)theH/60;
237 double aVmin = (100 - theS)*theV/100;
239 double anA = (theV - aVmin)* (theH % 60) / 60;
241 double aVinc = aVmin + anA;
242 double aVdec = theV - anA;
244 double aPercentToValue = 255./100;
245 int aV_int = (int)(aV*aPercentToValue);
246 int aVinc_int = (int)(aVinc*aPercentToValue);
247 int aVmin_int = (int)(aVmin*aPercentToValue);
248 int aVdec_int = (int)(aVdec*aPercentToValue);
251 case 0: appendValues(aRGB, aV_int, aVinc_int, aVmin_int); break;
252 case 1: appendValues(aRGB, aVdec_int, aV_int, aVmin_int); break;
253 case 2: appendValues(aRGB, aVmin_int, aV_int, aVinc_int); break;
254 case 3: appendValues(aRGB, aVmin_int, aVdec_int, aV_int); break;
255 case 4: appendValues(aRGB, aVinc_int, aVmin_int, aV_int); break;
256 case 5: appendValues(aRGB, aV_int, aVmin_int, aVdec_int); break;
265 if (!myColorMap.empty())
269 for (int s = 100; s > 0; s = s - 50)
271 for (int v = 100; v >= 40; v = v - 20)
273 for (int h = 0; h < 359 ; h = h + 60)
275 std::vector<int> aColor = HSVtoRGB(h, s, v);
276 if (containsValues(myColorMap, aColor))
278 myColorMap[i] = aColor;
285 void findRandomColor(std::vector<int>& theValues)
288 if (myColorMap.empty()) {
292 size_t aSize = myColorMap.size();
293 int anIndex = rand() % aSize;
294 if (myColorMap.find(anIndex) != myColorMap.end()) {
295 theValues = myColorMap.at(anIndex);
299 ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub)
301 if (theMain != theSub) { // to optimize and avoid of crash on partset document close (don't touch the sub-document structure)
302 for (int a = theMain->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) {
303 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(
304 theMain->object(ModelAPI_ResultPart::group(), a));
305 if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == theSub) {
313 FeaturePtr findPartFeature(const DocumentPtr& theMain, const DocumentPtr& theSub)
315 if (theMain != theSub) { // to optimize and avoid of crash on partset document close (don't touch the sub-document structure)
316 for (int a = theMain->size(ModelAPI_Feature::group()) - 1; a >= 0; a--) {
317 FeaturePtr aPartFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(
318 theMain->object(ModelAPI_Feature::group(), a));
319 if (aPartFeat.get()) {
320 const std::list<std::shared_ptr<ModelAPI_Result> >& aResList = aPartFeat->results();
321 std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResList.begin();
322 for(; aRes != aResList.end(); aRes++) {
323 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aRes);
325 if (aPart->isActivated() && aPart->partDoc() == theSub)
327 } else break; // if the first is not Part, others are also not
335 CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature)
337 if (theFeature.get() && theFeature->data()->isValid()) {
338 const std::set<std::shared_ptr<ModelAPI_Attribute> >& aRefs = theFeature->data()->refsToMe();
339 std::set<std::shared_ptr<ModelAPI_Attribute> >::const_iterator aRefIter = aRefs.begin();
340 for(; aRefIter != aRefs.end(); aRefIter++) {
341 CompositeFeaturePtr aComp = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
342 ((*aRefIter)->owner());
343 if (aComp.get() && aComp->data()->isValid() && aComp->isSub(theFeature))
347 return CompositeFeaturePtr(); // not found
350 ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
352 ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
354 FeaturePtr aFeatureOwner = aBody->document()->feature(aBody);
355 if (aFeatureOwner.get()) {
356 std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
357 aFeatureOwner->results().cbegin();
358 for(; aResIter != aFeatureOwner->results().cend(); aResIter++) {
359 ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIter);
360 if (aComp && aComp->isSub(aBody))
365 return ResultCompSolidPtr(); // not found
368 bool hasSubResults(const ResultPtr& theResult)
370 ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theResult);
371 return aCompSolid.get() && aCompSolid->numberOfSubs() > 0;
374 void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults)
376 if (!theFeature.get()) // safety: for empty feature no results
378 const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
379 std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
380 for (; aRIter != aResults.cend(); aRIter++) {
381 theResults.push_back(*aRIter);
382 // iterate sub-bodies of compsolid
383 ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
385 int aNumSub = aComp->numberOfSubs();
386 for(int a = 0; a < aNumSub; a++) {
387 theResults.push_back(aComp->subResult(a));
393 //******************************************************************
394 bool allDocumentsActivated(std::string& theNotActivatedNames)
396 theNotActivatedNames = "";
397 bool anAllPartActivated = true;
399 DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
400 int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
401 for (int i = 0; i < aSize; i++) {
402 ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), i);
403 ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
404 if (!aPart->isActivated()) {
405 anAllPartActivated = false;
406 if (!theNotActivatedNames.empty())
407 theNotActivatedNames += ", ";
408 theNotActivatedNames += aObject->data()->name().c_str();
411 return anAllPartActivated;
414 bool removeFeaturesAndReferences(const std::set<FeaturePtr>& theFeatures,
415 const bool theFlushRedisplay,
416 const bool theUseComposite,
417 const bool theUseRecursion)
419 #ifdef DEBUG_REMOVE_FEATURES
420 printListInfo(theFeatures, "selection: ");
423 std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
424 ModelAPI_Tools::findAllReferences(theFeatures, aReferences, theUseComposite, theUseRecursion);
425 #ifdef DEBUG_REMOVE_FEATURES
426 printMapInfo(aReferences, "allDependencies: ");
429 std::set<FeaturePtr> aFeaturesRefsTo;
430 ModelAPI_Tools::findRefsToFeatures(theFeatures, aReferences, aFeaturesRefsTo);
431 #ifdef DEBUG_REMOVE_FEATURES
432 printListInfo(aFeaturesRefsTo, "references: ");
435 std::set<FeaturePtr> aFeatures = theFeatures;
436 if (!aFeaturesRefsTo.empty())
437 aFeatures.insert(aFeaturesRefsTo.begin(), aFeaturesRefsTo.end());
438 #ifdef DEBUG_REMOVE_FEATURES
439 printListInfo(aFeatures, "removeFeatures: ");
442 return ModelAPI_Tools::removeFeatures(aFeatures, false);
445 bool removeFeatures(const std::set<FeaturePtr>& theFeatures,
446 const bool theFlushRedisplay)
449 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
450 aLast = theFeatures.end();
451 for (; anIt != aLast; anIt++) {
452 FeaturePtr aFeature = *anIt;
453 if (aFeature.get()) {
454 DocumentPtr aDoc = aFeature->document();
455 // flush REDISPLAY signal after remove feature
456 aDoc->removeFeature(aFeature);
460 if (isDone && theFlushRedisplay) {
461 // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
462 // if should be done after removeFeature() of document
463 Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
468 // Fills the references list by all references of the feature from the references map.
469 // This is a recusive method to find references by next found feature in the map of references.
470 // \param theFeature a feature to find references
471 // \param theReferencesMap a map of references
472 // \param theReferences an out container of references
473 void addRefsToFeature(const FeaturePtr& theFeature,
474 const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferencesMap,
475 std::map<FeaturePtr, std::set<FeaturePtr> >& theProcessedReferences,
477 std::set<FeaturePtr>& theReferences)
479 if (theRecLevel > RECURSE_TOP_LEVEL)
483 // if the feature is already processed, get the ready references from the map
484 if (theProcessedReferences.find(theFeature) != theProcessedReferences.end()) {
485 std::set<FeaturePtr> aReferences = theProcessedReferences.at(theFeature);
486 theReferences.insert(aReferences.begin(), aReferences.end());
490 if (theReferencesMap.find(theFeature) == theReferencesMap.end())
491 return; // this feature is not in the selection list, so exists without references to it
492 std::set<FeaturePtr> aMainReferences = theReferencesMap.at(theFeature);
494 std::set<FeaturePtr>::const_iterator anIt = aMainReferences.begin(),
495 aLast = aMainReferences.end();
496 #ifdef DEBUG_REMOVE_FEATURES_RECURSE
497 std::string aSpacing;
498 for (int i = 0; i < theRecLevel; i++)
499 aSpacing.append(" ");
502 for (; anIt != aLast; anIt++) {
503 FeaturePtr aRefFeature = *anIt;
504 #ifdef DEBUG_REMOVE_FEATURES_RECURSE
505 std::cout << aSpacing << " Ref: " << getFeatureInfo(aRefFeature) << std::endl;
507 if (theReferences.find(aRefFeature) == theReferences.end())
508 theReferences.insert(aRefFeature);
509 addRefsToFeature(aRefFeature, theReferencesMap, theProcessedReferences, theRecLevel, theReferences);
513 // For each feature from the feature list it searches references to the feature and append them
514 // to the references map. This is a recusive method.
515 // \param theFeature a feature to find references
516 // \param theReferencesMap a map of references
517 // \param theReferences an out container of references
518 void findReferences(const std::set<FeaturePtr>& theFeatures,
519 std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
520 const bool theUseComposite, const bool theUseRecursion, int theRecLevel)
522 if (theRecLevel > RECURSE_TOP_LEVEL)
525 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
526 aLast = theFeatures.end();
527 for (; anIt != aLast; anIt++) {
528 FeaturePtr aFeature = *anIt;
529 if (aFeature.get() && theReferences.find(aFeature) == theReferences.end()) {
530 DocumentPtr aSelFeatureDoc = aFeature->document();
531 std::set<FeaturePtr> aSelRefFeatures;
532 aSelFeatureDoc->refsToFeature(aFeature, aSelRefFeatures, false/*do not emit signals*/);
533 if (theUseComposite) { // do not filter selection
534 theReferences[aFeature] = aSelRefFeatures;
536 else { // filter references to skip composition features of the current feature
537 std::set<FeaturePtr> aFilteredFeatures;
538 std::set<FeaturePtr>::const_iterator anIt = aSelRefFeatures.begin(),
539 aLast = aSelRefFeatures.end();
540 for (; anIt != aLast; anIt++) {
541 FeaturePtr aCFeature = *anIt;
542 CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCFeature);
543 if (aComposite.get() && aComposite->isSub(aFeature))
544 continue; /// composite of the current feature should be skipped
545 aFilteredFeatures.insert(aCFeature);
547 theReferences[aFeature] = aFilteredFeatures;
549 if (theUseRecursion) {
550 #ifdef DEBUG_CYCLING_1550
551 findReferences(aSelRefFeatures, theReferences, theUseComposite, theUseRecursion, theRecLevel);
553 findReferences(theReferences[aFeature], theReferences, theUseComposite, theUseRecursion,
561 void findAllReferences(const std::set<FeaturePtr>& theFeatures,
562 std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
563 const bool theUseComposite,
564 const bool theUseRecursion)
566 // For dependencies, find main_list:
567 // sk_1(ext_1, vertex_1)
568 // ext_1(bool_1, sk_3)
573 // Information: bool_1 is not selected, ext_2(bool_2) exists
574 // find all referenced features
575 std::map<FeaturePtr, std::set<FeaturePtr> > aMainList;
577 findReferences(theFeatures, aMainList, theUseComposite, theUseRecursion, aRecLevel);
579 #ifdef DEBUG_REMOVE_FEATURES
580 printMapInfo(aMainList, "firstDependencies");
582 // find all dependencies for each object:
583 // sk_1(ext_1, vertex_1) + (sk_3, bool_1)
584 // ext_1(bool_1, sk_3)
586 // sk_2(ext_2) + (bool_1)
589 std::map<FeaturePtr, std::set<FeaturePtr> >::const_iterator aMainIt = aMainList.begin(),
590 aMainLast = aMainList.end();
591 for (; aMainIt != aMainLast; aMainIt++) {
592 FeaturePtr aMainListFeature = aMainIt->first;
594 //std::string aName = aMainListFeature->name();
595 std::set<FeaturePtr> aMainRefList = aMainIt->second;
597 #ifdef DEBUG_REMOVE_FEATURES_RECURSE
599 int n = sprintf(aBuf, "%d", aMainRefList.size());
600 std::string aSize(aBuf);
601 std::cout << "_findAllReferences for the Feature: " << getFeatureInfo(aMainListFeature)
602 << ", references size = " << aSize << std::endl;
604 std::set<FeaturePtr>::const_iterator anIt = aMainRefList.begin(),
605 aLast = aMainRefList.end();
606 std::set<FeaturePtr> aResultRefList;
607 aResultRefList.insert(aMainRefList.begin(), aMainRefList.end());
608 for (; anIt != aLast; anIt++) {
609 FeaturePtr aFeature = *anIt;
611 #ifdef DEBUG_REMOVE_FEATURES_RECURSE
612 std::cout << " Ref: " << getFeatureInfo(aFeature) << std::endl;
615 addRefsToFeature(aFeature, aMainList, theReferences, aRecLevel, aResultRefList/*aMainRefList*/);
617 theReferences[aMainListFeature] = aResultRefList;
619 #ifdef DEBUG_REMOVE_FEATURES_RECURSE
620 std::cout << std::endl;
623 #ifdef DEBUG_REMOVE_FEATURES
624 printMapInfo(theReferences, "allDependencies");
628 void findRefsToFeatures(const std::set<FeaturePtr>& theFeatures,
629 const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
630 std::set<FeaturePtr>& theFeaturesRefsTo)
632 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
633 aLast = theFeatures.end();
634 for (; anIt != aLast; anIt++) {
635 FeaturePtr aFeature = *anIt;
636 if (theReferences.find(aFeature) == theReferences.end())
638 std::set<FeaturePtr> aRefList = theReferences.at(aFeature);
639 std::set<FeaturePtr>::const_iterator aRefIt = aRefList.begin(), aRefLast = aRefList.end();
640 for (; aRefIt != aRefLast; aRefIt++) {
641 FeaturePtr aRefFeature = *aRefIt;
642 CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aRefFeature);
643 if (aComposite.get() && aComposite->isSub(aFeature))
644 continue; /// composite of the current feature should not be removed
646 if (theFeatures.find(aRefFeature) == theFeatures.end() && // it is not selected
647 theFeaturesRefsTo.find(aRefFeature) == theFeaturesRefsTo.end()) // it is not added
648 theFeaturesRefsTo.insert(aRefFeature);
653 } // namespace ModelAPI_Tools