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

Close holes in a surface by creating a cap made of triangles sharing a common vertex at the boundary barycenter. More...

#include <vtkvmtkCapPolyData.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCapPolyData * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual vtkIdList * GetCapCenterIds ()
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 SetDisplacement (double)
virtual double GetDisplacement ()
virtual void SetInPlaneDisplacement (double)
virtual double GetInPlaneDisplacement ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkCapPolyData ()
 ~vtkvmtkCapPolyData ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

vtkIdList * BoundaryIds
char * CellEntityIdsArrayName
int CellEntityIdOffset
char * BoundaryLabelsArrayName
char * BoundaryPointOrderArrayName
vtkIdTypeArray * BoundaryCellEntityIds
double Displacement
double InPlaneDisplacement
vtkIdList * CapCenterIds

Detailed Description

Close holes in a surface by creating a cap made of triangles sharing a common vertex at the boundary barycenter.

This class closes the boundaries of a surface with a cap. Each cap is made of triangles sharing the boundary barycenter which is added to the data set. It is possible to retrieve the ids of the added points with GetCapCenterIds. Boundary barycenters can be displaced along boundary normals through the Displacement parameter. Since this class is used as a preprocessing step for Delaunay tessellation, displacement is meant to avoid the occurrences of degenerate tetrahedra on the caps.

This is the simplest of the capping strategies used by the vmtksurfacecapper pype script (its "simple" Method); it is a fast, one-triangle-fan-per-hole capper meant to produce a closed, tetrahedralizable surface (e.g. before Delaunay-based volume meshing or before centerline extraction, both of which require a closed surface). Each open boundary of the input is capped independently; boundaries can be restricted with BoundaryIds. If CellEntityIdsArrayName is set, the newly created cap triangles 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.

See also
vtkvmtkPolyDataBoundaryExtractor, vtkvmtkBoundaryReferenceSystems

Definition at line 51 of file vtkvmtkCapPolyData.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkCapPolyData::Superclass

Definition at line 54 of file vtkvmtkCapPolyData.h.

Constructor & Destructor Documentation

◆ vtkvmtkCapPolyData()

vtkvmtkCapPolyData::vtkvmtkCapPolyData ( )
protected

Definition at line 44 of file vtkvmtkCapPolyData.cxx.

45{
46 this->BoundaryIds = NULL;
47 this->Displacement = 1E-1;
48 this->InPlaneDisplacement = 1E-1;
49 this->CapCenterIds = NULL;
50 this->CellEntityIdsArrayName = NULL;
51 this->CellEntityIdOffset = 1;
52 this->BoundaryLabelsArrayName = NULL;
53 this->BoundaryPointOrderArrayName = NULL;
54 this->BoundaryCellEntityIds = NULL;
55}
vtkIdTypeArray * BoundaryCellEntityIds

◆ ~vtkvmtkCapPolyData()

vtkvmtkCapPolyData::~vtkvmtkCapPolyData ( )
protected

Definition at line 57 of file vtkvmtkCapPolyData.cxx.

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

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCapPolyData::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCapPolyData * vtkvmtkCapPolyData::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 317 of file vtkvmtkCapPolyData.cxx.

318{
319 this->Superclass::PrintSelf(os,indent);
320}

◆ New()

vtkvmtkCapPolyData * vtkvmtkCapPolyData::New ( )
static

◆ SetBoundaryIds()

virtual void vtkvmtkCapPolyData::SetBoundaryIds ( vtkIdList * )
virtual

Set/Get the ids of the boundaries to cap. If not set (default, NULL), every open boundary of the input surface is capped. A boundary's id is its label when BoundaryLabelsArrayName and BoundaryPointOrderArrayName are set and the input carries those arrays, and otherwise its position in the list of open boundaries extracted from the input, in the order returned by vtkvmtkPolyDataBoundaryExtractor.

◆ GetBoundaryIds()

virtual vtkIdList * vtkvmtkCapPolyData::GetBoundaryIds ( )
virtual

Set/Get the ids of the boundaries to cap. If not set (default, NULL), every open boundary of the input surface is capped. A boundary's id is its label when BoundaryLabelsArrayName and BoundaryPointOrderArrayName are set and the input carries those arrays, and otherwise its position in the list of open boundaries extracted from the input, in the order returned by vtkvmtkPolyDataBoundaryExtractor.

◆ SetCellEntityIdsArrayName()

