]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Updated the selection of the sketcher faces for extrusion
authormpv <mikhail.ponikarov@opencascade.com>
Wed, 22 Oct 2014 11:46:20 +0000 (15:46 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Wed, 22 Oct 2014 11:46:20 +0000 (15:46 +0400)
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Update.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index 901686539335c7f790e82502a9852d5438fd7a87..f55ee9f5e685e305a7dd8794b0e77bc01bd74467 100644 (file)
@@ -15,6 +15,7 @@
 #include <TNaming_Selector.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Tool.hxx>
+#include <TNaming_Builder.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TDataStd_ReferenceList.hxx>
 #include <TopTools_MapOfShape.hxx>
@@ -50,7 +51,8 @@ boost::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape>(new GeomAPI_Shape);
+      aResult->setImpl(new TopoDS_Shape(aSelShape));
     }
   }
   return aResult;
@@ -97,8 +99,6 @@ void Model_AttributeSelection::selectBody(
   aSel.Select(aNewShape, aContext);
 }
 
-#include <BRepTools.hxx>
-
 void Model_AttributeSelection::selectConstruction(
     const ResultPtr& theContext, const boost::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
@@ -114,7 +114,6 @@ void Model_AttributeSelection::selectConstruction(
   const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
   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<ModelAPI_ResultConstruction>(*aRes);
       if (aConstr->shape()) {
         const TopoDS_Shape& aResShape = aConstr->shape()->impl<TopoDS_Shape>();
-        BRepTools::Write(aResShape, "D:\\sub.brep");
         if (allEdges.Contains(aResShape)) {
           boost::shared_ptr<Model_Data> aSubData = boost::dynamic_pointer_cast<Model_Data>(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);
 }
index 9ddd9f8e63d8e6847fa8f5ef1d90122bd0fcf325..7c3633aa78bb78c9b3f0ece80b194676a3aaa0dd 100644 (file)
@@ -13,6 +13,7 @@
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Result.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_CompositeFeature.h>
 #include <Events_Loop.h>
 #include <Events_LongOp.h>
 #include <Events_Error.h>
@@ -89,7 +90,7 @@ void Model_Update::processEvent(const boost::shared_ptr<Events_Message>& theMess
       aDocs = ModelAPI_Session::get()->allOpenedDocuments();
     }
   }
-  // collect all documents involved into the update
+  // collect all documents involved into the update process
   set<boost::shared_ptr<ModelAPI_Object> >::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<ModelAPI_CompositeFeature>(theFeature);
+    if (aComposite) {
+      int aSubsNum = aComposite->numberOfSubs();
+      for(int a = 0; a < aSubsNum; a++) {
+        if (updateFeature(aComposite->subFeature(a)))
+          aMustbeUpdated = true;
+      }
+    }
+
     // references
     list<boost::shared_ptr<ModelAPI_Attribute> > 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<ModelAPI_Object> 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<ModelAPI_Feature>(theObject);
@@ -251,4 +270,5 @@ bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
   if (myInitial.find(theObject) != myInitial.end())
     return true;
   return false;  // nothing is known
+  */
 }
index c35b37ce1f3cb0b97badfa985f62db8310460d04..b655ebe9a09dc9512253f49233c18ef71198d413 100644 (file)
@@ -123,7 +123,10 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_IPr
   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> 
     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