-
Notifications
You must be signed in to change notification settings - Fork 0
/
FieldDisplacementMapData.cxx
81 lines (65 loc) · 2.38 KB
/
FieldDisplacementMapData.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
/*
____ _ __ ____ __ ____
/ __/___(_) / ___ ____/ __ \__ _____ ___ / /_ / _/__ ____
_\ \/ __/ / _ \/ -_) __/ /_/ / // / -_|_-</ __/ _/ // _ \/ __/
/___/\__/_/_.__/\__/_/ \___\_\_,_/\__/___/\__/ /___/_//_/\__(_)
Copyright 2012 SciberQuest Inc.
*/
#include "FieldDisplacementMapData.h"
#include "TerminationCondition.h"
#include "vtkDataSet.h"
#include "vtkPointData.h"
//-----------------------------------------------------------------------------
FieldDisplacementMapData::FieldDisplacementMapData()
:
Displacement(0),
FwdDisplacement(0),
BwdDisplacement(0)
{
this->Displacement=vtkFloatArray::New();
this->Displacement->SetName("displacement");
this->Displacement->SetNumberOfComponents(3);
this->FwdDisplacement=vtkFloatArray::New();
this->FwdDisplacement->SetName("fwd-displacement-map");
this->FwdDisplacement->SetNumberOfComponents(3);
this->BwdDisplacement=vtkFloatArray::New();
this->BwdDisplacement->SetName("bwd-displacement-map");
this->BwdDisplacement->SetNumberOfComponents(3);
}
//-----------------------------------------------------------------------------
FieldDisplacementMapData::~FieldDisplacementMapData()
{
this->Displacement->Delete();
this->FwdDisplacement->Delete();
this->BwdDisplacement->Delete();
}
//-----------------------------------------------------------------------------
void FieldDisplacementMapData::SetOutput(vtkDataSet *o)
{
o->GetPointData()->AddArray(this->Displacement);
o->GetPointData()->AddArray(this->FwdDisplacement);
o->GetPointData()->AddArray(this->BwdDisplacement);
}
//-----------------------------------------------------------------------------
int FieldDisplacementMapData::SyncScalars()
{
vtkIdType nLines=this->Lines.size();
vtkIdType lastLineId=this->Displacement->GetNumberOfTuples();
float *pDisplacement
= this->Displacement->WritePointer(3*lastLineId,3*nLines);
float *pFwdDisplacement
= this->FwdDisplacement->WritePointer(3*lastLineId,3*nLines);
float *pBwdDisplacement
= this->BwdDisplacement->WritePointer(3*lastLineId,3*nLines);
for (vtkIdType i=0; i<nLines; ++i)
{
FieldLine *line=this->Lines[i];
line->GetDisplacement(pDisplacement);
pDisplacement+=3;
line->GetForwardEndPoint(pFwdDisplacement);
pFwdDisplacement+=3;
line->GetBackwardEndPoint(pBwdDisplacement);
pBwdDisplacement+=3;
}
return 1;
}