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 "vtkFiltersVerdictModule.h" // For export macro
71 #include "vtkDataSetAlgorithm.h"
72 
73 class vtkCell;
74 class vtkDataArray;
75 
76 #define VTK_QUALITY_EDGE_RATIO 0
77 #define VTK_QUALITY_ASPECT_RATIO 1
78 #define VTK_QUALITY_RADIUS_RATIO 2
79 #define VTK_QUALITY_ASPECT_FROBENIUS 3
80 #define VTK_QUALITY_MED_ASPECT_FROBENIUS 4
81 #define VTK_QUALITY_MAX_ASPECT_FROBENIUS 5
82 #define VTK_QUALITY_MIN_ANGLE 6
83 #define VTK_QUALITY_COLLAPSE_RATIO 7
84 #define VTK_QUALITY_MAX_ANGLE 8
85 #define VTK_QUALITY_CONDITION 9
86 #define VTK_QUALITY_SCALED_JACOBIAN 10
87 #define VTK_QUALITY_SHEAR 11
88 #define VTK_QUALITY_RELATIVE_SIZE_SQUARED 12
89 #define VTK_QUALITY_SHAPE 13
90 #define VTK_QUALITY_SHAPE_AND_SIZE 14
91 #define VTK_QUALITY_DISTORTION 15
92 #define VTK_QUALITY_MAX_EDGE_RATIO 16
93 #define VTK_QUALITY_SKEW 17
94 #define VTK_QUALITY_TAPER 18
95 #define VTK_QUALITY_VOLUME 19
96 #define VTK_QUALITY_STRETCH 20
97 #define VTK_QUALITY_DIAGONAL 21
98 #define VTK_QUALITY_DIMENSION 22
99 #define VTK_QUALITY_ODDY 23
100 #define VTK_QUALITY_SHEAR_AND_SIZE 24
101 #define VTK_QUALITY_JACOBIAN 25
102 #define VTK_QUALITY_WARPAGE 26
103 #define VTK_QUALITY_ASPECT_GAMMA 27
104 #define VTK_QUALITY_AREA 28
105 #define VTK_QUALITY_ASPECT_BETA 29
106 
107 class VTKFILTERSVERDICT_EXPORT vtkMeshQuality : public vtkDataSetAlgorithm
108 {
109 public:
110  void PrintSelf(ostream& os, vtkIndent indent);
112  static vtkMeshQuality* New();
113 
115 
118  vtkSetMacro(SaveCellQuality,int);
119  vtkGetMacro(SaveCellQuality,int);
120  vtkBooleanMacro(SaveCellQuality,int);
122 
124 
132  vtkSetMacro(TriangleQualityMeasure,int);
133  vtkGetMacro(TriangleQualityMeasure,int);
134  void SetTriangleQualityMeasureToArea()
135  {
136  this->SetTriangleQualityMeasure( VTK_QUALITY_AREA );
137  }
138  void SetTriangleQualityMeasureToEdgeRatio()
139  {
140  this->SetTriangleQualityMeasure( VTK_QUALITY_EDGE_RATIO );
141  }
142  void SetTriangleQualityMeasureToAspectRatio()
143  {
144  this->SetTriangleQualityMeasure( VTK_QUALITY_ASPECT_RATIO );
145  }
146  void SetTriangleQualityMeasureToRadiusRatio()
147  {
148  this->SetTriangleQualityMeasure( VTK_QUALITY_RADIUS_RATIO );
149  }
150  void SetTriangleQualityMeasureToAspectFrobenius()
151  {
152  this->SetTriangleQualityMeasure( VTK_QUALITY_ASPECT_FROBENIUS );
153  }
154  void SetTriangleQualityMeasureToMinAngle()
155  {
156  this->SetTriangleQualityMeasure( VTK_QUALITY_MIN_ANGLE );
157  }
158  void SetTriangleQualityMeasureToMaxAngle()
159  {
160  this->SetTriangleQualityMeasure( VTK_QUALITY_MAX_ANGLE );
161  }
162  void SetTriangleQualityMeasureToCondition()
163  {
164  this->SetTriangleQualityMeasure( VTK_QUALITY_CONDITION );
165  }
166  void SetTriangleQualityMeasureToScaledJacobian()
167  {
168  this->SetTriangleQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
169  }
170  void SetTriangleQualityMeasureToRelativeSizeSquared()
171  {
172  this->SetTriangleQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
173  }
174  void SetTriangleQualityMeasureToShape()
175  {
176  this->SetTriangleQualityMeasure( VTK_QUALITY_SHAPE );
177  }
178  void SetTriangleQualityMeasureToShapeAndSize()
179  {
180  this->SetTriangleQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
181  }
182  void SetTriangleQualityMeasureToDistortion()
183  {
184  this->SetTriangleQualityMeasure( VTK_QUALITY_DISTORTION );
185  }
187 
189 
203  vtkSetMacro(QuadQualityMeasure,int);
204  vtkGetMacro(QuadQualityMeasure,int);
205  void SetQuadQualityMeasureToEdgeRatio()
206  {
207  this->SetQuadQualityMeasure( VTK_QUALITY_EDGE_RATIO );
208  }
209  void SetQuadQualityMeasureToAspectRatio()
210  {
211  this->SetQuadQualityMeasure( VTK_QUALITY_ASPECT_RATIO );
212  }
213  void SetQuadQualityMeasureToRadiusRatio()
214  {
215  this->SetQuadQualityMeasure( VTK_QUALITY_RADIUS_RATIO );
216  }
217  void SetQuadQualityMeasureToMedAspectFrobenius()
218  {
219  this->SetQuadQualityMeasure( VTK_QUALITY_MED_ASPECT_FROBENIUS );
220  }
221  void SetQuadQualityMeasureToMaxAspectFrobenius()
222  {
223  this->SetQuadQualityMeasure( VTK_QUALITY_MAX_ASPECT_FROBENIUS );
224  }
225  void SetQuadQualityMeasureToMaxEdgeRatios()
226  {
227  this->SetQuadQualityMeasure( VTK_QUALITY_MAX_EDGE_RATIO );
228  }
229  void SetQuadQualityMeasureToSkew()
230  {
231  this->SetQuadQualityMeasure( VTK_QUALITY_SKEW );
232  }
233  void SetQuadQualityMeasureToTaper()
234  {
235  this->SetQuadQualityMeasure( VTK_QUALITY_TAPER );
236  }
237  void SetQuadQualityMeasureToWarpage()
238  {
239  this->SetQuadQualityMeasure( VTK_QUALITY_WARPAGE );
240  }
241  void SetQuadQualityMeasureToArea()
242  {
243  this->SetQuadQualityMeasure( VTK_QUALITY_AREA );
244  }
245  void SetQuadQualityMeasureToStretch()
246  {
247  this->SetQuadQualityMeasure( VTK_QUALITY_STRETCH );
248  }
249  void SetQuadQualityMeasureToMinAngle()
250  {
251  this->SetQuadQualityMeasure( VTK_QUALITY_MIN_ANGLE );
252  }
253  void SetQuadQualityMeasureToMaxAngle()
254  {
255  this->SetQuadQualityMeasure( VTK_QUALITY_MAX_ANGLE );
256  }
257  void SetQuadQualityMeasureToOddy()
258  {
259  this->SetQuadQualityMeasure( VTK_QUALITY_ODDY );
260  }
261  void SetQuadQualityMeasureToCondition()
262  {
263  this->SetQuadQualityMeasure( VTK_QUALITY_CONDITION );
264  }
265  void SetQuadQualityMeasureToJacobian()
266  {
267  this->SetQuadQualityMeasure( VTK_QUALITY_JACOBIAN );
268  }
269  void SetQuadQualityMeasureToScaledJacobian()
270  {
271  this->SetQuadQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
272  }
273  void SetQuadQualityMeasureToShear()
274  {
275  this->SetQuadQualityMeasure( VTK_QUALITY_SHEAR );
276  }
277  void SetQuadQualityMeasureToShape()
278  {
279  this->SetQuadQualityMeasure( VTK_QUALITY_SHAPE );
280  }
281  void SetQuadQualityMeasureToRelativeSizeSquared()
282  {
283  this->SetQuadQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
284  }
285  void SetQuadQualityMeasureToShapeAndSize()
286  {
287  this->SetQuadQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
288  }
289  void SetQuadQualityMeasureToShearAndSize()
290  {
291  this->SetQuadQualityMeasure( VTK_QUALITY_SHEAR_AND_SIZE );
292  }
293  void SetQuadQualityMeasureToDistortion()
294  {
295  this->SetQuadQualityMeasure( VTK_QUALITY_DISTORTION );
296  }
298 
300 
310  vtkSetMacro(TetQualityMeasure,int);
311  vtkGetMacro(TetQualityMeasure,int);
312  void SetTetQualityMeasureToEdgeRatio()
313  {
314  this->SetTetQualityMeasure( VTK_QUALITY_EDGE_RATIO );
315  }
316  void SetTetQualityMeasureToAspectRatio()
317  {
318  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_RATIO );
319  }
320  void SetTetQualityMeasureToRadiusRatio()
321  {
322  this->SetTetQualityMeasure( VTK_QUALITY_RADIUS_RATIO );
323  }
324  void SetTetQualityMeasureToAspectFrobenius()
325  {
326  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_FROBENIUS );
327  }
328  void SetTetQualityMeasureToMinAngle()
329  {
330  this->SetTetQualityMeasure( VTK_QUALITY_MIN_ANGLE );
331  }
332  void SetTetQualityMeasureToCollapseRatio()
333  {
334  this->SetTetQualityMeasure( VTK_QUALITY_COLLAPSE_RATIO );
335  }
336  void SetTetQualityMeasureToAspectBeta()
337  {
338  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_BETA );
339  }
340  void SetTetQualityMeasureToAspectGamma()
341  {
342  this->SetTetQualityMeasure( VTK_QUALITY_ASPECT_GAMMA );
343  }
344  void SetTetQualityMeasureToVolume()
345  {
346  this->SetTetQualityMeasure( VTK_QUALITY_VOLUME );
347  }
348  void SetTetQualityMeasureToCondition()
349  {
350  this->SetTetQualityMeasure( VTK_QUALITY_CONDITION );
351  }
352  void SetTetQualityMeasureToJacobian()
353  {
354  this->SetTetQualityMeasure( VTK_QUALITY_JACOBIAN );
355  }
356  void SetTetQualityMeasureToScaledJacobian()
357  {
358  this->SetTetQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
359  }
360  void SetTetQualityMeasureToShape()
361  {
362  this->SetTetQualityMeasure( VTK_QUALITY_SHAPE );
363  }
364  void SetTetQualityMeasureToRelativeSizeSquared()
365  {
366  this->SetTetQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
367  }
368  void SetTetQualityMeasureToShapeAndSize()
369  {
370  this->SetTetQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
371  }
372  void SetTetQualityMeasureToDistortion()
373  {
374  this->SetTetQualityMeasure( VTK_QUALITY_DISTORTION );
375  }
377 
379 
389  vtkSetMacro(HexQualityMeasure,int);
390  vtkGetMacro(HexQualityMeasure,int);
391  void SetHexQualityMeasureToEdgeRatio()
392  {
393  this->SetHexQualityMeasure( VTK_QUALITY_EDGE_RATIO );
394  }
395  void SetHexQualityMeasureToMedAspectFrobenius()
396  {
397  this->SetHexQualityMeasure( VTK_QUALITY_MED_ASPECT_FROBENIUS );
398  }
399  void SetHexQualityMeasureToMaxAspectFrobenius()
400  {
401  this->SetHexQualityMeasure( VTK_QUALITY_MAX_ASPECT_FROBENIUS );
402  }
403  void SetHexQualityMeasureToMaxEdgeRatios()
404  {
405  this->SetHexQualityMeasure( VTK_QUALITY_MAX_EDGE_RATIO );
406  }
407  void SetHexQualityMeasureToSkew()
408  {
409  this->SetHexQualityMeasure( VTK_QUALITY_SKEW );
410  }
411  void SetHexQualityMeasureToTaper()
412  {
413  this->SetHexQualityMeasure( VTK_QUALITY_TAPER );
414  }
415  void SetHexQualityMeasureToVolume()
416  {
417  this->SetHexQualityMeasure( VTK_QUALITY_VOLUME );
418  }
419  void SetHexQualityMeasureToStretch()
420  {
421  this->SetHexQualityMeasure( VTK_QUALITY_STRETCH );
422  }
423  void SetHexQualityMeasureToDiagonal()
424  {
425  this->SetHexQualityMeasure( VTK_QUALITY_DIAGONAL );
426  }
427  void SetHexQualityMeasureToDimension()
428  {
429  this->SetHexQualityMeasure( VTK_QUALITY_DIMENSION );
430  }
431  void SetHexQualityMeasureToOddy()
432  {
433  this->SetHexQualityMeasure( VTK_QUALITY_ODDY );
434  }
435  void SetHexQualityMeasureToCondition()
436  {
437  this->SetHexQualityMeasure( VTK_QUALITY_CONDITION );
438  }
439  void SetHexQualityMeasureToJacobian()
440  {
441  this->SetHexQualityMeasure( VTK_QUALITY_JACOBIAN );
442  }
443  void SetHexQualityMeasureToScaledJacobian()
444  {
445  this->SetHexQualityMeasure( VTK_QUALITY_SCALED_JACOBIAN );
446  }
447  void SetHexQualityMeasureToShear()
448  {
449  this->SetHexQualityMeasure( VTK_QUALITY_SHEAR );
450  }
451  void SetHexQualityMeasureToShape()
452  {
453  this->SetHexQualityMeasure( VTK_QUALITY_SHAPE );
454  }
455  void SetHexQualityMeasureToRelativeSizeSquared()
456  {
457  this->SetHexQualityMeasure( VTK_QUALITY_RELATIVE_SIZE_SQUARED );
458  }
459  void SetHexQualityMeasureToShapeAndSize()
460  {
461  this->SetHexQualityMeasure( VTK_QUALITY_SHAPE_AND_SIZE );
462  }
463  void SetHexQualityMeasureToShearAndSize()
464  {
465  this->SetHexQualityMeasure( VTK_QUALITY_SHEAR_AND_SIZE );
466  }
467  void SetHexQualityMeasureToDistortion()
468  {
469  this->SetHexQualityMeasure( VTK_QUALITY_DISTORTION );
470  }
472 
477  static double TriangleArea( vtkCell* cell );
478 
486  static double TriangleEdgeRatio( vtkCell* cell );
487 
495  static double TriangleAspectRatio( vtkCell* cell );
496 
503  static double TriangleRadiusRatio( vtkCell* cell );
504 
514  static double TriangleAspectFrobenius( vtkCell* cell );
515 
521  static double TriangleMinAngle( vtkCell* cell );
522 
528  static double TriangleMaxAngle( vtkCell* cell );
529 
534  static double TriangleCondition( vtkCell* cell );
535 
540  static double TriangleScaledJacobian( vtkCell* cell );
541 
546  static double TriangleRelativeSizeSquared( vtkCell* cell );
547 
552  static double TriangleShape( vtkCell* cell );
553 
558  static double TriangleShapeAndSize( vtkCell* cell );
559 
564  static double TriangleDistortion( vtkCell* cell );
565 
573  static double QuadEdgeRatio( vtkCell* cell );
574 
584  static double QuadAspectRatio( vtkCell* cell );
585 
599  static double QuadRadiusRatio( vtkCell* cell );
600 
612  static double QuadMedAspectFrobenius( vtkCell* cell );
613 
625  static double QuadMaxAspectFrobenius( vtkCell* cell );
626 
632  static double QuadMinAngle( vtkCell* cell );
633 
634  static double QuadMaxEdgeRatios( vtkCell* cell );
635  static double QuadSkew( vtkCell* cell );
636  static double QuadTaper( vtkCell* cell );
637  static double QuadWarpage( vtkCell* cell );
638  static double QuadArea( vtkCell* cell );
639  static double QuadStretch( vtkCell* cell );
640  static double QuadMaxAngle( vtkCell* cell );
641  static double QuadOddy( vtkCell* cell );
642  static double QuadCondition( vtkCell* cell );
643  static double QuadJacobian( vtkCell* cell );
644  static double QuadScaledJacobian( vtkCell* cell );
645  static double QuadShear( vtkCell* cell );
646  static double QuadShape( vtkCell* cell );
647  static double QuadRelativeSizeSquared( vtkCell* cell );
648  static double QuadShapeAndSize( vtkCell* cell );
649  static double QuadShearAndSize( vtkCell* cell );
650  static double QuadDistortion( vtkCell* cell );
651 
659  static double TetEdgeRatio( vtkCell* cell );
660 
668  static double TetAspectRatio( vtkCell* cell );
669 
676  static double TetRadiusRatio( vtkCell* cell );
677 
688  static double TetAspectFrobenius( vtkCell* cell );
689 
695  static double TetMinAngle( vtkCell* cell );
696 
698 
705  static double TetCollapseRatio( vtkCell* cell );
706  static double TetAspectBeta( vtkCell* cell );
707  static double TetAspectGamma( vtkCell* cell );
708  static double TetVolume( vtkCell* cell );
709  static double TetCondition( vtkCell* cell );
710  static double TetJacobian( vtkCell* cell );
711  static double TetScaledJacobian( vtkCell* cell );
712  static double TetShape( vtkCell* cell );
713  static double TetRelativeSizeSquared( vtkCell* cell );
714  static double TetShapeandSize( vtkCell* cell );
715  static double TetDistortion( vtkCell* cell );
717 
725  static double HexEdgeRatio( vtkCell* cell );
726 
733  static double HexMedAspectFrobenius( vtkCell* cell );
734 
736 
742  static double HexMaxAspectFrobenius( vtkCell* cell );
743  static double HexMaxEdgeRatio( vtkCell* cell );
744  static double HexSkew( vtkCell* cell );
745  static double HexTaper( vtkCell* cell );
746  static double HexVolume( vtkCell* cell );
747  static double HexStretch( vtkCell* cell );
748  static double HexDiagonal( vtkCell* cell );
749  static double HexDimension( vtkCell* cell );
750  static double HexOddy( vtkCell* cell );
751  static double HexCondition( vtkCell* cell );
752  static double HexJacobian( vtkCell* cell );
753  static double HexScaledJacobian( vtkCell* cell );
754  static double HexShear( vtkCell* cell );
755  static double HexShape( vtkCell* cell );
756  static double HexRelativeSizeSquared( vtkCell* cell );
757  static double HexShapeAndSize( vtkCell* cell );
758  static double HexShearAndSize( vtkCell* cell );
759  static double HexDistortion( vtkCell* cell );
761 
763 
769  virtual void SetRatio( int r ) { this->SetSaveCellQuality( r ); }
770  int GetRatio() { return this->GetSaveCellQuality(); }
771  vtkBooleanMacro(Ratio,int);
773 
775 
787  virtual void SetVolume( int cv )
788  {
789  if ( ! ((cv != 0) ^ (this->Volume != 0)) )
790  {
791  return;
792  }
793  this->Modified();
794  this->Volume = cv;
795  if ( this->Volume )
796  {
797  this->CompatibilityModeOn();
798  }
799  }
800  int GetVolume()
801  {
802  return this->Volume;
803  }
804  vtkBooleanMacro(Volume,int);
806 
808 
826  virtual void SetCompatibilityMode( int cm )
827  {
828  if ( !((cm != 0) ^ (this->CompatibilityMode != 0)) )
829  {
830  return;
831  }
832  this->CompatibilityMode = cm;
833  this->Modified();
834  if ( this->CompatibilityMode )
835  {
836  this->Volume = 1;
837  this->TetQualityMeasure = VTK_QUALITY_RADIUS_RATIO;
838  }
839  }
840  vtkGetMacro(CompatibilityMode,int);
841  vtkBooleanMacro(CompatibilityMode,int);
843 
844 protected:
845  vtkMeshQuality();
846  ~vtkMeshQuality();
847 
849 
852  static int GetCurrentTriangleNormal( double point[3], double normal[3] );
853 
859 
861  int Volume;
862 
864  static double CurrentTriNormal[3];
865 
866 private:
867  vtkMeshQuality( const vtkMeshQuality& ); // Not implemented.
868  void operator = ( const vtkMeshQuality& ); // Not implemented.
869 };
870 
871 #endif // vtkMeshQuality_h