+
+//********************************************************************
+void ModuleBase_WidgetValidated::filterCompSolids(QList<ModuleBase_ViewerPrsPtr>& theValues)
+{
+ std::set<ResultCompSolidPtr> aCompSolids;
+ QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
+
+ // Collect compsolids.
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ for (; anIt != aLast; anIt++) {
+ const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
+ ObjectPtr anObject = aViewerPrs->object();
+ ResultCompSolidPtr aResultCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
+ if(aResultCompSolid.get()) {
+ aCompSolids.insert(aResultCompSolid);
+ }
+ }
+
+ // Filter sub-solids of compsolids.
+ anIt = theValues.begin();
+ for (; anIt != aLast; anIt++) {
+ const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
+ ObjectPtr anObject = aViewerPrs->object();
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aResult);
+ if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) {
+ // Skip sub-solid of compsolid.
+ continue;
+ } else {
+ aValidatedValues.append(*anIt);
+ }
+ }
+
+ if (aValidatedValues.size() != theValues.size()) {
+ theValues.clear();
+ theValues = aValidatedValues;
+ }
+}