Salome HOME
Improve Model package coverage: remove unused methods, open/save tests improvements
authormpv <mpv@opencascade.com>
Wed, 12 Dec 2018 09:11:57 +0000 (12:11 +0300)
committermpv <mpv@opencascade.com>
Wed, 12 Dec 2018 09:11:57 +0000 (12:11 +0300)
22 files changed:
lcov_reports.sh
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultPart.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_AttributeDocRef.h
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/Test/TestSaveOpen.py [deleted file]
src/ModelAPI/Test/TestSaveOpen1.py [new file with mode: 0644]
src/ModelAPI/Test/TestSaveOpen2.py [new file with mode: 0644]

index 0fc2f13f89cce8264a0b97911a68b9f52d12372c..5474115e439fc4977340acccd66c720d640b1c68 100755 (executable)
@@ -53,7 +53,7 @@ cp -f covfile covElse
 NEED='BuildPlugin CollectionPlugin Config ConstructionPlugin Events ExchangePlugin FeaturesPlugin GDMLPlugin GeomData GeomDataAPLI GeomValidators InitializationPlugin Model_ ModelAPI ModelGeomAlgo ParametersPlugin PartSetPlugin PrimitivesPlugin Selector SketchPlugin SketchSolver'
 for MASK in $ALL; do
   if ! [[ " $NEED " =~ " $MASK " ]]; then
-    lcov -r covElse *${MASK}API* --output-file covElse_res -q
+    lcov -r covElse *${MASK}* --output-file covElse_res -q
     mv -f covElse_res covElse
   fi
 done
index b8b864acc2d034e259d31729d56ee1932a88bd0f..c40bffec08ca63303a6f9917e3f0247e48d31ce6 100644 (file)
@@ -201,13 +201,6 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
     aSelectionList->setSelectionType(aSelectionType);
     for (int anElementIndex = 0; anElementIndex < aXaoGroup->count(); ++anElementIndex) {
       aSelectionList->append(aResultBody, GeomShapePtr());
-      // complex conversion of element index to reference id
-      int anElementID = aXaoGroup->get(anElementIndex);
-      std::string aReferenceString =
-          aXaoGeometry->getElementReference(aXaoGroup->getDimension(), anElementID);
-      int aReferenceID = XAO::XaoUtils::stringToInt(aReferenceString);
-
-      aSelectionList->value(anElementIndex)->setId(aReferenceID);
     }
   }
   // Create new fields
index 1db965d233bc30a35d1ed1269207245c9ce2be69..e088c9a4410490ac5915599341e3f92dd0403538 100644 (file)
@@ -1020,76 +1020,6 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType,
   }
 }
 
