]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.1. Management of result names
authorazv <azv@opencascade.com>
Fri, 3 Nov 2017 10:25:51 +0000 (13:25 +0300)
committerazv <azv@opencascade.com>
Tue, 14 Nov 2017 12:26:07 +0000 (15:26 +0300)
Support user names along the shape modifications.

22 files changed:
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/Test/TestCustomName_BooleanCut.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_CommonCompSolid.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_CutCompSolid.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_CutGroup.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_ExtrudeFace.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_ExtrusionCut.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_MultiTranslation.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_Partition.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_Placement.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_Recover.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_Rename.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_RotateGroup.py [new file with mode: 0644]
src/ModelAPI/Test/TestCustomName_Translation.py [new file with mode: 0644]
src/ModelHighAPI/ModelHighAPI_Interface.cpp
src/ModelHighAPI/ModelHighAPI_Interface.h
src/ModelHighAPI/ModelHighAPI_Selection.cpp
src/ModelHighAPI/ModelHighAPI_Selection.h

index e9e55e9905ff79c78afcb7c82672b6f3e0cbef3f..32c9215547d930969ebc91b4fee79421063e8cdc 100644 (file)
@@ -144,7 +144,8 @@ void Model_Data::setName(const std::string& theName)
 AttributePtr Model_Data::addAttribute(const std::string& theID, const std::string theAttrType)
 {
   AttributePtr aResult;
-  TDF_Label anAttrLab = myLab.FindChild(int(myAttrs.size()) + 1);
+  int anAttrIndex = int(myAttrs.size()) + 1;
+  TDF_Label anAttrLab = myLab.FindChild(anAttrIndex);
   ModelAPI_Attribute* anAttr = 0;
   if (theAttrType == ModelAPI_AttributeDocRef::typeId()) {
     anAttr = new Model_AttributeDocRef(anAttrLab);
@@ -203,7 +204,7 @@ AttributePtr Model_Data::addAttribute(const std::string& theID, const std::strin
   }
   if (anAttr) {
     aResult = std::shared_ptr<ModelAPI_Attribute>(anAttr);
-    myAttrs[theID] = aResult;
+    myAttrs[theID] = std::pair<AttributePtr, int>(aResult, anAttrIndex);
     anAttr->setObject(myObject);
     anAttr->setID(theID);
   } else {
@@ -217,10 +218,9 @@ AttributePtr Model_Data::addAttribute(const std::string& theID, const std::strin
 #define GET_ATTRIBUTE_BY_ID(ATTR_TYPE, METHOD_NAME) \
   std::shared_ptr<ATTR_TYPE> Model_Data::METHOD_NAME(const std::string& theID) { \
     std::shared_ptr<ATTR_TYPE> aRes; \
-    std::map<std::string, AttributePtr >::iterator aFound = \
-      myAttrs.find(theID); \
+    AttributeMap::iterator aFound = myAttrs.find(theID); \
     if (aFound != myAttrs.end()) { \
-      aRes = std::dynamic_pointer_cast<ATTR_TYPE>(aFound->second); \
+      aRes = std::dynamic_pointer_cast<ATTR_TYPE>(aFound->second.first); \
     } \
     return aRes; \
   }
@@ -246,15 +246,14 @@ std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& the
   std::shared_ptr<ModelAPI_Attribute> aResult;
   if (myAttrs.find(theID) == myAttrs.end())  // no such attribute
     return aResult;
-  return myAttrs[theID];
+  return myAttrs[theID].first;
 }
 
 const std::string& Model_Data::id(const std::shared_ptr<ModelAPI_Attribute>& theAttr)
 {
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr =
-    myAttrs.begin();
+  AttributeMap::iterator anAttr = myAttrs.begin();
   for (; anAttr != myAttrs.end(); anAttr++) {
-    if (anAttr->second == theAttr)
+    if (anAttr->second.first == theAttr)
       return anAttr->first;
   }
   // not found
@@ -278,11 +277,11 @@ bool Model_Data::isValid()
 std::list<std::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const std::string& theType)
 {
   std::list<std::shared_ptr<ModelAPI_Attribute> > aResult;
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter =
-    myAttrs.begin();
+  AttributeMap::iterator anAttrsIter = myAttrs.begin();
   for (; anAttrsIter != myAttrs.end(); anAttrsIter++) {
-    if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
-      aResult.push_back(anAttrsIter->second);
+    AttributePtr anAttr = anAttrsIter->second.first;
+    if (theType.empty() || anAttr->attributeType() == theType) {
+      aResult.push_back(anAttr);
     }
   }
   return aResult;
@@ -291,10 +290,10 @@ std::list<std::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const std
 std::list<std::string> Model_Data::attributesIDs(const std::string& theType)
 {
   std::list<std::string> aResult;
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter =
-    myAttrs.begin();
+  AttributeMap::iterator anAttrsIter = myAttrs.begin();
   for (; anAttrsIter != myAttrs.end(); anAttrsIter++) {
-    if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
+    AttributePtr anAttr = anAttrsIter->second.first;
+    if (theType.empty() || anAttr->attributeType() == theType) {
       aResult.push_back(anAttrsIter->first);
     }
   }
@@ -380,7 +379,7 @@ void Model_Data::erase()
           if (aReferenced->get() && (*aReferenced)->data()->isValid()) {
             std::shared_ptr<Model_Data> aData =
               std::dynamic_pointer_cast<Model_Data>((*aReferenced)->data());
-            aData->removeBackReference(myAttrs[anAttrIter->first]);
+            aData->removeBackReference(myAttrs[anAttrIter->first].first);
           }
         }
       }
@@ -585,21 +584,22 @@ void Model_Data::referencesToObjects(
     static_cast<Model_ValidatorsFactory*>(ModelAPI_Session::get()->validators());
   FeaturePtr aMyFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(myObject);
 
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
+  AttributeMap::iterator anAttrIt = myAttrs.begin();
   std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory management
-  for(; anAttr != myAttrs.end(); anAttr++) {
+  for(; anAttrIt != myAttrs.end(); anAttrIt++) {
+    AttributePtr anAttr = anAttrIt->second.first;
     // skip not-case attributes, that really may refer to anything not-used (issue 671)
-    if (aMyFeature.get() && !aValidators->isCase(aMyFeature, anAttr->second->id()))
+    if (aMyFeature.get() && !aValidators->isCase(aMyFeature, anAttr->id()))
       continue;
 
-    std::string aType = anAttr->second->attributeType();
+    std::string aType = anAttr->attributeType();
     if (aType == ModelAPI_AttributeReference::typeId()) { // reference to object
       std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
-          ModelAPI_AttributeReference>(anAttr->second);
+          ModelAPI_AttributeReference>(anAttr);
       aReferenced.push_back(aRef->value());
     } else if (aType == ModelAPI_AttributeRefAttr::typeId()) { // reference to attribute or object
       std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
-          ModelAPI_AttributeRefAttr>(anAttr->second);
+          ModelAPI_AttributeRefAttr>(anAttr);
       if (aRef->isObject()) {
         aReferenced.push_back(aRef->object());
       } else {
@@ -608,20 +608,20 @@ void Model_Data::referencesToObjects(
           aReferenced.push_back(anAttr->owner());
       }
     } else if (aType == ModelAPI_AttributeRefList::typeId()) { // list of references
-      aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
+      aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr)->list();
     } else if (aType == ModelAPI_AttributeSelection::typeId()) { // selection attribute
       std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
-          ModelAPI_AttributeSelection>(anAttr->second);
+          ModelAPI_AttributeSelection>(anAttr);
       aReferenced.push_back(aRef->context());
     } else if (aType == ModelAPI_AttributeSelectionList::typeId()) { // list of selection attributes
       std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
-          ModelAPI_AttributeSelectionList>(anAttr->second);
-      for(int a = aRef->size() - 1; a >= 0; a--) {
+          ModelAPI_AttributeSelectionList>(anAttr);
+      for(int a = 0, aSize = aRef->size(); a < aSize; ++a) {
         aReferenced.push_back(aRef->value(a)->context());
       }
     } else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
       std::shared_ptr<ModelAPI_AttributeRefAttrList> aRefAttr = std::dynamic_pointer_cast<
-          ModelAPI_AttributeRefAttrList>(anAttr->second);
+          ModelAPI_AttributeRefAttrList>(anAttr);
       std::list<std::pair<ObjectPtr, AttributePtr> > aRefs = aRefAttr->list();
       std::list<std::pair<ObjectPtr, AttributePtr> >::const_iterator anIt = aRefs.begin(),
                                                                      aLast = aRefs.end();
@@ -630,25 +630,25 @@ void Model_Data::referencesToObjects(
       }
     } else if (aType == ModelAPI_AttributeInteger::typeId()) { // integer attribute
       AttributeIntegerPtr anAttribute =
-          std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttr->second);
+          std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttr);
       std::set<std::string> anUsedParameters = anAttribute->usedParameters();
       std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
     } else if (aType == ModelAPI_AttributeDouble::typeId()) { // double attribute
       AttributeDoublePtr anAttribute =
-          std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anAttr->second);
+          std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anAttr);
       std::set<std::string> anUsedParameters = anAttribute->usedParameters();
       std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
     } else if (aType == GeomDataAPI_Point::typeId()) { // point attribute
       AttributePointPtr anAttribute =
-        std::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr->second);
+        std::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr);
       std::set<std::string> anUsedParameters = usedParameters(anAttribute);
       std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
     } else if (aType == GeomDataAPI_Point2D::typeId()) { // point attribute
       AttributePoint2DPtr anAttribute =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->second);
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
       std::set<std::string> anUsedParameters = usedParameters(anAttribute);
       std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
       aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
