From: azv Date: Wed, 16 Dec 2015 07:04:42 +0000 (+0300) Subject: Problem with moving fixed point X-Git-Tag: V_2.1.0~176 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c48541d1114c5cc388db22ea73af8950de2ffa7b;p=modules%2Fshaper.git Problem with moving fixed point --- diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index e5a2b695b..96051c3d0 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -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(); diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp index b10d7e95d..1859ec215 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp @@ -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 diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index eecc86653..af6b022be 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -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::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 diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index 3369fc7ae..ee27e9d14 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -18,6 +18,8 @@ #include #include +typedef std::map > 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 > myConstraintMap; @@ -197,7 +204,7 @@ protected: /// map attribute to solver's entity std::map 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 StoragePtr; diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h index 7136648b1..04e6790aa 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h @@ -15,7 +15,6 @@ #include #include -typedef std::map > CoincidentPointsMap; typedef std::list< std::set > SameConstraintMap; /** \class SolveSpaceSolver_Storage @@ -266,7 +265,6 @@ private: Slvs_hConstraint myConstrMaxID; ///< current constraint index (may differs with the number of constraints) std::vector 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