]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' into cgt/devCEA
authorClarisse Genrault <clarisse.genrault@cea.fr>
Thu, 12 Jan 2017 11:24:48 +0000 (12:24 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Thu, 12 Jan 2017 11:24:48 +0000 (12:24 +0100)
14 files changed:
env_linux.sh
src/Model/Model_AttributeSelection.cpp
src/Model/Model_BodyBuilder.cpp
src/Model/Model_Document.cpp
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/ModelAPI/ModelAPI_Session.h
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/PythonAPI/model/sketcher/__init__.py
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/Test1924.py [new file with mode: 0644]
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp

index 5fad007a8485d1f71939910f7e367da2fa8add0f..ac90d7b01bc99e90c451d50aad070411617023ef 100644 (file)
@@ -43,8 +43,8 @@ export PATH=${CPPLINT_ROOT_DIR}:${PATH}
 
 #------ OCCT ------
 # Defaults
-export CSF_PluginDefaults=${CAS_ROOT_DIR}/src/StdResource
-export CSF_StandardDefaults=${CAS_ROOT_DIR}/src/StdResource
+export CSF_PluginDefaults=${CAS_ROOT_DIR}/share/opencascade/resources
+export CSF_StandardDefaults=${CAS_ROOT_DIR}/share/opencascade/resources
 # For CMake
 export LIB=${LD_LIBRARY_PATH}
 export PATH=${CASROOT}:${PATH}
index 8391d72f551a6f083722c39e003b7b065145bcb6..8fc2d5e77296ff285f37c758a5a1bafae4262cea 100644 (file)
@@ -929,10 +929,8 @@ void Model_AttributeSelection::selectConstruction(
     }
   }
   // store the selected as primitive
-  TNaming_Builder aBuilder(selectionLabel());
-  aBuilder.Generated(aSubShape);
-    registerSubShape(
-      selectionLabel(), aSubShape, 0, aContextFeature, aMyDoc, anOrientations, aSubNames, aRefs);
+  registerSubShape(
+    selectionLabel(), aSubShape, 0, aContextFeature, aMyDoc, anOrientations, aSubNames, aRefs);
 }
 
 bool Model_AttributeSelection::selectPart(
@@ -1156,6 +1154,8 @@ void Model_AttributeSelection::updateInHistory()
   // that this one and is really modifies the referenced result to refer to it
   ResultPtr aModifierResFound;
   TNaming_Iterator aPairIter(aContNS);
+  if (!aPairIter.More())
+    return;
   TopoDS_Shape aNewShape = aPairIter.NewShape();
   bool anIterate = true;
   // trying to update also the sub-shape selected
index 38b1543485ada04f857505b35b742b7109ee447d..2136750ba1dd6d235c3b928bad970039fcdd434f 100755 (executable)
@@ -72,24 +72,25 @@ static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) {
       aShapePairs.push_front(std::pair<TopoDS_Shape, TopoDS_Shape>
         (anIter.OldShape(), anIter.NewShape()));
     }
-  }
-  // create new
-  TNaming_Builder aBuilder(theLab);
-  TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
-  std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter = aShapePairs.begin();
-  for(; aPairsIter != aShapePairs.end(); aPairsIter++) {
-    if (theFlag) { // disabled => make selection
-      aBuilder.Select(aPairsIter->second, aPairsIter->first);
-    } else if (anEvol == TNaming_GENERATED) {
-      aBuilder.Generated(aPairsIter->first, aPairsIter->second);
-    } else if (anEvol == TNaming_MODIFY) {
-      aBuilder.Modify(aPairsIter->first, aPairsIter->second);
-    } else if (anEvol == TNaming_DELETE) {
-      aBuilder.Delete(aPairsIter->first);
-    } else if (anEvol == TNaming_PRIMITIVE) {
-      aBuilder.Generated(aPairsIter->second);
-    } else if (anEvol == TNaming_SELECTED) {
-      aBuilder.Select(aPairsIter->second, aPairsIter->first);
+
+    // create new
+    TNaming_Builder aBuilder(theLab);
+    TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution);
+    std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter = aShapePairs.begin();
+    for(; aPairsIter != aShapePairs.end(); aPairsIter++) {
+      if (theFlag) { // disabled => make selection
+        aBuilder.Select(aPairsIter->second, aPairsIter->first);
+      } else if (anEvol == TNaming_GENERATED) {
+        aBuilder.Generated(aPairsIter->first, aPairsIter->second);
+      } else if (anEvol == TNaming_MODIFY) {
+        aBuilder.Modify(aPairsIter->first, aPairsIter->second);
+      } else if (anEvol == TNaming_DELETE) {
+        aBuilder.Delete(aPairsIter->first);
+      } else if (anEvol == TNaming_PRIMITIVE) {
+        aBuilder.Generated(aPairsIter->second);
+      } else if (anEvol == TNaming_SELECTED) {
+        aBuilder.Select(aPairsIter->second, aPairsIter->first);
+      }
     }
   }
   // recursive call for all sub-labels