@@ -656,7 +656,8 @@ void Model_Data::referencesToObjects(
       continue; // nothing to do, not reference
 
     if (!aReferenced.empty()) {
-      theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
+      theRefs.push_back(
+          std::pair<std::string, std::list<ObjectPtr> >(anAttrIt->first, aReferenced));
       aReferenced.clear();
     }
   }
@@ -752,3 +753,15 @@ std::shared_ptr<ModelAPI_Object> Model_Data::owner()
 {
   return myObject;
 }
+
+bool Model_Data::isEarlierAttribute(const std::string& theAttribute1,
+                                    const std::string& theAttribute2) const
+{
+  AttributeMap::const_iterator aFound1 = myAttrs.find(theAttribute1);
+  AttributeMap::const_iterator aFound2 = myAttrs.find(theAttribute2);
+  if (aFound2 == myAttrs.end())
+    return true;
+  else if (aFound1 == myAttrs.end())
+    return false;
+  return aFound1->second.second < aFound2->second.second;
+}
index a5f9af4ed2c6eaf203f571db5eb1fca36ce2e28c..d46c13c31f695bce15bdf6e8ed009a7bcc6032bc 100644 (file)
@@ -58,9 +58,12 @@ class ModelAPI_Attribute;
 
 class Model_Data : public ModelAPI_Data
 {
+  typedef std::map<std::string, std::pair<std::shared_ptr<ModelAPI_Attribute>, int> > AttributeMap;
+
   TDF_Label myLab;  ///< label of the feature in the document
   /// All attributes of the object identified by the attribute ID
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> > myAttrs;
+  /// (the attribute is stored together with its index in the feature)
+  AttributeMap myAttrs;
   /// Array of flags of this data
   Handle(TDataStd_BooleanArray) myFlags;
 
@@ -290,6 +293,10 @@ private:
   /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay"
   /// signal.
   MODEL_EXPORT virtual void setDisplayed(const bool theDisplay);
+
+  /// Returns \c true if theAttribute1 is going earlier than theAttribute2 in the data
+  bool isEarlierAttribute(const std::string& theAttribute1,
+                          const std::string& theAttribute2) const;
 };
 
 /// Generic method to register back reference, used in referencing attributes.
