Oh ok. Here are the diffs
--- /home/addo/dev/VTK/VTK/Imaging/Stencil/vtkPolyDataToImageStencil.h 2022-10-18 10:30:17.586273841 +1100
+++ vtkPolyDataToImageStencil.h 2022-10-18 16:14:09.815632570 +1100
@@ -65,12 +65,18 @@
#include "vtkImageStencilSource.h"
#include "vtkImagingStencilModule.h" // For export macro
+#include <iostream>
+
class vtkMergePoints;
class vtkDataSet;
class vtkPolyData;
+
+
+
class VTKIMAGINGSTENCIL_EXPORT vtkPolyDataToImageStencil : public vtkImageStencilSource
{
+ friend class ParallelWorker;
public:
static vtkPolyDataToImageStencil* New();
vtkTypeMacro(vtkPolyDataToImageStencil, vtkImageStencilSource);
@@ -120,4 +126,35 @@
void operator=(const vtkPolyDataToImageStencil&) = delete;
};
+class ParallelWorker
+{
+public:
+ ParallelWorker( int extent[6], vtkPolyDataToImageStencil* algorithm, vtkImageStencilData* data )
+ {
+ m_extent[0] = extent[0];
+ m_extent[1] = extent[1];
+ m_extent[2] = extent[2];
+ m_extent[3] = extent[3];
+ m_extent[4] = extent[4];
+ m_extent[5] = extent[5];
+ m_algorithm = algorithm;
+ m_data = data;
+ }
+ ~ParallelWorker(){ }
+
+ void operator()(int begin, int end)
+ {
+ int subExtent[6] = { m_extent[0], m_extent[1],
+ m_extent[2], m_extent[3],
+ begin, end - 1 };
+ //std::cout << "begin " << begin << " " << end << std::endl;
+ m_algorithm->ThreadedExecute(m_data, subExtent, 0);
+ }
+
+protected:
+ int m_extent[6];
+ vtkPolyDataToImageStencil* m_algorithm;
+ vtkImageStencilData* m_data;
+};
#endif
+
--- /home/addo/dev/VTK/VTK/Imaging/Stencil/vtkPolyDataToImageStencil.cxx 2022-10-18 10:30:17.586273841 +1100
+++ vtkPolyDataToImageStencil.cxx 2022-10-18 16:14:09.815632570 +1100
@@ -63,12 +63,15 @@
#include "vtkSignedCharArray.h"
#include "vtkStreamingDemandDrivenPipeline.h"
+#include "vtkSMPTools.h"
+
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cmath>
+#include <iostream>
vtkStandardNewMacro(vtkPolyDataToImageStencil);
@@ -457,7 +460,8 @@
// the spacing and origin of the generated stencil
double* spacing = data->GetSpacing();
double* origin = data->GetOrigin();
-
+ //std::cout << "[" << extent[0] << ", " << extent[1] << ", " << extent[2] << ", "
+ // << extent[3] << ", " << extent[4] << ", " << extent[5] << "], threadId " << threadId << std::endl;
// if we have no data then return
if (!this->GetInput()->GetNumberOfPoints())
{
@@ -773,7 +777,13 @@
data->GetExtent(extent);
// ThreadedExecute is only called from a single thread for
// now, but it could as easily be called from ThreadedRequestData
- this->ThreadedExecute(data, extent, 0);
+ ParallelWorker worker( extent, this, data );
+ // this->ThreadedExecute(data, extent, 0);
+
+ vtkSMPTools::Initialize();
+ vtkSMPTools::SetBackend("TBB");
+ //std::cout << vtkSMPTools::GetEstimatedNumberOfThreads() << std::endl;
+ vtkSMPTools::For(extent[4], extent[5] + 1, 1, worker );
return 1;
}