Salome HOME
Problem with moving fixed point
authorazv <azv@opencascade.com>
Wed, 16 Dec 2015 07:04:42 +0000 (10:04 +0300)
committerazv <azv@opencascade.com>
Wed, 16 Dec 2015 07:04:42 +0000 (10:04 +0300)
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.h
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h

index e5a2b695ba505acfce62299472941f126194bce4..96051c3d01128d11ef79f375f255acb67cfaaabd 100644 (file)
@@ -163,7 +163,7 @@ void SketchSolver_Constraint::getAttributes(
       return;
     }
 
-    myStorage->update(*anIter, myGroupID);
+    myStorage->update(*anIter/*, myGroupID*/);
     EntityWrapperPtr anEntity = myStorage->entity(*anIter);
 
     SketchSolver_EntityType aType = anEntity->type();
index b10d7e95d44f25e14850f441cd45410275752e05..1859ec2156d74979f1f349667fde5cc3adfd31f6 100644 (file)
@@ -14,6 +14,12 @@ void SketchSolver_ConstraintCoincidence::getAttributes(
 
   if (theAttributes[1]) {
     myType = CONSTRAINT_PT_PT_COINCIDENT;
+    if (myStorage->isFixed(theAttributes[1]) && !myStorage->isFixed(theAttributes[0])) {
+      // fixed point should go first
+      EntityWrapperPtr aTemp = theAttributes[0];
+      theAttributes[0] = theAttributes[1];
+      theAttributes[1] = aTemp;
+    }
     // Set the slave (second) point the same as master (first) point.
     // This will allow to skip adding point-point coincidence to the set of constraints
     // and give us speed-up in solving the set of equations
index eecc86653a9c66fc4041ba9c3eb28ce5602686ce..af6b022be7dceb7191dd9320ac31d1f75365d5d1 100644 (file)
@@ -228,6 +228,27 @@ bool SketchSolver_Storage::isConsistent() const
   return true;
 }
 
+bool SketchSolver_Storage::isFixed(EntityWrapperPtr theEntity) const
+{
+  if (theEntity->group() != myGroupID)
+    return true;
+  // no need additional checking for entities differ than point
+  if (theEntity->type() != ENTITY_POINT)
+    return false;
+
+  CoincidentPointsMap::const_iterator anIt = myCoincidentPoints.begin();
+  for (; anIt != myCoincidentPoints.end(); ++anIt)
+    if (anIt->first == theEntity || anIt->second.find(theEntity) != anIt->second.end()) {
+      if (anIt->first->group() != myGroupID)
+        return true;
+      std::set<EntityWrapperPtr>::const_iterator anEntIt = anIt->second.begin();
+      for (; anEntIt != anIt->second.end(); ++anEntIt)
+        if ((*anEntIt)->group() != myGroupID)
+          return true;
+    }
+  return false;
+}
+
 void SketchSolver_Storage::removeInvalidEntities()
 {
   // Remove invalid constraints
index 3369fc7ae725ab5781b77ec3bdc980afa8a9c204..ee27e9d14b91b80bf4900a73941e33b92f036d01 100644 (file)
@@ -18,6 +18,8 @@
 #include <ModelAPI_Feature.h>
 #include <SketchPlugin_Constraint.h>
 
+typedef std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > CoincidentPointsMap;
+
 /** \class   SketchSolver_Storage
  *  \ingroup Plugins
  *  \brief   Interface to map SketchPlugin features to the entities of corresponding solver.
@@ -116,6 +118,10 @@ public:
   /// \brief Check the features is not removed
   bool isConsistent() const;
 
+  /// \brief Check the entity is fixed.
+  ///        If the point is under verification, all coincident points are checked too.
+  bool isFixed(EntityWrapperPtr theEntity) const;
+
   /// \brief Shows the sketch should be resolved
   virtual bool isNeedToResolve()
   { return myNeedToResolve; }
@@ -188,7 +194,8 @@ private:
   EntityWrapperPtr getNormal() const;
 
 protected:
-  GroupID myGroupID; ///< identifier of the group, this storage belongs to
+  GroupID myGroupID;       ///< identifier of the group, this storage belongs to
+  bool    myNeedToResolve; ///< parameters are changed and group needs to be resolved
 
   /// map SketchPlugin constraint to a list of solver's constraints
   std::map<ConstraintPtr, std::list<ConstraintWrapperPtr> > myConstraintMap;
@@ -197,7 +204,7 @@ protected:
   /// map attribute to solver's entity
   std::map<AttributePtr, EntityWrapperPtr>                  myAttributeMap;
 
-  bool myNeedToResolve; ///< parameters are changed and group needs to be resolved
+  CoincidentPointsMap myCoincidentPoints; ///< lists of coincident points (first is a master point, second is a set of slaves)
 };
 
 typedef std::shared_ptr<SketchSolver_Storage> StoragePtr;
index 7136648b11cba963a8f4f98a505f00d044cd644a..04e6790aac391e15131fffe1bc2e170865d7e9c2 100644 (file)
@@ -15,7 +15,6 @@
 #include <set>
 #include <vector>
 
-typedef std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > CoincidentPointsMap;
 typedef std::list< std::set<ConstraintWrapperPtr> >             SameConstraintMap;
 
 /** \class   SolveSpaceSolver_Storage
@@ -266,7 +265,6 @@ private:
   Slvs_hConstraint myConstrMaxID; ///< current constraint index (may differs with the number of constraints)
   std::vector<Slvs_Constraint> myConstraints; ///< list of constraints used in the current group (sorted by the identifier)
 
-  CoincidentPointsMap myCoincidentPoints; ///< lists of coincident points (first is a master point, second is a set of slaves)
   Slvs_hConstraint myFixed; ///< identifier of one of temporary constraints to fix separate point
 
   bool myDuplicatedConstraint; ///< shows the storage has same constraint twice