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

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

#include <vtkvmtkAnnularCapPolyData.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkAnnularCapPolyData * 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 vtkvmtkAnnularCapPolyData * SafeDownCast (vtkObjectBase *o)
static vtkvmtkAnnularCapPolyData * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkAnnularCapPolyData ()
 ~vtkvmtkAnnularCapPolyData ()
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 vtkvmtkCapPolyData (which caps each open boundary independently with a single-vertex triangle fan), this filter is meant for surfaces that have two "parallel" boundaries bounding a wall thickness (e.g. an inner lumen boundary and an outer wall boundary produced by offsetting a vessel surface) – it pairs up the closest boundaries by barycenter distance and connects them with an annular strip of triangles, without inserting new points. This is one of the capping strategies used by the vmtksurfacecapper pype script (its "annular" Method), producing a closed surface out of a "walled" (double-boundary) input. Boundaries can be restricted with BoundaryIds. If CellEntityIdsArrayName is set, the newly created cap triangles are tagged with per-boundary-pair ids in that cell data array.

See also
vtkvmtkCapPolyData, vtkvmtkPolyDataBoundaryExtractor, vtkvmtkBoundaryReferenceSystems

Definition at line 47 of file vtkvmtkAnnularCapPolyData.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkAnnularCapPolyData::Superclass

Definition at line 50 of file vtkvmtkAnnularCapPolyData.h.

Constructor & Destructor Documentation

◆ vtkvmtkAnnularCapPolyData()

vtkvmtkAnnularCapPolyData::vtkvmtkAnnularCapPolyData ( )
protected

◆ ~vtkvmtkAnnularCapPolyData()

vtkvmtkAnnularCapPolyData::~vtkvmtkAnnularCapPolyData ( )
protected

Definition at line 52 of file vtkvmtkAnnularCapPolyData.cxx.

53{
54 if (this->CellEntityIdsArrayName)
55 {
56 delete[] this->CellEntityIdsArrayName;
57 this->CellEntityIdsArrayName = NULL;
58 }
59 if (this->BoundaryIds)
60 {
61 this->BoundaryIds->Delete();
62 this->BoundaryIds = NULL;
63 }
64
67
68 if (this->BoundaryCellEntityIds)
69 {
70 this->BoundaryCellEntityIds->Delete();
71 this->BoundaryCellEntityIds = NULL;
72 }
73}
virtual void SetBoundaryPointOrderArrayName(const char *)
virtual void SetBoundaryLabelsArrayName(const char *)

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkAnnularCapPolyData::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkAnnularCapPolyData * vtkvmtkAnnularCapPolyData::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 420 of file vtkvmtkAnnularCapPolyData.cxx.

421{
422 this->Superclass::PrintSelf(os,indent);
423}

◆ New()

vtkvmtkAnnularCapPolyData * vtkvmtkAnnularCapPolyData::New ( )
static

◆ SetBoundaryIds()

virtual void vtkvmtkAnnularCapPolyData::SetBoundaryIds ( vtkIdList * )
virtual

Set/Get the ids (into the list of open boundaries extracted from the input, in the order returned by vtkvmtkPolyDataBoundaryExtractor) of the boundaries to pair up and cap. If not set (default, NULL), every open boundary of the input surface is considered, paired with its closest (by barycenter distance) unpaired boundary. The number of boundaries considered must be even.

◆ GetBoundaryIds()

virtual vtkIdList * vtkvmtkAnnularCapPolyData::GetBoundaryIds ( )
virtual

Set/Get the ids (into the list of open boundaries extracted from the input, in the order returned by vtkvmtkPolyDataBoundaryExtractor) of the boundaries to pair up and cap. If not set (default, NULL), every open boundary of the input surface is considered, paired with its closest (by barycenter distance) unpaired boundary. The number of boundaries considered must be even.

◆ SetCellEntityIdsArrayName()

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

