Salome HOME
Import STEP with materials and colors
[modules/shaper.git] / src / Model / Model_Objects.cpp
index 2c32988e2188e13577ee28df27f657110fbb5c6c..c7ea99cb0ac95592af8f3b8863d9eb2db9417395 100644 (file)
@@ -1226,7 +1226,8 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData,
 
 void Model_Objects::storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
                                 std::shared_ptr<ModelAPI_Result> theResult,
-                                const int theResultIndex)
+                                const int theResultIndex,
+                                const std::wstring& theNameShape)
 {
   theResult->init();
   theResult->setDoc(myDoc);
@@ -1240,11 +1241,15 @@ void Model_Objects::storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
       theResult->data()->setName(L"");
     } else {
       std::wstringstream aName;
-      aName << aNewName;
-      // if there are several results (issue #899: any number of result),
-      // add unique prefix starting from second
-      if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group())
-        aName << "_" << theResultIndex + 1;
+      if ( theNameShape != L"" ){
+        aName << theNameShape;
+      } else {
+        aName << aNewName;
+        // if there are several results (issue #899: any number of result),
+        // add unique prefix starting from second
+        if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group())
+          aName << "_" << theResultIndex + 1;
+      }
       aNewName = aName.str();
     }
     theResult->data()->setName(aNewName);
@@ -1269,7 +1274,9 @@ std::shared_ptr<ModelAPI_ResultConstruction> Model_Objects::createConstruction(
 }
 
 std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
-    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData,
+    const int theIndex,
+    const std::wstring& theNameShape)
 {
   TDF_Label aLab = resultLabel(theFeatureData, theIndex);
   TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
@@ -1280,7 +1287,7 @@ std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
   }
   if (!aResult.get()) {
     aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
-    storeResult(theFeatureData, aResult, theIndex);
+    storeResult(theFeatureData, aResult, theIndex, theNameShape);
   }
   return aResult;
 }