From 8b714c0bc3795b0a18977d2fdefbe741a8ef10c0 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 14 Jul 2014 11:47:50 +0400 Subject: [PATCH] Updated the references attributes --- .../FeaturesPlugin_Extrusion.cpp | 5 +- src/Model/Model_AttributeRefAttr.cpp | 24 +++---- src/Model/Model_AttributeRefAttr.h | 12 ++-- src/Model/Model_AttributeRefList.cpp | 14 ++-- src/Model/Model_AttributeRefList.h | 6 +- src/Model/Model_AttributeReference.cpp | 10 +-- src/Model/Model_AttributeReference.h | 8 +-- src/Model/Model_Document.cpp | 23 ++++++ src/Model/Model_Document.h | 4 ++ src/Model/Model_Update.cpp | 72 ++++++++++--------- src/Model/Model_Update.h | 6 +- src/ModelAPI/ModelAPI_AttributeRefAttr.h | 12 ++-- src/ModelAPI/ModelAPI_AttributeRefList.h | 6 +- src/ModelAPI/ModelAPI_AttributeReference.h | 8 +-- src/PartSetPlugin/PartSetPlugin_Duplicate.cpp | 2 +- .../SketchPlugin_ConstraintDistance.cpp | 2 +- .../SketchPlugin_ConstraintLength.cpp | 4 +- .../SketchPlugin_ConstraintParallel.cpp | 8 +-- .../SketchPlugin_ConstraintPerpendicular.cpp | 8 +-- .../SketchPlugin_ConstraintRadius.cpp | 6 +- src/SketchPlugin/SketchPlugin_Feature.cpp | 4 +- src/SketchPlugin/SketchPlugin_Sketch.cpp | 6 +- src/SketchSolver/SketchSolver_Constraint.cpp | 20 +++--- .../SketchSolver_ConstraintGroup.cpp | 20 +++--- .../SketchSolver_ConstraintManager.cpp | 4 +- 25 files changed, 163 insertions(+), 131 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index e89d50352..31fbe2cc1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -33,11 +33,8 @@ void FeaturesPlugin_Extrusion::execute() boost::dynamic_pointer_cast(data()->attribute(EXTRUSION_FACE)); if (!aFaceRef) return; - FeaturePtr aFaceFeature = aFaceRef->value(); - if (!aFaceFeature) - return; boost::shared_ptr aConstr = - boost::dynamic_pointer_cast(aFaceFeature->firstResult()); + boost::dynamic_pointer_cast(aFaceRef->value()); if (!aConstr) return; boost::shared_ptr aFace = aConstr->shape(); diff --git a/src/Model/Model_AttributeRefAttr.cpp b/src/Model/Model_AttributeRefAttr.cpp index 24bcddec1..77a89ba40 100644 --- a/src/Model/Model_AttributeRefAttr.cpp +++ b/src/Model/Model_AttributeRefAttr.cpp @@ -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 theAt boost::shared_ptr aData = boost::dynamic_pointer_cast(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 theAt boost::shared_ptr Model_AttributeRefAttr::attr() { - FeaturePtr aFeature = feature(); - if (aFeature) { + ObjectPtr anObj = object(); + if (anObj) { boost::shared_ptr aData = - boost::dynamic_pointer_cast(aFeature->data()); + boost::dynamic_pointer_cast(anObj->data()); return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString()); } // not initialized return boost::shared_ptr(); } -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 aData = - boost::dynamic_pointer_cast(theFeature->data()); + boost::dynamic_pointer_cast(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 aDoc = boost::dynamic_pointer_cast(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) diff --git a/src/Model/Model_AttributeRefAttr.h b/src/Model/Model_AttributeRefAttr.h index 69fda0163..273cfd544 100644 --- a/src/Model/Model_AttributeRefAttr.h +++ b/src/Model/Model_AttributeRefAttr.h @@ -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 theAttr); @@ -32,11 +32,11 @@ public: /// Returns attribute referenced from this attribute MODEL_EXPORT virtual boost::shared_ptr 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 diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index cc19ba6ca..0a6eee7c4 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -10,19 +10,19 @@ using namespace std; -void Model_AttributeRefList::append(FeaturePtr theFeature) +void Model_AttributeRefList::append(ObjectPtr theObject) { boost::shared_ptr aData = - boost::dynamic_pointer_cast(theFeature->data()); + boost::dynamic_pointer_cast(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 aData = - boost::dynamic_pointer_cast(theFeature->data()); + boost::dynamic_pointer_cast(theObject->data()); myRef->Remove(aData->label()); owner()->data()->sendAttributeUpdated(this); @@ -33,15 +33,15 @@ int Model_AttributeRefList::size() return myRef->Extent(); } -list Model_AttributeRefList::list() +list Model_AttributeRefList::list() { - std::list< FeaturePtr > aResult; + std::list< ObjectPtr > aResult; boost::shared_ptr aDoc = boost::dynamic_pointer_cast(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; diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index 340f5cdf0..7f797e2de 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -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 list(); + MODEL_EXPORT virtual std::list list(); protected: /// Objects are created for features automatically diff --git a/src/Model/Model_AttributeReference.cpp b/src/Model/Model_AttributeReference.cpp index e2ff01ce7..9cfd4a91c 100644 --- a/src/Model/Model_AttributeReference.cpp +++ b/src/Model/Model_AttributeReference.cpp @@ -10,11 +10,11 @@ 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 aData = - boost::dynamic_pointer_cast(theFeature->data()); + boost::dynamic_pointer_cast(theObject->data()); if (myRef.IsNull()) { boost::shared_ptr aMyData = boost::dynamic_pointer_cast(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 aDoc = boost::dynamic_pointer_cast(owner()->document()); if (aDoc) { TDF_Label aRefLab = myRef->Get(); - return aDoc->feature(aRefLab); + return aDoc->object(aRefLab); } } // not initialized diff --git a/src/Model/Model_AttributeReference.h b/src/Model/Model_AttributeReference.h index 6406d0bfb..822225500 100644 --- a/src/Model/Model_AttributeReference.h +++ b/src/Model/Model_AttributeReference.h @@ -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 diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index fb8e67a06..244eb0314 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -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& aVec = myObjs[ModelAPI_Feature::group()]; + vector::iterator aFIter = aVec.begin(); + for(; aFIter != aVec.end(); aFIter++) { + boost::shared_ptr aData = + boost::dynamic_pointer_cast((*aFIter)->data()); + if (aData->label().IsEqual(theLabel)) + return *aFIter; + list >& aResults = + boost::dynamic_pointer_cast(*aFIter)->results(); + list >::iterator aRIter = aResults.begin(); + for(; aRIter != aResults.end(); aRIter++) { + boost::shared_ptr aResData = + boost::dynamic_pointer_cast((*aRIter)->data()); + if (aResData->label().IsEqual(theLabel)) + return *aRIter; + } + } + return FeaturePtr(); // not found +} + boost::shared_ptr Model_Document::subDocument(string theDocID) { // just store sub-document identifier here to manage it later diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index f0bc73845..fb6268b73 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -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 subDocument(std::string theDocID); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 0700c826b..28048664e 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -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 aFeature = - boost::dynamic_pointer_cast((*aDIter)->object(ModelAPI_Feature::group(), aFIndex)); + boost::shared_ptr aFeature = boost::dynamic_pointer_cast + ((*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 theFeature) +bool Model_Update::updateObject(boost::shared_ptr 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 > aRefs = - theFeature->data()->attributes(ModelAPI_AttributeReference::type()); - list >::iterator aRefsIter = aRefs.begin(); - for(; aRefsIter != aRefs.end(); aRefsIter++) { - boost::shared_ptr aSub = - boost::dynamic_pointer_cast(*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 aListRef = - boost::dynamic_pointer_cast(*aRefsIter)->list(); - list::iterator aListIter = aListRef.begin(); - for(; aListIter != aListRef.end(); aListIter++) { - boost::shared_ptr 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(theObject); + if (aRealFeature) { // only real feature contains references to other objects + // references + list > aRefs = + theObject->data()->attributes(ModelAPI_AttributeReference::type()); + list >::iterator aRefsIter = aRefs.begin(); + for(; aRefsIter != aRefs.end(); aRefsIter++) { + boost::shared_ptr aSub = + boost::dynamic_pointer_cast(*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 aListRef = + boost::dynamic_pointer_cast(*aRefsIter)->list(); + list::iterator aListIter = aListRef.begin(); + for(; aListIter != aListRef.end(); aListIter++) { + boost::shared_ptr 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; } diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 3d5e58a01..f59d891f7 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -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 theFeature); + /// Recoursively checks and updates the object if needed + /// Returns true if object was updated. + bool updateObject(boost::shared_ptr theObject); }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeRefAttr.h b/src/ModelAPI/ModelAPI_AttributeRefAttr.h index a16813609..e2b425f0d 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefAttr.h +++ b/src/ModelAPI/ModelAPI_AttributeRefAttr.h @@ -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 theAttr) = 0; @@ -26,11 +26,11 @@ public: /// Returns attribute referenced from this attribute MODELAPI_EXPORT virtual boost::shared_ptr 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";} diff --git a/src/ModelAPI/ModelAPI_AttributeRefList.h b/src/ModelAPI/ModelAPI_AttributeRefList.h index 87800fb36..b897c1b42 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefList.h +++ b/src/ModelAPI/ModelAPI_AttributeRefList.h @@ -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 list() = 0; + MODELAPI_EXPORT virtual std::list list() = 0; protected: /// Objects are created for features automatically diff --git a/src/ModelAPI/ModelAPI_AttributeReference.h b/src/ModelAPI/ModelAPI_AttributeReference.h index 0af5898ff..89e24798e 100644 --- a/src/ModelAPI/ModelAPI_AttributeReference.h +++ b/src/ModelAPI/ModelAPI_AttributeReference.h @@ -16,11 +16,11 @@ 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";} diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 68f34b00b..3526f9db1 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -34,7 +34,7 @@ void PartSetPlugin_Duplicate::initAttributes() if (aSource) { boost::shared_ptr aCopy = aPManager->copy(aSource->data()->docRef(PART_ATTR_DOC_REF)->value(), data()->name()); - aRef->setFeature(aSource); + aRef->setObject(aSource); } } } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index faa2d7b62..fb5b37b4c 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -104,7 +104,7 @@ boost::shared_ptr getFeaturePoint(DataPtr theData, boost::shared_ptr anAttr = boost::dynamic_pointer_cast(theData->attribute(theAttribute)); if (anAttr) - aFeature = anAttr->feature(); + aFeature = boost::dynamic_pointer_cast(anAttr->object()); if (aFeature && aFeature->getKind() == SKETCH_POINT_KIND) aPointAttr = boost::dynamic_pointer_cast diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 71a35c4f1..a2f84ae1b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -33,7 +33,7 @@ void SketchPlugin_ConstraintLength::execute() boost::shared_ptr aRef = boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); - FeaturePtr aFeature = aRef->feature(); + ObjectPtr aFeature = aRef->object(); if (aFeature) { // set length value boost::shared_ptr aPoint1 = @@ -62,7 +62,7 @@ boost::shared_ptr SketchPlugin_ConstraintLength::getAISObject boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); if (!anAttr) return thePrevious; - FeaturePtr aFeature = anAttr->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(anAttr->object()); if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND) return thePrevious; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index 85d34d9c7..450e0c668 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -41,13 +41,13 @@ boost::shared_ptr SketchPlugin_ConstraintParallel::getAISObje boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); boost::shared_ptr anAttr2 = boost::dynamic_pointer_cast(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 aLine1Feature = - boost::dynamic_pointer_cast(anAttr1->feature()); + boost::dynamic_pointer_cast(anAttr1->object()); boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(anAttr2->feature()); + boost::dynamic_pointer_cast(anAttr2->object()); if (!aLine1Feature || !aLine2Feature) return thePrevious; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index ddd830858..f9764c90b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -41,13 +41,13 @@ boost::shared_ptr SketchPlugin_ConstraintPerpendicular::getAI boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); boost::shared_ptr anAttr2 = boost::dynamic_pointer_cast(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 aLine1Feature = - boost::dynamic_pointer_cast(anAttr1->feature()); + boost::dynamic_pointer_cast(anAttr1->object()); boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(anAttr2->feature()); + boost::dynamic_pointer_cast(anAttr2->object()); if (!aLine1Feature || !aLine2Feature) return thePrevious; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index 65ab125b5..8dcb9393b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -37,7 +37,7 @@ void SketchPlugin_ConstraintRadius::execute() boost::shared_ptr aRef = boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); - FeaturePtr aFeature = aRef->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); if (aFeature) { double aRadius = 0; boost::shared_ptr aData = aFeature->data(); @@ -73,7 +73,7 @@ boost::shared_ptr SketchPlugin_ConstraintRadius::getAISObject boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); if (!anAttr) return thePrevious; - FeaturePtr aFeature = anAttr->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(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 aRef = boost::dynamic_pointer_cast(data()->attribute(CONSTRAINT_ATTR_ENTITY_A)); - FeaturePtr aFeature = aRef->feature(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); if (!aFeature) return; std::string aCenterAttrName; diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp index 99d5684d3..e00ffdd35 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@ -20,9 +20,9 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch() boost::shared_ptr aSketch = boost:: dynamic_pointer_cast(document()->object("Construction", a)); if (aSketch) { - std::list aList = + std::list aList = aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list(); - std::list::iterator aSub = aList.begin(); + std::list::iterator aSub = aList.begin(); for(; aSub != aList.end(); aSub++) { if ((*aSub)->data()->isEqual(data())) { mySketch = aSketch.get(); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 0189bf561..9874ec763 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -64,13 +64,11 @@ void SketchPlugin_Sketch::execute() boost::shared_ptr aNorm = boost::dynamic_pointer_cast(data()->attribute(SKETCH_ATTR_NORM)); - std::list > aFeatures = aRefList->list(); + std::list aFeatures = aRefList->list(); if (aFeatures.empty()) return ; - std::list >::const_iterator anIt = aFeatures.begin(), - aLast = aFeatures.end(); - + std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); boost::shared_ptr aFeature; std::list< boost::shared_ptr > aFeaturesPreview; for (; anIt != aLast; anIt++) { diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 67a177038..1490a091c 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -104,9 +104,10 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptrdata()->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 + (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_ptrdata()->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(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( 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 + (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( 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 + (anAttr->object())->getKind(); if (aKind.compare(SKETCH_CIRCLE_KIND) == 0 || aKind.compare(SKETCH_ARC_KIND) == 0) { myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr]; diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 29d21da0a..954c6c596 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -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(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 aData = aConstrAttr->feature()->data(); + boost::shared_ptr 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(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(aConstrAttr->object())); else aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr()); } @@ -1142,7 +1144,7 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( bool isUpd = (*anAttrIter == theEntity); boost::shared_ptr aRefAttr = boost::dynamic_pointer_cast(*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 aRefAttr = boost::dynamic_pointer_cast(*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); diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 41de682cb..0ff4507b8 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -352,8 +352,8 @@ boost::shared_ptr SketchSolver_ConstraintManager::findWork boost::shared_ptr aWPFeatures = boost::dynamic_pointer_cast(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 -- 2.39.2