]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix processing multiply point-point coincidences (fix for the model test cases)
authorazv <azv@opencascade.com>
Wed, 17 May 2017 14:40:17 +0000 (17:40 +0300)
committerazv <azv@opencascade.com>
Wed, 17 May 2017 14:40:17 +0000 (17:40 +0300)
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.h
test.models/gear.py

index bad62522a08fc57b1d689c9865e1d93b8a0f4819..b44881bf88c6f9d35061ffb6fc3268c471792e68 100644 (file)
 #include <SketchPlugin_ConstraintCollinear.h>
 #include <SketchPlugin_ConstraintMiddle.h>
 
+static bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
+                         const EntityWrapperPtr& thePoint);
+
+
 void PlaneGCSSolver_UpdateCoincidence::attach(SketchSolver_Constraint* theObserver,
                                               const std::string& theType)
 {
@@ -72,17 +76,21 @@ bool PlaneGCSSolver_UpdateCoincidence::addCoincidence(
   } else if (aFound[0] == aFound[1]) { // same group => already coincident
     isAccepted = false;
   } else { // merge two groups
-    EntityWrapperPtr anEntityToAdd = theEntity1;
-    if (theEntity1->isExternal()) { // swap found groups;
-      anEntityToAdd = theEntity2;
-      std::list<CoincidentEntities>::iterator aTempIt = aFound[0];
-      aFound[0] = aFound[1];
-      aFound[1] = aTempIt;
+    // first check the external points are equal
+    EntityWrapperPtr anExternal0 = aFound[0]->externalPoint();
+    EntityWrapperPtr anExternal1 = aFound[1]->externalPoint();
+    if (anExternal0 && anExternal1) {
+      std::set<EntityWrapperPtr> anExtList;
+      anExtList.insert(anExternal0);
+      if (hasSamePoint(anExtList, anExternal1)) {
+        // no need to add coincidence, because all points are
+        // already coincident to correct external points
+        isAccepted = false;
+      }
     }
 
-    aFound[1]->remove(anEntityToAdd);
+    // merge
     aFound[0]->merge(*aFound[1]);
-    isAccepted = aFound[0]->add(anEntityToAdd);
     myCoincident.erase(aFound[1]);
   }
 
@@ -126,9 +134,7 @@ bool PlaneGCSSolver_UpdateCoincidence::addToGroupOfCoincidence(
 {
   if (theGroup.isExist(theEntity))
     return false;
-
-  theGroup.add(theEntity);
-  return true;
+  return theGroup.add(theEntity);
 }
 
 
@@ -157,8 +163,8 @@ static bool hasSamePoint(const std::set<EntityWrapperPtr>& theList, const GCS::P
   return false;
 }
 
-static bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
-                         const EntityWrapperPtr& thePoint)
+bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
+                  const EntityWrapperPtr& thePoint)
 {
   return hasSamePoint(theList, toPoint(thePoint));
 }
@@ -225,3 +231,8 @@ bool PlaneGCSSolver_UpdateCoincidence::CoincidentEntities::isExist(
 {
   return hasSamePoint(myExternalPoints, thePoint) || hasSamePoint(myPoints, thePoint);
 }
+
+EntityWrapperPtr PlaneGCSSolver_UpdateCoincidence::CoincidentEntities::externalPoint() const
+{
+  return myExternalPoints.empty() ? EntityWrapperPtr() : *myExternalPoints.begin();
+}
index d5acf494af430a2776bb1750a644678d0e3f5773..20ce3425a0b9c595cb4f68c5292db64302f5b247 100644 (file)
@@ -73,6 +73,9 @@ private:
     /// Merge two groups
     void merge(const CoincidentEntities& theOther);
 
+    /// Returns any of external points
+    EntityWrapperPtr externalPoint() const;
+
   private:
     std::set<EntityWrapperPtr> myPoints; ///< coincident points
     std::set<EntityWrapperPtr> myExternalPoints; //< external points coincident to other points
index 5d3a6d31b8a00855d5e27ebb473c3ac9aeb1c4d3..f49e7960d11e95c4db31e1cd9713024867741706 100644 (file)
@@ -145,6 +145,7 @@ SketchConstraintLength_10 = Sketch_3.setLength(SketchLine_83.result(), "2*R_fill
 model.do()
 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_1"), 360, 0)
 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_5"))
+SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "PartSet/Origin"))
 SketchLine_86 = Sketch_4.addLine(0, -13.49999999999519, 3.1, -13.49999999999519)
 SketchLine_87 = Sketch_4.addLine(model.selection("EDGE", "PartSet/OZ"))
 SketchConstraintCoincidence_51 = Sketch_4.setCoincident(SketchLine_86.startPoint(), SketchLine_87.result())
@@ -160,6 +161,7 @@ SketchConstraintLength_9 = Sketch_4.setLength(SketchLine_86.result(), 3.1)
 SketchConstraintMirror_2 = Sketch_4.addMirror(SketchLine_87.result(), [SketchLine_86.result(), SketchLine_88.result()])
 [SketchLine_90, SketchLine_91] = SketchConstraintMirror_2.mirrored()
 SketchArc_62 = Sketch_4.addArc(0, 0, 3.1, -10.55414610473955, -3.100000000000001, -10.55414610473344, False)
+SketchConstraintCoincidence_54 = Sketch_4.setCoincident(SketchPoint_4.coordinates(), SketchArc_62.center())
 SketchConstraintCoincidence_55 = Sketch_4.setCoincident(SketchLine_87.startPoint(), SketchArc_62.center())
 SketchConstraintCoincidence_56 = Sketch_4.setCoincident(SketchArc_62.startPoint(), SketchLine_88.result())
 SketchConstraintCoincidence_57 = Sketch_4.setCoincident(SketchArc_62.endPoint(), SketchLine_91.result())