1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkObject.cxx 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 // .NAME vtkCellQuality - Calculate functions of quality of the elements 16 // of a mesh 17 // 18 // .SECTION Description 19 // vtkCellQuality computes one or more functions of (geometric) quality for each 20 // cell of a mesh. The per-cell quality is added to the mesh's cell data, in an 21 // array named "Quality." Cell types not supported by this filter or undefined 22 // quality of supported cell types will have an entry of 0. 23 // 24 // .SECTION Caveats 25 // Most quadrilateral quality functions are intended for planar quadrilaterals 26 // only. The minimal angle is not, strictly speaking, a quality function, but 27 // it is provided because of its usage by many authors. 28 29 #ifndef vtkCellQuality_h 30 #define vtkCellQuality_h 31 32 #include "vtkFiltersVerdictModule.h" // For export macro 33 #include "vtkDataSetAlgorithm.h" 34 35 class vtkCell; 36 class vtkDataArray; 37 class vtkIdList; 38 class vtkPoints; 39 40 class VTKFILTERSVERDICT_EXPORT vtkCellQuality : public vtkDataSetAlgorithm 41 { 42 //BTX 43 enum 44 { 45 NONE = 0, 46 AREA, 47 ASPECT_BETA, 48 ASPECT_FROBENIUS, 49 ASPECT_GAMMA, 50 ASPECT_RATIO, 51 COLLAPSE_RATIO, 52 CONDITION, 53 DIAGONAL, 54 DIMENSION, 55 DISTORTION, 56 EDGE_RATIO, 57 JACOBIAN, 58 MAX_ANGLE, 59 MAX_ASPECT_FROBENIUS, 60 MAX_EDGE_RATIO, 61 MED_ASPECT_FROBENIUS, 62 MIN_ANGLE, 63 NORMAL, 64 ODDY, 65 RADIUS_RATIO, 66 RELATIVE_SIZE_SQUARED, 67 SCALED_JACOBIAN, 68 SHAPE, 69 SHAPE_AND_SIZE, 70 SHEAR, 71 SHEAR_AND_SIZE, 72 SKEW, 73 STRETCH, 74 TAPER, 75 VOLUME, 76 WARPAGE 77 }; 78 //ETX 79 80 public: 81 void PrintSelf (ostream&, vtkIndent); 82 vtkTypeMacro(vtkCellQuality, vtkDataSetAlgorithm); 83 static vtkCellQuality* New (); 84 85 // Description: 86 // Set/Get the particular estimator used to function the quality of all 87 // supported geometries. For qualities that are not defined for certain 88 // geometries, later program logic ensures that CellQualityNone static 89 // function will be used so that a predefined value is returned for the 90 // request. 91 // There is no default value for this call and valid values include all 92 // possible qualities supported by this class. 93 vtkSetMacro(QualityMeasure, int); 94 vtkGetMacro(QualityMeasure, int); 95 SetQualityMeasureToArea()96 void SetQualityMeasureToArea () 97 { 98 this->SetQualityMeasure(AREA); 99 } SetQualityMeasureToAspectBeta()100 void SetQualityMeasureToAspectBeta () 101 { 102 this->SetQualityMeasure(ASPECT_BETA); 103 } SetQualityMeasureToAspectFrobenius()104 void SetQualityMeasureToAspectFrobenius () 105 { 106 this->SetQualityMeasure(ASPECT_FROBENIUS); 107 } SetQualityMeasureToAspectGamma()108 void SetQualityMeasureToAspectGamma () 109 { 110 this->SetQualityMeasure(ASPECT_GAMMA); 111 } SetQualityMeasureToAspectRatio()112 void SetQualityMeasureToAspectRatio () 113 { 114 this->SetQualityMeasure(ASPECT_RATIO); 115 } SetQualityMeasureToCollapseRatio()116 void SetQualityMeasureToCollapseRatio () 117 { 118 this->SetQualityMeasure(COLLAPSE_RATIO); 119 } SetQualityMeasureToCondition()120 void SetQualityMeasureToCondition () 121 { 122 this->SetQualityMeasure(CONDITION); 123 } SetQualityMeasureToDiagonal()124 void SetQualityMeasureToDiagonal () 125 { 126 this->SetQualityMeasure(DIAGONAL); 127 } SetQualityMeasureToDimension()128 void SetQualityMeasureToDimension () 129 { 130 this->SetQualityMeasure(DIMENSION); 131 } SetQualityMeasureToDistortion()132 void SetQualityMeasureToDistortion () 133 { 134 this->SetQualityMeasure(DISTORTION); 135 } SetQualityMeasureToJacobian()136 void SetQualityMeasureToJacobian () 137 { 138 this->SetQualityMeasure(JACOBIAN); 139 } SetQualityMeasureToMaxAngle()140 void SetQualityMeasureToMaxAngle () 141 { 142 this->SetQualityMeasure(MAX_ANGLE); 143 } SetQualityMeasureToMaxAspectFrobenius()144 void SetQualityMeasureToMaxAspectFrobenius () 145 { 146 this->SetQualityMeasure(MAX_ASPECT_FROBENIUS); 147 } SetQualityMeasureToMaxEdgeRatio()148 void SetQualityMeasureToMaxEdgeRatio () 149 { 150 this->SetQualityMeasure(MAX_EDGE_RATIO); 151 } SetQualityMeasureToMedAspectFrobenius()152 void SetQualityMeasureToMedAspectFrobenius () 153 { 154 this->SetQualityMeasure(MED_ASPECT_FROBENIUS); 155 } SetQualityMeasureToMinAngle()156 void SetQualityMeasureToMinAngle () 157 { 158 this->SetQualityMeasure(MIN_ANGLE); 159 } SetQualityMeasureToOddy()160 void SetQualityMeasureToOddy () 161 { 162 this->SetQualityMeasure(ODDY); 163 } SetQualityMeasureToRadiusRatio()164 void SetQualityMeasureToRadiusRatio () 165 { 166 this->SetQualityMeasure(RADIUS_RATIO); 167 } SetQualityMeasureToRelativeSizeSquared()168 void SetQualityMeasureToRelativeSizeSquared () 169 { 170 this->SetQualityMeasure(RELATIVE_SIZE_SQUARED); 171 } SetQualityMeasureToScaledJacobian()172 void SetQualityMeasureToScaledJacobian () 173 { 174 this->SetQualityMeasure(SCALED_JACOBIAN); 175 } SetQualityMeasureToShapeAndSize()176 void SetQualityMeasureToShapeAndSize () 177 { 178 this->SetQualityMeasure(SHAPE_AND_SIZE); 179 } SetQualityMeasureToShape()180 void SetQualityMeasureToShape () 181 { 182 this->SetQualityMeasure(SHAPE); 183 } SetQualityMeasureToShearAndSize()184 void SetQualityMeasureToShearAndSize () 185 { 186 this->SetQualityMeasure(SHEAR_AND_SIZE); 187 } SetQualityMeasureToShear()188 void SetQualityMeasureToShear () 189 { 190 this->SetQualityMeasure(SHEAR); 191 } SetQualityMeasureToSkew()192 void SetQualityMeasureToSkew () 193 { 194 this->SetQualityMeasure(SKEW); 195 } SetQualityMeasureToStretch()196 void SetQualityMeasureToStretch () 197 { 198 this->SetQualityMeasure(STRETCH); 199 } SetQualityMeasureToTaper()200 void SetQualityMeasureToTaper () 201 { 202 this->SetQualityMeasure(TAPER); 203 } SetQualityMeasureToVolume()204 void SetQualityMeasureToVolume () 205 { 206 this->SetQualityMeasure(VOLUME); 207 } SetQualityMeasureToWarpage()208 void SetQualityMeasureToWarpage () 209 { 210 this->SetQualityMeasure(WARPAGE); 211 } 212 213 // Description: 214 // Set/Get the return value for unsupported geometry. Unsupported geometry 215 // are geometries that are not supported by this filter currently, future 216 // implementation might include support for them. The defalut value for 217 // UnsupportedGeometry is -1. 218 vtkSetMacro(UnsupportedGeometry, double); 219 vtkGetMacro(UnsupportedGeometry, double); 220 221 // Description: 222 // Set/Get the return value for undefined quality. Undefined quality 223 // are qualities that could be addressed by this filter but is not well 224 // defined for the particular geometry of cell in question, e.g. a 225 // volume query for a triangle. Undefined quality will always be undefined. 226 // The default value for UndefinedQuality is -1. 227 vtkSetMacro(UndefinedQuality, double); 228 vtkGetMacro(UndefinedQuality, double); 229 230 double TriangleStripArea (vtkCell*); 231 double PixelArea (vtkCell*); 232 double PolygonArea (vtkCell*); 233 234 protected: 235 ~vtkCellQuality (); 236 vtkCellQuality (); 237 238 // Description: 239 // Set/Get the particular estimator used to function the quality of triangles. 240 // The default is NONE and valid values also include 241 // ASPECT_FROBENIUS 242 // ASPECT_RATIO 243 // CONDITION 244 // DISTORTION 245 // EDGE_RATIO 246 // MAX_ANGLE 247 // MIN_ANGLE 248 // RADIUS_RATIO 249 // RELATIVE_SIZE_SQUARED 250 // SCALED_JACOBIAN 251 // SHAPE 252 // SHAPE_AND_SIZE 253 double ComputeTriangleQuality (vtkCell*); 254 255 // Description: 256 // Set/Get the particular estimator used to measure the quality of quadrilaterals. 257 // The default is NONE and valid values also include 258 // AREA 259 // ASPECT_RATIO 260 // CONDITION 261 // DISTORTION 262 // EDGE_RATIO 263 // JACOBIAN 264 // MAX_ANGLE 265 // MAX_EDGE_RATIO 266 // MIN_ANGLE 267 // ODDY 268 // RADIUS_RATIO 269 // RELATIVE_SIZE_SQUARED 270 // SCALED_JACOBIAN 271 // SHAPE 272 // SHAPE_AND_SIZE 273 // SHEAR 274 // SHEAR_AND_SIZE 275 // SKEW 276 // STRETCH 277 // TAPER 278 // WARPAGE 279 // Scope: Except for EDGE_RATIO, these estimators are intended for planar 280 // quadrilaterals only; use at your own risk if you really want to assess non-planar 281 // quadrilateral quality with those. 282 double ComputeQuadQuality (vtkCell*); 283 284 // Description: 285 // Set/Get the particular estimator used to measure the quality of tetrahedra. 286 // The default is NONE and valid values also include 287 // ASPECT_BETA 288 // ASPECT_FROBENIUS 289 // ASPECT_GAMMA 290 // ASPECT_RATIO 291 // COLLAPSE_RATIO 292 // CONDITION 293 // DISTORTION 294 // EDGE_RATIO 295 // JACOBIAN 296 // RADIUS_RATIO (identical to Verdict's aspect ratio beta) 297 // RELATIVE_SIZE_SQUARED 298 // SCALED_JACOBIAN 299 // SHAPE 300 // SHAPE_AND_SIZE 301 // VOLUME 302 double ComputeTetQuality (vtkCell*); 303 304 // Description: 305 // Set/Get the particular estimator used to measure the quality of hexahedra. 306 // The default is NONE and valid values also include 307 // CONDITION 308 // DIAGONAL 309 // DIMENSION 310 // DISTORTION 311 // EDGE_RATIO 312 // JACOBIAN 313 // MAX_ASPECT_FROBENIUS 314 // MAX_ASPECT_FROBENIUS 315 // MAX_EDGE_RATIO 316 // ODDY 317 // RELATIVE_SIZE_SQUARED 318 // SCALED_JACOBIAN 319 // SHAPE 320 // SHAPE_AND_SIZE 321 // SHEAR 322 // SHEAR_AND_SIZE 323 // SKEW 324 // STRETCH 325 // TAPER 326 // VOLUME 327 double ComputeHexQuality (vtkCell*); 328 329 // Description: 330 // Set/Get the particular estimator used to measure the quality of triangle 331 // strip. 332 // The default is NONE and valid values also include 333 // AREA 334 double ComputeTriangleStripQuality (vtkCell*); 335 336 // Description: 337 // Set/Get the particular estimator used to measure the quality of pixel. 338 // The default is NONE and valid values also include 339 // AREA 340 double ComputePixelQuality (vtkCell*); 341 342 virtual int RequestData 343 (vtkInformation*, vtkInformationVector**, vtkInformationVector*); 344 345 // Description: 346 // A function called by some VERDICT triangle quality functions to test for 347 // inverted triangles. 348 // VERDICT only accepts plain function pointers which means the follow 349 // function and member must be static. Unfortunately, this makes the use of 350 // this part not thread safe. 351 static int GetCurrentTriangleNormal (double point [3], double normal [3]); 352 static double CurrentTriNormal [3]; 353 354 int QualityMeasure; 355 356 // Default return value for unsupported geometry 357 double UnsupportedGeometry; 358 359 // Default return value for qualities that are not well-defined for certain 360 // types of supported geometries. e.g. volume of a triangle 361 double UndefinedQuality; 362 363 private: 364 vtkIdList* PointIds; 365 vtkPoints* Points; 366 367 vtkCellQuality(const vtkCellQuality&); // Not implemented 368 void operator=(const vtkCellQuality&); // Not implemented 369 }; 370 371 #endif // vtkCellQuality_h 372