VMTK
Loading...
Searching...
No Matches
vtkvmtkConcaveAnnularCapPolyData Class Reference

Add annular caps between the boundaries of a walled surface. More...

#include <vtkvmtkConcaveAnnularCapPolyData.h>

Inheritance diagram for vtkvmtkConcaveAnnularCapPolyData:
[legend]
Collaboration diagram for vtkvmtkConcaveAnnularCapPolyData:
[legend]

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkConcaveAnnularCapPolyData * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetBoundaryIds (vtkIdList *)
virtual vtkIdList * GetBoundaryIds ()
virtual void SetCellEntityIdsArrayName (const char *)
virtual char * GetCellEntityIdsArrayName ()
virtual void SetCellEntityIdOffset (int)
virtual int GetCellEntityIdOffset ()
virtual void SetBoundaryLabelsArrayName (const char *)
virtual char * GetBoundaryLabelsArrayName ()
virtual void SetBoundaryPointOrderArrayName (const char *)
virtual char * GetBoundaryPointOrderArrayName ()
virtual void SetBoundaryCellEntityIds (vtkIdTypeArray *)
virtual vtkIdTypeArray * GetBoundaryCellEntityIds ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkConcaveAnnularCapPolyData * SafeDownCast (vtkObjectBase *o)
static vtkvmtkConcaveAnnularCapPolyData * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkConcaveAnnularCapPolyData ()
 ~vtkvmtkConcaveAnnularCapPolyData ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkIdType PairCapCellEntityId (vtkIdType positionalId, vtkIdType boundaryId, vtkIdType partnerBoundaryId, bool useBoundaryLabels)

Protected Attributes

vtkIdList * BoundaryIds
char * BoundaryLabelsArrayName
char * BoundaryPointOrderArrayName
vtkIdTypeArray * BoundaryCellEntityIds
char * CellEntityIdsArrayName
int CellEntityIdOffset

Detailed Description

Add annular caps between the boundaries of a walled surface.

This class closes the boundaries between the surfaces of a walled surface with caps. The surfaces are required to be dense for the algorithm to produce legal caps.

Unlike vtkvmtkAnnularCapPolyData, boundaries are not required to be paired in input order: each open boundary is automatically paired with its geometrically closest remaining boundary (by barycenter distance), and the (possibly concave/non-convex) annular region between each pair is triangulated directly, without an intermediate flattening step.

See also
vtkvmtkAnnularCapPolyData

Definition at line 46 of file vtkvmtkConcaveAnnularCapPolyData.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkConcaveAnnularCapPolyData::Superclass

Definition at line 49 of file vtkvmtkConcaveAnnularCapPolyData.h.

Constructor & Destructor Documentation

◆ vtkvmtkConcaveAnnularCapPolyData()

◆ ~vtkvmtkConcaveAnnularCapPolyData()

vtkvmtkConcaveAnnularCapPolyData::~vtkvmtkConcaveAnnularCapPolyData ( )
protected

Definition at line 81 of file vtkvmtkConcaveAnnularCapPolyData.cxx.

82{
83 if (this->CellEntityIdsArrayName)
84 {
85 delete[] this->CellEntityIdsArrayName;
86 this->CellEntityIdsArrayName = NULL;
87 }
88 if (this->BoundaryIds)
89 {
90 this->BoundaryIds->Delete();
91 this->BoundaryIds = NULL;
92 }
93
96
97 if (this->BoundaryCellEntityIds)
98 {
99 this->BoundaryCellEntityIds->Delete();
100 this->BoundaryCellEntityIds = NULL;
101 }
102}
virtual void SetBoundaryLabelsArrayName(const char *)
virtual void SetBoundaryPointOrderArrayName(const char *)

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkConcaveAnnularCapPolyData::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkConcaveAnnularCapPolyData::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkConcaveAnnularCapPolyData * vtkvmtkConcaveAnnularCapPolyData::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkConcaveAnnularCapPolyData::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkConcaveAnnularCapPolyData * vtkvmtkConcaveAnnularCapPolyData::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkConcaveAnnularCapPolyData::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 523 of file vtkvmtkConcaveAnnularCapPolyData.cxx.

524{
525 this->Superclass::PrintSelf(os,indent);
526}

◆ New()

vtkvmtkConcaveAnnularCapPolyData * vtkvmtkConcaveAnnularCapPolyData::New ( )
static

◆ SetBoundaryIds()