-int Model_AttributeSelection::Id()
-{
-  int anID = 0;
-  std::shared_ptr<GeomAPI_Shape> aSelection = value();
-  ResultPtr aContextRes = context();
-  // support for compsolids:
-  while(ModelAPI_Tools::bodyOwner(aContextRes).get()) {
-    aContextRes = ModelAPI_Tools::bodyOwner(aContextRes);
-  }
-  std::shared_ptr<GeomAPI_Shape> aContext = aContextRes->shape();
-
-
-  TopoDS_Shape aMainShape = aContext->impl<TopoDS_Shape>();
-  const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
-  // searching for the latest main shape
-  if (aSelection && !aSelection->isNull() && aContext && !aContext->isNull())
-  {
-    std::shared_ptr<Model_Document> aDoc =
-      std::dynamic_pointer_cast<Model_Document>(context()->document());
-    if (aDoc.get()) {
-      Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel());
-      if (!aNS.IsNull()) {
-        aMainShape = TNaming_Tool::CurrentShape(aNS);
-      }
-    }
-
-    TopTools_IndexedMapOfShape aSubShapesMap;
-    TopExp::MapShapes(aMainShape, aSubShapesMap);
-    anID = aSubShapesMap.FindIndex(aSubShape);
-  }
-  return anID;
-}
-
-void Model_AttributeSelection::setId(int theID)
-{
-  std::shared_ptr<GeomAPI_Shape> aSelection;
-
-  ResultPtr aContextRes = context();
-  // support for compsolids:
-  while(ModelAPI_Tools::bodyOwner(aContextRes).get()) {
-    aContextRes = ModelAPI_Tools::bodyOwner(aContextRes);
-  }
-  std::shared_ptr<GeomAPI_Shape> aContext = aContextRes->shape();
-
-  TopoDS_Shape aMainShape = aContext->impl<TopoDS_Shape>();
-  // searching for the latest main shape
-  if (theID > 0 && aContext && !aContext->isNull())
-  {
-    std::shared_ptr<Model_Document> aDoc =
-      std::dynamic_pointer_cast<Model_Document>(aContextRes->document());
-    if (aDoc.get()) {
-      Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel());
-      if (!aNS.IsNull()) {
-        aMainShape = TNaming_Tool::CurrentShape(aNS);
-      }
-    }
-
-    TopTools_IndexedMapOfShape aSubShapesMap;
-    TopExp::MapShapes(aMainShape, aSubShapesMap);
-    const TopoDS_Shape& aSelShape = aSubShapesMap.FindKey(theID);
-
-    std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
-    aResult->setImpl(new TopoDS_Shape(aSelShape));
-
-    aSelection = aResult;
-  }
-
-  setValue(aContextRes, aSelection);
-}
-
 std::string Model_AttributeSelection::contextName(const ResultPtr& theContext) const
 {
   std::string aResult;
index 9512a3a73ebbdddb13ed03e32c51d020f735905d..6c8d66d73fcf9e65e41d5827169d3c11a76b0b56 100644 (file)
@@ -100,16 +100,6 @@ public:
   /// \param theDefaultValue a name, which is returned if the naming name can not be obtained
   MODEL_EXPORT virtual std::string namingName(const std::string& theDefaultValue = "");
 
-  /// Returns an Id of the selection
-  /// NOTE: This method has been added for temporary export of groups towards old GEOM
-  /// It should then be removed when a direct use of objects from SHAPER
-  /// will be possible from SMESH module of SALOME.
-  MODEL_EXPORT virtual int Id();
-
-  /// Defines the sub-shape by Id
-  /// NOTE: This method is opposite to Id() method.
-  MODEL_EXPORT virtual void setId(int theID);
-
   /// Selects (i.e. creates Naming data structure) of sub-shape specified by textual name
   MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
                                            const std::string& theSubShapeName);
index bfc4630579c80b776fda7551bca57a10c1307e16..cd3cf88cca46819f2af7ca43b0c4583abda56525 100644 (file)
@@ -96,15 +96,6 @@ void Model_Data::setLabel(TDF_Label theLab)
     myFlags->SetValue(kFlagInHistory, Standard_True); // is in history by default is true
     myFlags->SetValue(kFlagDisplayed, Standard_True); // is displayed by default is true
     myFlags->SetValue(kFlagDeleted, Standard_False); // is deleted by default is false
-  } else if (myFlags->Length() != 3) { // for old formats support
-    Standard_Boolean aFlag0 = myFlags->Upper() >= 0 ? myFlags->Value(0) : Standard_True;
-    Standard_Boolean aFlag1 = myFlags->Upper() >= 1 ? myFlags->Value(1) : Standard_True;
-    Standard_Boolean aFlag2 = myFlags->Upper() >= 2 ? myFlags->Value(2) : Standard_True;
-    Handle(TColStd_HArray1OfByte) aNewArray = new TColStd_HArray1OfByte(0, 2);
-    myFlags->SetInternalArray(aNewArray);
-    myFlags->SetValue(0, aFlag0);
-    myFlags->SetValue(1, aFlag1);
-    myFlags->SetValue(2, aFlag2);
   }
 }
 
@@ -344,12 +335,6 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
       if (myWasChangedButBlocked.empty() || *(myWasChangedButBlocked.rbegin()) != theAttr)
         myWasChangedButBlocked.push_back(theAttr);
     }
-  } else {
-    // trim: need to redisplay
-    /*if (myObject) {
-      static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
-      ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
-    }*/
   }
 }
 
@@ -417,7 +402,7 @@ enum StatesIndexes {
   STATE_INDEX_TRANSACTION = 2, // transaction ID
 };
 
