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

Close holes in a surface with a smooth, rounded (domed) cap built with concentric thin-plate-spline rings. More...

#include <vtkvmtkSmoothCapPolyData.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkSmoothCapPolyData * 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 ()
virtual void SetConstraintFactor (double)
virtual double GetConstraintFactor ()
virtual void SetNumberOfRings (int)
virtual int GetNumberOfRings ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkSmoothCapPolyData ()
 ~vtkvmtkSmoothCapPolyData ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkIdType CapCellEntityId (vtkIdType boundaryIndex, vtkIdType boundaryId, bool useBoundaryLabels)

Protected Attributes

vtkIdList * BoundaryIds
char * BoundaryLabelsArrayName
char * BoundaryPointOrderArrayName
vtkIdTypeArray * BoundaryCellEntityIds
char * CellEntityIdsArrayName
int CellEntityIdOffset
double ConstraintFactor
int NumberOfRings

Detailed Description

Close holes in a surface with a smooth, rounded (domed) cap built with concentric thin-plate-spline rings.

This is the "smooth" capping strategy used by the vmtksurfacecapper pype script. For each open boundary, a thin-plate-spline transform is fit between a flat unit disk (source landmarks) and the actual boundary loop together with an "outer ring" of points offset outward from the boundary, along the direction from each boundary point to the area-weighted centroid of its neighboring input triangles, by a distance proportional to ConstraintFactor and to the boundary's diagonal. This transform is then used to warp NumberOfRings concentric circles from the unit disk into 3D, producing a bulged, rounded cap whose shape near the rim follows the local shape of the surface (rather than a flat or conical cap). Each open boundary of the input is capped independently; boundaries can be restricted with BoundaryIds. If CellEntityIdsArrayName is set, the newly created cap cells are tagged with per-boundary ids in that cell data array, which downstream tools (mesh generators, boundary condition assignment) use to distinguish inlets/outlets/wall. The input is expected to be triangulated.

See also
vtkvmtkCapPolyData, vtkvmtkSimpleCapPolyData, vtkvmtkPolyDataBoundaryExtractor

Definition at line 49 of file vtkvmtkSmoothCapPolyData.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkSmoothCapPolyData::Superclass

Definition at line 52 of file vtkvmtkSmoothCapPolyData.h.

Constructor & Destructor Documentation

◆ vtkvmtkSmoothCapPolyData()

vtkvmtkSmoothCapPolyData::vtkvmtkSmoothCapPolyData ( )
protected

◆ ~vtkvmtkSmoothCapPolyData()

vtkvmtkSmoothCapPolyData::~vtkvmtkSmoothCapPolyData ( )
protected

Definition at line 56 of file vtkvmtkSmoothCapPolyData.cxx.

57{
58 if (this->BoundaryIds)
59 {
60 this->BoundaryIds->Delete();
61 this->BoundaryIds = NULL;
62 }
63
66
67 if (this->BoundaryCellEntityIds)
68 {
69 this->BoundaryCellEntityIds->Delete();
70 this->BoundaryCellEntityIds = NULL;
71 }
72 if (this->CellEntityIdsArrayName)
73 {
74 delete[] this->CellEntityIdsArrayName;
75 this->CellEntityIdsArrayName = NULL;
76 }
77}
virtual void SetBoundaryPointOrderArrayName(const char *)
virtual void SetBoundaryLabelsArrayName(const char *)

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkSmoothCapPolyData::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkSmoothCapPolyData * vtkvmtkSmoothCapPolyData::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 362 of file vtkvmtkSmoothCapPolyData.cxx.

363{
364 this->Superclass::PrintSelf(os,indent);
365}

◆ New()

vtkvmtkSmoothCapPolyData * vtkvmtkSmoothCapPolyData::New ( )
static

◆ SetBoundaryIds()

virtual void vtkvmtkSmoothCapPolyData::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 cap. If not set (default, NULL), every open boundary of the input surface is capped.

◆ GetBoundaryIds()

virtual vtkIdList * vtkvmtkSmoothCapPolyData::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 cap. If not set (default, NULL), every open boundary of the input surface is capped.

