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

Obtain sections of an unstructured grid mesh that lie along a centerline path. More...

#include <vtkvmtkUnstructuredGridCenterlineSections.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkUnstructuredGridCenterlineSections * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual vtkPolyData * GetSectionPointsPolyData ()
virtual void SetCenterlines (vtkPolyData *)
virtual vtkPolyData * GetCenterlines ()
virtual void SetSectionSource (vtkPolyData *)
virtual vtkPolyData * GetSectionSource ()
virtual void SetSectionUpNormalsArrayName (const char *)
virtual char * GetSectionUpNormalsArrayName ()
virtual void SetSectionNormalsArrayName (const char *)
virtual char * GetSectionNormalsArrayName ()
virtual void SetAdditionalNormalsArrayName (const char *)
virtual char * GetAdditionalNormalsArrayName ()
virtual void SetAdditionalScalarsArrayName (const char *)
virtual char * GetAdditionalScalarsArrayName ()
virtual void SetTransformSections (int)
virtual int GetTransformSections ()
virtual void TransformSectionsOn ()
virtual void TransformSectionsOff ()
virtual void SetUseSectionSource (int)
virtual int GetUseSectionSource ()
virtual void UseSectionSourceOn ()
virtual void UseSectionSourceOff ()
virtual void SetSourceScaling (int)
virtual int GetSourceScaling ()
virtual void SourceScalingOn ()
virtual void SourceScalingOff ()
virtual void SetOriginOffset (double data[])
virtual double * GetOriginOffset ()
virtual void GetOriginOffset (double data[3])
virtual void SetVectorsArrayName (const char *)
virtual char * GetVectorsArrayName ()
virtual void SetSectionIdsArrayName (const char *)
virtual char * GetSectionIdsArrayName ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkUnstructuredGridCenterlineSections ()
 ~vtkvmtkUnstructuredGridCenterlineSections ()
int FillInputPortInformation (int, vtkInformation *info) override
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
double ComputeAngle (double vector0[3], double vector1[3])
void CreateTransform (vtkTransform *transform, double currentOrigin[3], double currentNormal[3], double currentUpNormal[3], double targetOrigin[3], double targetNormal[3], double targetUpNormal[3])

Protected Attributes

vtkPolyData * Centerlines
vtkPolyData * SectionSource
vtkPolyData * SectionPointsPolyData
char * SectionUpNormalsArrayName
char * SectionNormalsArrayName
char * AdditionalNormalsArrayName
char * AdditionalScalarsArrayName
char * SectionIdsArrayName
char * VectorsArrayName
int TransformSections
int UseSectionSource
int SourceScaling
double OriginOffset [3]

Detailed Description

Obtain sections of an unstructured grid mesh that lie along a centerline path.

Obtain mesh sections (along a centerline) which pass through a dense unstructured grid mesh. This is useful because you can use this data to visualize velocity vectors (or other solutions) along many mesh sections intersecting the centerline.

This is the filter behind the vmtkcenterlinemeshsections pype script, typically used to sample a CFD solution mesh at a dense series of cross-sections along a centerline for post-processing (e.g. visualizing velocity profiles). Despite deriving from vtkPolyDataAlgorithm, it accepts an unstructured grid as input (see FillInputPortInformation).

See also
vtkvmtkPolyDataCenterlineSections

Definition at line 43 of file vtkvmtkUnstructuredGridCenterlineSections.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkUnstructuredGridCenterlineSections()

vtkvmtkUnstructuredGridCenterlineSections::vtkvmtkUnstructuredGridCenterlineSections ( )
protected

Definition at line 53 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

54{
55 this->Centerlines = NULL;
56 this->SectionSource = NULL;
57 this->SectionPointsPolyData = NULL;
58 this->SectionUpNormalsArrayName = NULL;
59 this->SectionNormalsArrayName = NULL;
60 this->AdditionalNormalsArrayName = NULL;
61 this->AdditionalScalarsArrayName = NULL;
62 this->SectionIdsArrayName = NULL;
63 this->TransformSections = 0;
64 this->UseSectionSource = 0;
65 this->SourceScaling = 0;
66 this->OriginOffset[0] = this->OriginOffset[1] = this->OriginOffset[2] = 0.0;
67 this->VectorsArrayName = NULL;
68}

◆ ~vtkvmtkUnstructuredGridCenterlineSections()

vtkvmtkUnstructuredGridCenterlineSections::~vtkvmtkUnstructuredGridCenterlineSections ( )
protected

Definition at line 70 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

