pcl::CorrespondencesPtr CloudMapper::LandmarksToCorresponencies(Cloud::Ptr &cloud1, CloudMapper::Landmarks &landmarks1, Cloud::Ptr &cloud2, CloudMapper::Landmarks &landmarks2) { pcl::CorrespondencesPtr result(new pcl::Correspondences); int resultSize = std::min(landmarks1.size(), landmarks2.size()); for (int i = 0; i < resultSize; i++) { auto sourcePoint1 = landmarks1.at(i).point; auto sourcePoint2 = landmarks2.at(i).point; auto p1IsNotNan = IsNotNAN(sourcePoint1); auto p2IsNotNan = IsNotNAN(sourcePoint2); if (p1IsNotNan && p2IsNotNan) { CloudMapper::Landmarks::value_type pt1 = FindClosestPoint(cloud1, sourcePoint1); CloudMapper::Landmarks::value_type pt2 = FindClosestPoint(cloud2, sourcePoint2); float distance = CalculateDistance(pt1.point, pt2.point); pcl::Correspondence correspondence(pt1.index, pt2.index, distance); result->push_back(correspondence); } } return result; }
ReturnValues Users::addGroupChat(const QString &admiLogin, QVector<QString> participantslogins, const int &IDNumber)/*,Correspondence *groupCaht)*/ { User *admin; QVector<User*> participants; QList<User>::iterator it = m_users.begin(); while (it != m_users.end()) { if(admiLogin == (*it).getLogin()) { admin =& (*it); it++; continue; } for(int j = 0; j < participantslogins.size(); j++) { if(participantslogins[j] == (*it).getLogin()) { participants.push_back(&(*it)); break; } } it++; } Correspondence correspondence(admin, participants,IDNumber); m_Correspondence.push_back(correspondence); QList<Correspondence>::iterator j = m_Correspondence.begin(); while(j != m_Correspondence.end()) { if((*j).findIDNumber(IDNumber)) { admin->addGroupCorrespondence(&(*j)); for(int h = 0; h < participants.size(); h++) { participants[h]->addGroupCorrespondence(&(*j)); } break; } j++; } return createdChat; }
ReturnValues Users::addFriend(const QString &userLogin, const QString &friendLogin) { User *puser = NULL; User *pfriend = NULL; QList<User>::iterator it = m_users.begin(); while (it != m_users.end()) { if (userLogin == (*it).getLogin()) { puser =& (*it); } if (friendLogin == (*it).getLogin()) { pfriend =& (*it); } if (puser && pfriend) { Correspondence correspondence(puser, pfriend); //create correspondence m_Correspondence.push_back(correspondence); QList<Correspondence>::iterator j = m_Correspondence.begin(); while(j != m_Correspondence.end()) { if((*j).findParticipants(userLogin, friendLogin)) { puser->addFriend(pfriend, &(*j)); pfriend->addFriend(puser, &(*j)); return ReturnValues::addedFriend; } j++; } } it++; } return ReturnValues::returnNull; }