[pdal] Linking with PCL

pidgeon13 at googlemail.com pidgeon13 at googlemail.com
Fri Dec 15 01:44:03 PST 2017


Hi,

I am trying to use the voxelgrid filter in some c++ code I am writing (and would also like to be able to read and write .pcd files). I believe I have linked in PCL correctly, and my solution builds the plugin .dll files. However, although there is plenty of information on the PDAL website about using PCL in pipelines, I have not managed to find anything to help me use the API. I currently have a function I am playing around with to try and get the filter to work:

bool ReadFilterWrite(const std::string& inputfilename, const std::string& readerdriver, const std::string& outputfilename)
{
  	bool bFilterWorks=false;
 	pdal::StageFactory factory;
  	pdal::PointTable table;
  	pdal::Stage *pReader = factory.createStage(readerdriver);
  	pdal::Options readerOptions;
  	readerOptions.add("filename", inputfilename);
  	if (pReader)
  	{
  		pReader->setOptions(readerOptions);
  	}
  	else
  	{
    		return false;
  	}
  	pdal::Options writerOptions;
  	writerOptions.add("filename", outputfilename);
  	pdal::Stage *pWriter = factory.createStage("writers.text");
  	if (pWriter)
  	{
  		pdal::Stage *pFilter = factory.createStage("filters.voxelgrid");
    		if (pFilter)
    		{
    			bFilterWorks = true;
  			pFilter->setInput(*pReader);
    			pWriter->setInput(*pFilter);
    		}
    		else
    		{
     			//Currently commented out so that files are only written if the filter works.
    			//pWriter->setInput(*pReader);
    			return false; //Temporary, currently where the function exits.
    		}
   		pWriter->setOptions(writerOptions);
    		pWriter->prepare(table);
    		pWriter->execute(table);
  	}
  	return bFilterWorks;
}

The function reads the data in from a .las file (for example) fine, but then doesn’t create the filter stage. Am I going about this in the right way?

Best regards,

Stephen

Sent from Mail for Windows 10

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20171215/92c2b712/attachment.html>


More information about the pdal mailing list