virtual void vtkvmtkConcaveAnnularCapPolyData::SetBoundaryIds ( vtkIdList * )
virtual

Set/get the (even-sized) subset of boundary indices to pair up and cap, restricting which boundaries are considered by the closest- barycenter pairing. If NULL (default), all boundaries of the input surface are considered and must number an even count.

◆ GetBoundaryIds()

virtual vtkIdList * vtkvmtkConcaveAnnularCapPolyData::GetBoundaryIds ( )
virtual

Set/get the (even-sized) subset of boundary indices to pair up and cap, restricting which boundaries are considered by the closest- barycenter pairing. If NULL (default), all boundaries of the input surface are considered and must number an even count.

◆ SetCellEntityIdsArrayName()

virtual void vtkvmtkConcaveAnnularCapPolyData::SetCellEntityIdsArrayName ( const char * )
virtual

Set/get the name of the cell data array used to tag the newly created cap triangles with an integer id, one distinct value per boundary pairing (the pairing index, starting from 1, plus CellEntityIdOffset). If the array already exists on the input, existing cell values are preserved and only the new cap cells are appended with the new tag. If left NULL (default), no cell entity id array is created. Commonly named "CellEntityIds".

◆ GetCellEntityIdsArrayName()

virtual char * vtkvmtkConcaveAnnularCapPolyData::GetCellEntityIdsArrayName ( )
virtual

Set/get the name of the cell data array used to tag the newly created cap triangles with an integer id, one distinct value per boundary pairing (the pairing index, starting from 1, plus CellEntityIdOffset). If the array already exists on the input, existing cell values are preserved and only the new cap cells are appended with the new tag. If left NULL (default), no cell entity id array is created. Commonly named "CellEntityIds".

◆ SetCellEntityIdOffset()

virtual void vtkvmtkConcaveAnnularCapPolyData::SetCellEntityIdOffset ( int )
virtual

Set/get the base offset added to the ids written into CellEntityIdsArrayName. The id assigned to the cap of the i-th boundary pairing is (i + 1 + CellEntityIdOffset). Default: 1.

◆ GetCellEntityIdOffset()

virtual int vtkvmtkConcaveAnnularCapPolyData::GetCellEntityIdOffset ( )
virtual

Set/get the base offset added to the ids written into CellEntityIdsArrayName. The id assigned to the cap of the i-th boundary pairing is (i + 1 + CellEntityIdOffset). Default: 1.

◆ SetBoundaryLabelsArrayName()

virtual void vtkvmtkConcaveAnnularCapPolyData::SetBoundaryLabelsArrayName ( const char * )
virtual

Set/Get the names of the point data arrays that carry the boundary labels of the input, as written by vtkvmtkPolyDataBoundaryLabeler. When both are set and the input carries arrays that still describe it, the boundaries are read from them instead of being extracted, and the cap of each pair can be named through BoundaryCellEntityIds. With the labels in use a boundary's id is its label, and without them it is its position in the extraction order. * A label is not merely a name this filter turns into an id: it is the id. The labeler numbers the boundaries of a surface from CellEntityIdOffset+1 up, which is where this filter would have numbered their caps anyway, so the cap of a labeled boundary carries its label unchanged and a labeled surface is capped exactly as an unlabeled one is.

◆ GetBoundaryLabelsArrayName()

virtual char * vtkvmtkConcaveAnnularCapPolyData::GetBoundaryLabelsArrayName ( )
virtual

Set/Get the names of the point data arrays that carry the boundary labels of the input, as written by vtkvmtkPolyDataBoundaryLabeler. When both are set and the input carries arrays that still describe it, the boundaries are read from them instead of being extracted, and the cap of each pair can be named through BoundaryCellEntityIds. With the labels in use a boundary's id is its label, and without them it is its position in the extraction order. * A label is not merely a name this filter turns into an id: it is the id. The labeler numbers the boundaries of a surface from CellEntityIdOffset+1 up, which is where this filter would have numbered their caps anyway, so the cap of a labeled boundary carries its label unchanged and a labeled surface is capped exactly as an unlabeled one is.

◆ SetBoundaryPointOrderArrayName()

virtual void vtkvmtkConcaveAnnularCapPolyData::SetBoundaryPointOrderArrayName ( const char * )
virtual