-/// Returns the label array, initialises it by default values if not exists
+/// Returns the label array, initializes it by default values if not exists
 static Handle(TDataStd_IntegerArray) stateArray(TDF_Label& theLab)
 {
   Handle(TDataStd_IntegerArray) aStateArray;
@@ -481,15 +466,6 @@ int Model_Data::featureId() const
   return myLab.Father().Tag(); // tag of the feature label
 }
 
-void Model_Data::eraseBackReferences()
-{
-  myRefsToMe.clear();
-  std::shared_ptr<ModelAPI_Result> aRes = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
-  if (aRes) {
-    aRes->setIsConcealed(false);
-  }
-}
-
 void Model_Data::removeBackReference(ObjectPtr theObject, std::string theAttrID)
 {
   AttributePtr anAttribute = theObject->data()->attribute(theAttrID);
@@ -503,7 +479,7 @@ void Model_Data::removeBackReference(AttributePtr theAttr)
 
   myRefsToMe.erase(theAttr);
 
-  // remove concealment immideately: on deselection it must be posible to reselect in GUI the same
+  // remove concealment immediately: on deselection it must be possible to reselect in GUI the same
   FeaturePtr aFeatureOwner = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttr->owner());
   if (aFeatureOwner.get() &&
     ModelAPI_Session::get()->validators()->isConcealed(aFeatureOwner->getKind(), theAttr->id())) {
@@ -741,7 +717,7 @@ void Model_Data::copyTo(std::shared_ptr<ModelAPI_Data> theTarget)
   // reinitialize Model_Attributes by TDF_Attributes set
   std::shared_ptr<Model_Data> aTData = std::dynamic_pointer_cast<Model_Data>(theTarget);
   aTData->myAttrs.clear();
-  theTarget->owner()->initAttributes(); // reinit feature attributes
+  theTarget->owner()->initAttributes(); // reinitialize feature attributes
 }
 
 bool Model_Data::isInHistory()
index 2ed26625f42b0da7b4a12cd01cbaeea42d30e7f5..b4cc048a7929dd15af71583d2fd4f6b930796e5b 100644 (file)
@@ -168,7 +168,7 @@ class Model_Data : public ModelAPI_Data
   MODEL_EXPORT virtual const std::string& id(const std::shared_ptr<ModelAPI_Attribute>& theAttr);
   /// Returns true if data belongs to same features
   MODEL_EXPORT virtual bool isEqual(const std::shared_ptr<ModelAPI_Data>& theData);
-  /// Returns true if it is correctly connected t othe data model
+  /// Returns true if it is correctly connected tthe data model
   MODEL_EXPORT virtual bool isValid();
 
   /// Returns the label where the shape must be stored (used in ResultBody)