71{
72 if (this->Centerlines)
73 {
74 this->Centerlines->Delete();
75 this->Centerlines = NULL;
76 }
77 if (this->SectionSource)
78 {
79 this->SectionSource->Delete();
80 this->SectionSource = NULL;
81 }
82 if (this->SectionPointsPolyData)
83 {
84 this->SectionPointsPolyData->Delete();
85 this->SectionPointsPolyData = NULL;
86 }
88 {
89 delete[] this->SectionUpNormalsArrayName;
90 this->SectionUpNormalsArrayName = NULL;
91 }
93 {
94 delete[] this->SectionNormalsArrayName;
95 this->SectionNormalsArrayName = NULL;
96 }
98 {
99 delete[] this->AdditionalNormalsArrayName;
100 this->AdditionalNormalsArrayName = NULL;
101 }
103 {
104 delete[] this->AdditionalScalarsArrayName;
105 this->AdditionalScalarsArrayName = NULL;
106 }
107 if (this->VectorsArrayName)
108 {
109 delete[] this->VectorsArrayName;
110 this->VectorsArrayName = NULL;
111 }
112 if (this->SectionIdsArrayName)
113 {
114 delete[] this->SectionIdsArrayName;
115 this->SectionIdsArrayName = NULL;
116 }
117}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkUnstructuredGridCenterlineSections::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkUnstructuredGridCenterlineSections * vtkvmtkUnstructuredGridCenterlineSections::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 589 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

590{
591 this->Superclass::PrintSelf(os,indent);
592}

◆ New()

vtkvmtkUnstructuredGridCenterlineSections * vtkvmtkUnstructuredGridCenterlineSections::New ( )
static

◆ SetCenterlines()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetCenterlines ( vtkPolyData * )
virtual

Set/Get the centerline(s) along which sections are cut, one per centerline point. Required input.

◆ GetCenterlines()

virtual vtkPolyData * vtkvmtkUnstructuredGridCenterlineSections::GetCenterlines ( )
virtual

Set/Get the centerline(s) along which sections are cut, one per centerline point. Required input.

◆ SetSectionSource()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetSectionSource ( vtkPolyData * )
virtual

Set/Get an optional poly data used as a template shape for each section outline instead of the mesh's own intersection polygon; used when UseSectionSource is on.

◆ GetSectionSource()

virtual vtkPolyData * vtkvmtkUnstructuredGridCenterlineSections::GetSectionSource ( )
virtual

Set/Get an optional poly data used as a template shape for each section outline instead of the mesh's own intersection polygon; used when UseSectionSource is on.

◆ SetSectionUpNormalsArrayName()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetSectionUpNormalsArrayName ( const char * )
virtual

Set/Get the name of the point data array of Centerlines holding the section "up" direction used to orient each cutting plane (together with SectionNormalsArrayName).

◆ GetSectionUpNormalsArrayName()

virtual char * vtkvmtkUnstructuredGridCenterlineSections::GetSectionUpNormalsArrayName ( )
virtual

Set/Get the name of the point data array of Centerlines holding the section "up" direction used to orient each cutting plane (together with SectionNormalsArrayName).

◆ SetSectionNormalsArrayName()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetSectionNormalsArrayName ( const char * )
virtual

Set/Get the name of the point data array of Centerlines holding the cutting plane normal at each centerline point. Commonly named "SectionNormals".

◆ GetSectionNormalsArrayName()

virtual char * vtkvmtkUnstructuredGridCenterlineSections::GetSectionNormalsArrayName ( )
virtual

Set/Get the name of the point data array of Centerlines holding the cutting plane normal at each centerline point. Commonly named "SectionNormals".

◆ SetAdditionalNormalsArrayName()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetAdditionalNormalsArrayName ( const char * )
virtual

Set/Get the name of an additional 3-component point data array of Centerlines to be carried through and transformed onto each section (e.g. a secondary reference direction), alongside SectionNormalsArrayName/SectionUpNormalsArrayName.

◆ GetAdditionalNormalsArrayName()

virtual char * vtkvmtkUnstructuredGridCenterlineSections::GetAdditionalNormalsArrayName ( )
virtual

Set/Get the name of an additional 3-component point data array of Centerlines to be carried through and transformed onto each section (e.g. a secondary reference direction), alongside SectionNormalsArrayName/SectionUpNormalsArrayName.

◆ SetAdditionalScalarsArrayName()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetAdditionalScalarsArrayName ( const char * )
virtual

Set/Get the name of an additional scalar point data array of Centerlines to be carried through onto each section (e.g. used as a per-section scaling factor when SourceScaling is on).

◆ GetAdditionalScalarsArrayName()

