1 /*=========================================================================
2
3 Module: $RCSfile: V_EdgeMetric.cpp,v $
4
5 Copyright (c) 2006 Sandia Corporation.
6 All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13 =========================================================================*/
14
15 /*
16 *
17 * V_EdgeMetric.cpp contains quality calcultions for edges
18 *
19 * This file is part of VERDICT
20 *
21 */
22
23 #define VERDICT_EXPORTS
24
25 #include "moab/verdict.h"
26 #include <cmath>
27
28 /*!
29 length of and edge
30 length is calculated by taking the distance between the end nodes
31 */
32 C_FUNC_DEF double v_edge_length( int /*num_nodes*/, double coordinates[][3] )
33 {
34
35 double x = coordinates[1][0] - coordinates[0][0];
36 double y = coordinates[1][1] - coordinates[0][1];
37 double z = coordinates[1][2] - coordinates[0][2];
38 return (double)( sqrt( x * x + y * y + z * z ) );
39 }
40
41 /*!
42
43 higher order function for calculating multiple metrics at once.
44
45 for an edge, there is only one metric, edge length.
46 */
47
48 C_FUNC_DEF void edge_quality( int num_nodes,
49 double coordinates[][3],
50 unsigned int metrics_request_flag,
51 struct EdgeMetricVals* metric_vals )
52 {
53 if( metrics_request_flag & V_EDGE_LENGTH ) metric_vals->length = v_edge_length( num_nodes, coordinates );
54 }