]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix the problem with multi-coincidence of points (issue #1143)
authorazv <azv@opencascade.com>
Wed, 16 Dec 2015 05:18:01 +0000 (08:18 +0300)
committerazv <azv@opencascade.com>
Thu, 17 Dec 2015 15:51:56 +0000 (18:51 +0300)
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintMovement.cpp
src/SketchSolver/SketchSolver_ConstraintMovement.h
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.h
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp

index 1417bde62f2769c5f2d86baf6fc2dc7c3dbbb963..cddafdb1252b8605df55e0d496b9e7d6c9c76f63 100644 (file)
@@ -53,7 +53,7 @@ void SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature)
   // extract feature from the group
   if (theFeature->baseAttribute())
     myStorage->update(theFeature->baseAttribute(), GID_OUTOFGROUP);
-  else
+  else if (theFeature->baseFeature())
     myStorage->update(theFeature->baseFeature(), GID_OUTOFGROUP);
 }
 
index 85542cb42c7cad8c36e86a18530dc18c8479da23..7f4c8d78be74bc356fa3c967a41d612b9bbb1b0f 100644 (file)
@@ -49,7 +49,8 @@ static std::list<EntityWrapperPtr> movedEntities(
   for (; anOldIt != anOldSubs.end() && aNewIt != aNewSubs.end(); ++anOldIt, ++aNewIt) {
     std::list<EntityWrapperPtr> aMovedSubs = movedEntities(
         *anOldIt, theOldStorage, *aNewIt, theNewStorage);
-    if (aMovedSubs.size() != 1 || aMovedSubs.front() != *anOldIt)
+    if ((*anOldIt)->type() == ENTITY_POINT && // check only the points to be moved (because arcs in PlaneGCS have scalar subs too)
+       (aMovedSubs.size() != 1 || aMovedSubs.front() != *anOldIt))
       isFullyMoved = false;
     aMoved.insert(aMoved.end(), aMovedSubs.begin(), aMovedSubs.end());
   }
@@ -96,3 +97,21 @@ void SketchSolver_ConstraintMovement::getAttributes(
   theAttributes.clear();
   theAttributes.insert(theAttributes.begin(), aMoved.begin(), aMoved.end());
 }
+
+bool SketchSolver_ConstraintMovement::remove()
+{
+  cleanErrorMsg();
+  // Move fixed entities back to the current group
+  std::vector<EntityWrapperPtr>::iterator aMoveIt = myMovedEntities.begin();
+  for (; aMoveIt != myMovedEntities.end(); ++aMoveIt) {
+    if ((*aMoveIt)->baseAttribute())
+      myStorage->update((*aMoveIt)->baseAttribute(), myGroupID);
+    else if ((*aMoveIt)->baseFeature())
+      myStorage->update((*aMoveIt)->baseFeature(), myGroupID);
+  }
+
+  // Remove base feature
+  if (myBaseFeature)
+    myStorage->removeEntity(myBaseFeature);
+  return true;
+}
index ba119beaadf2f6bc7cab53469949838d3b9a19c3..93b2ea001f756e2e41b544bb30070f773556c8c1 100644 (file)
@@ -28,6 +28,10 @@ public:
     : SketchSolver_ConstraintFixed(theFeature)
   {}
 
+  /// \brief Tries to remove constraint
+  /// \return \c false, if current constraint contains another SketchPlugin constraints (like for multiple coincidence)
+  virtual bool remove();
+
 protected:
   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
   virtual void process();
index c853970a34d43eb53025c67226357f489215e48f..aa7729551494dcbc77fd7bd4fea9e87d9667d2c5 100644 (file)
@@ -41,7 +41,7 @@ typedef unsigned int UINT32;
  */
 class SolveSpaceSolver_Solver : public SketchSolver_ISolver
 {
- public:
+public:
   SolveSpaceSolver_Solver();
   virtual ~SolveSpaceSolver_Solver();
 
index 080e321386a4298bb4fae03c7160f449a8a80014..c8113afb835f8ab6f0dd32368dcede80c97d83da 100644 (file)
@@ -295,8 +295,9 @@ void SolveSpaceSolver_Storage::addCoincidentPoints(
     replaceInFeatures(theSlave, theMaster);
     replaceInConstraints(theSlave, theMaster);
 
-    // Remove slave entity
-    removeEntity((Slvs_hEntity)theSlave->id());
+    // Remove slave entity (if the IDs are equal no need to remove slave entity, just update it)
+    if (theMaster->id() != theSlave->id())
+      removeEntity((Slvs_hEntity)theSlave->id());
 
     std::shared_ptr<SolveSpaceSolver_EntityWrapper> aPointMaster = 
         std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theMaster);