From: mpv Date: Wed, 22 Oct 2014 11:46:20 +0000 (+0400) Subject: Updated the selection of the sketcher faces for extrusion X-Git-Tag: V_0.5~85 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e232dbabeabd12b641f086627a7c9fa6659bab87;p=modules%2Fshaper.git Updated the selection of the sketcher faces for extrusion --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 901686539..f55ee9f5e 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +51,8 @@ boost::shared_ptr Model_AttributeSelection::value() Handle(TNaming_NamedShape) aSelection; if (myRef.myRef->Label().FindAttribute(TNaming_NamedShape::GetID(), aSelection)) { TopoDS_Shape aSelShape = aSelection->Get(); - aResult->setImpl(&aSelShape); + aResult = boost::shared_ptr(new GeomAPI_Shape); + aResult->setImpl(new TopoDS_Shape(aSelShape)); } } return aResult; @@ -97,8 +99,6 @@ void Model_AttributeSelection::selectBody( aSel.Select(aNewShape, aContext); } -#include - void Model_AttributeSelection::selectConstruction( const ResultPtr& theContext, const boost::shared_ptr& theSubShape) { @@ -114,7 +114,6 @@ void Model_AttributeSelection::selectConstruction( const TopoDS_Shape& aSubShape = theSubShape->impl(); TopTools_MapOfShape allEdges; for(TopExp_Explorer anEdgeExp(aSubShape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next()) { - BRepTools::Write(anEdgeExp.Current(), "D:\\selected.brep"); allEdges.Add(anEdgeExp.Current()); } // iterate and store the result ids of sub-elements @@ -130,7 +129,6 @@ void Model_AttributeSelection::selectConstruction( boost::dynamic_pointer_cast(*aRes); if (aConstr->shape()) { const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - BRepTools::Write(aResShape, "D:\\sub.brep"); if (allEdges.Contains(aResShape)) { boost::shared_ptr aSubData = boost::dynamic_pointer_cast(aSub->data()); TDF_Label aSubLab = aSubData->label(); @@ -139,4 +137,7 @@ void Model_AttributeSelection::selectConstruction( } } } + // store the selected as primitive + TNaming_Builder aBuilder(myRef.myRef->Label()); + aBuilder.Generated(aSubShape); } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 9ddd9f8e6..7c3633aa7 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -89,7 +90,7 @@ void Model_Update::processEvent(const boost::shared_ptr& theMess aDocs = ModelAPI_Session::get()->allOpenedDocuments(); } } - // collect all documents involved into the update + // collect all documents involved into the update process set >::iterator aFIter = myInitial.begin(); for (; aFIter != myInitial.end(); aFIter++) { aDocs.push_back((*aFIter)->document()); @@ -123,6 +124,18 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end(); if (theFeature) { // only real feature contains references to other objects if (theFeature->data()->mustBeUpdated()) aMustbeUpdated = true; + + // composite feature must be executed after sub-features execution + CompositeFeaturePtr aComposite = + boost::dynamic_pointer_cast(theFeature); + if (aComposite) { + int aSubsNum = aComposite->numberOfSubs(); + for(int a = 0; a < aSubsNum; a++) { + if (updateFeature(aComposite->subFeature(a))) + aMustbeUpdated = true; + } + } + // references list > aRefs = theFeature->data()->attributes( ModelAPI_AttributeReference::type()); @@ -166,6 +179,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) } } } + // execute feature if it must be updated if (aMustbeUpdated) { @@ -231,6 +245,11 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) bool Model_Update::updateObject(boost::shared_ptr theObject) { + if (myUpdated.find(theObject) != myUpdated.end()) + return myUpdated[theObject]; // already processed + return myInitial.find(theObject) != myInitial.end(); + + /* remove algorithm for update of all features by dependencies tree if (!theObject) return false; FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); @@ -251,4 +270,5 @@ bool Model_Update::updateObject(boost::shared_ptr theObject) if (myInitial.find(theObject) != myInitial.end()) return true; return false; // nothing is known + */ } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index c35b37ce1..b655ebe9a 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -123,7 +123,10 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_IPr SKETCHPLUGIN_EXPORT virtual boost::shared_ptr subFeature(const int theIndex) const; - protected: + /// Construction result is allways recomuted on the fly + SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;} + +protected: /// Creates a plane and append it to the list /// \param theX the X normal value /// \param theY the Y normal value