59 vtkInformation *vtkNotUsed(request),
60 vtkInformationVector **inputVector,
61 vtkInformationVector *outputVector)
64 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
65 vtkInformation *outInfo = outputVector->GetInformationObject(0);
68 vtkPolyData *input = vtkPolyData::SafeDownCast(
69 inInfo->Get(vtkDataObject::DATA_OBJECT()));
70 vtkPolyData *output = vtkPolyData::SafeDownCast(
71 outInfo->Get(vtkDataObject::DATA_OBJECT()));
75 vtkErrorMacro(<<
"AbscissasArrayName not specified");
81 vtkErrorMacro(<<
"ParallelTransportNormalsArrayName not specified");
85 output->DeepCopy(input);
87 vtkDoubleArray* abscissasArray = vtkDoubleArray::New();
88 abscissasArray->SetNumberOfComponents(1);
92 output->GetPointData()->AddArray(abscissasArray);
94 vtkDoubleArray* parallelTransportNormalsArray = vtkDoubleArray::New();
95 parallelTransportNormalsArray->SetNumberOfComponents(3);
99 output->GetPointData()->AddArray(parallelTransportNormalsArray);
101 abscissasArray->Delete();
102 parallelTransportNormalsArray->Delete();
109 int numberOfPoints = input->GetNumberOfPoints();
111 abscissasArray->SetNumberOfTuples(numberOfPoints);
112 abscissasArray->FillComponent(0,0.0);
114 double point0[3], point1[3];
118 int numberOfCells = input->GetNumberOfCells();
119 int numberOfPointsInCell;
121 for (
int k=0; k<numberOfCells; k++)
123 vtkPolyLine* polyLine = vtkPolyLine::SafeDownCast(input->GetCell(k));
130 numberOfPointsInCell = polyLine->GetNumberOfPoints();
134 id0 = polyLine->GetPointId(0);
135 abscissasArray->SetValue(id0,abscissa);
137 for (
int i=1; i<numberOfPointsInCell; i++)
139 id0 = polyLine->GetPointId(i-1);
140 id1 = polyLine->GetPointId(i);
141 input->GetPoint(id0,point0);
142 input->GetPoint(id1,point1);
143 abscissa += sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
144 abscissasArray->SetValue(id1,abscissa);
151 int numberOfPoints = input->GetNumberOfPoints();
153 parallelTransportNormalsArray->SetNumberOfTuples(numberOfPoints);
154 parallelTransportNormalsArray->FillComponent(0,0.0);
156 int numberOfCells = input->GetNumberOfCells();
157 int numberOfPointsInCell;
159 vtkTransform* transform = vtkTransform::New();
161 vtkIdType id0, id1, id2;
162 double p0[3], p1[3], p2[3];
164 double t0[3], t1[3], v[3];
170 for (
int k=0; k<numberOfCells; k++)
172 vtkPolyLine* polyLine = vtkPolyLine::SafeDownCast(input->GetCell(k));
179 numberOfPointsInCell = polyLine->GetNumberOfPoints();
181 if (numberOfPointsInCell < 2)
186 t0[0] = t0[1] = t0[2] = 0.0;
188 id0 = polyLine->GetPointId(0);
189 input->GetPoint(id0,p0);
191 vtkIdType nextId = 1;
194 id1 = polyLine->GetPointId(nextId);
195 input->GetPoint(id1,p1);
197 t0[0] = p1[0] - p0[0];
198 t0[1] = p1[1] - p0[1];
199 t0[2] = p1[2] - p0[2];
204 vtkMath::Normalize(t0);
207 vtkMath::Perpendiculars(t0,n0,dummy,0.0);
209 parallelTransportNormalsArray->SetTuple(id0,n0);
211 for (
int i=1; i<numberOfPointsInCell-1; i++)
213 id0 = polyLine->GetPointId(i-1);
214 id1 = polyLine->GetPointId(i);
215 id2 = polyLine->GetPointId(i+1);
216 input->GetPoint(id0,p0);
217 input->GetPoint(id1,p1);
218 input->GetPoint(id2,p2);
220 t0[0] = p1[0] - p0[0];
221 t0[1] = p1[1] - p0[1];
222 t0[2] = p1[2] - p0[2];
224 t1[0] = p2[0] - p1[0];
225 t1[1] = p2[1] - p1[1];
226 t1[2] = p2[2] - p1[2];
228 vtkMath::Normalize(t0);
229 vtkMath::Normalize(t1);
231 dot = vtkMath::Dot(t0,t1);
239 theta = acos(dot) * 180.0 / vtkMath::Pi();
242 vtkMath::Cross(t0,t1,v);
244 transform->Identity();
245 transform->RotateWXYZ(theta,v);
246 transform->TransformPoint(n0,n1);
248 dot = vtkMath::Dot(t1,n1);
249 n1[0] -= dot * t1[0];
250 n1[1] -= dot * t1[1];
251 n1[2] -= dot * t1[2];
253 vtkMath::Normalize(n1);
255 parallelTransportNormalsArray->SetTuple(id1,n1);
262 parallelTransportNormalsArray->SetTuple(id2,n1);