169 vtkInformation *vtkNotUsed(request),
170 vtkInformationVector **inputVector,
171 vtkInformationVector *outputVector)
173 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
174 vtkInformation *outInfo = outputVector->GetInformationObject(0);
176 vtkPolyData *input = vtkPolyData::SafeDownCast(
177 inInfo->Get(vtkDataObject::DATA_OBJECT()));
178 vtkPolyData *output = vtkPolyData::SafeDownCast(
179 outInfo->Get(vtkDataObject::DATA_OBJECT()));
183 vtkErrorMacro(<<
"RadiusArrayName not specified");
187 vtkDataArray* radiusArray = input->GetPointData()->GetArray(this->
RadiusArrayName);
191 vtkErrorMacro(<<
"RadiusArray with name specified does not exist");
197 vtkErrorMacro(<<
"GroupIdsArrayName not specified");
201 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->
GroupIdsArrayName);
205 vtkErrorMacro(<<
"GroupIdsArray with name specified does not exist");
211 vtkErrorMacro(<<
"CenterlineIdsArrayName not specified");
217 if (!centerlineIdsArray)
219 vtkErrorMacro(<<
"CenterlineIdsArray with name specified does not exist");
225 vtkErrorMacro(<<
"TractIdsArrayName not specified");
229 vtkDataArray* tractIdsArray = input->GetCellData()->GetArray(this->
TractIdsArrayName);
233 vtkErrorMacro(<<
"TractIdsArray with name specified does not exist");
239 vtkErrorMacro(<<
"BlankingArrayName not specified");
243 vtkDataArray* blankingArray = input->GetCellData()->GetArray(this->
BlankingArrayName);
247 vtkErrorMacro(<<
"BlankingArray with name specified does not exist");
253 vtkErrorMacro(<<
"ReferenceSystemGroupIdsArrayName not specified");
259 if (!referenceSystemGroupIdsArray)
261 vtkErrorMacro(<<
"ReferenceSystemGroupIdsArray with name specified does not exist");
267 vtkErrorMacro(<<
"ReferenceSystemNormalArrayName not specified");
273 if (!referenceSystemNormalArray)
275 vtkErrorMacro(<<
"ReferenceSystemNormalArray with name specified does not exist");
281 vtkErrorMacro(<<
"ReferenceSystemUpNormalArrayName not specified");
287 if (!referenceSystemUpNormalArray)
289 vtkErrorMacro(<<
"ReferenceSystemUpNormalArray with name specified does not exist");
295 vtkErrorMacro(<<
"BifurcationVectorsArrayName not specified");
301 vtkErrorMacro(<<
"InPlaneBifurcationVectorsArrayName not specified");
307 vtkErrorMacro(<<
"OutOfPlaneBifurcationVectorsArrayName not specified");
313 vtkErrorMacro(<<
"BifurcationVectorsOrientationArrayName not specified");
319 vtkErrorMacro(<<
"BifurcationGroupIdsArrayName not specified");
325 vtkErrorMacro(<<
"InPlaneBifurcationVectorAnglesArrayName not specified");
331 vtkErrorMacro(<<
"OutOfPlaneBifurcationVectorAnglesArrayName not specified");
335 vtkPoints* outputPoints = vtkPoints::New();
336 vtkCellArray* outputVerts = vtkCellArray::New();
338 output->SetPoints(outputPoints);
339 output->SetVerts(outputVerts);
341 vtkDoubleArray* bifurcationVectorsArray = vtkDoubleArray::New();
343 bifurcationVectorsArray->SetNumberOfComponents(3);
345 vtkDoubleArray* inPlaneBifurcationVectorsArray = vtkDoubleArray::New();
347 inPlaneBifurcationVectorsArray->SetNumberOfComponents(3);
349 vtkDoubleArray* outOfPlaneBifurcationVectorsArray = vtkDoubleArray::New();
351 outOfPlaneBifurcationVectorsArray->SetNumberOfComponents(3);
353 vtkDoubleArray* inPlaneBifurcationVectorAnglesArray = vtkDoubleArray::New();
355 inPlaneBifurcationVectorAnglesArray->SetNumberOfComponents(1);
357 vtkDoubleArray* outOfPlaneBifurcationVectorAnglesArray = vtkDoubleArray::New();
359 outOfPlaneBifurcationVectorAnglesArray->SetNumberOfComponents(1);
361 vtkIntArray* bifurcationVectorsOrientationArray = vtkIntArray::New();
363 bifurcationVectorsOrientationArray->SetNumberOfComponents(1);
365 vtkIntArray* bifurcationVectorsGroupIdsArray = vtkIntArray::New();
367 bifurcationVectorsGroupIdsArray->SetNumberOfComponents(1);
369 vtkIntArray* bifurcationVectorsBifurcationGroupIdsArray = vtkIntArray::New();
371 bifurcationVectorsBifurcationGroupIdsArray->SetNumberOfComponents(1);
373 output->GetPointData()->AddArray(bifurcationVectorsArray);
374 output->GetPointData()->AddArray(inPlaneBifurcationVectorsArray);
375 output->GetPointData()->AddArray(outOfPlaneBifurcationVectorsArray);
376 output->GetPointData()->AddArray(inPlaneBifurcationVectorAnglesArray);
377 output->GetPointData()->AddArray(outOfPlaneBifurcationVectorAnglesArray);
378 output->GetPointData()->AddArray(bifurcationVectorsOrientationArray);
379 output->GetPointData()->AddArray(bifurcationVectorsGroupIdsArray);
380 output->GetPointData()->AddArray(bifurcationVectorsBifurcationGroupIdsArray);
382 vtkIdList* blankedGroupIds = vtkIdList::New();
385 for (i=0; i<blankedGroupIds->GetNumberOfIds(); i++)
387 vtkIdType bifurcationGroupId = blankedGroupIds->GetId(i);
389 vtkIdList* groupBifurcationVectorsGroupIds = vtkIdList::New();
390 vtkIntArray* groupBifurcationVectorsOrientation = vtkIntArray::New();
391 vtkDoubleArray* groupBifurcationVectors = vtkDoubleArray::New();
392 vtkPoints* groupBifurcationVectorsPoints = vtkPoints::New();
393 vtkDoubleArray* groupInPlaneBifurcationVectors = vtkDoubleArray::New();
394 vtkDoubleArray* groupOutOfPlaneBifurcationVectors = vtkDoubleArray::New();
395 vtkDoubleArray* groupInPlaneBifurcationVectorAngles = vtkDoubleArray::New();
396 vtkDoubleArray* groupOutOfPlaneBifurcationVectorAngles = vtkDoubleArray::New();
398 this->
ComputeBifurcationVectors(input,bifurcationGroupId,groupBifurcationVectorsGroupIds,groupBifurcationVectorsOrientation,groupBifurcationVectors,groupBifurcationVectorsPoints);
400 this->
ComputeBifurcationVectorAngles(bifurcationGroupId,groupBifurcationVectors,groupInPlaneBifurcationVectors,groupOutOfPlaneBifurcationVectors,groupInPlaneBifurcationVectorAngles,groupOutOfPlaneBifurcationVectorAngles);
403 for (j=0; j<groupBifurcationVectorsGroupIds->GetNumberOfIds(); j++)
405 vtkIdType pointId = outputPoints->InsertNextPoint(groupBifurcationVectorsPoints->GetPoint(j));
406 outputVerts->InsertNextCell(1);
407 outputVerts->InsertCellPoint(pointId);
409 bifurcationVectorsArray->InsertNextTuple(groupBifurcationVectors->GetTuple(j));
410 inPlaneBifurcationVectorsArray->InsertNextTuple(groupInPlaneBifurcationVectors->GetTuple(j));
411 outOfPlaneBifurcationVectorsArray->InsertNextTuple(groupOutOfPlaneBifurcationVectors->GetTuple(j));
412 inPlaneBifurcationVectorAnglesArray->InsertNextTuple(groupInPlaneBifurcationVectorAngles->GetTuple(j));
413 outOfPlaneBifurcationVectorAnglesArray->InsertNextTuple(groupOutOfPlaneBifurcationVectorAngles->GetTuple(j));
414 bifurcationVectorsOrientationArray->InsertNextValue(groupBifurcationVectorsOrientation->GetValue(j));
415 bifurcationVectorsGroupIdsArray->InsertNextValue(groupBifurcationVectorsGroupIds->GetId(j));
416 bifurcationVectorsBifurcationGroupIdsArray->InsertNextValue(bifurcationGroupId);
419 groupBifurcationVectorsGroupIds->Delete();
420 groupBifurcationVectorsOrientation->Delete();
421 groupBifurcationVectors->Delete();
422 groupBifurcationVectorsPoints->Delete();
423 groupInPlaneBifurcationVectors->Delete();
424 groupOutOfPlaneBifurcationVectors->Delete();
425 groupInPlaneBifurcationVectorAngles->Delete();
426 groupOutOfPlaneBifurcationVectorAngles->Delete();
429 blankedGroupIds->Delete();
431 outputPoints->Delete();
432 outputVerts->Delete();
434 bifurcationVectorsArray->Delete();
435 inPlaneBifurcationVectorsArray->Delete();
436 outOfPlaneBifurcationVectorsArray->Delete();
437 inPlaneBifurcationVectorAnglesArray->Delete();
438 outOfPlaneBifurcationVectorAnglesArray->Delete();
439 bifurcationVectorsOrientationArray->Delete();
440 bifurcationVectorsGroupIdsArray->Delete();
441 bifurcationVectorsBifurcationGroupIdsArray->Delete();
448 vtkDataArray* radiusArray = input->GetPointData()->GetArray(this->
RadiusArrayName);
450 bifurcationVectorsGroupIds->Initialize();
451 bifurcationVectorsOrientation->Initialize();
453 vtkIdList* upStreamGroupIds = vtkIdList::New();
454 vtkIdList* downStreamGroupIds = vtkIdList::New();
458 int numberOfUpStreamGroupIds = upStreamGroupIds->GetNumberOfIds();
459 int numberOfDownStreamGroupIds = downStreamGroupIds->GetNumberOfIds();
462 for (i=0; i<numberOfUpStreamGroupIds; i++)
464 bifurcationVectorsGroupIds->InsertNextId(upStreamGroupIds->GetId(i));
467 for (i=0; i<numberOfDownStreamGroupIds; i++)
469 bifurcationVectorsGroupIds->InsertNextId(downStreamGroupIds->GetId(i));
473 upStreamGroupIds->Delete();
474 downStreamGroupIds->Delete();
476 bifurcationVectors->Initialize();
477 bifurcationVectors->SetNumberOfComponents(3);
479 int numberOfBifurcationVectors = bifurcationVectorsGroupIds->GetNumberOfIds();
481 for (i=0; i<numberOfBifurcationVectors; i++)
483 int bifurcationVectorGroupId = bifurcationVectorsGroupIds->GetId(i);
484 int bifurcationVectorOrientation = bifurcationVectorsOrientation->GetValue(i);
485 double averageLastPoint[3], averageTouchingPoint[3];
486 averageLastPoint[0] = averageLastPoint[1] = averageLastPoint[2] = 0.0;
487 averageTouchingPoint[0] = averageTouchingPoint[1] = averageTouchingPoint[2] = 0.0;
488 double lastPointWeightSum = 0.0;
489 double touchingPointWeightSum = 0.0;
490 vtkIdList* groupCellIds = vtkIdList::New();
492 for (
int j=0; j<groupCellIds->GetNumberOfIds(); j++)
494 vtkIdType cellId = groupCellIds->GetId(j);
495 vtkCell* cell = input->GetCell(cellId);
496 int numberOfCellPoints = cell->GetNumberOfPoints();
498 vtkIdType touchingSubId = -1;
499 double touchingPCoord = 0.0;
501 vtkIdType pointSubId = -1;
502 double pointPCoord = 0.0;
506 double lastPointRadius = 0.0;
510 pointSubId = numberOfCellPoints-2;
513 cell->GetPoints()->GetPoint(numberOfCellPoints-1,lastPoint);
514 lastPointRadius = radiusArray->GetComponent(cell->GetPointId(numberOfCellPoints-1),0);
521 cell->GetPoints()->GetPoint(0,lastPoint);
522 lastPointRadius = radiusArray->GetComponent(cell->GetPointId(0),0);
526 vtkErrorMacro(
"Error: invalid BifurcationVectorOrientation");
532 if (touchingSubId == -1)
534 touchingSubId = numberOfCellPoints-2;
535 touchingPCoord = 1.0;
540 averageLastPoint[0] += lastPointRadius * lastPointRadius * lastPoint[0];
541 averageLastPoint[1] += lastPointRadius * lastPointRadius * lastPoint[1];
542 averageLastPoint[2] += lastPointRadius * lastPointRadius * lastPoint[2];
544 lastPointWeightSum += lastPointRadius * lastPointRadius;
545 double touchingPoint[3], touchingPointRadius;
549 averageTouchingPoint[0] += touchingPointRadius * touchingPointRadius * touchingPoint[0];
550 averageTouchingPoint[1] += touchingPointRadius * touchingPointRadius * touchingPoint[1];
551 averageTouchingPoint[2] += touchingPointRadius * touchingPointRadius * touchingPoint[2];
553 touchingPointWeightSum += touchingPointRadius * touchingPointRadius;
555 groupCellIds->Delete();
557 averageLastPoint[0] /= lastPointWeightSum;
558 averageLastPoint[1] /= lastPointWeightSum;
559 averageLastPoint[2] /= lastPointWeightSum;
561 averageTouchingPoint[0] /= touchingPointWeightSum;
562 averageTouchingPoint[1] /= touchingPointWeightSum;
563 averageTouchingPoint[2] /= touchingPointWeightSum;
567 double bifurcationVector[3], bifurcationVectorPoint[3];
571 bifurcationVector[0] = averageLastPoint[0] - averageTouchingPoint[0];
572 bifurcationVector[1] = averageLastPoint[1] - averageTouchingPoint[1];
573 bifurcationVector[2] = averageLastPoint[2] - averageTouchingPoint[2];
574 bifurcationVectorPoint[0] = averageTouchingPoint[0];
575 bifurcationVectorPoint[1] = averageTouchingPoint[1];
576 bifurcationVectorPoint[2] = averageTouchingPoint[2];
580 bifurcationVector[0] = averageTouchingPoint[0] - averageLastPoint[0];
581 bifurcationVector[1] = averageTouchingPoint[1] - averageLastPoint[1];
582 bifurcationVector[2] = averageTouchingPoint[2] - averageLastPoint[2];
583 bifurcationVectorPoint[0] = averageLastPoint[0];
584 bifurcationVectorPoint[1] = averageLastPoint[1];
585 bifurcationVectorPoint[2] = averageLastPoint[2];
589 vtkErrorMacro(
"Error: invalid BifurcationVectorOrientation");
595 vtkMath::Normalize(bifurcationVector);
598 bifurcationVectors->InsertNextTuple(bifurcationVector);
599 bifurcationVectorsPoints->InsertNextPoint(bifurcationVectorPoint);
610 inPlaneBifurcationVectors->Initialize();
611 inPlaneBifurcationVectors->SetNumberOfComponents(3);
612 outOfPlaneBifurcationVectors->Initialize();
613 outOfPlaneBifurcationVectors->SetNumberOfComponents(3);
617 double bifurcationPlaneNormal[3];
618 referenceSystemNormalArray->GetTuple(referenceSystemPointId,bifurcationPlaneNormal);
620 double bifurcationUpNormal[3];
621 referenceSystemUpNormalArray->GetTuple(referenceSystemPointId,bifurcationUpNormal);
623 double bifurcationVector[3], inPlaneBifurcationVector[3], outOfPlaneBifurcationVector[3];
625 int numberOfBifurcationVectors = bifurcationVectors->GetNumberOfTuples();
628 for (j=0; j<numberOfBifurcationVectors; j++)
630 bifurcationVectors->GetTuple(j,bifurcationVector);
632 double dot = vtkMath::Dot(bifurcationVector,bifurcationPlaneNormal);
634 outOfPlaneBifurcationVector[0] = dot * bifurcationPlaneNormal[0];
635 outOfPlaneBifurcationVector[1] = dot * bifurcationPlaneNormal[1];
636 outOfPlaneBifurcationVector[2] = dot * bifurcationPlaneNormal[2];
638 inPlaneBifurcationVector[0] = bifurcationVector[0] - outOfPlaneBifurcationVector[0];
639 inPlaneBifurcationVector[1] = bifurcationVector[1] - outOfPlaneBifurcationVector[1];
640 inPlaneBifurcationVector[2] = bifurcationVector[2] - outOfPlaneBifurcationVector[2];
642 inPlaneBifurcationVectors->InsertNextTuple(inPlaneBifurcationVector);
643 outOfPlaneBifurcationVectors->InsertNextTuple(outOfPlaneBifurcationVector);
654 double bifurcationPlaneNormal[3], bifurcationUpNormal[3];
656 referenceSystemNormalArray->GetTuple(referenceSystemPointId,bifurcationPlaneNormal);
657 referenceSystemUpNormalArray->GetTuple(referenceSystemPointId,bifurcationUpNormal);
659 int numberOfBifurcationVectors = bifurcationVectors->GetNumberOfTuples();
661 for (i=0; i<numberOfBifurcationVectors; i++)
663 double bifurcationVector[3], inPlaneBifurcationVector[3], outOfPlaneBifurcationVector[3];
665 bifurcationVectors->GetTuple(i,bifurcationVector);
666 inPlaneBifurcationVectors->GetTuple(i,inPlaneBifurcationVector);
667 outOfPlaneBifurcationVectors->GetTuple(i,outOfPlaneBifurcationVector);
669 vtkMath::Normalize(bifurcationVector);
670 vtkMath::Normalize(inPlaneBifurcationVector);
674 vtkMath::Cross(inPlaneBifurcationVector,bifurcationUpNormal,cross);
675 if (vtkMath::Dot(cross,bifurcationPlaneNormal) < 0.0)
677 inPlaneBifurcationVectorAngle *= -1.0;
682 inPlaneBifurcationVectorAngles->InsertNextValue(inPlaneBifurcationVectorAngle);
683 outOfPlaneBifurcationVectorAngles->InsertNextValue(outOfPlaneBifurcationVectorAngle);