◆ SetCellEntityIdsArrayName()

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

Set/Get the name of the cell data array used to tag the newly created cap cells with an integer id, one distinct value per capped boundary (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 * vtkvmtkSmoothCapPolyData::GetCellEntityIdsArrayName ( )
virtual

Set/Get the name of the cell data array used to tag the newly created cap cells with an integer id, one distinct value per capped boundary (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 vtkvmtkSmoothCapPolyData::SetCellEntityIdOffset ( int )
virtual

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

◆ GetCellEntityIdOffset()

virtual int vtkvmtkSmoothCapPolyData::GetCellEntityIdOffset ( )
virtual

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

◆ SetBoundaryLabelsArrayName()

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

Note that this filter writes no point data on its output, the labels included: the caps it builds add points of their own, and it has never carried the input's point data over.

◆ GetBoundaryLabelsArrayName()

virtual char * vtkvmtkSmoothCapPolyData::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 boundary 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.

Note that this filter writes no point data on its output, the labels included: the caps it builds add points of their own, and it has never carried the input's point data over.

◆ SetBoundaryPointOrderArrayName()

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

Note that this filter writes no point data on its output, the labels included: the caps it builds add points of their own, and it has never carried the input's point data over.

◆ GetBoundaryPointOrderArrayName()

virtual char * vtkvmtkSmoothCapPolyData::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 boundary 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.

Note that this filter writes no point data on its output, the labels included: the caps it builds add points of their own, and it has never carried the input's point data over.

◆ SetBoundaryCellEntityIds()

virtual void vtkvmtkSmoothCapPolyData::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): entry i is the id given to the cap closing the boundary whose id is i.

An id beyond the end of the array, or one whose entry is negative, is no entry at all: with the labels in use that cap keeps its boundary's label, and without them the id its position would have given it. An id chosen here is used as it stands, with CellEntityIdOffset not added to it, while the offset still lands on the cells copied from the input and on any boundary left to its positional id.

◆ GetBoundaryCellEntityIds()

virtual vtkIdTypeArray * vtkvmtkSmoothCapPolyData::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): entry i is the id given to the cap closing the boundary whose id is i.

An id beyond the end of the array, or one whose entry is negative, is no entry at all: with the labels in use that cap keeps its boundary's label, and without them the id its position would have given it. An id chosen here is used as it stands, with CellEntityIdOffset not added to it, while the offset still lands on the cells copied from the input and on any boundary left to its positional id.

◆ SetConstraintFactor()

virtual void vtkvmtkSmoothCapPolyData::SetConstraintFactor ( double )
virtual

Set/Get the factor controlling how much the cap bulges outward before curving in towards the center, i.e. how strongly the shape of the input surface near the boundary influences the shape of the cap. It scales the outward displacement (along the direction from each boundary point to the area-weighted centroid of its neighboring triangles) used to build the outer thin-plate-spline landmark ring, as a multiple of the boundary's diagonal length. A value of 0 produces a flatter cap; larger values produce a more pronounced dome. Default: 1.0.

◆ GetConstraintFactor()

virtual double vtkvmtkSmoothCapPolyData::GetConstraintFactor ( )
virtual

Set/Get the factor controlling how much the cap bulges outward before curving in towards the center, i.e. how strongly the shape of the input surface near the boundary influences the shape of the cap. It scales the outward displacement (along the direction from each boundary point to the area-weighted centroid of its neighboring triangles) used to build the outer thin-plate-spline landmark ring, as a multiple of the boundary's diagonal length. A value of 0 produces a flatter cap; larger values produce a more pronounced dome. Default: 1.0.

◆ SetNumberOfRings()

virtual void vtkvmtkSmoothCapPolyData::SetNumberOfRings ( int )
virtual

Set/Get the number of concentric point rings, interpolated by the thin-plate-spline transform between the boundary loop and the cap's center, used to build the cap surface. Higher values produce a smoother, more finely tessellated dome at the cost of more points and cells. Default: 8.

◆ GetNumberOfRings()

virtual int vtkvmtkSmoothCapPolyData::GetNumberOfRings ( )
virtual