Set/Get the names of the point data arrays that carry the boundary labels of the input, as written by vtkvmtkPolyDataBoundaryLabeler. When both are set and the input carries arrays that still describe it, the boundaries are read from them instead of being extracted, and the cap of each pair can be named through BoundaryCellEntityIds. With the labels in use a boundary's id is its label, and without them it is its position in the extraction order. * A label is not merely a name this filter turns into an id: it is the id. The labeler numbers the boundaries of a surface from CellEntityIdOffset+1 up, which is where this filter would have numbered their caps anyway, so the cap of a labeled boundary carries its label unchanged and a labeled surface is capped exactly as an unlabeled one is.

◆ GetBoundaryPointOrderArrayName()

virtual char * vtkvmtkConcaveAnnularCapPolyData::GetBoundaryPointOrderArrayName ( )
virtual

Set/Get the names of the point data arrays that carry the boundary labels of the input, as written by vtkvmtkPolyDataBoundaryLabeler. When both are set and the input carries arrays that still describe it, the boundaries are read from them instead of being extracted, and the cap of each pair can be named through BoundaryCellEntityIds. With the labels in use a boundary's id is its label, and without them it is its position in the extraction order. * A label is not merely a name this filter turns into an id: it is the id. The labeler numbers the boundaries of a surface from CellEntityIdOffset+1 up, which is where this filter would have numbered their caps anyway, so the cap of a labeled boundary carries its label unchanged and a labeled surface is capped exactly as an unlabeled one is.

◆ SetBoundaryCellEntityIds()

virtual void vtkvmtkConcaveAnnularCapPolyData::SetBoundaryCellEntityIds ( vtkIdTypeArray * )
virtual

Set/Get the id to write into CellEntityIdsArrayName for the cap of each boundary pair, indexed by boundary id (see BoundaryLabelsArrayName).

A cap closes a pair of boundaries, so it takes whichever of the two has an entry, and when both do and they disagree it takes the one of the lower boundary id and says so. Labelling the surface with vtkvmtkPolyDataBoundaryLabeler in its Annular mode makes the lower of a pair the inner boundary every time.

◆ GetBoundaryCellEntityIds()

virtual vtkIdTypeArray * vtkvmtkConcaveAnnularCapPolyData::GetBoundaryCellEntityIds ( )
virtual

Set/Get the id to write into CellEntityIdsArrayName for the cap of each boundary pair, indexed by boundary id (see BoundaryLabelsArrayName).

A cap closes a pair of boundaries, so it takes whichever of the two has an entry, and when both do and they disagree it takes the one of the lower boundary id and says so. Labelling the surface with vtkvmtkPolyDataBoundaryLabeler in its Annular mode makes the lower of a pair the inner boundary every time.

◆ RequestData()

int vtkvmtkConcaveAnnularCapPolyData::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 209 of file vtkvmtkConcaveAnnularCapPolyData.cxx.