index 4311f40f6580f05393d19b6690c9a7711bc75af0..2afecb39cd95f5bf52190e1406dbd35a83f3c6ce 100755 (executable)
@@ -38,6 +38,7 @@
 #include <TDF_ListIteratorOfLabelList.hxx>
 #include <TDF_LabelMap.hxx>
 #include <TDF_DeltaOnAddition.hxx>
+#include <TNaming_Builder.hxx>
 #include <TNaming_SameShapeIterator.hxx>
 #include <TNaming_Iterator.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -196,6 +197,51 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
   if (!isError) {
     myDoc = aLoaded;
     myDoc->SetUndoLimit(UNDO_LIMIT);
+
+    // TODO: remove after fix in OCCT.
+    // All named shapes are stored in reversed order, so to fix this we reverse them back.
+    for(TDF_ChildIDIterator aChildIter(myDoc->Main(), TNaming_NamedShape::GetID(), true);
+        aChildIter.More();
+        aChildIter.Next()) {
+      Handle(TNaming_NamedShape) aNamedShape =
+        Handle(TNaming_NamedShape)::DownCast(aChildIter.Value());
+      if (aNamedShape.IsNull()) {
+        continue;
+      }
+
+      TopoDS_Shape aShape = aNamedShape->Get();
+      if(aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND) {
+        continue;
+      }
+
+      TNaming_Evolution anEvol = aNamedShape->Evolution();
+      std::list<std::pair<TopoDS_Shape, TopoDS_Shape> > aShapePairs; // to store old and new shapes
+      for(TNaming_Iterator anIter(aNamedShape); anIter.More(); anIter.Next()) {
+        aShapePairs.push_back(
+          std::pair<TopoDS_Shape, TopoDS_Shape>(anIter.OldShape(), anIter.NewShape()));
+      }
+
+      // Add in reverse order.
+      TDF_Label aLabel = aNamedShape->Label();
+      TNaming_Builder aBuilder(aLabel);
+      for(std::list<std::pair<TopoDS_Shape, TopoDS_Shape> >::iterator aPairsIter =
+            aShapePairs.begin();
+          aPairsIter != aShapePairs.end();
+          aPairsIter++) {
+        if (anEvol == TNaming_GENERATED) {
+          aBuilder.Generated(aPairsIter->first, aPairsIter->second);
+        } else if (anEvol == TNaming_MODIFY) {
+          aBuilder.Modify(aPairsIter->first, aPairsIter->second);
+        } else if (anEvol == TNaming_DELETE) {
+          aBuilder.Delete(aPairsIter->first);
+        } else if (anEvol == TNaming_PRIMITIVE) {
+          aBuilder.Generated(aPairsIter->second);
+        } else if (anEvol == TNaming_SELECTED) {
+          aBuilder.Select(aPairsIter->second, aPairsIter->first);
+        }
+      }
+    }
+
     // to avoid the problem that feature is created in the current, not this, document
     aSession->setActiveDocument(anApp->document(myID), false);
     aSession->setCheckTransactions(false);
index 5bb981ea3b907559f97d3f920e5dbec30fde4a5d..9d13485f3d8a1fed152f50aef9875fab175c676a 100644 (file)
@@ -473,22 +473,3 @@ int Model_Session::transactionID()
 {
   return ROOT_DOC->transactionID();
 }
-
-void Model_Session::forceLoadPlugin(const std::string& thePluginName)
-{
-  // load all information about plugins, features and attributes
-  LoadPluginsInfo();
-
-  // store name of current plugin for further restoring,
-  // because forceLoadPlugin may be called while loading another plugin
-  std::string aCurrentPluginName = myCurrentPluginName;
-
-  myCurrentPluginName = thePluginName;
-  if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) {
-    // load plugin library if not yet done
-    Config_ModuleReader::loadPlugin(myCurrentPluginName);
-  }
-
-  // restore current plugin
-  myCurrentPluginName = aCurrentPluginName;
-}
index d9f9f2c2d0b63d450257463beeaf9d9be0f4deb2..2afa84a26b292305e6aa4c143f7bd792028cf110 100644 (file)
@@ -128,9 +128,6 @@ class Model_Session : public ModelAPI_Session, public Events_Listener
   /// Returns the global identifier of the current transaction (needed for the update algo)
   MODEL_EXPORT virtual int transactionID();
 