Set/Get the name of the cell data array used to tag the newly created annular cap triangles with an integer id, one distinct value per capped boundary pair (offset by CellEntityIdOffset, then further offset by boundary index + 1). 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 * vtkvmtkAnnularCapPolyData::GetCellEntityIdsArrayName ( )
virtual

Set/Get the name of the cell data array used to tag the newly created annular cap triangles with an integer id, one distinct value per capped boundary pair (offset by CellEntityIdOffset, then further offset by boundary index + 1). 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 vtkvmtkAnnularCapPolyData::SetCellEntityIdOffset ( int )
virtual

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

◆ GetCellEntityIdOffset()

virtual int vtkvmtkAnnularCapPolyData::GetCellEntityIdOffset ( )
virtual

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

◆ SetBoundaryLabelsArrayName()

virtual void vtkvmtkAnnularCapPolyData::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.

Setting them also settles what a boundary id means everywhere else in this filter: with the labels in use a boundary's id is its label, and without them it is the boundary's position in the order the extractor returns, which is what it has always been. * 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 * vtkvmtkAnnularCapPolyData::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.

Setting them also settles what a boundary id means everywhere else in this filter: with the labels in use a boundary's id is its label, and without them it is the boundary's position in the order the extractor returns, which is what it has always been. * 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 vtkvmtkAnnularCapPolyData::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.

Setting them also settles what a boundary id means everywhere else in this filter: with the labels in use a boundary's id is its label, and without them it is the boundary's position in the order the extractor returns, which is what it has always been. * 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 * vtkvmtkAnnularCapPolyData::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.

Setting them also settles what a boundary id means everywhere else in this filter: with the labels in use a boundary's id is its label, and without them it is the boundary's position in the order the extractor returns, which is what it has always been. * 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 vtkvmtkAnnularCapPolyData::SetBoundaryCellEntityIds ( vtkIdTypeArray * )
virtual

Set/Get the id to write into CellEntityIdsArrayName for the cap of each boundary, indexed the way boundary ids are indexed everywhere else here (see BoundaryIds).

A cap here closes a pair of boundaries rather than one, so it has two entries to choose between: 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, so the cap is named after the vessel end rather than after whichever boundary the pairing happened to find first.

An id beyond the end of the array, or one whose entry is negative, is no entry at all. An id chosen here is used as it stands, with CellEntityIdOffset not added to it.

◆ GetBoundaryCellEntityIds()

virtual vtkIdTypeArray * vtkvmtkAnnularCapPolyData::GetBoundaryCellEntityIds ( )
virtual

Set/Get the id to write into CellEntityIdsArrayName for the cap of each boundary, indexed the way boundary ids are indexed everywhere else here (see BoundaryIds).

A cap here closes a pair of boundaries rather than one, so it has two entries to choose between: 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, so the cap is named after the vessel end rather than after whichever boundary the pairing happened to find first.

An id beyond the end of the array, or one whose entry is negative, is no entry at all. An id chosen here is used as it stands, with CellEntityIdOffset not added to it.

◆ RequestData()

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

Definition at line 75 of file vtkvmtkAnnularCapPolyData.cxx.

