]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Updated the references attributes
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 14 Jul 2014 07:47:50 +0000 (11:47 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 14 Jul 2014 07:47:50 +0000 (11:47 +0400)
25 files changed:
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/Model/Model_AttributeRefAttr.cpp
src/Model/Model_AttributeRefAttr.h
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/Model/Model_AttributeReference.cpp
src/Model/Model_AttributeReference.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/ModelAPI/ModelAPI_AttributeRefAttr.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeReference.h
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index e89d503521a97bcde385000421af90f9303c906a..31fbe2cc1ac7198789104fbb92662fd487d3de08 100644 (file)
@@ -33,11 +33,8 @@ void FeaturesPlugin_Extrusion::execute()
     boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
   if (!aFaceRef)
     return;
-  FeaturePtr aFaceFeature = aFaceRef->value();
-  if (!aFaceFeature)
-    return;
   boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
-    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceFeature->firstResult());
+    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceRef->value());
   if (!aConstr) 
     return;
   boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
index 24bcddec1a7e63378c7ed4e5fd3f24462f323295..77a89ba40868cb6ce030610e3c438b79f9e80ef0 100644 (file)
@@ -9,7 +9,7 @@
 
 using namespace std;
 
-bool Model_AttributeRefAttr::isFeature()
+bool Model_AttributeRefAttr::isObject()
 {
   return myID->Get().Length() == 0;
 }
@@ -19,7 +19,7 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theAttr->owner()->data());
   string anID = aData->id(theAttr);
-  if (myIsInitialized && feature() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
+  if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
     return; // nothing is changed
 
   myRef->Set(aData->label());
@@ -29,40 +29,40 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
 
 boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
 {
-  FeaturePtr aFeature = feature();
-  if (aFeature) {
+  ObjectPtr anObj = object();
+  if (anObj) {
     boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(aFeature->data());
+      boost::dynamic_pointer_cast<Model_Data>(anObj->data());
     return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString());
   }
   // not initialized
   return boost::shared_ptr<ModelAPI_Attribute>();
 }
 
-void Model_AttributeRefAttr::setFeature(FeaturePtr theFeature)
+void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
 {
-  if (!myIsInitialized || myID->Get().Length() != 0 || feature() != theFeature) {
+  if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) {
     boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+      boost::dynamic_pointer_cast<Model_Data>(theObject->data());
     myRef->Set(aData->label());
     myID->Set(""); // feature is identified by the empty ID
     owner()->data()->sendAttributeUpdated(this);
   }
 }
 
-FeaturePtr Model_AttributeRefAttr::feature()
+ObjectPtr Model_AttributeRefAttr::object()
 {
   if (myRef->Get() != myRef->Label()) { // initialized
     boost::shared_ptr<Model_Document> aDoc = 
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
-      TDF_Label aFeatureLab = aRefLab.Father();
-      return aDoc->feature(aRefLab);
+      TDF_Label anObjLab = aRefLab.Father();
+      return aDoc->object(aRefLab);
     }
   }
   // not initialized
-  return FeaturePtr();
+  return ObjectPtr();
 }
 
 Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
index 69fda0163632dd7a0d858fd7c04c706d73ef4e0d..273cfd544102c0c5e183668e578d2d9914727c78 100644 (file)
@@ -23,8 +23,8 @@ class Model_AttributeRefAttr : public ModelAPI_AttributeRefAttr
    ///< ID of the referenced attirbute (empty if this is a reference to a feature)
   Handle_TDataStd_Comment myID;
 public:
-  /// Returns true if this attribute references to a feature (not to the attribute)
-  MODEL_EXPORT virtual bool isFeature();
+  /// Returns true if this attribute references to a object (not to the attribute)
+  MODEL_EXPORT virtual bool isObject();
 
   /// Defines the reference to the attribute
   MODEL_EXPORT virtual void setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr);
@@ -32,11 +32,11 @@ public:
   /// Returns attribute referenced from this attribute
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr();
 
-  /// Defines the reference to the feature
-  MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature);
+  /// Defines the reference to the object
+  MODEL_EXPORT virtual void setObject(ObjectPtr theFeature);
 
