typename TIterator::value_type operator()(TIterator first, TIterator last, typename TIterator::value_type queryNode)
  {
    typedef typename TIterator::value_type VertexDescriptorType;

    // Step 1 - K-NN search on first topology
    std::vector<VertexDescriptorType> outputContainer(this->MultipleNeighborFinder.GetK());
    this->MultipleNeighborFinder(first, last, queryNode, outputContainer.begin());

//    std::cout << "There are " << outputContainer.size() << " items to search in the second step." << std::endl;
    if(outputContainer.size() <= 0)
    {
      throw std::runtime_error("MultipleNeighborFinder did not find any neighbors!");
    }

    Visitor.FoundNeighbors(outputContainer);

    this->TopPatchWriter(outputContainer.begin(),
                         outputContainer.end(), queryNode);

    // Step 2 - 1-NN search on result of first search, on second topology
    VertexDescriptorType nearestNeighbor = this->NearestNeighborFinder(outputContainer.begin(),
                                                                       outputContainer.end(), queryNode);
    return nearestNeighbor;
  }
Beispiel #2
0
NPT_String RootContainer::generateDidl(const NPT_List<const Object*>& ls, const NPT_String& resUriTmpl)
{
	NPT_StringOutputStream outputStream;
	NPT_XmlSerializer xml(&outputStream, 0, true, true);

	xml.StartDocument();
	xml.StartElement(NULL, "DIDL-Lite");
	xml.Attribute(NULL, "xmlns", "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/");
	xml.Attribute("xmlns", "dc", "http://purl.org/dc/elements/1.1/");
	xml.Attribute("xmlns", "upnp", "urn:schemas-upnp-org:metadata-1-0/upnp/");

	for (NPT_Ordinal i = 0; i < ls.GetItemCount(); i++) {
		const Object *obj = *ls.GetItem(i);
		if (const Item *item = obj->asItem()) {
			outputItem(xml, item, resUriTmpl);
		} else if (const Container *container = obj->asContainer()) {
			outputContainer(xml, container, resUriTmpl);
		}
	}

	xml.EndElement(NULL, "DIDL-Lite");
	xml.EndDocument();
	return outputStream.GetString();
}
inline
void InpaintingAlgorithmWithVerification(TVertexListGraph& g, TInpaintingVisitor vis,
                     TBoundaryStatusMap* boundaryStatusMap, TPriorityQueue* boundaryNodeQueue,
                     TKNNFinder knnFinder, TBestNeighborFinder& bestNeighborFinder,
                     TManualNeighborFinder& manualNeighborFinder, TPatchInpainter inpaint_patch)
{
  BOOST_CONCEPT_ASSERT((InpaintingVisitorConcept<TInpaintingVisitor, TVertexListGraph>));

  typedef typename boost::graph_traits<TVertexListGraph>::vertex_descriptor VertexDescriptorType;

  unsigned int numberOfManualVerifications = 0;
  while(true)
  {
    // Find the next target to in-paint. Some of the nodes in the priority queue
    // can be already filled (they get "covered up" when a patch is filled around
    // a target node). So we do not just process the node at the front of the queue,
    // we also check that it has not been filled by looking at its value in the boundaryStatusMap

    VertexDescriptorType targetNode;
    do
    {
      if( (*boundaryNodeQueue).empty() )
      {
        std::cout << "Inpainting complete. There were " << numberOfManualVerifications << " manual verifications required." << std::endl;
        vis.InpaintingComplete();
        return;  //terminate if the queue is empty.
      }
      targetNode = (*boundaryNodeQueue).top();
      (*boundaryNodeQueue).pop();
    } while( get(*boundaryStatusMap, targetNode) == false);
    //} while( get(boundaryStatusMap, targetNode) == false && get(fillStatusMap, targetNode));

    // Notify the visitor that we have a hole target center.
    vis.DiscoverVertex(targetNode);

    // Find the source node that matches best to the target node
    typename boost::graph_traits<TVertexListGraph>::vertex_iterator vi,vi_end;
    tie(vi,vi_end) = vertices(g);

    std::vector<VertexDescriptorType> outputContainer(knnFinder.GetK());
    knnFinder(vi, vi_end, targetNode, outputContainer.begin());

    VertexDescriptorType sourceNode = bestNeighborFinder(outputContainer.begin(), outputContainer.end(), targetNode);
    vis.PotentialMatchMade(targetNode, sourceNode);

    if(!vis.AcceptMatch(targetNode, sourceNode))
      {
      numberOfManualVerifications++;
      std::cout << "So far there have been " << numberOfManualVerifications << " manual verifications." << std::endl;
      std::cout << "Automatic match not accepted!" << std::endl;
      sourceNode = manualNeighborFinder(outputContainer.begin(), outputContainer.end(), targetNode);
      }

    // Do the in-painting of the target patch from the source patch.
    // the inpaint_patch functor should take care of calling
    // "vis.paint_vertex(target, source)" on the individual vertices in the patch.
    inpaint_patch(targetNode, sourceNode, vis);

    vis.FinishVertex(targetNode, sourceNode);
  } // end main iteration loop

}