79{
80 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
81 vtkInformation *outInfo = outputVector->GetInformationObject(0);
82
83 vtkPolyData *input = vtkPolyData::SafeDownCast(
84 inInfo->Get(vtkDataObject::DATA_OBJECT()));
85 vtkPolyData *output = vtkPolyData::SafeDownCast(
86 outInfo->Get(vtkDataObject::DATA_OBJECT()));
87
88 if ( input->GetNumberOfPoints() < 1 )
89 {
90 return 1;
91 }
92
93 input->BuildLinks();
94
95 vtkPoints* newPoints = vtkPoints::New();
96 newPoints->DeepCopy(input->GetPoints());
97
98 vtkCellArray* newPolys = vtkCellArray::New();
99 newPolys->DeepCopy(input->GetPolys());
100
101 vtkIdTypeArray* cellEntityIdsArray = NULL;
102 bool markCells = this->CellEntityIdsArrayName && this->CellEntityIdsArrayName[0];
103 if (markCells)
104 {
105 cellEntityIdsArray = vtkIdTypeArray::New();
106 cellEntityIdsArray->SetName(this->CellEntityIdsArrayName);
107 if (input->GetCellData()->GetArray(this->CellEntityIdsArrayName))
108 {
109 cellEntityIdsArray->DeepCopy(input->GetCellData()->GetArray(this->CellEntityIdsArrayName));
110 }
111 else
112 {
113 cellEntityIdsArray->SetNumberOfTuples(newPolys->GetNumberOfCells());
114 cellEntityIdsArray->FillComponent(0,static_cast<double>(this->CellEntityIdOffset));
115 }
116 }
117
118 // The boundaries either come from the labels the input already carries, which are the same
119 // boundaries in the same order every other filter reading those labels sees, or they are
120 // extracted here as they always were.
121 vtkNew<vtkPolyData> boundaries;
122 vtkNew<vtkIdList> boundaryLabels;
123 bool useBoundaryLabels = vtkvmtkBoundaryLabels::GetOrExtractBoundaries(
124 input,this->BoundaryLabelsArrayName,this->BoundaryPointOrderArrayName,boundaries,boundaryLabels,this);
125 int numberOfBoundaries = boundaries->GetNumberOfCells();
126
127 if ( (this->BoundaryIds && this->BoundaryIds->GetNumberOfIds() % 2)
128 || (!this->BoundaryIds && numberOfBoundaries % 2) )
129 {
130 vtkErrorMacro(<< "Error: the number of boundaries must be even.");
131 newPoints->Delete();
132 newPolys->Delete();
133 if (markCells)
134 {
135 cellEntityIdsArray->Delete();
136 }
137 }
138
139 vtkPoints* barycenters = vtkPoints::New();
140 barycenters->SetNumberOfPoints(numberOfBoundaries);
141
142 vtkIdList* boundaryPairings = vtkIdList::New();
143 boundaryPairings->SetNumberOfIds(numberOfBoundaries);
144 vtkIdList* visitedBoundaries = vtkIdList::New();
145 visitedBoundaries->SetNumberOfIds(numberOfBoundaries);
146
147 double barycenter[3];
148 for (int i=0; i<numberOfBoundaries; i++)
149 {
150 vtkCell* boundary = boundaries->GetCell(i);
151 vtkvmtkBoundaryReferenceSystems::ComputeBoundaryBarycenter(boundary->GetPoints(),barycenter);
152 barycenters->SetPoint(i,barycenter);
153 boundaryPairings->SetId(i,-1);
154 visitedBoundaries->SetId(i,-1);
155 }
156
157 double currentBarycenter[3];
158 double distance2, minDistance2 = 0.0;
159 vtkIdType closestBoundaryId;
160 for (int i=0; i<numberOfBoundaries; i++)
161 {
162 if (this->BoundaryIds && this->BoundaryIds->IsId(useBoundaryLabels ? boundaryLabels->GetId(i) : i) == -1)
163 {
164 continue;
165 }
166 if (boundaryPairings->GetId(i) != -1 || boundaryPairings->IsId(i) != -1)
167 {
168 continue;
169 }
170 barycenters->GetPoint(i,barycenter);
171 closestBoundaryId = -1;
172 for (int j=i+1; j<numberOfBoundaries; j++)
173 {
174 if (this->BoundaryIds && this->BoundaryIds->IsId(useBoundaryLabels ? boundaryLabels->GetId(j) : j) == -1)
175 {
176 continue;
177 }
178 if (boundaryPairings->GetId(j) != -1 || boundaryPairings->IsId(j) != -1)
179 {
180 continue;
181 }
182 barycenters->GetPoint(j,currentBarycenter);
183 distance2 = vtkMath::Distance2BetweenPoints(barycenter,currentBarycenter);
184 if (closestBoundaryId == -1 || distance2 < minDistance2)
185 {
186 minDistance2 = distance2;
187 closestBoundaryId = j;
188 }
189 }
190 boundaryPairings->SetId(i,closestBoundaryId);
191 boundaryPairings->SetId(closestBoundaryId,i);
192 }
193
194 for (int i=0; i<numberOfBoundaries; i++)
195 {
196 if (this->BoundaryIds && this->BoundaryIds->IsId(useBoundaryLabels ? boundaryLabels->GetId(i) : i) == -1)
197 {
198 continue;
199 }
200
201 if (boundaryPairings->GetId(i) == -1)
202 {
203 continue;
204 }
205
206 if (visitedBoundaries->GetId(i) != -1)
207 {
208 continue;
209 }
210
211 visitedBoundaries->SetId(i,i);
212 visitedBoundaries->SetId(boundaryPairings->GetId(i),i);
213
214 vtkIdTypeArray* boundaryPointIdsArray = vtkIdTypeArray::New();
215 boundaryPointIdsArray->DeepCopy(boundaries->GetPointData()->GetScalars());
216
217 vtkPolyLine* boundary0 = vtkPolyLine::SafeDownCast(boundaries->GetCell(i));
218 vtkIdType numberOfBoundaryPoints0 = boundary0->GetNumberOfPoints();
219 vtkIdList* boundaryPointIds0 = vtkIdList::New();
220 boundaryPointIds0->SetNumberOfIds(numberOfBoundaryPoints0);
221 for (int j=0; j<numberOfBoundaryPoints0; j++)
222 {
223 boundaryPointIds0->SetId(j,boundaryPointIdsArray->GetValue(boundary0->GetPointId(j)));
224 }
225
226 vtkPolyLine* boundary1 = vtkPolyLine::SafeDownCast(boundaries->GetCell(boundaryPairings->GetId(i)));
227 vtkIdType numberOfBoundaryPoints1 = boundary1->GetNumberOfPoints();
228 vtkIdList* boundaryPointIds1 = vtkIdList::New();
229 boundaryPointIds1->SetNumberOfIds(numberOfBoundaryPoints1);
230 for (int j=0; j<numberOfBoundaryPoints1; j++)
231 {
232 boundaryPointIds1->SetId(j,boundaryPointIdsArray->GetValue(boundary1->GetPointId(j)));
233 }
234
235 double startingPoint[3], currentPoint[3];
236 input->GetPoint(boundaryPointIds0->GetId(0),startingPoint);
237
238 vtkIdType offset = -1;
239 for (int j=0; j<numberOfBoundaryPoints1; j++)
240 {
241 input->GetPoint(boundaryPointIds1->GetId(j),currentPoint);
242 distance2 = vtkMath::Distance2BetweenPoints(startingPoint,currentPoint);
243 if (offset == -1 || distance2 < minDistance2)
244 {
245 offset = j;
246 minDistance2 = distance2;
247 }
248 }
249
250 double vectorToStart[3], vectorToForward[3], cross0[3], cross1[3];
251 double pointForward[3];
252
253 barycenters->GetPoint(i,barycenter);
254 input->GetPoint(boundaryPointIds0->GetId(0),startingPoint);
255 input->GetPoint(boundaryPointIds0->GetId(numberOfBoundaryPoints0/8),pointForward);
256
257 vectorToStart[0] = startingPoint[0] - barycenter[0];
258 vectorToStart[1] = startingPoint[1] - barycenter[1];
259 vectorToStart[2] = startingPoint[2] - barycenter[2];
260
261 vectorToForward[0] = pointForward[0] - barycenter[0];
262 vectorToForward[1] = pointForward[1] - barycenter[1];
263 vectorToForward[2] = pointForward[2] - barycenter[2];
264
265 vtkMath::Cross(vectorToStart,vectorToForward,cross0);
266
267 barycenters->GetPoint(boundaryPairings->GetId(i),barycenter);
268 input->GetPoint(boundaryPointIds1->GetId(0),startingPoint);
269 input->GetPoint(boundaryPointIds1->GetId(numberOfBoundaryPoints1/8),pointForward);
270
271 vectorToStart[0] = startingPoint[0] - barycenter[0];
272 vectorToStart[1] = startingPoint[1] - barycenter[1];
273 vectorToStart[2] = startingPoint[2] - barycenter[2];
274
275 vectorToForward[0] = pointForward[0] - barycenter[0];
276 vectorToForward[1] = pointForward[1] - barycenter[1];
277 vectorToForward[2] = pointForward[2] - barycenter[2];
278
279 vtkMath::Cross(vectorToStart,vectorToForward,cross1);
280
281 bool backward = false;
282 if (vtkMath::Dot(cross0,cross1) < 0.0)
283 {
284 backward = true;
285 }
286
287 double point0[3], nextPoint0[3];
288 double point1[3], nextPoint1[3];
289 vtkIdType pointId0, nextPointId0;
290 vtkIdType pointId1, nextPointId1;
291 int j = 0;
292 int k = 0;
293 while (true)
294 {
295 if (j == numberOfBoundaryPoints0 && k == numberOfBoundaryPoints1)
296 {
297 break;
298 }
299
300 pointId0 = j % numberOfBoundaryPoints0;
301 nextPointId0 = (pointId0 + 1) % numberOfBoundaryPoints0;
302 pointId1 = (k + offset) % numberOfBoundaryPoints1;
303 nextPointId1 = (pointId1 + 1) % numberOfBoundaryPoints1;
304 if (backward)
305 {
306 pointId1 = (numberOfBoundaryPoints1 - k + offset + numberOfBoundaryPoints1) % numberOfBoundaryPoints1;
307 nextPointId1 = (pointId1 - 1 + numberOfBoundaryPoints1) % numberOfBoundaryPoints1;
308 }
309
310 input->GetPoint(boundaryPointIds0->GetId(pointId0),point0);
311 input->GetPoint(boundaryPointIds0->GetId(nextPointId0),nextPoint0);
312 input->GetPoint(boundaryPointIds1->GetId(pointId1),point1);
313 input->GetPoint(boundaryPointIds1->GetId(nextPointId1),nextPoint1);
314
315 newPolys->InsertNextCell(3);
316 newPolys->InsertCellPoint(boundaryPointIds0->GetId(pointId0));
317 newPolys->InsertCellPoint(boundaryPointIds1->GetId(pointId1));
318
319 bool next1 = false;
320 if (vtkMath::Distance2BetweenPoints(point0,nextPoint1) < vtkMath::Distance2BetweenPoints(point1,nextPoint0))
321 {
322 next1 = true;
323 }
324 if (k == numberOfBoundaryPoints1)
325 {
326 next1 = false;
327 }
328 else if (j == numberOfBoundaryPoints0)
329 {
330 next1 = true;
331 }
332
333 if (next1)
334 {
335 newPolys->InsertCellPoint(boundaryPointIds1->GetId(nextPointId1));
336 k++;
337 }
338 else
339 {
340 newPolys->InsertCellPoint(boundaryPointIds0->GetId(nextPointId0));
341 j++;
342 }
343
344 if (markCells)
345 {
346 // A cap here closes two boundaries, so the id comes from the pair rather than from one
347 // of them. i is the pair's position; the ids that name it are the two boundaries'.
348 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(i) : i;
349 vtkIdType partnerBoundaryId = useBoundaryLabels ? boundaryLabels->GetId(boundaryPairings->GetId(i)) : boundaryPairings->GetId(i);
350 cellEntityIdsArray->InsertNextValue(
351 this->PairCapCellEntityId(i+1+this->CellEntityIdOffset,boundaryId,partnerBoundaryId,useBoundaryLabels));
352 }
353 }
354
355 boundaryPointIdsArray->Delete();
356 boundaryPointIds0->Delete();
357 boundaryPointIds1->Delete();
358 }
359
360 output->SetPoints(newPoints);
361 output->SetPolys(newPolys);
362
363 output->GetPointData()->PassData(input->GetPointData());
364
365 if (markCells)
366 {
367 output->GetCellData()->AddArray(cellEntityIdsArray);
368 cellEntityIdsArray->Delete();
369 }
370
371 newPoints->Delete();
372 newPolys->Delete();
373 barycenters->Delete();
374 boundaryPairings->Delete();
375 visitedBoundaries->Delete();
376
377 return 1;
378}
vtkIdType PairCapCellEntityId(vtkIdType positionalId, vtkIdType boundaryId, vtkIdType partnerBoundaryId, bool useBoundaryLabels)
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])

