112 vtkInformation *vtkNotUsed(request),
113 vtkInformationVector **inputVector,
114 vtkInformationVector *outputVector)
116 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
117 vtkInformation *outInfo = outputVector->GetInformationObject(0);
119 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
120 inInfo->Get(vtkDataObject::DATA_OBJECT()));
121 vtkUnstructuredGrid *output = vtkUnstructuredGrid::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();
219 int numberOfPoints = input->GetNumberOfPoints();
221 const char clippingArrayName[] =
"ClippingArray";
223 vtkDoubleArray* clippingArray = vtkDoubleArray::New();
224 clippingArray->SetNumberOfComponents(1);
225 clippingArray->SetNumberOfTuples(numberOfPoints);
226 clippingArray->FillComponent(0,0.0);
227 clippingArray->SetName(clippingArrayName);
229 vtkUnstructuredGrid* clippingInput = vtkUnstructuredGrid::New();
230 clippingInput->DeepCopy(input);
231 clippingInput->GetPointData()->AddArray(clippingArray);
232 clippingInput->GetPointData()->SetActiveScalars(clippingArrayName);
234 vtkIdList* groupTubesGroupIds = vtkIdList::New();
235 vtkIdList* nonGroupTubesGroupIds = vtkIdList::New();
238 double groupTubeValue, nonGroupTubeValue, tubeDifferenceValue;
242 vtkIdList* centerlineGroupIds = vtkIdList::New();
247 for (i=0; i<centerlineGroupIdsArray->GetNumberOfTuples(); i++)
249 if (blankingArray->GetValue(i) == 1)
253 centerlineGroupIds->InsertUniqueId(
static_cast<vtkIdType
>(vtkMath::Round(centerlineGroupIdsArray->GetComponent(i,0))));
261 for (i=0; i<centerlineGroupIds->GetNumberOfIds(); i++)
263 groupId = centerlineGroupIds->GetId(i);
265 groupTubesGroupIds->Initialize();
266 nonGroupTubesGroupIds->Initialize();
268 for (
int j=0; j<this->
Centerlines->GetNumberOfCells(); j++)
270 if (blankingArray->GetValue(j) == 1)
274 if (
static_cast<vtkIdType
>(vtkMath::Round(centerlineGroupIdsArray->GetComponent(j,0))) == groupId)
276 groupTubesGroupIds->InsertNextId(j);
280 nonGroupTubesGroupIds->InsertNextId(j);
284 if ((groupTubesGroupIds->GetNumberOfIds() == 0) || (nonGroupTubesGroupIds->GetNumberOfIds() == 0))
292 for (
int k=0; k<numberOfPoints; k++)
294 input->GetPoint(k,point);
301 tubeDifferenceValue = nonGroupTubeValue - groupTubeValue;
302 clippingArray->SetValue(k,tubeDifferenceValue);
305 vtkClipDataSet* clipper = vtkClipDataSet::New();
306 clipper->SetInputData(clippingInput);
308 clipper->GenerateClipScalarsOff();
312 if (clipper->GetOutput()->GetNumberOfPoints()==0)
318 vtkUnstructuredGrid* clippedBranch = vtkUnstructuredGrid::New();
319 clippedBranch->DeepCopy(clipper->GetOutput());
323 vtkUnstructuredGrid* clippedOutputBranch = vtkUnstructuredGrid::New();
324 clippedOutputBranch->DeepCopy(clipper->GetClippedOutput());
325 appendClippedOutput->AddInputData(clippedOutputBranch);
326 clippedOutputBranch->Delete();
329 groupIdsArray = vtkIntArray::New();
331 groupIdsArray->SetNumberOfTuples(clippedBranch->GetNumberOfPoints());
332 groupIdsArray->FillComponent(0,groupId);
334 clippedBranch->GetPointData()->AddArray(groupIdsArray);
335 appendBranches->AddInputData(clippedBranch);
336 groupIdsArray->Delete();
337 clippedBranch->Delete();
341 appendBranches->Update();
343 output->DeepCopy(appendBranches->GetOutput());
347 appendClippedOutput->Update();
349 appendClippedOutput->Delete();
352 clippingArray->Delete();
353 clippingInput->Delete();
354 appendBranches->Delete();
355 groupTubes->Delete();
356 nonGroupTubes->Delete();
357 groupTubesGroupIds->Delete();
358 nonGroupTubesGroupIds->Delete();
359 centerlineGroupIds->Delete();