1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkCellValidator.h 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 /** 16 * @class vtkCellValidator 17 * @brief validates cells in a dataset 18 * 19 * 20 * vtkCellValidator accepts as input a dataset and adds integral cell data 21 * to it corresponding to the "validity" of each cell. The validity field 22 * encodes a bitfield for identifying problems that prevent a cell from standard 23 * use, including: 24 * 25 * WrongNumberOfPoints: filters assume that a cell has access to the 26 * appropriate number of points that comprise it. This 27 * assumption is often tacit, resulting in unexpected 28 * behavior when the condition is not met. This check 29 * simply confirms that the cell has the minimum number 30 * of points needed to describe it. 31 * 32 * IntersectingEdges: cells that incorrectly describe the order of their 33 * points often manifest with intersecting edges or 34 * intersecting faces. Given a tolerance, this check 35 * ensures that two edges from a two-dimensional cell 36 * are separated by at least the tolerance (discounting 37 * end-to-end connections). 38 * 39 * IntersectingFaces: cells that incorrectly describe the order of their 40 * points often manifest with intersecting edges or 41 * intersecting faces. Given a tolerance, this check 42 * ensures that two faces from a three-dimensional cell 43 * do not intersect. 44 * 45 * NoncontiguousEdges: another symptom of incorrect point ordering within a 46 * cell is the presence of noncontiguous edges where 47 * contiguous edges are otherwise expected. Given a 48 * tolerance, this check ensures that edges around the 49 * perimeter of a two-dimensional cell are contiguous. 50 * 51 * Nonconvex: many algorithms implicitly require that all input three- 52 * dimensional cells be convex. This check uses the generic 53 * convexity checkers implemented in vtkPolygon and vtkPolyhedron 54 * to test this requirement. 55 * 56 * FacesAreOrientedIncorrectly: All three-dimensional cells have an implicit 57 * expectation for the orientation of their 58 * faces. While the convention is unfortunately 59 * inconsistent across cell types, it is usually 60 * required that cell faces point outward. This 61 * check tests that the faces of a cell point in 62 * the direction required by the cell type, 63 * taking into account the cell types with 64 * nonstandard orientation requirements. 65 * 66 * 67 * @sa 68 * vtkCellQuality 69 */ 70 71 #ifndef vtkCellValidator_h 72 #define vtkCellValidator_h 73 74 #include "vtkDataSetAlgorithm.h" 75 #include "vtkFiltersGeneralModule.h" // For export macro 76 77 class vtkCell; 78 class vtkGenericCell; 79 class vtkEmptyCell; 80 class vtkVertex; 81 class vtkPolyVertex; 82 class vtkLine; 83 class vtkPolyLine; 84 class vtkTriangle; 85 class vtkTriangleStrip; 86 class vtkPolygon; 87 class vtkPixel; 88 class vtkQuad; 89 class vtkTetra; 90 class vtkVoxel; 91 class vtkHexahedron; 92 class vtkWedge; 93 class vtkPyramid; 94 class vtkPentagonalPrism; 95 class vtkHexagonalPrism; 96 class vtkQuadraticEdge; 97 class vtkQuadraticTriangle; 98 class vtkQuadraticQuad; 99 class vtkQuadraticPolygon; 100 class vtkQuadraticTetra; 101 class vtkQuadraticHexahedron; 102 class vtkQuadraticWedge; 103 class vtkQuadraticPyramid; 104 class vtkBiQuadraticQuad; 105 class vtkTriQuadraticHexahedron; 106 class vtkTriQuadraticPyramid; 107 class vtkQuadraticLinearQuad; 108 class vtkQuadraticLinearWedge; 109 class vtkBiQuadraticQuadraticWedge; 110 class vtkBiQuadraticQuadraticHexahedron; 111 class vtkBiQuadraticTriangle; 112 class vtkCubicLine; 113 class vtkConvexPointSet; 114 class vtkPolyhedron; 115 class vtkLagrangeCurve; 116 class vtkLagrangeTriangle; 117 class vtkLagrangeQuadrilateral; 118 class vtkLagrangeTetra; 119 class vtkLagrangeHexahedron; 120 class vtkLagrangeWedge; 121 class vtkBezierCurve; 122 class vtkBezierTriangle; 123 class vtkBezierQuadrilateral; 124 class vtkBezierTetra; 125 class vtkBezierHexahedron; 126 class vtkBezierWedge; 127 128 class VTKFILTERSGENERAL_EXPORT vtkCellValidator : public vtkDataSetAlgorithm 129 { 130 public: 131 vtkTypeMacro(vtkCellValidator, vtkDataSetAlgorithm); 132 void PrintSelf(ostream& os, vtkIndent indent) override; 133 134 // Description: 135 // Construct to compute the validity of cells. 136 static vtkCellValidator* New(); 137 138 enum State : short 139 { 140 Valid = 0x0, 141 WrongNumberOfPoints = 0x01, 142 IntersectingEdges = 0x02, 143 IntersectingFaces = 0x04, 144 NoncontiguousEdges = 0x08, 145 Nonconvex = 0x10, 146 FacesAreOrientedIncorrectly = 0x20, 147 }; 148 149 friend inline State operator&(State a, State b) 150 { 151 return static_cast<State>(static_cast<short>(a) & static_cast<short>(b)); 152 } 153 friend inline State operator|(State a, State b) 154 { 155 return static_cast<State>(static_cast<short>(a) | static_cast<short>(b)); 156 } 157 friend inline State& operator&=(State& a, State b) { return a = a & b; } 158 159 friend inline State& operator|=(State& a, State b) { return a = a | b; } 160 161 static void PrintState(State state, ostream& os, vtkIndent indent); 162 163 static State Check(vtkGenericCell*, double tolerance); 164 static State Check(vtkCell*, double tolerance); 165 166 static State Check(vtkEmptyCell*, double tolerance); 167 static State Check(vtkVertex*, double tolerance); 168 static State Check(vtkPolyVertex*, double tolerance); 169 static State Check(vtkLine*, double tolerance); 170 static State Check(vtkPolyLine*, double tolerance); 171 static State Check(vtkTriangle*, double tolerance); 172 static State Check(vtkTriangleStrip*, double tolerance); 173 static State Check(vtkPolygon*, double tolerance); 174 static State Check(vtkPixel*, double tolerance); 175 static State Check(vtkQuad*, double tolerance); 176 static State Check(vtkTetra*, double tolerance); 177 static State Check(vtkVoxel*, double tolerance); 178 static State Check(vtkHexahedron*, double tolerance); 179 static State Check(vtkWedge*, double tolerance); 180 static State Check(vtkPyramid*, double tolerance); 181 static State Check(vtkPentagonalPrism*, double tolerance); 182 static State Check(vtkHexagonalPrism*, double tolerance); 183 static State Check(vtkQuadraticEdge*, double tolerance); 184 static State Check(vtkQuadraticTriangle*, double tolerance); 185 static State Check(vtkQuadraticQuad*, double tolerance); 186 static State Check(vtkQuadraticPolygon*, double tolerance); 187 static State Check(vtkQuadraticTetra*, double tolerance); 188 static State Check(vtkQuadraticHexahedron*, double tolerance); 189 static State Check(vtkQuadraticWedge*, double tolerance); 190 static State Check(vtkQuadraticPyramid*, double tolerance); 191 static State Check(vtkBiQuadraticQuad*, double tolerance); 192 static State Check(vtkTriQuadraticHexahedron*, double tolerance); 193 static State Check(vtkTriQuadraticPyramid*, double tolerance); 194 static State Check(vtkQuadraticLinearQuad*, double tolerance); 195 static State Check(vtkQuadraticLinearWedge*, double tolerance); 196 static State Check(vtkBiQuadraticQuadraticWedge*, double tolerance); 197 static State Check(vtkBiQuadraticQuadraticHexahedron*, double tolerance); 198 static State Check(vtkBiQuadraticTriangle*, double tolerance); 199 static State Check(vtkCubicLine*, double tolerance); 200 static State Check(vtkConvexPointSet*, double tolerance); 201 static State Check(vtkPolyhedron*, double tolerance); 202 static State Check(vtkLagrangeCurve*, double tolerance); 203 static State Check(vtkLagrangeTriangle*, double tolerance); 204 static State Check(vtkLagrangeQuadrilateral*, double tolerance); 205 static State Check(vtkLagrangeTetra*, double tolerance); 206 static State Check(vtkLagrangeHexahedron*, double tolerance); 207 static State Check(vtkLagrangeWedge*, double tolerance); 208 static State Check(vtkBezierCurve*, double tolerance); 209 static State Check(vtkBezierTriangle*, double tolerance); 210 static State Check(vtkBezierQuadrilateral*, double tolerance); 211 static State Check(vtkBezierTetra*, double tolerance); 212 static State Check(vtkBezierHexahedron*, double tolerance); 213 static State Check(vtkBezierWedge*, double tolerance); 214 215 ///@{ 216 /** 217 * Set/Get the tolerance. This value is used as an epsilon for floating point 218 * equality checks throughout the cell checking process. The default value is 219 * FLT_EPSILON. 220 */ 221 vtkSetClampMacro(Tolerance, double, 0.0, VTK_DOUBLE_MAX); 222 vtkGetMacro(Tolerance, double); 223 ///@} 224 225 protected: 226 vtkCellValidator(); 227 ~vtkCellValidator() override = default; 228 229 double Tolerance; 230 231 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; 232 233 static bool NoIntersectingEdges(vtkCell* cell, double tolerance); 234 static bool NoIntersectingFaces(vtkCell* cell, double tolerance); 235 static bool ContiguousEdges(vtkCell* twoDimensionalCell, double tolerance); 236 static bool Convex(vtkCell* cell, double tolerance); 237 static bool FacesAreOrientedCorrectly(vtkCell* threeDimensionalCell, double tolerance); 238 239 private: 240 vtkCellValidator(const vtkCellValidator&) = delete; 241 void operator=(const vtkCellValidator&) = delete; 242 }; 243 244 #endif 245