◆ PairCapCellEntityId()

vtkIdType vtkvmtkAnnularCapPolyData::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 380 of file vtkvmtkAnnularCapPolyData.cxx.

381{
382 // With the labels in use a boundary's label is its name, so the pair is named by the
383 // lower of its two labels -- the inner boundary, when the surface was labelled in annular
384 // mode -- unless the caller chose an id for it. Without them there is only position.
385 vtkIdType unchosenId = useBoundaryLabels
386 ? (boundaryId < partnerBoundaryId ? boundaryId : partnerBoundaryId)
387 : positionalId;
388 if (!this->BoundaryCellEntityIds)
389 {
390 return unchosenId;
391 }
392
393 vtkIdType lowerId = boundaryId < partnerBoundaryId ? boundaryId : partnerBoundaryId;
394 vtkIdType higherId = boundaryId < partnerBoundaryId ? partnerBoundaryId : boundaryId;
395
396 vtkIdType numberOfEntries = this->BoundaryCellEntityIds->GetNumberOfTuples();
397 vtkIdType lowerEntry = (lowerId >= 0 && lowerId < numberOfEntries) ? this->BoundaryCellEntityIds->GetValue(lowerId) : -1;
398 vtkIdType higherEntry = (higherId >= 0 && higherId < numberOfEntries) ? this->BoundaryCellEntityIds->GetValue(higherId) : -1;
399
400 if (lowerEntry >= 0 && higherEntry >= 0 && lowerEntry != higherEntry)
401 {
402 // Silence here would name the cap after whichever boundary the pairing happened to reach
403 // first, which is not something the caller can predict or see afterwards.
404 vtkWarningMacro(<<"The two boundaries of a pair were given different cap ids ("<<lowerEntry<<" for boundary "<<lowerId
405 <<" and "<<higherEntry<<" for boundary "<<higherId<<"); the cap takes "<<lowerEntry
406 <<", the id of the lower boundary.");
407 }
408
409 if (lowerEntry >= 0)
410 {
411 return lowerEntry;
412 }
413 if (higherEntry >= 0)
414 {
415 return higherEntry;
416 }
417 return unchosenId;
418}

