I&#39;m looking at adding PDAL support to an existing application--one that is mature enough that I&#39;m not sure I really want to embed PDAL throughout (e.g., converting my filtering methods to PDAL Filters), but I do want to use it for point cloud I/O.<br>


<br>My first step was to use PDAL to import data into the code&#39;s existing data structures, which works well enough. I&#39;m able to get all the necessary information about each dimension, and to subsequently use getField to pull the data into memory. I then use existing code to filter the data and write it to disk. I&#39;d like PDAL to take care of that last step, but I think I&#39;m currently limited in my ability to use PDAL in this manner given that there is so much emphasis on stages and pipelines, neither of which I&#39;m using. Is this by design?<br>


<br>Consider the following.<br><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">First, I make the reader stage, inferring driver type from the filename.<br>


<br></span>  pdal::Options readerOptions;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    readerOptions.add&lt;std::string&gt;(&quot;filename&quot;, in_filename);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace">  }</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  pdal::Stage *reader = AppSupport::makeReader(readerOptions);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace"><br><span style="font-family:arial,helvetica,sans-serif">Next, I go ahead and read all of the data into a PointBuffer.</span><br>


<br>  pdal::PointBuffer in_buffer(schema, reader-&gt;getNumPoints());<br>  pdal::StageSequentialIterator *iter = reader-&gt;createSequentialIterator(</span><span style="font-family:courier new,monospace">in_buffer</span><span style="font-family:courier new,monospace">);<br>


  boost::uint32_t num_read = iter-&gt;read(</span><span style="font-family:courier new,monospace">in_buffer</span><span style="font-family:courier new,monospace">);<br><br>  for (boost::uint32_t point_idx = 0; point_idx &lt; num_read; ++point_idx)<br>


  {<br>    x[point_idx] = </span><span style="font-family:courier new,monospace">in_buffer</span><span style="font-family:courier new,monospace">.getField&lt;float&gt;(data.getSchema().getDimension(&quot;X&quot;), point_idx);<br>


  }<br><br><span style="font-family:arial,helvetica,sans-serif">Here I&#39;d like to do &quot;stuff.&quot; The operations do not necessarily </span><span style="font-family:arial,helvetica,sans-serif">retain the same number of points as the input. Points may </span><span style="font-family:arial,helvetica,sans-serif">also be scaled, smoothed, classified, etc.</span><br>


<br><span style="font-family:arial,helvetica,sans-serif">When I&#39;m done filtering the data, I create a new buffer, using the existing schema, but limited to the number of points I&#39;ve retained.</span><br><br>  pdal::PointBuffer out_buffer(reader-&gt;getSchema(), num_points_kept);<br>


<br><span style="font-family:arial,helvetica,sans-serif">I then iterate over the points, setting the modified dimension to its new value.</span><br><br>  for (boost::int32_t point_idx = 0; point_idx &lt; num_points_kept; ++point_idx)<br>


  {<br>    </span><span style="font-family:courier new,monospace">out_buffer</span><span style="font-family:courier new,monospace">.setField&lt;float&gt;(</span><span style="font-family:courier new,monospace">out_buffer</span><span style="font-family:courier new,monospace">.getSchema().getDimension(&quot;X&quot;), point_idx, x[point_idx]);<br>


  }<br></span><span style="font-family:courier new,monospace"><br><span style="font-family:arial,helvetica,sans-serif">Here&#39;s the problem, I don&#39;t really want to create the writer using the reader as the previous stage (as shown below), but I also didn&#39;t want to go to the lengths of creating a filter to serve as the previous stage. Given the scenario, is there a way to write the modified cloud?</span><br>


<br>  pdal::Options writerOptions;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    writerOptions.add&lt;std::string&gt;(&quot;filename&quot;, out_filename);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace">  }</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace">  pdal::Writer *writer = AppSupport::makeWriter(writerOptions, *reader);</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">  writer-&gt;initialize();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace">  writer-&gt;write();</span><br>


<br>As an aside, note the use of makeReader and makeWriter. I like being able to infer the I/O drivers from the filename, as is done
 in the apps (e.g., pc2pc), hence the reuse here. Has there been any discussion about bringing these into the main library and exposing them?<br><br>Brad<br>