Sketcher: Fix block constraint with several dependency groups

=============================================================

Fixes:
https://forum.freecadweb.org/viewtopic.php?f=8&t=53466&p=460513#p460270

When a parameter belonging to a blocked geometry is present in several
dependency groups and there are other fixed parameters one or more of
the dependency groups, it is not enough to remove that parameter, from
the one or more dependency groups. The removal of a parameter may only
satisfy one dependency group. Removing a single parameter creates a
new different dependency group.

Solution:
If the first blocked parameter in a group is already set for removal,
continue searching for other blocked parameters, until one not searched
for removal is found.
This commit is contained in:
Abdullah Tahiri
2020-12-24 07:27:32 +01:00
committed by abdullahtahiriyo
parent fffbbf14c5
commit 19be9767fc

View File

@@ -62,8 +62,8 @@
#include "Sketch.h"
#define DEBUG_BLOCK_CONSTRAINT
//#undef DEBUG_BLOCK_CONSTRAINT
//#define DEBUG_BLOCK_CONSTRAINT
#undef DEBUG_BLOCK_CONSTRAINT
using namespace Sketcher;
using namespace Base;
@@ -265,17 +265,25 @@ int Sketch::setUpSketch(const std::vector<Part::Geometry *> &GeoList,
auto blocked = std::find(blockedGeoIds.begin(),blockedGeoIds.end(),element->second.first);
if( blocked != blockedGeoIds.end()) { // this dependent parameter group contains a parameter that should be blocked
params_to_block.push_back(thisparam);
if( blocked != blockedGeoIds.end()) {
// This dependent parameter group contains a parameter that should be blocked.
//
// One parameter per group is enough to fix the group, but it must be a different one for each group or
// it will create a different dependency group
auto already_in = std::find(params_to_block.begin(),params_to_block.end(), thisparam);
if( already_in == params_to_block.end()) {
params_to_block.push_back(thisparam);
#ifdef DEBUG_BLOCK_CONSTRAINT
Base::Console().Log("\nBlocking: Param=%x ,GeoId=%d, GeoPos=%d",
element->first,
element->second.first,
element->second.second);
Base::Console().Log("\nBlocking: Param=%x ,GeoId=%d, GeoPos=%d",
element->first,
element->second.first,
element->second.second);
#endif //DEBUG_BLOCK_CONSTRAINT
break; // one parameter per group is enough to fix the group
break;
}
}
}
}