112 vtkInformation *vtkNotUsed(request),
113 vtkInformationVector **inputVector,
114 vtkInformationVector *outputVector)
116 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
117 vtkInformation *outInfo = outputVector->GetInformationObject(0);
119 vtkPolyData *input = vtkPolyData::SafeDownCast(
120 inInfo->Get(vtkDataObject::DATA_OBJECT()));
121 vtkPolyData *output = vtkPolyData::SafeDownCast(
122 outInfo->Get(vtkDataObject::DATA_OBJECT()));
124 vtkDataArray* centerlineGroupIdsArray;
125 vtkIntArray* blankingArray;
126 vtkIntArray* groupIdsArray;
130 vtkErrorMacro(<<
"Centerlines not set.");
136 vtkErrorMacro(<<
"CenterlineGroupIds not set.");
142 vtkErrorMacro(<<
"CenterlineGroupIdsArrayName not set.");
148 vtkErrorMacro(<<
"GroupIdsArrayName not set.");
154 if (!centerlineGroupIdsArray)
156 vtkErrorMacro(<<
"CenterlineGroupIdsArray with name specified does not exist");
162 vtkErrorMacro(<<
"BlankingArrayName not set.");
166 blankingArray = vtkIntArray::SafeDownCast(this->
Centerlines->GetCellData()->GetArray(this->BlankingArrayName));
170 vtkErrorMacro(<<
"BlankingArrayName with name specified does not exist");
176 vtkErrorMacro(<<
"CenterlineRadiusArrayName not set.");
180 if (!this->
Centerlines->GetPointData()->GetArray(this->CenterlineRadiusArrayName))
182 vtkErrorMacro(<<
"CenterlineRadiusArray with name specified does not exist");
188 output->DeepCopy(input);
189 groupIdsArray = vtkIntArray::New();
191 groupIdsArray->SetNumberOfTuples(output->GetNumberOfPoints());
192 groupIdsArray->FillComponent(0,centerlineGroupIdsArray->GetComponent(0,0));
193 output->GetPointData()->AddArray(groupIdsArray);
194 groupIdsArray->Delete();
198 vtkAppendPolyData* appendBranches = vtkAppendPolyData::New();
199 vtkAppendPolyData* appendClippedOutput = NULL;
202 appendClippedOutput = vtkAppendPolyData::New();
217 int numberOfPoints = input->GetNumberOfPoints();
219 const char clippingArrayName[] =
"ClippingArray";
221 vtkDoubleArray* clippingArray = vtkDoubleArray::New();
222 clippingArray->SetNumberOfComponents(1);
223 clippingArray->SetNumberOfTuples(numberOfPoints);
224 clippingArray->FillComponent(0,0.0);
225 clippingArray->SetName(clippingArrayName);
227 vtkPolyData* clippingInput = vtkPolyData::New();
228 clippingInput->DeepCopy(input);
229 clippingInput->GetPointData()->AddArray(clippingArray);
230 clippingInput->GetPointData()->SetActiveScalars(clippingArrayName);
232 vtkIdList* groupTubesGroupIds = vtkIdList::New();
233 vtkIdList* nonGroupTubesGroupIds = vtkIdList::New();
236 double groupTubeValue, nonGroupTubeValue, tubeDifferenceValue;
240 vtkIdList* centerlineGroupIds = vtkIdList::New();
245 for (i=0; i<centerlineGroupIdsArray->GetNumberOfTuples(); i++)
247 if (blankingArray->GetValue(i) == 1)
251 centerlineGroupIds->InsertUniqueId(
static_cast<vtkIdType
>(vtkMath::Round(centerlineGroupIdsArray->GetComponent(i,0))));
259 for (i=0; i<centerlineGroupIds->GetNumberOfIds(); i++)
261 groupId = centerlineGroupIds->GetId(i);
263 groupTubesGroupIds->Initialize();
264 nonGroupTubesGroupIds->Initialize();
266 for (
int j=0; j<this->
Centerlines->GetNumberOfCells(); j++)
268 if (blankingArray->GetValue(j) == 1)
272 if (
static_cast<vtkIdType
>(vtkMath::Round(centerlineGroupIdsArray->GetComponent(j,0))) == groupId)
274 groupTubesGroupIds->InsertNextId(j);
278 nonGroupTubesGroupIds->InsertNextId(j);
282 if ((groupTubesGroupIds->GetNumberOfIds() == 0) || (nonGroupTubesGroupIds->GetNumberOfIds() == 0))
290 for (
int k=0; k<numberOfPoints; k++)
292 input->GetPoint(k,point);
299 tubeDifferenceValue = nonGroupTubeValue - groupTubeValue;
300 clippingArray->SetValue(k,tubeDifferenceValue);
303 vtkClipPolyData* clipper = vtkClipPolyData::New();
304 clipper->SetInputData(clippingInput);
306 clipper->GenerateClipScalarsOff();
310 if (clipper->GetOutput()->GetNumberOfPoints()==0)
316 vtkPolyData* clippedBranch = vtkPolyData::New();
317 clippedBranch->DeepCopy(clipper->GetOutput());
321 vtkPolyData* clippedOutputBranch = vtkPolyData::New();
322 clippedOutputBranch->DeepCopy(clipper->GetClippedOutput());
323 appendClippedOutput->AddInputData(clippedOutputBranch);
324 clippedOutputBranch->Delete();
327 groupIdsArray = vtkIntArray::New();
329 groupIdsArray->SetNumberOfTuples(clippedBranch->GetNumberOfPoints());
330 groupIdsArray->FillComponent(0,groupId);
332 clippedBranch->GetPointData()->AddArray(groupIdsArray);
333 appendBranches->AddInputData(clippedBranch);
334 groupIdsArray->Delete();
335 clippedBranch->Delete();
339 appendBranches->Update();
341 output->DeepCopy(appendBranches->GetOutput());
345 appendClippedOutput->Update();
347 appendClippedOutput->Delete();
350 clippingArray->Delete();
351 clippingInput->Delete();
352 appendBranches->Delete();
353 groupTubes->Delete();
354 nonGroupTubes->Delete();
355 groupTubesGroupIds->Delete();
356 nonGroupTubesGroupIds->Delete();
357 centerlineGroupIds->Delete();