]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/FeaturesPlugin_Tools.cpp
Salome HOME
import image: add texture to transformations
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Tools.cpp
index 44068e38394423c0a93d4a1e7e1f83fd2a6e05d4..29654258c11327eebcfccb74c40bcb8164674246 100644 (file)
@@ -259,13 +259,35 @@ bool FeaturesPlugin_Tools::getShape(const AttributeSelectionListPtr theSelection
 }
 
 //==================================================================================================
-bool FeaturesPlugin_Tools::shapesFromSelectionList(
-    const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
+bool FeaturesPlugin_Tools::shapesFromSelectionList(const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
     const bool theStoreFullHierarchy,
     GeomAPI_ShapeHierarchy& theHierarchy,
-    std::list<ResultPtr>& theParts)
+    std::list<ResultPtr>& theParts, std::string &theTextureFile)
 {
   int aSize = theSelectionList->size();
+  if(aSize == 1)
+  {
+    auto anObjectAttr = theSelectionList->value(0);
+    if(anObjectAttr.get())
+    {
+      FeaturePtr aFeature = anObjectAttr->contextFeature();      
+      if(aFeature.get() &&  aFeature->results().size() == 1)
+      {
+        theTextureFile = aFeature->firstResult()->getTextureFile();
+      }
+      else
+      {
+        if(!aFeature.get())
+        {
+          auto aResult =  anObjectAttr->context();
+          if(aResult.get())
+          {
+            theTextureFile = aResult->getTextureFile();
+          }
+        }
+      }
+    }
+  }
   for (int anObjectsIndex = 0; anObjectsIndex < aSize; anObjectsIndex++) {
     AttributeSelectionPtr anObjectAttr = theSelectionList->value(anObjectsIndex);
     std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();