myEntities.clear();
myEntOfConstr.clear();
myConstraints.clear();
+
myTempConstraints.clear();
+ myTempPointWhereDragged.clear();
+ myTempPointWDrgdID = 0;
// Initialize workplane
myWorkplane.h = SLVS_E_UNKNOWN;
myConstraints.clear();
myConstraintMap.clear();
myTempConstraints.clear();
+ myTempPointWhereDragged.clear();
// If the group with maximal identifier is deleted, decrease the indexer
if (myID == myGroupIndexer)
// If the attribute was changed by the user, we need to fix it before solving
if (myNeedToSolve && theEntity->isImmutable())
- addTemporaryConstraintWhereDragged(theEntity);
+ addTemporaryConstraintWhereDragged(theEntity, false);
return aResult;
}
myConstrSolver.setParameters(myParams);
myConstrSolver.setEntities(myEntities);
myConstrSolver.setConstraints(myConstraints);
+ myConstrSolver.setDraggedParameters(myTempPointWhereDragged);
int aResult = myConstrSolver.solve();
if (aResult == SLVS_RESULT_OKAY) { // solution succeeded, store results into correspondent attributes
myTempConstraints.push_back(aFind->second);
}
+ if (myTempPointWhereDragged.empty())
+ myTempPointWhereDragged = theGroup.myTempPointWhereDragged;
+ else if (!theGroup.myTempPointWhereDragged.empty()) { // Need to create additional transient constraint
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator aFeatureIter =
+ theGroup.myEntityAttrMap.begin();
+ for (; aFeatureIter != theGroup.myEntityAttrMap.end(); aFeatureIter++)
+ if (aFeatureIter->second == myTempPointWDrgdID) {
+ addTemporaryConstraintWhereDragged(aFeatureIter->first);
+ break;
+ }
+ }
+
myNeedToSolve = myNeedToSolve || theGroup.myNeedToSolve;
}
// which was moved by user
// ============================================================================
void SketchSolver_ConstraintGroup::addTemporaryConstraintWhereDragged(
- boost::shared_ptr<ModelAPI_Attribute> theEntity)
+ boost::shared_ptr<ModelAPI_Attribute> theEntity,
+ bool theAllowToFit)
{
// Find identifier of the entity
std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator anEntIter =
if (anEntIter == myEntityAttrMap.end())
return;
+ // If this is a first dragged point, its parameters should be placed
+ // into Slvs_System::dragged field to avoid system inconsistense
+ if (myTempPointWhereDragged.empty() && theAllowToFit) {
+ int anEntPos = Search(anEntIter->second, myEntities);
+ Slvs_hParam* aDraggedParam = myEntities[anEntPos].param;
+ for (int i = 0; i < 4; i++, aDraggedParam++)
+ if (*aDraggedParam != 0)
+ myTempPointWhereDragged.push_back(*aDraggedParam);
+ myTempPointWDrgdID = myEntities[anEntPos].h;
+ return;
+ }
+
// Get identifiers of all dragged points
std::set<Slvs_hEntity> aDraggedPntID;
+ aDraggedPntID.insert(myTempPointWDrgdID);
std::list<Slvs_hConstraint>::iterator aTmpCoIter = myTempConstraints.begin();
for (; aTmpCoIter != myTempConstraints.end(); aTmpCoIter++) {
unsigned int aConstrPos = Search(*aTmpCoIter, myConstraints);
myConstrMaxID--;
}
myTempConstraints.clear();
+
+ // Clear basic dragged point
+ myTempPointWhereDragged.clear();
+ myTempPointWDrgdID = SLVS_E_UNKNOWN;
}
// ============================================================================
const Slvs_hEntity& theEntityID);
/** \brief Adds a constraint for a point which should not be changed during computations
- * \param[in] theEntity the base for the constraint
+ * \param[in] theEntity the base for the constraint
+ * \param[in] theAllowToFit this flag shows that the entity may be placed into
+ * the 'dragged' field of SolveSpace solver, so this entity
+ * may be changed a little during solution
*/
- void addTemporaryConstraintWhereDragged(boost::shared_ptr<ModelAPI_Attribute> theEntity);
+ void addTemporaryConstraintWhereDragged(boost::shared_ptr<ModelAPI_Attribute> theEntity,
+ bool theAllowToFit = true);
/** \brief Remove all temporary constraint after computation finished
*/
SketchSolver_Solver myConstrSolver; ///< Solver for set of equations obtained by constraints
+ std::vector<Slvs_hParam> myTempPointWhereDragged; ///< Parameters of one of the points which is moved by user
+ Slvs_hEntity myTempPointWDrgdID; ///< Identifier of such point
std::list<Slvs_hConstraint> myTempConstraints; ///< The list of identifiers of temporary constraints (SLVS_C_WHERE_DRAGGED) applied for all other points moved by user
// SketchPlugin entities