213{
214 // Administrative data type wrestling
215 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
216 vtkInformation *outInfo = outputVector->GetInformationObject(0);
217
218 vtkPolyData *input = vtkPolyData::SafeDownCast(
219 inInfo->Get(vtkDataObject::DATA_OBJECT()));
220 vtkPolyData *output = vtkPolyData::SafeDownCast(
221 outInfo->Get(vtkDataObject::DATA_OBJECT()));
222
223 // Minimal check that we get at least some data
224 if ( input->GetNumberOfPoints() < 6 )
225 {
226 vtkErrorMacro(<< "Error: too few input points.");
227 return 1;
228 }
229 input->BuildLinks();
230
231 // Allocate output objects
232 vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New();
233 newPoints->DeepCopy(input->GetPoints());
234 vtkSmartPointer<vtkCellArray> newPolys = vtkSmartPointer<vtkCellArray>::New();
235 newPolys->DeepCopy(input->GetPolys());
236
237 // Mark cells if we have a nonempty name
238 bool markCells = this->CellEntityIdsArrayName && this->CellEntityIdsArrayName[0];
239 vtkSmartPointer<vtkIntArray> cellEntityIdsArray;
240 if (markCells)
241 {
242 cellEntityIdsArray = vtkSmartPointer<vtkIntArray>::New();
243 cellEntityIdsArray->SetName(this->CellEntityIdsArrayName);
244 if (input->GetCellData()->GetArray(this->CellEntityIdsArrayName))
245 {
246 cellEntityIdsArray->DeepCopy(input->GetCellData()->GetArray(this->CellEntityIdsArrayName));
247 }
248 else
249 {
250 cellEntityIdsArray->SetNumberOfTuples(newPolys->GetNumberOfCells());
251 cellEntityIdsArray->FillComponent(0,static_cast<double>(this->CellEntityIdOffset));
252 }
253 }
254
255 // Extract all boundaries (polylines) from input mesh
256 info("Finding boundaries of input surface...");
257 // The boundaries either come from the labels the input already carries, which are the same
258 // boundaries in the same order every other filter reading those labels sees, or they are
259 // extracted here as they always were.
260 vtkNew<vtkPolyData> boundariesData;
261 vtkNew<vtkIdList> boundaryLabels;
262 bool useBoundaryLabels = vtkvmtkBoundaryLabels::GetOrExtractBoundaries(
263 input,this->BoundaryLabelsArrayName,this->BoundaryPointOrderArrayName,boundariesData,boundaryLabels,this);
264 vtkPolyData* boundaries = boundariesData;
265
266 int numberOfBoundaries = boundaries->GetNumberOfCells();
267 std::cout << "Found " << numberOfBoundaries << " boundaries." << std::endl;
268
269 // Compute barycenters for all boundaries
270 info("Computing boundary barycenters...");
271 vtkSmartPointer<vtkPoints> barycenters = vtkSmartPointer<vtkPoints>::New();
272 barycenters->SetNumberOfPoints(numberOfBoundaries);
273 for (int i=0; i<numberOfBoundaries; i++)
274 {
275 double barycenter[3];
276 vtkvmtkBoundaryReferenceSystems::ComputeBoundaryBarycenter(boundaries->GetCell(i)->GetPoints(), barycenter);
277 barycenters->SetPoint(i, barycenter);
278 }
279
280 // Build pairs of boundaries from closest barycenter pairs, limited to list of input ids if any
281 info("Pairing boundaries...");
282 if ( (this->BoundaryIds && this->BoundaryIds->GetNumberOfIds() % 2)
283 || (!this->BoundaryIds && numberOfBoundaries % 2) )
284 {
285 vtkErrorMacro(<< "Error: the number of boundaries must be even.");
286 }
287 // build_closest_pairs() selects by boundary index; with the labels in use the caller's
288 // BoundaryIds name labels, so they are translated to indices here.
289 vtkNew<vtkIdList> boundaryIndicesToUse;
290 vtkIdList* boundaryIndexFilter = this->BoundaryIds;
291 if (this->BoundaryIds && useBoundaryLabels)
292 {
293 for (vtkIdType boundaryIndex=0; boundaryIndex<numberOfBoundaries; boundaryIndex++)
294 {
295 if (this->BoundaryIds->IsId(boundaryLabels->GetId(boundaryIndex)) != -1)
296 {
297 boundaryIndicesToUse->InsertNextId(boundaryIndex);
298 }
299 }
300 boundaryIndexFilter = boundaryIndicesToUse;
301 }
302 vector<IdPair> boundaryPairs = build_closest_pairs(barycenters, boundaryIndexFilter);
303
304 // Loop over all boundary pairings uniquely
305 for (size_t pairingCount=0; pairingCount<boundaryPairs.size(); ++pairingCount)
306 {
307 vtkIdType i0 = boundaryPairs[pairingCount].first;
308 vtkIdType i1 = boundaryPairs[pairingCount].second;
309
310 // These are point ids for all boundaries globally, pointing into global vertex array
311 info("Finding boundary point ids...");
312 vtkIdTypeArray * boundaryPointIdsArray = vtkIdTypeArray::SafeDownCast(boundaries->GetPointData()->GetScalars());
313
314 // Collect (global!) point ids for boundary 0 in current pairing into a contiguous array
315 vtkPolyLine* boundary0 = vtkPolyLine::SafeDownCast(boundaries->GetCell(i0));
316 vtkIdType numberOfBoundaryPoints0 = boundary0->GetNumberOfPoints();
317 if (numberOfBoundaryPoints0 < 8)
318 {
319 vtkErrorMacro(<< "Error: Assuming at least 8 boundary points!");
320 }
321 vtkSmartPointer<vtkIdList> boundaryPointIds0 = vtkSmartPointer<vtkIdList>::New();
322 boundaryPointIds0->SetNumberOfIds(numberOfBoundaryPoints0);
323 for (int j=0; j<numberOfBoundaryPoints0; j++)
324 {
325 // Translation: local0[j] = global[local2global0[j]];
326 boundaryPointIds0->SetId(j, boundaryPointIdsArray->GetValue(boundary0->GetPointId(j)));
327 }
328
329 // Collect (global!) point ids for boundary 1 in current pairing into a contiguous array
330 vtkPolyLine* boundary1 = vtkPolyLine::SafeDownCast(boundaries->GetCell(i1));
331 vtkIdType numberOfBoundaryPoints1 = boundary1->GetNumberOfPoints();
332 if (numberOfBoundaryPoints1 < 8)
333 {
334 vtkErrorMacro(<< "Error: Assuming at least 8 boundary points!");
335 }
336 vtkSmartPointer<vtkIdList> boundaryPointIds1 = vtkSmartPointer<vtkIdList>::New();
337 boundaryPointIds1->SetNumberOfIds(numberOfBoundaryPoints1);
338 for (int j=0; j<numberOfBoundaryPoints1; j++)
339 {
340 // Translation: local1[j] = global[local2global1[j]];
341 boundaryPointIds1->SetId(j, boundaryPointIdsArray->GetValue(boundary1->GetPointId(j)));
342 }
343
344 // Find the two closest vertices between the boundaries
345 info("Finding closest vertices...");
346 IdPair starts = find_closest_points(input, boundaryPointIds0, boundaryPointIds1);
347 vtkIdType i0start = starts.first;
348 vtkIdType i1start = starts.second;
349
350 // Compute direction of paired boundaries
351 // TODO: Why was this numBP0/8 in annular case? Numerical robustness or something?
352 int i0forward = (i0start + 1) % numberOfBoundaryPoints0;
353 int i1forward = (i1start + 1) % numberOfBoundaryPoints1;
354 double cross[2][3];
355 double barycenter[3];
356 double startingPoint[3];
357 double pointForward[3];
358
359 barycenters->GetPoint(i0, barycenter);
360 input->GetPoint(boundaryPointIds0->GetId(i0start), startingPoint);
361 input->GetPoint(boundaryPointIds0->GetId(i0forward), pointForward);
362 cross_diff(startingPoint, pointForward, barycenter, cross[0]);
363
364 barycenters->GetPoint(i1, barycenter);
365 input->GetPoint(boundaryPointIds1->GetId(i1start), startingPoint);
366 input->GetPoint(boundaryPointIds1->GetId(i1forward), pointForward);
367 cross_diff(startingPoint, pointForward, barycenter, cross[1]);
368
369 int dir0 = +1; // TODO: Does the absolute direction matter?
370 bool backwards = vtkMath::Dot(cross[0], cross[1]) < 0.0;
371 int dir1 = backwards ? dir0: -dir0;
372
373 // Compute vectors in directions away from endpoints of polygon
374 double nudgeFactor = 0.01;
375 i0forward = (i0start + dir0 + numberOfBoundaryPoints0) % numberOfBoundaryPoints0;
376 input->GetPoint(boundaryPointIds0->GetId(i0start), startingPoint);
377 input->GetPoint(boundaryPointIds0->GetId(i0forward), pointForward);
378 double nudgeVector0[3] = { nudgeFactor*(pointForward[0] - startingPoint[0]),
379 nudgeFactor*(pointForward[1] - startingPoint[1]),
380 nudgeFactor*(pointForward[2] - startingPoint[2]) };
381 i1forward = (i1start - dir1 + numberOfBoundaryPoints1) % numberOfBoundaryPoints1;
382 input->GetPoint(boundaryPointIds1->GetId(i1start), startingPoint);
383 input->GetPoint(boundaryPointIds1->GetId(i1forward), pointForward);
384 double nudgeVector1[3] = { nudgeFactor*(pointForward[0] - startingPoint[0]),
385 nudgeFactor*(pointForward[1] - startingPoint[1]),
386 nudgeFactor*(pointForward[2] - startingPoint[2]) };
387
388 // Use vtkPolygon::Triangulate to mesh between boundary pair
389 info("Setting up n-sided polygon...");
390 // Initialize a vtkPolygon instance with list of boundary points
391 int npts = numberOfBoundaryPoints0 + numberOfBoundaryPoints1 + 2;
392 vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
393 vtkPoints * polygonPoints = polygon->GetPoints();
394 vtkIdList * polygonPointIds = polygon->GetPointIds();
395 polygonPoints->SetNumberOfPoints(npts);
396 polygonPointIds->SetNumberOfIds(npts);
397 vector<vtkIdType> polygonPointIdToGlobalPointId(npts);
398 // Add all vertices from the inner polygon in one
399 // direction, starting and ending with i0start.
400 int kk = 0;
401 for (int k=0; k<=numberOfBoundaryPoints0; k++) // NB! Using <= to repeat first point.
402 {
403 vtkIdType bp0id = (i0start + dir0*k + numberOfBoundaryPoints0) % numberOfBoundaryPoints0;
404 vtkIdType pid = boundaryPointIds0->GetId(bp0id);
405 double point[3];
406 input->GetPoint(pid, point);
407 if (k == 0)
408 {
409 point[0] += nudgeVector0[0];
410 point[1] += nudgeVector0[1];
411 point[2] += nudgeVector0[2];
412 }
413 polygonPointIdToGlobalPointId[kk] = pid;
414 polygonPointIds->SetId(kk,kk);
415 polygonPoints->InsertPoint(kk, point);
416 kk++;
417 }
418 // Continue by adding all vertices from the outer polygon in the
419 // opposite direction, starting and ending with i1start.
420 for (int k=0; k<=numberOfBoundaryPoints1; k++) // NB! Using <= to repeat first point.
421 {
422 vtkIdType bp1id = (i1start + dir1*k + numberOfBoundaryPoints1) % numberOfBoundaryPoints1;
423 vtkIdType pid = boundaryPointIds1->GetId(bp1id);
424 double point[3];
425 input->GetPoint(pid, point);
426 if (k == numberOfBoundaryPoints1)
427 {
428 point[0] += nudgeVector1[0];
429 point[1] += nudgeVector1[1];
430 point[2] += nudgeVector1[2];
431 }
432 polygonPointIdToGlobalPointId[kk] = pid;
433 polygonPointIds->SetId(kk,kk);
434 polygonPoints->InsertPoint(kk, point);
435 kk++;
436 }
437
438 // Call polygon->Triangulate(...) to mesh the interior of the concave polygon
439 info("Triangulating...");
440 vtkSmartPointer<vtkIdList> outTris = vtkSmartPointer<vtkIdList>::New();
441 int triRes = polygon->NonDegenerateTriangulate(outTris);
442 if (triRes == 0)
443 {
444 vtkErrorMacro(<< "Error: Numerical degeneracy when triangulating endcaps surface! Code: " << triRes);
445 }
446
447 // Output of triangulation is now in outTris, outPoints, append to newPolys
448 info("Appending datasets...");
449 size_t nt = outTris->GetNumberOfIds()/3;
450 for (size_t it=0; it<nt; ++it)
451 {
452 // Get mapped point ids for new triangle
453 vtkIdType triangleIds[3] = { polygonPointIdToGlobalPointId[outTris->GetId(3*it+0)],
454 polygonPointIdToGlobalPointId[outTris->GetId(3*it+1)],
455 polygonPointIdToGlobalPointId[outTris->GetId(3*it+2)] };
456
457 // Insert new triangle in endcaps mesh!
458 newPolys->InsertNextCell(3, triangleIds);
459 // Mark this new triangle with the pairing number (starting from 1) + given offset
460 if (markCells)
461 {
462 // A cap closes two boundaries, so the id comes from the pair rather than from one of
463 // them; pairingCount is only the fallback position.
464 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(i0) : i0;
465 vtkIdType partnerBoundaryId = useBoundaryLabels ? boundaryLabels->GetId(i1) : i1;
466 cellEntityIdsArray->InsertNextValue(static_cast<int>(
467 this->PairCapCellEntityId(pairingCount + 1 + this->CellEntityIdOffset,boundaryId,partnerBoundaryId,useBoundaryLabels)));
468 }
469 }
470 } // end for loop over boundary pairs
471
472 // Collect output datastructures
473 output->SetPoints(newPoints);
474 output->SetPolys(newPolys);
475 output->GetPointData()->PassData(input->GetPointData());
476 if (markCells)
477 {
478 output->GetCellData()->AddArray(cellEntityIdsArray);
479 }
480 info("Done!");
481
482 return 1;
483}
static bool GetOrExtractBoundaries(vtkPolyData *surface, const char *boundaryLabelsArrayName, const char *boundaryPointOrderArrayName, vtkPolyData *boundaries, vtkIdList *boundaryLabels, vtkObject *warningSource=nullptr)
static void ComputeBoundaryBarycenter(vtkPoints *points, double barycenter[3])
vtkIdType PairCapCellEntityId(vtkIdType positionalId, vtkIdType boundaryId, vtkIdType partnerBoundaryId, bool useBoundaryLabels)
pair< vtkIdType, vtkIdType > IdPair
vector< IdPair > build_closest_pairs(vtkSmartPointer< vtkPoints > barycenters, vtkIdList *boundaryIds)
IdPair find_closest_points(vtkPolyData *points, vtkSmartPointer< vtkIdList > pointIds0, vtkSmartPointer< vtkIdList > pointIds1)