-  /// Returns feature referenced from this attribute
-  MODEL_EXPORT virtual FeaturePtr feature();
+  /// Returns object referenced from this attribute
+  MODEL_EXPORT virtual ObjectPtr object();
 
 protected:
   /// Objects are created for features automatically
index cc19ba6cafa5083d5ac6880d4a65db925b1d95e1..0a6eee7c45cb9b66de20009239fc98ccb6eba55a 100644 (file)
 
 using namespace std;
 
-void Model_AttributeRefList::append(FeaturePtr theFeature)
+void Model_AttributeRefList::append(ObjectPtr theObject)
 {
   boost::shared_ptr<Model_Data> aData = 
-    boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+    boost::dynamic_pointer_cast<Model_Data>(theObject->data());
   myRef->Append(aData->label());
 
   owner()->data()->sendAttributeUpdated(this);
 }
 
-void Model_AttributeRefList::remove(FeaturePtr theFeature)
+void Model_AttributeRefList::remove(ObjectPtr theObject)
 {
   boost::shared_ptr<Model_Data> aData = 
-    boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+    boost::dynamic_pointer_cast<Model_Data>(theObject->data());
   myRef->Remove(aData->label());
 
   owner()->data()->sendAttributeUpdated(this);
@@ -33,15 +33,15 @@ int Model_AttributeRefList::size()
   return myRef->Extent();
 }
 
-list<FeaturePtr> Model_AttributeRefList::list()
+list<ObjectPtr> Model_AttributeRefList::list()
 {
-  std::list< FeaturePtr > aResult;
+  std::list< ObjectPtr > aResult;
   boost::shared_ptr<Model_Document> aDoc = 
     boost::dynamic_pointer_cast<Model_Document>(owner()->document());
   if (aDoc) {
     const TDF_LabelList& aList = myRef->List();
     for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
-      aResult.push_back(aDoc->feature(aLIter.Value()));
+      aResult.push_back(aDoc->object(aLIter.Value()));
     }
   }
   return aResult;
index 340f5cdf011ad037338248b3a19731b25a8bf46c..7f797e2dec4d6ecbf221869c8a4691f4a9e3d5d0 100644 (file)
@@ -21,16 +21,16 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList
   Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
 public:
   /// Appends the feature to the end of a list
-  MODEL_EXPORT virtual void append(FeaturePtr theFeature);
+  MODEL_EXPORT virtual void append(ObjectPtr theObject);
 
   /// Erases the first meet of the feature in the list
-  MODEL_EXPORT virtual void remove(FeaturePtr theFeature);
+  MODEL_EXPORT virtual void remove(ObjectPtr theObject);
 
   /// Returns number of features in the list
   MODEL_EXPORT virtual int size();
 
   /// Returns the list of features
-  MODEL_EXPORT virtual std::list<FeaturePtr > list();
+  MODEL_EXPORT virtual std::list<ObjectPtr > list();
 
 protected:
   /// Objects are created for features automatically
index e2ff01ce7798975aa6e11d829c86281f6bfc99f5..9cfd4a91c3ef72ee3df11bdd76f6deadcb5e650f 100644 (file)
 
 using namespace std;
 