virtual void vtkvmtkCapPolyData::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 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 * vtkvmtkCapPolyData::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 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 vtkvmtkCapPolyData::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 processed boundary is (i + 1 + CellEntityIdOffset). Default: 1.

◆ GetCellEntityIdOffset()

virtual int vtkvmtkCapPolyData::GetCellEntityIdOffset ( )
virtual

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

◆ SetBoundaryLabelsArrayName()

virtual void vtkvmtkCapPolyData::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. The arrays are written on the output too, where the points of a capped boundary keep the label they had, as a record of the boundary the cap closed.

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. So BoundaryIds and BoundaryCellEntityIds are read the same way either way, and a caller that labels its surface gets ids that survive the filters in between without having to say so twice.

A label is not merely a name this filter then has to turn 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 * vtkvmtkCapPolyData::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. The arrays are written on the output too, where the points of a capped boundary keep the label they had, as a record of the boundary the cap closed.

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. So BoundaryIds and BoundaryCellEntityIds are read the same way either way, and a caller that labels its surface gets ids that survive the filters in between without having to say so twice.

A label is not merely a name this filter then has to turn 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 vtkvmtkCapPolyData::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. The arrays are written on the output too, where the points of a capped boundary keep the label they had, as a record of the boundary the cap closed.

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. So BoundaryIds and BoundaryCellEntityIds are read the same way either way, and a caller that labels its surface gets ids that survive the filters in between without having to say so twice.

A label is not merely a name this filter then has to turn 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 * vtkvmtkCapPolyData::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. The arrays are written on the output too, where the points of a capped boundary keep the label they had, as a record of the boundary the cap closed.

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. So BoundaryIds and BoundaryCellEntityIds are read the same way either way, and a caller that labels its surface gets ids that survive the filters in between without having to say so twice.

A label is not merely a name this filter then has to turn 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 vtkvmtkCapPolyData::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, which already is the id its position would have given it, and without them the id its position gives it. An output can carry ids from both rules at once. 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. A label is not shifted either, for the same reason: it was numbered above the wall to begin with, and shifting it again would move the cap off the id its end is known by.

Where this earns its keep is with the boundary labels in use, because then the choice survives the filters in between: the label of a vessel end is carried by the surface's own point data, so a flow extension that replaces a boundary with a new one at the tip of its extension, or any filter that renumbers the points, leaves the answer to "which end is this" unchanged.

◆ GetBoundaryCellEntityIds()

virtual vtkIdTypeArray * vtkvmtkCapPolyData::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, which already is the id its position would have given it, and without them the id its position gives it. An output can carry ids from both rules at once. 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. A label is not shifted either, for the same reason: it was numbered above the wall to begin with, and shifting it again would move the cap off the id its end is known by.

Where this earns its keep is with the boundary labels in use, because then the choice survives the filters in between: the label of a vessel end is carried by the surface's own point data, so a flow extension that replaces a boundary with a new one at the tip of its extension, or any filter that renumbers the points, leaves the answer to "which end is this" unchanged.

◆ SetDisplacement()

virtual void vtkvmtkCapPolyData::SetDisplacement ( double )
virtual

Set/Get the displacement of boundary barycenters along the (outward-oriented) boundary normal, expressed as a fraction of the boundary's mean radius. A small positive value (default 0.1) lifts the cap center off the boundary plane so that Delaunay tetrahedralization of the capped surface does not produce degenerate (near-zero-volume) tetrahedra.

◆ GetDisplacement()

virtual double vtkvmtkCapPolyData::GetDisplacement ( )
virtual

Set/Get the displacement of boundary barycenters along the (outward-oriented) boundary normal, expressed as a fraction of the boundary's mean radius. A small positive value (default 0.1) lifts the cap center off the boundary plane so that Delaunay tetrahedralization of the capped surface does not produce degenerate (near-zero-volume) tetrahedra.

◆ SetInPlaneDisplacement()

virtual void vtkvmtkCapPolyData::SetInPlaneDisplacement ( double )
virtual

Set/Get the in-plane displacement of boundary barycenters, expressed as a fraction of the boundary's mean radius, applied along one of the two directions perpendicular to the boundary normal. Like Displacement, this is used to break symmetry and avoid degenerate tetrahedra in a subsequent Delaunay tessellation. Default: 0.1.

◆ GetInPlaneDisplacement()

virtual double vtkvmtkCapPolyData::GetInPlaneDisplacement ( )
virtual