@@ -236,10 +236,10 @@ class Model_Data : public ModelAPI_Data
   MODEL_EXPORT virtual void referencesToObjects(
     std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
 
-  /// Copies all atributes content into theTarget data
+  /// Copies all attributes content into theTarget data
   MODEL_EXPORT virtual void copyTo(std::shared_ptr<ModelAPI_Data> theTarget);
 
-  /// Returns the invalid data pointer (to avoid working with NULL shared ptrs in swig)
+  /// Returns the invalid data pointer (to avoid working with NULL shared pointers in swig)
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Data> invalidPtr();
 
   /// Returns the invalid data pointer: static method
@@ -263,15 +263,13 @@ protected:
   /// Defines the custom "is in history" behavior
   MODEL_EXPORT virtual void setIsInHistory(const bool theFlag);
 
-  /// Returns true if the object is deleted, but some data is still keept in memory
+  /// Returns true if the object is deleted, but some data is still kept in memory
   MODEL_EXPORT virtual bool isDeleted();
 
-  /// Sets true if the object is deleted, but some data is still keept in memory
+  /// Sets true if the object is deleted, but some data is still kept in memory
   MODEL_EXPORT virtual void setIsDeleted(const bool theFlag);
 
 private:
-  /// Removes all information about back references
-  void eraseBackReferences();
   /// Removes a back reference (with identifier which attribute references to this object)
   /// \param theFeature feature referenced to this
   /// \param theAttrID identifier of the attribute that is references from theFeature to this
@@ -282,7 +280,7 @@ private:
   /// Adds a back reference (with identifier which attribute references to this object
   /// \param theFeature feature referenced to this
   /// \param theAttrID identifier of the attribute that is references from theFeature to this
-  /// \param theApplyConcealment applies consealment flag changes
+  /// \param theApplyConcealment applies concealment flag changes
   void addBackReference(FeaturePtr theFeature, std::string theAttrID,
     const bool theApplyConcealment = true);
   /// Adds a back reference to an object
@@ -295,7 +293,7 @@ private:
 
   /// Returns true if object must be displayed in the viewer: flag is stored in the
   /// data model, so on undo/redo, open/save or recreation of object by history-playing it keeps
-  /// the original state i nthe current transaction.
+  /// the original state ithe current transaction.
   MODEL_EXPORT virtual bool isDisplayed();
 
   /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay"
index 99a624ae09f4746f66d7ef5f9a21596db44d6cf9..6ba5fd91083871e1491d79a6bcb0b1373d330aab 100755 (executable)
@@ -45,7 +45,6 @@
 #include <TDataStd_AsciiString.hxx>
 #include <TDF_Reference.hxx>
 #include <TDF_ChildIDIterator.hxx>
-#include <TDF_LabelMapHasher.hxx>
 #include <TDF_Delta.hxx>
 #include <TDF_AttributeDelta.hxx>
 #include <TDF_AttributeDeltaList.hxx>
@@ -1435,16 +1434,6 @@ std::shared_ptr<ModelAPI_Feature> Model_Document::feature(
   return myObjs->feature(theResult);
 }
 
-Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper)
-{
-  return TDF_LabelMapHasher::HashCode(theLab, theUpper);
-
-}
-Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2)
-{
-  return TDF_LabelMapHasher::IsEqual(theLab1, theLab2);
-}
-
 FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) {
   TDF_Label aCurrentLab = theLab;
   while(aCurrentLab.Depth() > 3)
@@ -1759,11 +1748,6 @@ void Model_Document::incrementTransactionID()
   int aNewVal = transactionID() + 1;
   TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal);
 }
