<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-GB link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>bool ReadFilterWrite(const std::string& inputfilename, const std::string& readerdriver, const std::string& outputfilename)</p><p class=MsoNormal>{</p><p class=MsoNormal>                bool bFilterWorks=false;</p><p class=MsoNormal>                pdal::StageFactory factory;</p><p class=MsoNormal>                pdal::PointTable table;</p><p class=MsoNormal>                pdal::Stage *pReader = factory.createStage(readerdriver);</p><p class=MsoNormal>                pdal::Options readerOptions;</p><p class=MsoNormal>                readerOptions.add("filename", inputfilename);</p><p class=MsoNormal>                if (pReader)</p><p class=MsoNormal>                {</p><p class=MsoNormal>                                pReader->setOptions(readerOptions);</p><p class=MsoNormal>                }</p><p class=MsoNormal>                else</p><p class=MsoNormal>                {</p><p class=MsoNormal>                                return false;</p><p class=MsoNormal>                }</p><p class=MsoNormal>                pdal::Options writerOptions;</p><p class=MsoNormal>                writerOptions.add("filename", outputfilename);</p><p class=MsoNormal>                pdal::Stage *pWriter = factory.createStage("writers.text");</p><p class=MsoNormal>                if (pWriter)</p><p class=MsoNormal>                {</p><p class=MsoNormal>                                pdal::Stage *pFilter = factory.createStage("filters.voxelgrid");</p><p class=MsoNormal>                                if (pFilter)</p><p class=MsoNormal>                                {</p><p class=MsoNormal>                                                bFilterWorks = true;</p><p class=MsoNormal>                                                pFilter->setInput(*pReader);</p><p class=MsoNormal>                                                pWriter->setInput(*pFilter);</p><p class=MsoNormal>                                }</p><p class=MsoNormal>                                else</p><p class=MsoNormal>                                {</p><p class=MsoNormal>                                               //Currently commented out so that files are only written if the filter works.</p><p class=MsoNormal>                                                //pWriter->setInput(*pReader);</p><p class=MsoNormal>                                                return false; //Temporary, currently where the function exits.</p><p class=MsoNormal>                                }</p><p class=MsoNormal>                                pWriter->setOptions(writerOptions);</p><p class=MsoNormal>                                pWriter->prepare(table);</p><p class=MsoNormal>                                pWriter->execute(table);</p><p class=MsoNormal>                }</p><p class=MsoNormal>                return bFilterWorks;</p><p class=MsoNormal>}</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Best regards,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Stephen</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>