void MainWindow::onCreatePoint() {
    QVector<GLfloat> vertCoordsPoint = QVector<GLfloat>(0);

    this->getCoordsFromUser(vertCoordsPoint);
    if (vertCoordsPoint.size()) {
        Geometry::Point* p = new Geometry::Point(vertCoordsPoint.data()[0], vertCoordsPoint.data()[1], vertCoordsPoint.data()[2]);
        qDebug()<<"hierarchy: "<<p->getHierarchy();
        qDebug()<<"name: "<<p->getName();
    }
}
Exemple #2
0
	/**
	 * 画像のブロック転送
	 * @param dest 転送先のデバイスコンテキストオブジェクト
	 * @param sourcePosition 転送元の矩形範囲
	 * @param destPosition 転送先の矩形範囲
	 */
	bool blockTransfer(const DeviceContext& dest,
					   const geometry::Rectangle<int>& sourcePosition,
					   const geometry::Point<int>& destPosition) const throw()
	{
		return ::BitBlt(this->deviceContext,
						destPosition.getX(),
						destPosition.getY(),
						sourcePosition.getWidth(),
						sourcePosition.getHeight(),
						dest.getDeviceContext(),
						sourcePosition.getLeft(),
						sourcePosition.getTop(),
						SRCCOPY) == TRUE;
	}
            void Single::_storeBorder(const GEOMETRY::Point<uint32>& pos, PointVec<uint32>& borderTiles, sl::Bitset2D& bitset)
            {
                for (uint32 i = 0; i < 8; ++i)
                {
                    try
                    {
                        auto mapTileInfo = m_Layer.getBorderTileInfo(pos, static_cast<BorderTile>(i));
                        // resize bitset if needed
                        bitset.resize(std::max(bitset.getWidth(), pos.getX() + mapTileInfo.getPosition().getX() + 1),
                            std::max(bitset.getHeight(), pos.getY() + mapTileInfo.getPosition().getY() + 1));
                        if (bitset.get(mapTileInfo.getPosition()))
                            continue;
                        bitset.set(mapTileInfo.getPosition());

                        if (mapTileInfo.isValid() && mapTileInfo.isAutoTile())
                            borderTiles.push_back(mapTileInfo.getPosition());
                    }
                    catch (const EXCEPTION::TileOutOfRangeException&) {}
                }
            }
 QPixmap createPixmap(const TileSet* pTileSet, CACHE::Tiles& tileCache)
 {
     QPixmap pixmap;
     if (pTileSet)
     {
         pixmap = QPixmap(pTileSet->getSize().getWidth() * MAP::TILE_SIZE, pTileSet->getSize().getHeight() * MAP::TILE_SIZE);
         pixmap.fill();
         QPainter painter(&pixmap);
         GEOMETRY::Point<uint32> pos;
         for (pos.getX() = 0; pos.getX() < pTileSet->getSize().getWidth(); ++pos.getX())
         {
             for (pos.getY() = 0; pos.getY() < pTileSet->getSize().getHeight(); ++pos.getY())
             {
                 auto info = tileCache.get(pTileSet->getTileID(pos));
                 if (info.isValid())
                     painter.drawPixmap(pos.getX()*MAP::TILE_SIZE, pos.getY()*MAP::TILE_SIZE, *info.getPixmap(), info.getPosition().getX(), info.getPosition().getY(),
                     MAP::TILE_SIZE, MAP::TILE_SIZE);
             }
         }
     }
     return pixmap;
 }
            void Single::_do(const MapTileInfo& info, MapTileInfoVec& tiles, PointVec<uint32>& borderTiles)
            {
                // first set complete brush size -> bitset is checked
                sl::Bitset2D bitset;
                for (GEOMETRY::Point<uint32> pos; pos.getX() < getBrushSize().getWidth(); ++pos.getX())
                {
                    for (pos.getY() = 0; pos.getY() < getBrushSize().getHeight(); ++pos.getY())
                    {
                        try
                        {
                            auto mapTileInfo = m_Layer.getMapTile(pos + getStartPosition());
                            tiles.push_back(mapTileInfo);
                            if (pos.getX() == 0 || pos.getX() + 1 == getBrushSize().getWidth())
                            {
                                if (pos.getY() == 0 || pos.getY() + 1 == getBrushSize().getHeight())
                                    borderTiles.push_back(mapTileInfo.getPosition());
                            }

                            // resize bitset if needed
                            bitset.resize(std::max(bitset.getWidth(), pos.getX() + mapTileInfo.getPosition().getX() + 1),
                                std::max(bitset.getHeight(), pos.getY() + mapTileInfo.getPosition().getY() + 1));

                            bitset.set(pos + mapTileInfo.getPosition());
                        }
                        catch (const EXCEPTION::TileOutOfRangeException&) {}
                    }
                }

                // after that, we can really check borders
                for (GEOMETRY::Point<uint32> pos; pos.getX() < getBrushSize().getWidth(); ++pos.getX())
                {
                    for (pos.getY() = 0; pos.getY() < getBrushSize().getHeight(); ++pos.getY())
                        _storeBorder(getStartPosition() + pos, borderTiles, bitset);
                }
                
            }