Set/Get the in-plane displacement of boundary barycenters, expressed as a fraction of the boundary's mean radius, applied along one of the two directions perpendicular to the boundary normal. Like Displacement, this is used to break symmetry and avoid degenerate tetrahedra in a subsequent Delaunay tessellation. Default: 0.1.

◆ GetCapCenterIds()

virtual vtkIdList * vtkvmtkCapPolyData::GetCapCenterIds ( )
virtual

Get the ids, in the output poly data, of the newly inserted cap-center (barycenter) points – one per processed boundary, in the same order as the boundaries returned by vtkvmtkPolyDataBoundaryExtractor, and indexed consistently with BoundaryIds when the latter is set. Valid only after Update() has been called.

◆ RequestData()

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

Definition at line 83 of file vtkvmtkCapPolyData.cxx.

87{
88 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
89 vtkInformation *outInfo = outputVector->GetInformationObject(0);
90
91 vtkPolyData *input = vtkPolyData::SafeDownCast(
92 inInfo->Get(vtkDataObject::DATA_OBJECT()));
93 vtkPolyData *output = vtkPolyData::SafeDownCast(
94 outInfo->Get(vtkDataObject::DATA_OBJECT()));
95
96 // Declare
97 vtkIdType barycenterId, trianglePoints[3];
98 vtkIdType i, j;
99 vtkvmtkPolyDataBoundaryExtractor* boundaryExtractor;
100 vtkPolyData* boundaries;
101 vtkPoints* newPoints;
102 vtkCellArray* newPolys;
103 vtkPolyLine* boundary;
104
105 // Initialize
106 if ( ((input->GetNumberOfPoints()) < 1) )
107 {
108 //vtkErrorMacro(<< "No input!");
109 return 1;
110 }
111 input->BuildLinks();
112
113 // Allocate
114 newPoints = vtkPoints::New();
115 newPoints->DeepCopy(input->GetPoints());
116 newPolys = vtkCellArray::New();
117 newPolys->DeepCopy(input->GetPolys());
118 boundaryExtractor = vtkvmtkPolyDataBoundaryExtractor::New();
119
120 // Copy cell entity ids array
121 vtkIdTypeArray* cellEntityIdsArray = NULL;
122 bool markCells = this->CellEntityIdsArrayName && this->CellEntityIdsArrayName[0];
123 if (markCells)
124 {
125 cellEntityIdsArray = vtkIdTypeArray::New();
126 cellEntityIdsArray->SetName(this->CellEntityIdsArrayName);
127 if (input->GetCellData()->GetArray(this->CellEntityIdsArrayName))
128 {
129 cellEntityIdsArray->DeepCopy(input->GetCellData()->GetArray(this->CellEntityIdsArrayName));
130 }
131 else
132 {
133 cellEntityIdsArray->SetNumberOfTuples(newPolys->GetNumberOfCells());
134 cellEntityIdsArray->FillComponent(0,static_cast<double>(this->CellEntityIdOffset));
135 }
136 }
137
138 // Execute
139 // The boundaries either come from the labels the input already carries, which are the same
140 // boundaries in the same order every other filter reading those labels sees, or they are
141 // extracted here as they always were.
142 vtkNew<vtkPolyData> labeledBoundaries;
143 vtkNew<vtkIdList> boundaryLabels;
144 boundaries = NULL;
145 bool useBoundaryLabels = false;
148 {
149 useBoundaryLabels = vtkvmtkBoundaryLabels::GetBoundaries(
151 labeledBoundaries,boundaryLabels);
152 if (useBoundaryLabels)
153 {
154 boundaries = labeledBoundaries;
155 }
156 else
157 {
158 vtkWarningMacro(<<"The boundary label arrays are missing from the input surface or no longer describe it; "
159 <<"extracting its boundaries instead, and naming the caps by position.");
160 }
161 }
162 if (!boundaries)
163 {
164 boundaryExtractor->SetInputData(input);
165 boundaryExtractor->Update();
166 boundaries = boundaryExtractor->GetOutput();
167 }
168
169 if (this->BoundaryCellEntityIds)
170 {
171 // Silence here is how a caller ends up with caps carrying ids it did not choose and no way
172 // of telling. Say which boundaries were left out instead.
173 for (vtkIdType boundaryIndex=0; boundaryIndex<boundaries->GetNumberOfCells(); boundaryIndex++)
174 {
175 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(boundaryIndex) : boundaryIndex;
176 if (boundaryId >= this->BoundaryCellEntityIds->GetNumberOfTuples())
177 {
178 vtkWarningMacro(<<"BoundaryCellEntityIds has no entry for the boundary with id "<<boundaryId
179 <<"; its cap takes the id its position gives it.");
180 }
181 }
182 }
183
184 if (this->CapCenterIds)
185 {
186 this->CapCenterIds->Delete();
187 this->CapCenterIds = NULL;
188 }
189
190 this->CapCenterIds = vtkIdList::New();
191 this->CapCenterIds->SetNumberOfIds(boundaries->GetNumberOfCells());
192 for (i=0; i<this->CapCenterIds->GetNumberOfIds(); i++)
193 {
194 this->CapCenterIds->SetId(i,-1);
195 }
196
197 double barycenter[3], normal[3], outwardNormal[3], meanRadius;
198
199 for (i=0; i<boundaries->GetNumberOfCells(); i++)
200 {
201 if (this->BoundaryIds)
202 {
203 // A boundary is named by its label when the labels are in use, and by its position in the
204 // extraction order otherwise, here as everywhere else in this filter.
205 if (this->BoundaryIds->IsId(useBoundaryLabels ? boundaryLabels->GetId(i) : i) == -1)
206 {
207 continue;
208 }
209 }
210 boundary = vtkPolyLine::SafeDownCast(boundaries->GetCell(i));
211
212 vtkvmtkBoundaryReferenceSystems::ComputeBoundaryBarycenter(boundary->GetPoints(),barycenter);
213 vtkvmtkBoundaryReferenceSystems::ComputeBoundaryNormal(boundary->GetPoints(),barycenter,normal);
214 vtkvmtkBoundaryReferenceSystems::OrientBoundaryNormalOutwards(input,boundaries,i,normal,outwardNormal);
215 meanRadius = vtkvmtkBoundaryReferenceSystems::ComputeBoundaryMeanRadius(boundary->GetPoints(),barycenter);
216
217 for (j=0; j<3; j++)
218 {
219 barycenter[j] += meanRadius * this->Displacement * outwardNormal[j];
220 }
221
222 double inplane1[3], inplane2[3];
223 vtkMath::Perpendiculars(outwardNormal,inplane1,inplane2,0.0);
224 for (j=0; j<3; j++)
225 {
226 barycenter[j] += meanRadius * this->InPlaneDisplacement * inplane1[j];
227 }
228
229 barycenterId = newPoints->InsertNextPoint(barycenter);
230 this->CapCenterIds->SetId(i,barycenterId);
231
232 vtkIdType numberOfBoundaryPoints = boundary->GetNumberOfPoints();
233 for (j=0; j<numberOfBoundaryPoints; j++)
234 {
235 trianglePoints[0] = static_cast<vtkIdType>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundary->GetPointId(j)));
236 trianglePoints[1] = barycenterId;
237 trianglePoints[2] = static_cast<vtkIdType>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundary->GetPointId((j+1)%numberOfBoundaryPoints)));
238
239 newPolys->InsertNextCell(3,trianglePoints);
240
241 if (markCells)
242 {
243 // An id the caller chose for this boundary is used as it stands; CellEntityIdOffset is
244 // what moves the ids this filter derives itself out of the way of the input's, and has
245 // no business shifting one that was picked deliberately.
246 // With the labels in use the boundary's label is its name, so it is also the cap's id
247 // unless the caller chose another: a label is as deliberate as an entry in
248 // BoundaryCellEntityIds, and neither is shifted by CellEntityIdOffset. Without them
249 // there is nothing to go on but the boundary's position.
250 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(i) : i;
251 vtkIdType capCellEntityId = useBoundaryLabels ? boundaryId : i+1+this->CellEntityIdOffset;
252 if (this->BoundaryCellEntityIds
253 && boundaryId < this->BoundaryCellEntityIds->GetNumberOfTuples()
254 && this->BoundaryCellEntityIds->GetValue(boundaryId) >= 0)
255 {
256 capCellEntityId = this->BoundaryCellEntityIds->GetValue(boundaryId);
257 }
258 cellEntityIdsArray->InsertNextValue(capCellEntityId);
259 }
260
261 }
262 }
263
264 output->SetPoints(newPoints);
265 output->SetPolys(newPolys);
266
267 if (markCells)
268 {
269 output->GetCellData()->AddArray(cellEntityIdsArray);
270 cellEntityIdsArray->Delete();
271 }
272
273 if (useBoundaryLabels)
274 {
275 // The input's points keep the ids they had - they are deep copied first and the cap centers
276 // only appended - so the labels copy across as they stand. They describe no open boundary
277 // any more, every one of them having just been closed, but they are left in place as a
278 // record of which vessel end each ring of points was.
279 const vtkIdType invalidLabel = vtkvmtkBoundaryLabels::GetInvalidBoundaryLabel();
280 vtkIdType numberOfInputPoints = input->GetNumberOfPoints();
281 vtkIdType numberOfOutputPoints = newPoints->GetNumberOfPoints();
282
283 vtkDataArray* inputLabels = input->GetPointData()->GetArray(this->BoundaryLabelsArrayName);
284 vtkDataArray* inputOrder = input->GetPointData()->GetArray(this->BoundaryPointOrderArrayName);
285
286 vtkNew<vtkIntArray> outputLabels;
287 outputLabels->SetName(this->BoundaryLabelsArrayName);
288 outputLabels->SetNumberOfTuples(numberOfOutputPoints);
289 outputLabels->FillComponent(0,static_cast<double>(invalidLabel));
290
291 vtkNew<vtkIntArray> outputOrder;
292 outputOrder->SetName(this->BoundaryPointOrderArrayName);
293 outputOrder->SetNumberOfTuples(numberOfOutputPoints);
294 outputOrder->FillComponent(0,static_cast<double>(invalidLabel));
295
296 for (vtkIdType pointId=0; pointId<numberOfInputPoints; pointId++)
297 {
298 outputLabels->SetValue(pointId,static_cast<int>(vtkMath::Round(inputLabels->GetComponent(pointId,0))));
299 outputOrder->SetValue(pointId,static_cast<int>(vtkMath::Round(inputOrder->GetComponent(pointId,0))));
300 }
301
302 output->GetPointData()->AddArray(outputLabels);
303 output->GetPointData()->AddArray(outputOrder);
304 }
305
306 // TODO: the filter throws all the point and cell data
307 //output->GetPointData()->PassData(input->GetPointData()); // Like this?
308
309 // Destroy
310 newPoints->Delete();
311 newPolys->Delete();
312 boundaryExtractor->Delete();
313
314 return 1;
315}
static bool GetBoundaries(vtkPolyData *surface, const char *boundaryLabelsArrayName, const char *boundaryPointOrderArrayName, vtkPolyData *boundaries, vtkIdList *boundaryLabels)
static vtkIdType GetInvalidBoundaryLabel()
static void ComputeBoundaryBarycenter(vtkPoints *points, double barycenter[3])
static void OrientBoundaryNormalOutwards(vtkPolyData *surface, vtkPolyData *boundaries, vtkIdType boundaryCellId, double normal[3], double outwardNormal[3])
static void ComputeBoundaryNormal(vtkPoints *points, double barycenter[3], double normal[3])
static double ComputeBoundaryMeanRadius(vtkPoints *points, double barycenter[3])
static vtkvmtkPolyDataBoundaryExtractor * New()