index c8e1ca72f1e6f0738d49b03a5084697a04c0ba82..373e5ff1457f85861e2794f173db347e0977cd06 100644 (file)
@@ -933,22 +933,117 @@ TDF_Label Model_Objects::resultLabel(
   return aData->label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theResultIndex + 1);
 }
 
+
+// Obtain an index of result in the CompSolid (return 0 if the indexing is not necessary)
+static int subResultIndex(const FeaturePtr& theFeature, const ResultPtr& theResult)
+{
+  int anIndex = 0;
+  const std::list<ResultPtr>& aResults = theFeature->results();
+  for (std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
+       aResIt != aResults.end(); ++aResIt) {
+    ResultCompSolidPtr aCompSolidRes =
+        std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIt);
+    if (aCompSolidRes && aCompSolidRes->isSub(theResult, anIndex))
+      break;
+  }
+  return anIndex;
+}
+
+bool Model_Objects::hasCustomName(DataPtr theFeatureData,
+                                  ResultPtr theResult,
+                                  int theResultIndex,
+                                  std::string& theParentName) const
+{
+  typedef std::list< std::pair < std::string, std::list<ObjectPtr> > > ListOfReferences;
+
+  SessionPtr aSession = ModelAPI_Session::get();
+  FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner());
+
+  ResultCompSolidPtr aCompSolidRes =
+      std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theFeatureData->owner());
+  if (aCompSolidRes) {
+    // names of sub-solids in CompSolid should be default (for example,
+    // result of boolean operation 'Boolean_1' is a CompSolid which is renamed to 'MyBOOL',
+    // however, sub-elements of 'MyBOOL' should be named 'Boolean_1_1', 'Boolean_1_2' etc.)
+    std::ostringstream aDefaultName;
+    aDefaultName << anOwner->name();
+    // compute default name of CompSolid (name of feature + index of CompSolid's result)
+    int aCompSolidResultIndex = 0;
+    const std::list<ResultPtr>& aResults = anOwner->results();
+    for (std::list<ResultPtr>::const_iterator anIt = aResults.begin();
+         anIt != aResults.end(); ++anIt, ++aCompSolidResultIndex)
+      if (aCompSolidRes == *anIt)
+        break;
+    aDefaultName << "_" << (aCompSolidResultIndex + 1);
+    theParentName = aDefaultName.str();
+    return false;
+  }
+
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(anOwner->data());
+
+  ListOfReferences aReferences;
+  aData->referencesToObjects(aReferences);
+
+  // find first result with user-defined name
+  ListOfReferences::const_iterator aFoundRef = aReferences.end();
+  for (ListOfReferences::const_iterator aRefIt = aReferences.begin();
+       aRefIt != aReferences.end(); ++aRefIt) {
+    if (aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first)) {
+      // check the referred object is a Body
+      // (for example, ExtrusionCut has a sketch as a first attribute which is concealing)
+      bool isBody = aRefIt->second.size() > 1 || (aRefIt->second.size() == 1 &&
+                    aRefIt->second.front()->groupName() == ModelAPI_ResultBody::group());
+      if (isBody && (aFoundRef == aReferences.end() ||
+          aData->isEarlierAttribute(aRefIt->first, aFoundRef->first)))
+        aFoundRef = aRefIt;
+    }
+  }
+
+  // find an object which is concealed by theResult
+  if (aFoundRef != aReferences.end() && !aFoundRef->second.empty()) {
+    std::list<ObjectPtr>::const_iterator anObjIt = aFoundRef->second.begin();
+    while (--theResultIndex >= 0) {
+      ++anObjIt;
+      if (anObjIt == aFoundRef->second.end()) {
+        anObjIt = aFoundRef->second.begin();
+        break;
+      }
+    }
+    // check the result is a Body
+    if ((*anObjIt)->groupName() == ModelAPI_ResultBody::group()) {
+      // check the result is part of CompSolid
+      ResultPtr anObjRes = std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIt);
+      ResultCompSolidPtr aParentCompSolid = ModelAPI_Tools::compSolidOwner(anObjRes);
+      if (aParentCompSolid)
+        anObjRes = aParentCompSolid;
+      theParentName = anObjRes->data()->name();
+      return true;
+    }
+  }
+
+  return false;
+}
+
 void Model_Objects::storeResult(std::shared_ptr<ModelAPI_Data> theFeatureData,
-                                 std::shared_ptr<ModelAPI_Result> theResult,
-                                 const int theResultIndex)
+                                std::shared_ptr<ModelAPI_Result> theResult,
+                                const int theResultIndex)
 {
   theResult->init();
   theResult->setDoc(myDoc);
   initData(theResult, resultLabel(theFeatureData, theResultIndex), TAG_FEATURE_ARGUMENTS);
   if (theResult->data()->name().empty()) {
     // if was not initialized, generate event and set a name
-    std::stringstream aNewName;
-    aNewName<<theFeatureData->name();
-    // 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())
-      aNewName<<"_"<<theResultIndex + 1;
-    theResult->data()->setName(aNewName.str());
+    std::string aNewName = theFeatureData->name();
+    if (!hasCustomName(theFeatureData, theResult, theResultIndex, aNewName)) {
+      std::stringstream 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;
+      aNewName = aName.str();
+    }
+    theResult->data()->setName(aNewName);
   }
 }
 
