126{
127 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
128 vtkInformation *outInfo = outputVector->GetInformationObject(0);
129
130 vtkPolyData *input = vtkPolyData::SafeDownCast(
131 inInfo->Get(vtkDataObject::DATA_OBJECT()));
132 vtkPolyData *output = vtkPolyData::SafeDownCast(
133 outInfo->Get(vtkDataObject::DATA_OBJECT()));
134
136 {
137 vtkErrorMacro(<<"OffsetAbscissasArrayName not specified");
138 return 1;
139 }
140
142 {
143 vtkErrorMacro(<<"OffsetNormalsArrayName not specified");
144 return 1;
145 }
146
148 {
149 vtkErrorMacro(<<"AbscissasArrayName not specified");
150 return 1;
151 }
152
153 vtkDataArray* abscissasArray = input->GetPointData()->GetArray(this->
AbscissasArrayName);
154
155 if (!abscissasArray)
156 {
157 vtkErrorMacro(<<"AbscissasArray with name specified does not exist");
158 return 1;
159 }
160
162 {
163 vtkErrorMacro(<<"NormalsArrayName not specified");
164 return 1;
165 }
166
167 vtkDataArray* normalsArray = input->GetPointData()->GetArray(this->
NormalsArrayName);
168
169 if (!normalsArray)
170 {
171 vtkErrorMacro(<<"NormalsArray with name specified does not exist");
172 return 1;
173 }
174
176 {
177 vtkErrorMacro(<<"GroupIdsArrayName not specified");
178 return 1;
179 }
180
181 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->
GroupIdsArrayName);
182
183 if (!groupIdsArray)
184 {
185 vtkErrorMacro(<<"GroupIdsArray with name specified does not exist");
186 return 1;
187 }
188
190 {
191 vtkErrorMacro(<<"CenterlineIdsArrayName not specified");
192 return 1;
193 }
194
196
197 if (!centerlineIdsArray)
198 {
199 vtkErrorMacro(<<"CenterlineIdsArray with name specified does not exist");
200 return 1;
201 }
202
204 {
205 vtkErrorMacro(<<"ReferenceSystems not specified");
206 return 1;
207 }
208
210 {
211 vtkErrorMacro(<<"ReferenceSystems empty");
212 return 1;
213 }
214
216 {
217 vtkErrorMacro(<<"ReferenceSystemsNormalArrayName not specified");
218 return 1;
219 }
220
222
223 if (!referenceSystemsNormalArray)
224 {
225 vtkErrorMacro(<<"ReferenceSystemNormalsArray with name specified does not exist");
226 return 1;
227 }
228
230 {
231 vtkErrorMacro(<<"ReferenceSystemsGroupIdsArrayName not specified");
232 return 1;
233 }
234
236
237 if (!referenceSystemsGroupIdsArray)
238 {
239 vtkErrorMacro(<<"ReferenceSystemsGroupIdsArray with name specified does not exist");
240 return 1;
241 }
242
243 output->DeepCopy(input);
244
245 vtkDoubleArray* offsetAbscissasArray = vtkDoubleArray::New();
247 offsetAbscissasArray->SetNumberOfComponents(1);
248 offsetAbscissasArray->SetNumberOfTuples(input->GetNumberOfPoints());
249
250 vtkDoubleArray* offsetNormalsArray = vtkDoubleArray::New();
252 offsetNormalsArray->SetNumberOfComponents(3);
253 offsetNormalsArray->SetNumberOfTuples(input->GetNumberOfPoints());
254
255
256
257
258
262
263 vtkIdList* tubeInputCellIds = vtkIdList::New();
264
265 double referenceSystemOrigin[3], referenceSystemNormal[3];
266
268 {
269 this->
ReferenceGroupId =
static_cast<int>(referenceSystemsGroupIdsArray->GetComponent(0,0));
270 }
271
273
274 if (referenceSystemPointId == -1)
275 {
276 vtkErrorMacro(<<"Invalid ReferenceGroupId");
277 return 1;
278 }
279
280 this->
ReferenceSystems->GetPoint(referenceSystemPointId,referenceSystemOrigin);
281 referenceSystemsNormalArray->GetTuple(referenceSystemPointId,referenceSystemNormal);
282
283 vtkIdList* groupCellIds = vtkIdList::New();
285 for (int i=0; i<groupCellIds->GetNumberOfIds(); i++)
286 {
287 vtkIdType currentCellId = groupCellIds->GetId(i);
288
289 vtkIdType centerlineId = static_cast<int>(centerlineIdsArray->GetComponent(currentCellId,0));
290 tubeInputCellIds->Initialize();
291 tubeInputCellIds->InsertNextId(currentCellId);
293
295
299
300 double abscissa = 0.0;
302 double abscissaOffset = - abscissa;
303
304 double normal[3];
306 vtkMath::Normalize(normal);
307
308 double point0[3], point1[3], tangent[3];
309 input->GetCell(cellId)->GetPoints()->GetPoint(subId,point0);
310 input->GetCell(cellId)->GetPoints()->GetPoint(subId+1,point1);
311 tangent[0] = point1[0] - point0[0];
312 tangent[1] = point1[1] - point0[1];
313 tangent[2] = point1[2] - point0[2];
314 double normalDot = vtkMath::Dot(tangent,normal);
315 tangent[0] -= normalDot * normal[0];
316 tangent[1] -= normalDot * normal[1];
317 tangent[2] -= normalDot * normal[2];
318 vtkMath::Normalize(tangent);
319
320 double dot = vtkMath::Dot(tangent,referenceSystemNormal);
321 double projectedReferenceSystemNormal[3];
322 projectedReferenceSystemNormal[0] = referenceSystemNormal[0] - dot * tangent[0];
323 projectedReferenceSystemNormal[1] = referenceSystemNormal[1] - dot * tangent[1];
324 projectedReferenceSystemNormal[2] = referenceSystemNormal[2] - dot * tangent[2];
325 vtkMath::Normalize(projectedReferenceSystemNormal);
326
328
329 double cross[3];
330 vtkMath::Cross(projectedReferenceSystemNormal,normal,cross);
331 double tangentDot = vtkMath::Dot(tangent,cross);
332
333 if (tangentDot < 0.0)
334 {
335 angle *= -1.0;
336 }
337
338 double angleOffset = -angle;
339
340 vtkIdList* centerlineCellIds = vtkIdList::New();
342 for (int j=0; j<centerlineCellIds->GetNumberOfIds(); j++)
343 {
344 vtkCell* branchCell = input->GetCell(centerlineCellIds->GetId(j));
345 int numberOfBranchPoints = branchCell->GetNumberOfPoints();
346 for (int k=0; k<numberOfBranchPoints; k++)
347 {
348 vtkIdType branchPointId = branchCell->GetPointId(k);
349 double branchPointAbscissa = abscissasArray->GetComponent(branchPointId,0);
350 double offsetBranchPointAbscissa = branchPointAbscissa + abscissaOffset;
351 offsetAbscissasArray->SetComponent(branchPointId,0,offsetBranchPointAbscissa);
352
353 double branchPointNormal[3];
354 normalsArray->GetTuple(branchPointId,branchPointNormal);
355 double branchPoint[3];
356 branchCell->GetPoints()->GetPoint(k,branchPoint);
357 double branchTangent[3];
358 branchTangent[0] = branchTangent[1] = branchTangent[2] = 0.0;
359 if (k > 0)
360 {
361 double branchPoint0[3];
362 branchCell->GetPoints()->GetPoint(k-1,branchPoint0);
363 branchTangent[0] += branchPoint[0] - branchPoint0[0];
364 branchTangent[1] += branchPoint[1] - branchPoint0[1];
365 branchTangent[2] += branchPoint[2] - branchPoint0[2];
366 }
367 if (k < numberOfBranchPoints-1)
368 {
369 double branchPoint1[3];
370 branchCell->GetPoints()->GetPoint(k+1,branchPoint1);
371 branchTangent[0] += branchPoint1[0] - branchPoint[0];
372 branchTangent[1] += branchPoint1[1] - branchPoint[1];
373 branchTangent[2] += branchPoint1[2] - branchPoint[2];
374 }
375 double branchNormalDot = vtkMath::Dot(branchTangent,branchPointNormal);
376 branchTangent[0] -= branchNormalDot * branchPointNormal[0];
377 branchTangent[1] -= branchNormalDot * branchPointNormal[1];
378 branchTangent[2] -= branchNormalDot * branchPointNormal[2];
379 vtkMath::Normalize(branchTangent);
380
381 vtkTransform* transform = vtkTransform::New();
382 transform->RotateWXYZ(angleOffset/vtkMath::Pi()*180.0,branchTangent);
383
384 double offsetBranchPointNormal[3];
385 transform->TransformNormal(branchPointNormal,offsetBranchPointNormal);
386 offsetNormalsArray->SetTuple(branchPointId,offsetBranchPointNormal);
387
388 transform->Delete();
389 }
390 }
391 centerlineCellIds->Delete();
392 }
393
394 groupCellIds->Delete();
395
396 output->GetPointData()->AddArray(offsetAbscissasArray);
397 output->GetPointData()->AddArray(offsetNormalsArray);
398
399 offsetAbscissasArray->Delete();
400 offsetNormalsArray->Delete();
401 tube->Delete();
402 tubeInputCellIds->Delete();
403
404 return 1;
405}
static void GetCenterlineCellIds(vtkPolyData *centerlines, const char *centerlineIdsArrayName, vtkIdType centerlineId, vtkIdList *centerlineCellIds)
static void GetGroupCellIds(vtkPolyData *centerlines, const char *groupIdsArrayName, vtkIdType groupId, vtkIdList *groupCellIds)
static void InterpolateTuple1(vtkPolyData *centerlines, const char *arrayName, int cellId, int subId, double pcoord, double &interpolatedTuple1)
static void InterpolateTuple3(vtkPolyData *centerlines, const char *arrayName, int cellId, int subId, double pcoord, double interpolatedTuple3[3])
static double AngleBetweenNormals(double normal0[3], double normal1[3])
virtual double GetLastPolyBallCellPCoord()
virtual void SetInput(vtkPolyData *)
virtual void SetInputCellIds(vtkIdList *)
virtual vtkIdType GetLastPolyBallCellId()
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
virtual vtkIdType GetLastPolyBallCellSubId()
virtual void UseRadiusInformationOff()
static vtkIdType GetReferenceSystemPointId(vtkPolyData *referenceSystems, const char *groupIdsArrayName, vtkIdType groupId)