virtual char * vtkvmtkUnstructuredGridCenterlineSections::GetAdditionalScalarsArrayName ( )
virtual

Set/Get the name of an additional scalar point data array of Centerlines to be carried through onto each section (e.g. used as a per-section scaling factor when SourceScaling is on).

◆ SetTransformSections()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetTransformSections ( int )
virtual

Toggle transforming each section into a canonical local frame (aligning its normal/up-normal to fixed axes) rather than leaving it in the original mesh coordinate system. Default: off.

◆ GetTransformSections()

virtual int vtkvmtkUnstructuredGridCenterlineSections::GetTransformSections ( )
virtual

Toggle transforming each section into a canonical local frame (aligning its normal/up-normal to fixed axes) rather than leaving it in the original mesh coordinate system. Default: off.

◆ TransformSectionsOn()

virtual void vtkvmtkUnstructuredGridCenterlineSections::TransformSectionsOn ( )
virtual

Toggle transforming each section into a canonical local frame (aligning its normal/up-normal to fixed axes) rather than leaving it in the original mesh coordinate system. Default: off.

◆ TransformSectionsOff()

virtual void vtkvmtkUnstructuredGridCenterlineSections::TransformSectionsOff ( )
virtual

Toggle transforming each section into a canonical local frame (aligning its normal/up-normal to fixed axes) rather than leaving it in the original mesh coordinate system. Default: off.

◆ SetUseSectionSource()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetUseSectionSource ( int )
virtual

Toggle using SectionSource as a template shape, transformed to each centerline point's local frame, instead of intersecting the mesh with the cutting plane. Default: off.

◆ GetUseSectionSource()

virtual int vtkvmtkUnstructuredGridCenterlineSections::GetUseSectionSource ( )
virtual

Toggle using SectionSource as a template shape, transformed to each centerline point's local frame, instead of intersecting the mesh with the cutting plane. Default: off.

◆ UseSectionSourceOn()

virtual void vtkvmtkUnstructuredGridCenterlineSections::UseSectionSourceOn ( )
virtual

Toggle using SectionSource as a template shape, transformed to each centerline point's local frame, instead of intersecting the mesh with the cutting plane. Default: off.

◆ UseSectionSourceOff()

virtual void vtkvmtkUnstructuredGridCenterlineSections::UseSectionSourceOff ( )
virtual

Toggle using SectionSource as a template shape, transformed to each centerline point's local frame, instead of intersecting the mesh with the cutting plane. Default: off.

◆ SetSourceScaling()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetSourceScaling ( int )
virtual

Toggle scaling SectionSource at each centerline point by the value of AdditionalScalarsArrayName (e.g. the local vessel radius), when UseSectionSource is on. Default: off.

◆ GetSourceScaling()

virtual int vtkvmtkUnstructuredGridCenterlineSections::GetSourceScaling ( )
virtual

Toggle scaling SectionSource at each centerline point by the value of AdditionalScalarsArrayName (e.g. the local vessel radius), when UseSectionSource is on. Default: off.

◆ SourceScalingOn()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SourceScalingOn ( )
virtual

Toggle scaling SectionSource at each centerline point by the value of AdditionalScalarsArrayName (e.g. the local vessel radius), when UseSectionSource is on. Default: off.

◆ SourceScalingOff()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SourceScalingOff ( )
virtual

Toggle scaling SectionSource at each centerline point by the value of AdditionalScalarsArrayName (e.g. the local vessel radius), when UseSectionSource is on. Default: off.

◆ SetOriginOffset()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetOriginOffset ( double data[])
virtual

Set/Get a constant (x,y,z) offset applied to the origin of every section. Default: (0,0,0).

◆ GetOriginOffset() [1/2]

virtual double * vtkvmtkUnstructuredGridCenterlineSections::GetOriginOffset ( )
virtual

Set/Get a constant (x,y,z) offset applied to the origin of every section. Default: (0,0,0).

◆ GetOriginOffset() [2/2]

virtual void vtkvmtkUnstructuredGridCenterlineSections::GetOriginOffset ( double data[3])
virtual

Set/Get a constant (x,y,z) offset applied to the origin of every section. Default: (0,0,0).

◆ SetVectorsArrayName()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetVectorsArrayName ( const char * )
virtual

Set/Get the name of a 3-component point data array of the input mesh (e.g. a velocity field) to be resampled onto each output section.

◆ GetVectorsArrayName()

virtual char * vtkvmtkUnstructuredGridCenterlineSections::GetVectorsArrayName ( )
virtual

Set/Get the name of a 3-component point data array of the input mesh (e.g. a velocity field) to be resampled onto each output section.

