557 vtkIdList* notVisitedIds = vtkIdList::New();
559 for (i=0; i<virtualPoints->GetNumberOfPoints(); i++)
561 notVisitedIds->InsertNextId(i);
564 while (notVisitedIds->GetNumberOfIds())
566 vtkPolyData* newProfile = vtkPolyData::New();
567 vtkPoints* newProfilePoints = vtkPoints::New();
568 newProfile->SetPoints(newProfilePoints);
570 vtkIdTypeArray* newProfileEdgeTable = vtkIdTypeArray::New();
571 newProfileEdgeTable->SetNumberOfComponents(2);
572 vtkIdType cellPair0[2];
573 vtkIdType position1 = notVisitedIds->GetId(0);
575 vtkIdType initialCellId = cellPair0[0];
576 vtkIdType cellIdToSearch = cellPair0[1];
577 newProfile->GetPoints()->InsertNextPoint(virtualPoints->GetPoint(position1));
578 vtkIdType newProfileEdge[2];
580 notVisitedIds->DeleteId(position1);
581 this->
InsertInEdgeTable(newProfileEdgeTable,newProfileEdge[0],newProfileEdge[1]);
584 vtkIdType cellPair1[2];
587 bool foundNext =
false;
591 if (j >= notVisitedIds->GetNumberOfIds())
593 vtkErrorMacro(<<
"Error: can't reconstruct new profile.");
597 vtkIdType position2 = notVisitedIds->GetId(j);
599 if (cellPair1[0] == cellIdToSearch)
601 double virtualPoint[3];
602 virtualPoints->GetPoint(position2,virtualPoint);
603 newProfile->GetPoints()->InsertNextPoint(virtualPoint);
605 this->
InsertInEdgeTable(newProfileEdgeTable,newProfileEdge[0],newProfileEdge[1]);
607 notVisitedIds->DeleteId(position2);
608 cellIdToSearch = cellPair1[1];
610 else if (cellPair1[1] == cellIdToSearch)
612 double virtualPoint[3];
613 virtualPoints->GetPoint(position2,virtualPoint);
614 newProfile->GetPoints()->InsertNextPoint(virtualPoint);
616 this->
InsertInEdgeTable(newProfileEdgeTable,newProfileEdge[0],newProfileEdge[1]);
618 notVisitedIds->DeleteId(position2);
619 cellIdToSearch = cellPair1[0];
624 if (cellIdToSearch == initialCellId)
630 vtkCellArray* newProfileLines = vtkCellArray::New();
631 newProfileLines->InsertNextCell(newProfile->GetNumberOfPoints() + 1);
633 for (i=0; i<newProfile->GetNumberOfPoints(); i++)
635 newProfileLines->InsertCellPoint(i);
637 newProfileLines->InsertCellPoint(0);
638 newProfile->SetLines(newProfileLines);
639 newProfiles->AddItem(newProfile);
640 newProfilesEdgeTables->AddItem(newProfileEdgeTable);
641 newProfile->Delete();
642 newProfilePoints->Delete();
643 newProfileLines->Delete();
644 newProfileEdgeTable->Delete();
646 notVisitedIds->Delete();
776vtkIdType
vtkvmtkPolyDataNetworkExtraction::StepIteration(vtkPolyData* model, vtkPolyDataCollection* baseProfiles, vtkCollection* baseProfilesEdgeTables, vtkPolyDataCollection* globalProfiles, vtkCollection* globalProfilesEdgeTables, vtkPolyDataCollection* newProfiles, vtkCollection* newProfilesEdgeTables, vtkPoints* segmentPoints, vtkDoubleArray* segmentRadii, vtkPoints* bifurcationPoints, vtkDoubleArray* bifurcationRadii,
double oldCenter[3],
double &oldRadius,
double advancementRatio)
778 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(
MarksArrayName));
784 bool sameCenter =
false;
789 radius = 2.0 * oldRadius;
795 vtkIdTypeArray* edgeTableForNewProfiles = vtkIdTypeArray::New();
796 edgeTableForNewProfiles->SetNumberOfComponents(2);
797 vtkIdTypeArray* cellPairsForNewProfiles = vtkIdTypeArray::New();
798 cellPairsForNewProfiles->SetNumberOfComponents(2);
799 vtkIdList* pointIdsForNewProfiles = vtkIdList::New();
801 vtkIdTypeArray* edgeTableForIncludedGlobalProfiles = vtkIdTypeArray::New();
802 edgeTableForIncludedGlobalProfiles->SetNumberOfComponents(2);
804 vtkPoints* markedPoints = vtkPoints::New();
805 vtkIdList* markedPointIds = vtkIdList::New();
808 baseProfiles->InitTraversal();
809 baseProfilesEdgeTables->InitTraversal();
810 vtkIdList* old2MarkedPointIds = vtkIdList::New();
811 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
813 vtkPolyData* baseProfile = baseProfiles->GetNextItem();
814 vtkIdTypeArray* baseProfileEdgeTable = (vtkIdTypeArray*)baseProfilesEdgeTables->GetNextItemAsObject();
816 for (j=0; j<baseProfile->GetNumberOfPoints(); j++)
818 vtkIdType currentEdge[2];
820 if (marksArray->GetValue(currentEdge[0]) ==
GLOBAL)
822 marksArray->InsertValue(currentEdge[0],
VISITED);
823 old2MarkedPointIds->InsertNextId(currentEdge[0]);
829 baseProfiles->InitTraversal();
830 baseProfilesEdgeTables->InitTraversal();
832 vtkIdList* toVisitPointIds = vtkIdList::New();
833 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
835 vtkPolyData* baseProfile = baseProfiles->GetNextItem();
836 vtkIdTypeArray* baseProfileEdgeTable = (vtkIdTypeArray*)baseProfilesEdgeTables->GetNextItemAsObject();
839 for (j=0; j<baseProfile->GetNumberOfPoints(); j++)
841 vtkIdType currentEdge[2];
845 if (marksArray->GetValue(currentEdge[1]) ==
GLOBAL)
847 this->
InsertInEdgeTable(edgeTableForIncludedGlobalProfiles,currentEdge[0],currentEdge[1]);
850 if (currentPointId!=-1)
852 if (this->
Distance(model->GetPoint(currentPointId),center)>radius)
854 this->
InsertEdgeForNewProfiles(model,currentEdge,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles);
858 toVisitPointIds->InsertNextId(currentPointId);
864 this->
PropagateFromBaseProfilePoint(model,toVisitPointIds,center,radius,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles,markedPoints,markedPointIds,edgeTableForIncludedGlobalProfiles);
866 toVisitPointIds->Delete();
868 for (i=0; i<old2MarkedPointIds->GetNumberOfIds(); i++)
870 marksArray->InsertValue(old2MarkedPointIds->GetId(i),
GLOBAL);
873 old2MarkedPointIds->Delete();
875 if (edgeTableForIncludedGlobalProfiles->GetNumberOfTuples() > 0)
877 vtkIdTypeArray* edgeTableForEffectiveIncludedGlobalProfiles = vtkIdTypeArray::New();
878 edgeTableForEffectiveIncludedGlobalProfiles->SetNumberOfComponents(2);
881 for (i=0; i<edgeTableForIncludedGlobalProfiles->GetNumberOfTuples(); i++)
883 vtkIdType edgeForIncludedGlobalProfile[2];
884 this->
GetFromEdgeTable(edgeTableForIncludedGlobalProfiles,i,edgeForIncludedGlobalProfile);
885 if (this->
Distance(model->GetPoint(edgeForIncludedGlobalProfile[1]),center) <= radius)
887 this->
InsertInEdgeTable(edgeTableForEffectiveIncludedGlobalProfiles,edgeForIncludedGlobalProfile[0],edgeForIncludedGlobalProfile[1]);
891 if (edgeTableForEffectiveIncludedGlobalProfiles->GetNumberOfTuples() > 0)
893 vtkIdList* includedGlobalProfilesIds = vtkIdList::New();
894 for (i=0; i<edgeTableForEffectiveIncludedGlobalProfiles->GetNumberOfTuples(); i++)
896 vtkIdType edgeForIncludedGlobalProfile[2];
897 this->
GetFromEdgeTable(edgeTableForEffectiveIncludedGlobalProfiles,i,edgeForIncludedGlobalProfile);
898 globalProfiles->InitTraversal();
899 globalProfilesEdgeTables->InitTraversal();
901 for (j=0; j<globalProfiles->GetNumberOfItems(); j++)
904 vtkIdTypeArray* globalProfileEdgeTable = (vtkIdTypeArray*)globalProfilesEdgeTables->GetNextItemAsObject();
906 for (k=0; k<globalProfileEdgeTable->GetNumberOfTuples(); k++)
908 vtkIdType globalProfileEdge[2];
910 if (globalProfileEdge[0]!=globalProfileEdge[1])
912 if ((edgeForIncludedGlobalProfile[0] == globalProfileEdge[0] && edgeForIncludedGlobalProfile[1] == globalProfileEdge[1]) || (edgeForIncludedGlobalProfile[0] == globalProfileEdge[1] && edgeForIncludedGlobalProfile[1] == globalProfileEdge[0]))
914 includedGlobalProfilesIds->InsertUniqueId(j);
917 else if (globalProfileEdge[0] == globalProfileEdge[1])
919 if (edgeForIncludedGlobalProfile[0] == globalProfileEdge[0] || edgeForIncludedGlobalProfile[1] == globalProfileEdge[0])
921 includedGlobalProfilesIds->InsertUniqueId(j);
928 vtkPolyDataCollection* includedGlobalProfiles = vtkPolyDataCollection::New();
929 vtkCollection* includedGlobalProfilesEdgeTables = vtkCollection::New();
930 globalProfiles->InitTraversal();
931 globalProfilesEdgeTables->InitTraversal();
932 for (i=0; i<globalProfiles->GetNumberOfItems(); i++)
934 vtkPolyData* globalProfile = globalProfiles->GetNextItem();
935 vtkIdTypeArray* globalProfileEdgeTable = (vtkIdTypeArray*)globalProfilesEdgeTables->GetNextItemAsObject();
936 if (includedGlobalProfilesIds->IsId(i) != -1)
938 includedGlobalProfiles->AddItem(globalProfile);
939 baseProfiles->AddItem(globalProfile);
940 includedGlobalProfilesEdgeTables->AddItem(globalProfileEdgeTable);
941 baseProfilesEdgeTables->AddItem(globalProfileEdgeTable);
945 includedGlobalProfiles->InitTraversal();
946 includedGlobalProfilesEdgeTables->InitTraversal();
947 for (i=0; i<includedGlobalProfiles->GetNumberOfItems(); i++)
949 globalProfiles->RemoveItem(includedGlobalProfiles->GetNextItem());
950 globalProfilesEdgeTables->RemoveItem(includedGlobalProfilesEdgeTables->GetNextItemAsObject());
955 edgeTableForNewProfiles->Delete();
956 cellPairsForNewProfiles->Delete();
957 pointIdsForNewProfiles->Delete();
958 edgeTableForIncludedGlobalProfiles->Delete();
959 markedPoints->Delete();
960 markedPointIds->Delete();
961 edgeTableForEffectiveIncludedGlobalProfiles->Delete();
963 includedGlobalProfilesIds->Delete();
965 includedGlobalProfiles->Delete();
966 includedGlobalProfilesEdgeTables->Delete();
971 for (i=0; i<edgeTableForIncludedGlobalProfiles->GetNumberOfTuples(); i++)
973 vtkIdType currentEdge[2];
975 this->
InsertEdgeForNewProfiles(model,currentEdge,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles);
978 edgeTableForEffectiveIncludedGlobalProfiles->Delete();
982 this->
GenerateNewProfiles(model,center,radius,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles,newProfiles,newProfilesEdgeTables);
987 vtkIdType numberOfBaseProfiles = baseProfiles->GetNumberOfItems();
988 vtkIdType numberOfNewProfiles = newProfiles->GetNumberOfItems();
990 if (numberOfBaseProfiles == 1 && numberOfNewProfiles == 0)
992 segmentPoints->InsertNextPoint(center);
993 edgeTableForNewProfiles->Delete();
994 cellPairsForNewProfiles->Delete();
995 pointIdsForNewProfiles->Delete();
996 edgeTableForIncludedGlobalProfiles->Delete();
997 markedPoints->Delete();
998 markedPointIds->Delete();
1002 else if (numberOfBaseProfiles == 2 && numberOfNewProfiles == 0)
1004 baseProfiles->InitTraversal();
1005 vtkPolyData* profile;
1006 profile = baseProfiles->GetNextItem();
1009 segmentPoints->InsertNextPoint(point1);
1010 profile = baseProfiles->GetNextItem();
1013 segmentPoints->InsertNextPoint(point2);
1015 vtkPoints *pointsForRadius = vtkPoints::New();
1016 this->
PointsForRadius(markedPoints,baseProfiles,NULL,pointsForRadius);
1017 segmentRadii->InsertNextValue(
ComputeStepRadius(pointsForRadius,point1,point2));
1019 pointsForRadius->Delete();
1021 edgeTableForNewProfiles->Delete();
1022 cellPairsForNewProfiles->Delete();
1023 pointIdsForNewProfiles->Delete();
1024 edgeTableForIncludedGlobalProfiles->Delete();
1025 markedPoints->Delete();
1026 markedPointIds->Delete();
1030 else if (numberOfBaseProfiles + numberOfNewProfiles > 2)
1032 double lastCenter[3];
1033 if (numberOfBaseProfiles==1)
1035 lastCenter[0] = center[0];
1036 lastCenter[1] = center[1];
1037 lastCenter[2] = center[2];
1041 baseProfiles->InitTraversal();
1042 vtkPolyData* profile;
1043 profile = baseProfiles->GetNextItem();
1047 segmentPoints->InsertNextPoint(lastCenter);
1049 double firstBranchRadius = 0.0;
1050 vtkIdType intersectingPointId = -1;
1051 if (segmentRadii->GetNumberOfTuples() > 0)
1056 vtkPoints* backupSegmentPoints = vtkPoints::New();
1057 for (i=0; i<segmentPoints->GetNumberOfPoints(); i++)
1059 backupSegmentPoints->InsertNextPoint(segmentPoints->GetPoint(i));
1061 vtkDoubleArray* backupSegmentRadii = vtkDoubleArray::New();
1062 for (i=0; i<segmentRadii->GetNumberOfTuples(); i++)
1064 backupSegmentRadii->InsertNextValue(segmentRadii->GetValue(i));
1067 segmentPoints->Initialize();
1068 for (i=0; i<=intersectingPointId; i++)
1070 segmentPoints->InsertNextPoint(backupSegmentPoints->GetPoint(i));
1072 segmentRadii->Initialize();
1073 for (i=0; i<intersectingPointId; i++)
1075 segmentRadii->InsertNextValue(backupSegmentRadii->GetValue(i));
1078 firstBranchRadius = backupSegmentRadii->GetValue(intersectingPointId-1);
1080 backupSegmentPoints->Delete();
1081 backupSegmentRadii->Delete();
1084 double bifurcationBarycenter[3];
1085 bifurcationBarycenter[0] = center[0];
1086 bifurcationBarycenter[1] = center[1];
1087 bifurcationBarycenter[2] = center[2];
1089 bifurcationPoints->InsertNextPoint(bifurcationBarycenter);
1090 bifurcationRadii->InsertNextValue(0.0);
1092 vtkPolyData* profile;
1093 baseProfiles->InitTraversal();
1095 double bifurcationPoint[3];
1096 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
1098 profile=baseProfiles->GetNextItem();
1099 if (i==0 && segmentRadii->GetNumberOfTuples())
1101 bifurcationPoints->InsertNextPoint(segmentPoints->GetPoint(intersectingPointId));
1102 bifurcationRadii->InsertNextValue(firstBranchRadius);
1107 bifurcationPoints->InsertNextPoint(bifurcationPoint);
1108 bifurcationRadii->InsertNextValue(this->
ComputeMeanRadius(profile->GetPoints(),bifurcationPoint));
1111 newProfiles->InitTraversal();
1112 for (i=0; i<newProfiles->GetNumberOfItems(); i++)
1114 profile=newProfiles->GetNextItem();
1116 bifurcationPoints->InsertNextPoint(bifurcationPoint);
1117 bifurcationRadii->InsertNextValue(this->
ComputeMeanRadius(profile->GetPoints(),bifurcationPoint));
1121 bifurcationBarycenter[0] = bifurcationBarycenter[1] = bifurcationBarycenter[2] = 0.0;
1122 double weightSum = 0.0;
1123 for (i=1; i<bifurcationPoints->GetNumberOfPoints(); i++)
1125 double bifurcationPoint[3];
1126 bifurcationPoints->GetPoint(i,bifurcationPoint);
1127 double bifurcationPointRadius = bifurcationRadii->GetValue(i);
1128 weightSum+=bifurcationPointRadius;
1131 bifurcationBarycenter[j] += bifurcationPoint[j] * bifurcationPointRadius;
1136 bifurcationBarycenter[j] /= weightSum;
1138 bifurcationPoints->InsertPoint(0,bifurcationBarycenter);
1140 edgeTableForNewProfiles->Delete();
1141 cellPairsForNewProfiles->Delete();
1142 pointIdsForNewProfiles->Delete();
1143 edgeTableForIncludedGlobalProfiles->Delete();
1144 markedPoints->Delete();
1145 markedPointIds->Delete();
1150 vtkPoints *pointsForRadius = vtkPoints::New();
1151 this->
PointsForRadius(markedPoints,baseProfiles,newProfiles,pointsForRadius);
1153 newProfiles->InitTraversal();
1154 double profileBarycenter[3];
1155 this->
ProfileBarycenter(newProfiles->GetNextItem()->GetPoints(),profileBarycenter);
1156 double stepRadius = this->
ComputeStepRadius(pointsForRadius,center,profileBarycenter);
1158 pointsForRadius->Delete();
1162 segmentRadii->InsertNextValue(stepRadius);
1163 segmentPoints->InsertNextPoint(center);
1167 segmentRadii->InsertValue(segmentRadii->GetNumberOfTuples()-1,stepRadius);
1168 segmentPoints->InsertPoint(segmentPoints->GetNumberOfPoints()-1,center);
1171 oldCenter[0] = center[0];
1172 oldCenter[1] = center[1];
1173 oldCenter[2] = center[2];
1176 edgeTableForNewProfiles->Delete();
1177 cellPairsForNewProfiles->Delete();
1178 pointIdsForNewProfiles->Delete();
1179 edgeTableForIncludedGlobalProfiles->Delete();
1180 markedPoints->Delete();
1181 markedPointIds->Delete();
1379void vtkvmtkPolyDataNetworkExtraction::SegmentIteration(vtkPolyData* model, vtkPolyData* initialProfile, vtkIdTypeArray* initialProfileEdgeTable, vtkPolyDataCollection* globalProfiles, vtkCollection* globalProfilesEdgeTables, vtkCollection* bifurcations, vtkCollection* bifurcationsRadii, vtkPolyDataCollection* segments,
double advancementRatio)
1381 vtkPolyDataCollection* baseProfiles = vtkPolyDataCollection::New();
1382 baseProfiles->AddItem(initialProfile);
1383 vtkCollection* baseProfilesEdgeTables = vtkCollection::New();
1384 baseProfilesEdgeTables->AddItem(initialProfileEdgeTable);
1386 vtkPolyDataCollection* newProfiles = vtkPolyDataCollection::New();
1387 vtkCollection* newProfilesEdgeTables = vtkCollection::New();
1389 vtkPoints* segmentPoints = vtkPoints::New();
1390 vtkDoubleArray* segmentRadii = vtkDoubleArray::New();
1391 vtkPoints* bifurcationPoints = vtkPoints::New();
1392 vtkDoubleArray* bifurcationRadii = vtkDoubleArray::New();
1394 double oldCenter[3];
1395 double oldRadius = 0.0;
1401 stepIterationState = this->
StepIteration(model,baseProfiles,baseProfilesEdgeTables,globalProfiles,globalProfilesEdgeTables,newProfiles,newProfilesEdgeTables,segmentPoints,segmentRadii,bifurcationPoints,bifurcationRadii,oldCenter,oldRadius,advancementRatio);
1411 baseProfiles->RemoveAllItems();
1412 baseProfilesEdgeTables->RemoveAllItems();
1413 newProfiles->InitTraversal();
1414 newProfilesEdgeTables->InitTraversal();
1415 baseProfiles->AddItem(newProfiles->GetNextItem());
1416 baseProfilesEdgeTables->AddItem(newProfilesEdgeTables->GetNextItemAsObject());
1417 newProfiles->RemoveAllItems();
1418 newProfilesEdgeTables->RemoveAllItems();
1422 vtkPolyData* segment = vtkPolyData::New();
1423 vtkPolyDataCollection* additionalSegments = vtkPolyDataCollection::New();
1424 vtkIdType segmentTopology[2];
1425 double firstPoint[3], lastPoint[3];
1426 double firstRadius, lastRadius;
1430 newProfiles->InitTraversal();
1431 newProfilesEdgeTables->InitTraversal();
1432 for (i=0; i<newProfiles->GetNumberOfItems(); i++)
1434 globalProfiles->AddItem(newProfiles->GetNextItem());
1435 vtkIdTypeArray* newGlobalProfileEdgeTable = (vtkIdTypeArray*)newProfilesEdgeTables->GetNextItemAsObject();
1436 globalProfilesEdgeTables->AddItem(newGlobalProfileEdgeTable);
1441 this->
InsertNewBifurcation(bifurcations,bifurcationsRadii,bifurcationPoints,bifurcationRadii,additionalSegments);
1443 if (segmentPoints->GetNumberOfPoints()>=2)
1445 double segmentPoint0[3], segmentPoint1[3];
1446 segmentPoints->GetPoint(0,segmentPoint0);
1447 segmentPoints->GetPoint(segmentPoints->GetNumberOfPoints()-1,segmentPoint1);
1448 this->
SegmentTopology(bifurcations,bifurcationsRadii,segmentPoint0,segmentPoint1,firstPoint,firstRadius,lastPoint,lastRadius,segmentTopology);
1449 this->
BuildSegment(segmentPoints,segmentRadii,segmentTopology,firstPoint,firstRadius,lastPoint,lastRadius,NULL,segment);
1450 segments->AddItem(segment);
1455 if (segmentPoints->GetNumberOfPoints() >= 2)
1457 double segmentPoint0[3], segmentPoint1[3];
1458 segmentPoints->GetPoint(0,segmentPoint0);
1459 segmentPoints->GetPoint(segmentPoints->GetNumberOfPoints()-1,segmentPoint1);
1460 this->
SegmentTopology(bifurcations,bifurcationsRadii,segmentPoint0,segmentPoint1,firstPoint,firstRadius,lastPoint,lastRadius,segmentTopology);
1461 this->
BuildSegment(segmentPoints,segmentRadii,segmentTopology,firstPoint,firstRadius,lastPoint,lastRadius,NULL,segment);
1462 segments->AddItem(segment);
1467 if (segmentPoints->GetNumberOfPoints() >= 2)
1469 double segmentPoint0[3];
1470 segmentPoints->GetPoint(0,segmentPoint0);
1471 this->
SegmentTopology(bifurcations,bifurcationsRadii,segmentPoint0,NULL,firstPoint,firstRadius,lastPoint,lastRadius,segmentTopology);
1472 this->
BuildSegment(segmentPoints,segmentRadii,segmentTopology,firstPoint,firstRadius,lastPoint,lastRadius,NULL,segment);
1473 segments->AddItem(segment);
1478 additionalSegments->InitTraversal();
1480 for (k=0; k<additionalSegments->GetNumberOfItems(); k++)
1482 segments->AddItem(additionalSegments->GetNextItem());
1485 additionalSegments->Delete();
1487 baseProfiles->Delete();
1488 baseProfilesEdgeTables->Delete();
1489 newProfiles->Delete();
1490 newProfilesEdgeTables->Delete();
1491 segmentPoints->Delete();
1492 segmentRadii->Delete();
1493 bifurcationPoints->Delete();
1494 bifurcationRadii->Delete();
1581 vtkIdList* realBifurcations = vtkIdList::New();
1582 realBifurcations->InsertNextId(0);
1583 vtkIdList* degenerateBifurcations = vtkIdList::New();
1584 vtkIdTypeArray* bifurcationFrequency = vtkIdTypeArray::New();
1585 bifurcations->InitTraversal();
1587 for (i=0; i<bifurcations->GetNumberOfItems(); i++)
1589 bifurcationFrequency->InsertNextValue(0);
1591 segments->InitTraversal();
1592 for (i=0; i<segments->GetNumberOfItems(); i++)
1594 vtkPolyData* segment = segments->GetNextItem();
1596 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(segment->GetCellData()->GetArray(
TopologyArrayName));
1597 vtkIdType topology[2];
1598 topologyArray->GetTypedTuple(0, topology);
1599 vtkIdType bifurcation0 = topology[0];
1600 if (bifurcation0 > 0)
1602 vtkIdType frequency0 = bifurcationFrequency->GetValue(bifurcation0);
1603 bifurcationFrequency->InsertValue(bifurcation0,frequency0+1);
1606 vtkIdType bifurcation1 = topology[1];
1607 if (bifurcation1 > 0)
1609 vtkIdType frequency1 = bifurcationFrequency->GetValue(bifurcation1);
1610 bifurcationFrequency->InsertValue(bifurcation1,frequency1+1);
1613 for (i=0; i<bifurcationFrequency->GetNumberOfTuples(); i++)
1617 if (bifurcationFrequency->GetValue(i) < 3)
1619 degenerateBifurcations->InsertNextId(i);
1623 realBifurcations->InsertNextId(i);
1629 while (degenerateBifurcations->GetNumberOfIds() > 0)
1631 segments->InitTraversal();
1632 vtkPolyData* segment0 = NULL,* segment1 = NULL,* currentSegment;
1633 vtkIdType degenerateId = -1;
1634 bool first0, first1;
1635 first0 = first1 =
false;
1636 for (i=0; i<segments->GetNumberOfItems(); i++)
1638 currentSegment = segments->GetNextItem();
1640 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(currentSegment->GetCellData()->GetArray(
TopologyArrayName));
1641 vtkIdType topology[2];
1642 topologyArray->GetTypedTuple(0,topology);
1645 degenerateId = topology[0];
1646 if (degenerateBifurcations->IsId(degenerateId) != -1)
1648 segment0 = currentSegment;
1650 degenerateBifurcations->DeleteId(degenerateId);
1654 degenerateId = topology[1];
1655 if (degenerateBifurcations->IsId(degenerateId) != -1)
1657 segment0 = currentSegment;
1659 degenerateBifurcations->DeleteId(degenerateId);
1665 if (topology[0] == degenerateId)
1667 segment1 = currentSegment;
1670 if (topology[1] == degenerateId)
1672 segment1 = currentSegment;
1677 if (segment0 && segment1)
1679 segment0->Register((vtkObjectBase*)NULL);
1680 segment1->Register((vtkObjectBase*)NULL);
1681 segments->RemoveItem(segment0);
1682 segments->RemoveItem(segment1);
1683 vtkPolyData* joinedSegment = vtkPolyData::New();
1684 this->
JoinSegments(segment0,segment1,first0,first1,joinedSegment);
1685 segments->AddItem(joinedSegment);
1686 joinedSegment->Delete();
1687 segment0->UnRegister((vtkObjectBase*)NULL);
1688 segment1->UnRegister((vtkObjectBase*)NULL);
1693 segments->InitTraversal();
1694 vtkIdType scalar0, scalar1, position0, position1;
1695 for (i=0; i<segments->GetNumberOfItems(); i++)
1697 vtkPolyData* currentSegment = segments->GetNextItem();
1699 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(currentSegment->GetCellData()->GetArray(
TopologyArrayName));
1700 vtkIdType topology[2];
1701 topologyArray->GetTypedTuple(0, topology);
1702 scalar0 = topology[0];
1703 scalar1 = topology[1];
1706 position0 = realBifurcations->InsertUniqueId(scalar0);
1707 topology[0] = position0;
1711 position1=realBifurcations->InsertUniqueId(scalar1);
1712 topology[1] = position1;
1714 topologyArray->InsertTypedTuple(0,topology);
1717 realBifurcations->Delete();
1718 degenerateBifurcations->Delete();
1719 bifurcationFrequency->Delete();
1725 vtkCollection* globalProfilesEdgeTables = vtkCollection::New();
1728 vtkCollection* bifurcations = vtkCollection::New();
1729 vtkCollection* bifurcationsRadii = vtkCollection::New();
1730 vtkPolyDataCollection* segments = vtkPolyDataCollection::New();
1732 vtkPoints* globalBoundaryBarycenters = vtkPoints::New();
1733 vtkDoubleArray* globalBoundaryRadii = vtkDoubleArray::New();
1734 vtkPolyData* profile;
1736 globalProfiles->InitTraversal();
1737 for (i=0; i<globalProfiles->GetNumberOfItems(); i++)
1739 profile=globalProfiles->GetNextItem();
1740 double barycenter[3];
1742 globalBoundaryBarycenters->InsertNextPoint(barycenter);
1743 globalBoundaryRadii->InsertNextValue(
ComputeMeanRadius(profile->GetPoints(),barycenter));
1746 bifurcations->AddItem(globalBoundaryBarycenters);
1747 bifurcationsRadii->AddItem(globalBoundaryRadii);
1749 while (globalProfiles->GetNumberOfItems())
1751 globalProfiles->InitTraversal();
1752 vtkPolyData* initialProfile = globalProfiles->GetNextItem();
1753 initialProfile->Register((vtkObjectBase*)NULL);
1754 globalProfiles->RemoveItem(initialProfile);
1756 globalProfilesEdgeTables->InitTraversal();
1757 vtkIdTypeArray* initialProfileEdgeTable = (vtkIdTypeArray*)globalProfilesEdgeTables->GetNextItemAsObject();
1758 initialProfileEdgeTable->Register((vtkObjectBase*)NULL);
1759 globalProfilesEdgeTables->RemoveItem(initialProfileEdgeTable);
1761 this->
SegmentIteration(model,initialProfile,initialProfileEdgeTable,globalProfiles,globalProfilesEdgeTables,bifurcations,bifurcationsRadii,segments,advancementRatio);
1763 double progress = (double)this->
TotalMarkedPoints/(
double)model->GetNumberOfPoints();
1764 this->InvokeEvent(vtkCommand::ProgressEvent,&progress);
1766 initialProfile->UnRegister((vtkObjectBase*)NULL);
1767 initialProfileEdgeTable->UnRegister((vtkObjectBase*)NULL);
1772 vtkIdTypeArray* topologyArray = vtkIdTypeArray::New();
1774 topologyArray->SetNumberOfComponents(2);
1776 segments->InitTraversal();
1777 for (i=0; i<segments->GetNumberOfItems(); i++)
1779 vtkIdType topology[2];
1780 vtkIdTypeArray* segmentTopologyArray = vtkIdTypeArray::SafeDownCast(segments->GetNextItem()->GetCellData()->GetArray(
TopologyArrayName));
1781 segmentTopologyArray->GetTypedTuple(0, topology);
1782 topologyArray->InsertNextTypedTuple(topology);
1785 vtkAppendPolyData* segmentsAppended = vtkAppendPolyData::New();
1786 segments->InitTraversal();
1787 for (i=0; i<segments->GetNumberOfItems(); i++)
1789 segmentsAppended->AddInputData(segments->GetNextItem());
1791 segmentsAppended->Update();
1793 network->DeepCopy(segmentsAppended->GetOutput());
1794 network->GetCellData()->AddArray(topologyArray);
1796 globalProfilesEdgeTables->Delete();
1797 bifurcations->Delete();
1798 bifurcationsRadii->Delete();
1800 globalBoundaryBarycenters->Delete();
1801 globalBoundaryRadii->Delete();
1802 segmentsAppended->Delete();
1803 topologyArray->Delete();