-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvtkProfileFilter.cxx
729 lines (680 loc) · 23.7 KB
/
vtkProfileFilter.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
/*=========================================================================
Program: AstroViz plugin for ParaView
Module: $RCSfile: vtkProfileFilter.cxx,v $
=========================================================================*/
#include "vtkProfileFilter.h"
#include "AstroVizHelpersLib/AstroVizHelpers.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkDoubleArray.h"
#include "vtkIntArray.h"
#include "vtkCellData.h"
#include "vtkTable.h"
#include "vtkSortDataArray.h"
#include "vtkMath.h"
#include "vtkInformationDataObjectKey.h"
#include "vtkPointSet.h"
#include "vtkMultiProcessController.h"
#include "vtkSmartPointer.h"
#include "vtkPointData.h"
#include "vtkLine.h"
#include "vtkPlane.h"
#include <cmath>
using vtkstd::string;
vtkCxxRevisionMacro(vtkProfileFilter, "$Revision: 1.72 $");
vtkStandardNewMacro(vtkProfileFilter);
vtkCxxSetObjectMacro(vtkProfileFilter, Controller, vtkMultiProcessController);
//----------------------------------------------------------------------------
vtkProfileFilter::vtkProfileFilter()
{
this->SetNumberOfInputPorts(2);
this->SetInputArrayToProcess(
0,
0,
0,
vtkDataObject::FIELD_ASSOCIATION_POINTS_THEN_CELLS,
vtkDataSetAttributes::SCALARS);
// Defaults for quantities which will be computed based on user's
// later input
this->MaxR=1.0;
this->Delta=1;
this->BinNumber=30;
this->Controller = NULL;
this->SetController(vtkMultiProcessController::GetGlobalController());
}
//----------------------------------------------------------------------------
vtkProfileFilter::~vtkProfileFilter()
{
this->SetController(0);
}
//----------------------------------------------------------------------------
void vtkProfileFilter::PrintSelf(ostream& os, vtkIndent indent)
{
os << indent << "bin number: " << this->BinNumber << "\n";
}
//----------------------------------------------------------------------------
void vtkProfileFilter::SetSourceConnection(vtkAlgorithmOutput* algOutput)
{
this->SetInputConnection(1, algOutput);
}
int vtkProfileFilter::FillInputPortInformation (int port,
vtkInformation *info)
{
this->Superclass::FillInputPortInformation(port, info);
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPointSet");
return 1;
}
//----------------------------------------------------------------------------
int vtkProfileFilter::RequestData(vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
// Now we can get the input with which we want to work
vtkPointSet* input = vtkPointSet::GetData(inputVector[0]);
// Will set the center based upon the selection in the GUI
vtkDataSet* centerInfo = vtkDataSet::GetData(inputVector[1]);
// Get name of data array containing mass
vtkDataArray* massArray = this->GetInputArrayToProcess(0, inputVector);
if (!massArray)
{
vtkErrorMacro("Failed to locate mass array");
return 0;
}
vtkTable* const output = vtkTable::GetData(outputVector,0);
output->Initialize();
// Choosing which quantities to profile. Right now choosing all,
// could later by modified to use user's input to select
this->AdditionalProfileQuantities.push_back(
ProfileElement("angular momentum",3,&ComputeAngularMomentum,AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("radial velocity",3,&ComputeRadialVelocity,AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("tangential velocity",3,&ComputeTangentialVelocity,
AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("velocity squared",1,&ComputeVelocitySquared,AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("radial velocity squared",1,&ComputeRadialVelocitySquared,
AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("tangential velocity squared",1,
&ComputeTangentialVelocitySquared,AVERAGE));
// These use a different constructor as they are elements to be
// postprocessed.
this->AdditionalProfileQuantities.push_back(
ProfileElement("velocity dispersion",3,
&ComputeVelocityDispersion,
"velocity squared",AVERAGE,
"velocity",AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("tangential velocity dispersion",3,
&ComputeVelocityDispersion,
"tangential velocity squared",AVERAGE,
"tangential velocity",AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("radial velocity dispersion",3,
&ComputeVelocityDispersion,
"radial velocity squared",AVERAGE,
"radial velocity",AVERAGE));
this->AdditionalProfileQuantities.push_back(
ProfileElement("circular velocity",1,
&ComputeCircularVelocity,
massArray->GetName(),CUMULATIVE,
"bin radius",TOTAL));
this->AdditionalProfileQuantities.push_back(
ProfileElement("density",1,
&ComputeDensity,
massArray->GetName(),CUMULATIVE,
"bin radius",TOTAL));
// runs in parallel, syncing class member data, if necessary, if not
// functions in serial
this->SetBoundsAndBinExtents(input,centerInfo);
if(RunInParallel(this->Controller))
{
int procId=this->Controller->GetLocalProcessId();
int numProc=this->Controller->GetNumberOfProcesses();
vtkSmartPointer<vtkTable> localTable = \
vtkSmartPointer<vtkTable>::New();
localTable->Initialize();
if(procId==0)
{
// only take the time to initialize on process 0
this->InitializeBins(input,localTable);
// Syncronizing the intialized table with the other processes
this->Controller->Broadcast(localTable,0);
this->UpdateStatistics(input,localTable);
// Receive computations from each process and merge the table into
// the localTable of process 0
for(int proc = 1; proc < numProc; ++proc)
{
vtkSmartPointer<vtkTable> recLocalTable = \
vtkSmartPointer<vtkTable>::New();
recLocalTable->Initialize();
this->Controller->Receive(recLocalTable,proc,DATA_TABLE);
this->MergeTables(input,localTable,recLocalTable);
}
// Perform final computations
// Updating averages and doing relevant postprocessing
this->BinAveragesAndPostprocessing(input,localTable);
// Copy process 0's local table to output, which should have collected
// answer
output->DeepCopy(localTable);
}
else
{
// Syncing initialized, empty table
this->Controller->Broadcast(localTable,0);
// Updating table with the data on this processor
this->UpdateStatistics(input,localTable);
// sending result to root
this->Controller->Send(localTable,0,DATA_TABLE);
}
}
else
{
this->InitializeBins(input,output);
this->UpdateStatistics(input,output);
// Updating averages and doing relevant postprocessing
this->BinAveragesAndPostprocessing(input,output);
}
return 1;
}
//----------------------------------------------------------------------------
void vtkProfileFilter::MergeTables(vtkPointSet* input,
vtkTable* originalTable, vtkTable* tableToMerge)
{
assert(originalTable->GetNumberOfRows()==tableToMerge->GetNumberOfRows());
for(int binNum = 0; binNum < originalTable->GetNumberOfRows(); ++binNum)
{
this->MergeBins(binNum,ADD,"number in bin",TOTAL,
originalTable,tableToMerge);
this->MergeBins(binNum,ADD,"number in bin",CUMULATIVE,
originalTable,tableToMerge);
assert(0<=binNum<=this->BinNumber);
// Updating quanties for the input data arrays
for(int i = 0; i < input->GetPointData()->GetNumberOfArrays(); ++i)
{
vtkSmartPointer<vtkDataArray> nextArray = \
input->GetPointData()->GetArray(i);
// Merging the bins
string baseName = nextArray->GetName();
this->MergeBins(binNum,ADD,baseName,TOTAL,originalTable,tableToMerge);
this->MergeBins(binNum,ADD,baseName,AVERAGE,originalTable,tableToMerge);
this->MergeBins(binNum,ADD,baseName,CUMULATIVE,
originalTable,tableToMerge);
}
for(int i = 0; i < this->AdditionalProfileQuantities.size(); ++i)
{
ProfileElement nextElement=this->AdditionalProfileQuantities[i];
if(!nextElement.Postprocess)
{
this->MergeBins(binNum,ADD,nextElement.BaseName,
nextElement.ProfileColumnType,
originalTable,tableToMerge);
}
}
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::SetBoundsAndBinExtents(vtkPointSet* input,
vtkDataSet* source)
{
if(RunInParallel(this->Controller))
{
int procId=this->Controller->GetLocalProcessId();
int numProc=this->Controller->GetNumberOfProcesses();
if(procId==0)
{
double* sourceCenter=CalculateCenter(source);
for(int i = 0; i < 3; ++i)
{
this->Center[i]=sourceCenter[i];
}
// Syncronizing the centers
this->Controller->Broadcast(this->Center,3,0);
}
else
{
// Syncronizing the centers
this->Controller->Broadcast(this->Center,3,0);
}
// calculating the max R
this->MaxR=ComputeMaxRadiusInParallel(this->Controller,
input,this->Center);
}
else
{
// we aren't using MPI or have only one process
double* sourceCenter=CalculateCenter(source);
for(int i = 0; i < 3; ++i)
{
this->Center[i]=sourceCenter[i];
}
//calculating the the max R
this->MaxR=ComputeMaxR(input,this->Center);
}
// this->MaxR, this->BinNumber are already set/synced
// whether we are in parallel or serial, and each process can perform
// computation on its own
this->BinSpacing=this->CalculateBinSpacing(this->MaxR,this->BinNumber);
}
//----------------------------------------------------------------------------
int vtkProfileFilter::GetBinNumber(double x[])
{
double distanceToCenter;
if(this->ProfileAxis[0]==0 && this->ProfileAxis[1]==0 && this->ProfileAxis[2]==0) {// spherical profile
distanceToCenter = sqrt(vtkMath::Distance2BetweenPoints(this->Center,x));
}
else {
distanceToCenter = vtkLine::DistanceToLine(x, this->Center, this->ProfileAxis);
}
if(this->ProfileHeight!=0) {
if(this->ProfileAxis[0]==0 && this->ProfileAxis[1]==0 && this->ProfileAxis[2]==0){ //spherical profile
if(distanceToCenter > this->ProfileHeight){
return -1;
}
}
else {
double projectedPoint[3];
vtkPlane::ProjectPoint(x, this->Center, this->ProfileAxis, projectedPoint); // TODO: this ProfileAxis is not the correct normal vector
if( sqrt(vtkMath::Distance2BetweenPoints(x,projectedPoint)) > this->ProfileHeight) {
return -1;
}
}
}
return floor(distanceToCenter/this->BinSpacing);
}
//----------------------------------------------------------------------------
void vtkProfileFilter::InitializeBins(vtkPointSet* input,
vtkTable* output)
{
// the first column will be the bin radius (max)
string binRadiusColumnName=this->GetColumnName("bin radius",
TOTAL);
// the second column will be the bin radius (min)
string binRadiusMinColumnName=this->GetColumnName("bin radius min",
TOTAL);
AllocateDataArray(output,binRadiusColumnName.c_str(),1,this->BinNumber);
AllocateDataArray(output,binRadiusMinColumnName.c_str(),1,this->BinNumber);
// setting the bin radii in the output
for(int binNum = 0; binNum < this->BinNumber; ++binNum)
{
this->UpdateBin(binNum,SET,
"bin radius",TOTAL,(binNum+1)*this->BinSpacing,output);
this->UpdateBin(binNum,SET,
"bin radius min",TOTAL,binNum*this->BinSpacing,output);
}
// always need this for averages
AllocateDataArray(output,GetColumnName("number in bin",TOTAL).c_str(),
1,this->BinNumber);
AllocateDataArray(output,GetColumnName("number in bin",
CUMULATIVE).c_str(),1,this->BinNumber);
for(int i = 0; i < input->GetPointData()->GetNumberOfArrays(); ++i)
{
// Next array data
vtkSmartPointer<vtkDataArray> nextArray = \
input->GetPointData()->GetArray(i);
int numComponents = nextArray->GetNumberOfComponents();
string baseName = nextArray->GetName();
AllocateDataArray(output,GetColumnName(baseName,TOTAL).c_str(),
numComponents,this->BinNumber);
AllocateDataArray(output,GetColumnName(baseName,AVERAGE).c_str(),
numComponents,this->BinNumber);
AllocateDataArray(output,GetColumnName(baseName,CUMULATIVE).c_str(),
numComponents,this->BinNumber);
}
// For our additional quantities, allocating a column for the average
// and the sum. These are currently restricted to be 3-vectors
for(int i = 0;
i < this->AdditionalProfileQuantities.size();
++i)
{
ProfileElement nextElement = this->AdditionalProfileQuantities[i];
AllocateDataArray(output,
GetColumnName(nextElement.BaseName,
nextElement.ProfileColumnType).c_str(),nextElement.NumberComponents,
this->BinNumber);
}
}
//----------------------------------------------------------------------------
double vtkProfileFilter::CalculateBinSpacing(double maxR,int binNumber)
{
return maxR/binNumber;
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateStatistics(vtkPointSet* input,vtkTable* output)
{
for(unsigned long nextPointId = 0;
nextPointId < input->GetPoints()->GetNumberOfPoints();
++nextPointId)
{
this->UpdateBinStatistics(input,nextPointId,output);
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateBinStatistics(vtkPointSet* input,
vtkIdType pointGlobalId,vtkTable* output)
{
double* x = GetPoint(input,pointGlobalId);
// As we bin by radius always need
double* r=PointVectorDifference(x,this->Center);
// Many of the quantities explicitely require the velocity
double* v=GetDataValue(input,"velocity",pointGlobalId);
int binNum=this->GetBinNumber(x);
if(binNum < 0){
// This indicates the point is not to be included.
return;
}
this->UpdateBin(binNum,ADD,"number in bin",TOTAL,1.0,output);
this->UpdateCumulativeBins(binNum,ADD,
"number in bin",CUMULATIVE,1.0,output);
assert(0<=binNum<=this->BinNumber);
// Updating quanties for the input data arrays
for(int i = 0; i < input->GetPointData()->GetNumberOfArrays(); ++i)
{
vtkSmartPointer<vtkDataArray> nextArray = \
input->GetPointData()->GetArray(i);
// getting the data for this point
double* nextData = GetDataValue(input,
nextArray->GetName(),pointGlobalId);
// Updating the total bin
string baseName = nextArray->GetName();
this->UpdateBin(binNum,ADD,baseName,TOTAL,nextData, output);
this->UpdateBin(binNum,ADD,baseName,AVERAGE,nextData, output);
this->UpdateCumulativeBins(binNum,ADD,baseName,CUMULATIVE,nextData,
output);
//Finally some memory management
delete [] nextData;
}
for(int i = 0; i <
this->AdditionalProfileQuantities.size();
++i)
{
ProfileElement nextElement=this->AdditionalProfileQuantities[i];
if(!nextElement.Postprocess)
{
double* additionalData = \
nextElement.Function(v,r);
this->UpdateBin(binNum,ADD,nextElement.BaseName,
nextElement.ProfileColumnType,additionalData,output);
}
}
// Finally some memory management
delete [] x;
delete [] r;
delete [] v;
}
//----------------------------------------------------------------------------
void vtkProfileFilter::BinAveragesAndPostprocessing(
vtkPointSet* input,vtkTable* output)
{
for(int binNum = 0; binNum < this->BinNumber; ++binNum)
{
int binSize=output->GetValueByName(binNum,
GetColumnName("number in bin",TOTAL).c_str()).ToInt();
// For each input array, update its average column by getting
// the total from the total column then dividing by
// the number in the bin. Only do this if the number in the bin
// is greater than zero
if(binSize>0)
{
vtkSmartPointer<vtkDataArray> nextArray;
for(int i = 0; i < input->GetPointData()->GetNumberOfArrays(); ++i)
{
nextArray = input->GetPointData()->GetArray(i);
string baseName = nextArray->GetName();
this->UpdateBin(binNum,MULTIPLY,baseName,AVERAGE,1./binSize,output);
}
// For each additional quantity we also divide by N in the average
// if requested
for(int i = 0;
i < this->AdditionalProfileQuantities.size();
++i)
{
ProfileElement nextElement = \
this->AdditionalProfileQuantities[i];
if(nextElement.ProfileColumnType==AVERAGE)
{
this->UpdateBin(binNum,MULTIPLY,nextElement.BaseName,
AVERAGE,1./binSize,output);
}
}
}
// Finally post processing those items which are marked as such, don't
// do this within the average loop as these quantities are allowed
// to depend on averages themselves
for(int i = 0;
i < this->AdditionalProfileQuantities.size();
++i)
{
ProfileElement nextElement = \
this->AdditionalProfileQuantities[i];
if(nextElement.Postprocess)
{
vtkVariant argumentOne = \
this->GetData(binNum, nextElement.ArgOneBaseName,
nextElement.ArgOneColumnType, output);
vtkVariant argumentTwo = \
this->GetData(binNum, nextElement.ArgTwoBaseName,
nextElement.ArgTwoColumnType, output);
double* updateData = \
nextElement.PostProcessFunction(argumentOne,argumentTwo);
this->UpdateBin(binNum,SET,nextElement.BaseName,TOTAL,
updateData,output);
// memory management
delete [] updateData;
}
}
}
}
//----------------------------------------------------------------------------
string vtkProfileFilter::GetColumnName(string baseName,
ColumnType columnType)
{
switch(columnType)
{
case AVERAGE:
return baseName+"_average";
case TOTAL:
return baseName+"_total";
case CUMULATIVE:
return baseName+"_cumulative";
default:
vtkDebugMacro("columnType not found for function GetColumnName, returning error string");
return "error";
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateBin(int binNum, BinUpdateType updateType,
string baseName, ColumnType columnType, double* updateData,
vtkTable* output)
{
vtkVariant oldData = this->GetData(binNum,baseName,columnType,output);
if(oldData.IsArray())
{
this->UpdateArrayBin(binNum,updateType,baseName,columnType,
updateData,oldData.ToArray(),output);
}
else
{
this->UpdateDoubleBin(binNum,updateType,baseName,columnType,
updateData[0],oldData.ToDouble(),output);
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::MergeBins(int binNum, BinUpdateType updateType,
string baseName, ColumnType columnType, vtkTable* originalTable,
vtkTable* tableToMerge)
{
vtkVariant originalData = this->GetData(binNum,baseName,columnType,
originalTable);
vtkVariant mergeData = this->GetData(binNum,baseName,columnType,
tableToMerge);
if(originalData.IsArray() && mergeData.IsArray())
{
this->UpdateArrayBin(binNum,updateType,baseName,columnType,
mergeData.ToArray(),originalData.ToArray(),originalTable);
}
else
{
assert(originalData.IsNumeric() && mergeData.IsNumeric());
this->UpdateDoubleBin(binNum,updateType,baseName,columnType,
mergeData.ToDouble(),originalData.ToDouble(),originalTable);
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateBin(int binNum, BinUpdateType updateType,
string baseName, ColumnType columnType, double updateData,
vtkTable* output)
{
vtkVariant oldData = this->GetData(binNum,baseName,columnType,output);
if(oldData.IsArray())
{
int sizeOfUpdateData = oldData.ToArray()->GetNumberOfComponents();
double* arrayUpdateData = new double[sizeOfUpdateData];
for(int comp = 0; comp < sizeOfUpdateData; ++comp)
{
arrayUpdateData[comp] = updateData;
}
this->UpdateArrayBin(binNum,updateType,baseName,columnType,
arrayUpdateData,oldData.ToArray(),output);
// finally some memory management
delete [] arrayUpdateData;
}
else
{
this->UpdateDoubleBin(binNum,updateType,baseName,columnType,
updateData,oldData.ToDouble(),output);
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateDoubleBin(int binNum, BinUpdateType updateType,
string baseName, ColumnType columnType, double updateData, double oldData,
vtkTable* output)
{
switch(updateType)
{
case ADD:
updateData+=oldData;
break;
case MULTIPLY:
updateData*=oldData;
break;
case SET:
break;
}
output->SetValueByName(binNum,
GetColumnName(baseName,columnType).c_str(),updateData);
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateArrayBin(int binNum, BinUpdateType updateType,
string baseName, ColumnType columnType, vtkAbstractArray* updateData,
vtkAbstractArray* oldData, vtkTable* output)
{
for(int comp = 0; comp < oldData->GetNumberOfComponents(); ++comp)
{
switch(updateType)
{
case ADD:
oldData->InsertVariantValue(comp,
updateData->GetVariantValue(comp).ToDouble()+\
oldData->GetVariantValue(comp).ToDouble());
break;
case MULTIPLY:
oldData->InsertVariantValue(comp,
updateData->GetVariantValue(comp).ToDouble()*\
oldData->GetVariantValue(comp).ToDouble());
break;
case SET:
oldData->InsertVariantValue(comp,
updateData->GetVariantValue(comp).ToDouble());
break;
}
}
output->SetValueByName(binNum,GetColumnName(baseName,columnType).c_str(),
oldData);
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateArrayBin(int binNum, BinUpdateType updateType,
string baseName, ColumnType columnType, double* updateData,
vtkAbstractArray* oldData, vtkTable* output)
{
for(int comp = 0; comp < oldData->GetNumberOfComponents(); ++comp)
{
switch(updateType)
{
case ADD:
oldData->InsertVariantValue(comp,
updateData[comp]+oldData->GetVariantValue(comp).ToDouble());
break;
case MULTIPLY:
oldData->InsertVariantValue(comp,
updateData[comp]*oldData->GetVariantValue(comp).ToDouble());
break;
case SET:
oldData->InsertVariantValue(comp,updateData[comp]);
break;
}
}
output->SetValueByName(binNum,GetColumnName(baseName,columnType).c_str(),
oldData);
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateCumulativeBins(int binNum, BinUpdateType
updateType, string baseName, ColumnType columnType, double* dataToAdd,
vtkTable* output)
{
for(int bin = binNum; bin < this->BinNumber; ++bin)
{
this->UpdateBin(bin,updateType,baseName,columnType,dataToAdd,output);
}
}
//----------------------------------------------------------------------------
void vtkProfileFilter::UpdateCumulativeBins(int binNum, BinUpdateType
updateType, string baseName, ColumnType columnType, double dataToAdd,
vtkTable* output)
{
for(int bin = binNum; bin < this->BinNumber; ++bin)
{
this->UpdateBin(bin,updateType,baseName,columnType,dataToAdd,output);
}
}
//----------------------------------------------------------------------------
vtkVariant vtkProfileFilter::GetData(int binNum, string baseName,
ColumnType columnType, vtkTable* output)
{
return output->GetValueByName(binNum,
GetColumnName(baseName,columnType).c_str());
}
//----------------------------------------------------------------------------
vtkProfileFilter::ProfileElement::ProfileElement(string baseName,
int numberComponents, double* (*funcPtr)(double [], double []),
ColumnType columnType)
{
this->BaseName = baseName;
this->NumberComponents = numberComponents;
this->Function = funcPtr;
this->ProfileColumnType = columnType;
this->Postprocess = 0;
}
vtkProfileFilter::ProfileElement::ProfileElement(string baseName,
int numberComponents, double* (*funcPtr)(vtkVariant, vtkVariant),
string argOneBaseName, ColumnType argOneColumnType,
string argTwoBaseName, ColumnType argTwoColumnType)
{
this->BaseName = baseName;
this->NumberComponents = numberComponents;
this->PostProcessFunction = funcPtr;
this->ProfileColumnType = TOTAL;
this->Postprocess = 1;
this->ArgOneBaseName=argOneBaseName;
this->ArgOneColumnType=argOneColumnType;
this->ArgTwoBaseName=argTwoBaseName;
this->ArgTwoColumnType=argTwoColumnType;
}
//----------------------------------------------------------------------------
vtkProfileFilter::ProfileElement::~ProfileElement()
{
}