index 97507367db5ab1741de54c60e43c094e53267335..57e02fa3492b539851d737261a4cd394acdf4270 100644 (file)
@@ -229,6 +229,13 @@ class Model_Objects
   /// Just removes all features without touching the document data (to be able undo)
   virtual void eraseAllFeatures();
 
+  // Check whether the pre-image of the result had user-defined name.
+  // If yes, return this name.
+  bool hasCustomName(DataPtr theFeatureData,
+                     ResultPtr theResult,
+                     int theResultIndex,
+                     std::string& theParentName) const;
+
  private:
   TDF_Label myMain; ///< main label of the data storage
 
index e043a23a2731cb5d8bedcb33639334b311749e19..94462f161e0e9b50b13c1106eb20e0db27e574bf 100644 (file)
@@ -172,4 +172,17 @@ ADD_UNIT_TESTS(TestConstants.py
                Test2241.py
                Test2252.py
                Test2276.py
+               TestCustomName_BooleanCut.py
+               TestCustomName_CommonCompSolid.py
+               TestCustomName_CutCompSolid.py
+               TestCustomName_CutGroup.py
+               TestCustomName_ExtrudeFace.py
+               TestCustomName_ExtrusionCut.py
+               TestCustomName_MultiTranslation.py
+               TestCustomName_Partition.py
+               TestCustomName_Placement.py
+               TestCustomName_Recover.py
+               TestCustomName_Rename.py
+               TestCustomName_RotateGroup.py
+               TestCustomName_Translation.py
 )