◆ SetSectionIdsArrayName()

virtual void vtkvmtkUnstructuredGridCenterlineSections::SetSectionIdsArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the id of the centerline point each section was cut at is stored. Commonly named "SectionIds".

◆ GetSectionIdsArrayName()

virtual char * vtkvmtkUnstructuredGridCenterlineSections::GetSectionIdsArrayName ( )
virtual

Set/Get the name of the output cell data array where the id of the centerline point each section was cut at is stored. Commonly named "SectionIds".

◆ GetSectionPointsPolyData()

virtual vtkPolyData * vtkvmtkUnstructuredGridCenterlineSections::GetSectionPointsPolyData ( )
virtual

Get a poly data of vertex points, one per output section, located at each section's origin – useful for visualizing where along the centerline each section was taken.

◆ FillInputPortInformation()

int vtkvmtkUnstructuredGridCenterlineSections::FillInputPortInformation ( int ,
vtkInformation * info )
overrideprotected

Definition at line 119 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

120{
121 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid");
122 return 1;
123}

◆ RequestData()

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

Definition at line 191 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

195{
196 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
197 vtkInformation *outInfo = outputVector->GetInformationObject(0);
198
199 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
200 inInfo->Get(vtkDataObject::DATA_OBJECT()));
201 vtkPolyData *output = vtkPolyData::SafeDownCast(
202 outInfo->Get(vtkDataObject::DATA_OBJECT()));
203
204 if (!this->Centerlines)
205 {
206 vtkErrorMacro(<<"Centerlines not set");
207 return 1;
208 }
209
210 if (this->UseSectionSource && !this->SectionSource)
211 {
212 vtkErrorMacro(<<"SectionSource not set");
213 return 1;
214 }
215
216 vtkDataArray* upNormalsArray = NULL;
217
219 {
220 vtkErrorMacro(<<"TransformSection is On and no SectionUpNormalsArrayName specified!");
221 return 1;
222 }
223
225 {
226 upNormalsArray = this->Centerlines->GetPointData()->GetArray(this->SectionUpNormalsArrayName);
227 if (!upNormalsArray)
228 {
229 vtkErrorMacro(<<"UpNormalsArray with name specified does not exist!");
230 return 1;
231 }
232 if (upNormalsArray->GetNumberOfComponents() != 3)
233 {
234 vtkErrorMacro(<<"UpNormalsArray does not have 3 components!");
235 return 1;
236 }
237 }
238
239 if (!this->SectionNormalsArrayName)
240 {
241 vtkErrorMacro(<<"SectionNormalsArrayName not specified!");
242 return 1;
243 }
244
245 if (!this->SectionIdsArrayName)
246 {
247 vtkErrorMacro(<<"SectionIdsArrayName not specified!");
248 return 1;
249 }
250
251 vtkDataArray* additionalNormalsArray = NULL;
252 vtkDataArray* additionalScalarsArray = NULL;
254 {
255 additionalNormalsArray = this->Centerlines->GetPointData()->GetArray(this->AdditionalNormalsArrayName);
256 if (!additionalNormalsArray)
257 {
258 vtkErrorMacro(<<"AdditionalNormalsArray with name specified does not exist!");
259 }
260 if (additionalNormalsArray->GetNumberOfComponents() != 3)
261 {
262 vtkErrorMacro(<<"AdditionalNormalsArray does not have 3 components!");
263 additionalNormalsArray = NULL;
264 }
265 }
266
268 {
269 additionalScalarsArray = this->Centerlines->GetPointData()->GetArray(this->AdditionalScalarsArrayName);
270 if (!additionalScalarsArray)
271 {
272 vtkErrorMacro(<<"AdditionalScalarsArray with name specified does not exist!");
273 }
274 }
275
276 if (this->SectionPointsPolyData)
277 {
278 this->SectionPointsPolyData->Delete();
279 this->SectionPointsPolyData = NULL;
280 }
281
282 this->SectionPointsPolyData = vtkPolyData::New();
283 vtkPoints* sectionPointsPoints = vtkPoints::New();
284 vtkCellArray* sectionPointsVerts = vtkCellArray::New();
285 vtkDoubleArray* sectionPointsUpNormals = vtkDoubleArray::New();
286 sectionPointsUpNormals->SetNumberOfComponents(3);
287 sectionPointsUpNormals->SetName(this->SectionUpNormalsArrayName);
288 vtkDoubleArray* sectionPointsNormals = vtkDoubleArray::New();
289 sectionPointsNormals->SetNumberOfComponents(3);
290 sectionPointsNormals->SetName(this->SectionNormalsArrayName);
291 vtkDoubleArray* sectionPointsAdditionalNormals = vtkDoubleArray::New();
292 sectionPointsAdditionalNormals->SetNumberOfComponents(3);
293 sectionPointsAdditionalNormals->SetName(this->AdditionalNormalsArrayName);
294 vtkDoubleArray* sectionPointsAdditionalScalars = vtkDoubleArray::New();
295 sectionPointsAdditionalScalars->SetNumberOfComponents(1);
296 sectionPointsAdditionalScalars->SetName(this->AdditionalScalarsArrayName);
297 this->SectionPointsPolyData->SetPoints(sectionPointsPoints);
298 this->SectionPointsPolyData->SetVerts(sectionPointsVerts);
299 if (upNormalsArray)
300 {
301 this->SectionPointsPolyData->GetPointData()->AddArray(sectionPointsUpNormals);
302 }
303 this->SectionPointsPolyData->GetPointData()->AddArray(sectionPointsNormals);
304 if (additionalNormalsArray)
305 {
306 this->SectionPointsPolyData->GetPointData()->AddArray(sectionPointsAdditionalNormals);
307 }
308 if (additionalScalarsArray)
309 {
310 this->SectionPointsPolyData->GetPointData()->AddArray(sectionPointsAdditionalScalars);
311 }
312
313 vtkIdType sectionId = 0;
314 vtkAppendPolyData* appendFilter = vtkAppendPolyData::New();
315
316 int numberOfCenterlineCells = this->Centerlines->GetNumberOfCells();
317 int i;
318 for (i=0; i<numberOfCenterlineCells; i++)
319 {
320 vtkCell* centerlineCell = this->Centerlines->GetCell(i);
321 vtkPoints* centerlineCellPoints = centerlineCell->GetPoints();
322 int numberOfCellPoints = centerlineCellPoints->GetNumberOfPoints();
323
324 int j;
325 for (j=0; j<numberOfCellPoints; j++)
326 {
327 double point[3];
328 centerlineCellPoints->GetPoint(j,point);
329
330 double tangent[3];
331 tangent[0] = tangent[1] = tangent[2] = 0.0;
332
333 double upNormal[3];
334 upNormal[0] = upNormal[1] = upNormal[2] = 0.0;
335
336 double weightSum = 0.0;
337 if (j>0)
338 {
339 double point0[3], point1[3];
340 centerlineCellPoints->GetPoint(j-1,point0);
341 centerlineCellPoints->GetPoint(j,point1);
342 double distance = sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
343 tangent[0] += (point1[0] - point0[0]) / distance;
344 tangent[1] += (point1[1] - point0[1]) / distance;
345 tangent[2] += (point1[2] - point0[2]) / distance;
346 weightSum += 1.0;
347 }
348
349 if (j<numberOfCellPoints-1)
350 {
351 double point0[3], point1[3];
352 centerlineCellPoints->GetPoint(j,point0);
353 centerlineCellPoints->GetPoint(j+1,point1);
354 double distance = sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
355 tangent[0] += (point1[0] - point0[0]) / distance;
356 tangent[1] += (point1[1] - point0[1]) / distance;
357 tangent[2] += (point1[2] - point0[2]) / distance;
358 weightSum += 1.0;
359 }
360
361 tangent[0] /= weightSum;
362 tangent[1] /= weightSum;
363 tangent[2] /= weightSum;
364
365 vtkMath::Normalize(tangent);
366
367 if (upNormalsArray)
368 {
369 upNormalsArray->GetTuple(centerlineCell->GetPointId(j),upNormal);
370 vtkMath::Normalize(upNormal);
371 }
372
373 vtkPolyData* section = vtkPolyData::New();
374
375 if (!this->UseSectionSource)
376 {
377 vtkPlane* plane = vtkPlane::New();
378 plane->SetOrigin(point);
379 plane->SetNormal(tangent);
380
381 vtkCutter* cutter = vtkCutter::New();
382 cutter->SetInputData(input);
383 cutter->SetCutFunction(plane);
384 cutter->GenerateCutScalarsOff();
385 cutter->SetValue(0,0.0);
386 cutter->Update();
387
388 vtkCleanPolyData* cleaner = vtkCleanPolyData::New();
389 cleaner->SetInputConnection(cutter->GetOutputPort());
390 cleaner->Update();
391
392 if (cleaner->GetOutput()->GetNumberOfPoints() == 0)
393 {
394 plane->Delete();
395 cutter->Delete();
396 cleaner->Delete();
397 continue;
398 }
399
400 vtkPolyDataConnectivityFilter* connectivityFilter = vtkPolyDataConnectivityFilter::New();
401 connectivityFilter->SetInputConnection(cleaner->GetOutputPort());
402 connectivityFilter->SetExtractionModeToClosestPointRegion();
403 connectivityFilter->SetClosestPoint(point);
404 connectivityFilter->Update();
405
406 section->DeepCopy(connectivityFilter->GetOutput());
407 section->GetPointData()->SetActiveVectors(this->VectorsArrayName);
408
409 plane->Delete();
410 cutter->Delete();
411 cleaner->Delete();
412 connectivityFilter->Delete();
413 }
414 else
415 {
416 double currentOrigin[3];
417 currentOrigin[0] = 0.0;
418 currentOrigin[1] = 0.0;
419 currentOrigin[2] = 0.0;
420
421 double currentNormal[3];
422 currentNormal[0] = 0.0;
423 currentNormal[1] = 0.0;
424 currentNormal[2] = 1.0;
425
426 double currentUpNormal[3];
427 currentUpNormal[0] = 0.0;
428 currentUpNormal[1] = 1.0;
429 currentUpNormal[2] = 0.0;
430
431 double targetOrigin[3];
432 targetOrigin[0] = point[0];
433 targetOrigin[1] = point[1];
434 targetOrigin[2] = point[2];
435
436 double targetNormal[3];
437 targetNormal[0] = tangent[0];
438 targetNormal[1] = tangent[1];
439 targetNormal[2] = tangent[2];
440
441 double targetUpNormal[3];
442 targetUpNormal[0] = upNormal[0];
443 targetUpNormal[1] = upNormal[1];
444 targetUpNormal[2] = upNormal[2];
445
446 vtkTransform* transform = vtkTransform::New();
447 this->CreateTransform(transform,currentOrigin,currentNormal,currentUpNormal,targetOrigin,targetNormal,targetUpNormal);
448
449 vtkTransformPolyDataFilter* transformFilter = vtkTransformPolyDataFilter::New();
450 transformFilter->SetInputData(this->SectionSource);
451 transformFilter->SetTransform(transform);
452 transformFilter->Update();
453
454 vtkProbeFilter* probeFilter = vtkProbeFilter::New();
455 probeFilter->SetInputConnection(transformFilter->GetOutputPort());
456 probeFilter->SetSourceData(input);
457 probeFilter->Update();
458
459 section->DeepCopy(probeFilter->GetOutput());
460 section->GetPointData()->SetActiveVectors(this->VectorsArrayName);
461
462 probeFilter->Delete();
463 transformFilter->Delete();
464 transform->Delete();
465 }
466
467 vtkIdType numberOfSectionPoints = section->GetNumberOfPoints();
468 vtkIdTypeArray* sectionIdsArray = vtkIdTypeArray::New();
469 sectionIdsArray->SetName(this->SectionIdsArrayName);
470 sectionIdsArray->SetNumberOfTuples(numberOfSectionPoints);
471 vtkIdType pointId;
472 for (pointId=0; pointId<numberOfSectionPoints; pointId++)
473 {
474 sectionIdsArray->SetValue(pointId,sectionId);
475 }
476 sectionId += 1;
477 section->GetPointData()->AddArray(sectionIdsArray);
478
479 if (!this->TransformSections)
480 {
481 appendFilter->AddInputData(section);
482
483 vtkIdType pointId = sectionPointsPoints->InsertNextPoint(point);
484 sectionPointsVerts->InsertNextCell(1);
485 sectionPointsVerts->InsertCellPoint(pointId);
486 sectionPointsNormals->InsertNextTuple(tangent);
487 if (upNormalsArray)
488 {
489 sectionPointsUpNormals->InsertNextTuple(upNormal);
490 }
491 if (additionalNormalsArray)
492 {
493 double additionalNormal[3];
494 additionalNormalsArray->GetTuple(centerlineCell->GetPointId(j),additionalNormal);
495 sectionPointsAdditionalNormals->InsertNextTuple(additionalNormal);
496 }
497 if (additionalScalarsArray)
498 {
499 double scalar = additionalScalarsArray->GetTuple1(centerlineCell->GetPointId(j));
500 sectionPointsAdditionalScalars->InsertNextTuple1(scalar);
501 }
502 }
503 else
504 {
505 double currentOrigin[3];
506 currentOrigin[0] = point[0];
507 currentOrigin[1] = point[1];
508 currentOrigin[2] = point[2];
509
510 double currentNormal[3];
511 currentNormal[0] = tangent[0];
512 currentNormal[1] = tangent[1];
513 currentNormal[2] = tangent[2];
514
515 double currentUpNormal[3];
516 currentUpNormal[0] = upNormal[0];
517 currentUpNormal[1] = upNormal[1];
518 currentUpNormal[2] = upNormal[2];
519
520 double targetOrigin[3];
521 targetOrigin[0] = j * this->OriginOffset[0];
522 targetOrigin[1] = j * this->OriginOffset[1];
523 targetOrigin[2] = j * this->OriginOffset[2];
524
525 double targetNormal[3];
526 targetNormal[0] = 0.0;
527 targetNormal[1] = 0.0;
528 targetNormal[2] = 1.0;
529
530 double targetUpNormal[3];
531 targetUpNormal[0] = 0.0;
532 targetUpNormal[1] = 1.0;
533 targetUpNormal[2] = 0.0;
534
535 vtkTransform* transform = vtkTransform::New();
536 this->CreateTransform(transform,currentOrigin,currentNormal,currentUpNormal,targetOrigin,targetNormal,targetUpNormal);
537
538 vtkTransformPolyDataFilter* transformFilter = vtkTransformPolyDataFilter::New();
539 transformFilter->SetInputData(section);
540 transformFilter->SetTransform(transform);
541 transformFilter->Update();
542
543 appendFilter->AddInputConnection(transformFilter->GetOutputPort());
544
545 vtkIdType pointId = sectionPointsPoints->InsertNextPoint(targetOrigin);
546 sectionPointsVerts->InsertNextCell(1);
547 sectionPointsVerts->InsertCellPoint(pointId);
548 sectionPointsNormals->InsertNextTuple(targetNormal);
549 sectionPointsUpNormals->InsertNextTuple(targetUpNormal);
550 if (additionalNormalsArray)
551 {
552 double additionalNormal[3], projectedAdditionalNormal[3], transformedAdditionalNormal[3];
553 additionalNormalsArray->GetTuple(centerlineCell->GetPointId(j),additionalNormal);
554 double dot = vtkMath::Dot(additionalNormal,currentNormal);
555 projectedAdditionalNormal[0] = additionalNormal[0] - dot * currentNormal[0];
556 projectedAdditionalNormal[1] = additionalNormal[1] - dot * currentNormal[1];
557 projectedAdditionalNormal[2] = additionalNormal[2] - dot * currentNormal[2];
558 vtkMath::Normalize(projectedAdditionalNormal);
559 transform->TransformNormal(projectedAdditionalNormal,transformedAdditionalNormal);
560 sectionPointsAdditionalNormals->InsertNextTuple(transformedAdditionalNormal);
561 }
562 if (additionalScalarsArray)
563 {
564 double scalar = additionalScalarsArray->GetTuple1(centerlineCell->GetPointId(j));
565 sectionPointsAdditionalScalars->InsertNextTuple1(scalar);
566 }
567
568 transform->Delete();
569 transformFilter->Delete();
570 }
571
572 section->Delete();
573 }
574 }
575
576 appendFilter->Update();
577
578 output->DeepCopy(appendFilter->GetOutput());
579
580 appendFilter->Delete();
581 sectionPointsPoints->Delete();
582 sectionPointsVerts->Delete();
583 sectionPointsAdditionalNormals->Delete();
584 sectionPointsAdditionalScalars->Delete();
585
586 return 1;
587}
void CreateTransform(vtkTransform *transform, double currentOrigin[3], double currentNormal[3], double currentUpNormal[3], double targetOrigin[3], double targetNormal[3], double targetUpNormal[3])

