84 vtkInformation *vtkNotUsed(request),
85 vtkInformationVector **inputVector,
86 vtkInformationVector *outputVector)
88 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
89 vtkInformation *outInfo = outputVector->GetInformationObject(0);
91 vtkPolyData *input = vtkPolyData::SafeDownCast(
92 inInfo->Get(vtkDataObject::DATA_OBJECT()));
93 vtkPolyData *output = vtkPolyData::SafeDownCast(
94 outInfo->Get(vtkDataObject::DATA_OBJECT()));
97 vtkIdType barycenterId, trianglePoints[3];
100 vtkPolyData* boundaries;
101 vtkPoints* newPoints;
102 vtkCellArray* newPolys;
103 vtkPolyLine* boundary;
106 if ( ((input->GetNumberOfPoints()) < 1) )
114 newPoints = vtkPoints::New();
115 newPoints->DeepCopy(input->GetPoints());
116 newPolys = vtkCellArray::New();
117 newPolys->DeepCopy(input->GetPolys());
121 vtkIdTypeArray* cellEntityIdsArray = NULL;
125 cellEntityIdsArray = vtkIdTypeArray::New();
126 cellEntityIdsArray->SetName(this->CellEntityIdsArrayName);
127 if (input->GetCellData()->GetArray(this->CellEntityIdsArrayName))
129 cellEntityIdsArray->DeepCopy(input->GetCellData()->GetArray(this->CellEntityIdsArrayName));
133 cellEntityIdsArray->SetNumberOfTuples(newPolys->GetNumberOfCells());
142 vtkNew<vtkPolyData> labeledBoundaries;
143 vtkNew<vtkIdList> boundaryLabels;
145 bool useBoundaryLabels =
false;
151 labeledBoundaries,boundaryLabels);
152 if (useBoundaryLabels)
154 boundaries = labeledBoundaries;
158 vtkWarningMacro(<<
"The boundary label arrays are missing from the input surface or no longer describe it; "
159 <<
"extracting its boundaries instead, and naming the caps by position.");
164 boundaryExtractor->SetInputData(input);
165 boundaryExtractor->Update();
166 boundaries = boundaryExtractor->GetOutput();
173 for (vtkIdType boundaryIndex=0; boundaryIndex<boundaries->GetNumberOfCells(); boundaryIndex++)
175 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(boundaryIndex) : boundaryIndex;
178 vtkWarningMacro(<<
"BoundaryCellEntityIds has no entry for the boundary with id "<<boundaryId
179 <<
"; its cap takes the id its position gives it.");
191 this->
CapCenterIds->SetNumberOfIds(boundaries->GetNumberOfCells());
197 double barycenter[3], normal[3], outwardNormal[3], meanRadius;
199 for (i=0; i<boundaries->GetNumberOfCells(); i++)
205 if (this->
BoundaryIds->IsId(useBoundaryLabels ? boundaryLabels->GetId(i) : i) == -1)
210 boundary = vtkPolyLine::SafeDownCast(boundaries->GetCell(i));
219 barycenter[j] += meanRadius * this->
Displacement * outwardNormal[j];
222 double inplane1[3], inplane2[3];
223 vtkMath::Perpendiculars(outwardNormal,inplane1,inplane2,0.0);
229 barycenterId = newPoints->InsertNextPoint(barycenter);
232 vtkIdType numberOfBoundaryPoints = boundary->GetNumberOfPoints();
233 for (j=0; j<numberOfBoundaryPoints; j++)
235 trianglePoints[0] =
static_cast<vtkIdType
>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundary->GetPointId(j)));
236 trianglePoints[1] = barycenterId;
237 trianglePoints[2] =
static_cast<vtkIdType
>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundary->GetPointId((j+1)%numberOfBoundaryPoints)));
239 newPolys->InsertNextCell(3,trianglePoints);
250 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(i) : i;
251 vtkIdType capCellEntityId = useBoundaryLabels ? boundaryId : i+1+this->
CellEntityIdOffset;
254 && this->BoundaryCellEntityIds->GetValue(boundaryId) >= 0)
258 cellEntityIdsArray->InsertNextValue(capCellEntityId);
264 output->SetPoints(newPoints);
265 output->SetPolys(newPolys);
269 output->GetCellData()->AddArray(cellEntityIdsArray);
270 cellEntityIdsArray->Delete();
273 if (useBoundaryLabels)
280 vtkIdType numberOfInputPoints = input->GetNumberOfPoints();
281 vtkIdType numberOfOutputPoints = newPoints->GetNumberOfPoints();
286 vtkNew<vtkIntArray> outputLabels;
288 outputLabels->SetNumberOfTuples(numberOfOutputPoints);
289 outputLabels->FillComponent(0,
static_cast<double>(invalidLabel));
291 vtkNew<vtkIntArray> outputOrder;
293 outputOrder->SetNumberOfTuples(numberOfOutputPoints);
294 outputOrder->FillComponent(0,
static_cast<double>(invalidLabel));
296 for (vtkIdType pointId=0; pointId<numberOfInputPoints; pointId++)
298 outputLabels->SetValue(pointId,
static_cast<int>(vtkMath::Round(inputLabels->GetComponent(pointId,0))));
299 outputOrder->SetValue(pointId,
static_cast<int>(vtkMath::Round(inputOrder->GetComponent(pointId,0))));
302 output->GetPointData()->AddArray(outputLabels);
303 output->GetPointData()->AddArray(outputOrder);
312 boundaryExtractor->Delete();