improve whitespace, fix const correctness

This commit is contained in:
wmayer
2018-01-23 00:40:41 +01:00
parent 46aa2c6356
commit c65585ccaf
5 changed files with 304 additions and 298 deletions

View File

@@ -257,13 +257,14 @@ int Sketch::addGeometry(const std::vector<Part::Geometry *> &geo, bool fixed)
return ret;
}
int Sketch::addGeometry(const std::vector<Part::Geometry *> &geo, std::vector<bool> &blockedGeometry)
int Sketch::addGeometry(const std::vector<Part::Geometry *> &geo,
const std::vector<bool> &blockedGeometry)
{
assert(geo.size() == blockedGeometry.size());
int ret = -1;
std::vector<Part::Geometry *>::const_iterator it;
std::vector<bool>::iterator bit;
std::vector<bool>::const_iterator bit;
for (it=geo.begin(),bit=blockedGeometry.begin(); it != geo.end() && bit !=blockedGeometry.end(); ++it,++bit)
ret = addGeometry(*it, *bit);
@@ -1324,12 +1325,13 @@ int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList)
int rtn = -1;
for (std::vector<Constraint *>::const_iterator it = ConstraintList.begin();it!=ConstraintList.end();++it)
rtn = addConstraint (*it);
rtn = addConstraint (*it);
return rtn;
}
int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList, std::vector<bool> &unenforceableConstraints)
int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList,
const std::vector<bool> &unenforceableConstraints)
{
int rtn = -1;
@@ -1337,17 +1339,18 @@ int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList, std:
for (std::vector<Constraint *>::const_iterator it = ConstraintList.begin();it!=ConstraintList.end();++it,++cid) {
if (!unenforceableConstraints[cid] && (*it)->Type != Block) {
rtn = addConstraint (*it);
}
else {
++ConstraintsCounter; // For correct solver redundant reporting
}
}
else {
++ConstraintsCounter; // For correct solver redundant reporting
}
}
return rtn;
}
void Sketch::getBlockedGeometry(std::vector<bool> & blockedGeometry, std::vector<bool> & unenforceableConstraints, const std::vector<Constraint *> &ConstraintList)
void Sketch::getBlockedGeometry(std::vector<bool> & blockedGeometry,
std::vector<bool> & unenforceableConstraints,
const std::vector<Constraint *> &ConstraintList) const
{
std::vector<int> internalAlignmentConstraintIndex;
std::vector<int> internalAlignmentgeo;
@@ -1364,8 +1367,8 @@ void Sketch::getBlockedGeometry(std::vector<bool> & blockedGeometry, std::vector
if(geoid>=0 && geoid<int(blockedGeometry.size())) {
blockedGeometry[geoid]=true;
geo2blockingconstraintindex[geoid]=i;
}
geo2blockingconstraintindex[geoid]=i;
}
}
break;
case InternalAlignment:
@@ -1378,66 +1381,66 @@ void Sketch::getBlockedGeometry(std::vector<bool> & blockedGeometry, std::vector
// if a GeoId is blocked and it is linked to Internal Alignment, then GeoIds linked via Internal Alignment are also to be blocked
for(std::vector<int>::iterator it = internalAlignmentConstraintIndex.begin(); it != internalAlignmentConstraintIndex.end() ; it++) {
if ( blockedGeometry[ConstraintList[(*it)]->Second] ) {
if (blockedGeometry[ConstraintList[(*it)]->Second]) {
blockedGeometry[ConstraintList[(*it)]->First] = true;
// asociated geometry gets the same blocking constraint index as the blocked element
geo2blockingconstraintindex[ConstraintList[(*it)]->First]= geo2blockingconstraintindex[ConstraintList[(*it)]->Second];
// asociated geometry gets the same blocking constraint index as the blocked element
geo2blockingconstraintindex[ConstraintList[(*it)]->First]= geo2blockingconstraintindex[ConstraintList[(*it)]->Second];
internalAlignmentgeo.push_back(ConstraintList[(*it)]->First);
unenforceableConstraints[(*it)]= true;
}
}
i = 0;
for (std::vector<Constraint *>::const_iterator it = ConstraintList.begin();it!=ConstraintList.end();++it,++i) {
if((*it)->isDriving) {
// additionally any further constraint on auxiliary elements linked via Internal Alignment are also uneforceable.
for(std::vector<int>::iterator itg = internalAlignmentgeo.begin(); itg != internalAlignmentgeo.end() ; itg++) {
if( (*it)->First==*itg || (*it)->Second==*itg || (*it)->Third==*itg ) {
unenforceableConstraints[i]= true;
}
}
// IMPORTANT NOTE:
// The rest of the ignoring of redundant/conflicting applies to constraints introduced before the blocking constraint only
// Constraints introduced after the block will not be ignored and will lead to redundancy/conflicting status as per normal
// solver behaviour
// further, any constraint taking only one element, which is blocked is also unenforceable
if((*it)->Second==Constraint::GeoUndef && (*it)->Third==Constraint::GeoUndef) {
if (blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) {
unenforceableConstraints[i]= true;
}
}
// further any constraint on only two elements where both elements are blocked or one is blocked and the other is an axis or external
// provided that the constraints precede the last block constraint.
else if((*it)->Third==Constraint::GeoUndef) {
if ( ((*it)->First>=0 && (*it)->Second>=0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second])) ||
((*it)->First<0 && (*it)->Second>=0 && blockedGeometry[(*it)->Second] && i < geo2blockingconstraintindex[(*it)->Second]) ||
((*it)->First>=0 && (*it)->Second<0 && blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) ){
unenforceableConstraints[i]= true;
}
}
// further any constraint on three elements where the three of them are blocked, or two are blocked and the other is an axis or external geo
// or any constraint on three elements where one is blocked and the other two are axis or external geo, provided that the constraints precede
// the last block constraint.
else {
if( ((*it)->First>=0 && (*it)->Second>=0 && (*it)->Third>=0 &&
blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] && blockedGeometry[(*it)->Third] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second] || i < geo2blockingconstraintindex[(*it)->Third])) ||
((*it)->First<0 && (*it)->Second>=0 && (*it)->Third>=0 && blockedGeometry[(*it)->Second] && blockedGeometry[(*it)->Third] &&
(i < geo2blockingconstraintindex[(*it)->Second] || i < geo2blockingconstraintindex[(*it)->Third])) ||
((*it)->First>=0 && (*it)->Second<0 && (*it)->Third>=0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Third] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Third])) ||
((*it)->First>=0 && (*it)->Second>=0 && (*it)->Third<0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second])) ||
((*it)->First>=0 && (*it)->Second<0 && (*it)->Third<0 && blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) ||
((*it)->First<0 && (*it)->Second>=0 && (*it)->Third<0 && blockedGeometry[(*it)->Second] && i < geo2blockingconstraintindex[(*it)->Second]) ||
((*it)->First<0 && (*it)->Second<0 && (*it)->Third>=0 && blockedGeometry[(*it)->Third] && i < geo2blockingconstraintindex[(*it)->Third]) ) {
unenforceableConstraints[i]= true;
}
}
}
if((*it)->isDriving) {
// additionally any further constraint on auxiliary elements linked via Internal Alignment are also uneforceable.
for(std::vector<int>::iterator itg = internalAlignmentgeo.begin(); itg != internalAlignmentgeo.end() ; itg++) {
if( (*it)->First==*itg || (*it)->Second==*itg || (*it)->Third==*itg ) {
unenforceableConstraints[i]= true;
}
}
// IMPORTANT NOTE:
// The rest of the ignoring of redundant/conflicting applies to constraints introduced before the blocking constraint only
// Constraints introduced after the block will not be ignored and will lead to redundancy/conflicting status as per normal
// solver behaviour
// further, any constraint taking only one element, which is blocked is also unenforceable
if((*it)->Second==Constraint::GeoUndef && (*it)->Third==Constraint::GeoUndef) {
if (blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) {
unenforceableConstraints[i]= true;
}
}
// further any constraint on only two elements where both elements are blocked or one is blocked and the other is an axis or external
// provided that the constraints precede the last block constraint.
else if((*it)->Third==Constraint::GeoUndef) {
if ( ((*it)->First>=0 && (*it)->Second>=0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second])) ||
((*it)->First<0 && (*it)->Second>=0 && blockedGeometry[(*it)->Second] && i < geo2blockingconstraintindex[(*it)->Second]) ||
((*it)->First>=0 && (*it)->Second<0 && blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) ){
unenforceableConstraints[i]= true;
}
}
// further any constraint on three elements where the three of them are blocked, or two are blocked and the other is an axis or external geo
// or any constraint on three elements where one is blocked and the other two are axis or external geo, provided that the constraints precede
// the last block constraint.
else {
if( ((*it)->First>=0 && (*it)->Second>=0 && (*it)->Third>=0 &&
blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] && blockedGeometry[(*it)->Third] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second] || i < geo2blockingconstraintindex[(*it)->Third])) ||
((*it)->First<0 && (*it)->Second>=0 && (*it)->Third>=0 && blockedGeometry[(*it)->Second] && blockedGeometry[(*it)->Third] &&
(i < geo2blockingconstraintindex[(*it)->Second] || i < geo2blockingconstraintindex[(*it)->Third])) ||
((*it)->First>=0 && (*it)->Second<0 && (*it)->Third>=0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Third] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Third])) ||
((*it)->First>=0 && (*it)->Second>=0 && (*it)->Third<0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second])) ||
((*it)->First>=0 && (*it)->Second<0 && (*it)->Third<0 && blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) ||
((*it)->First<0 && (*it)->Second>=0 && (*it)->Third<0 && blockedGeometry[(*it)->Second] && i < geo2blockingconstraintindex[(*it)->Second]) ||
((*it)->First<0 && (*it)->Second<0 && (*it)->Third>=0 && blockedGeometry[(*it)->Third] && i < geo2blockingconstraintindex[(*it)->Third]) ) {
unenforceableConstraints[i]= true;
}
}
}
}
}