void NodeColorSampler::operator()(LidarProcessOctree::Node& node,unsigned int nodeLevel)
	{
	if(node.isLeaf())
		{
		if(node.getNumPoints()>0)
			{
			/* Find all images whose bounding boxes overlap this node: */
			std::vector<Image2D*> nodeImages;
			for(std::vector<Image2D*>::const_iterator iIt=images.begin();iIt!=images.end();++iIt)
				{
				const Image2D::Box& box=(*iIt)->getWorldBox();
				if(box.min[0]-lpo.getOffset()[0]<node.getDomain().getMax()[0]&&box.max[0]-lpo.getOffset()[0]>node.getDomain().getMin()[0]
		  		 &&box.min[1]-lpo.getOffset()[1]<node.getDomain().getMax()[1]&&box.max[1]-lpo.getOffset()[1]>node.getDomain().getMin()[1])
					nodeImages.push_back(*iIt);
				}
			
			/* Page in all found images: */
			imageCacher.requestImages(nodeImages);
			
			/* Assign a color to each LiDAR point in this node: */
			for(unsigned int i=0;i<node.getNumPoints();++i)
				{
				/* Copy the point's original color: */
				colorBuffer[i]=node[i].value;
				
				/* Lookup the point in all images overlapping this node: */
				Geometry::Point<double,3> pos;
				for(int j=0;j<3;++j)
					pos[j]=double(node[i][j]+lpo.getOffset()[j]);
				for(std::vector<Image2D*>::iterator iIt=nodeImages.begin();iIt!=nodeImages.end();++iIt)
					{
					Image2D::SampleResult sr=(*iIt)->getColor(Image2D::Point(pos.getComponents()));
					if(sr.first)
						{
						/* Copy the sample result: */
						for(int j=0;j<3;++j)
							colorBuffer[i][j]=sr.second[j];
						colorBuffer[i][3]=Color::Scalar(255);
						
						++numAssignedColors;
						
						/* Bail out: */
						break;
						}
					}
				}
			}
		}
	else
		{
		/* Get pointers to the node's children and load their color arrays: */
		colorFile.flush();
		for(int childIndex=0;childIndex<8;++childIndex)
			{
			LidarProcessOctree::Node* child=lpo.getChild(&node,childIndex);
			if(child->getNumPoints()>0)
				{
				colorFile.setReadPosAbs(LidarDataFileHeader::getFileSize()+colorDataSize*child->getDataOffset());
				colorFile.read(childColorBuffers[childIndex],child->getNumPoints());
				}
			}
		
		/* Find the direct ancestors of all LiDAR points in this node and copy their color values from the child arrays: */
		for(unsigned int i=0;i<node.getNumPoints();++i)
			{
			/* Find the child node containing this point's ancestor: */
			int pointChildIndex=node.getDomain().findChild(node[i]);
			LidarProcessOctree::Node* pointChild=lpo.getChild(&node,pointChildIndex);
			
			/* Find the point's ancestor: */
			NodePointFinder npf(node[i]);
			lpo.processNodePointsDirected(pointChild,npf);
			if(npf.getFoundPoint()==0)
				{
				/* This is an internal corruption in the octree file. Print a helpful and non-offensive error message: */
				Misc::throwStdErr("Fatal error: Octree file corrupted around position (%f, %f, %f)",node[i][0],node[i][1],node[i][2]);
				}
			
			/* Retrieve the ancestor's color: */
			colorBuffer[i]=childColorBuffers[pointChildIndex][npf.getFoundPoint()-pointChild->getPoints()];
			}
		}
	
	/* Write the node's colors to the color file: */
	colorFile.setWritePosAbs(LidarDataFileHeader::getFileSize()+colorDataSize*node.getDataOffset());
	colorFile.write(colorBuffer,node.getNumPoints());
	
	/* Update the progress counter: */
	++numProcessedNodes;
	if(numProcessedNodes>=nextProgressUpdate)
		{
		int percent=int((numProcessedNodes*100+lpo.getNumNodes()/2)/lpo.getNumNodes());
		std::cout<<"\rAssigning colors... "<<std::setw(3)<<percent<<"%"<<std::flush;
		nextProgressUpdate=((percent+1)*lpo.getNumNodes()-lpo.getNumNodes()/2+99)/100;
		}
	}