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

Close holes in a surface by filling each boundary loop with a single flat polygon. More...

#include <vtkvmtkSimpleCapPolyData.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Detailed Description

Close holes in a surface by filling each boundary loop with a single flat polygon.

This is the simplest and fastest of the capping strategies used by the vmtksurfacecapper pype script (its "simple" Method): for every open boundary of the input, a single polygon cell is inserted whose vertices are exactly the (unmodified) boundary points, in order – no new points are added and the boundary is not displaced or smoothed. Each open boundary of the input is capped independently; boundaries can be restricted with BoundaryIds. If CellEntityIdsArrayName is set, the newly created cap polygon is tagged with a per-boundary id in that cell data array, which downstream tools (mesh generators, boundary condition assignment) use to distinguish inlets/outlets/wall. The output caps are polygons, not necessarily triangles or planar for non-planar boundaries; they are commonly triangulated afterwards with vtkTriangleFilter.

See also
vtkvmtkCapPolyData, vtkvmtkSmoothCapPolyData, vtkvmtkPolyDataBoundaryExtractor

Definition at line 45 of file vtkvmtkSimpleCapPolyData.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkSimpleCapPolyData::Superclass

Definition at line 48 of file vtkvmtkSimpleCapPolyData.h.

Constructor & Destructor Documentation

◆ vtkvmtkSimpleCapPolyData()

vtkvmtkSimpleCapPolyData::vtkvmtkSimpleCapPolyData ( )
protected

◆ ~vtkvmtkSimpleCapPolyData()

vtkvmtkSimpleCapPolyData::~vtkvmtkSimpleCapPolyData ( )
protected

Definition at line 51 of file vtkvmtkSimpleCapPolyData.cxx.