-void Model_Document::decrementTransactionID()
-{
-  int aNewVal = transactionID() - 1;
-  TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal);
-}
 
 TDF_Label Model_Document::extConstructionsLabel() const
 {
@@ -1785,11 +1769,6 @@ std::shared_ptr<ModelAPI_Feature> Model_Document::internalFeature(const int theI
   return myObjs->internalFeature(theIndex);
 }
 
-std::shared_ptr<ModelAPI_Feature> Model_Document::featureById(const int theId)
-{
-  return myObjs->featureById(theId);
-}
-
 void Model_Document::synchronizeTransactions()
 {
   Model_Document* aRoot =
index f4c6233d1c72cd18e37a588fda9c798295f3d6fe..45b0923adb3599403f46e18ec8ae1972fcf2157d 100644 (file)
@@ -180,10 +180,6 @@ class Model_Document : public ModelAPI_Document
   //! without this participation
   MODEL_EXPORT virtual void synchronizeTransactions();
 
-  //! Returns feature by the id of the feature (produced by the Data "featureId" method)
-  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> featureById(const int theId);
-
-
   /// Creates construction results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
@@ -285,8 +281,6 @@ class Model_Document : public ModelAPI_Document
   MODEL_EXPORT virtual int transactionID();
   /// Increases the transaction ID
   MODEL_EXPORT virtual void incrementTransactionID();
-  /// Decreases the transaction ID
-  MODEL_EXPORT virtual void decrementTransactionID();
 
   /// Returns true if document is opened and valid
   MODEL_EXPORT virtual bool isOpened();
index d7ecf71879dc3ee3b39e5f34eadef130e13f536b..0d6479c3f8b149cb23c341d540a10883542c3573 100644 (file)
@@ -798,15 +798,6 @@ void Model_Objects::initData(ObjectPtr theObj, TDF_Label theLab, const int theTa
   theObj->initAttributes();
 }
 
-std::shared_ptr<ModelAPI_Feature> Model_Objects::featureById(const int theId)
-{
-  if (theId > 0) {
-    TDF_Label aLab = featuresLabel().FindChild(theId, Standard_False);
-    return feature(aLab);
-  }
-  return std::shared_ptr<ModelAPI_Feature>(); // not found
-}
-
 void Model_Objects::synchronizeFeatures(
   const TDF_LabelList& theUpdated, const bool theUpdateReferences,
   const bool theExecuteFeatures, const bool theOpen, const bool theFlush)
index 26e6e6d19b70b2613a762e44521f1eaccedfec91..64afceda8e6cd82d5b4f15c963c3e03d76288b6c 100644 (file)
@@ -124,10 +124,6 @@ class Model_Objects
   //! Returns the feature by zero-based index: features in the history or not
   std::shared_ptr<ModelAPI_Feature> internalFeature(const int theIndex);
 
-  //! Returns feature by the id of the feature (produced by the Data "featureId" method)
-  std::shared_ptr<ModelAPI_Feature> featureById(const int theId);
-
-
   /// Creates a construction result
   std::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
index dbad51c7be3630204a22249cccb871b745d5c82a..3c53dc54e98ddad73f7669b3a0751d2ed754532a 100644 (file)
@@ -56,7 +56,7 @@ void Model_ResultPart::initAttributes()
   data()->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId());
 
-  if (aDocRef->isInitialized() && // initialized immideately means already exist and will be loaded
+  if (aDocRef->isInitialized() && // initialized immediately means already exist and will be loaded
       !Model_Application::getApplication()->hasDocument(aDocRef->docId()))
     Model_Application::getApplication()->setLoadByDemand(data()->name(), aDocRef->docId());
 }
@@ -139,7 +139,7 @@ bool Model_ResultPart::setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
     if (!myTrsf.get()) { // disable of base result part
       DocumentPtr aDoc = Model_ResultPart::partDoc();
       if (aDoc.get() && aDoc->isOpened()) {
-        // make the current feature the last in any case: to update shapes defore deactivation too
+        // make the current feature the last in any case: to update shapes before deactivation too
         int aSize = aDoc->size(ModelAPI_Feature::group());
         FeaturePtr aLastFeature;
         if (aSize)
@@ -170,7 +170,7 @@ std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shape()
   std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
   if (myShape.IsNull()) { // shape is not produced yet, create it
     SessionPtr aMgr = ModelAPI_Session::get();
-    bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update evnet
+    bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update event
     if (myTrsf.get()) { // get shape of the base result and apply the transformation
       ResultPtr anOrigResult = baseRef();
       std::shared_ptr<GeomAPI_Shape> anOrigShape = anOrigResult->shape();
index 22b949c54246424129624587d7063bf6f956c6d3..55fc4a99f2fab896d7fda96eff836c2a430cdd50 100644 (file)
@@ -232,5 +232,6 @@ ADD_UNIT_TESTS(TestConstants.py
                TestGeomNamingSketchPlane.py
                TestGeomNamingBoxWithFillet.py
                TestContainerSelector.py
-               TestSaveOpen.py
+               TestSaveOpen1.py
+               TestSaveOpen2.py
 )
index db3acb539818eb043ace5bfdf0d440223fcdb952..179037e02adcfcb723eb97a8cb4034134c57ea77 100644 (file)
@@ -182,8 +182,8 @@ template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr
 %template(modelAPI_ResultBody) shared_ptr_cast<ModelAPI_ResultBody, ModelAPI_Result>;
 %template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
 %template(modelAPI_ResultParameter) shared_ptr_cast<ModelAPI_ResultParameter, ModelAPI_Result>;
-%template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultGroup>;
-%template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultField>;
+%template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultGroup, ModelAPI_Result>;
+%template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultField, ModelAPI_Result>;
 
 // Attribute casts
 %template(modelAPI_AttributeDocRef)        shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
index 1a9d5abc074f369764b0ac8e910692b12443412d..8dc5122ff12fd2c0172c99811c9a88656fe7314f 100644 (file)
@@ -38,7 +38,7 @@ class ModelAPI_AttributeDocRef : public ModelAPI_Attribute
   /// Returns document referenced from this attribute
   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> value() = 0;
 
-  /// Returns the persisten ID of the document
+  /// Returns the persistent ID of the document
   MODELAPI_EXPORT virtual int docId() = 0;
 
   /// Returns the type of this class of attributes
index d2dec5bc49e02e0e4b0ceb595b33acd1c849f9f6..a1df51888ac19a4eed87bd1a993119a9906a5a30 100644 (file)
@@ -95,12 +95,6 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute
   /// \param theDefaultValue a value, which is used if the naming name can not be obtained
   virtual std::string namingName(const std::string& theDefaultValue = "") = 0;
 
-  /// Returns an id of the selection
-  virtual int Id() = 0;
-
-  /// Defines an id of the selection
-  virtual void setId(int theID) = 0;
-
   /// Selects sub-shape by the textual Name
   virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0;
 
index 2fc8fbfc8fec35a6997faf2119930bcc8b9885fc..810558e413bfc21dccb6b8b7b452fe6ac0b0d280 100644 (file)
@@ -181,7 +181,7 @@ class MODELAPI_EXPORT ModelAPI_Data
   /// Copies all attributes content into theTarget data
   virtual void copyTo(std::shared_ptr<ModelAPI_Data> theTarget) = 0;
 
-  /// Returns the invalid data pointer (to avoid working with NULL shared ptrs in swig)
+  /// Returns the invalid data pointer (to avoid working with NULL shared pointers in swig)
   virtual std::shared_ptr<ModelAPI_Data> invalidPtr() = 0;
 
   /// Identifier of the transaction when object (feature or result) was updated last time.
@@ -191,13 +191,13 @@ class MODELAPI_EXPORT ModelAPI_Data
   /// This method is called by the updater.
   virtual void setUpdateID(const int theID) = 0;
 
-  /// Returns the owner of htis data
+  /// Returns the owner of this data
   virtual std::shared_ptr<ModelAPI_Object> owner() = 0;
 
-  /// Returns true if the object is deleted, but some data is still keept in memory
+  /// Returns true if the object is deleted, but some data is still kept in memory
   virtual bool isDeleted() = 0;
 
-  /// Sets true if the object is deleted, but some data is still keept in memory
+  /// Sets true if the object is deleted, but some data is still kept in memory
   virtual void setIsDeleted(const bool theFlag) = 0;
 
   /// Returns \c true if theAttribute1 is going earlier than theAttribute2 in the data
@@ -216,7 +216,7 @@ class MODELAPI_EXPORT ModelAPI_Data
 
   /// Returns true if object must be displayed in the viewer: flag is stored in the
   /// data model, so on undo/redo, open/save or recreation of object by history-playing it keeps
-  /// the original state i nthe current transaction.
+  /// the original state ithe current transaction.
   virtual bool isDisplayed() = 0;
 
   /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay"
index be23056ae6cae47231bd735fdae8a451234b2757..b4980301390e89ec254f3430a417359fe72e3d4c 100644 (file)
@@ -46,8 +46,8 @@ class GeomAPI_Shape;
 /**\class ModelAPI_Document
  * \ingroup DataModel
  * \brief Document for internal data structure of any object storage.
- * Document contains all data that must be stored/retrived in the file.
- * Also it provides acces to this data: open/save, transactions management etc.
+ * Document contains all data that must be stored/retrieved in the file.
+ * Also it provides access to this data: open/save, transactions management etc.
  */
 class ModelAPI_Document: public ModelAPI_Entity
 {
@@ -58,7 +58,7 @@ public:
   virtual const std::string& kind() const = 0;
 
   //! Removes document data
-  //! \param theForever if it is false, document is just hiden
+  //! \param theForever if it is false, document is just hidden
   //!                   (to keep possibility make it back on Undo/Redo)
   virtual void close(const bool theForever = false) = 0;
 
@@ -128,7 +128,7 @@ public:
   //! Sets the current feature: all features below will be disabled, new features
   //! will be appended after this one. This method does not flushes the events appeared:
   //! it will be done by the finishOperation, or direct flushes
-  //! \param theCurrent the selected feature as current: blow it everythin become disabled
+  //! \param theCurrent the selected feature as current: blow it everything become disabled
   //! \param theVisible use visible features only: flag is true for Object Browser functionality
   virtual void setCurrentFeature(std::shared_ptr<ModelAPI_Feature> theCurrent,
     const bool theVisible) = 0;
@@ -141,13 +141,10 @@ public:
   virtual std::shared_ptr<ModelAPI_Feature> internalFeature(const int theIndex) = 0;
   //! Performs synchronization of transactions with the module document:
   //! If some document is not active (by undo of activation) but in memory,
-  //! on activation the transactions must be synchronised because all redos performed
-  //! wihtout this participation
+  //! on activation the transactions must be synchronized because all redo-s performed
+  //! without this participation
   virtual void synchronizeTransactions() = 0;
 
-  //! Returns feature by the id of the feature (produced by the Data "featureId" method)
-  virtual std::shared_ptr<ModelAPI_Feature> featureById(const int theId) = 0;
-
   //! To virtually destroy the fields of successors
   MODELAPI_EXPORT virtual ~ModelAPI_Document();
 
@@ -204,7 +201,7 @@ public:
   virtual std::shared_ptr<ModelAPI_Folder> findFolderBelow(
       const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures) = 0;
   //! Search a folder containing the given feature.
-  //! Addtionally calculates a zero-based index of the feature in this folder.
+  //! Additionally calculates a zero-based index of the feature in this folder.
   //! \param theFeature feature to search
   //! \param theIndexInFolder zero-based index in the folder or -1 if the feature is top-level.
   //! \return the folder containing the feature or empty pointer if the feature is top-level.
@@ -213,7 +210,7 @@ public:
       int& theIndexInFolder) = 0;
   //! Add a list of features to the folder. The correctness of the adding is not performed
   //! (such checks have been done in corresponding find.. method).
-  //! \return \c true if the movement is successfull
+  //! \return \c true if the movement is successful
   virtual bool moveToFolder(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
                             const std::shared_ptr<ModelAPI_Folder>& theFolder) = 0;
   //! Remove features from the folder
@@ -250,7 +247,7 @@ public:
   /// Normally is called outside of the transaction, just before "save".
   MODELAPI_EXPORT virtual void storeNodesState(const std::list<bool>& theStates) = 0;
 
-  /// Returns the stored nodes states. Normally it is calles just after "open".
+  /// Returns the stored nodes states. Normally it is calls just after "open".
   /// Appends the values to theStates list.
   MODELAPI_EXPORT virtual void restoreNodesState(std::list<bool>& theStates) const = 0;
 
index 22284d1ee6c0443a738c72d37d7b12cb148c67e5..9129f0638ad1a0a4c73fac6b1a859f7221c11764 100644 (file)
@@ -87,12 +87,6 @@ GeomShapePtr ModelAPI_ResultBody::shape()
   return myBuilder->shape();
 }
 
-bool ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape,
-  const std::string& theName, const bool theCheckIsInResult)
-{
-  return myBuilder->generated(theNewShape, theName, theCheckIsInResult);
-}
-
 void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape,
                                     const GeomShapePtr& theNewShape,
                                     const std::string& theName)
@@ -116,22 +110,6 @@ void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
   myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude);
 }
 