Member Data Documentation

◆ BoundaryIds

vtkIdList* vtkvmtkCapPolyData::BoundaryIds
protected

Definition at line 163 of file vtkvmtkCapPolyData.h.

◆ CellEntityIdsArrayName

char* vtkvmtkCapPolyData::CellEntityIdsArrayName
protected

Definition at line 164 of file vtkvmtkCapPolyData.h.

◆ CellEntityIdOffset

int vtkvmtkCapPolyData::CellEntityIdOffset
protected

Definition at line 165 of file vtkvmtkCapPolyData.h.

◆ BoundaryLabelsArrayName

char* vtkvmtkCapPolyData::BoundaryLabelsArrayName
protected

Definition at line 166 of file vtkvmtkCapPolyData.h.

◆ BoundaryPointOrderArrayName

char* vtkvmtkCapPolyData::BoundaryPointOrderArrayName
protected

Definition at line 167 of file vtkvmtkCapPolyData.h.

◆ BoundaryCellEntityIds

vtkIdTypeArray* vtkvmtkCapPolyData::BoundaryCellEntityIds
protected

Definition at line 168 of file vtkvmtkCapPolyData.h.

◆ Displacement

double vtkvmtkCapPolyData::Displacement
protected

Definition at line 170 of file vtkvmtkCapPolyData.h.

◆ InPlaneDisplacement

double vtkvmtkCapPolyData::InPlaneDisplacement
protected

Definition at line 171 of file vtkvmtkCapPolyData.h.

◆ CapCenterIds

vtkIdList* vtkvmtkCapPolyData::CapCenterIds
protected

Definition at line 172 of file vtkvmtkCapPolyData.h.


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