1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkDuplicatePolyData.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /**
16  * @class   vtkDuplicatePolyData
17  * @brief   For distributed tiled displays.
18  *
19  * This filter collects poly data and duplicates it on every node.
20  * Converts data parallel so every node has a complete copy of the data.
21  * The filter is used at the end of a pipeline for driving a tiled
22  * display.
23 */
24 
25 #ifndef vtkDuplicatePolyData_h
26 #define vtkDuplicatePolyData_h
27 
28 #include "vtkFiltersParallelModule.h" // For export macro
29 #include "vtkPolyDataAlgorithm.h"
30 class vtkSocketController;
31 class vtkMultiProcessController;
32 
33 class VTKFILTERSPARALLEL_EXPORT vtkDuplicatePolyData : public vtkPolyDataAlgorithm
34 {
35 public:
36   static vtkDuplicatePolyData *New();
37   vtkTypeMacro(vtkDuplicatePolyData, vtkPolyDataAlgorithm);
38   void PrintSelf(ostream& os, vtkIndent indent) override;
39 
40   //@{
41   /**
42    * By default this filter uses the global controller,
43    * but this method can be used to set another instead.
44    */
45   virtual void SetController(vtkMultiProcessController*);
46   vtkGetObjectMacro(Controller, vtkMultiProcessController);
47   //@}
48 
49   void InitializeSchedule(int numProcs);
50 
51   //@{
52   /**
53    * This flag causes sends and receives to be matched.
54    * When this flag is off, two sends occur then two receives.
55    * I want to see if it makes a difference in performance.
56    * The flag is on by default.
57    */
58   vtkSetMacro(Synchronous, vtkTypeBool);
59   vtkGetMacro(Synchronous, vtkTypeBool);
60   vtkBooleanMacro(Synchronous, vtkTypeBool);
61   //@}
62 
63   //@{
64   /**
65    * This duplicate filter works in client server mode when this
66    * controller is set.  We have a client flag to differentiate the
67    * client and server because the socket controller is odd:
68    * Proth processes think their id is 0.
69    */
GetSocketController()70   vtkSocketController *GetSocketController() {return this->SocketController;}
71   void SetSocketController (vtkSocketController *controller);
72   vtkSetMacro(ClientFlag,int);
73   vtkGetMacro(ClientFlag,int);
74   //@}
75 
76   //@{
77   /**
78    * This returns to size of the output (on this process).
79    * This method is not really used.  It is needed to have
80    * the same API as vtkCollectPolyData.
81    */
82   vtkGetMacro(MemorySize, unsigned long);
83   //@}
84 
85 protected:
86   vtkDuplicatePolyData();
87   ~vtkDuplicatePolyData() override;
88 
89   // Data generation method
90   int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
91   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
92   void ClientExecute(vtkPolyData *output);
93 
94   vtkMultiProcessController *Controller;
95   vtkTypeBool Synchronous;
96 
97   int NumberOfProcesses;
98   int ScheduleLength;
99   int **Schedule;
100 
101   // For client server mode.
102   vtkSocketController *SocketController;
103   int ClientFlag;
104 
105   unsigned long MemorySize;
106 
107 private:
108   vtkDuplicatePolyData(const vtkDuplicatePolyData&) = delete;
109   void operator=(const vtkDuplicatePolyData&) = delete;
110 };
111 
112 #endif
113 
114