-void ModelAPI_ResultBody::loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
-                                             const GeomShapePtr& theOldShape,
-                                             const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
-                                             const std::string& theName)
-{
-  myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
-}
-
-void ModelAPI_ResultBody::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
-                                              const GeomShapePtr& theOldShape,
-                                              const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
-                                              const std::string& theName)
-{
-  myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName);
-}
-
 void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
                                          const std::string& theName)
 {
index 1ad95f5d1e7dfb3b11c02af52e6721fe578ac25f..c41854f9d081c6c82e9dd7a35ba1c0592c66b0d3 100644 (file)
@@ -114,7 +114,7 @@ public:
   /// As an example, consider the case of a face generated in construction of a box.
   /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
   MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
-    const std::string& theName, const bool theCheckIsInResult = true);
+    const std::string& theName, const bool theCheckIsInResult = true) = 0;
 
   /// Records the shape newShape which was generated from the shape oldShape during a topological
   /// construction. As an example, consider the case of a face generated from an edge in
@@ -141,14 +141,14 @@ public:
   virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
                                   const GeomShapePtr& theOldShape,
                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
-                                  const std::string& theName = "");
+                                  const std::string& theName = "") = 0;
 
   /// load and orient generated shapes
   MODELAPI_EXPORT
   virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
                                    const GeomShapePtr& theOldShape,
                                    const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