◆ PairCapCellEntityId()

vtkIdType vtkvmtkConcaveAnnularCapPolyData::PairCapCellEntityId ( vtkIdType positionalId,
vtkIdType boundaryId,
vtkIdType partnerBoundaryId,
bool useBoundaryLabels )
protected

The id to tag the cap closing a pair of boundaries with: the entry of whichever of the two has one, the lower boundary id winning a disagreement; failing that the pair's lower boundary id with the labels in use, and the positional id without them.

Definition at line 485 of file vtkvmtkConcaveAnnularCapPolyData.cxx.

486{
487 // With the labels in use a boundary's label is its name, so the pair is named by the
488 // lower of its two labels -- the inner boundary, when the surface was labelled in annular
489 // mode -- unless the caller chose an id for it. Without them there is only position.
490 vtkIdType unchosenId = useBoundaryLabels
491 ? (boundaryId < partnerBoundaryId ? boundaryId : partnerBoundaryId)
492 : positionalId;
493 if (!this->BoundaryCellEntityIds)
494 {
495 return unchosenId;
496 }
497
498 vtkIdType lowerId = boundaryId < partnerBoundaryId ? boundaryId : partnerBoundaryId;
499 vtkIdType higherId = boundaryId < partnerBoundaryId ? partnerBoundaryId : boundaryId;
500
501 vtkIdType numberOfEntries = this->BoundaryCellEntityIds->GetNumberOfTuples();
502 vtkIdType lowerEntry = (lowerId >= 0 && lowerId < numberOfEntries) ? this->BoundaryCellEntityIds->GetValue(lowerId) : -1;
503 vtkIdType higherEntry = (higherId >= 0 && higherId < numberOfEntries) ? this->BoundaryCellEntityIds->GetValue(higherId) : -1;
504
505 if (lowerEntry >= 0 && higherEntry >= 0 && lowerEntry != higherEntry)
506 {
507 vtkWarningMacro(<<"The two boundaries of a pair were given different cap ids ("<<lowerEntry<<" for boundary "<<lowerId
508 <<" and "<<higherEntry<<" for boundary "<<higherId<<"); the cap takes "<<lowerEntry
509 <<", the id of the lower boundary.");
510 }
511
512 if (lowerEntry >= 0)
513 {
514 return lowerEntry;
515 }
516 if (higherEntry >= 0)
517 {
518 return higherEntry;
519 }
520 return unchosenId;
521}

