forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkStreamingDemandDrivenPipeline.cxx
2089 lines (1944 loc) · 69.9 KB
/
vtkStreamingDemandDrivenPipeline.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*=========================================================================
Program: Visualization Toolkit
Module: vtkStreamingDemandDrivenPipeline.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkAlgorithm.h"
#include "vtkAlgorithmOutput.h"
#include "vtkDataObject.h"
#include "vtkDataSet.h"
#include "vtkExtentTranslator.h"
#include "vtkInformation.h"
#include "vtkInformationDoubleKey.h"
#include "vtkInformationDoubleVectorKey.h"
#include "vtkInformationIntegerKey.h"
#include "vtkInformationStringKey.h"
#include "vtkInformationIdTypeKey.h"
#include "vtkInformationInformationVectorKey.h"
#include "vtkInformationIntegerVectorKey.h"
#include "vtkInformationObjectBaseKey.h"
#include "vtkInformationRequestKey.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
vtkStandardNewMacro(vtkStreamingDemandDrivenPipeline);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, CONTINUE_EXECUTING, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, EXACT_EXTENT, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, REQUEST_UPDATE_EXTENT, Request);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, REQUEST_UPDATE_EXTENT_INFORMATION, Request);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, REQUEST_RESOLUTION_PROPAGATE, Request);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, MAXIMUM_NUMBER_OF_PIECES, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_EXTENT_INITIALIZED, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_PIECE_NUMBER, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_NUMBER_OF_PIECES, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_NUMBER_OF_GHOST_LEVELS, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_EXTENT_TRANSLATED, Integer);
vtkInformationKeyRestrictedMacro(vtkStreamingDemandDrivenPipeline, WHOLE_EXTENT, IntegerVector, 6);
vtkInformationKeyRestrictedMacro(vtkStreamingDemandDrivenPipeline, UPDATE_EXTENT, IntegerVector, 6);
vtkInformationKeyRestrictedMacro(vtkStreamingDemandDrivenPipeline,
EXTENT_TRANSLATOR, ObjectBase,
"vtkExtentTranslator");
vtkInformationKeyRestrictedMacro(vtkStreamingDemandDrivenPipeline, WHOLE_BOUNDING_BOX, DoubleVector, 6);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, TIME_STEPS, DoubleVector);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_TIME_STEPS, DoubleVector);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PREVIOUS_UPDATE_TIME_STEPS, DoubleVector);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, TIME_RANGE, DoubleVector);
vtkInformationKeyRestrictedMacro(vtkStreamingDemandDrivenPipeline, PIECE_BOUNDING_BOX, DoubleVector, 6);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PRIORITY, Double);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, UPDATE_RESOLUTION, Double);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, REMOVE_ATTRIBUTE_INFORMATION, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, FAST_PATH_FOR_TEMPORAL_DATA, Integer);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, FAST_PATH_OBJECT_TYPE, String);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, FAST_PATH_ID_TYPE, String);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, FAST_PATH_OBJECT_ID, IdType);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PREVIOUS_FAST_PATH_OBJECT_ID, IdType);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PREVIOUS_FAST_PATH_OBJECT_TYPE, String);
vtkInformationKeyMacro(vtkStreamingDemandDrivenPipeline, PREVIOUS_FAST_PATH_ID_TYPE, String);
//----------------------------------------------------------------------------
class vtkStreamingDemandDrivenPipelineToDataObjectFriendship
{
public:
static void Crop(vtkDataObject* obj)
{
obj->Crop();
}
};
//----------------------------------------------------------------------------
vtkStreamingDemandDrivenPipeline::vtkStreamingDemandDrivenPipeline()
{
this->ContinueExecuting = 0;
this->UpdateExtentRequest = 0;
this->LastPropogateUpdateExtentShortCircuited = 0;
}
//----------------------------------------------------------------------------
vtkStreamingDemandDrivenPipeline::~vtkStreamingDemandDrivenPipeline()
{
if (this->UpdateExtentRequest)
{
this->UpdateExtentRequest->Delete();
}
}
//----------------------------------------------------------------------------
void vtkStreamingDemandDrivenPipeline::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
int vtkStreamingDemandDrivenPipeline
::ProcessRequest(vtkInformation* request,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// The algorithm should not invoke anything on the executive.
if(!this->CheckAlgorithm("ProcessRequest", request))
{
return 0;
}
// Look for specially supported requests.
if(request->Has(REQUEST_UPDATE_EXTENT()))
{
// Get the output port from which the request was made.
this->LastPropogateUpdateExtentShortCircuited = 1;
int outputPort = -1;
if(request->Has(FROM_OUTPUT_PORT()))
{
outputPort = request->Get(FROM_OUTPUT_PORT());
}
// Make sure the information on the output port is valid.
if(!this->VerifyOutputInformation(outputPort,inInfoVec,outInfoVec))
{
return 0;
}
// If we need to execute, propagate the update extent.
int result = 1;
int N2E = this->NeedToExecuteData(outputPort,inInfoVec,outInfoVec);
if (!N2E &&
outputPort>-1 &&
this->GetNumberOfInputPorts() &&
inInfoVec[0]->GetNumberOfInformationObjects () > 0)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(outputPort);
vtkInformation* inInfo = inInfoVec[0]->GetInformationObject(0);
int outNumberOfPieces = outInfo->Get(UPDATE_NUMBER_OF_PIECES());
int inNumberOfPieces = inInfo->Get(UPDATE_NUMBER_OF_PIECES());
if(inNumberOfPieces != outNumberOfPieces)
{
N2E = 1;
}
else
{
if (outNumberOfPieces != 1)
{
int outPiece = outInfo->Get(UPDATE_PIECE_NUMBER());
int inPiece = inInfo->Get(UPDATE_PIECE_NUMBER());
if (inPiece != outPiece)
{
N2E = 1;
}
else
{
if (outInfo->Get(UPDATE_RESOLUTION()) !=
inInfo->Get(UPDATE_RESOLUTION()))
{
N2E = 1;
}
}
}
}
}
if(N2E)
{
// Make sure input types are valid before algorithm does anything.
if(!this->InputCountIsValid(inInfoVec) ||
!this->InputTypeIsValid(inInfoVec))
{
return 0;
}
// Remove update-related keys from the input information.
this->ResetUpdateInformation(request, inInfoVec, outInfoVec);
// Invoke the request on the algorithm.
this->LastPropogateUpdateExtentShortCircuited = 0;
result = this->CallAlgorithm(request, vtkExecutive::RequestUpstream,
inInfoVec, outInfoVec);
// Propagate the update extent to all inputs.
if(result)
{
result = this->ForwardUpstream(request);
}
result = 1;
}
return result;
}
if(request->Has(REQUEST_DATA()))
{
// Let the superclass handle the request first.
if(this->Superclass::ProcessRequest(request, inInfoVec, outInfoVec))
{
// Crop the output if the exact extent flag is set.
for(int i=0; i < outInfoVec->GetNumberOfInformationObjects(); ++i)
{
vtkInformation* info = outInfoVec->GetInformationObject(i);
if(info->Has(EXACT_EXTENT()) && info->Get(EXACT_EXTENT()))
{
vtkDataObject* data = info->Get(vtkDataObject::DATA_OBJECT());
vtkStreamingDemandDrivenPipelineToDataObjectFriendship::Crop(data);
}
}
return 1;
}
return 0;
}
// Let the superclass handle other requests.
return this->Superclass::ProcessRequest(request, inInfoVec, outInfoVec);
}
//----------------------------------------------------------------------------
int vtkStreamingDemandDrivenPipeline::Update()
{
return this->Superclass::Update();
}
//----------------------------------------------------------------------------
int vtkStreamingDemandDrivenPipeline::Update(int port)
{
if(!this->UpdateInformation())
{
return 0;
}
if(port >= -1 && port < this->Algorithm->GetNumberOfOutputPorts())
{
int retval = 1;
// some streaming filters can request that the pipeline execute multiple
// times for a single update
do
{
retval = retval && this->PropagateUpdateExtent(port);
if (retval && !this->LastPropogateUpdateExtentShortCircuited)
{
retval = retval && this->UpdateData(port);
}
}
while (this->ContinueExecuting);
return retval;
}
else
{
return 1;
}
}
//----------------------------------------------------------------------------
int vtkStreamingDemandDrivenPipeline::UpdateWholeExtent()
{
this->UpdateInformation();
// if we have an output then set the UE to WE for it
if (this->Algorithm->GetNumberOfOutputPorts())
{
this->SetUpdateExtentToWholeExtent
(this->GetOutputInformation()->GetInformationObject(0));
}
// otherwise do it for the inputs
else
{
// Loop over all input ports.
for(int i=0; i < this->Algorithm->GetNumberOfInputPorts(); ++i)
{
// Loop over all connections on this input port.
int numInConnections = this->Algorithm->GetNumberOfInputConnections(i);
for (int j=0; j<numInConnections; j++)
{
// Get the pipeline information for this input connection.
vtkInformation* inInfo = this->GetInputInformation(i, j);
this->SetUpdateExtentToWholeExtent(inInfo);
}
}
}
return this->Update();
}
//----------------------------------------------------------------------------
int
vtkStreamingDemandDrivenPipeline
::ExecuteInformation(vtkInformation* request,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// Let the superclass make the request to the algorithm.
if(this->Superclass::ExecuteInformation(request,inInfoVec,outInfoVec))
{
for(int i=0; i < this->Algorithm->GetNumberOfOutputPorts(); ++i)
{
vtkInformation* info = outInfoVec->GetInformationObject(i);
vtkDataObject* data = info->Get(vtkDataObject::DATA_OBJECT());
if (!data)
{
return 0;
}
// Set default maximum request.
if(data->GetExtentType() == VTK_PIECES_EXTENT ||
data->GetExtentType() == VTK_TIME_EXTENT)
{
if(!info->Has(MAXIMUM_NUMBER_OF_PIECES()))
{
info->Set(MAXIMUM_NUMBER_OF_PIECES(), -1);
}
}
else if(data->GetExtentType() == VTK_3D_EXTENT)
{
if(!info->Has(WHOLE_EXTENT()))
{
int extent[6] = {0,-1,0,-1,0,-1};
info->Set(WHOLE_EXTENT(), extent, 6);
}
}
// Make sure an update request exists.
if(!info->Has(UPDATE_EXTENT_INITIALIZED()) ||
!info->Get(UPDATE_EXTENT_INITIALIZED()))
{
// Request all data by default.
this->SetUpdateExtentToWholeExtent
(outInfoVec->GetInformationObject(i));
}
}
return 1;
}
else
{
return 0;
}
}
//----------------------------------------------------------------------------
void
vtkStreamingDemandDrivenPipeline
::CopyDefaultInformation(vtkInformation* request, int direction,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// Let the superclass copy first.
this->Superclass::CopyDefaultInformation(request, direction,
inInfoVec, outInfoVec);
if(request->Has(REQUEST_INFORMATION()))
{
if(this->GetNumberOfInputPorts() > 0)
{
if(vtkInformation* inInfo = inInfoVec[0]->GetInformationObject(0))
{
// Copy information from the first input to all outputs.
for(int i=0; i < outInfoVec->GetNumberOfInformationObjects(); ++i)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(i);
outInfo->CopyEntry(inInfo, WHOLE_BOUNDING_BOX());
outInfo->CopyEntry(inInfo, WHOLE_EXTENT());
outInfo->CopyEntry(inInfo, MAXIMUM_NUMBER_OF_PIECES());
outInfo->CopyEntry(inInfo, EXTENT_TRANSLATOR());
outInfo->CopyEntry(inInfo, TIME_STEPS());
outInfo->CopyEntry(inInfo, TIME_RANGE());
}
}
}
// Setup default information for the outputs.
for(int i=0; i < outInfoVec->GetNumberOfInformationObjects(); ++i)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(i);
// The data object will exist because UpdateDataObject has already
// succeeded. Except when this method is called by a subclass
// that does not provide this key in certain cases.
vtkDataObject* dataObject = outInfo->Get(vtkDataObject::DATA_OBJECT());
if (!dataObject)
{
continue;
}
vtkInformation* dataInfo = dataObject->GetInformation();
if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) ==
VTK_PIECES_EXTENT ||
dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) ==
VTK_TIME_EXTENT)
{
if (!outInfo->Has(MAXIMUM_NUMBER_OF_PIECES()))
{
if (this->GetNumberOfInputPorts() > 0)
{
// must have structured input; MAXIMUM_NUMBER_OF_PIECES will
// not be copied above (CopyEntry does nothing since key not set
// in inInfo); set to -1
outInfo->Set(MAXIMUM_NUMBER_OF_PIECES(), -1);
}
else
{
// Since most unstructured filters in VTK generate all their
// data once, set the default maximum number of pieces to 1.
outInfo->Set(MAXIMUM_NUMBER_OF_PIECES(), 1);
}
}
}
else if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_3D_EXTENT)
{
if(!outInfo->Has(EXTENT_TRANSLATOR()) ||
!outInfo->Get(EXTENT_TRANSLATOR()))
{
// Create a default extent translator.
vtkExtentTranslator* translator = vtkExtentTranslator::New();
outInfo->Set(EXTENT_TRANSLATOR(), translator);
translator->Delete();
}
}
}
}
if(request->Has(REQUEST_UPDATE_EXTENT()))
{
//Copy requested resolution back
// Get the output port from which to copy the extent.
int outputPort = -1;
if(request->Has(FROM_OUTPUT_PORT()))
{
outputPort = request->Get(FROM_OUTPUT_PORT());
}
// Setup default information for the inputs.
if(outInfoVec->GetNumberOfInformationObjects() > 0)
{
// Copy information from the output port that made the request.
// Since VerifyOutputInformation has already been called we know
// there is output information with a data object.
vtkInformation* outInfo =
outInfoVec->GetInformationObject((outputPort >= 0)? outputPort : 0);
vtkDataObject* outData = outInfo->Get(vtkDataObject::DATA_OBJECT());
// Loop over all input ports.
for(int i=0; i < this->Algorithm->GetNumberOfInputPorts(); ++i)
{
// Loop over all connections on this input port.
int numInConnections = inInfoVec[i]->GetNumberOfInformationObjects();
for (int j=0; j<numInConnections; j++)
{
// Get the pipeline information for this input connection.
vtkInformation* inInfo = inInfoVec[i]->GetInformationObject(j);
// Copy the time request
if ( outInfo->Has(UPDATE_TIME_STEPS()) )
{
inInfo->CopyEntry(outInfo, UPDATE_TIME_STEPS());
}
// Copy the fast-path-specific keys
if ( outInfo->Has(FAST_PATH_OBJECT_ID()) )
{
inInfo->CopyEntry(outInfo, FAST_PATH_OBJECT_ID());
}
if ( outInfo->Has(FAST_PATH_OBJECT_TYPE()) )
{
inInfo->CopyEntry(outInfo, FAST_PATH_OBJECT_TYPE());
}
if ( outInfo->Has(FAST_PATH_ID_TYPE()) )
{
inInfo->CopyEntry(outInfo, FAST_PATH_ID_TYPE());
}
// If an algorithm wants an exact extent it must explicitly
// add it to the request. We do not want to get the setting
// from another consumer of the same input.
inInfo->Remove(EXACT_EXTENT());
// Get the input data object for this connection. It should
// have already been created by the UpdateDataObject pass.
vtkDataObject* inData = inInfo->Get(vtkDataObject::DATA_OBJECT());
if(!inData)
{
vtkErrorMacro("Cannot copy default update request from output port "
<< outputPort << " on algorithm "
<< this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ") to input connection "
<< j << " on input port " << i
<< " because there is no data object.");
continue;
}
//Copy requested resolution back
inInfo->CopyEntry(outInfo, UPDATE_RESOLUTION());
// Consider all combinations of extent types.
if(inData->GetExtentType() == VTK_PIECES_EXTENT)
{
if(outData->GetExtentType() == VTK_PIECES_EXTENT)
{
if (outInfo->Get(UPDATE_PIECE_NUMBER()) < 0)
{
return;
}
inInfo->CopyEntry(outInfo, UPDATE_PIECE_NUMBER());
inInfo->CopyEntry(outInfo, UPDATE_NUMBER_OF_PIECES());
inInfo->CopyEntry(outInfo, UPDATE_NUMBER_OF_GHOST_LEVELS());
inInfo->CopyEntry(outInfo, UPDATE_EXTENT_INITIALIZED());
}
else if(outData->GetExtentType() == VTK_3D_EXTENT)
{
// The conversion from structrued requests to
// unstrcutured requests is always to request the whole
// extent.
this->SetUpdateExtentToWholeExtent(inInfo);
}
}
else if(inData->GetExtentType() == VTK_3D_EXTENT)
{
if (outInfo->Get(UPDATE_PIECE_NUMBER()) >= 0)
{
// Although only the extent is used when processing
// structured datasets, this is still passed to let
// algorithms know what the actual request was.
inInfo->CopyEntry(outInfo, UPDATE_PIECE_NUMBER());
inInfo->CopyEntry(outInfo, UPDATE_NUMBER_OF_PIECES());
inInfo->CopyEntry(outInfo, UPDATE_NUMBER_OF_GHOST_LEVELS());
}
if(outData->GetExtentType() == VTK_PIECES_EXTENT)
{
int piece = outInfo->Get(UPDATE_PIECE_NUMBER());
int numPieces = outInfo->Get(UPDATE_NUMBER_OF_PIECES());
int ghostLevel = outInfo->Get(UPDATE_NUMBER_OF_GHOST_LEVELS());
if (piece >= 0)
{
this->SetUpdateExtent(inInfo, piece, numPieces, ghostLevel);
}
}
else if(outData->GetExtentType() == VTK_3D_EXTENT)
{
inInfo->CopyEntry(outInfo, UPDATE_EXTENT());
inInfo->CopyEntry(outInfo, UPDATE_EXTENT_INITIALIZED());
}
}
else if(inData->GetExtentType() == VTK_TIME_EXTENT)
{
if(outData->GetExtentType() == VTK_TIME_EXTENT)
{
inInfo->CopyEntry(outInfo, UPDATE_PIECE_NUMBER());
inInfo->CopyEntry(outInfo, UPDATE_NUMBER_OF_PIECES());
inInfo->CopyEntry(outInfo, UPDATE_NUMBER_OF_GHOST_LEVELS());
inInfo->CopyEntry(outInfo, UPDATE_TIME_STEPS());
inInfo->CopyEntry(outInfo, UPDATE_EXTENT_INITIALIZED());
}
}
}
}
}
}
if(request->Has(REQUEST_UPDATE_EXTENT_INFORMATION()))
{
// Copy the meta information across that algorithm as long as
// the algorithm doesn't change the information that the meta-information
// is about.
if(this->GetNumberOfInputPorts() > 0 &&
inInfoVec[0]->GetNumberOfInformationObjects() > 0)
{
vtkInformation* inInfo = inInfoVec[0]->GetInformationObject(0);
int oiobj = outInfoVec->GetNumberOfInformationObjects();
for(int i=0; i < oiobj; ++i)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(i);
// Copy the priority result always, algorithms can modify it in RUEI if needed
outInfo->CopyEntry(inInfo, PRIORITY());
// Copy the attribute meta information when algorithm is known not to modify it
vtkInformation *algsProps = this->GetAlgorithm()->GetInformation();
if (
algsProps->Has(vtkAlgorithm::PRESERVES_RANGES()) ||
algsProps->Has(vtkAlgorithm::PRESERVES_ATTRIBUTES()) ||
algsProps->Has(vtkAlgorithm::PRESERVES_DATASET())
)
{
if (inInfo->Has(vtkDataObject::CELL_DATA_VECTOR()))
{
outInfo->CopyEntry(inInfo, vtkDataObject::CELL_DATA_VECTOR(), 1);
}
if (inInfo->Has(vtkDataObject::POINT_DATA_VECTOR()))
{
outInfo->CopyEntry(inInfo, vtkDataObject::POINT_DATA_VECTOR(), 1);
}
}
else
{
//RI normally passes it on always, so this flag says remove it downstream
request->Set(REMOVE_ATTRIBUTE_INFORMATION(), 1);
}
//remove the attribute range information downstream
if(request->Has(REMOVE_ATTRIBUTE_INFORMATION()))
{
vtkInformationVector *miv;
miv = outInfo->Get(vtkDataObject::CELL_DATA_VECTOR());
if (miv)
{
int nArrays = miv->GetNumberOfInformationObjects();
for (int n = 0; n < nArrays; n++)
{
vtkInformation *oArray = miv->GetInformationObject(n);
oArray->Remove(vtkDataObject::PIECE_FIELD_RANGE());
}
}
miv = outInfo->Get(vtkDataObject::POINT_DATA_VECTOR());
if (miv)
{
int nArrays = miv->GetNumberOfInformationObjects();
for (int n = 0; n < nArrays; n++)
{
vtkInformation *oArray = miv->GetInformationObject(n);
oArray->Remove(vtkDataObject::PIECE_FIELD_RANGE());
}
}
}
// Copy the geometric meta information when algorithm is known not to modify it
if (
algsProps->Has(vtkAlgorithm::PRESERVES_BOUNDS()) ||
algsProps->Has(vtkAlgorithm::PRESERVES_GEOMETRY()) ||
algsProps->Has(vtkAlgorithm::PRESERVES_DATASET())
)
{
outInfo->CopyEntry(inInfo, PIECE_BOUNDING_BOX());
}
// Copy the topological meta information when algorithm is known not to modify it
if (
algsProps->Has(vtkAlgorithm::PRESERVES_TOPOLOGY()) ||
algsProps->Has(vtkAlgorithm::PRESERVES_DATASET())
)
{
outInfo->CopyEntry(inInfo, vtkDataObject::DATA_GEOMETRY_UNMODIFIED());
}
}
}
}
if(request->Has(REQUEST_RESOLUTION_PROPAGATE()))
{
// Get the output port from which to copy the extent.
int outputPort = -1;
if(request->Has(FROM_OUTPUT_PORT()))
{
outputPort = request->Get(FROM_OUTPUT_PORT());
}
// Setup default information for the inputs.
if(outInfoVec->GetNumberOfInformationObjects() > 0)
{
// Copy information from the output port that made the request.
// Since VerifyOutputInformation has already been called we know
// there is output information with a data object.
vtkInformation* outInfo =
outInfoVec->GetInformationObject((outputPort >= 0)? outputPort : 0);
// Loop over all input ports.
for(int i=0; i < this->Algorithm->GetNumberOfInputPorts(); ++i)
{
// Loop over all connections on this input port.
int numInConnections = inInfoVec[i]->GetNumberOfInformationObjects();
for (int j=0; j<numInConnections; j++)
{
// Get the pipeline information for this input connection.
vtkInformation* inInfo = inInfoVec[i]->GetInformationObject(j);
//Copy requested resolution back
inInfo->CopyEntry(outInfo, UPDATE_RESOLUTION());
vtkDataObject *inData = inInfo->Get(vtkDataObject::DATA_OBJECT());
if (inData)
{
vtkInformation* dataInfo = inData->GetInformation();
dataInfo->Set(vtkDataObject::DATA_RESOLUTION(), -1.0);
}
}
}
}
}
}
//----------------------------------------------------------------------------
void
vtkStreamingDemandDrivenPipeline
::ResetPipelineInformation(int port, vtkInformation* info)
{
this->Superclass::ResetPipelineInformation(port, info);
info->Remove(WHOLE_EXTENT());
info->Remove(MAXIMUM_NUMBER_OF_PIECES());
info->Remove(EXTENT_TRANSLATOR());
info->Remove(EXACT_EXTENT());
info->Remove(UPDATE_EXTENT_INITIALIZED());
info->Remove(UPDATE_EXTENT());
info->Remove(UPDATE_PIECE_NUMBER());
info->Remove(UPDATE_RESOLUTION());
info->Remove(UPDATE_NUMBER_OF_PIECES());
info->Remove(UPDATE_NUMBER_OF_GHOST_LEVELS());
info->Remove(UPDATE_EXTENT_TRANSLATED());
info->Remove(TIME_STEPS());
info->Remove(TIME_RANGE());
info->Remove(UPDATE_TIME_STEPS());
info->Remove(PREVIOUS_UPDATE_TIME_STEPS());
info->Remove(FAST_PATH_OBJECT_ID());
info->Remove(FAST_PATH_OBJECT_TYPE());
info->Remove(FAST_PATH_ID_TYPE());
info->Remove(PREVIOUS_FAST_PATH_OBJECT_ID());
info->Remove(PREVIOUS_FAST_PATH_OBJECT_TYPE());
info->Remove(PREVIOUS_FAST_PATH_ID_TYPE());
}
//----------------------------------------------------------------------------
int vtkStreamingDemandDrivenPipeline::PropagateUpdateExtent(int outputPort)
{
// The algorithm should not invoke anything on the executive.
if(!this->CheckAlgorithm("PropagateUpdateExtent", 0))
{
return 0;
}
// Range check.
if(outputPort < -1 ||
outputPort >= this->Algorithm->GetNumberOfOutputPorts())
{
vtkErrorMacro("PropagateUpdateExtent given output port index "
<< outputPort << " on an algorithm with "
<< this->Algorithm->GetNumberOfOutputPorts()
<< " output ports.");
return 0;
}
// Setup the request for update extent propagation.
if (!this->UpdateExtentRequest)
{
this->UpdateExtentRequest = vtkInformation::New();
this->UpdateExtentRequest->Set(REQUEST_UPDATE_EXTENT());
// The request is forwarded upstream through the pipeline.
this->UpdateExtentRequest->Set(vtkExecutive::FORWARD_DIRECTION(), vtkExecutive::RequestUpstream);
// Algorithms process this request before it is forwarded.
this->UpdateExtentRequest->Set(vtkExecutive::ALGORITHM_BEFORE_FORWARD(), 1);
}
this->UpdateExtentRequest->Set(FROM_OUTPUT_PORT(), outputPort);
// Send the request.
return this->ProcessRequest(this->UpdateExtentRequest,
this->GetInputInformation(),
this->GetOutputInformation());
}
//----------------------------------------------------------------------------
int vtkStreamingDemandDrivenPipeline
::VerifyOutputInformation(int outputPort,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// If no port is specified, check all ports.
if(outputPort < 0)
{
for(int i=0; i < this->Algorithm->GetNumberOfOutputPorts(); ++i)
{
if(!this->VerifyOutputInformation(i,inInfoVec,outInfoVec))
{
return 0;
}
}
return 1;
}
// Get the information object to check.
vtkInformation* outInfo = outInfoVec->GetInformationObject(outputPort);
// Make sure there is a data object. It is supposed to be created
// by the UpdateDataObject step.
vtkDataObject* dataObject = outInfo->Get(vtkDataObject::DATA_OBJECT());
if(!dataObject)
{
vtkErrorMacro("No data object has been set in the information for "
"output port " << outputPort << ".");
return 0;
}
// Check extents.
vtkInformation* dataInfo = dataObject->GetInformation();
if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_PIECES_EXTENT
|| dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_TIME_EXTENT)
{
// For an unstructured extent, make sure the update request
// exists. We do not need to check if it is valid because
// out-of-range requests produce empty data.
if(!outInfo->Has(MAXIMUM_NUMBER_OF_PIECES()))
{
vtkErrorMacro("No maximum number of pieces has been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
if(!outInfo->Has(UPDATE_PIECE_NUMBER()))
{
vtkErrorMacro("No update piece number has been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
if(!outInfo->Has(UPDATE_NUMBER_OF_PIECES()))
{
vtkErrorMacro("No update number of pieces has been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
if(!outInfo->Has(UPDATE_NUMBER_OF_GHOST_LEVELS()))
{
// Use zero ghost levels by default.
outInfo->Set(UPDATE_NUMBER_OF_GHOST_LEVELS(), 0);
}
}
else if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_3D_EXTENT)
{
// For a structured extent, make sure the update request
// exists.
if(!outInfo->Has(WHOLE_EXTENT()))
{
vtkErrorMacro("No whole extent has been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
if(!outInfo->Has(UPDATE_EXTENT()))
{
vtkErrorMacro("No update extent has been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
// Make sure the update request is inside the whole extent.
int wholeExtent[6];
int updateExtent[6];
outInfo->Get(WHOLE_EXTENT(), wholeExtent);
outInfo->Get(UPDATE_EXTENT(), updateExtent);
if((updateExtent[0] < wholeExtent[0] ||
updateExtent[1] > wholeExtent[1] ||
updateExtent[2] < wholeExtent[2] ||
updateExtent[3] > wholeExtent[3] ||
updateExtent[4] < wholeExtent[4] ||
updateExtent[5] > wholeExtent[5]) &&
(updateExtent[0] <= updateExtent[1] &&
updateExtent[2] <= updateExtent[3] &&
updateExtent[4] <= updateExtent[5]))
{
if (!outInfo->Has(UPDATE_RESOLUTION()))
{
// Update extent is outside the whole extent and is not empty.
vtkErrorMacro("The update extent specified in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ") is "
<< updateExtent[0] << " " << updateExtent[1] << " "
<< updateExtent[2] << " " << updateExtent[3] << " "
<< updateExtent[4] << " " << updateExtent[5]
<< ", which is outside the whole extent "
<< wholeExtent[0] << " " << wholeExtent[1] << " "
<< wholeExtent[2] << " " << wholeExtent[3] << " "
<< wholeExtent[4] << " " << wholeExtent[5] << ".");
}
return 0;
}
}
if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_TIME_EXTENT)
{
// For a structured extent, make sure the update request
// exists.
if(!outInfo->Has(TIME_STEPS()) && !outInfo->Has(TIME_RANGE()))
{
vtkErrorMacro("No time steps or time range been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
if(!outInfo->Has(UPDATE_TIME_STEPS()))
{
vtkErrorMacro("No update time steps have been set in the "
"information for output port " << outputPort
<< " on algorithm " << this->Algorithm->GetClassName()
<< "(" << this->Algorithm << ").");
return 0;
}
}
return 1;
}
//----------------------------------------------------------------------------
void
vtkStreamingDemandDrivenPipeline
::ExecuteDataStart(vtkInformation* request,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// Preserve the execution continuation flag in the request across
// iterations of the algorithm. Perform start operations only if
// not in an execute continuation.
if(this->ContinueExecuting)
{
request->Set(CONTINUE_EXECUTING(), 1);
}
else
{
request->Remove(CONTINUE_EXECUTING());
this->Superclass::ExecuteDataStart(request,inInfoVec,outInfoVec);
}
}
//----------------------------------------------------------------------------
void
vtkStreamingDemandDrivenPipeline
::ExecuteDataEnd(vtkInformation* request,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// Preserve the execution continuation flag in the request across
// iterations of the algorithm. Perform start operations only if
// not in an execute continuation.
if(request->Get(CONTINUE_EXECUTING()))
{
this->ContinueExecuting = 1;
this->Update(request->Get(FROM_OUTPUT_PORT()));
}
else
{
this->ContinueExecuting = 0;
this->Superclass::ExecuteDataEnd(request,inInfoVec,outInfoVec);
}
}
//----------------------------------------------------------------------------
void
vtkStreamingDemandDrivenPipeline
::MarkOutputsGenerated(vtkInformation* request,
vtkInformationVector** inInfoVec,
vtkInformationVector* outInfoVec)
{
// Tell outputs they have been generated.
this->Superclass::MarkOutputsGenerated(request,inInfoVec,outInfoVec);
int outputPort = 0;
if(request->Has(FROM_OUTPUT_PORT()))
{
outputPort = request->Get(FROM_OUTPUT_PORT());
outputPort = (outputPort >= 0 ? outputPort : 0);
}
// Get the piece request from the update port (port 0 if none)
// The defaults are:
int piece = 0;
int numPieces = 1;
int ghostLevel = 0;
vtkInformation* fromInfo = 0;
if (outputPort < outInfoVec->GetNumberOfInformationObjects())
{
fromInfo = outInfoVec->GetInformationObject(outputPort);
if (fromInfo->Has(UPDATE_PIECE_NUMBER()))
{
piece = fromInfo->Get(UPDATE_PIECE_NUMBER());
}
if (fromInfo->Has(UPDATE_NUMBER_OF_PIECES()))
{
numPieces = fromInfo->Get(UPDATE_NUMBER_OF_PIECES());
}
if (fromInfo->Has(UPDATE_NUMBER_OF_GHOST_LEVELS()))
{
ghostLevel = fromInfo->Get(UPDATE_NUMBER_OF_GHOST_LEVELS());
}
}
for(int i=0; i < outInfoVec->GetNumberOfInformationObjects(); ++i)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(i);
vtkDataObject* data = outInfo->Get(vtkDataObject::DATA_OBJECT());
// Compute ghost level arrays for generated outputs.
if(data && !outInfo->Get(DATA_NOT_GENERATED()))
{
if(vtkDataSet* ds = vtkDataSet::SafeDownCast(data))
{
// Generate ghost level arrays automatically only if the extent