1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
/*
* Copyright 2003 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the
* U.S. Government. Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that this Notice and any
* statement of authorship are reproduced on all copies.
*/
#include "vtkMeshQuality.h"
#include "vtkDebugLeaks.h"
#include "vtkTestUtilities.h"
#include "vtkUnstructuredGrid.h"
#include "vtkUnstructuredGridReader.h"
#include "vtkFieldData.h"
int DumpQualityStats( vtkMeshQuality* iq, const char *arrayname )
{
cout << " cardinality: "
<< iq->GetOutput()->GetFieldData()->GetArray( arrayname )->GetComponent( 0, 4 )
<< " , range: "
<< iq->GetOutput()->GetFieldData()->GetArray( arrayname )->GetComponent( 0, 0 )
<< " - "
<< iq->GetOutput()->GetFieldData()->GetArray( arrayname )->GetComponent( 0, 2 )
<< endl;
cout << " average: " << iq->GetOutput()->GetFieldData()->GetArray( arrayname )->GetComponent( 0, 1 )
<< " , standard deviation: "
<< sqrt(fabs(iq->GetOutput()->GetFieldData()->GetArray( arrayname )->GetComponent( 0, 3 )))
<< endl;
return 0;
}
int MeshQuality( int argc, char* argv[] )
{
vtkUnstructuredGridReader* mr = vtkUnstructuredGridReader::New();
vtkUnstructuredGrid* ug;
vtkMeshQuality* iq = vtkMeshQuality::New();
char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/uGridEx.vtk");
mr->SetFileName( fname );
mr->Update();
ug = mr->GetOutput();
iq->SetInput( ug );
if ( ug->GetNumberOfCells() )
{
cout << endl;
cout << "Triangle quality of mesh" << endl;
cout << mr->GetFileName()
<< endl;
iq->SetTriangleQualityMeasureToEdgeRatio();
iq->Update();
cout << " Edge Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Triangle Quality" );
iq->SetTriangleQualityMeasureToAspectRatio();
iq->Update();
cout << " Aspect Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Triangle Quality" );
iq->SetTriangleQualityMeasureToRadiusRatio();
iq->Update();
cout << " Radius Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Triangle Quality" );
iq->SetTriangleQualityMeasureToAspectFrobenius();
iq->Update();
cout << " Frobenius Norm:"
<< endl;
DumpQualityStats( iq, "Mesh Triangle Quality" );
iq->SetTriangleQualityMeasureToMinAngle();
iq->Update();
cout << " Minimal Angle:"
<< endl;
DumpQualityStats( iq, "Mesh Triangle Quality" );
cout << endl;
cout << "Quadrilatedral quality of mesh" << endl;
cout << mr->GetFileName()
<< endl;
iq->SetQuadQualityMeasureToEdgeRatio();
iq->Update();
cout << " Edge Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Quadrilateral Quality" );
iq->SetQuadQualityMeasureToAspectRatio();
iq->Update();
cout << " Aspect Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Quadrilateral Quality" );
iq->SetQuadQualityMeasureToRadiusRatio();
iq->Update();
cout << " Radius Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Quadrilateral Quality" );
iq->SetQuadQualityMeasureToMedAspectFrobenius();
iq->Update();
cout << " Average Frobenius Norm:"
<< endl;
DumpQualityStats( iq, "Mesh Quadrilateral Quality" );
iq->SetQuadQualityMeasureToMaxAspectFrobenius();
iq->Update();
cout << " Maximal Frobenius Norm:"
<< endl;
DumpQualityStats( iq, "Mesh Quadrilateral Quality" );
iq->SetQuadQualityMeasureToMinAngle();
iq->Update();
cout << " Minimal Angle:"
<< endl;
DumpQualityStats( iq, "Mesh Quadrilateral Quality" );
cout << endl;
cout << "Tetrahedral quality of mesh" << endl;
cout << mr->GetFileName()
<< endl;
iq->SetTetQualityMeasureToEdgeRatio();
iq->Update();
cout << " Edge Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Tetrahedron Quality" );
iq->SetTetQualityMeasureToAspectRatio();
iq->Update();
cout << " Aspect Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Tetrahedron Quality" );
iq->SetTetQualityMeasureToRadiusRatio();
iq->Update();
cout << " Radius Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Tetrahedron Quality" );
iq->SetTetQualityMeasureToAspectFrobenius();
iq->Update();
cout << " Frobenius Norm:"
<< endl;
DumpQualityStats( iq, "Mesh Tetrahedron Quality" );
iq->SetTetQualityMeasureToMinAngle();
iq->Update();
cout << " Minimal Dihedral Angle:"
<< endl;
DumpQualityStats( iq, "Mesh Tetrahedron Quality" );
iq->SetTetQualityMeasureToCollapseRatio();
iq->Update();
cout << " Collapse Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Tetrahedron Quality" );
cout << endl;
cout << "Hexahedral quality of mesh" << endl;
cout << mr->GetFileName()
<< endl;
iq->SetHexQualityMeasureToEdgeRatio();
iq->Update();
cout << " Edge Ratio:"
<< endl;
DumpQualityStats( iq, "Mesh Hexahedron Quality" );
cout << endl;
}
iq->Delete();
mr->Delete();
delete [] fname;
return 0;
}
|