Member Data Documentation

◆ BoundaryIds

vtkIdList* vtkvmtkConcaveAnnularCapPolyData::BoundaryIds
protected

Definition at line 132 of file vtkvmtkConcaveAnnularCapPolyData.h.

◆ BoundaryLabelsArrayName

char* vtkvmtkConcaveAnnularCapPolyData::BoundaryLabelsArrayName
protected

Definition at line 133 of file vtkvmtkConcaveAnnularCapPolyData.h.

◆ BoundaryPointOrderArrayName

char* vtkvmtkConcaveAnnularCapPolyData::BoundaryPointOrderArrayName
protected

Definition at line 134 of file vtkvmtkConcaveAnnularCapPolyData.h.

◆ BoundaryCellEntityIds

vtkIdTypeArray* vtkvmtkConcaveAnnularCapPolyData::BoundaryCellEntityIds
protected

Definition at line 135 of file vtkvmtkConcaveAnnularCapPolyData.h.

◆ CellEntityIdsArrayName

char* vtkvmtkConcaveAnnularCapPolyData::CellEntityIdsArrayName
protected

Definition at line 136 of file vtkvmtkConcaveAnnularCapPolyData.h.

◆ CellEntityIdOffset

int vtkvmtkConcaveAnnularCapPolyData::CellEntityIdOffset
protected

Definition at line 137 of file vtkvmtkConcaveAnnularCapPolyData.h.


The documentation for this class was generated from the following files: