Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Bond/BondInfo.cpp

    rc26617 r5aaa43  
    6161  atom * const rightatom = World::getInstance().getAtom(AtomById(rightid));
    6262  if ((leftatom == NULL) || (rightatom == NULL)) {
    63 //    LOG(3, "DEBUG: Either of the two atoms " << leftid << " or "
    64 //        << rightid << " does not exist in the world.");
     63    ELOG(1, "Either of the two atoms " << leftid << " or "
     64        << rightid << " does not exists in the world.");
    6565    return false;
    6666  }
    6767  const BondList &leftbonds = leftatom->getListOfBonds();
     68  boost::function< bool (const bond::ptr )> predicate =
     69      boost::bind(static_cast<bool (bond::*)(const int) const>(&bond::Contains), _1, rightid);
     70  if (std::find_if(leftbonds.begin(), leftbonds.end(), predicate) != leftbonds.end())
     71    return false;
     72
    6873  const BondList &rightbonds = rightatom->getListOfBonds();
    69   boost::function< bool (const bond::ptr )> leftpredicate =
    70       boost::bind(static_cast<bool (bond::*)(const atomId_t) const>(&bond::ContainsId), _1, rightid);
    71   boost::function< bool (const bond::ptr )> rightpredicate =
    72       boost::bind(static_cast<bool (bond::*)(const atomId_t) const>(&bond::ContainsId), _1, leftid);
    73   if ((std::find_if(leftbonds.begin(), leftbonds.end(), leftpredicate) != leftbonds.end())
    74       || (std::find_if(rightbonds.begin(), rightbonds.end(), rightpredicate) != rightbonds.end())) {
    75 //    LOG(3, "DEBUG: Bond between atoms " << leftid << " or "111
    76 //        << rightid << " is already present in the world.");
    77     return true;
    78   }
     74  if (std::find_if(rightbonds.begin(), rightbonds.end(), predicate) != rightbonds.end())
     75    return false;
    7976
    8077  // create bond
     
    8481  return true;
    8582}
    86 
    87 void BondInfo::RemoveBond() const
    88 {
    89   atom * leftatom = World::getInstance().getAtom(AtomById(leftid));
    90   atom * rightatom = World::getInstance().getAtom(AtomById(rightid));
    91   leftatom->removeBond(rightatom);
    92 }
Note: See TracChangeset for help on using the changeset viewer.