return;
}
- myStorage->update(*anIter, myGroupID);
+ myStorage->update(*anIter/*, myGroupID*/);
EntityWrapperPtr anEntity = myStorage->entity(*anIter);
SketchSolver_EntityType aType = anEntity->type();
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
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
#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.
/// \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; }
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;
/// 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;
#include <set>
#include <vector>
-typedef std::map<EntityWrapperPtr, std::set<EntityWrapperPtr> > CoincidentPointsMap;
typedef std::list< std::set<ConstraintWrapperPtr> > SameConstraintMap;
/** \class SolveSpaceSolver_Storage
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