◆ ComputeAngle()

double vtkvmtkUnstructuredGridCenterlineSections::ComputeAngle ( double vector0[3],
double vector1[3] )
protected

Definition at line 125 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

126{
127 double normal0[3], normal1[3];
128 normal0[0] = vector0[0];
129 normal0[1] = vector0[1];
130 normal0[2] = vector0[2];
131 normal1[0] = vector1[0];
132 normal1[1] = vector1[1];
133 normal1[2] = vector1[2];
134 vtkMath::Normalize(normal0);
135 vtkMath::Normalize(normal1);
136 double sum[3], difference[3];
137 sum[0] = normal0[0] + normal1[0];
138 sum[1] = normal0[1] + normal1[1];
139 sum[2] = normal0[2] + normal1[2];
140 difference[0] = normal0[0] - normal1[0];
141 difference[1] = normal0[1] - normal1[1];
142 difference[2] = normal0[2] - normal1[2];
143 double sumNorm = vtkMath::Norm(sum);
144 double differenceNorm = vtkMath::Norm(difference);
145 double angle = 2.0 * atan2(differenceNorm,sumNorm);
146 return angle;
147}

◆ CreateTransform()

void vtkvmtkUnstructuredGridCenterlineSections::CreateTransform ( vtkTransform * transform,
double currentOrigin[3],
double currentNormal[3],
double currentUpNormal[3],
double targetOrigin[3],
double targetNormal[3],
double targetUpNormal[3] )
protected

Definition at line 149 of file vtkvmtkUnstructuredGridCenterlineSections.cxx.

150{
151 transform->PostMultiply();
152
153 double translation0[3];
154 translation0[0] = 0.0 - currentOrigin[0];
155 translation0[1] = 0.0 - currentOrigin[1];
156 translation0[2] = 0.0 - currentOrigin[2];
157
158 double translation1[3];
159 translation1[0] = targetOrigin[0] - 0.0;
160 translation1[1] = targetOrigin[1] - 0.0;
161 translation1[2] = targetOrigin[2] - 0.0;
162
163 transform->Translate(translation0);
164
165 double cross0[3];
166 vtkMath::Cross(currentNormal,targetNormal,cross0);
167 vtkMath::Normalize(cross0);
168 double angle0 = this->ComputeAngle(currentNormal,targetNormal);
169 angle0 = angle0 / (2.0*vtkMath::Pi()) * 360.0;
170 transform->RotateWXYZ(angle0,cross0);
171
172 double dot = vtkMath::Dot(currentUpNormal,currentNormal);
173 double currentProjectedUpNormal[3];
174 currentProjectedUpNormal[0] = currentUpNormal[0] - dot * currentNormal[0];
175 currentProjectedUpNormal[1] = currentUpNormal[1] - dot * currentNormal[1];
176 currentProjectedUpNormal[2] = currentUpNormal[2] - dot * currentNormal[2];
177 vtkMath::Normalize(currentProjectedUpNormal);
178
179 double transformedUpNormal[3];
180 transform->TransformNormal(currentProjectedUpNormal,transformedUpNormal);
181
182 double cross1[3];
183 vtkMath::Cross(transformedUpNormal,targetUpNormal,cross1);
184 vtkMath::Normalize(cross1);
185 double angle1 = this->ComputeAngle(transformedUpNormal,targetUpNormal);
186 angle1 = angle1 / (2.0*vtkMath::Pi()) * 360.0;
187 transform->RotateWXYZ(angle1,cross1);
188 transform->Translate(translation1);
189}

Member Data Documentation

◆ Centerlines

vtkPolyData* vtkvmtkUnstructuredGridCenterlineSections::Centerlines
protected

Definition at line 182 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ SectionSource

vtkPolyData* vtkvmtkUnstructuredGridCenterlineSections::SectionSource
protected

Definition at line 183 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ SectionPointsPolyData

vtkPolyData* vtkvmtkUnstructuredGridCenterlineSections::SectionPointsPolyData
protected

Definition at line 184 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ SectionUpNormalsArrayName

char* vtkvmtkUnstructuredGridCenterlineSections::SectionUpNormalsArrayName
protected

Definition at line 186 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ SectionNormalsArrayName

char* vtkvmtkUnstructuredGridCenterlineSections::SectionNormalsArrayName
protected

Definition at line 187 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ AdditionalNormalsArrayName

char* vtkvmtkUnstructuredGridCenterlineSections::AdditionalNormalsArrayName
protected

Definition at line 188 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ AdditionalScalarsArrayName

char* vtkvmtkUnstructuredGridCenterlineSections::AdditionalScalarsArrayName
protected

Definition at line 189 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ SectionIdsArrayName

char* vtkvmtkUnstructuredGridCenterlineSections::SectionIdsArrayName
protected

Definition at line 190 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ VectorsArrayName

char* vtkvmtkUnstructuredGridCenterlineSections::VectorsArrayName
protected

Definition at line 192 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ TransformSections

int vtkvmtkUnstructuredGridCenterlineSections::TransformSections
protected

Definition at line 194 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ UseSectionSource

int vtkvmtkUnstructuredGridCenterlineSections::UseSectionSource
protected

Definition at line 196 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ SourceScaling

int vtkvmtkUnstructuredGridCenterlineSections::SourceScaling
protected

Definition at line 197 of file vtkvmtkUnstructuredGridCenterlineSections.h.

◆ OriginOffset

double vtkvmtkUnstructuredGridCenterlineSections::OriginOffset[3]
protected

Definition at line 199 of file vtkvmtkUnstructuredGridCenterlineSections.h.


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