Member Data Documentation

◆ BoundaryIds

vtkIdList* vtkvmtkAnnularCapPolyData::BoundaryIds
protected

Definition at line 141 of file vtkvmtkAnnularCapPolyData.h.

◆ BoundaryLabelsArrayName

char* vtkvmtkAnnularCapPolyData::BoundaryLabelsArrayName
protected

Definition at line 142 of file vtkvmtkAnnularCapPolyData.h.

◆ BoundaryPointOrderArrayName

char* vtkvmtkAnnularCapPolyData::BoundaryPointOrderArrayName
protected

Definition at line 143 of file vtkvmtkAnnularCapPolyData.h.

◆ BoundaryCellEntityIds

vtkIdTypeArray* vtkvmtkAnnularCapPolyData::BoundaryCellEntityIds
protected

Definition at line 144 of file vtkvmtkAnnularCapPolyData.h.

◆ CellEntityIdsArrayName

char* vtkvmtkAnnularCapPolyData::CellEntityIdsArrayName
protected

Definition at line 145 of file vtkvmtkAnnularCapPolyData.h.

◆ CellEntityIdOffset

int vtkvmtkAnnularCapPolyData::CellEntityIdOffset
protected

Definition at line 146 of file vtkvmtkAnnularCapPolyData.h.


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