diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index 691aac3904e75cd44b7b03a8c9051ee8f3e34b0d..194866e7eeda1c48285cefd9413438b7bd32ce34 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -1625,83 +1625,98 @@ bool Problem::check(int verbose_level) const auto fo = c->getFeatureOther(); auto Lo = c->getLandmarkOther(); - if ( !Fo && !Co && !fo && !Lo ) // case ABSOLUTE: + if ( c->getFrameOtherList() .empty() + && c->getCaptureOtherList() .empty() + && c->getFeatureOtherList() .empty() + && c->getLandmarkOtherList().empty() ) // case ABSOLUTE: { if (verbose_level > 0) - cout << " --> Abs." << endl; + cout << " --> Abs."; } // find constrained_by pointer in constrained frame - if ( Fo ) // case FRAME: + for (const auto& Fow : c->getFrameOtherList()) { - if (verbose_level > 0) - cout << " ( --> F" << Fo->id() << " <- "; - bool found = false; - for (auto cby : Fo->getConstrainedByList()) + if (!Fow.expired()) { + const auto& Fo = Fow.lock(); if (verbose_level > 0) - cout << " c" << cby->id(); - found = found || (c == cby); + { + cout << " ( --> F" << Fo->id() << " <- "; + for (auto cby : Fo->getConstrainedByList()) + cout << " c" << cby->id(); + } + // check constrained_by pointer in constrained frame + bool found = Fo->isConstrainedBy(c); + is_consistent = is_consistent && found; } - if (verbose_level > 0) - cout << ")"; - // check constrained_by pointer in constrained frame - is_consistent = is_consistent && found; } + if (verbose_level > 0 && !c->getFrameOtherList().empty()) + cout << ")"; // find constrained_by pointer in constrained capture - if ( Co ) // case CAPTURE: + for (const auto& Cow : c->getCaptureOtherList()) { - if (verbose_level > 0) - cout << " ( --> C" << Co->id() << " <- "; - bool found = false; - for (auto cby : Co->getConstrainedByList()) + if (!Cow.expired()) { + const auto& Co = Cow.lock(); + if (verbose_level > 0) - cout << " c" << cby->id(); - found = found || (c == cby); + { + cout << " ( --> C" << Co->id() << " <- "; + for (auto cby : Co->getConstrainedByList()) + cout << " c" << cby->id(); + } + // check constrained_by pointer in constrained frame + bool found = Co->isConstrainedBy(c); + is_consistent = is_consistent && found; } - if (verbose_level > 0) - cout << ")"; - // check constrained_by pointer in constrained frame - is_consistent = is_consistent && found; } + if (verbose_level > 0 && !c->getCaptureOtherList().empty()) + cout << ")"; // find constrained_by pointer in constrained feature - if ( fo ) // case FEATURE: + for (const auto& fow : c->getFeatureOtherList()) { - if (verbose_level > 0) - cout << " ( --> f" << fo->id() << " <- "; - bool found = false; - for (auto cby : fo->getConstrainedByList()) + if (!fow.expired()) { + const auto& fo = fow.lock(); + if (verbose_level > 0) - cout << " c" << cby->id(); - found = found || (c == cby); + { + cout << " ( --> f" << fo->id() << " <- "; + for (auto cby : fo->getConstrainedByList()) + cout << " c" << cby->id(); + } + // check constrained_by pointer in constrained feature + bool found = fo->isConstrainedBy(c); + is_consistent = is_consistent && found; } - if (verbose_level > 0) - cout << ")"; - // check constrained_by pointer in constrained feature - is_consistent = is_consistent && found; } + if (verbose_level > 0 && !c->getFeatureOtherList().empty()) + cout << ")"; // find constrained_by pointer in constrained landmark - if ( Lo ) // case LANDMARK: + for (const auto& Low : c->getLandmarkOtherList()) { - if (verbose_level > 0) - cout << " ( --> L" << Lo->id() << " <- "; - bool found = false; - for (auto cby : Lo->getConstrainedByList()) + if (Low.expired()) { + const auto& Lo = Low.lock(); + if (verbose_level > 0) - cout << " c" << cby->id(); - found = found || (c == cby); + { + cout << " ( --> L" << Lo->id() << " <- "; + for (auto cby : Lo->getConstrainedByList()) + cout << " c" << cby->id(); + } + // check constrained_by pointer in constrained landmark + bool found = Lo->isConstrainedBy(c); + is_consistent = is_consistent && found; } - if (verbose_level > 0) - cout << ")"; - // check constrained_by pointer in constrained landmark - is_consistent = is_consistent && found; } + if (verbose_level > 0 && !c->getLandmarkOtherList().empty()) + cout << ")"; + if (verbose_level > 0) cout << endl; @@ -1735,13 +1750,13 @@ bool Problem::check(int verbose_level) const // find in own Frame sb_vec = F->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " F" << F->id(); + if (found_here && verbose_level > 0) cout << " F" << F->id(); found = found || found_here; // find in own Capture sb_vec = C->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " C" << C->id(); + if (found_here && verbose_level > 0) cout << " C" << C->id(); found = found || found_here; // Find in other Captures of the own Frame @@ -1750,7 +1765,7 @@ bool Problem::check(int verbose_level) const { sb_vec = FC->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " F" << F->id() << ".C" << FC->id(); + if (found_here && verbose_level > 0) cout << " F" << F->id() << ".C" << FC->id(); found = found || found_here; } @@ -1759,7 +1774,7 @@ bool Problem::check(int verbose_level) const { sb_vec = S->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " S" << S->id(); + if (found_here && verbose_level > 0) cout << " S" << S->id(); found = found || found_here; } @@ -1767,7 +1782,7 @@ bool Problem::check(int verbose_level) const if (Fo){ sb_vec = Fo->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " Fo" << Fo->id(); + if (found_here && verbose_level > 0) cout << " Fo" << Fo->id(); found = found || found_here; } @@ -1777,7 +1792,7 @@ bool Problem::check(int verbose_level) const { sb_vec = Co->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " Co" << Co->id(); + if (found_here && verbose_level > 0) cout << " Co" << Co->id(); found = found || found_here; } @@ -1787,7 +1802,7 @@ bool Problem::check(int verbose_level) const { sb_vec = FoC->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " Fo" << Fo->id() << ".C" << FoC->id(); + if (found_here && verbose_level > 0) cout << " Fo" << Fo->id() << ".C" << FoC->id(); found = found || found_here; } @@ -1798,21 +1813,21 @@ bool Problem::check(int verbose_level) const auto foF = fo->getFrame(); sb_vec = foF->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " foF" << foF->id(); + if (found_here && verbose_level > 0) cout << " foF" << foF->id(); found = found || found_here; // find in constrained feature's Capture auto foC = fo->getCapture(); sb_vec = foC->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " foC" << foC->id(); + if (found_here && verbose_level > 0) cout << " foC" << foC->id(); found = found || found_here; // find in constrained feature's Sensor auto foS = fo->getCapture()->getSensor(); sb_vec = foS->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " foS" << foS->id(); + if (found_here && verbose_level > 0) cout << " foS" << foS->id(); found = found || found_here; } @@ -1821,7 +1836,7 @@ bool Problem::check(int verbose_level) const { sb_vec = Lo->getStateBlockVec(); found_here = (std::find(sb_vec.begin(), sb_vec.end(), sb) != sb_vec.end()); - if (found_here) cout << " Lo" << Lo->id(); + if (found_here && verbose_level > 0) cout << " Lo" << Lo->id(); found = found || found_here; }