-void Model_AttributeReference::setValue(FeaturePtr theFeature)
+void Model_AttributeReference::setValue(ObjectPtr theObject)
 {
-  if (!myIsInitialized || value() != theFeature) {
+  if (!myIsInitialized || value() != theObject) {
     boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+      boost::dynamic_pointer_cast<Model_Data>(theObject->data());
     if (myRef.IsNull()) {
       boost::shared_ptr<Model_Data> aMyData = 
         boost::dynamic_pointer_cast<Model_Data>(owner()->data());
@@ -26,14 +26,14 @@ void Model_AttributeReference::setValue(FeaturePtr theFeature)
   }
 }
 
-FeaturePtr Model_AttributeReference::value()
+ObjectPtr Model_AttributeReference::value()
 {
   if (!myRef.IsNull()) {
     boost::shared_ptr<Model_Document> aDoc = 
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
-      return aDoc->feature(aRefLab);
+      return aDoc->object(aRefLab);
     }
   }
   // not initialized
index 6406d0bfbfbf0fd8b828ab4fc0dca034c39423ec..82222550043618c949308fa5ddadb9c9568a3263 100644 (file)
@@ -20,11 +20,11 @@ class Model_AttributeReference : public ModelAPI_AttributeReference
 {
   Handle_TDF_Reference myRef; ///< references to the feature label
 public:
-  /// Defines the feature referenced from this attribute
-  MODEL_EXPORT virtual void setValue(FeaturePtr theFeature);
+  /// Defines the object referenced from this attribute
+  MODEL_EXPORT virtual void setValue(ObjectPtr theObject);
 
-  /// Returns feature referenced from this attribute
-  MODEL_EXPORT virtual FeaturePtr value();
+  /// Returns object referenced from this attribute
+  MODEL_EXPORT virtual ObjectPtr value();
 
 protected:
   /// Objects are created for features automatically
index fb8e67a06bc85c8ad3e1900531947123a0f9b586..244eb0314369cb483d1403c1b5700853c66b4036 100644 (file)
@@ -456,6 +456,29 @@ FeaturePtr Model_Document::feature(TDF_Label& theLabel)
   return FeaturePtr(); // not found
 }
 
+ObjectPtr Model_Document::object(TDF_Label& theLabel)
+{
+  // iterate all features, may be optimized later by keeping labels-map
+  std::vector<ObjectPtr>& aVec = myObjs[ModelAPI_Feature::group()];
+  vector<ObjectPtr>::iterator aFIter = aVec.begin();
+  for(; aFIter != aVec.end(); aFIter++) {
+    boost::shared_ptr<Model_Data> aData = 
+      boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
+    if (aData->label().IsEqual(theLabel))
+      return *aFIter;
+    list<boost::shared_ptr<ModelAPI_Result> >& aResults = 
+      boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter)->results();
+    list<boost::shared_ptr<ModelAPI_Result> >::iterator aRIter = aResults.begin();
+    for(; aRIter != aResults.end(); aRIter++) {
+      boost::shared_ptr<Model_Data> aResData = 
+        boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
+      if (aResData->label().IsEqual(theLabel))
+        return *aRIter;
+    }
+  }
+  return FeaturePtr(); // not found
+}
+
 boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
 {
   // just store sub-document identifier here to manage it later
index f0bc738451488ad11bfb24feba474990054ce24a..fb6268b733d314c8d97184420d752c3ab481f509 100644 (file)
@@ -72,6 +72,10 @@ public:
   //! \param theLabel base label of the feature
   MODEL_EXPORT virtual FeaturePtr feature(TDF_Label& theLabel);
 
+  //! Returns the existing object: result or feature
+  //! \param theLabel base label of the object
+  MODEL_EXPORT virtual ObjectPtr object(TDF_Label& theLabel);
+
   //! Adds a new sub-document by the identifier, or returns existing one if it is already exist
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
 
index 0700c826bc38d44975aac980f11cc1ddf5bae8e1..28048664e146ce06f0ca7211688d565a4dc302e0 100644 (file)
@@ -36,10 +36,10 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   for(; aDIter != aDocs.end(); aDIter++) {
     int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group());
     for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = 
-        boost::dynamic_pointer_cast<ModelAPI_Feature>((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
+      boost::shared_ptr<ModelAPI_Object> aFeature = boost::dynamic_pointer_cast<ModelAPI_Object>
+        ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex));
       if (aFeature)
-        updateFeature(aFeature);
+        updateObject(aFeature);
     }
   }
   myUpdated.clear();
@@ -48,42 +48,46 @@ void Model_Update::processEvent(const Events_Message* theMessage)
   Events_Loop::loop()->flush(EVENT_DISP);
 }
 