diff --git a/src/ModelAPI/Test/TestCustomName_BooleanCut.py b/src/ModelAPI/Test/TestCustomName_BooleanCut.py
new file mode 100644 (file)
index 0000000..fb24a17
--- /dev/null
@@ -0,0 +1,79 @@
+## 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>
+##
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(70, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 50)
+SketchLine_3 = Sketch_1.addLine(0, 50, 70, 50)
+SketchLine_4 = Sketch_1.addLine(70, 50, 70, 0)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 70)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 50)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 10, 0)
+Extrusion_1.result().setName("box")
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r"))
+SketchLine_5 = Sketch_2.addLine(10, 55, 50, 55)
+SketchLine_6 = Sketch_2.addLine(50, 55, 50, -5)
+SketchLine_7 = Sketch_2.addLine(50, -5, 10, -5)
+SketchLine_8 = Sketch_2.addLine(10, -5, 10, 55)
+SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result())
+SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result())
+SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result())
+SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_2 = SketchProjection_2.createdFeature()
+SketchConstraintDistanceVertical_1 = Sketch_2.setVerticalDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_7.endPoint(), -5)
+SketchConstraintDistanceHorizontal_1 = Sketch_2.setHorizontalDistance(SketchLine_8.startPoint(), SketchAPI_Point(SketchPoint_2).coordinates(), -10)
+SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_8.result(), 60)
+SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_7.result(), 40)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")], model.selection(), 15, 5)
+Extrusion_2.result().setName("tool")
+Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "box")], [model.selection("SOLID", "tool")])
+model.do()
+
+assert(Boolean_1.result().name() == Extrusion_1.result().name()), "Boolean CUT name '{}' != '{}'".format(Boolean_1.result().name(), Extrusion_1.result().name())
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_CommonCompSolid.py b/src/ModelAPI/Test/TestCustomName_CommonCompSolid.py
new file mode 100644 (file)
index 0000000..8e1e794
--- /dev/null
@@ -0,0 +1,62 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 100, 100, 10)
+Box_1.result().setName("plate")
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "plate/Front"), 50, True)
+Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "plate/Left"), 50, True)
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "plate"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")])
+#Partition_1.result().setName("plate")
+Partition_1.result().subResult(0).setName("Partition_1_1_1")
+Partition_1.result().subResult(1).setName("top_left")
+Partition_1.result().subResult(2).setName("bottom_right")
+Partition_1.result().subResult(3).setName("Partition_1_1_4")
+Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Partition_1_1_1/Modified_Face_3_3"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Partition_1_1_1/Modified_Face_3_3&top_left/Modified_Face_3_1&bottom_right/Modified_Face_3_2"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchCircle_1 = Sketch_1.addCircle(50, 50, 40)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 40)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection(), 10, model.selection("FACE", "Partition_1_1_1/Modified_Face_3_4"), 10)
+Extrusion_1.result().setName("cylinder")
+Boolean_1 = model.addCommon(Part_1_doc, [model.selection("COMPSOLID", "plate")], [model.selection("SOLID", "cylinder")])
+model.do()
+
+# check the name of result is kept
+CommonResult = Boolean_1.result()
+CommonResultName = CommonResult.name()
+assert(CommonResultName == Partition_1.result().name()), "Name of Boolean COMMON result '{}' != '{}'".format(CommonResultName, Partition_1.result().name())
+# check sub-result names are lost
+BooleanName = Boolean_1.name() + "_1"
+for i in range(0, CommonResult.numberOfSubs()):
+  refName = BooleanName + '_' + str(i + 1)
+  subResult = CommonResult.subResult(i)
+  assert(subResult.name() == refName), "Boolean COMMON sub-result {} name '{}' != '{}'".format(i, subResult.name(), refName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_CutCompSolid.py b/src/ModelAPI/Test/TestCustomName_CutCompSolid.py
new file mode 100644 (file)
index 0000000..831f49f
--- /dev/null
@@ -0,0 +1,89 @@
+## 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>
+##
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(80, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 80)
+SketchLine_3 = Sketch_1.addLine(0, 80, 80, 80)
+SketchLine_4 = Sketch_1.addLine(80, 80, 80, 0)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchLine_5 = Sketch_1.addLine(35, 80, 65, 0)
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_3.result())
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.result())
+SketchLine_6 = Sketch_1.addLine(0, 20, 80, 50)
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_2.result())
+SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_4.result())
+SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_5.result(), SketchLine_6.result())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 80)
+SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_6.startPoint(), SketchLine_1.endPoint(), -20)
+SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_5.endPoint(), SketchLine_1.startPoint(), 15)
+SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchLine_6.endPoint(), SketchLine_1.startPoint(), -50)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 0)
+Extrusion_1.result().setName("compsolid")
+
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "compsolid/Generated_Face_5"))
+SketchCircle_1 = Sketch_2.addCircle(65, -30, 10)
+SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_1.results()[1], 10)
+SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "compsolid/Generated_Face_5&compsolid/Generated_Face_4&compsolid/To_Face_3"), False)
+SketchPoint_2 = SketchProjection_2.createdFeature()
+SketchConstraintDistanceVertical_3 = Sketch_2.setVerticalDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchCircle_1.center(), 20)
+SketchConstraintDistanceHorizontal_2 = Sketch_2.setHorizontalDistance(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_2).coordinates(), 15)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), model.selection(), 10, model.selection("FACE", "compsolid/Generated_Face_1"), 10)
+Extrusion_2.result().setName("cyl")
+
+Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3")], [model.selection("SOLID", "cyl")])
+model.do()
+
+# check the name of Extrusion_1 is kept
+CutResult = Boolean_1.result()
+CutResultName = CutResult.name()
+assert(CutResultName == Extrusion_1.result().name()), "Name of Boolean CUT result '{}' != '{}'".format(CutResultName, Extrusion_1.result().name())
+# check sub-result names are lost
+BooleanName = Boolean_1.name() + "_1"
+for i in range(0, CutResult.numberOfSubs()):
+  refName = BooleanName + '_' + str(i + 1)
+  subResult = CutResult.subResult(i)
+  assert(subResult.name() == refName), "Boolean CUT sub-result {} name '{}' != '{}'".format(i, subResult.name(), refName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_CutGroup.py b/src/ModelAPI/Test/TestCustomName_CutGroup.py
new file mode 100644 (file)
index 0000000..d4fb33a
--- /dev/null
@@ -0,0 +1,107 @@
+## 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>
+##
+
+from SketchAPI import *
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(70, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 40)
+SketchLine_3 = Sketch_1.addLine(0, 40, 70, 40)
+SketchLine_4 = Sketch_1.addLine(70, 40, 70, 0)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 70)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 40)
+SketchCircle_1 = Sketch_1.addCircle(30, 70, 20)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 20)
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_3.result(), 30, True)
+SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchCircle_1.center(), SketchLine_2.startPoint(), -30)
+SketchLine_5 = Sketch_1.addLine(12.50000000006628, -45.31088913249455, 30, -15)
+SketchLine_6 = Sketch_1.addLine(30, -15, 47.50000000006629, -45.31088913249455)
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchLine_7 = Sketch_1.addLine(47.50000000006629, -45.31088913249455, 12.50000000006628, -45.31088913249455)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_7.result())
+SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_6.result())
+SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result())
+SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 35)
+SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_5.endPoint(), SketchLine_2.startPoint(), -30)
+SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_5.endPoint(), SketchLine_2.startPoint(), 15)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 10, 0)
+Extrusion_1.result().setName("box")
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r")], model.selection(), 20, 20)
+Extrusion_2.result().setName("prism")
+Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0)
+Extrusion_3.result().setName("cylinder")
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "box/From_Face_1"))
+SketchLine_8 = Sketch_2.addLine(45, 30, 25, 30)
+SketchLine_9 = Sketch_2.addLine(25, 30, 25, -100)
+SketchLine_10 = Sketch_2.addLine(25, -100, 45, -100)
+SketchLine_11 = Sketch_2.addLine(45, -100, 45, 30)
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_8.startPoint())
+SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
+SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
+SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result())
+SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_9.result())
+SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_10.result())
+SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_11.result())
+SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_10.result(), 20)
+SketchConstraintLength_5 = Sketch_2.setLength(SketchLine_9.result(), 130)
+SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "box/Generated_Face_3&box/Generated_Face_2&box/From_Face_1"), False)
+SketchPoint_2 = SketchProjection_2.createdFeature()
+SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchLine_8.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates(), -30)
+SketchConstraintDistanceHorizontal_3 = Sketch_2.setHorizontalDistance(SketchLine_8.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates(), -25)
+model.do()
+Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchLine_11f")], model.selection(), 5, 15)
+Extrusion_4.result().setName("cut_tool")
+Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "box"), model.selection("SOLID", "prism"), model.selection("SOLID", "cylinder")], [model.selection("SOLID", "cut_tool")])
+model.do()
+
+Extrusions = [Extrusion_1, Extrusion_2, Extrusion_3]
+BooleanResults = Boolean_1.results()
+for i in xrange(len(BooleanResults)):
+  assert(BooleanResults[i].name() == Extrusions[i].result().name()), "Name of result {} of Boolean CUT '{}' != '{}'".format(i, BooleanResults[i].name(), Extrusions[i].result().name())
+  BooleanName = Boolean_1.name() + "_" + str(i + 1)
+  for sub in range(0, BooleanResults[i].numberOfSubs()):
+    refName = BooleanName + '_' + str(sub + 1)
+    subResult = BooleanResults[i].subResult(sub)
+    assert(subResult.name() == refName), "Name of sub-result {} of result {} of Boolean CUT '{}' != '{}'".format(sub, i, subResult.name(), refName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_ExtrudeFace.py b/src/ModelAPI/Test/TestCustomName_ExtrudeFace.py
new file mode 100644 (file)
index 0000000..e1fa838
--- /dev/null
@@ -0,0 +1,50 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(0, 0, 68.31067519504786, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(68.31067519504786, 0, 0, 68.31067519504786)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(0, 68.31067519504786, 0, 0)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result())
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")])
+Face_1.result().setName("triangle")
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "triangle")], model.selection(), 10, 0)
+model.do()
+
+assert(Extrusion_1.result().name() == Face_1.result().name()), "Extrusion name '{}' != '{}'".format(Extrusion_1.result().name(), Face_1.result().name())
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_ExtrusionCut.py b/src/ModelAPI/Test/TestCustomName_ExtrusionCut.py
new file mode 100644 (file)
index 0000000..9d08321
--- /dev/null
@@ -0,0 +1,65 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(50.00000000000001, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 50)
+SketchLine_3 = Sketch_1.addLine(0, 50, 50, 50)
+SketchLine_4 = Sketch_1.addLine(50, 50, 50.00000000000001, 0)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 50)
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result())
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 20, 0)
+Extrusion_1.result().setName("plate")
+ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 10, [model.selection("SOLID", "plate")])
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "plate/To_Face_1"))
+SketchCircle_1 = Sketch_2.addCircle(30, 35, 10)
+SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "plate/Generated_Face_4&plate/To_Face_1"), False)
+SketchLine_5 = SketchProjection_2.createdFeature()
+SketchConstraintDistance_1 = Sketch_2.setDistance(SketchCircle_1.center(), SketchLine_5.result(), 20, True)
+SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "plate/Generated_Face_1&plate/To_Face_1"), False)
+SketchLine_6 = SketchProjection_3.createdFeature()
+SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_1.center(), SketchLine_6.result(), 15, True)
+SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_1.results()[1], 10)
+ExtrusionCut_1.setNestedSketch(Sketch_2)
+model.do()
+
+assert(ExtrusionCut_1.result().name() == Extrusion_1.result().name()), "ExtrusionCut name '{}' != '{}'".format(ExtrusionCut_1.result().name(), Extrusion_1.result().name())
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_MultiTranslation.py b/src/ModelAPI/Test/TestCustomName_MultiTranslation.py
new file mode 100644 (file)
index 0000000..6e008ee
--- /dev/null
@@ -0,0 +1,48 @@
+## 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>
+##
+
+from salome.shaper import model
+from ModelAPI import *
+
+NB_COPIES = 3
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Cylinder_1.result().setName("cylinder")
+MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("EDGE", "cylinder/Face_1"), 10, NB_COPIES)
+model.do()
+
+TransResult = MultiTranslation_1.result()
+TransResultName = TransResult.name()
+assert(TransResultName == Cylinder_1.result().name()), "MultiTranslation name '{}' != '{}'".format(TransResultName, Cylinder_1.result().name())
+# check sub-result names
+assert(NB_COPIES == TransResult.numberOfSubs()), "Number of results {} is not equal to reference {}".format(TransResult.numberOfSubs(), NB_COPIES)
+MultiTranslationName = MultiTranslation_1.name() + "_1"
+for i in range(0, NB_COPIES):
+  refName = MultiTranslationName + '_' + str(i + 1)
+  subResult = TransResult.subResult(i)
+  assert(subResult.name() == refName), "MultiTranslation sub-result {} name '{}' != '{}'".format(i, subResult.name(), refName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_Partition.py b/src/ModelAPI/Test/TestCustomName_Partition.py
new file mode 100644 (file)
index 0000000..b660c67
--- /dev/null
@@ -0,0 +1,46 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Cylinder_1.result().setName("cylinder")
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_1.result().setName("box")
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "box"), model.selection("SOLID", "cylinder")])
+model.do()
+
+PartitionResult = Partition_1.result()
+PartitionResultName = PartitionResult.name()
+assert(PartitionResultName == Box_1.result().name()), "Partition name '{}' != '{}'".format(PartitionResultName, Box_1.result().name())
+# check sub-result names
+PartitionName = Partition_1.name() + "_1"
+for i in range(0, PartitionResult.numberOfSubs()):
+  refName = PartitionName + '_' + str(i + 1)
+  subResult = PartitionResult.subResult(i)
+  assert(subResult.name() == refName), "Partition sub-result {} name '{}' != '{}'".format(i, subResult.name(), refName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_Placement.py b/src/ModelAPI/Test/TestCustomName_Placement.py
new file mode 100644 (file)
index 0000000..2d86f75
--- /dev/null
@@ -0,0 +1,56 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(30, 76.16895059675974, 30, 16.16895059675975)
+SketchLine_2 = Sketch_1.addLine(30, 16.16895059675975, 55.98076211353315, 31.16895059675975)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(55.98076211353315, 31.16895059675975, 30, 76.16895059675974)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
+SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_2.result(), SketchLine_3.result())
+SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_3.result(), 30)
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 60)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_4 = SketchProjection_1.createdFeature()
+SketchConstraintMirror_1_objects = [SketchLine_2.result(), SketchLine_1.result(), SketchLine_3.result()]
+SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_4.result(), SketchConstraintMirror_1_objects)
+[SketchLine_5, SketchLine_6, SketchLine_7] = SketchConstraintMirror_1.mirrored()
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_4.result(), 30, True)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 20, 0)
+Extrusion_1.result().setName("prism")
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), 360, 0)
+Revolution_1.result().setName("spinner")
+Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "spinner")], model.selection("VERTEX", "spinner/Lateral_Edge_1&spinner/Base_Edge_2"), model.selection("FACE", "prism/Generated_Face_1"), False, True)
+model.do()
+
+assert(Placement_1.result().name() == Revolution_1.result().name()), "Placement name '{}' != '{}'".format(Placement_1.result().name(), Revolution_1.result().name())
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_Recover.py b/src/ModelAPI/Test/TestCustomName_Recover.py
new file mode 100644 (file)
index 0000000..e069c44
--- /dev/null
@@ -0,0 +1,46 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Cylinder_1.result().setName("cylinder")
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "cylinder/Face_2"), 10, False)
+Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("FACE", "Plane_1"))
+model.do()
+
+# check the name of the Symmetry
+SymmetryName = Symmetry_1.result().name()
+assert(SymmetryName == Cylinder_1.result().name()), "Symmetry name '{}' != '{}'".format(SymmetryName, Cylinder_1.result().name())
+
+# recover original cylinder
+Recover_1 = model.addRecover(Part_1_doc, Symmetry_1, [Cylinder_1.result()])
+model.do()
+
+# check the name of the recovered result is not the cylinder name
+assert(Recover_1.result().name() != SymmetryName), "Recovered feature SHOULD NOT have the same name as original feature '{}'".format(SymmetryName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_Rename.py b/src/ModelAPI/Test/TestCustomName_Rename.py
new file mode 100644 (file)
index 0000000..f755a72
--- /dev/null
@@ -0,0 +1,61 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Cylinder_1.result().setName("cylinder")
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_1.result().setName("box")
+Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "box"), model.selection("SOLID", "cylinder")])
+model.do()
+
+# check name of result and its subs before rename
+PartitionResult = Partition_1.result()
+PartitionResultName = PartitionResult.name()
+assert(PartitionResultName == Box_1.result().name()), "Partition name '{}' != '{}'".format(PartitionResultName, Box_1.result().name())
+# check sub-result names
+PartitionName = Partition_1.name() + "_1"
+PartitionSubresultNames = []
+for i in range(0, PartitionResult.numberOfSubs()):
+  refName = PartitionName + '_' + str(i + 1)
+  subResult = PartitionResult.subResult(i)
+  assert(subResult.name() == refName), "Partition sub-result {} name '{}' != '{}'".format(i, subResult.name(), refName)
+  PartitionSubresultNames.append(refName)
+
+# rename original objects before the Partition
+Cylinder_1.result().setName("new_cylinder")
+Box_1.result().setName("new_box")
+model.do()
+
+# check names of the Partition does not changed
+assert(PartitionResultName == PartitionResult.name()), "After rename: Partition name '{}' != '{}'".format(PartitionResult.name(), PartitionResultName)
+for i in range(0, PartitionResult.numberOfSubs()):
+  refName = PartitionSubresultNames[i]
+  subResult = PartitionResult.subResult(i)
+  assert(subResult.name() == refName), "After rename: Partition sub-result {} name '{}' != '{}'".format(i, subResult.name(), refName)
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_RotateGroup.py b/src/ModelAPI/Test/TestCustomName_RotateGroup.py
new file mode 100644 (file)
index 0000000..cb36786
--- /dev/null
@@ -0,0 +1,55 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Cylinder_1.result().setName("cylinder")
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
+SketchArc_1 = Sketch_1.addArc(13.72530642620941, 12.64599334927434, 17.72530642621026, 15.64599334928998, 17.72530642621026, 9.645993349258699, False)
+SketchArc_2 = Sketch_1.addArc(21.72530642620941, 12.64599334927434, 17.72530642621026, 9.645993349258699, 17.72530642621026, 15.64599334928998, False)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchArc_2.endPoint())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_1.results()[1], SketchArc_2.results()[1])
+SketchLine_1 = Sketch_1.addLine(13.72530642620941, 12.64599334927434, 21.72530642620941, 12.64599334927434)
+SketchLine_1.setAuxiliary(True)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_1.endPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.startPoint())
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5)
+SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_1.endPoint(), 8, True)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_2_2f")], model.selection(), 10, 0)
+Extrusion_1.result().setName("prism")
+Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "prism"), model.selection("SOLID", "cylinder")], model.selection("EDGE", "PartSet/OX"), 30)
+model.do()
+
+RotationResults = Rotation_1.results()
+assert(RotationResults[0].name() == Extrusion_1.result().name()), "Rotation name [0] '{}' != '{}'".format(RotationResults[0].name(), Extrusion_1.result().name())
+assert(RotationResults[1].name() == Cylinder_1.result().name()),  "Rotation name [1] '{}' != '{}'".format(RotationResults[1].name(), Cylinder_1.result().name())
+
+model.end()
+
+assert(model.checkPythonDump())
diff --git a/src/ModelAPI/Test/TestCustomName_Translation.py b/src/ModelAPI/Test/TestCustomName_Translation.py
new file mode 100644 (file)
index 0000000..bad08c5
--- /dev/null
@@ -0,0 +1,36 @@
+## 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>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+Cylinder_1.result().setName("cylinder")
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("EDGE", "cylinder/Face_1"), 20)
+model.do()
+
+assert(Translation_1.result().name() == Cylinder_1.result().name()), "Translation name '{}' != '{}'".format(Translation_1.result().name(), Cylinder_1.result().name())
+
+model.end()
+
+assert(model.checkPythonDump())
index 0a691d2be2acf168ed55d86bb77cdd42fa18b5e0..d5b6332a3edac800c39907303082f5b461df9548 100644 (file)
@@ -91,6 +91,11 @@ void ModelHighAPI_Interface::setName(const std::string& theName)
   feature()->data()->setName(theName);
 }
 
