Commit 52008a61 authored by miller86's avatar miller86

adding face planarity mesh quality expression

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@7464 18c085ea-50e0-402c-830e-de6fd14e8384
parent f89f61b2
......@@ -1334,6 +1334,7 @@ avtDatabase::Convert1DVarMDsToCurveMDs(avtDatabaseMetaData *md)
md->GetMeshes(it->second).hideFromGUI = true;
}
// ****************************************************************************
// Method: avtDatabase::AddMeshQualityExpressions
//
// Purpose:
......@@ -1375,6 +1376,8 @@ avtDatabase::Convert1DVarMDsToCurveMDs(avtDatabaseMetaData *md)
// Eric Brugger, Thu Aug 7 08:52:06 PDT 2008
// Updated for verdict version 110.
//
// Mark C. Miller, Wed Jun 3 14:51:09 PDT 2009
// Added face_planarity expressions.
// ****************************************************************************
void
......@@ -1424,7 +1427,7 @@ avtDatabase::AddMeshQualityExpressions(avtDatabaseMetaData *md)
continue;
nmeshes_done++;
const int nPairs = 24;
const int nPairs = 26;
MQExprTopoPair exprs[nPairs];
exprs[0] = MQExprTopoPair("area", 2);
exprs[1] = MQExprTopoPair("aspect_gamma", 3);
......@@ -1450,6 +1453,8 @@ avtDatabase::AddMeshQualityExpressions(avtDatabaseMetaData *md)
exprs[21] = MQExprTopoPair("taper", -1);
exprs[22] = MQExprTopoPair("volume", 3);
exprs[23] = MQExprTopoPair("warpage", 2);
exprs[24] = MQExprTopoPair("face_planarity", 3);
exprs[25] = MQExprTopoPair("relative_face_planarity", 3);
for (int j = 0 ; j < nPairs ; j++)
{
......
......@@ -429,6 +429,7 @@ Math_src= \
MeshQuality_src= \
MeshQuality/avtCornerAngle.C \
MeshQuality/avtEdgeLength.C \
MeshQuality/avtFacePlanarity.C \
MeshQuality/avtNeighborExpression.C \
MeshQuality/avtNodeDegreeExpression.C \
MeshQuality/avtRevolvedSurfaceArea.C \
......
......@@ -36,18 +36,15 @@
*
*****************************************************************************/
#include <avtExprNode.h>
#include <avtCornerAngle.h>
#include <avtCornerAngle.h>
#include <avtEdgeLength.h>
#include <avtEdgeLength.h>
#include <avtExternalNodeExpression.h>
#include <avtFacePlanarity.h>
#include <avtNeighborExpression.h>
#include <avtNodeDegreeExpression.h>
#include <avtRevolvedSurfaceArea.h>
#include <avtRevolvedVolume.h>
#include <avtSideVolume.h>
#include <avtSideVolume.h>
#include <avtVMetricArea.h>
#include <avtVMetricAspectGamma.h>
#include <avtVMetricAspectRatio.h>
......@@ -67,7 +64,6 @@
#include <avtVMetricStretch.h>
#include <avtVMetricTaper.h>
#include <avtVMetricVolume.h>
#include <avtVMetricVolume.h>
#include <avtVMetricWarpage.h>
// ****************************************************************************
......@@ -88,6 +84,8 @@
//
// Modifications:
//
// Mark C. Miller, Wed Jun 3 14:50:50 PDT 2009
// Added face_planarity expressions.
// ****************************************************************************
avtExpressionFilter *
......@@ -188,6 +186,17 @@ avtFunctionExpr::CreateMeshQualityFilters(const string &functionName) const
f = new avtRevolvedVolume;
else if (functionName == "revolved_surface_area")
f = new avtRevolvedSurfaceArea;
else if (functionName == "face_planarity")
{
avtFacePlanarity *fp = new avtFacePlanarity();
return fp;
}
else if (functionName == "relative_face_planarity")
{
avtFacePlanarity *fp = new avtFacePlanarity();
fp->SetTakeRelative(true);
return fp;
}
return f;
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400142
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtFacePlanarity.C //
// ************************************************************************* //
#include <avtFacePlanarity.h>
#include <float.h>
#include <vtkCell.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkPoints.h>
static double
GetFacePlanarityForFace(vtkCell *face, bool takeRel)
{
int i, j;
int nPoints = face->GetNumberOfPoints();
if (nPoints <= 3)
return 0;
//
// Compute average edge length first if necessary.
//
double len_sum = 1;
if (takeRel)
{
len_sum = 0;
for (i = 0; i < nPoints; i++)
{
int ptids[2];
double ptx[2][3];
for (j = 0; j < 2; j++)
{
ptids[j] = (i+j) % nPoints;
face->GetPoints()->GetPoint(ptids[j],ptx[j]);
}
double n[3] = {ptx[0][0] - ptx[1][0], ptx[0][1] - ptx[1][1], ptx[0][2] - ptx[1][2]};
double n_len = sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);
len_sum += n_len;
}
len_sum /= nPoints;
}
double distMax = 0;
for (i = 0; i < nPoints; i++)
{
int ptids[4];
double ptx[4][3];
for (j = 0; j < 4; j++)
{
ptids[j] = (i+j) % nPoints;
face->GetPoints()->GetPoint(ptids[j],ptx[j]);
}
//
// Compute a vector normal to plane of first 3 points
// n1 = p0 - p1, n2 = p2 - p1
//
double n1[3] = {ptx[0][0] - ptx[1][0], ptx[0][1] - ptx[1][1], ptx[0][2] - ptx[1][2]};
double n2[3] = {ptx[2][0] - ptx[1][0], ptx[2][1] - ptx[1][1], ptx[2][2] - ptx[1][2]};
double n1Xn2[3] = { n1[1]*n2[2] - n1[2]*n2[1],
-(n1[0]*n2[2] - n1[2]*n2[0]),
n1[0]*n2[1] - n1[1]*n2[0]};
//
// Normalize it.
//
double n1Xn2_len = sqrt(n1Xn2[0]*n1Xn2[0]+n1Xn2[1]*n1Xn2[1]+n1Xn2[2]*n1Xn2[2]);
if (n1Xn2_len > 0)
{
n1Xn2[0] /= n1Xn2_len;
n1Xn2[1] /= n1Xn2_len;
n1Xn2[2] /= n1Xn2_len;
}
//
// Compute distance to 4th point via dot-product with normal computed above.
//
double p4[3] = {ptx[3][0] - ptx[1][0], ptx[3][1] - ptx[1][1], ptx[3][2] - ptx[1][2]};
double dist = p4[0] * n1Xn2[0] + p4[1] * n1Xn2[1] + p4[2] * n1Xn2[2];
if (dist < 0) dist = -dist;
if (takeRel)
dist /= len_sum;
if (dist > distMax)
distMax = dist;
}
return distMax;
}
// ****************************************************************************
// Funcion: GetFacePlanarityForCell
//
// Purpose: Compute Face planarity measure over whole cell.
//
// Programmer: Mark C. Miller
// Creation: June 3, 2009
//
// ****************************************************************************
static double
GetFacePlanarityForCell(vtkCell *cell, bool takeRel)
{
int celltype = cell->GetCellType();
if (celltype == VTK_EMPTY_CELL ||
celltype == VTK_VERTEX ||
celltype == VTK_POLY_VERTEX ||
celltype == VTK_LINE ||
celltype == VTK_POLY_LINE ||
celltype == VTK_TRIANGLE ||
celltype == VTK_TRIANGLE_STRIP ||
celltype == VTK_POLYGON || // assumed 2d
celltype == VTK_PIXEL ||
celltype == VTK_TETRA)
{
return 0;
}
else if (celltype == VTK_QUAD)
{
return GetFacePlanarityForFace(cell, takeRel);
}
else
{
int nFaces = cell->GetNumberOfFaces();
if (nFaces == 0)
return 0;
double distMax = 0;
for (int f = 0; f < nFaces; f++)
{
double dist = GetFacePlanarityForFace(cell->GetFace(f), takeRel);
if (dist > distMax)
distMax = dist;
}
return distMax;
}
}
// ****************************************************************************
// Method: avtFacePlanarity constructor
//
// Programmer: Hank Childs
// Creation: May 19, 2008
//
// ****************************************************************************
avtFacePlanarity::avtFacePlanarity()
{
takeRel = false;
}
// ****************************************************************************
// Method: avtFacePlanarity::DeriveVariable
//
// Purpose:
// Find the minimum or maximum corner angle.
//
// Programmer: Hank Childs
// Creation: May 19, 2008
//
// ****************************************************************************
vtkDataArray *
avtFacePlanarity::DeriveVariable(vtkDataSet *in_ds)
{
vtkFloatArray *arr = vtkFloatArray::New();
int ncells = in_ds->GetNumberOfCells();
arr->SetNumberOfTuples(ncells);
for (int i = 0 ; i < ncells ; i++)
{
vtkCell *cell = in_ds->GetCell(i);
float vol = (float) GetFacePlanarityForCell(cell, takeRel);
arr->SetTuple(i, &vol);
}
return arr;
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400142
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtFacePlanarity.h //
// ************************************************************************* //
#ifndef AVT_FACE_PLANARITY_H
#define AVT_FACE_PLANARITY_H
#include <avtSingleInputExpressionFilter.h>
class vtkCell;
// ****************************************************************************
// Class: avtFacePlanarity
//
// Purpose: Calculates either relative or absolute face planarity for a cell.
// Face planarity is defined ONLY for cells that have at least one face that
// is non-simplex (e.g. non-triangle). That means wedge, pyramid and hex
// cells. For a given face, a face planarity measure of zero means all the
// points on the face lie on the same plane. This is true by definition for
// triangular faces. For quadrilateral faces, the distance between the 4th
// node and the plane defined by the first 3 nodes represents the face
// planarity measure. If this distance is divided by the average of the
// lengths of the 4 edges, it is a relative planarity measure for the face.
// Finally, the face planarity measure for a whole cell consisting
// of potentially several non-triangular faces is taken to be the maximum
// over its faces.
//
// Programmer: Mark C. Miller
// Created: Wed Jun 3 12:34:41 PDT 2009
//
// ****************************************************************************
class EXPRESSION_API avtFacePlanarity : public avtSingleInputExpressionFilter
{
public:
avtFacePlanarity();
virtual const char *GetType(void) { return "avtFacePlanarity"; };
virtual const char *GetDescription(void)
{ return "Calculating face planarities"; };
void SetTakeRelative(bool tr) { takeRel = tr; };
protected:
bool takeRel;
virtual vtkDataArray *DeriveVariable(vtkDataSet *);
virtual bool IsPointVariable(void) { return false; };
virtual int GetVariableDimension() { return 1; };
};
#endif
......@@ -189,6 +189,8 @@ const char *expr_meshquality[] = {
"stretch",
"taper",
"warpage",
"face_planarity",
"relative_face_planarity",
NULL
};
......
../../avt/Expressions/MeshQuality/avtFacePlanarity.h
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment