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

Cut a branched, longitudinally/angularly mapped surface into a grid of quadrilateral patches, averaging point data arrays over each patch. More...

#include <vtkvmtkPolyDataPatchingFilter.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataPatchingFilter * NewInstance () const
virtual void SetLongitudinalMappingArrayName (const char *)
virtual char * GetLongitudinalMappingArrayName ()
virtual void SetCircularMappingArrayName (const char *)
virtual char * GetCircularMappingArrayName ()
virtual void SetGroupIdsArrayName (const char *)
virtual char * GetGroupIdsArrayName ()
virtual void SetLongitudinalPatchNumberArrayName (const char *)
virtual char * GetLongitudinalPatchNumberArrayName ()
virtual void SetCircularPatchNumberArrayName (const char *)
virtual char * GetCircularPatchNumberArrayName ()
virtual void SetPatchAreaArrayName (const char *)
virtual char * GetPatchAreaArrayName ()
virtual void SetPatchSize (double, double)
void SetPatchSize (double[2])
virtual double * GetPatchSize ()
virtual void GetPatchSize (double data[2])
virtual void SetPatchOffsets (double, double)
void SetPatchOffsets (double[2])
virtual double * GetPatchOffsets ()
virtual void GetPatchOffsets (double data[2])
virtual void SetLongitudinalPatchBounds (double, double)
void SetLongitudinalPatchBounds (double[2])
virtual double * GetLongitudinalPatchBounds ()
virtual void GetLongitudinalPatchBounds (double data[2])
virtual void SetCircularPatchBounds (double, double)
void SetCircularPatchBounds (double[2])
virtual double * GetCircularPatchBounds ()
virtual void GetCircularPatchBounds (double data[2])
virtual void SetPatchedData (vtkImageData *)
virtual vtkImageData * GetPatchedData ()
virtual void SetCircularPatching (int)
virtual int GetCircularPatching ()
virtual void CircularPatchingOn ()
virtual void CircularPatchingOff ()
virtual void SetUseConnectivity (int)
virtual int GetUseConnectivity ()
virtual void UseConnectivityOn ()
virtual void UseConnectivityOff ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

char * LongitudinalMappingArrayName
char * CircularMappingArrayName
char * GroupIdsArrayName
char * LongitudinalPatchNumberArrayName
char * CircularPatchNumberArrayName
char * PatchAreaArrayName
double PatchSize [2]
double PatchOffsets [2]
double LongitudinalPatchBounds [2]
double CircularPatchBounds [2]
vtkImageData * PatchedData
int CircularPatching
int UseConnectivity

Detailed Description

Cut a branched, longitudinally/angularly mapped surface into a grid of quadrilateral patches, averaging point data arrays over each patch.

Given a surface whose points already carry a longitudinal (abscissa) mapping and, optionally, a circular (angular) mapping array – typically computed per-branch by vtkvmtkPolyDataStretchMappingFilter or an equivalent reference-system-based metric – and a branch GroupIdsArrayName, this filter cuts each branch into a regular grid of patches following iso-contours of these two mapping arrays. Patch dimensions are set through PatchSize (longitudinal height and circular fraction of 2*pi). All point data arrays are area-averaged over each patch and written both onto the output surface (as cell data, one value per patch) and into PatchedData, a vtkImageData whose pixels correspond to patches (one axis per branch/longitudinal slab, the other per circular sector), which is convenient for aligning and statistically comparing this quantity across a population of vessels mapped onto the same parametric grid. This is the filter behind the vmtkbranchpatching pype script.

See also
vtkvmtkPolyDataBranchUtilities, vtkvmtkPolyDataStretchMappingFilter

Definition at line 45 of file vtkvmtkPolyDataPatchingFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataPatchingFilter::Superclass

Definition at line 49 of file vtkvmtkPolyDataPatchingFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataPatchingFilter()

vtkvmtkPolyDataPatchingFilter::vtkvmtkPolyDataPatchingFilter ( )
protected

Definition at line 46 of file vtkvmtkPolyDataPatchingFilter.cxx.

47{
49 this->CircularMappingArrayName = NULL;
50 this->GroupIdsArrayName = NULL;
53 this->PatchAreaArrayName = NULL;
54 this->PatchSize[0] = this->PatchSize[1] = 0.0;
55 this->PatchOffsets[0] = this->PatchOffsets[1] = 0.0;
56 this->LongitudinalPatchBounds[0] = this->LongitudinalPatchBounds[1] = 0.0;
57 this->CircularPatchBounds[0] = this->CircularPatchBounds[1] = 0.0;
58 this->PatchedData = NULL;
59 this->CircularPatching = 1;
60 this->UseConnectivity = 1;
61}

◆ ~vtkvmtkPolyDataPatchingFilter()

vtkvmtkPolyDataPatchingFilter::~vtkvmtkPolyDataPatchingFilter ( )
protected

Definition at line 63 of file vtkvmtkPolyDataPatchingFilter.cxx.

64{
66 {
67 delete[] this->LongitudinalMappingArrayName;
69 }
70
72 {
73 delete[] this->CircularMappingArrayName;
74 this->CircularMappingArrayName = NULL;
75 }
76
78 {
81 }
82
84 {
85 delete[] this->CircularPatchNumberArrayName;
87 }
88
89 if (this->PatchAreaArrayName)
90 {
91 delete[] this->PatchAreaArrayName;
92 this->PatchAreaArrayName = NULL;
93 }
94
95 if (this->PatchedData)
96 {
97 this->PatchedData->Delete();
98 this->PatchedData = NULL;
99 }
100}

Member Function Documentation

◆ New()

vtkvmtkPolyDataPatchingFilter * vtkvmtkPolyDataPatchingFilter::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataPatchingFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataPatchingFilter * vtkvmtkPolyDataPatchingFilter::NewInstance ( ) const

◆ SetLongitudinalMappingArrayName()

virtual void vtkvmtkPolyDataPatchingFilter::SetLongitudinalMappingArrayName ( const char * )
virtual

Set/Get the name of the point data array of the input surface holding the longitudinal (abscissa) mapping used to cut patches along the branch direction. Required input. Commonly named "AbscissaMetric".

◆ GetLongitudinalMappingArrayName()

virtual char * vtkvmtkPolyDataPatchingFilter::GetLongitudinalMappingArrayName ( )
virtual

Set/Get the name of the point data array of the input surface holding the longitudinal (abscissa) mapping used to cut patches along the branch direction. Required input. Commonly named "AbscissaMetric".

◆ SetCircularMappingArrayName()

virtual void vtkvmtkPolyDataPatchingFilter::SetCircularMappingArrayName ( const char * )
virtual

Set/Get the name of the point data array of the input surface holding the circular (angular, in radians over (-pi, +pi]) mapping used to cut patches around the branch circumference. Required input when CircularPatching is on. Commonly named "AngularMetric".

◆ GetCircularMappingArrayName()

virtual char * vtkvmtkPolyDataPatchingFilter::GetCircularMappingArrayName ( )
virtual

Set/Get the name of the point data array of the input surface holding the circular (angular, in radians over (-pi, +pi]) mapping used to cut patches around the branch circumference. Required input when CircularPatching is on. Commonly named "AngularMetric".

◆ SetGroupIdsArrayName()

virtual void vtkvmtkPolyDataPatchingFilter::SetGroupIdsArrayName ( const char * )
virtual

Set/Get the name of the point data array of the input surface holding the branch group id of each point; patches are cut and their longitudinal bounds computed independently for each group. Required input. Commonly named "GroupIds".

◆ GetGroupIdsArrayName()

virtual char * vtkvmtkPolyDataPatchingFilter::GetGroupIdsArrayName ( )
virtual

Set/Get the name of the point data array of the input surface holding the branch group id of each point; patches are cut and their longitudinal bounds computed independently for each group. Required input. Commonly named "GroupIds".

◆ SetLongitudinalPatchNumberArrayName()

virtual void vtkvmtkPolyDataPatchingFilter::SetLongitudinalPatchNumberArrayName ( const char * )
virtual

Set/Get the name of the output cell data array (also written to PatchedData) where the longitudinal patch (slab) index of each patch is stored. Commonly named "Slab".

◆ GetLongitudinalPatchNumberArrayName()

virtual char * vtkvmtkPolyDataPatchingFilter::GetLongitudinalPatchNumberArrayName ( )
virtual

Set/Get the name of the output cell data array (also written to PatchedData) where the longitudinal patch (slab) index of each patch is stored. Commonly named "Slab".

◆ SetCircularPatchNumberArrayName()

virtual void vtkvmtkPolyDataPatchingFilter::SetCircularPatchNumberArrayName ( const char * )
virtual

Set/Get the name of the output cell data array (also written to PatchedData) where the circular patch (sector) index of each patch is stored. Commonly named "Sector".

◆ GetCircularPatchNumberArrayName()

virtual char * vtkvmtkPolyDataPatchingFilter::GetCircularPatchNumberArrayName ( )
virtual

Set/Get the name of the output cell data array (also written to PatchedData) where the circular patch (sector) index of each patch is stored. Commonly named "Sector".

◆ SetPatchAreaArrayName()

virtual void vtkvmtkPolyDataPatchingFilter::SetPatchAreaArrayName ( const char * )
virtual

Set/Get the name of the output cell data array (also written to PatchedData) where the surface area of each patch is stored. Commonly named "PatchArea".

◆ GetPatchAreaArrayName()

virtual char * vtkvmtkPolyDataPatchingFilter::GetPatchAreaArrayName ( )
virtual

Set/Get the name of the output cell data array (also written to PatchedData) where the surface area of each patch is stored. Commonly named "PatchArea".

◆ SetPatchSize() [1/2]

virtual void vtkvmtkPolyDataPatchingFilter::SetPatchSize ( double ,
double  )
virtual

Set/Get the size of each patch: PatchSize[0] is the longitudinal extent (in the units of LongitudinalMappingArrayName, e.g. mm of arc length), PatchSize[1] is the circular extent expressed as a fraction of the full circle (2*pi); e.g. 1.0/N to cut N equal sectors. Default: (0,0).

◆ SetPatchSize() [2/2]

void vtkvmtkPolyDataPatchingFilter::SetPatchSize ( double [2])

Set/Get the size of each patch: PatchSize[0] is the longitudinal extent (in the units of LongitudinalMappingArrayName, e.g. mm of arc length), PatchSize[1] is the circular extent expressed as a fraction of the full circle (2*pi); e.g. 1.0/N to cut N equal sectors. Default: (0,0).

◆ GetPatchSize() [1/2]

virtual double * vtkvmtkPolyDataPatchingFilter::GetPatchSize ( )
virtual

Set/Get the size of each patch: PatchSize[0] is the longitudinal extent (in the units of LongitudinalMappingArrayName, e.g. mm of arc length), PatchSize[1] is the circular extent expressed as a fraction of the full circle (2*pi); e.g. 1.0/N to cut N equal sectors. Default: (0,0).

◆ GetPatchSize() [2/2]

virtual void vtkvmtkPolyDataPatchingFilter::GetPatchSize ( double data[2])
virtual

Set/Get the size of each patch: PatchSize[0] is the longitudinal extent (in the units of LongitudinalMappingArrayName, e.g. mm of arc length), PatchSize[1] is the circular extent expressed as a fraction of the full circle (2*pi); e.g. 1.0/N to cut N equal sectors. Default: (0,0).

◆ SetPatchOffsets() [1/2]

virtual void vtkvmtkPolyDataPatchingFilter::SetPatchOffsets ( double ,
double  )
virtual

Set/Get the longitudinal and circular offsets (in the same units as PatchSize) added to the patch grid origin, shifting where the first longitudinal/circular patch boundary falls. Default: (0,0).

◆ SetPatchOffsets() [2/2]

void vtkvmtkPolyDataPatchingFilter::SetPatchOffsets ( double [2])

Set/Get the longitudinal and circular offsets (in the same units as PatchSize) added to the patch grid origin, shifting where the first longitudinal/circular patch boundary falls. Default: (0,0).

◆ GetPatchOffsets() [1/2]

virtual double * vtkvmtkPolyDataPatchingFilter::GetPatchOffsets ( )
virtual

Set/Get the longitudinal and circular offsets (in the same units as PatchSize) added to the patch grid origin, shifting where the first longitudinal/circular patch boundary falls. Default: (0,0).

◆ GetPatchOffsets() [2/2]

virtual void vtkvmtkPolyDataPatchingFilter::GetPatchOffsets ( double data[2])
virtual

Set/Get the longitudinal and circular offsets (in the same units as PatchSize) added to the patch grid origin, shifting where the first longitudinal/circular patch boundary falls. Default: (0,0).

◆ SetLongitudinalPatchBounds() [1/2]

virtual void vtkvmtkPolyDataPatchingFilter::SetLongitudinalPatchBounds ( double ,
double  )
virtual

Set/Get the longitudinal mapping range, per branch, over which patches are cut. If left at the default (0,0), the full range of LongitudinalMappingArrayName on each branch is used.

◆ SetLongitudinalPatchBounds() [2/2]

void vtkvmtkPolyDataPatchingFilter::SetLongitudinalPatchBounds ( double [2])

Set/Get the longitudinal mapping range, per branch, over which patches are cut. If left at the default (0,0), the full range of LongitudinalMappingArrayName on each branch is used.

◆ GetLongitudinalPatchBounds() [1/2]

virtual double * vtkvmtkPolyDataPatchingFilter::GetLongitudinalPatchBounds ( )
virtual

Set/Get the longitudinal mapping range, per branch, over which patches are cut. If left at the default (0,0), the full range of LongitudinalMappingArrayName on each branch is used.

◆ GetLongitudinalPatchBounds() [2/2]

virtual void vtkvmtkPolyDataPatchingFilter::GetLongitudinalPatchBounds ( double data[2])
virtual

Set/Get the longitudinal mapping range, per branch, over which patches are cut. If left at the default (0,0), the full range of LongitudinalMappingArrayName on each branch is used.

◆ SetCircularPatchBounds() [1/2]

virtual void vtkvmtkPolyDataPatchingFilter::SetCircularPatchBounds ( double ,
double  )
virtual

Set/Get the circular mapping range (in radians) over which patches are cut, used when CircularPatching is on. If left at the default (0,0), the full circle (-pi, +pi) is used.

◆ SetCircularPatchBounds() [2/2]

void vtkvmtkPolyDataPatchingFilter::SetCircularPatchBounds ( double [2])

Set/Get the circular mapping range (in radians) over which patches are cut, used when CircularPatching is on. If left at the default (0,0), the full circle (-pi, +pi) is used.

◆ GetCircularPatchBounds() [1/2]

virtual double * vtkvmtkPolyDataPatchingFilter::GetCircularPatchBounds ( )
virtual

Set/Get the circular mapping range (in radians) over which patches are cut, used when CircularPatching is on. If left at the default (0,0), the full circle (-pi, +pi) is used.

◆ GetCircularPatchBounds() [2/2]

virtual void vtkvmtkPolyDataPatchingFilter::GetCircularPatchBounds ( double data[2])
virtual

Set/Get the circular mapping range (in radians) over which patches are cut, used when CircularPatching is on. If left at the default (0,0), the full circle (-pi, +pi) is used.

◆ SetPatchedData()

virtual void vtkvmtkPolyDataPatchingFilter::SetPatchedData ( vtkImageData * )
virtual

Set/Get the image data holding, one pixel per patch (longitudinal slabs stacked along one axis, circular sectors along the other), the area-averaged value of every point data array of the input surface, plus LongitudinalPatchNumberArrayName, CircularPatchNumberArrayName and PatchAreaArrayName. Populated by this filter; not meant to be set directly by the caller.

◆ GetPatchedData()

virtual vtkImageData * vtkvmtkPolyDataPatchingFilter::GetPatchedData ( )
virtual

Set/Get the image data holding, one pixel per patch (longitudinal slabs stacked along one axis, circular sectors along the other), the area-averaged value of every point data array of the input surface, plus LongitudinalPatchNumberArrayName, CircularPatchNumberArrayName and PatchAreaArrayName. Populated by this filter; not meant to be set directly by the caller.

◆ SetCircularPatching()

virtual void vtkvmtkPolyDataPatchingFilter::SetCircularPatching ( int )
virtual

Toggle cutting patches in the circular direction as well as the longitudinal one. When off, each branch is only cut into longitudinal slabs (one patch per slab) and CircularMappingArrayName is not required. Default: on.

◆ GetCircularPatching()

virtual int vtkvmtkPolyDataPatchingFilter::GetCircularPatching ( )
virtual

Toggle cutting patches in the circular direction as well as the longitudinal one. When off, each branch is only cut into longitudinal slabs (one patch per slab) and CircularMappingArrayName is not required. Default: on.

◆ CircularPatchingOn()

virtual void vtkvmtkPolyDataPatchingFilter::CircularPatchingOn ( )
virtual

Toggle cutting patches in the circular direction as well as the longitudinal one. When off, each branch is only cut into longitudinal slabs (one patch per slab) and CircularMappingArrayName is not required. Default: on.

◆ CircularPatchingOff()

virtual void vtkvmtkPolyDataPatchingFilter::CircularPatchingOff ( )
virtual

Toggle cutting patches in the circular direction as well as the longitudinal one. When off, each branch is only cut into longitudinal slabs (one patch per slab) and CircularMappingArrayName is not required. Default: on.

◆ SetUseConnectivity()

virtual void vtkvmtkPolyDataPatchingFilter::SetUseConnectivity ( int )
virtual

Toggle restricting each cut patch to its largest connected region (via vtkPolyDataConnectivityFilter) before averaging, discarding smaller disconnected fragments that can result from clipping a non-convex cross-section. Default: on.

◆ GetUseConnectivity()

virtual int vtkvmtkPolyDataPatchingFilter::GetUseConnectivity ( )
virtual

Toggle restricting each cut patch to its largest connected region (via vtkPolyDataConnectivityFilter) before averaging, discarding smaller disconnected fragments that can result from clipping a non-convex cross-section. Default: on.

◆ UseConnectivityOn()

virtual void vtkvmtkPolyDataPatchingFilter::UseConnectivityOn ( )
virtual

Toggle restricting each cut patch to its largest connected region (via vtkPolyDataConnectivityFilter) before averaging, discarding smaller disconnected fragments that can result from clipping a non-convex cross-section. Default: on.

◆ UseConnectivityOff()

virtual void vtkvmtkPolyDataPatchingFilter::UseConnectivityOff ( )
virtual

Toggle restricting each cut patch to its largest connected region (via vtkPolyDataConnectivityFilter) before averaging, discarding smaller disconnected fragments that can result from clipping a non-convex cross-section. Default: on.

◆ RequestData()

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

Definition at line 102 of file vtkvmtkPolyDataPatchingFilter.cxx.

106{
107 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
108 vtkInformation *outInfo = outputVector->GetInformationObject(0);
109
110 vtkPolyData *input = vtkPolyData::SafeDownCast(
111 inInfo->Get(vtkDataObject::DATA_OBJECT()));
112 vtkPolyData *output = vtkPolyData::SafeDownCast(
113 outInfo->Get(vtkDataObject::DATA_OBJECT()));
114
116 {
117 vtkErrorMacro(<<"LongitudinalPatchNumberArrayName not set.");
118 return 1;
119 }
120
122 {
123 vtkErrorMacro(<<"CircularPatchNumberArrayName not set.");
124 return 1;
125 }
126
127 if (!this->PatchAreaArrayName)
128 {
129 vtkErrorMacro(<<"PatchAreaArrayName not set.");
130 return 1;
131 }
132
134 {
135 vtkErrorMacro(<<"LongitudinalMappingArrayName not set.");
136 return 1;
137 }
138
139 vtkDataArray* longitudinalMappingArray = input->GetPointData()->GetArray(this->LongitudinalMappingArrayName);
140
141 if (!longitudinalMappingArray)
142 {
143 vtkErrorMacro(<<"LongitudinalMappingArray with name specified does not exist.");
144 return 1;
145 }
146
147 vtkDataArray* circularMappingArray = NULL;
148 if (this->CircularPatching)
149 {
150
151 if (!this->CircularMappingArrayName)
152 {
153 vtkErrorMacro(<<"CircularMappingArrayName not set.");
154 return 1;
155 }
156
157 circularMappingArray = input->GetPointData()->GetArray(this->CircularMappingArrayName);
158
159 if (!circularMappingArray)
160 {
161 vtkErrorMacro(<<"CircularMappingArray with name specified does not exist.");
162 return 1;
163 }
164 }
165
166 if (!this->GroupIdsArrayName)
167 {
168 vtkErrorMacro(<<"GroupIdsArrayName not set.");
169 return 1;
170 }
171
172 vtkDataArray* groupIdsArray = input->GetPointData()->GetArray(this->GroupIdsArrayName);
173
174 if (!groupIdsArray)
175 {
176 vtkErrorMacro(<<"GroupIdsArray with name specified does not exist.");
177 return 1;
178 }
179
180 int numberOfInputPoints = input->GetNumberOfPoints();
181
182 double circumferentialActualPatchSize = this->PatchSize[1] * 2.0 * vtkMath::Pi();
183
184 char shiftedCircularMapping90ArrayName[] = "ShiftedCircularMapping90";
185 char shiftedCircularMapping180ArrayName[] = "ShiftedCircularMapping180";
186 char shiftedCircularMapping270ArrayName[] = "ShiftedCircularMapping270";
187
188 vtkDoubleArray* shiftedCircularMapping90Array = vtkDoubleArray::New();
189 shiftedCircularMapping90Array->SetName(shiftedCircularMapping90ArrayName);
190 shiftedCircularMapping90Array->SetNumberOfComponents(1);
191 shiftedCircularMapping90Array->SetNumberOfTuples(numberOfInputPoints);
192 vtkDoubleArray* shiftedCircularMapping180Array = vtkDoubleArray::New();
193 shiftedCircularMapping180Array->SetName(shiftedCircularMapping180ArrayName);
194 shiftedCircularMapping180Array->SetNumberOfComponents(1);
195 shiftedCircularMapping180Array->SetNumberOfTuples(numberOfInputPoints);
196 vtkDoubleArray* shiftedCircularMapping270Array = vtkDoubleArray::New();
197 shiftedCircularMapping270Array->SetName(shiftedCircularMapping270ArrayName);
198 shiftedCircularMapping270Array->SetNumberOfComponents(1);
199 shiftedCircularMapping270Array->SetNumberOfTuples(numberOfInputPoints);
200
201 int i;
202 if (this->CircularPatching)
203 {
204 for (i=0; i<numberOfInputPoints; i++)
205 {
206 double value = circularMappingArray->GetComponent(i,0);
207 double shiftedValue = value + 0.5 * vtkMath::Pi();
208 if (shiftedValue > vtkMath::Pi())
209 {
210 shiftedValue -= 2.0 * vtkMath::Pi();
211 }
212 shiftedCircularMapping90Array->SetValue(i,shiftedValue);
213 shiftedValue = value + vtkMath::Pi();
214 if (shiftedValue > vtkMath::Pi())
215 {
216 shiftedValue -= 2.0 * vtkMath::Pi();
217 }
218 shiftedCircularMapping180Array->SetValue(i,shiftedValue);
219 shiftedValue = value + 1.5 * vtkMath::Pi();
220 if (shiftedValue > vtkMath::Pi())
221 {
222 shiftedValue -= 2.0 * vtkMath::Pi();
223 }
224 shiftedCircularMapping270Array->SetValue(i,shiftedValue);
225 }
226 }
227 else
228 {
229 shiftedCircularMapping90Array->FillComponent(0,0.0);
230 shiftedCircularMapping180Array->FillComponent(0,0.0);
231 shiftedCircularMapping270Array->FillComponent(0,0.0);
232 }
233
234 input->GetPointData()->AddArray(shiftedCircularMapping90Array);
235 input->GetPointData()->AddArray(shiftedCircularMapping180Array);
236 input->GetPointData()->AddArray(shiftedCircularMapping270Array);
237
238 if (this->PatchedData)
239 {
240 this->PatchedData->Delete();
241 this->PatchedData = NULL;
242 }
243
244 this->PatchedData = vtkImageData::New();
245
246 vtkPointData* patchedDataPointData = this->PatchedData->GetPointData();
247 patchedDataPointData->CopyAllocate(input->GetPointData(),0);
248
249 vtkIntArray* patchedDataLongitudinalPatchNumberArray = vtkIntArray::New();
250 patchedDataLongitudinalPatchNumberArray->SetName(this->LongitudinalPatchNumberArrayName);
251 patchedDataLongitudinalPatchNumberArray->SetNumberOfComponents(1);
252
253 vtkIntArray* patchedDataCircularPatchNumberArray = vtkIntArray::New();
254 patchedDataCircularPatchNumberArray->SetName(this->CircularPatchNumberArrayName);
255 patchedDataCircularPatchNumberArray->SetNumberOfComponents(1);
256
257 vtkDoubleArray* patchedDataPatchAreaArray = vtkDoubleArray::New();
258 patchedDataPatchAreaArray->SetName(this->PatchAreaArrayName);
259 patchedDataPatchAreaArray->SetNumberOfComponents(1);
260
261 vtkAppendPolyData* patchAppendFilter = vtkAppendPolyData::New();
262
263 if (this->CircularPatchBounds[0] == 0.0 && this->CircularPatchBounds[1] == 0.0)
264 {
265 this->CircularPatchBounds[0] = - vtkMath::Pi();
266 this->CircularPatchBounds[1] = vtkMath::Pi();
267 }
268
269 int circularPatchStartIndex = 0;
270 int circularPatchEndIndex = 0;
271
272 if (this->CircularPatching)
273 {
274 circularPatchStartIndex = vtkMath::Floor((this->CircularPatchBounds[0] - this->PatchOffsets[1]) / circumferentialActualPatchSize);
275 if (circularPatchStartIndex*circumferentialActualPatchSize - this->PatchOffsets[1] < - vtkMath::Pi())
276 {
277 circularPatchStartIndex += 1;
278 }
279 circularPatchEndIndex = vtkMath::Floor((this->CircularPatchBounds[1] - this->PatchOffsets[1] - 1E-3 * circumferentialActualPatchSize) / circumferentialActualPatchSize);
280 }
281
282 int numberOfPreviousPatchDataLines = 0;
283 vtkIdList* groupIds = vtkIdList::New();
285 for (i=0; i<groupIds->GetNumberOfIds(); i++)
286 {
287 vtkIdType groupId = groupIds->GetId(i);
288 vtkPolyData* cylinder = vtkPolyData::New();
289 vtkvmtkPolyDataBranchUtilities::ExtractGroup(input,this->GroupIdsArrayName,groupId,true,cylinder);
290
291 longitudinalMappingArray = cylinder->GetPointData()->GetArray(this->LongitudinalMappingArrayName);
292 circularMappingArray = cylinder->GetPointData()->GetArray(this->CircularMappingArrayName);
293
294 cylinder->GetPointData()->SetActiveScalars(this->LongitudinalMappingArrayName);
295
296 vtkClipPolyData* longitudinalClipper0 = vtkClipPolyData::New();
297 longitudinalClipper0->SetInputData(cylinder);
298 longitudinalClipper0->GenerateClipScalarsOff();
299 longitudinalClipper0->InsideOutOff();
300
301 vtkClipPolyData* longitudinalClipper1 = vtkClipPolyData::New();
302 longitudinalClipper1->SetInputConnection(longitudinalClipper0->GetOutputPort());
303 longitudinalClipper1->GenerateClipScalarsOff();
304 longitudinalClipper1->InsideOutOn();
305
306 vtkClipPolyData* circularClipper0 = vtkClipPolyData::New();
307 circularClipper0->SetInputConnection(longitudinalClipper1->GetOutputPort());
308 circularClipper0->GenerateClipScalarsOff();
309 circularClipper0->InsideOutOff();
310
311 vtkClipPolyData* circularClipper1 = vtkClipPolyData::New();
312 circularClipper1->SetInputConnection(circularClipper0->GetOutputPort());
313 circularClipper1->GenerateClipScalarsOff();
314 circularClipper1->InsideOutOn();
315
316 vtkPolyDataConnectivityFilter* patchConnectivityFilter = vtkPolyDataConnectivityFilter::New();
317 patchConnectivityFilter->SetInputConnection(circularClipper1->GetOutputPort());
318 patchConnectivityFilter->SetExtractionModeToLargestRegion();
319
320 double longitudinalMappingRange[2];
321
322 longitudinalMappingArray->GetRange(longitudinalMappingRange,0);
323
324 double longitudinalCylinderPatchBounds[2];
325
326 if (this->LongitudinalPatchBounds[0] == 0.0 && this->LongitudinalPatchBounds[1] == 0.0)
327 {
328 longitudinalCylinderPatchBounds[0] = longitudinalMappingRange[0];
329 longitudinalCylinderPatchBounds[1] = longitudinalMappingRange[1];
330 }
331 else
332 {
333 longitudinalCylinderPatchBounds[0] = this->LongitudinalPatchBounds[0];
334 longitudinalCylinderPatchBounds[1] = this->LongitudinalPatchBounds[1];
335 }
336
337 int longitudinalPatchStartIndex = vtkMath::Floor((longitudinalCylinderPatchBounds[0] - this->PatchOffsets[0]) / this->PatchSize[0]);
338 int longitudinalPatchEndIndex = vtkMath::Floor((longitudinalCylinderPatchBounds[1] - this->PatchOffsets[0] - 1E-3 * this->PatchSize[0]) / this->PatchSize[0]);
339
340 int j, k;
341 for (j=longitudinalPatchStartIndex; j<=longitudinalPatchEndIndex; j++)
342 {
343 double longitudinalPatchStart = this->PatchOffsets[0] + j * this->PatchSize[0];
344 double longitudinalPatchEnd = this->PatchOffsets[0] + (j+1) * this->PatchSize[0];
345
346 longitudinalClipper0->SetValue(longitudinalPatchStart);
347 longitudinalClipper1->SetValue(longitudinalPatchEnd);
348 longitudinalClipper1->Update();
349
350 if (longitudinalClipper1->GetOutput()->GetNumberOfPoints() == 0)
351 {
352 continue;
353 }
354
355 for (k=circularPatchStartIndex; k<=circularPatchEndIndex; k++)
356 {
357 int patchId = k - circularPatchStartIndex + (j - longitudinalPatchStartIndex) * (circularPatchEndIndex-circularPatchStartIndex+1) + numberOfPreviousPatchDataLines * (circularPatchEndIndex-circularPatchStartIndex+1);
358 double circularPatchCenter = 0.0;
359 double shiftedCircularPatchCenter = 0.0;
360 char* patchShiftedCircularMappingArrayName = NULL;
361
362 if (this->CircularPatching)
363 {
364 double circularPatchStart = this->PatchOffsets[1] + k * circumferentialActualPatchSize;
365 double circularPatchEnd = this->PatchOffsets[1] + (k+1) * circumferentialActualPatchSize;
366
367 double pi = vtkMath::Pi();
368
369 if (circularPatchStart < -pi)
370 {
371 circularPatchStart += 2.0 * pi;
372 circularPatchEnd += 2.0 * pi;
373 }
374
375 circularPatchCenter = 0.5 * (circularPatchStart + circularPatchEnd);
376
377// if (circularPatchStart < pi && circularPatchEnd > pi)
378 if (circularPatchCenter <= - 0.75 * pi || circularPatchCenter >= 0.75 * pi)
379 {
380 patchShiftedCircularMappingArrayName = shiftedCircularMapping180ArrayName;
381 if (circularPatchCenter <= - 0.75 * pi)
382 {
383 circularPatchStart += pi;
384 circularPatchEnd += pi;
385 }
386 else if (circularPatchCenter >= 0.75 * pi)
387 {
388 circularPatchStart -= pi;
389 circularPatchEnd -= pi;
390 }
391 }
392// else if (circularPatchStart < 0.5 * pi && circularPatchEnd > 0.5 * pi)
393 else if (circularPatchCenter >= 0.25 * pi && circularPatchCenter < 0.75 * pi)
394 {
395 patchShiftedCircularMappingArrayName = shiftedCircularMapping270ArrayName;
396 circularPatchStart -= 0.5 * pi;
397 circularPatchEnd -= 0.5 * pi;
398 }
399// else if (circularPatchStart < -0.5 * pi && circularPatchEnd > -0.5 * pi)
400 else if (circularPatchCenter > -0.75 * pi && circularPatchCenter <= -0.25 * pi)
401 {
402 patchShiftedCircularMappingArrayName = shiftedCircularMapping90ArrayName;
403 circularPatchStart += 0.5 * pi;
404 circularPatchEnd += 0.5 * pi;
405 }
406 else
407 {
408 patchShiftedCircularMappingArrayName = this->CircularMappingArrayName;
409 }
410
411 longitudinalClipper1->GetOutput()->GetPointData()->SetActiveScalars(patchShiftedCircularMappingArrayName);
412
413 shiftedCircularPatchCenter = 0.5 * (circularPatchStart + circularPatchEnd);
414
415 circularClipper0->Modified();
416 circularClipper0->SetValue(circularPatchStart);
417 circularClipper1->SetValue(circularPatchEnd);
418 circularClipper1->Update();
419
420 if (circularClipper1->GetOutput()->GetNumberOfPoints() == 0)
421 {
422 continue;
423 }
424 }
425
426 vtkTriangleFilter* patchTriangleFilter = vtkTriangleFilter::New();
427
428 if (this->UseConnectivity)
429 {
430 if (this->CircularPatching)
431 {
432 patchConnectivityFilter->SetInputConnection(circularClipper1->GetOutputPort());
433 }
434 else
435 {
436 patchConnectivityFilter->SetInputConnection(longitudinalClipper1->GetOutputPort());
437 }
438 patchConnectivityFilter->Update();
439 patchTriangleFilter->SetInputConnection(patchConnectivityFilter->GetOutputPort());
440 }
441 else
442 {
443 if (this->CircularPatching)
444 {
445 patchTriangleFilter->SetInputConnection(circularClipper1->GetOutputPort());
446 }
447 else
448 {
449 patchTriangleFilter->SetInputConnection(longitudinalClipper1->GetOutputPort());
450 }
451 }
452
453 patchTriangleFilter->Update();
454
455 vtkPolyData* patch = vtkPolyData::New();
456 patch->DeepCopy(patchTriangleFilter->GetOutput());
457
458 patch->BuildCells();
459 int patchNumberOfCells = patch->GetNumberOfCells();
460
461 if (this->CircularPatching)
462 {
463 vtkDataArray* patchCircularMappingArray = patch->GetPointData()->GetArray(this->CircularMappingArrayName);
464 vtkDataArray* patchShiftedCircularMappingArray = patch->GetPointData()->GetArray(patchShiftedCircularMappingArrayName);
465
466 double angularOffset = circularPatchCenter - shiftedCircularPatchCenter;
467
468 vtkIdType patchNumberOfPoints = patch->GetNumberOfPoints();
469 vtkIdType pointId;
470 for (pointId=0; pointId<patchNumberOfPoints; pointId++)
471 {
472 double circularMappingValue = patchShiftedCircularMappingArray->GetTuple1(pointId);
473 circularMappingValue += angularOffset;
474 patchCircularMappingArray->SetTuple1(pointId,circularMappingValue);
475 }
476 }
477
478 vtkIntArray* longitudinalPatchNumberArray = vtkIntArray::New();
479 longitudinalPatchNumberArray->SetName(this->LongitudinalPatchNumberArrayName);
480 longitudinalPatchNumberArray->SetNumberOfComponents(1);
481 longitudinalPatchNumberArray->SetNumberOfTuples(patchNumberOfCells);
482
483 vtkIntArray* circularPatchNumberArray = vtkIntArray::New();
484 circularPatchNumberArray->SetName(this->CircularPatchNumberArrayName);
485 circularPatchNumberArray->SetNumberOfComponents(1);
486 circularPatchNumberArray->SetNumberOfTuples(patchNumberOfCells);
487
488 vtkDoubleArray* patchAreaArray = vtkDoubleArray::New();
489 patchAreaArray->SetName(this->PatchAreaArrayName);
490 patchAreaArray->SetNumberOfComponents(1);
491 patchAreaArray->SetNumberOfTuples(patchNumberOfCells);
492
493 double patchArea = 0.0;
494
495 vtkPointData* patchPointData = patch->GetPointData();
496
497 vtkCellData* patchCellData = vtkCellData::New();
498 patchCellData->CopyAllocate(patchPointData,patchNumberOfCells);
499
500 vtkCellData* patchedPatchCellData = patch->GetCellData();
501 patchedPatchCellData->CopyAllocate(patchCellData,patchNumberOfCells);
502
503 int cellId;
504 for (cellId=0; cellId < patchNumberOfCells; cellId++)
505 {
506 vtkTriangle* triangle = vtkTriangle::SafeDownCast(patch->GetCell(cellId));
507 if (!triangle)
508 {
509 continue;
510 }
511
512 double point0[3], point1[3], point2[3];
513 triangle->GetPoints()->GetPoint(0,point0);
514 triangle->GetPoints()->GetPoint(1,point1);
515 triangle->GetPoints()->GetPoint(2,point2);
516 patchArea += vtkTriangle::TriangleArea(point0,point1,point2);
517
518 double weights[3];
519 weights[1] = 1.0/3.0;
520 weights[2] = 1.0/3.0;
521 weights[0] = (1.0 - weights[1] - weights[2]);
522
523 patchCellData->InterpolatePoint(patchPointData,cellId,triangle->GetPointIds(),weights);
524 }
525
526 for (cellId = 0; cellId < patchNumberOfCells; cellId++)
527 {
528 longitudinalPatchNumberArray->SetValue(cellId,j);
529 circularPatchNumberArray->SetValue(cellId,k);
530 patchAreaArray->SetValue(cellId,patchArea);
531 }
532
533 patchedDataLongitudinalPatchNumberArray->InsertValue(patchId,j);
534 patchedDataCircularPatchNumberArray->InsertValue(patchId,k);
535 patchedDataPatchAreaArray->InsertValue(patchId,patchArea);
536
537 int numberOfArrays = patchCellData->GetNumberOfArrays();
538 int arrayId;
539 for (arrayId = 0; arrayId<numberOfArrays; arrayId++)
540 {
541 vtkDataArray* patchArray = patchCellData->GetArray(arrayId);
542 vtkDataArray* patchedArray = patchedPatchCellData->GetArray(patchArray->GetName());
543 vtkDataArray* patchedDataArray = patchedDataPointData->GetArray(arrayId);
544 if (!patchedArray)
545 {
546 continue;
547 }
548
549 int dataType = patchArray->GetDataType();
550 if (dataType != VTK_FLOAT && dataType != VTK_DOUBLE)
551 {
552 for (cellId = 0; cellId < patchNumberOfCells; cellId++)
553 {
554 patchedArray->InsertTuple(cellId,patchArray->GetTuple(cellId));
555 }
556 if (patchNumberOfCells > 0)
557 {
558 patchedDataArray->InsertTuple(patchId,patchArray->GetTuple(0));
559 }
560 continue;
561 }
562
563 double* integralTuple = new double[patchArray->GetNumberOfComponents()];
564 int componentId;
565 for (componentId = 0; componentId < patchArray->GetNumberOfComponents(); componentId++)
566 {
567 integralTuple[componentId] = 0.0;
568 }
569 for (cellId = 0; cellId < patchNumberOfCells; cellId++)
570 {
571 vtkTriangle* triangle = vtkTriangle::SafeDownCast(patch->GetCell(cellId));
572 if (!triangle)
573 {
574 continue;
575 }
576 double point0[3], point1[3], point2[3];
577 triangle->GetPoints()->GetPoint(0,point0);
578 triangle->GetPoints()->GetPoint(1,point1);
579 triangle->GetPoints()->GetPoint(2,point2);
580 double area = vtkTriangle::TriangleArea(point0,point1,point2);
581
582 for (componentId = 0; componentId < patchArray->GetNumberOfComponents(); componentId++)
583 {
584 integralTuple[componentId] += area * patchArray->GetComponent(cellId,componentId);
585 }
586 }
587 for (componentId = 0; componentId < patchArray->GetNumberOfComponents(); componentId++)
588 {
589 integralTuple[componentId] /= patchArea;
590 }
591 for (cellId = 0; cellId < patchNumberOfCells; cellId++)
592 {
593 patchedArray->InsertTuple(cellId,integralTuple);
594 }
595
596 patchedDataArray->InsertTuple(patchId,integralTuple);
597
598 delete[] integralTuple;
599 }
600
601 patch->GetCellData()->AddArray(longitudinalPatchNumberArray);
602 patch->GetCellData()->AddArray(circularPatchNumberArray);
603 patch->GetCellData()->AddArray(patchAreaArray);
604
605 patchAppendFilter->AddInputData(patch);
606
607 patch->Delete();
608 patchTriangleFilter->Delete();
609 patchCellData->Delete();
610 longitudinalPatchNumberArray->Delete();
611 circularPatchNumberArray->Delete();
612 patchAreaArray->Delete();
613 }
614 }
615
616 cylinder->Delete();
617
618 longitudinalClipper0->Delete();
619 longitudinalClipper1->Delete();
620 circularClipper0->Delete();
621 circularClipper1->Delete();
622 patchConnectivityFilter->Delete();
623
624 numberOfPreviousPatchDataLines += longitudinalPatchEndIndex - longitudinalPatchStartIndex + 1;
625 }
626 groupIds->Delete();
627
628 this->PatchedData->SetOrigin(0.0,0.0,0.0);
629 this->PatchedData->SetSpacing(circumferentialActualPatchSize,this->PatchSize[0],1.0);
630 this->PatchedData->SetExtent(0,circularPatchEndIndex-circularPatchStartIndex,0,numberOfPreviousPatchDataLines-1,0,0);
631
632 this->PatchedData->GetPointData()->AddArray(patchedDataLongitudinalPatchNumberArray);
633 this->PatchedData->GetPointData()->AddArray(patchedDataCircularPatchNumberArray);
634 this->PatchedData->GetPointData()->AddArray(patchedDataPatchAreaArray);
635
636 this->PatchedData->GetPointData()->RemoveArray(shiftedCircularMapping90ArrayName);
637 this->PatchedData->GetPointData()->RemoveArray(shiftedCircularMapping180ArrayName);
638 this->PatchedData->GetPointData()->RemoveArray(shiftedCircularMapping270ArrayName);
639
640 patchAppendFilter->Update();
641 output->DeepCopy(patchAppendFilter->GetOutput());
642
643 output->GetPointData()->RemoveArray(shiftedCircularMapping90ArrayName);
644 output->GetPointData()->RemoveArray(shiftedCircularMapping180ArrayName);
645 output->GetPointData()->RemoveArray(shiftedCircularMapping270ArrayName);
646 output->GetCellData()->RemoveArray(shiftedCircularMapping90ArrayName);
647 output->GetCellData()->RemoveArray(shiftedCircularMapping180ArrayName);
648 output->GetCellData()->RemoveArray(shiftedCircularMapping270ArrayName);
649
650 input->GetPointData()->RemoveArray(shiftedCircularMapping90ArrayName);
651 input->GetPointData()->RemoveArray(shiftedCircularMapping180ArrayName);
652 input->GetPointData()->RemoveArray(shiftedCircularMapping270ArrayName);
653
654 patchedDataLongitudinalPatchNumberArray->Delete();
655 patchedDataCircularPatchNumberArray->Delete();
656 patchedDataPatchAreaArray->Delete();
657
658 patchAppendFilter->Delete();
659
660 shiftedCircularMapping90Array->Delete();
661 shiftedCircularMapping180Array->Delete();
662 shiftedCircularMapping270Array->Delete();
663
664 return 1;
665}
static void ExtractGroup(vtkPolyData *surface, const char *groupIdsArrayName, vtkIdType groupId, bool cleanGroupSurface, vtkPolyData *groupSurface)
static void GetGroupsIdList(vtkPolyData *surface, const char *groupIdsArrayName, vtkIdList *groupIds)

Member Data Documentation

◆ LongitudinalMappingArrayName

char* vtkvmtkPolyDataPatchingFilter::LongitudinalMappingArrayName
protected

Definition at line 189 of file vtkvmtkPolyDataPatchingFilter.h.

◆ CircularMappingArrayName

char* vtkvmtkPolyDataPatchingFilter::CircularMappingArrayName
protected

Definition at line 190 of file vtkvmtkPolyDataPatchingFilter.h.

◆ GroupIdsArrayName

char* vtkvmtkPolyDataPatchingFilter::GroupIdsArrayName
protected

Definition at line 191 of file vtkvmtkPolyDataPatchingFilter.h.

◆ LongitudinalPatchNumberArrayName

char* vtkvmtkPolyDataPatchingFilter::LongitudinalPatchNumberArrayName
protected

Definition at line 193 of file vtkvmtkPolyDataPatchingFilter.h.

◆ CircularPatchNumberArrayName

char* vtkvmtkPolyDataPatchingFilter::CircularPatchNumberArrayName
protected

Definition at line 194 of file vtkvmtkPolyDataPatchingFilter.h.

◆ PatchAreaArrayName

char* vtkvmtkPolyDataPatchingFilter::PatchAreaArrayName
protected

Definition at line 196 of file vtkvmtkPolyDataPatchingFilter.h.

