VTK
vtkMeshQuality.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMeshQuality.h
5  Language: C++
6 
7  Copyright 2003-2006 Sandia Corporation.
8  Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9  license for use of this work by or on behalf of the
10  U.S. Government. Redistribution and use in source and binary forms, with
11  or without modification, are permitted provided that this Notice and any
12  statement of authorship are reproduced on all copies.
13 
14  Contact: dcthomp@sandia.gov,pppebay@sandia.gov
15 
16 =========================================================================*/
67 #ifndef __vtkMeshQuality_h
68 #define __vtkMeshQuality_h
69 
70 #include "vtkDataSetAlgorithm.h"
71 
72 class vtkCell;
73 class vtkDataArray;
74 
75 #define VTK_QUALITY_EDGE_RATIO 0
76 #define VTK_QUALITY_ASPECT_RATIO 1
77 #define VTK_QUALITY_RADIUS_RATIO 2
78 #define VTK_QUALITY_ASPECT_FROBENIUS 3
79 #define VTK_QUALITY_MED_ASPECT_FROBENIUS 4
80 #define VTK_QUALITY_MAX_ASPECT_FROBENIUS 5
81 #define VTK_QUALITY_MIN_ANGLE 6
82 #define VTK_QUALITY_COLLAPSE_RATIO 7
83 #define VTK_QUALITY_MAX_ANGLE 8
84 #define VTK_QUALITY_CONDITION 9
85 #define VTK_QUALITY_SCALED_JACOBIAN 10
86 #define VTK_QUALITY_SHEAR 11
87 #define VTK_QUALITY_RELATIVE_SIZE_SQUARED 12
88 #define VTK_QUALITY_SHAPE 13
89 #define VTK_QUALITY_SHAPE_AND_SIZE 14
90 #define VTK_QUALITY_DISTORTION 15
91 #define VTK_QUALITY_MAX_EDGE_RATIO 16
92 #define VTK_QUALITY_SKEW 17
93 #define VTK_QUALITY_TAPER 18
94 #define VTK_QUALITY_VOLUME 19
95 #define VTK_QUALITY_STRETCH 20
96 #define VTK_QUALITY_DIAGONAL 21
97 #define VTK_QUALITY_DIMENSION 22
98 #define VTK_QUALITY_ODDY 23
99 #define VTK_QUALITY_SHEAR_AND_SIZE 24
100 #define VTK_QUALITY_JACOBIAN 25
101 #define VTK_QUALITY_WARPAGE 26
102 #define VTK_QUALITY_ASPECT_GAMMA 27
103 #define VTK_QUALITY_AREA 28
104 #define VTK_QUALITY_ASPECT_BETA 29
105 
107 {
108 public:
109  void PrintSelf(ostream& os, vtkIndent indent);
111  static vtkMeshQuality* New();
112 
114 
117  vtkSetMacro(SaveCellQuality,int);
118  vtkGetMacro(SaveCellQuality,int);
119  vtkBooleanMacro(SaveCellQuality,int);
121 
123 
131  vtkSetMacro(TriangleQualityMeasure,int);
132  vtkGetMacro(TriangleQualityMeasure,int);
133  void SetTriangleQualityMeasureToArea()
134  {
135  this->SetTriangleQualityMeasure( VTK_QUALITY_AREA );
136  }
137  void SetTriangleQualityMeasureToEdgeRatio()
138  {
139  this->SetTriangleQualityMeasure( VTK_QUALITY_EDGE_RATIO );
140  }
141  void SetTriangleQualityMeasureToAspectRatio()
142  {
143  this->SetTriangleQualityMeasure( VTK_QUALITY_ASPECT_RATIO );
144  }
145  void SetTriangleQualityMeasureToRadiusRatio()
146  {
147  this->SetTriangleQualityMeasure( VTK_QUALITY_RADIUS_RATIO );
148  }
149  void SetTriangleQualityMeasureToAspectFrobenius()
150  {
151  this->SetTriangleQualityMeasure( VTK_QUALITY_ASPECT_FROBENIUS );
152  }
153  void SetTriangleQualityMeasureToMinAngle()
154  {
155  this->SetTriangleQualityMeasure( VTK_QUALITY_MIN_ANGLE );
156  }
157  void SetTriangleQualityMeasureToMaxAngle()
158  {
159  this->SetTriangleQualityMeasure( VTK_QUALITY_MAX_ANGLE );
160  }
161  void SetTriangleQualityMeasureToCondition()
162  {
163  this->SetTriangleQualityMeasure( VTK_QUALITY_CONDITION );
164  }
165  void SetTriangleQualityMeasureToScaledJacobian()
166  {
167  this->SetTriangleQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
168  }
169  void SetTriangleQualityMeasureToRelativeSizeSquared()
170  {
171  this->SetTriangleQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
172  }
173  void SetTriangleQualityMeasureToShape()
174  {
175  this->SetTriangleQualityMeasure( VTK_QUALITY_SHAPE );
176  }
177  void SetTriangleQualityMeasureToShapeAndSize()
178  {
179  this->SetTriangleQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
180  }
181  void SetTriangleQualityMeasureToDistortion()
182  {
183  this->SetTriangleQualityMeasure( VTK_QUALITY_DISTORTION );
184  }
186 
188 
202  vtkSetMacro(QuadQualityMeasure,int);
203  vtkGetMacro(QuadQualityMeasure,int);
204  void SetQuadQualityMeasureToEdgeRatio()
205  {
206  this->SetQuadQualityMeasure( VTK_QUALITY_EDGE_RATIO );
207  }
208  void SetQuadQualityMeasureToAspectRatio()
209  {
210  this->SetQuadQualityMeasure( VTK_QUALITY_ASPECT_RATIO );
211  }
212  void SetQuadQualityMeasureToRadiusRatio()
213  {
214  this->SetQuadQualityMeasure( VTK_QUALITY_RADIUS_RATIO );
215  }
216  void SetQuadQualityMeasureToMedAspectFrobenius()
217  {
218  this->SetQuadQualityMeasure( VTK_QUALITY_MED_ASPECT_FROBENIUS );
219  }
220  void SetQuadQualityMeasureToMaxAspectFrobenius()
221  {
222  this->SetQuadQualityMeasure( VTK_QUALITY_MAX_ASPECT_FROBENIUS );
223  }
224  void SetQuadQualityMeasureToMaxEdgeRatios()
225  {
226  this->SetQuadQualityMeasure( VTK_QUALITY_MAX_EDGE_RATIO );
227  }
228  void SetQuadQualityMeasureToSkew()
229  {
230  this->SetQuadQualityMeasure( VTK_QUALITY_SKEW );
231  }
232  void SetQuadQualityMeasureToTaper()
233  {
234  this->SetQuadQualityMeasure( VTK_QUALITY_TAPER );
235  }
236  void SetQuadQualityMeasureToWarpage()
237  {
238  this->SetQuadQualityMeasure( VTK_QUALITY_WARPAGE );
239  }
240  void SetQuadQualityMeasureToArea()
241  {
242  this->SetQuadQualityMeasure( VTK_QUALITY_AREA );
243  }
244  void SetQuadQualityMeasureToStretch()
245  {
246  this->SetQuadQualityMeasure( VTK_QUALITY_STRETCH );
247  }
248  void SetQuadQualityMeasureToMinAngle()
249  {
250  this->SetQuadQualityMeasure( VTK_QUALITY_MIN_ANGLE );
251  }
252  void SetQuadQualityMeasureToMaxAngle()
253  {
254  this->SetQuadQualityMeasure( VTK_QUALITY_MAX_ANGLE );
255  }
256  void SetQuadQualityMeasureToOddy()
257  {
258  this->SetQuadQualityMeasure( VTK_QUALITY_ODDY );
259  }
260  void SetQuadQualityMeasureToCondition()
261  {
262  this->SetQuadQualityMeasure( VTK_QUALITY_CONDITION );
263  }
264  void SetQuadQualityMeasureToJacobian()
265  {
266  this->SetQuadQualityMeasure( VTK_QUALITY_JACOBIAN );
267  }
268  void SetQuadQualityMeasureToScaledJacobian()
269  {
270  this->SetQuadQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
271  }
272  void SetQuadQualityMeasureToShear()
273  {
274  this->SetQuadQualityMeasure( VTK_QUALITY_SHEAR );
275  }
276  void SetQuadQualityMeasureToShape()
277  {
278  this->SetQuadQualityMeasure( VTK_QUALITY_SHAPE );
279  }
280  void SetQuadQualityMeasureToRelativeSizeSquared()
281  {
282  this->SetQuadQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
283  }
284  void SetQuadQualityMeasureToShapeAndSize()
285  {
286  this->SetQuadQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
287  }
288  void SetQuadQualityMeasureToShearAndSize()
289  {
290  this->SetQuadQualityMeasure( VTK_QUALITY_SHEAR_AND_SIZE );
291  }
292  void SetQuadQualityMeasureToDistortion()
293  {
294  this->SetQuadQualityMeasure( VTK_QUALITY_DISTORTION );
295  }
297 
299 
309  vtkSetMacro(TetQualityMeasure,int);
310  vtkGetMacro(TetQualityMeasure,int);
311  void SetTetQualityMeasureToEdgeRatio()
312  {
313  this->SetTetQualityMeasure( VTK_QUALITY_EDGE_RATIO );
314  }
315  void SetTetQualityMeasureToAspectRatio()
316  {
317  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_RATIO );
318  }
319  void SetTetQualityMeasureToRadiusRatio()
320  {
321  this->SetTetQualityMeasure( VTK_QUALITY_RADIUS_RATIO );
322  }
323  void SetTetQualityMeasureToAspectFrobenius()
324  {
325  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_FROBENIUS );
326  }
327  void SetTetQualityMeasureToMinAngle()
328  {
329  this->SetTetQualityMeasure( VTK_QUALITY_MIN_ANGLE );
330  }
331  void SetTetQualityMeasureToCollapseRatio()
332  {
333  this->SetTetQualityMeasure( VTK_QUALITY_COLLAPSE_RATIO );
334  }
335  void SetTetQualityMeasureToAspectBeta()
336  {
337  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_BETA );
338  }
339  void SetTetQualityMeasureToAspectGamma()
340  {
341  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_GAMMA );
342  }
343  void SetTetQualityMeasureToVolume()
344  {
345  this->SetTetQualityMeasure( VTK_QUALITY_VOLUME );
346  }
347  void SetTetQualityMeasureToCondition()
348  {
349  this->SetTetQualityMeasure( VTK_QUALITY_CONDITION );
350  }
351  void SetTetQualityMeasureToJacobian()
352  {
353  this->SetTetQualityMeasure( VTK_QUALITY_JACOBIAN );
354  }
355  void SetTetQualityMeasureToScaledJacobian()
356  {
357  this->SetTetQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
358  }
359  void SetTetQualityMeasureToShape()
360  {
361  this->SetTetQualityMeasure( VTK_QUALITY_SHAPE );
362  }
363  void SetTetQualityMeasureToRelativeSizeSquared()
364  {
365  this->SetTetQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
366  }
367  void SetTetQualityMeasureToShapeAndSize()
368  {
369  this->SetTetQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
370  }
371  void SetTetQualityMeasureToDistortion()
372  {
373  this->SetTetQualityMeasure( VTK_QUALITY_DISTORTION );
374  }
376 
378 
388  vtkSetMacro(HexQualityMeasure,int);
389  vtkGetMacro(HexQualityMeasure,int);
390  void SetHexQualityMeasureToEdgeRatio()
391  {
392  this->SetHexQualityMeasure( VTK_QUALITY_EDGE_RATIO );
393  }
394  void SetHexQualityMeasureToMedAspectFrobenius()
395  {
396  this->SetHexQualityMeasure( VTK_QUALITY_MED_ASPECT_FROBENIUS );
397  }
398  void SetHexQualityMeasureToMaxAspectFrobenius()
399  {
400  this->SetHexQualityMeasure( VTK_QUALITY_MAX_ASPECT_FROBENIUS );
401  }
402  void SetHexQualityMeasureToMaxEdgeRatios()
403  {
404  this->SetHexQualityMeasure( VTK_QUALITY_MAX_EDGE_RATIO );
405  }
406  void SetHexQualityMeasureToSkew()
407  {
408  this->SetHexQualityMeasure( VTK_QUALITY_SKEW );
409  }
410  void SetHexQualityMeasureToTaper()
411  {
412  this->SetHexQualityMeasure( VTK_QUALITY_TAPER );
413  }
414  void SetHexQualityMeasureToVolume()
415  {
416  this->SetHexQualityMeasure( VTK_QUALITY_VOLUME );
417  }
418  void SetHexQualityMeasureToStretch()
419  {
420  this->SetHexQualityMeasure( VTK_QUALITY_STRETCH );
421  }
422  void SetHexQualityMeasureToDiagonal()
423  {
424  this->SetHexQualityMeasure( VTK_QUALITY_DIAGONAL );
425  }
426  void SetHexQualityMeasureToDimension()
427  {
428  this->SetHexQualityMeasure( VTK_QUALITY_DIMENSION );
429  }
430  void SetHexQualityMeasureToOddy()
431  {
432  this->SetHexQualityMeasure( VTK_QUALITY_ODDY );
433  }
434  void SetHexQualityMeasureToCondition()
435  {
436  this->SetHexQualityMeasure( VTK_QUALITY_CONDITION );
437  }
438  void SetHexQualityMeasureToJacobian()
439  {
440  this->SetHexQualityMeasure( VTK_QUALITY_JACOBIAN );
441  }
442  void SetHexQualityMeasureToScaledJacobian()
443  {
444  this->SetHexQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
445  }
446  void SetHexQualityMeasureToShear()
447  {
448  this->SetHexQualityMeasure( VTK_QUALITY_SHEAR );
449  }
450  void SetHexQualityMeasureToShape()
451  {
452  this->SetHexQualityMeasure( VTK_QUALITY_SHAPE );
453  }
454  void SetHexQualityMeasureToRelativeSizeSquared()
455  {
456  this->SetHexQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
457  }
458  void SetHexQualityMeasureToShapeAndSize()
459  {
460  this->SetHexQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
461  }
462  void SetHexQualityMeasureToShearAndSize()
463  {
464  this->SetHexQualityMeasure( VTK_QUALITY_SHEAR_AND_SIZE );
465  }
466  void SetHexQualityMeasureToDistortion()
467  {
468  this->SetHexQualityMeasure( VTK_QUALITY_DISTORTION );
469  }
471 
476  static double TriangleArea( vtkCell* cell );
477 
485  static double TriangleEdgeRatio( vtkCell* cell );
486 
494  static double TriangleAspectRatio( vtkCell* cell );
495 
502  static double TriangleRadiusRatio( vtkCell* cell );
503 
513  static double TriangleAspectFrobenius( vtkCell* cell );
514 
520  static double TriangleMinAngle( vtkCell* cell );
521 
527  static double TriangleMaxAngle( vtkCell* cell );
528 
533  static double TriangleCondition( vtkCell* cell );
534 
539  static double TriangleScaledJacobian( vtkCell* cell );
540 
545  static double TriangleRelativeSizeSquared( vtkCell* cell );
546 
551  static double TriangleShape( vtkCell* cell );
552 
557  static double TriangleShapeAndSize( vtkCell* cell );
558 
563  static double TriangleDistortion( vtkCell* cell );
564 
572  static double QuadEdgeRatio( vtkCell* cell );
573 
583  static double QuadAspectRatio( vtkCell* cell );
584 
598  static double QuadRadiusRatio( vtkCell* cell );
599 
611  static double QuadMedAspectFrobenius( vtkCell* cell );
612 
624  static double QuadMaxAspectFrobenius( vtkCell* cell );
625 
631  static double QuadMinAngle( vtkCell* cell );
632 
633  static double QuadMaxEdgeRatios( vtkCell* cell );
634  static double QuadSkew( vtkCell* cell );
635  static double QuadTaper( vtkCell* cell );
636  static double QuadWarpage( vtkCell* cell );
637  static double QuadArea( vtkCell* cell );
638  static double QuadStretch( vtkCell* cell );
639  static double QuadMaxAngle( vtkCell* cell );
640  static double QuadOddy( vtkCell* cell );
641  static double QuadCondition( vtkCell* cell );
642  static double QuadJacobian( vtkCell* cell );
643  static double QuadScaledJacobian( vtkCell* cell );
644  static double QuadShear( vtkCell* cell );
645  static double QuadShape( vtkCell* cell );
646  static double QuadRelativeSizeSquared( vtkCell* cell );
647  static double QuadShapeAndSize( vtkCell* cell );
648  static double QuadShearAndSize( vtkCell* cell );
649  static double QuadDistortion( vtkCell* cell );
650 
658  static double TetEdgeRatio( vtkCell* cell );
659 
667  static double TetAspectRatio( vtkCell* cell );
668 
675  static double TetRadiusRatio( vtkCell* cell );
676 
687  static double TetAspectFrobenius( vtkCell* cell );
688 
694  static double TetMinAngle( vtkCell* cell );
695 
697 
704  static double TetCollapseRatio( vtkCell* cell );
705  static double TetAspectBeta( vtkCell* cell );
706  static double TetAspectGamma( vtkCell* cell );
707  static double TetVolume( vtkCell* cell );
708  static double TetCondition( vtkCell* cell );
709  static double TetJacobian( vtkCell* cell );
710  static double TetScaledJacobian( vtkCell* cell );
711  static double TetShape( vtkCell* cell );
712  static double TetRelativeSizeSquared( vtkCell* cell );
713  static double TetShapeandSize( vtkCell* cell );
714  static double TetDistortion( vtkCell* cell );
716 
724  static double HexEdgeRatio( vtkCell* cell );
725 
732  static double HexMedAspectFrobenius( vtkCell* cell );
733 
735 
741  static double HexMaxAspectFrobenius( vtkCell* cell );
742  static double HexMaxEdgeRatio( vtkCell* cell );
743  static double HexSkew( vtkCell* cell );
744  static double HexTaper( vtkCell* cell );
745  static double HexVolume( vtkCell* cell );
746  static double HexStretch( vtkCell* cell );
747  static double HexDiagonal( vtkCell* cell );
748  static double HexDimension( vtkCell* cell );
749  static double HexOddy( vtkCell* cell );
750  static double HexCondition( vtkCell* cell );
751  static double HexJacobian( vtkCell* cell );
752  static double HexScaledJacobian( vtkCell* cell );
753  static double HexShear( vtkCell* cell );
754  static double HexShape( vtkCell* cell );
755  static double HexRelativeSizeSquared( vtkCell* cell );
756  static double HexShapeAndSize( vtkCell* cell );
757  static double HexShearAndSize( vtkCell* cell );
758  static double HexDistortion( vtkCell* cell );
760 
762 
768  virtual void SetRatio( int r ) { this->SetSaveCellQuality( r ); }
769  int GetRatio() { return this->GetSaveCellQuality(); }
770  vtkBooleanMacro(Ratio,int);
772 
774 
786  virtual void SetVolume( int cv )
787  {
788  if ( ! ((cv != 0) ^ (this->Volume != 0)) )
789  {
790  return;
791  }
792  this->Modified();
793  this->Volume = cv;
794  if ( this->Volume )
795  {
796  this->CompatibilityModeOn();
797  }
798  }
799  int GetVolume()
800  {
801  return this->Volume;
802  }
803  vtkBooleanMacro(Volume,int);
805 
807 
825  virtual void SetCompatibilityMode( int cm )
826  {
827  if ( !((cm != 0) ^ (this->CompatibilityMode != 0)) )
828  {
829  return;
830  }
831  this->CompatibilityMode = cm;
832  this->Modified();
833  if ( this->CompatibilityMode )
834  {
835  this->Volume = 1;
836  this->TetQualityMeasure = VTK_QUALITY_RADIUS_RATIO;
837  }
838  }
839  vtkGetMacro(CompatibilityMode,int);
840  vtkBooleanMacro(CompatibilityMode,int);
842 
843 protected:
844  vtkMeshQuality();
845  ~vtkMeshQuality();
846 
848 
851  static int GetCurrentTriangleNormal( double point[3], double normal[3] );
852 
858 
860  int Volume;
861 
863  static double CurrentTriNormal[3];
864 
865 private:
866  vtkMeshQuality( const vtkMeshQuality& ); // Not implemented.
867  void operator = ( const vtkMeshQuality& ); // Not implemented.
868 };
869 
870 #endif // vtkMeshQuality_h