Set/Get the number of concentric point rings, interpolated by the thin-plate-spline transform between the boundary loop and the cap's center, used to build the cap surface. Higher values produce a smoother, more finely tessellated dome at the cost of more points and cells. Default: 8.

◆ RequestData()

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

Definition at line 79 of file vtkvmtkSmoothCapPolyData.cxx.

83{
84 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
85 vtkInformation *outInfo = outputVector->GetInformationObject(0);
86
87 vtkPolyData *input = vtkPolyData::SafeDownCast(
88 inInfo->Get(vtkDataObject::DATA_OBJECT()));
89 vtkPolyData *output = vtkPolyData::SafeDownCast(
90 outInfo->Get(vtkDataObject::DATA_OBJECT()));
91
92 if ( input->GetNumberOfPoints() < 1 )
93 {
94 return 1;
95 }
96
97 input->BuildCells();
98 input->BuildLinks();
99
100 vtkPoints* newPoints = vtkPoints::New();
101 newPoints->DeepCopy(input->GetPoints());
102
103 vtkCellArray* newPolys = vtkCellArray::New();
104 newPolys->DeepCopy(input->GetPolys());
105
106 // Copy cell entity ids array
107 vtkIdTypeArray* cellEntityIdsArray = NULL;
108 bool markCells = this->CellEntityIdsArrayName && this->CellEntityIdsArrayName[0];
109 if (markCells)
110 {
111 cellEntityIdsArray = vtkIdTypeArray::New();
112 cellEntityIdsArray->SetName(this->CellEntityIdsArrayName);
113 if (input->GetCellData()->GetArray(this->CellEntityIdsArrayName))
114 {
115 cellEntityIdsArray->DeepCopy(input->GetCellData()->GetArray(this->CellEntityIdsArrayName));
116 }
117 else
118 {
119 cellEntityIdsArray->SetNumberOfTuples(newPolys->GetNumberOfCells());
120 cellEntityIdsArray->FillComponent(0,static_cast<double>(this->CellEntityIdOffset));
121 }
122 }
123
124 // The boundaries either come from the labels the input already carries, which are the same
125 // boundaries in the same order every other filter reading those labels sees, or they are
126 // extracted here as they always were.
127 vtkNew<vtkPolyData> boundaries;
128 vtkNew<vtkIdList> boundaryLabels;
129 bool useBoundaryLabels = vtkvmtkBoundaryLabels::GetOrExtractBoundaries(
130 input,this->BoundaryLabelsArrayName,this->BoundaryPointOrderArrayName,boundaries,boundaryLabels,this);
131
132 int boundaryId;
133 for (boundaryId=0; boundaryId<boundaries->GetNumberOfCells(); boundaryId++)
134 {
135 // boundaryId is the boundary's position here; capBoundaryId is what names it, which is its
136 // label when the labels are in use and its position otherwise.
137 vtkIdType capBoundaryId = useBoundaryLabels ? boundaryLabels->GetId(boundaryId) : boundaryId;
138 if (this->BoundaryIds)
139 {
140 if (this->BoundaryIds->IsId(capBoundaryId) == -1)
141 {
142 continue;
143 }
144 }
145
146 vtkPolyLine* boundaryCell = vtkPolyLine::SafeDownCast(boundaries->GetCell(boundaryId));
147
148 int numberOfBoundaryPoints = boundaryCell->GetNumberOfPoints();
149 double boundaryDiagonal = sqrt(boundaryCell->GetLength2());
150
151 vtkIdList* boundaryPointIds = vtkIdList::New();
152 int i;
153 for (i=0; i<numberOfBoundaryPoints; i++)
154 {
155 vtkIdType boundaryPointId = static_cast<vtkIdType>(boundaries->GetPointData()->GetScalars()->GetComponent(boundaryCell->GetPointId(i),0));
156 boundaryPointIds->InsertNextId(boundaryPointId);
157 }
158
159 vtkPoints* outerRingPoints = vtkPoints::New();
160 vtkIdList* pointCells = vtkIdList::New();
161 vtkIdList* cellPoints = vtkIdList::New();
162 for (i=0; i<numberOfBoundaryPoints; i++)
163 {
164 vtkIdType boundaryPointId = boundaryPointIds->GetId(i);
165 pointCells->Initialize();
166 input->GetPointCells(boundaryPointId,pointCells);
167 double outerRingPoint[3];
168 outerRingPoint[0] = outerRingPoint[1] = outerRingPoint[2] = 0.0;
169 double areaSum = 0.0;
170 int j;
171 for (j=0; j<pointCells->GetNumberOfIds(); j++)
172 {
173 vtkIdType cellId = pointCells->GetId(j);
174 input->GetCellPoints(cellId,cellPoints);
175 //TODO: assert cell is vtkTriangle
176 double point0[3], point1[3], point2[3];
177 input->GetPoint(cellPoints->GetId(0),point0);
178 input->GetPoint(cellPoints->GetId(1),point1);
179 input->GetPoint(cellPoints->GetId(2),point2);
180 double triangleCenter[3];
181 vtkTriangle::TriangleCenter(point0,point1,point2,triangleCenter);
182 double triangleArea = vtkTriangle::TriangleArea(point0,point1,point2);
183 outerRingPoint[0] += triangleArea * triangleCenter[0];
184 outerRingPoint[1] += triangleArea * triangleCenter[1];
185 outerRingPoint[2] += triangleArea * triangleCenter[2];
186 areaSum += triangleArea;
187 }
188 outerRingPoint[0] /= areaSum;
189 outerRingPoint[1] /= areaSum;
190 outerRingPoint[2] /= areaSum;
191 double boundaryPoint[3];
192 input->GetPoint(boundaryPointId,boundaryPoint);
193 double boundaryVector[3];
194 boundaryVector[0] = outerRingPoint[0] - boundaryPoint[0];
195 boundaryVector[1] = outerRingPoint[1] - boundaryPoint[1];
196 boundaryVector[2] = outerRingPoint[2] - boundaryPoint[2];
197 vtkMath::Normalize(boundaryVector);
198 double distance = this->ConstraintFactor * 0.125 * boundaryDiagonal;
199 outerRingPoint[0] = distance * boundaryVector[0] + boundaryPoint[0];
200 outerRingPoint[1] = distance * boundaryVector[1] + boundaryPoint[1];
201 outerRingPoint[2] = distance * boundaryVector[2] + boundaryPoint[2];
202 outerRingPoints->InsertNextPoint(outerRingPoint);
203 }
204
205 pointCells->Delete();
206 cellPoints->Delete();
207
208 vtkThinPlateSplineTransform* thinPlateSplineTransform = vtkThinPlateSplineTransform::New();
209 thinPlateSplineTransform->SetBasisToR2LogR();
210 thinPlateSplineTransform->SetSigma(1.0);
211 vtkPoints* sourceLandmarks = vtkPoints::New();
212 vtkPoints* targetLandmarks = vtkPoints::New();
213
214 for (i=0; i<numberOfBoundaryPoints; i++)
215 {
216 double angle = (double)i / (double)numberOfBoundaryPoints * 2.0*vtkMath::Pi();
217 double sourcePoint[3];
218 sourcePoint[0] = cos(angle);
219 sourcePoint[1] = sin(angle);
220 sourcePoint[2] = 0.0;
221 sourceLandmarks->InsertNextPoint(sourcePoint);
222 targetLandmarks->InsertNextPoint(boundaryCell->GetPoints()->GetPoint(i));
223 double outerRingRadius = 1.25;
224 sourcePoint[0] = outerRingRadius * cos(angle);
225 sourcePoint[1] = outerRingRadius * sin(angle);
226 sourcePoint[2] = 0.0;
227 sourceLandmarks->InsertNextPoint(sourcePoint);
228 targetLandmarks->InsertNextPoint(outerRingPoints->GetPoint(i));
229 }
230
231 thinPlateSplineTransform->SetSourceLandmarks(sourceLandmarks);
232 thinPlateSplineTransform->SetTargetLandmarks(targetLandmarks);
233
234 outerRingPoints->Delete();
235
236 vtkIdList* circlePointIds = vtkIdList::New();
237 vtkIdList* previousCirclePointIds = vtkIdList::New();
238
239 circlePointIds->DeepCopy(boundaryPointIds);
240
241 int k;
242 for (k=1; k<this->NumberOfRings; k++)
243 {
244 previousCirclePointIds->DeepCopy(circlePointIds);
245 circlePointIds->Initialize();
246 for (i=0; i<numberOfBoundaryPoints; i++)
247 {
248 double angle = (double)i / (double)numberOfBoundaryPoints * 2.0*vtkMath::Pi();
249 double radius = 1.0 - (double)k/(double)this->NumberOfRings;
250 double sourcePoint[3];
251 sourcePoint[0] = radius * cos(angle);
252 sourcePoint[1] = radius * sin(angle);
253 sourcePoint[2] = 0.0;
254 double transformedPoint[3];
255 thinPlateSplineTransform->TransformPoint(sourcePoint,transformedPoint);
256 vtkIdType circlePointId = newPoints->InsertNextPoint(transformedPoint);
257 circlePointIds->InsertNextId(circlePointId);
258 }
259 for (i=0; i<numberOfBoundaryPoints; i++)
260 {
261 // Two triangles rather than the quad they would make. The four points are not reliably
262 // a simple quadrilateral: the warp that places a ring can bring neighbouring points of
263 // it past each other, and the quad through them then crosses itself. vtkTriangleFilter
264 // gives up on such a cell and emits nothing for it, which takes a hole out of a cap that
265 // was closed - so the split is made here, where the two triangles are known, instead of
266 // being left to a filter that cannot always make it.
267 vtkIdType previousId = previousCirclePointIds->GetId(i);
268 vtkIdType previousNextId = previousCirclePointIds->GetId((i+1)%numberOfBoundaryPoints);
269 vtkIdType currentId = circlePointIds->GetId(i);
270 vtkIdType currentNextId = circlePointIds->GetId((i+1)%numberOfBoundaryPoints);
271
272 vtkIdType firstTriangle[3] = {previousId, previousNextId, currentId};
273 vtkIdType secondTriangle[3] = {previousNextId, currentNextId, currentId};
274 newPolys->InsertNextCell(3,firstTriangle);
275 newPolys->InsertNextCell(3,secondTriangle);
276 if (markCells)
277 {
278 vtkIdType capCellEntityId = this->CapCellEntityId(boundaryId,capBoundaryId,useBoundaryLabels);
279 cellEntityIdsArray->InsertNextValue(capCellEntityId);
280 cellEntityIdsArray->InsertNextValue(capCellEntityId);
281 }
282 }
283 }
284
285 // The innermost ring closes the cap. It used to be one polygon, which leaves the same trap
286 // as the ring cells did: the ring is not reliably convex, or even simple, so a filter asked
287 // to triangulate it can fail and leave the tip open. Close it with a fan from its own centre
288 // instead, which is a triangle either way.
289 double tipCentre[3] = {0.0, 0.0, 0.0};
290 vtkIdType numberOfTipPoints = circlePointIds->GetNumberOfIds();
291 for (i=0; i<numberOfTipPoints; i++)
292 {
293 double tipPoint[3];
294 newPoints->GetPoint(circlePointIds->GetId(i),tipPoint);
295 for (int component=0; component<3; component++)
296 {
297 tipCentre[component] += tipPoint[component];
298 }
299 }
300 for (int component=0; component<3; component++)
301 {
302 tipCentre[component] /= static_cast<double>(numberOfTipPoints);
303 }
304 vtkIdType tipCentreId = newPoints->InsertNextPoint(tipCentre);
305 for (i=0; i<numberOfTipPoints; i++)
306 {
307 vtkIdType tipTriangle[3] = {circlePointIds->GetId(i),
308 circlePointIds->GetId((i+1)%numberOfTipPoints),
309 tipCentreId};
310 newPolys->InsertNextCell(3,tipTriangle);
311 if (markCells)
312 {
313 cellEntityIdsArray->InsertNextValue(this->CapCellEntityId(boundaryId,capBoundaryId,useBoundaryLabels));
314 }
315 }
316
317 boundaryPointIds->Delete();
318
319 circlePointIds->Delete();
320 previousCirclePointIds->Delete();
321
322 thinPlateSplineTransform->Delete();
323 sourceLandmarks->Delete();
324 targetLandmarks->Delete();
325 }
326
327 output->SetPoints(newPoints);
328 output->SetPolys(newPolys);
329
330 if (markCells)
331 {
332 output->GetCellData()->AddArray(cellEntityIdsArray);
333 cellEntityIdsArray->Delete();
334 }
335
336 newPoints->Delete();
337 newPolys->Delete();
338
339 return 1;
340}
static bool GetOrExtractBoundaries(vtkPolyData *surface, const char *boundaryLabelsArrayName, const char *boundaryPointOrderArrayName, vtkPolyData *boundaries, vtkIdList *boundaryLabels, vtkObject *warningSource=nullptr)
vtkIdType CapCellEntityId(vtkIdType boundaryIndex, vtkIdType boundaryId, bool useBoundaryLabels)