-                                   const std::string& theName = "");
+                                   const std::string& theName = "") = 0;
 
   /// load shapes of the first level (to be used during shape import)
   MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
diff --git a/src/ModelAPI/Test/TestSaveOpen.py b/src/ModelAPI/Test/TestSaveOpen.py
deleted file mode 100644 (file)
index 5bc57a2..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-## 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>
-##
-
-# -*- coding: utf-8 -*-
-
-from salome.shaper import model
-from ModelAPI import *
-
-model.begin()
-partSet = model.moduleDocument()
-Point_2 = model.addPoint(partSet, 1, 2, 3)
-Point_name = Point_2.name()
-model.end()
-
-# check save document in a current folder
-aSession = ModelAPI_Session.get()
-aFiles = StringList()
-aSession.save(".", aFiles)
-assert(len(aFiles) == 1)
-
-# check open of the same document
-assert(aSession.load(".") == False) # error because this document is already opened
-
-# close the current document
-aSession.closeAll()
-
-# open again: it must be correct now
-assert(aSession.load("."))
-
-# check the created point is opened
-partSet = model.moduleDocument()
-assert(partSet.size("Features") == 1)
-assert(partSet.object("Features", 0).data().name() == Point_name)
diff --git a/src/ModelAPI/Test/TestSaveOpen1.py b/src/ModelAPI/Test/TestSaveOpen1.py
new file mode 100644 (file)
index 0000000..5bc57a2
--- /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>
+##
+
+# -*- coding: utf-8 -*-
+
+from salome.shaper import model
+from ModelAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Point_2 = model.addPoint(partSet, 1, 2, 3)
+Point_name = Point_2.name()
+model.end()
+
+# check save document in a current folder
+aSession = ModelAPI_Session.get()
+aFiles = StringList()
+aSession.save(".", aFiles)
+assert(len(aFiles) == 1)
+
+# check open of the same document
+assert(aSession.load(".") == False) # error because this document is already opened
+
+# close the current document
+aSession.closeAll()
+
+# open again: it must be correct now
+assert(aSession.load("."))
+
+# check the created point is opened
+partSet = model.moduleDocument()
+assert(partSet.size("Features") == 1)
+assert(partSet.object("Features", 0).data().name() == Point_name)
diff --git a/src/ModelAPI/Test/TestSaveOpen2.py b/src/ModelAPI/Test/TestSaveOpen2.py
new file mode 100644 (file)
index 0000000..133ba14
--- /dev/null
@@ -0,0 +1,73 @@
+## 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>
+##
+
+# -*- coding: utf-8 -*-
+
+from salome.shaper import model
+from ModelAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")])
+Field_1 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]")])
+Field_1.addStep(0, 5, [[0], [3], [4]])
+model.do()
+Translation_1 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OY"), 20)
+model.end()
+
+# check save document in a current folder
+aSession = ModelAPI_Session.get()
+aFiles = StringList()
+aSession.save(".", aFiles)
+assert(len(aFiles) == 3)
+
+# check open of the same document
+assert(aSession.load(".") == False) # error because this document is already opened
+
+# close the current document
+aSession.closeAll()
+
+# open again: it must be correct now
+assert(aSession.load("."))
+
+# activate the Part of session
+model.begin()
+partSet = model.moduleDocument()
+assert(partSet.size("Features") == 2)
+aPart = objectToFeature(partSet.object("Features", 0))
+aPartResult = modelAPI_ResultPart(aPart.results()[0])
+aPartResult.activate()
+aPartDoc = aPartResult.partDoc()
+aSession.setActiveDocument(aPartDoc, True)
+model.do()
+# check the field result data
+aFieldFeature = aPartDoc.objectByName("Features", "Field_1")
+aFieldResult = modelAPI_ResultField(objectToFeature(aFieldFeature).results()[0])
+assert(aFieldResult.textLine(0) == "5")
+aSession.setActiveDocument(partSet, True)
+aTranslation = objectToFeature(partSet.objectByName("Features", "Translation_1"))
+partSet.setCurrentFeature(aTranslation, True)
+model.end()
+
+# check the translation feature has a correct result
+assert(not aTranslation.firstResult().shape().isNull())
\ No newline at end of file