127 vtkInformation *vtkNotUsed(request),
128 vtkInformationVector **inputVector,
129 vtkInformationVector *outputVector)
131 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
132 vtkInformation *outInfo = outputVector->GetInformationObject(0);
134 vtkPolyData *input = vtkPolyData::SafeDownCast(
135 inInfo->Get(vtkDataObject::DATA_OBJECT()));
136 vtkPolyData *output = vtkPolyData::SafeDownCast(
137 outInfo->Get(vtkDataObject::DATA_OBJECT()));
141 vtkErrorMacro(<<
"GroupIdsArrayName not specified");
145 vtkDataArray* groupIdsArray = input->GetPointData()->GetArray(this->
GroupIdsArrayName);
149 vtkErrorMacro(<<
"GroupIdsArray with name specified does not exist");
155 vtkErrorMacro(<<
"Centerlines not set");
161 vtkErrorMacro(<<
"CenterlineRadiusArrayName not specified");
167 if (!centerlineRadiusArray)
169 vtkErrorMacro(<<
"CenterlineRadiusArray with name specified does not exist");
175 vtkErrorMacro(<<
"CenterlineGroupIdsArrayName not specified");
181 if (!centerlineGroupIdsArray)
183 vtkErrorMacro(<<
"CenterlineGroupIdsArray with name specified does not exist");
189 vtkErrorMacro(<<
"CenterlineIdsArrayName not specified");
195 if (!centerlineIdsArray)
197 vtkErrorMacro(<<
"CenterlineIdsArray with name specified does not exist");
203 vtkErrorMacro(<<
"CenterlineTractIdsArrayName not specified");
209 if (!centerlineTractIdsArray)
211 vtkErrorMacro(<<
"CenterlineTractIdsArray with name specified does not exist");
217 vtkErrorMacro(<<
"BlankingArrayName not specified");
225 vtkErrorMacro(<<
"BlankingArray with name specified does not exist");
231 vtkErrorMacro(<<
"BifurcationProfileGroupIdsArrayName not specified");
237 vtkErrorMacro(<<
"BifurcationProfileBifurcationGroupIdsArrayName not specified");
243 vtkErrorMacro(<<
"BifurcationProfileOrientationArrayName not specified");
247 vtkIntArray* bifurcationProfileGroupIdsArray = vtkIntArray::New();
250 vtkIntArray* bifurcationProfileBifurcationGroupIdsArray = vtkIntArray::New();
253 vtkIntArray* bifurcationProfileOrientationArray = vtkIntArray::New();
256 output->GetCellData()->AddArray(bifurcationProfileGroupIdsArray);
257 output->GetCellData()->AddArray(bifurcationProfileBifurcationGroupIdsArray);
258 output->GetCellData()->AddArray(bifurcationProfileOrientationArray);
260 vtkPoints* outputPoints = vtkPoints::New();
261 vtkCellArray* outputLines = vtkCellArray::New();
263 output->SetPoints(outputPoints);
264 output->SetLines(outputLines);
266 vtkIdList* blankedGroupIds = vtkIdList::New();
269 for (i=0; i<blankedGroupIds->GetNumberOfIds(); i++)
271 vtkIdType bifurcationGroupId = blankedGroupIds->GetId(i);
274 vtkIdList* upStreamGroupIds = vtkIdList::New();
275 vtkIdList* downStreamGroupIds = vtkIdList::New();
281 upStreamGroupIds->Delete();
282 downStreamGroupIds->Delete();
285 blankedGroupIds->Delete();
287 outputPoints->Delete();
288 outputLines->Delete();
290 bifurcationProfileGroupIdsArray->Delete();
291 bifurcationProfileBifurcationGroupIdsArray->Delete();
292 bifurcationProfileOrientationArray->Delete();
300 vtkPoints* outputPoints = output->GetPoints();
301 vtkCellArray* outputLines = output->GetLines();
302 vtkIntArray* bifurcationProfileOrientationArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationProfileOrientationArrayName));
303 vtkIntArray* bifurcationProfileGroupIdsArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationProfileGroupIdsArrayName));
304 vtkIntArray* bifurcationProfileBifurcationGroupIdsArray = vtkIntArray::SafeDownCast(output->GetCellData()->GetArray(this->BifurcationProfileBifurcationGroupIdsArrayName));
306 vtkIdList* bifurcationProfileGroupIds = vtkIdList::New();
307 vtkIntArray* bifurcationProfileOrientations = vtkIntArray::New();
309 int numberOfUpStreamGroupIds = upStreamGroupIds->GetNumberOfIds();
310 int numberOfDownStreamGroupIds = downStreamGroupIds->GetNumberOfIds();
312 for (i=0; i<numberOfUpStreamGroupIds; i++)
314 bifurcationProfileGroupIds->InsertNextId(upStreamGroupIds->GetId(i));
317 for (i=0; i<numberOfDownStreamGroupIds; i++)
319 bifurcationProfileGroupIds->InsertNextId(downStreamGroupIds->GetId(i));
323 int numberOfBifurcationProfiles = bifurcationProfileGroupIds->GetNumberOfIds();
325 for (i=0; i<numberOfBifurcationProfiles; i++)
327 int bifurcationProfileGroupId = bifurcationProfileGroupIds->GetId(i);
328 int bifurcationProfileOrientation = bifurcationProfileOrientations->GetValue(i);
330 double averagePoint[3];
331 averagePoint[0] = averagePoint[1] = averagePoint[2] = 0.0;
333 double weightSum = 0.0;
336 vtkIdList* groupCellIds = vtkIdList::New();
338 for (j=0; j<groupCellIds->GetNumberOfIds(); j++)
340 vtkIdType cellId = groupCellIds->GetId(j);
341 vtkCell* cell = this->
Centerlines->GetCell(cellId);
342 int numberOfCellPoints = cell->GetNumberOfPoints();
345 double lastPointRadius = 0.0;
349 cell->GetPoints()->GetPoint(numberOfCellPoints-1,lastPoint);
350 lastPointRadius = radiusArray->GetComponent(cell->GetPointId(numberOfCellPoints-1),0);
354 cell->GetPoints()->GetPoint(0,lastPoint);
355 lastPointRadius = radiusArray->GetComponent(cell->GetPointId(0),0);
359 vtkErrorMacro(
"Error: invalid BifurcationVectorOrientation");
363 averagePoint[0] += lastPointRadius * lastPointRadius * lastPoint[0];
364 averagePoint[1] += lastPointRadius * lastPointRadius * lastPoint[1];
365 averagePoint[2] += lastPointRadius * lastPointRadius * lastPoint[2];
367 weightSum += lastPointRadius * lastPointRadius;
370 averagePoint[0] /= weightSum;
371 averagePoint[1] /= weightSum;
372 averagePoint[2] /= weightSum;
374 vtkPolyData* cylinder = vtkPolyData::New();
378 boundaryExtractor->SetInputData(cylinder);
379 boundaryExtractor->Update();
381 vtkPolyData* profile = boundaryExtractor->GetOutput();
383 int numberOfCells = profile->GetNumberOfCells();
384 int closestCellId = -1;
386 for (j=0; j<numberOfCells; j++)
388 double barycenter[3];
390 double barycenterDistance = vtkMath::Distance2BetweenPoints(barycenter,averagePoint);
391 if (barycenterDistance < minDistance)
394 minDistance = barycenterDistance;
398 vtkPoints* profileCellPoints = profile->GetCell(closestCellId)->GetPoints();
399 int numberOfProfileCellPoints = profileCellPoints->GetNumberOfPoints();
400 outputLines->InsertNextCell(numberOfProfileCellPoints);
401 for (j=0; j<numberOfProfileCellPoints; j++)
403 vtkIdType pointId = outputPoints->InsertNextPoint(profileCellPoints->GetPoint(j));
404 outputLines->InsertCellPoint(pointId);
407 bifurcationProfileGroupIdsArray->InsertNextValue(bifurcationProfileGroupId);
408 bifurcationProfileBifurcationGroupIdsArray->InsertNextValue(bifurcationGroupId);
409 bifurcationProfileOrientationArray->InsertNextValue(bifurcationProfileOrientation);
411 groupCellIds->Delete();
413 boundaryExtractor->Delete();
416 bifurcationProfileGroupIds->Delete();
417 bifurcationProfileOrientations->Delete();