+std::string ModelHighAPI_Interface::name() const
+{
+  return feature()->data()->name();
+}
+
 ModelHighAPI_Selection ModelHighAPI_Interface::result() const
 {
   const_cast<ModelHighAPI_Interface*>(this)->execute();
index 054dd1c36ec8cd655b285d0e14ffd664ca84c519..729d84a23997ae5bdb9276ba99bb39ffafe03973 100644 (file)
@@ -71,6 +71,10 @@ public:
   MODELHIGHAPI_EXPORT
   void setName(const std::string& theName);
 
+  /// Shortcut for feature()->data()->name()
+  MODELHIGHAPI_EXPORT
+  std::string name() const;
+
   /// Return firts object of the feature
   MODELHIGHAPI_EXPORT
   virtual ModelHighAPI_Selection result() const;
index 0eb6c78c27b23106dae089b83f34bd8220b8569c..ec6201600f530f5f3ef4a4c4071115b15af0e8cf 100644 (file)
@@ -131,6 +131,16 @@ void ModelHighAPI_Selection::setName(const std::string& theName)
   }
 }
 
+std::string ModelHighAPI_Selection::name() const
+{
+  if (myVariantType == VT_ResultSubShapePair) {
+    std::shared_ptr<ModelAPI_Result> aResult = myResultSubShapePair.first;
+    if (aResult.get())
+      return aResult->data()->name();
+  }
+  return std::string();
+}
+
 void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue)
 {
   if (myVariantType != VT_ResultSubShapePair || !myResultSubShapePair.first.get())
index 1aa1788e862cf813b14edfe0ac79324979939922..21da1cdfe188790a4c1f30c6876c21c378f9472d 100644 (file)
@@ -96,6 +96,10 @@ public:
   MODELHIGHAPI_EXPORT
   void setName(const std::string& theName);
 
+  /// Shortcut for result()->data()->name()
+  MODELHIGHAPI_EXPORT
+  std::string name() const;
+
   /// Change result's color
   MODELHIGHAPI_EXPORT
   void setColor(int theRed, int theGreen, int theBlue);