◆ CapCellEntityId()

vtkIdType vtkvmtkSmoothCapPolyData::CapCellEntityId ( vtkIdType boundaryIndex,
vtkIdType boundaryId,
bool useBoundaryLabels )
protected

The id to tag the cap of a boundary with: the one BoundaryCellEntityIds chose for it, or the one its position gives it.

Definition at line 342 of file vtkvmtkSmoothCapPolyData.cxx.

343{
344 // An id the caller chose for this boundary is used as it stands; CellEntityIdOffset is what
345 // moves the ids this filter derives itself out of the way of the input's, and has no business
346 // shifting one that was picked deliberately.
347 if (this->BoundaryCellEntityIds
348 && boundaryId < this->BoundaryCellEntityIds->GetNumberOfTuples()
349 && this->BoundaryCellEntityIds->GetValue(boundaryId) >= 0)
350 {
351 return this->BoundaryCellEntityIds->GetValue(boundaryId);
352 }
353 if (useBoundaryLabels)
354 {
355 // The boundary's label is its name, and so the cap's id; neither it nor a chosen id is
356 // shifted by CellEntityIdOffset.
357 return boundaryId;
358 }
359 return boundaryIndex+1+this->CellEntityIdOffset;
360}

Member Data Documentation

◆ BoundaryIds