-  /// Load plugin by its name
-  MODEL_EXPORT virtual void forceLoadPlugin(const std::string& thePluginName);
-
  protected:
   /// Loads (if not done yet) the information about the features and plugins
   void LoadPluginsInfo();
index cc6987bd3653898a99c96d804776d1465d37fdff..40984fb03469e9981ef4db83520a3a21f43b5cb3 100644 (file)
@@ -115,9 +115,6 @@ class MODELAPI_EXPORT ModelAPI_Session
   /// Returns the global identifier of the current transaction (needed for the update algo)
   virtual int transactionID() = 0;
 
-  /// Load plugin by its name
-  virtual void forceLoadPlugin(const std::string& thePluginName) = 0;
-
  protected:
   /// Sets the session interface implementation (once per application launch)
   static void setSession(std::shared_ptr<ModelAPI_Session> theManager);
index c32d2ed7f9ed25204b690d5c5b86f683131d9bd2..f3b96003e9e1a4a950719095161f755e36260f2b 100644 (file)
@@ -915,13 +915,24 @@ ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
   theDumper.myDumpBuffer << theEndl;
 
   if (!theDumper.myEntitiesStack.empty()) {
-    // Name for composite feature is dumped when all sub-entities are dumped
-    // (see method ModelHighAPI_Dumper::processSubs).
-    const ModelHighAPI_Dumper::LastDumpedEntity& aLastDumped = theDumper.myEntitiesStack.top();
-    CompositeFeaturePtr aComposite =
-        std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aLastDumped.myEntity);
-    if (!aComposite)
-      theDumper.dumpEntitySetName();
+    bool isCopy;
+    // all copies have been stored into stack, pop them all
+    do {
+      isCopy = false;
+      // Name for composite feature is dumped when all sub-entities are dumped
+      // (see method ModelHighAPI_Dumper::processSubs).
+      const ModelHighAPI_Dumper::LastDumpedEntity& aLastDumped = theDumper.myEntitiesStack.top();
+      CompositeFeaturePtr aComposite =
+          std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aLastDumped.myEntity);
+      if (!aComposite) {
+        theDumper.dumpEntitySetName();
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aLastDumped.myEntity);
+        if (aFeature) {
+          AttributeBooleanPtr aCopyAttr = aFeature->boolean("Copy");
+          isCopy = aCopyAttr.get() && aCopyAttr->value();
+        }
+      }
+    } while (isCopy);
   }
 
   // store all not-dumped entities first
index 9231f5d32d2bdf16520e76494d2f734a8723da2d..7aa9934344907a8229d5091b0bcc5fc7edc7680f 100644 (file)
@@ -1,16 +1,5 @@
 """Package for Sketch plugin for the Parametric Geometry API of the Modeler.
 """
 
-# DEBIAN 6.0 WORKAROUND START
-"""
-  Following code is used to support Debian 6.0.
-  It is kept, because SketchPlugin should be loaded before SketchAPI is first used.
-  Otherwise, the runtime error will be generated while some static inline methods are broken.
-""" 
-from ModelAPI import ModelAPI_Session
-aSession = ModelAPI_Session.get()
-aSession.forceLoadPlugin("SketchPlugin")
-# DEBIAN 6.0 WORKAROUND FINISH
-
 from SketchAPI import addSketch
 from tools import addPolyline, addPolygon
index dd373fe5a607d7aecc0eafb8b2301c8561c3913a..a92dcbd5101a822ad596751c28aaf78c3f58e163 100644 (file)
@@ -143,4 +143,5 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestSplit.py
                TestHighload.py
                TestSnowflake.py
