115{
116 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
117 vtkInformation *outInfo = outputVector->GetInformationObject(0);
118
119 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
120 inInfo->Get(vtkDataObject::DATA_OBJECT()));
121 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
122 outInfo->Get(vtkDataObject::DATA_OBJECT()));
123
124 vtkDataArray* centerlineGroupIdsArray;
125 vtkIntArray* blankingArray;
126 vtkIntArray* groupIdsArray;
127
129 {
130 vtkErrorMacro(<< "Centerlines not set.");
131 return 1;
132 }
133
135 {
136 vtkErrorMacro(<< "CenterlineGroupIds not set.");
137 return 1;
138 }
139
141 {
142 vtkErrorMacro(<< "CenterlineGroupIdsArrayName not set.");
143 return 1;
144 }
145
147 {
148 vtkErrorMacro(<< "GroupIdsArrayName not set.");
149 return 1;
150 }
151
153
154 if (!centerlineGroupIdsArray)
155 {
156 vtkErrorMacro(<< "CenterlineGroupIdsArray with name specified does not exist");
157 return 1;
158 }
159
161 {
162 vtkErrorMacro(<< "BlankingArrayName not set.");
163 return 1;
164 }
165
166 blankingArray = vtkIntArray::SafeDownCast(this->
Centerlines->GetCellData()->GetArray(this->BlankingArrayName));
167
168 if (!blankingArray)
169 {
170 vtkErrorMacro(<< "BlankingArrayName with name specified does not exist");
171 return 1;
172 }
173
175 {
176 vtkErrorMacro(<< "CenterlineRadiusArrayName not set.");
177 return 1;
178 }
179
180 if (!this->
Centerlines->GetPointData()->GetArray(this->CenterlineRadiusArrayName))
181 {
182 vtkErrorMacro(<< "CenterlineRadiusArray with name specified does not exist");
183 return 1;
184 }
185
187 {
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();
195 return 1;
196 }
197
200 vtkvmtkAppendFilter* appendClippedOutput = NULL;
202 {
205 }
206
207
208
213
218
219 int numberOfPoints = input->GetNumberOfPoints();
220
221 const char clippingArrayName[] = "ClippingArray";
222
223 vtkDoubleArray* clippingArray = vtkDoubleArray::New();
224 clippingArray->SetNumberOfComponents(1);
225 clippingArray->SetNumberOfTuples(numberOfPoints);
226 clippingArray->FillComponent(0,0.0);
227 clippingArray->SetName(clippingArrayName);
228
229 vtkUnstructuredGrid* clippingInput = vtkUnstructuredGrid::New();
230 clippingInput->DeepCopy(input);
231 clippingInput->GetPointData()->AddArray(clippingArray);
232 clippingInput->GetPointData()->SetActiveScalars(clippingArrayName);
233
234 vtkIdList* groupTubesGroupIds = vtkIdList::New();
235 vtkIdList* nonGroupTubesGroupIds = vtkIdList::New();
236
237 double point[3];
238 double groupTubeValue, nonGroupTubeValue, tubeDifferenceValue;
239
240 vtkIdType groupId;
241
242 vtkIdList* centerlineGroupIds = vtkIdList::New();
243
244 int i;
246 {
247 for (i=0; i<centerlineGroupIdsArray->GetNumberOfTuples(); i++)
248 {
249 if (blankingArray->GetValue(i) == 1)
250 {
251 continue;
252 }
253 centerlineGroupIds->InsertUniqueId(static_cast<vtkIdType>(vtkMath::Round(centerlineGroupIdsArray->GetComponent(i,0))));
254 }
255 }
256 else
257 {
259 }
260
261 for (i=0; i<centerlineGroupIds->GetNumberOfIds(); i++)
262 {
263 groupId = centerlineGroupIds->GetId(i);
264
265 groupTubesGroupIds->Initialize();
266 nonGroupTubesGroupIds->Initialize();
267
268 for (
int j=0; j<this->
Centerlines->GetNumberOfCells(); j++)
269 {
270 if (blankingArray->GetValue(j) == 1)
271 {
272 continue;
273 }
274 if (static_cast<vtkIdType>(vtkMath::Round(centerlineGroupIdsArray->GetComponent(j,0))) == groupId)
275 {
276 groupTubesGroupIds->InsertNextId(j);
277 }
278 else
279 {
280 nonGroupTubesGroupIds->InsertNextId(j);
281 }
282 }
283
284 if ((groupTubesGroupIds->GetNumberOfIds() == 0) || (nonGroupTubesGroupIds->GetNumberOfIds() == 0))
285 {
286 continue;
287 }
288
291
292 for (int k=0; k<numberOfPoints; k++)
293 {
294 input->GetPoint(k,point);
297 {
299 }
301 tubeDifferenceValue = nonGroupTubeValue - groupTubeValue;
302 clippingArray->SetValue(k,tubeDifferenceValue);
303 }
304
305 vtkClipDataSet* clipper = vtkClipDataSet::New();
306 clipper->SetInputData(clippingInput);
308 clipper->GenerateClipScalarsOff();
310 clipper->Update();
311
312 if (clipper->GetOutput()->GetNumberOfPoints()==0)
313 {
314 clipper->Delete();
315 continue;
316 }
317
318 vtkUnstructuredGrid* clippedBranch = vtkUnstructuredGrid::New();
319 clippedBranch->DeepCopy(clipper->GetOutput());
320
322 {
323 vtkUnstructuredGrid* clippedOutputBranch = vtkUnstructuredGrid::New();
324 clippedOutputBranch->DeepCopy(clipper->GetClippedOutput());
325 appendClippedOutput->AddInputData(clippedOutputBranch);
326 clippedOutputBranch->Delete();
327 }
328
329 groupIdsArray = vtkIntArray::New();
331 groupIdsArray->SetNumberOfTuples(clippedBranch->GetNumberOfPoints());
332 groupIdsArray->FillComponent(0,groupId);
333
334 clippedBranch->GetPointData()->AddArray(groupIdsArray);
335 appendBranches->AddInputData(clippedBranch);
336 groupIdsArray->Delete();
337 clippedBranch->Delete();
338 clipper->Delete();
339 }
340
341 appendBranches->Update();
342
343 output->DeepCopy(appendBranches->GetOutput());
344
346 {
347 appendClippedOutput->Update();
349 appendClippedOutput->Delete();
350 }
351
352 clippingArray->Delete();
353 clippingInput->Delete();
354 appendBranches->Delete();
355 groupTubes->Delete();
356 nonGroupTubes->Delete();
357 groupTubesGroupIds->Delete();
358 nonGroupTubesGroupIds->Delete();
359 centerlineGroupIds->Delete();
360
361 return 1;
362}
static vtkvmtkAppendFilter * New()
virtual void MergeDuplicatePointsOff()
virtual void SetInput(vtkPolyData *)
virtual void SetPolyBallRadiusArrayName(const char *)
virtual void SetInputCellIds(vtkIdList *)
virtual void SetUseRadiusInformation(int)
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
vtkUnstructuredGrid * GetClippedOutput()