vtkIdList* vtkvmtkSmoothCapPolyData::BoundaryIds
protected

Definition at line 165 of file vtkvmtkSmoothCapPolyData.h.

◆ BoundaryLabelsArrayName

char* vtkvmtkSmoothCapPolyData::BoundaryLabelsArrayName
protected

Definition at line 166 of file vtkvmtkSmoothCapPolyData.h.

◆ BoundaryPointOrderArrayName

char* vtkvmtkSmoothCapPolyData::BoundaryPointOrderArrayName
protected

Definition at line 167 of file vtkvmtkSmoothCapPolyData.h.

◆ BoundaryCellEntityIds

vtkIdTypeArray* vtkvmtkSmoothCapPolyData::BoundaryCellEntityIds
protected

Definition at line 168 of file vtkvmtkSmoothCapPolyData.h.

◆ CellEntityIdsArrayName

char* vtkvmtkSmoothCapPolyData::CellEntityIdsArrayName
protected

Definition at line 169 of file vtkvmtkSmoothCapPolyData.h.

◆ CellEntityIdOffset

int vtkvmtkSmoothCapPolyData::CellEntityIdOffset
protected

Definition at line 170 of file vtkvmtkSmoothCapPolyData.h.

◆ ConstraintFactor

double vtkvmtkSmoothCapPolyData::ConstraintFactor
protected

Definition at line 172 of file vtkvmtkSmoothCapPolyData.h.

◆ NumberOfRings

int vtkvmtkSmoothCapPolyData::NumberOfRings
protected

Definition at line 173 of file vtkvmtkSmoothCapPolyData.h.


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