34     std::cout << 
"Creating tree from topology." << std::endl;
    36     std::map<std::string, std::pair<boost::shared_ptr<TreeNode>, 
bool>> nodesByType;
    40         nodesByType[trajectory->objects[0]->type] = std::pair<boost::shared_ptr<TreeNode>, 
bool>(newNode, 
false);
    42     std::vector<std::string> typesToVisit;
    43     typesToVisit.push_back(pType);
    44     std::vector<boost::shared_ptr<Relation>> remainingRelations = 
mRelations;
    45     while (!remainingRelations.empty())
    47         std::cout << 
"Number of relations left is " << remainingRelations.size() << 
". ";
    48         std::string currentType = typesToVisit[0];
    49         typesToVisit.erase(typesToVisit.begin());
    50         std::cout << 
"Current type is " << currentType << std::endl;
    52         std::vector<boost::shared_ptr<Relation>> newRemainingRelations;
    56             if (relation->containsObject(currentType))
    58                 std::string otherType = relation->getOtherType(currentType);
    59                 std::cout << 
"Found relation to " << otherType << 
". ";
    60                 if (!nodesByType[otherType].second)   
    62                     std::cout << 
"Node not yet in tree. ";
    63                     currentNode->addChild(nodesByType[otherType].first);  
    64                     nodesByType[otherType].second = 
true;           
    65                     typesToVisit.push_back(otherType);
    66                     std::cout << 
"Added node." << std::endl;
    70                     std::cout << 
"Node already in tree. ";
    73                     reference->mChildren = std::vector<boost::shared_ptr<TreeNode>>();
    74                     reference->mReferenceTo = nodesByType[otherType].first;
    75                     reference->mIsReference = 
true;
    76                     currentNode->addChild(reference);
    77                     std::cout << 
"Added reference." << std::endl;
    80             else newRemainingRelations.push_back(relation);
    82         remainingRelations = newRemainingRelations;
    84     std::cout << 
"All relations visited." << std::endl;
    85     pRoot = nodesByType[pType].first;
    91     mRelations = std::vector<boost::shared_ptr<Relation>>();
    93     std::cout << 
"Removing duplicate relations. " << pRelations.size(); 
    94     for (
unsigned int i = 0; i < pRelations.size(); i++)
    97         for (
unsigned int j = i + 1; j < pRelations.size(); j++)
    99             if (pRelations[i]->containsObject(pRelations[j]->getObjectTypeA()) && pRelations[i]->containsObject(pRelations[j]->getObjectTypeB()))
   102         if (unique) 
mRelations.push_back(pRelations[i]);
   104     std::cout << 
" -> " << 
mRelations.size() << 
" relations." << std::endl;
 
std::vector< boost::shared_ptr< ISM::ObjectSet > > mObjectSets
void buildTree(ObjectSetList pObjectSets, boost::shared_ptr< TreeNode > &pRoot)
void setRelations(std::vector< boost::shared_ptr< Relation >> pRelations)
std::vector< boost::shared_ptr< Relation > > mRelations