Example #1
0
void World::UpdateGenerateQueue() {
	std::sort(m_vpChunksToGenerate.begin(), m_vpChunksToGenerate.end(), SortByDistance());

	int count = 0;
	std::vector<Chunk*>::iterator it = m_vpChunksToGenerate.begin();
	while(it != m_vpChunksToGenerate.end()) {
		if(count >= m_generatePerFrame) break;
		Chunk* pChunk = *it;
		pChunk->GenerateVoxels();
		//it = m_vpChunksToGenerate.erase(std::remove(m_vpChunksToGenerate.begin(), m_vpChunksToGenerate.end(), pChunk), m_vpChunksToGenerate.end());
		//it++;
		m_vpChunksToGenerate.erase(it++);
		count++;
	}
}
Example #2
0
OSMNode Router::calcStartEndNode(GPSPosition pos, double radius)
{
    OSMPropertyTreeAlwaysTrueNode alwaystrue;
    QList<boost::shared_ptr<OSMNode> > nodeList = db->getNodes(pos, radius, alwaystrue);
    
    qSort(nodeList.begin(), nodeList.end(), SortByDistance(pos) );
    
    for (QList<boost::shared_ptr<OSMNode> >::iterator it = nodeList.begin(); it < nodeList.end(); it++)
    {
        QList<boost::shared_ptr<OSMEdge> > edgeList = db->getEdges(*(it->get()), *(metric->getAssociatedPropertyTree()));
        if (!edgeList.isEmpty())
            return *(it->get());
    }
    
    return OSMNode();
}
Example #3
0
void World::UpdateMeshQueue() {
	std::sort(m_vpChunksToMesh.begin(), m_vpChunksToMesh.end(), SortByDistance());

	int count = 0;
	std::vector<Chunk*>::iterator it = m_vpChunksToMesh.begin();
	while(it != m_vpChunksToMesh.end()) {
		if(count >= m_meshPerFrame) break;
		Chunk* pChunk = *it;
		pChunk->BuildMesh();
		pChunk->RebuildNeighbours();
		//it = m_vpChunksToGenerate.erase(std::remove(m_vpChunksToGenerate.begin(), m_vpChunksToGenerate.end(), pChunk), m_vpChunksToGenerate.end());
		//it++;
		m_vpChunksToMesh.erase(it++);
		count++;
	}
}
Example #4
0
AirspaceSelectInfoVector
FilterAirspaces(const Airspaces &airspaces, const GeoPoint &location,
                const AirspaceFilterData &filter)
{
  AirspaceFilterVisitor visitor(location, airspaces.GetProjection(), filter);

  if (!negative(filter.distance))
    airspaces.VisitWithinRange(location, filter.distance, visitor);
  else
    for (const auto &i : airspaces)
      visitor.Visit(i.GetAirspace());

  if (filter.direction.IsNegative() && negative(filter.distance))
    SortByName(visitor.result);
  else
    SortByDistance(visitor.result, location, airspaces.GetProjection());

  return visitor.result;
}
Example #5
0
void MainWindow::exportImage() {

    QVector<CPoint> centroids = nGas.getCentroids();
    QVector<KPoint> points = nGas.getPoints();

    QImage image(imageSize,QImage::Format_RGB32);

    QProgressDialog progress(this);
    progress.setWindowTitle("Self-organizing maps");
    progress.setLabelText("Generating file...");
    progress.setModal(true);
    progress.show();

    int k = 0;

    for(int i=0;i<image.width();i++) {
        progress.setValue(((double)i / (double)image.width()) * 100);
        if(progress.wasCanceled())
            return;

        for(int j=0;j<image.height();j++) {
            for(int d=0;d<centroids.size();d++)
                centroids[d].setDistance(Centroids::countDistance(centroids[d],points[k]));
            qSort(centroids.begin(),centroids.end(),SortByDistance());
            image.setPixel(i,j,qRgb(centroids[0].paramAt(0),centroids[1].paramAt(1),centroids[2].paramAt(2)));
            k++;
        }
    }

    progress.setValue(100);

    QGraphicsScene* scene = new QGraphicsScene(this);
    ui->graphicsView_2->setScene(scene);
    scene->addPixmap(QPixmap::fromImage(image.scaled(ui->graphicsView->width()*0.95,ui->graphicsView->height()*0.95)));
    ui->graphicsView_2->show();

    QImageWriter writer;
    writer.setFileName(QFileDialog::getSaveFileName(this,tr("Open image"),"C:\\Users\\GiBSoN\\Desktop",tr("Image files (*.jpg *.png)")));
    writer.setFormat("jpg");
    writer.setCompression(10);
    writer.write(image);
}