52{
53 if (this->CellEntityIdsArrayName)
54 {
55 delete[] this->CellEntityIdsArrayName;
56 this->CellEntityIdsArrayName = NULL;
57 }
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 vtkvmtkSimpleCapPolyData::IsTypeOf ( const char * type)
static

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkSimpleCapPolyData::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkSimpleCapPolyData * vtkvmtkSimpleCapPolyData::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 185 of file vtkvmtkSimpleCapPolyData.cxx.

186{
187 this->Superclass::PrintSelf(os,indent);
188}

◆ New()

vtkvmtkSimpleCapPolyData * vtkvmtkSimpleCapPolyData::New ( )
static

◆ SetBoundaryIds()

virtual void vtkvmtkSimpleCapPolyData::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 * vtkvmtkSimpleCapPolyData::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 vtkvmtkSimpleCapPolyData::SetCellEntityIdsArrayName ( const char * )
virtual

Set/Get the name of the cell data array used to tag the newly created cap polygons 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 cell is appended with the new tag. If left NULL (default), no cell entity id array is created. Commonly named "CellEntityIds".

◆ GetCellEntityIdsArrayName()

virtual char * vtkvmtkSimpleCapPolyData::GetCellEntityIdsArrayName ( )
virtual

Set/Get the name of the cell data array used to tag the newly created cap polygons 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 cell is appended with the new tag. If left NULL (default), no cell entity id array is created. Commonly named "CellEntityIds".

◆ SetCellEntityIdOffset()

virtual void vtkvmtkSimpleCapPolyData::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 vtkvmtkSimpleCapPolyData::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 vtkvmtkSimpleCapPolyData::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. This filter adds no point, so the arrays reach the output unchanged with the rest of the input's point data.

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 * vtkvmtkSimpleCapPolyData::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. This filter adds no point, so the arrays reach the output unchanged with the rest of the input's point data.

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 vtkvmtkSimpleCapPolyData::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. This filter adds no point, so the arrays reach the output unchanged with the rest of the input's point data.

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 * vtkvmtkSimpleCapPolyData::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. This filter adds no point, so the arrays reach the output unchanged with the rest of the input's point data.

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 vtkvmtkSimpleCapPolyData::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 names it just as well, 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 * vtkvmtkSimpleCapPolyData::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 names it just as well, 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.

◆ RequestData()

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

Definition at line 75 of file vtkvmtkSimpleCapPolyData.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 bool markCells = this->CellEntityIdsArrayName && this->CellEntityIdsArrayName[0];
94
95 input->BuildLinks();
96
97 vtkPoints* newPoints = vtkPoints::New();
98 newPoints->DeepCopy(input->GetPoints());
99
100 vtkCellArray* newPolys = vtkCellArray::New();
101 newPolys->DeepCopy(input->GetPolys());
102
103 vtkIdTypeArray* cellEntityIdsArray = NULL;
104
105 if (markCells)
106 {
107 cellEntityIdsArray = vtkIdTypeArray::New();
108 cellEntityIdsArray->SetName(this->CellEntityIdsArrayName);
109 if (input->GetCellData()->GetArray(this->CellEntityIdsArrayName))
110 {
111 cellEntityIdsArray->DeepCopy(input->GetCellData()->GetArray(this->CellEntityIdsArrayName));
112 }
113 else
114 {
115 cellEntityIdsArray->SetNumberOfTuples(newPolys->GetNumberOfCells());
116 cellEntityIdsArray->FillComponent(0,static_cast<double>(this->CellEntityIdOffset));
117 }
118 }
119
120 // The boundaries either come from the labels the input already carries, which are the same
121 // boundaries in the same order every other filter reading those labels sees, or they are
122 // extracted here as they always were.
123 vtkNew<vtkPolyData> boundaries;
124 vtkNew<vtkIdList> boundaryLabels;
125 bool useBoundaryLabels = vtkvmtkBoundaryLabels::GetOrExtractBoundaries(
126 input,this->BoundaryLabelsArrayName,this->BoundaryPointOrderArrayName,boundaries,boundaryLabels,this);
127
128 for (int i=0; i<boundaries->GetNumberOfCells(); i++)
129 {
130 // A boundary is named by its label when the labels are in use, and by its position in the
131 // extraction order otherwise, here as everywhere else in this filter.
132 vtkIdType boundaryId = useBoundaryLabels ? boundaryLabels->GetId(i) : i;
133 if (this->BoundaryIds)
134 {
135 if (this->BoundaryIds->IsId(boundaryId) == -1)
136 {
137 continue;
138 }
139 }
140 vtkPolyLine* boundary = vtkPolyLine::SafeDownCast(boundaries->GetCell(i));
141 vtkIdType numberOfBoundaryPoints = boundary->GetNumberOfPoints();
142 vtkIdList* boundaryPointIds = vtkIdList::New();
143 boundaryPointIds->SetNumberOfIds(numberOfBoundaryPoints);
144 for (int j=0; j<numberOfBoundaryPoints; j++)
145 {
146 boundaryPointIds->SetId(j,static_cast<vtkIdType>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundary->GetPointId(j))));
147 }
148 newPolys->InsertNextCell(boundaryPointIds);
149 if (markCells)
150 {
151 // An id the caller chose for this boundary is used as it stands; CellEntityIdOffset is
152 // what moves the ids this filter derives itself out of the way of the input's, and has
153 // no business shifting one that was picked deliberately.
154 // With the labels in use the boundary's label is its name, so it is also the cap's id
155 // unless the caller chose another; neither is shifted by CellEntityIdOffset.
156 vtkIdType capCellEntityId = useBoundaryLabels ? boundaryId : i+1+this->CellEntityIdOffset;
157 if (this->BoundaryCellEntityIds
158 && boundaryId < this->BoundaryCellEntityIds->GetNumberOfTuples()
159 && this->BoundaryCellEntityIds->GetValue(boundaryId) >= 0)
160 {
161 capCellEntityId = this->BoundaryCellEntityIds->GetValue(boundaryId);
162 }
163 cellEntityIdsArray->InsertNextValue(capCellEntityId);
164 }
165 boundaryPointIds->Delete();
166 }
167
168 output->SetPoints(newPoints);
169 output->SetPolys(newPolys);
170
171 output->GetPointData()->PassData(input->GetPointData());
172
173 if (markCells)
174 {
175 output->GetCellData()->AddArray(cellEntityIdsArray);
176 cellEntityIdsArray->Delete();
177 }
178
179 newPoints->Delete();
180 newPolys->Delete();
181
182 return 1;
183}
static bool GetOrExtractBoundaries(vtkPolyData *surface, const char *boundaryLabelsArrayName, const char *boundaryPointOrderArrayName, vtkPolyData *boundaries, vtkIdList *boundaryLabels, vtkObject *warningSource=nullptr)

Member Data Documentation

◆ BoundaryIds

vtkIdList* vtkvmtkSimpleCapPolyData::BoundaryIds
protected

Definition at line 133 of file vtkvmtkSimpleCapPolyData.h.

◆ CellEntityIdsArrayName

char* vtkvmtkSimpleCapPolyData::CellEntityIdsArrayName
protected

Definition at line 134 of file vtkvmtkSimpleCapPolyData.h.

◆ CellEntityIdOffset

int vtkvmtkSimpleCapPolyData::CellEntityIdOffset
protected

Definition at line 135 of file vtkvmtkSimpleCapPolyData.h.

◆ BoundaryLabelsArrayName

char* vtkvmtkSimpleCapPolyData::BoundaryLabelsArrayName
protected

Definition at line 136 of file vtkvmtkSimpleCapPolyData.h.

◆ BoundaryPointOrderArrayName

char* vtkvmtkSimpleCapPolyData::BoundaryPointOrderArrayName
protected

Definition at line 137 of file vtkvmtkSimpleCapPolyData.h.

◆ BoundaryCellEntityIds

vtkIdTypeArray* vtkvmtkSimpleCapPolyData::BoundaryCellEntityIds
protected

Definition at line 138 of file vtkvmtkSimpleCapPolyData.h.


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