79 vtkInformation *vtkNotUsed(request),
80 vtkInformationVector **inputVector,
81 vtkInformationVector *outputVector)
83 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
84 vtkInformation *outInfo = outputVector->GetInformationObject(0);
86 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
87 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
89 vtkPoints* inputPoints = input->GetPoints();
91 vtkIdType numberOfInputPoints = inputPoints->GetNumberOfPoints();
92 vtkIdType numberOfInputCells = input->GetNumberOfCells();
96 vtkErrorMacro(
"WarpVectors array name not specified.");
100 if (!input->GetPointData()->GetArray(this->WarpVectorsArrayName))
102 vtkErrorMacro(<<
"WarpVectors array with name specified does not exist!");
112 vtkErrorMacro(
"LayerThickness array name not specified.");
116 if (!input->GetPointData()->GetArray(this->LayerThicknessArrayName))
118 vtkErrorMacro(<<
"LayerThickness array with name specified does not exist!");
125 vtkPoints* outputPoints = vtkPoints::New();
126 vtkPoints* warpedPoints = vtkPoints::New();
128 vtkCellArray* boundaryLayerCellArray = vtkCellArray::New();
129 vtkIdList* boundaryLayerCellTypes = vtkIdList::New();
131 vtkIntArray *cellEntityIdsArray = NULL;
135 cellEntityIdsArray = vtkIntArray::New();
137 cellEntityIdsArray->SetNumberOfComponents(1);
143 cellType = input->GetCellType(0);
144 bool warpQuadratic =
false;
145 if (cellType == VTK_QUADRATIC_TRIANGLE)
147 warpQuadratic =
true;
150 vtkIdType numberOfLayerPoints = numberOfInputPoints;
153 numberOfLayerPoints = 2 * numberOfInputPoints;
156 outputPoints->SetNumberOfPoints(numberOfInputPoints + numberOfLayerPoints * this->
NumberOfSubLayers);
160 for (i=0; i<numberOfInputPoints; i++)
162 inputPoints->GetPoint(i,point);
163 outputPoints->SetPoint(i,point);
167 const vtkIdType *pts;
169 vtkIdType *surfacePts;
173 for (i=0; i<numberOfInputCells; i++)
175 input->GetCellPoints(i,npts,pts);
176 cellType = input->GetCellType(i);
177 surfacePts =
new vtkIdType[npts];
181 boundaryLayerCellTypes->InsertNextId(VTK_TRIANGLE);
182 surfacePts[0] = pts[0];
183 surfacePts[1] = pts[1];
184 surfacePts[2] = pts[2];
187 boundaryLayerCellTypes->InsertNextId(VTK_QUAD);
188 surfacePts[0] = pts[0];
189 surfacePts[1] = pts[1];
190 surfacePts[2] = pts[2];
191 surfacePts[3] = pts[3];
193 case VTK_QUADRATIC_TRIANGLE:
194 boundaryLayerCellTypes->InsertNextId(VTK_QUADRATIC_TRIANGLE);
195 surfacePts[0] = pts[0];
196 surfacePts[1] = pts[1];
197 surfacePts[2] = pts[2];
198 surfacePts[3] = pts[3];
199 surfacePts[4] = pts[4];
200 surfacePts[5] = pts[5];
203 vtkErrorMacro(<<
"Unsupported surface element.");
207 boundaryLayerCellArray->InsertNextCell(npts,surfacePts);
208 if (cellEntityIdsArray)
210 cellEntityIdsArray->InsertNextValue(currentSurfaceEntityId);
215 currentSurfaceEntityId++;
226 vtkPoints* innerSurfacePoints = vtkPoints::New();
227 this->
WarpPoints(inputPoints,innerSurfacePoints,this->NumberOfSubLayers-1,warpQuadratic);
228 this->
InnerSurface->GetPoints()->DeepCopy(innerSurfacePoints);
231 vtkDataArray *openProfilesIdsArray = NULL;
232 bool allocateArray =
false;
244 allocateArray = (openProfilesIdsArray == NULL);
248 openProfilesIdsArray = vtkIntArray::New();
249 openProfilesIdsArray->SetName(
"OpenProfilesIds");
250 openProfilesIdsArray->SetNumberOfComponents(1);
251 openProfilesIdsArray->SetNumberOfTuples(numberOfInputPoints);
252 openProfilesIdsArray->FillComponent(0, -1);
255 vtkGeometryFilter *meshToSurface = vtkGeometryFilter::New();
256 meshToSurface->SetInputData(input);
257 meshToSurface->MergingOff();
258 meshToSurface->Update();
262 openProfilesExtractor->SetInputData(meshToSurface->GetOutput());
263 openProfilesExtractor->Update();
266 vtkCellArray *openProfiles = openProfilesExtractor->GetOutput()->GetLines();
267 vtkDataArray *openProfilesScalars = openProfilesExtractor->GetOutput()->GetPointData()->GetScalars();
270 const vtkIdType *pts = NULL;
272 for (profileId=0, openProfiles->InitTraversal(); openProfiles->GetNextCell(npts,pts); profileId++)
274 for (
int i=0;i<npts;i++)
276 openProfilesIdsArray->SetComponent(openProfilesScalars->GetComponent(pts[i],0),0,profileId);
280 openProfilesExtractor->Delete();
281 meshToSurface->Delete();
289 for (k=0; k<this->NumberOfSubLayers; k++)
291 warpedPoints->Initialize();
292 this->
WarpPoints(inputPoints,warpedPoints,k,warpQuadratic);
294 for (i=0; i<numberOfLayerPoints; i++)
296 warpedPoints->GetPoint(i,point);
297 outputPoints->SetPoint(i + numberOfInputPoints + k*numberOfLayerPoints,point);
300 vtkIdType prismNPts, *prismPts;
301 vtkIdType nTetraPts = 0;
302 const vtkIdType *tetraPts = NULL;
304 for (i=0; i<numberOfInputCells; i++)
306 input->GetCellPoints(i,npts,pts);
307 cellType = input->GetCellType(i);
308 if (cellType == VTK_TRIANGLE || cellType == VTK_QUAD)
310 prismNPts = npts * 2;
311 prismPts =
new vtkIdType[prismNPts];
313 for (j=0; j<npts; j++)
315 prismPts[j] = pts[j] + k*numberOfLayerPoints;
317 for (j=0; j<npts; j++)
319 prismPts[j+npts] = pts[j] + (k+1)*numberOfLayerPoints;
324 double pCoordsWedge[] = {0.0,0.0,0.0, 1.0,0.0,0.0, 0.0,1.0,0.0,
325 0.0,0.0,1.0, 1.0,0.0,1.0, 0.0,1.0,1.0};
327 double pCoordsHex[] = {0.0,0.0,0.0, 1.0,0.0,0.0,
328 1.0,1.0,0.0, 0.0,1.0,0.0,
329 0.0,0.0,1.0, 1.0,0.0,1.0,
330 1.0,1.0,1.0, 0.0,1.0,1.0};
331 double *pCoords = NULL;
335 if (cellType == VTK_TRIANGLE)
337 prismType = VTK_WEDGE;
338 pCoords = pCoordsWedge;
341 else if (cellType == VTK_QUAD)
343 prismType = VTK_HEXAHEDRON;
344 pCoords = pCoordsHex;
348 this->
Triangulator->InitTriangulation(0.0,1.0, 0.0,1.0, 0.0,1.0, prismNPts);
352 for (p=pCoords, j=0; j<prismNPts; j++, p+=3)
354 outputPoints->GetPoint(prismPts[j], prismPt);
355 this->
Triangulator->InsertPoint(prismPts[j], prismPt, p, 0);
358 this->
Triangulator->TemplateTriangulate(prismType, prismNPts, prismNEdges);
361 vtkIdType tetraStartId = boundaryLayerCellArray->GetNumberOfCells();
363 vtkIdType numTets = this->
Triangulator->AddTetras(0,boundaryLayerCellArray);
365 for (j=0; j<numTets; j++)
367 boundaryLayerCellTypes->InsertNextId(VTK_TETRA);
368 if (cellEntityIdsArray)
376 if (openProfilesIdsArray)
381 if ((openProfilesIdsArray->GetComponent(pts[j],0) != -1) && (openProfilesIdsArray->GetComponent(pts[(j+1)%npts],0) != -1))
384 vtkIdList *openProfilePts = vtkIdList::New();
385 openProfilePts->InsertNextId(prismPts[j]);
386 openProfilePts->InsertNextId(prismPts[(j+1)%npts]);
387 openProfilePts->InsertNextId(prismPts[j+npts]);
388 openProfilePts->InsertNextId(prismPts[(j+1)%npts + npts]);
390 vtkIdList *tetraPtsList = vtkIdList::New();
392 for (
int k=0; k<numTets; k++)
394 boundaryLayerCellArray->GetCellAtId(tetraStartId + k, nTetraPts, tetraPts);
395 tetraPtsList->Initialize();
396 for (
int l=0; l<nTetraPts; l++)
398 tetraPtsList->InsertNextId(tetraPts[l]);
400 tetraPtsList->IntersectWith(openProfilePts);
402 if (tetraPtsList->GetNumberOfIds() == 3)
404 boundaryLayerCellArray->InsertNextCell(tetraPtsList);
405 boundaryLayerCellTypes->InsertNextId(VTK_TRIANGLE);
406 if (cellEntityIdsArray)
408 cellEntityIdsArray->InsertNextValue(this->
OpenProfilesEntityId + openProfilesIdsArray->GetComponent(pts[j],0));
412 tetraPtsList->Delete();
413 openProfilePts->Delete();
460 vtkErrorMacro(<<
"Unsupported surface element.");
468 openProfilesIdsArray->Delete();
474 for (i=0; i<numberOfInputCells; i++)
476 input->GetCellPoints(i,npts,pts);
477 cellType = input->GetCellType(i);
478 surfacePts =
new vtkIdType[npts];
482 boundaryLayerCellTypes->InsertNextId(VTK_TRIANGLE);
483 surfacePts[0] = pts[0] + this->NumberOfSubLayers*numberOfLayerPoints;
484 surfacePts[1] = pts[1] + this->NumberOfSubLayers*numberOfLayerPoints;
485 surfacePts[2] = pts[2] + this->NumberOfSubLayers*numberOfLayerPoints;
488 boundaryLayerCellTypes->InsertNextId(VTK_QUAD);
489 surfacePts[0] = pts[0] + this->NumberOfSubLayers*numberOfLayerPoints;
490 surfacePts[1] = pts[1] + this->NumberOfSubLayers*numberOfLayerPoints;
491 surfacePts[2] = pts[2] + this->NumberOfSubLayers*numberOfLayerPoints;
492 surfacePts[3] = pts[3] + this->NumberOfSubLayers*numberOfLayerPoints;
494 case VTK_QUADRATIC_TRIANGLE:
495 boundaryLayerCellTypes->InsertNextId(VTK_QUADRATIC_TRIANGLE);
496 surfacePts[0] = pts[0] + this->NumberOfSubLayers*numberOfLayerPoints;
497 surfacePts[1] = pts[1] + this->NumberOfSubLayers*numberOfLayerPoints;
498 surfacePts[2] = pts[2] + this->NumberOfSubLayers*numberOfLayerPoints;
499 surfacePts[3] = pts[3] + this->NumberOfSubLayers*numberOfLayerPoints;
500 surfacePts[4] = pts[4] + this->NumberOfSubLayers*numberOfLayerPoints;
501 surfacePts[5] = pts[5] + this->NumberOfSubLayers*numberOfLayerPoints;
504 vtkErrorMacro(<<
"Unsupported surface element.");
508 boundaryLayerCellArray->InsertNextCell(npts,surfacePts);
509 if (cellEntityIdsArray) cellEntityIdsArray->InsertNextValue(currentSurfaceEntityId);
514 output->SetPoints(outputPoints);
516 int* boundaryLayerCellTypesInt =
new int[boundaryLayerCellTypes->GetNumberOfIds()];
517 for (i=0; i<boundaryLayerCellTypes->GetNumberOfIds(); i++)
519 boundaryLayerCellTypesInt[i] = boundaryLayerCellTypes->GetId(i);
522 output->SetCells(boundaryLayerCellTypesInt,boundaryLayerCellArray);
524 delete[] boundaryLayerCellTypesInt;
526 if (cellEntityIdsArray)
528 output->GetCellData()->AddArray(cellEntityIdsArray);
529 cellEntityIdsArray->Delete();
532 outputPoints->Delete();
533 warpedPoints->Delete();
534 boundaryLayerCellArray->Delete();
535 boundaryLayerCellTypes->Delete();
536 innerSurfacePoints->Delete();