-bool Model_Update::updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
 {
   // check it is already processed
-  if (myUpdated.find(theFeature) != myUpdated.end())
-    return myUpdated[theFeature];
+  if (myUpdated.find(theObject) != myUpdated.end())
+    return myUpdated[theObject];
   // check all features this feature depended on (recursive call of updateFeature)
-  bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end();
-  // references
-  list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = 
-    theFeature->data()->attributes(ModelAPI_AttributeReference::type());
-  list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
-  for(; aRefsIter != aRefs.end(); aRefsIter++) {
-    boost::shared_ptr<ModelAPI_Feature> aSub =
-      boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
-    if (aSub && aSub != theFeature && updateFeature(aSub))
-      aMustbeUpdated = true;
-  }
-  // lists of references
-  aRefs = theFeature->data()->attributes(ModelAPI_AttributeRefList::type());
-  for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
-    list<FeaturePtr> aListRef = 
-      boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
-    list<FeaturePtr>::iterator aListIter = aListRef.begin();
-    for(; aListIter != aListRef.end(); aListIter++) {
-      boost::shared_ptr<ModelAPI_Feature> aSub = *aListIter;
-      if (aSub && updateFeature(aSub))
+  bool anExecute = myInitial.find(theObject) != myInitial.end();
+  bool aMustbeUpdated = myInitial.find(theObject) != myInitial.end();
+  FeaturePtr aRealFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (aRealFeature) { // only real feature contains references to other objects
+    // references
+    list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = 
+      theObject->data()->attributes(ModelAPI_AttributeReference::type());
+    list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
+    for(; aRefsIter != aRefs.end(); aRefsIter++) {
+      boost::shared_ptr<ModelAPI_Object> aSub =
+        boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
+      if (aSub && aSub != theObject && updateObject(aSub))
         aMustbeUpdated = true;
     }
+    // lists of references
+    aRefs = theObject->data()->attributes(ModelAPI_AttributeRefList::type());
+    for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+      list<ObjectPtr> aListRef = 
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
+      list<ObjectPtr>::iterator aListIter = aListRef.begin();
+      for(; aListIter != aListRef.end(); aListIter++) {
+        boost::shared_ptr<ModelAPI_Object> aSub = *aListIter;
+        if (aSub && updateObject(aSub))
+          aMustbeUpdated = true;
+      }
+    }
+    // execute feature if it must be updated
+    anExecute = aMustbeUpdated || anExecute;
+    if (anExecute) {
+      aRealFeature->execute();
+      static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      ModelAPI_EventCreator::get()->sendUpdated(theObject, EVENT_DISP);
+    }
   }
-  // execute feature if it must be updated
-  bool anExecute = aMustbeUpdated || myInitial.find(theFeature) != myInitial.end();
-  if (anExecute) {
-    theFeature->execute();
-    static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-    ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
-  }
-  myUpdated[theFeature] = anExecute;
+  myUpdated[theObject] = anExecute;
   return anExecute;
 }
index 3d5e58a01b601bc31397feca4017bfb52ef673b6..f59d891f78609c6cc067908da3eeb02893893e0a 100644 (file)
@@ -32,9 +32,9 @@ public:
   MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
 
 protected:
-  /// Recoursively checks and updates the feature if needed
-  /// Returns true if feature was updated.
-  bool updateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  /// Recoursively checks and updates the object if needed
+  /// Returns true if object was updated.
+  bool updateObject(boost::shared_ptr<ModelAPI_Object> theObject);
 };
 
 #endif
