std::list<ObjectPtr>::iterator anIt = anItems.begin();
for (; anIt != anItems.end(); anIt++) {
FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
- std::map<FeaturePtr, Slvs_hEntity>::iterator aFIt = myFeatureMap.find(aFeature);
- if (aFeature && (aFIt == myFeatureMap.end() || aCurAttrs.find(aFIt->second) == aCurAttrs.end()))
+ if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end())
return true;
}
}
}
}
- // Set the translation line unchanged during constraint recalculation
- for (int i = 0; i < 2; i++) {
- if (myStorage->isPointFixed(aTranslationLine.point[i], aConstraint.h, true))
- continue;
- aConstraint = Slvs_MakeConstraint(
- SLVS_E_UNKNOWN, myGroup->getId(), SLVS_C_WHERE_DRAGGED, myGroup->getWorkplaneId(), 0.0,
- aTranslationLine.point[i], SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
- aConstraint.h = myStorage->addConstraint(aConstraint);
- mySlvsConstraints.push_back(aConstraint.h);
- }
-
adjustConstraint();
}
void SketchSolver_ConstraintMultiTranslation::adjustConstraint()
{
Slvs_Entity aTranslationLine = myStorage->getEntity(myTranslationLine);
+ Slvs_hConstraint aFixed; // temporary variable
+ // Set the translation line unchanged during constraint recalculation
+ for (int i = 0; i < 2; i++) {
+ if (myStorage->isPointFixed(aTranslationLine.point[i], aFixed, true))
+ continue;
+ Slvs_Constraint aConstraint = Slvs_MakeConstraint(
+ SLVS_E_UNKNOWN, myGroup->getId(), SLVS_C_WHERE_DRAGGED, myGroup->getWorkplaneId(), 0.0,
+ aTranslationLine.point[i], SLVS_E_UNKNOWN, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
+ aConstraint.h = myStorage->addConstraint(aConstraint);
+ myStorage->addTemporaryConstraint(aConstraint.h);
+ }
+
// Check if the distance between point is 0, no need to resolve constraints (just wait another values)
double aXY[4];
for (int i = 0; i < 2; i++) {
std::list<Slvs_Constraint> aParallel = myStorage->getConstraintsByType(SLVS_C_PARALLEL);
std::list<Slvs_Constraint>::iterator aParIt = aParallel.begin();
std::vector<Slvs_hConstraint>::iterator aCIt;
- Slvs_hConstraint aFixed; // temporary variable
for (; aParIt != aParallel.end(); aParIt++) {
for (aCIt = mySlvsConstraints.begin(); aCIt != mySlvsConstraints.end(); aCIt++)
if (aParIt->h == *aCIt)
else {
// To avoid overconstraint situation, we will remove temporary constraints one-by-one
// and try to find the case without overconstraint
- int aNbTemp = (int)myTempConstraints.size();
+ int aNbTemp = myStorage->numberTemporary();
while (true) {
aResult = myConstrSolver.solve();
if (aResult == SLVS_RESULT_OKAY || aNbTemp <= 0)
void SketchSolver_Group::removeTemporaryConstraints()
{
myTempConstraints.clear();
- myStorage->removeTemporaryConstraints();
+ while (myStorage->numberTemporary())
+ myStorage->deleteTemporaryConstraint();
// Clean lists of removed entities in the storage
std::set<Slvs_hParam> aRemPar;
std::set<Slvs_hEntity> aRemEnt;
int deleteTemporaryConstraint();
/// \brief Checks the constraint is temporary
bool isTemporary(const Slvs_hConstraint& theConstraintID) const;
+ /// \brief Number of temporary constraints
+ int numberTemporary() const
+ { return (int)myTemporaryConstraints.size(); }
/// \brief Shows the sketch should be resolved
bool isNeedToResolve() const