182 vtkInformation *vtkNotUsed(request),
183 vtkInformationVector **inputVector,
184 vtkInformationVector *outputVector)
186 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
187 vtkInformation *outInfo = outputVector->GetInformationObject(0);
189 vtkPolyData *input = vtkPolyData::SafeDownCast(
190 inInfo->Get(vtkDataObject::DATA_OBJECT()));
191 vtkPolyData *output = vtkPolyData::SafeDownCast(
192 outInfo->Get(vtkDataObject::DATA_OBJECT()));
196 vtkErrorMacro(<<
"GroupIdsArrayName not specified");
200 vtkDataArray* groupIdsArray = input->GetPointData()->GetArray(this->
GroupIdsArrayName);
204 vtkErrorMacro(<<
"GroupIdsArray with name specified does not exist");
210 vtkErrorMacro(<<
"Centerlines not set");
216 vtkErrorMacro(<<
"CenterlineRadiusArrayName not specified");
222 if (!centerlineRadiusArray)
224 vtkErrorMacro(<<
"CenterlineRadiusArray with name specified does not exist");
230 vtkErrorMacro(<<
"CenterlineGroupIdsArrayName not specified");
236 if (!centerlineGroupIdsArray)
238 vtkErrorMacro(<<
"CenterlineGroupIdsArray with name specified does not exist");
244 vtkErrorMacro(<<
"CenterlineIdsArrayName not specified");
250 if (!centerlineIdsArray)
252 vtkErrorMacro(<<
"CenterlineIdsArray with name specified does not exist");
258 vtkErrorMacro(<<
"CenterlineTractIdsArrayName not specified");
264 if (!centerlineTractIdsArray)
266 vtkErrorMacro(<<
"CenterlineTractIdsArray with name specified does not exist");
272 vtkErrorMacro(<<
"BlankingArrayName not specified");
280 vtkErrorMacro(<<
"BlankingArray with name specified does not exist");
286 vtkErrorMacro(<<
"BifurcationSectionGroupIdsArrayName not specified");
292 vtkErrorMacro(<<
"BifurcationSectionBifurcationGroupIdsArrayName not specified");
298 vtkErrorMacro(<<
"BifurcationSectionPointArrayName not specified");
304 vtkErrorMacro(<<
"BifurcationSectionNormalArrayName not specified");
310 vtkErrorMacro(<<
"BifurcationSectionAreaArrayName not specified");
316 vtkErrorMacro(<<
"BifurcationSectionMinSizeArrayName not specified");
322 vtkErrorMacro(<<
"BifurcationSectionMaxSizeArrayName not specified");
328 vtkErrorMacro(<<
"BifurcationSectionShapeArrayName not specified");
334 vtkErrorMacro(<<
"BifurcationSectionClosedArrayName not specified");
340 vtkErrorMacro(<<
"BifurcationSectionOrientationArrayName not specified");
346 vtkErrorMacro(<<
"BifurcationSectionDistanceSpheresArrayName not specified");
350 vtkIntArray* bifurcationSectionGroupIdsArray = vtkIntArray::New();
353 vtkIntArray* bifurcationSectionBifurcationGroupIdsArray = vtkIntArray::New();
356 vtkDoubleArray* bifurcationSectionPointArray = vtkDoubleArray::New();
358 bifurcationSectionPointArray->SetNumberOfComponents(3);
360 vtkDoubleArray* bifurcationSectionNormalArray = vtkDoubleArray::New();
362 bifurcationSectionNormalArray->SetNumberOfComponents(3);
364 vtkDoubleArray* bifurcationSectionAreaArray = vtkDoubleArray::New();
367 vtkDoubleArray* bifurcationSectionShapeArray = vtkDoubleArray::New();
370 vtkDoubleArray* bifurcationSectionMinSizeArray = vtkDoubleArray::New();
373 vtkDoubleArray* bifurcationSectionMaxSizeArray = vtkDoubleArray::New();
376 vtkIntArray* bifurcationSectionClosedArray = vtkIntArray::New();
379 vtkIntArray* bifurcationSectionOrientationArray = vtkIntArray::New();
382 vtkIntArray* bifurcationSectionDistanceSpheresArray = vtkIntArray::New();
385 output->GetCellData()->AddArray(bifurcationSectionGroupIdsArray);
386 output->GetCellData()->AddArray(bifurcationSectionBifurcationGroupIdsArray);
387 output->GetCellData()->AddArray(bifurcationSectionPointArray);
388 output->GetCellData()->AddArray(bifurcationSectionNormalArray);
389 output->GetCellData()->AddArray(bifurcationSectionAreaArray);
390 output->GetCellData()->AddArray(bifurcationSectionMinSizeArray);
391 output->GetCellData()->AddArray(bifurcationSectionMaxSizeArray);
392 output->GetCellData()->AddArray(bifurcationSectionShapeArray);
393 output->GetCellData()->AddArray(bifurcationSectionClosedArray);
394 output->GetCellData()->AddArray(bifurcationSectionOrientationArray);
395 output->GetCellData()->AddArray(bifurcationSectionDistanceSpheresArray);
397 vtkPoints* outputPoints = vtkPoints::New();
398 vtkCellArray* outputPolys = vtkCellArray::New();
400 output->SetPoints(outputPoints);
401 output->SetPolys(outputPolys);
403 vtkIdList* blankedGroupIds = vtkIdList::New();
406 for (i=0; i<blankedGroupIds->GetNumberOfIds(); i++)
408 vtkIdType bifurcationGroupId = blankedGroupIds->GetId(i);
411 vtkIdList* upStreamGroupIds = vtkIdList::New();
412 vtkIdList* downStreamGroupIds = vtkIdList::New();
418 upStreamGroupIds->Delete();
419 downStreamGroupIds->Delete();
422 blankedGroupIds->Delete();
424 outputPoints->Delete();
425 outputPolys->Delete();
427 bifurcationSectionGroupIdsArray->Delete();
428 bifurcationSectionBifurcationGroupIdsArray->Delete();
429 bifurcationSectionPointArray->Delete();
430 bifurcationSectionNormalArray->Delete();
431 bifurcationSectionAreaArray->Delete();
432 bifurcationSectionShapeArray->Delete();
433 bifurcationSectionMinSizeArray->Delete();
434 bifurcationSectionMaxSizeArray->Delete();
435 bifurcationSectionClosedArray->Delete();
436 bifurcationSectionOrientationArray->Delete();
437 bifurcationSectionDistanceSpheresArray->Delete();
445 vtkPoints* outputPoints = output->GetPoints();
446 vtkCellArray* outputPolys = output->GetPolys();
447 vtkDoubleArray* bifurcationSectionPointArray = vtkDoubleArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionPointArrayName));
448 vtkDoubleArray* bifurcationSectionNormalArray = vtkDoubleArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionNormalArrayName));
449 vtkDoubleArray* bifurcationSectionAreaArray = vtkDoubleArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionAreaArrayName));
450 vtkDoubleArray* bifurcationSectionMinSizeArray = vtkDoubleArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionMinSizeArrayName));
451 vtkDoubleArray* bifurcationSectionMaxSizeArray = vtkDoubleArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionMaxSizeArrayName));
452 vtkDoubleArray* bifurcationSectionShapeArray = vtkDoubleArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionShapeArrayName));
453 vtkIntArray* bifurcationSectionClosedArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionClosedArrayName));
454 vtkIntArray* bifurcationSectionOrientationArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionOrientationArrayName));
455 vtkIntArray* bifurcationSectionDistanceSpheresArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionDistanceSpheresArrayName));
456 vtkIntArray* bifurcationSectionGroupIdsArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionGroupIdsArrayName));
457 vtkIntArray* bifurcationSectionBifurcationGroupIdsArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationSectionBifurcationGroupIdsArrayName));
459 vtkIdList* bifurcationSectionGroupIds = vtkIdList::New();
460 vtkIntArray* bifurcationSectionOrientations = vtkIntArray::New();
462 int numberOfUpStreamGroupIds = upStreamGroupIds->GetNumberOfIds();
463 int numberOfDownStreamGroupIds = downStreamGroupIds->GetNumberOfIds();
465 for (i=0; i<numberOfUpStreamGroupIds; i++)
467 bifurcationSectionGroupIds->InsertNextId(upStreamGroupIds->GetId(i));
470 for (i=0; i<numberOfDownStreamGroupIds; i++)
472 bifurcationSectionGroupIds->InsertNextId(downStreamGroupIds->GetId(i));
476 int numberOfBifurcationSections = bifurcationSectionGroupIds->GetNumberOfIds();
478 for (i=0; i<numberOfBifurcationSections; i++)
480 int bifurcationSectionGroupId = bifurcationSectionGroupIds->GetId(i);
481 int bifurcationSectionOrientation = bifurcationSectionOrientations->GetValue(i);
483 double averagePoint[3];
484 averagePoint[0] = averagePoint[1] = averagePoint[2] = 0.0;
486 double averageTangent[3];
487 averageTangent[0] = averageTangent[1] = averageTangent[2] = 0.0;
489 double weightSum = 0.0;
492 bool anyPoint =
false;
493 vtkIdList* groupCellIds = vtkIdList::New();
495 for (j=0; j<groupCellIds->GetNumberOfIds(); j++)
497 vtkIdType cellId = groupCellIds->GetId(j);
498 vtkCell* cell = this->
Centerlines->GetCell(cellId);
499 int numberOfCellPoints = cell->GetNumberOfPoints();
501 vtkIdType touchingSubId = -1;
502 double touchingPCoord = 0.0;
504 vtkIdType pointSubId = -1;
505 double pointPCoord = 0.0;
509 double lastPointRadius = 0.0;
513 pointSubId = numberOfCellPoints-2;
516 cell->GetPoints()->GetPoint(numberOfCellPoints-1,lastPoint);
517 lastPointRadius = radiusArray->GetComponent(cell->GetPointId(numberOfCellPoints-1),0);
524 cell->GetPoints()->GetPoint(0,lastPoint);
525 lastPointRadius = radiusArray->GetComponent(cell->GetPointId(0),0);
529 vtkErrorMacro(
"Error: invalid BifurcationVectorOrientation");
535 if (touchingSubId == -1)
541 double touchingPoint[3];
544 double touchingPoint0[3], touchingPoint1[3];
545 this->
Centerlines->GetCell(cellId)->GetPoints()->GetPoint(touchingSubId,touchingPoint0);
546 this->
Centerlines->GetCell(cellId)->GetPoints()->GetPoint(touchingSubId+1,touchingPoint1);
548 double touchingPointTangent[3];
549 touchingPointTangent[0] = touchingPoint1[0] - touchingPoint0[0];
550 touchingPointTangent[1] = touchingPoint1[1] - touchingPoint0[1];
551 touchingPointTangent[2] = touchingPoint1[2] - touchingPoint0[2];
553 vtkMath::Normalize(touchingPointTangent);
554 double touchingPointRadius = 0.0;
557 averagePoint[0] += touchingPointRadius * touchingPointRadius * touchingPoint[0];
558 averagePoint[1] += touchingPointRadius * touchingPointRadius * touchingPoint[1];
559 averagePoint[2] += touchingPointRadius * touchingPointRadius * touchingPoint[2];
561 averageTangent[0] += touchingPointRadius * touchingPointRadius * touchingPointTangent[0];
562 averageTangent[1] += touchingPointRadius * touchingPointRadius * touchingPointTangent[1];
563 averageTangent[2] += touchingPointRadius * touchingPointRadius * touchingPointTangent[2];
565 weightSum += touchingPointRadius * touchingPointRadius;
573 averagePoint[0] /= weightSum;
574 averagePoint[1] /= weightSum;
575 averagePoint[2] /= weightSum;
577 averageTangent[0] /= weightSum;
578 averageTangent[1] /= weightSum;
579 averageTangent[2] /= weightSum;
581 vtkMath::Normalize(averageTangent);
585 vtkPolyData* cylinder = vtkPolyData::New();
588 vtkPolyData* section = vtkPolyData::New();
592 section->BuildCells();
593 if (section->GetNumberOfCells() == 0)
599 vtkPoints* sectionCellPoints = section->GetCell(0)->GetPoints();
600 int numberOfSectionCellPoints = sectionCellPoints->GetNumberOfPoints();
601 outputPolys->InsertNextCell(numberOfSectionCellPoints);
602 for (j=0; j<numberOfSectionCellPoints; j++)
604 vtkIdType pointId = outputPoints->InsertNextPoint(sectionCellPoints->GetPoint(j));
605 outputPolys->InsertCellPoint(pointId);
611 int closedValue = closed ? 1 : 0;
613 bifurcationSectionGroupIdsArray->InsertNextValue(bifurcationSectionGroupId);
614 bifurcationSectionBifurcationGroupIdsArray->InsertNextValue(bifurcationGroupId);
615 bifurcationSectionPointArray->InsertNextTuple(averagePoint);
616 bifurcationSectionNormalArray->InsertNextTuple(averageTangent);
617 bifurcationSectionAreaArray->InsertNextValue(area);
618 bifurcationSectionMinSizeArray->InsertNextValue(sizeRange[0]);
619 bifurcationSectionMaxSizeArray->InsertNextValue(sizeRange[1]);
620 bifurcationSectionShapeArray->InsertNextValue(shape);
621 bifurcationSectionClosedArray->InsertNextValue(closedValue);
622 bifurcationSectionOrientationArray->InsertNextValue(bifurcationSectionOrientation);
625 groupCellIds->Delete();
630 bifurcationSectionGroupIds->Delete();
631 bifurcationSectionOrientations->Delete();