index a16813609520877f62af3b2e996f96486cff5b65..e2b425f0d76915baf6440017dceb5fcb67f34d83 100644 (file)
@@ -17,8 +17,8 @@
 class ModelAPI_AttributeRefAttr : public ModelAPI_Attribute
 {
 public:
-  /// Returns true if this attribute references to a feature (not to the attribute)
-  MODELAPI_EXPORT virtual bool isFeature() = 0;
+  /// Returns true if this attribute references to a object (not to the attribute)
+  MODELAPI_EXPORT virtual bool isObject() = 0;
 
   /// Defines the reference to the attribute
   MODELAPI_EXPORT virtual void setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
@@ -26,11 +26,11 @@ public:
   /// Returns attribute referenced from this attribute
   MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr() = 0;
 
-  /// Defines the reference to the feature
-  MODELAPI_EXPORT virtual void setFeature(FeaturePtr theFeature) = 0;
+  /// Defines the reference to the object
+  MODELAPI_EXPORT virtual void setObject(ObjectPtr theFeature) = 0;
 
-  /// Returns feature referenced from this attribute
-  MODELAPI_EXPORT virtual FeaturePtr feature() = 0;
+  /// Returns object referenced from this attribute
+  MODELAPI_EXPORT virtual ObjectPtr object() = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string type() {return "RefAttr";}
index 87800fb3660d0ab102944894dc0093aaf5295138..b897c1b4250e173bb3591bdd0ac425b330f07ff5 100644 (file)
@@ -24,16 +24,16 @@ public:
   MODELAPI_EXPORT virtual std::string attributeType() {return type();}
 
   /// Appends the feature to the end of a list
-  MODELAPI_EXPORT virtual void append(FeaturePtr theFeature) = 0;
+  MODELAPI_EXPORT virtual void append(ObjectPtr theObject) = 0;
 
   /// Erases the first meet of the feature in the list
-  MODELAPI_EXPORT virtual void remove(FeaturePtr theFeature) = 0;
+  MODELAPI_EXPORT virtual void remove(ObjectPtr theObject) = 0;
 
   /// Returns number of features in the list
   MODELAPI_EXPORT virtual int size() = 0;
 
   /// Returns the list of features
-  MODELAPI_EXPORT virtual std::list<FeaturePtr > list() = 0;
+  MODELAPI_EXPORT virtual std::list<ObjectPtr > list() = 0;
 
 protected:
   /// Objects are created for features automatically
index 0af5898ff69c29fb97b555fc619e81e17b754929..89e24798e1a9f085cab44838051d7338371154eb 100644 (file)
 class ModelAPI_AttributeReference : public ModelAPI_Attribute
 {
 public:
-  /// Defines the feature referenced from this attribute
-  MODELAPI_EXPORT virtual void setValue(FeaturePtr theFeature) = 0;
+  /// Defines the object referenced from this attribute
+  MODELAPI_EXPORT virtual void setValue(ObjectPtr theObject) = 0;
 
-  /// Returns feature referenced from this attribute
-  MODELAPI_EXPORT virtual FeaturePtr value() = 0;
+  /// Returns object referenced from this attribute
+  MODELAPI_EXPORT virtual ObjectPtr value() = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string type() {return "Reference";}
index 68f34b00b2f6582cce4ba5b9c59237e1d0bcaff9..3526f9db125b0f78fc45fd7dc6847071fdb76b9b 100644 (file)
@@ -34,7 +34,7 @@ void PartSetPlugin_Duplicate::initAttributes()
     if (aSource) {
       boost::shared_ptr<ModelAPI_Document> aCopy = 
         aPManager->copy(aSource->data()->docRef(PART_ATTR_DOC_REF)->value(), data()->name());
-      aRef->setFeature(aSource);
+      aRef->setObject(aSource);
     }
   }
 }
index faa2d7b62270e966b31fd6b295149e2111d4628d..fb5b37b4c448bd1ba7294f4e94633fe34274986f 100644 (file)
@@ -104,7 +104,7 @@ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
   if (anAttr)
-    aFeature = anAttr->feature();
+    aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
 
   if (aFeature && aFeature->getKind() == SKETCH_POINT_KIND)
     aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
