|
32 | 32 | * OF SUCH DAMAGE. |
33 | 33 | ****************************************************************************/ |
34 | 34 |
|
| 35 | +#include "PyArray.hpp" |
35 | 36 | #include "PyPipeline.hpp" |
36 | 37 |
|
37 | 38 | #ifndef _WIN32 |
|
43 | 44 | #include <pdal/Stage.hpp> |
44 | 45 | #include <pdal/pdal_features.hpp> |
45 | 46 |
|
46 | | -#include "PyArray.hpp" |
47 | | - |
48 | 47 | namespace pdal |
49 | 48 | { |
50 | 49 | namespace python |
51 | 50 | { |
52 | 51 |
|
53 | | -// Create a pipeline for writing data to PDAL |
54 | | -PyPipelineExecutor::PyPipelineExecutor(std::string const& json, |
55 | | - std::vector<Array*> arrays) : PipelineExecutor(json) |
| 52 | + |
| 53 | +void readPipeline(PipelineExecutor* executor, std::string json) |
56 | 54 | { |
| 55 | + std::stringstream strm(json); |
| 56 | + executor->getManager().readPipeline(strm); |
| 57 | +} |
| 58 | + |
| 59 | + |
| 60 | +void addArrayReaders(PipelineExecutor* executor, std::vector<Array*> arrays) |
| 61 | +{ |
| 62 | + // Make the symbols in pdal_base global so that they're accessible |
| 63 | + // to PDAL plugins. Python dlopen's this extension with RTLD_LOCAL, |
| 64 | + // which means that without this, symbols in libpdal_base aren't available |
| 65 | + // for resolution of symbols on future runtime linking. This is an issue |
| 66 | + // on Alpine and other Linux variants that don't use UNIQUE symbols |
| 67 | + // for C++ template statics only. Without this, you end up with multiple |
| 68 | + // copies of template statics. |
57 | 69 | #ifndef _WIN32 |
58 | | - // See comment in alternate constructor below. |
59 | 70 | ::dlopen("libpdal_base.so", RTLD_NOLOAD | RTLD_GLOBAL); |
60 | 71 | #endif |
61 | 72 |
|
62 | | - PipelineManager& manager = getManager(); |
63 | | - std::stringstream strm(json); |
64 | | - manager.readPipeline(strm); |
| 73 | + PipelineManager& manager = executor->getManager(); |
65 | 74 | std::vector<Stage *> roots = manager.roots(); |
66 | 75 | if (roots.size() != 1) |
67 | 76 | throw pdal_error("Filter pipeline must contain a single root stage."); |
@@ -100,20 +109,6 @@ PyPipelineExecutor::PyPipelineExecutor(std::string const& json, |
100 | 109 | manager.validateStageOptions(); |
101 | 110 | } |
102 | 111 |
|
103 | | -// Create a pipeline for reading data from PDAL |
104 | | -PyPipelineExecutor::PyPipelineExecutor(std::string const& json) : PipelineExecutor(json) |
105 | | -{ |
106 | | - // Make the symbols in pdal_base global so that they're accessible |
107 | | - // to PDAL plugins. Python dlopen's this extension with RTLD_LOCAL, |
108 | | - // which means that without this, symbols in libpdal_base aren't available |
109 | | - // for resolution of symbols on future runtime linking. This is an issue |
110 | | - // on Alpine and other Linux variants that don't use UNIQUE symbols |
111 | | - // for C++ template statics only. Without this, you end up with multiple |
112 | | - // copies of template statics. |
113 | | -#ifndef _WIN32 |
114 | | - ::dlopen("libpdal_base.so", RTLD_NOLOAD | RTLD_GLOBAL); |
115 | | -#endif |
116 | | -} |
117 | 112 |
|
118 | 113 | inline PyObject* buildNumpyDescription(PointViewPtr view) |
119 | 114 | { |
@@ -182,10 +177,10 @@ PyArrayObject* viewToNumpyArray(PointViewPtr view) |
182 | 177 | return array; |
183 | 178 | } |
184 | 179 |
|
185 | | -std::vector<PyArrayObject*> PyPipelineExecutor::getArrays() const |
| 180 | +std::vector<PyArrayObject*> getArrays(const PipelineExecutor* executor) |
186 | 181 | { |
187 | 182 | std::vector<PyArrayObject*> output; |
188 | | - for (auto view: getManagerConst().views()) |
| 183 | + for (auto view: executor->getManagerConst().views()) |
189 | 184 | output.push_back(viewToNumpyArray(view)); |
190 | 185 | return output; |
191 | 186 | } |
@@ -243,10 +238,10 @@ PyArrayObject* meshToNumpyArray(const TriangularMesh* mesh) |
243 | 238 | } |
244 | 239 |
|
245 | 240 |
|
246 | | -std::vector<PyArrayObject*> PyPipelineExecutor::getMeshes() const |
| 241 | +std::vector<PyArrayObject*> getMeshes(const PipelineExecutor* executor) |
247 | 242 | { |
248 | 243 | std::vector<PyArrayObject*> output; |
249 | | - for (auto view: getManagerConst().views()) |
| 244 | + for (auto view: executor->getManagerConst().views()) |
250 | 245 | output.push_back(meshToNumpyArray(view->mesh())); |
251 | 246 | return output; |
252 | 247 | } |
|
0 commit comments