-               TestArcBehavior.py )
+               TestArcBehavior.py
+               Test1924.py )
diff --git a/src/SketchPlugin/Test/Test1924.py b/src/SketchPlugin/Test/Test1924.py
new file mode 100644 (file)
index 0000000..0aa073d
--- /dev/null
@@ -0,0 +1,28 @@
+"""
+    Test1924.py
+    Test case for issue #1924 "Wrong naming of multiple-rotated sketch edges on python dump"
+"""
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(70, 120, 50, 25)
+SketchLine_2 = Sketch_1.addLine(50, 25, 170, 50)
+SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
+SketchMultiRotation_1_objects = [SketchLine_1.result(), SketchLine_2.result()]
+# names of rotated objects: "SketchLine_3", "SketchLine_4"
+SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchPoint_1.coordinates(), 90, 2)
+# line named "SketchLine_5"
+SketchLine_5 = Sketch_1.addLine(0, 100, 100, 100)
+# change number of rotated objects.
+# names of rotated objects: "SketchLine_3", "SketchLine_4", "SketchLine_6", "SketchLine_7"
+SketchMultiRotation_1.numberOfObjects().setValue(3)
+
+model.end()
+
+assert(model.checkPythonDump())
index b1097be9716f9cdbf3e34dfe914ffa180eb4478b..a16a3bbde75b2a93983f6cc735c36db1543f846c 100644 (file)
@@ -127,6 +127,7 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve()
 
   // Additionally check redundant constraints
   if (aResult == GCS::Success || aResult == GCS::Converged) {
+    bool isSolveWithoutTangent = !aRedundantID.empty();
     GCS::VEC_I aRedundantLocal;
     myEquationSystem->getRedundant(aRedundantLocal);
     aRedundantID.insert(aRedundantID.end(), aRedundantLocal.begin(), aRedundantLocal.end());
@@ -137,7 +138,15 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve()
     // if the entities are coupled smoothly.
     // Sometimes tangent constraints are fall to both conflicting and redundant constraints.
     // Need to check if there are redundant constraints without these tangencies.
-    if (!aRedundantID.empty())
+    if (!aRedundantID.empty() && !isSolveWithoutTangent) {
+      GCS::VEC_I::iterator aCIt = aRedundantID.begin();
+      for (; aCIt != aRedundantID.end(); ++ aCIt)
+        if (myTangent.find(*aCIt) != myTangent.end()) {
+          isSolveWithoutTangent = true;
+          break;
+        }
+    }
+    if (isSolveWithoutTangent)
       aResult = myTangent.empty() ? GCS::Failed : solveWithoutTangent();
     else
       aResult = GCS::Success;
index 91b36b77cce7671c53841deb1e18d51664de39cb..d1f6c4f17bbe88a2619731e5bb59c8c854be1183 100644 (file)
@@ -18,6 +18,7 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintMirror.h>
 #include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_Projection.h>
 
 
 /// \brief Verify two vectors of constraints are equal.
@@ -160,20 +161,14 @@ static bool isCopyInMulti(std::shared_ptr<SketchPlugin_Feature> theFeature,
     return false;
   bool aResult = theFeature->isCopy();
   if (aResult) {
-    std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> >::const_iterator
-        anIt = theConstraints.begin();
-    for (; anIt != theConstraints.end() && aResult; ++anIt) {
-      if (anIt->first->getKind() != SketchPlugin_ConstraintMirror::ID())
-        continue;
-      AttributeRefListPtr aRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
-          anIt->first->attribute(SketchPlugin_Constraint::ENTITY_C()));
-      std::list<ObjectPtr> aMirroredList =  aRefList->list();
-      std::list<ObjectPtr>::const_iterator aMIt = aMirroredList.begin();
-      for (; aMIt != aMirroredList.end() && aResult; ++aMIt) {
-        FeaturePtr aFeat = ModelAPI_Feature::feature(*aMIt);
-        if (aFeat == theFeature)
-          aResult = false;
-      }
+    const std::set<AttributePtr>& aRefs = theFeature->data()->refsToMe();
+    for (std::set<AttributePtr>::const_iterator aRefIt = aRefs.begin();
+         aRefIt != aRefs.end() && aResult; ++aRefIt) {
+      FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner());
+      if ((anOwner->getKind() == SketchPlugin_ConstraintMirror::ID() &&
+          (*aRefIt)->id() == SketchPlugin_Constraint::ENTITY_C()) ||
+         (anOwner->getKind() == SketchPlugin_Projection::ID()))
+        aResult = false;
     }
   }
   return aResult;
index 8a3a0fa7a415209dc719e659faedd0e064a6181f..729d13be56d0c8b9b3d5014566e222725d5a92c9 100644 (file)
@@ -254,7 +254,7 @@ void SketcherPrs_SymbolPrs::Compute(
   aBnd.Clear();
   for (int i = 1; i <= myPntArray->ItemNumber(); i++) {
     aVert = myPntArray->Vertice(i);
-    aBnd.Add (Graphic3d_Vec4((float)aVert.X(), (float)aVert.Y(), (float)aVert.Z(), 1.0f));
+    aBnd.Add(Graphic3d_Vec4((float)aVert.X(), (float)aVert.Y(), (float)aVert.Z(), 1.0f));
   }
 
   // Pint the group with custom procedure (see Render)
@@ -263,7 +263,7 @@ void SketcherPrs_SymbolPrs::Compute(
   aGroup->AddElement(aElem);
 
   // Disable frustum culling for this object by marking it as mutable
-  //aGroup->Structure()->SetMutable(true);
+  aGroup->Structure()->SetMutable(true);
 
   if (!aReadyToDisplay)
     SketcherPrs_Tools::sendEmptyPresentationError(myConstraint,