index 71a35c4f189624649c2501a7f66d36799a437ad2..a2f84ae1b9e0427db63d888428fe5cc106f65475 100644 (file)
@@ -33,7 +33,7 @@ void SketchPlugin_ConstraintLength::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
-    FeaturePtr aFeature = aRef->feature();
+    ObjectPtr aFeature = aRef->object();
     if (aFeature) {
       // set length value
       boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
@@ -62,7 +62,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = anAttr->feature();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
   if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
     return thePrevious;
 
index 85d34d9c7bcff9b1421d9e8b2bcf5e650e3ca682..450e0c6682f2ce6fde8f8bd6e6b695a18a6880d0 100644 (file)
@@ -41,13 +41,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
-  if (!anAttr1 || !anAttr1->isFeature() || 
-      !anAttr2 || !anAttr2->isFeature())
+  if (!anAttr1 || !anAttr1->isObject() || 
+      !anAttr2 || !anAttr2->isObject())
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
   if (!aLine1Feature || !aLine2Feature)
     return thePrevious;
 
index ddd8308586b14f0554ff808e5de256858b43c796..f9764c90bfc0b061a256af5dd3a01af9220f72ba 100644 (file)
@@ -41,13 +41,13 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 = 
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
-  if (!anAttr1 || !anAttr1->isFeature() || 
-      !anAttr2 || !anAttr2->isFeature())
+  if (!anAttr1 || !anAttr1->isObject() || 
+      !anAttr2 || !anAttr2->isObject())
     return thePrevious;
   boost::shared_ptr<SketchPlugin_Line> aLine1Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
   boost::shared_ptr<SketchPlugin_Line> aLine2Feature = 
-    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+    boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
   if (!aLine1Feature || !aLine2Feature)
     return thePrevious;
 
index 65ab125b5474f361543530bdc5dd2a79539e0ac0..8dcb9393b2770acf9da1749e7d42c0cdddd7d575 100644 (file)
@@ -37,7 +37,7 @@ void SketchPlugin_ConstraintRadius::execute()
 
     boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
-    FeaturePtr aFeature = aRef->feature();
+    FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
     if (aFeature) {
       double aRadius = 0;
       boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
@@ -73,7 +73,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
   if (!anAttr)
     return thePrevious;
-  FeaturePtr aFeature = anAttr->feature();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
   std::string aKind = aFeature ? aFeature->getKind() : "";
   if (aKind != SKETCH_CIRCLE_KIND && aKind != SKETCH_ARC_KIND)
     return thePrevious;
@@ -130,7 +130,7 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
 
   boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
     boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(CONSTRAINT_ATTR_ENTITY_A));
-  FeaturePtr aFeature = aRef->feature();
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
   if (!aFeature)
     return;
   std::string aCenterAttrName;
index 99d5684d36fdd6d307cbce0e2e84b0c7007b49ba..e00ffdd351c81b1aaeb9aba55ebced4d3ef57745 100644 (file)
@@ -20,9 +20,9 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
       boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
         dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object("Construction", a));
       if (aSketch) {
-        std::list<FeaturePtr > aList = 
+        std::list<ObjectPtr> aList = 
           aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
-        std::list<FeaturePtr >::iterator aSub = aList.begin();
+        std::list<ObjectPtr>::iterator aSub = aList.begin();
         for(; aSub != aList.end(); aSub++) {
           if ((*aSub)->data()->isEqual(data())) {
             mySketch = aSketch.get();
index 0189bf561d443750adeb8b0746b4857b58db3876..9874ec763a0fa30a7202ec30ee597a78acc23a18 100644 (file)
@@ -64,13 +64,11 @@ void SketchPlugin_Sketch::execute()
   boost::shared_ptr<GeomDataAPI_Dir> aNorm = 
     boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
 
-  std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
+  std::list<ObjectPtr> aFeatures = aRefList->list();
   if (aFeatures.empty())
     return ;
 
-  std::list<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
-                                                                  aLast = aFeatures.end();
-
+  std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
   boost::shared_ptr<SketchPlugin_Feature> aFeature;
   std::list< boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
   for (; anIt != aLast; anIt++) {
index 67a177038088fffb546b35af925fa8483aab67e6..1490a091cc6403b7bde5b41d86ca58c4666fc316 100644 (file)
@@ -104,9 +104,10 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
       if (!anAttr) continue;
-      if (anAttr->isFeature() && anAttr->feature())
+      if (anAttr->isObject() && anAttr->object())
       { // verify posiible entities
-        const std::string& aKind = anAttr->feature()->getKind();
+        const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
+          (anAttr->object())->getKind();
         if (aKind.compare(SKETCH_POINT_KIND) == 0)
         {
           myAttributesList[aNbPoints++] = CONSTRAINT_ATTRIBUTES[indAttr];
@@ -159,8 +160,9 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
       if (!anAttr) continue;
-      if (anAttr->isFeature() && anAttr->feature() &&
-          anAttr->feature()->getKind().compare(SKETCH_LINE_KIND) == 0)
+      if (anAttr->isObject() && anAttr->object() &&
+        boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object())->getKind().
+        compare(SKETCH_LINE_KIND) == 0)
       {
         myAttributesList[aNbLines++] = CONSTRAINT_ATTRIBUTES[indAttr];
         break;
@@ -183,8 +185,9 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
-      if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
-      const std::string& aKind = anAttr->feature()->getKind();
+      if (!anAttr || !anAttr->isObject() || !anAttr->object()) continue;
+      const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
+        (anAttr->object())->getKind();
       if (aKind.compare(SKETCH_LINE_KIND) == 0)
       {
         myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
@@ -206,8 +209,9 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
-      if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
-      const std::string& aKind = anAttr->feature()->getKind();
+      if (!anAttr || !anAttr->isObject() || !anAttr->object()) continue;
+      const std::string& aKind = boost::dynamic_pointer_cast<ModelAPI_Feature>
+        (anAttr->object())->getKind();
       if (aKind.compare(SKETCH_CIRCLE_KIND) == 0 || aKind.compare(SKETCH_ARC_KIND) == 0)
       {
         myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
index 29d21da0a7f25c411c3ef5640e7d725bbc947453..954c6c5963fb779fba5116bbe9132eab4e6cba89 100644 (file)
@@ -121,11 +121,12 @@ bool SketchSolver_ConstraintGroup::isInteract(
         theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[i])
       );
     if (!aCAttrRef) continue;
-    if (!aCAttrRef->isFeature() && 
+    if (!aCAttrRef->isObject() && 
         myEntityAttrMap.find(aCAttrRef->attr()) != myEntityAttrMap.end())
       return true;
-    if (aCAttrRef->isFeature() && 
-        myEntityFeatMap.find(aCAttrRef->feature()) != myEntityFeatMap.end())
+    if (aCAttrRef->isObject() && 
+        myEntityFeatMap.find(boost::dynamic_pointer_cast<ModelAPI_Feature>(aCAttrRef->object())) 
+        != myEntityFeatMap.end())
       return true;
   }
 
@@ -193,14 +194,15 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
     // For the length constraint the start and end points of the line should be added to the entities list instead of line
     if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
     {
-      boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->feature()->data();
+      boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->object()->data();
       aConstrEnt[indAttr]   = changeEntity(aData->attribute(LINE_ATTR_START));
       aConstrEnt[indAttr+1] = changeEntity(aData->attribute(LINE_ATTR_END));
-      myEntityFeatMap[aConstrAttr->feature()] = 0; // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group
+       // measured object is added into the map of objects to avoid problems with interaction betwee constraint and group
+      myEntityFeatMap[boost::dynamic_pointer_cast<ModelAPI_Feature>(aConstrAttr->object())] = 0;
       break; // there should be no other entities
     }
-    else if (aConstrAttr->isFeature())
-      aConstrEnt[indAttr] = changeEntity(aConstrAttr->feature());
+    else if (aConstrAttr->isObject())
+      aConstrEnt[indAttr] = changeEntity(boost::dynamic_pointer_cast<ModelAPI_Feature>(aConstrAttr->object()));
     else
       aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr());
   }
@@ -1142,7 +1144,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints(
       bool isUpd = (*anAttrIter == theEntity);
       boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr = 
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
-      if (aRefAttr && !aRefAttr->isFeature() && aRefAttr->attr() == theEntity)
+      if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theEntity)
         isUpd = true;
 
       if (isUpd)
@@ -1171,7 +1173,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints(
     {
       boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr = 
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
-      if (aRefAttr && aRefAttr->isFeature() && aRefAttr->feature() == theFeature)
+      if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == theFeature)
       {
         static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
         ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent);
index 41de682cb5f7b27f40d08449843be79b0d8f7b42..0ff4507b854c0b690a2f05a20b8439459baf36c9 100644 (file)
@@ -352,8 +352,8 @@ boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
 
     boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SKETCH_ATTR_FEATURES));
-    std::list< FeaturePtr > aFeaturesList = aWPFeatures->list();
-    std::list< FeaturePtr >::const_iterator anIter;
+    std::list< ObjectPtr >& aFeaturesList = aWPFeatures->list();
+    std::list< ObjectPtr >::const_iterator anIter;
     for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++)
       if (*anIter == theConstraint)
         return aWP; // workplane is found