◆ PatchSize

double vtkvmtkPolyDataPatchingFilter::PatchSize[2]
protected

Definition at line 198 of file vtkvmtkPolyDataPatchingFilter.h.

◆ PatchOffsets

double vtkvmtkPolyDataPatchingFilter::PatchOffsets[2]
protected

Definition at line 199 of file vtkvmtkPolyDataPatchingFilter.h.

◆ LongitudinalPatchBounds

double vtkvmtkPolyDataPatchingFilter::LongitudinalPatchBounds[2]
protected

Definition at line 200 of file vtkvmtkPolyDataPatchingFilter.h.

◆ CircularPatchBounds

double vtkvmtkPolyDataPatchingFilter::CircularPatchBounds[2]
protected

Definition at line 201 of file vtkvmtkPolyDataPatchingFilter.h.

◆ PatchedData

vtkImageData* vtkvmtkPolyDataPatchingFilter::PatchedData
protected

Definition at line 203 of file vtkvmtkPolyDataPatchingFilter.h.

◆ CircularPatching

int vtkvmtkPolyDataPatchingFilter::CircularPatching
protected

Definition at line 205 of file vtkvmtkPolyDataPatchingFilter.h.

◆ UseConnectivity

int vtkvmtkPolyDataPatchingFilter::UseConnectivity
protected

Definition at line 206 of file vtkvmtkPolyDataPatchingFilter.h.


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