MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 #include "moab/VtkUtil.hpp" 00017 00018 namespace moab 00019 { 00020 00021 const char* VtkUtil::vtkTypeNames[] = { 00022 "unsigned_char", // MB_TYPE_OPAQUE 00023 "int", // MB_TYPE_INTEGER 00024 "double", // MB_TYPE_DOUBLE 00025 "bit", // MB_TYPE_BIT 00026 "unsigned_long", // MB_TYPE_HANDLE 00027 }; 00028 00029 /* 00030 const unsigned VtkUtil::typeSizes[] = { 00031 1, // MB_TYPE_OPAQUE 00032 sizeof(int), // MB_TYPE_INTEGER 00033 sizeof(double), // MB_TYPE_DOUBLE 00034 1, // MB_TYPE_BIT 00035 sizeof(EntityHandle), // MB_TYPE_HANDLE 00036 }; 00037 */ 00038 00039 // Define node ordering for those types for which 00040 // the VTK and MOAB ordering doesn't match. The values 00041 // contained in the array are MOAB connectivity indices, 00042 // and the values used to index the arrays are VTK 00043 // connectivity indices. 00044 const unsigned pixel[] = { 0, 1, 3, 2 }; 00045 const unsigned voxel[] = { 0, 1, 3, 2, 4, 5, 7, 6 }; 00046 const unsigned wedge[] = { 0, 2, 1, // bottom corners 00047 3, 5, 4, // top corners 00048 8, 7, 6, // bottom edges 00049 14, 13, 12, // top edges 00050 9, 11, 10, // lateral edges 00051 17, 16, 15 }; // quadrilateral faces 00052 const unsigned qhex[] = { 0, 1, 2, 3, // corners (same) 00053 4, 5, 6, 7, 8, 9, 10, 11, // mid-edge (top before lateral) 00054 16, 17, 18, 19, 12, 13, 14, 15, 23, 21, 20, 22, // mid-face (mixed up) & mid-region (same) 00055 24, 25, 26 }; 00056 00057 // List of VtkElemType structs, indexed by the VTK type number. 00058 const VtkElemType VtkUtil::vtkElemTypes[] = { 00059 { 0, 0, MBMAXTYPE, 0, 0 }, 00060 { "vertex", 1, MBVERTEX, 1, 0 }, 00061 { "polyvertex", 2, MBMAXTYPE, 0, 0 }, 00062 { "line", 3, MBEDGE, 2, 0 }, 00063 { "polyline", 4, MBMAXTYPE, 0, 0 }, 00064 { "triangle", 5, MBTRI, 3, 0 }, 00065 { "triangle strip", 6, MBMAXTYPE, 0, 0 }, 00066 { "polygon", 7, MBPOLYGON, 0, 0 }, 00067 { "pixel", 8, MBQUAD, 4, pixel }, 00068 { "quadrilateral", 9, MBQUAD, 4, 0 }, 00069 { "tetrahedron", 10, MBTET, 4, 0 }, 00070 { "voxel", 11, MBHEX, 8, voxel }, 00071 { "hexahedron", 12, MBHEX, 8, 0 }, 00072 { "wedge", 13, MBPRISM, 6, wedge }, 00073 { "pyramid", 14, MBPYRAMID, 5, 0 }, 00074 { "pentagonal prism", 15, MBMAXTYPE, 10, 0 }, // not supported 00075 { "hexagonal prism", 16, MBMAXTYPE, 12, 0 }, // not supported 00076 { 0, 17, MBMAXTYPE, 0, 0 }, 00077 { 0, 18, MBMAXTYPE, 0, 0 }, 00078 { 0, 19, MBMAXTYPE, 0, 0 }, 00079 { 0, 20, MBMAXTYPE, 0, 0 }, 00080 { "quadratic edge", 21, MBEDGE, 3, 0 }, 00081 { "quadratic tri", 22, MBTRI, 6, 0 }, 00082 { "quadratic quad", 23, MBQUAD, 8, 0 }, 00083 { "quadratic tet", 24, MBTET, 10, 0 }, 00084 { "quadratic hex", 25, MBHEX, 20, qhex }, 00085 { "quadratic wedge", 26, MBPRISM, 15, wedge }, 00086 { "quadratic pyramid", 27, MBPYRAMID, 13, 0 }, 00087 { "bi-quadratic quad", 28, MBQUAD, 9, 0 }, 00088 { "tri-quadratic hex", 29, MBHEX, 27, qhex }, 00089 { "quadratic-linear quad", 30, MBMAXTYPE, 6, 0 }, // not supported 00090 { "quadratic-linear wedge", 31, MBMAXTYPE, 12, wedge }, // not supported 00091 { "bi-quadratic wedge", 32, MBMAXTYPE, 18, wedge }, // not supported 00092 { "bi-quadratic hex", 33, MBMAXTYPE, 24, qhex }, // not supported 00093 { "bi-quadratic triangle", 34, MBMAXTYPE, 0, 0 }, 00094 { "cubic line", 35, MBMAXTYPE, 0, 0 }, // VTK_CUBIC_LINE not supported 00095 { 0, 36, MBMAXTYPE, 0, 0 }, 00096 { 0, 37, MBMAXTYPE, 0, 0 }, 00097 { 0, 38, MBMAXTYPE, 0, 0 }, 00098 { 0, 39, MBMAXTYPE, 0, 0 }, 00099 { 0, 40, MBMAXTYPE, 0, 0 }, 00100 { "convex point set", 41, MBMAXTYPE, 0, 0 }, // VTK_CONVEX_POINT_SET = 41, not supported 00101 { "polyhedron", 42, MBPOLYHEDRON, 0, 0 } // 00102 }; 00103 00104 const unsigned VtkUtil::numVtkElemType = sizeof( VtkUtil::vtkElemTypes ) / sizeof( VtkUtil::vtkElemTypes[0] ); 00105 00106 // Define an array, indexed by EntityType containing the corresponding 00107 // VTK element type numbers for the linear, quadratic (mid-edge), 00108 // and full (mid-face & mid-region node) elements. 00109 // Zero is used to indicate an invalid type (not supported by VTK.) The 00110 // VTK element type number may be used as an index into vtkElemTypes[]. 00111 const int mb_to_vtk_type[][3] = { { 1, 0, 0 }, // MBVERTEX 00112 { 3, 21, 0 }, // MBEDGE 00113 { 5, 22, 0 }, // MBTRI 00114 { 9, 23, 28 }, // MBQUAD 00115 { 7, 0, 0 }, // MBPOLYGON 00116 { 10, 24, 0 }, // MBTET 00117 { 14, 27, 0 }, // MBPYRAMID 00118 { 13, 26, 0 }, // MBWEDGE 00119 { 0, 0, 0 }, // MBKNIFE 00120 { 12, 25, 29 }, // MBHEX 00121 { 42, 0, 0 }, // MBPOLYHEDRON 00122 { 0, 0, 0 }, // MBENTITYSET 00123 { 0, 0, 0 } }; // MBMAXTYPE 00124 00125 const VtkElemType* VtkUtil::get_vtk_type( EntityType type, unsigned num_nodes ) 00126 { 00127 const int i = mb_to_vtk_type[type][0]; // Index for linear type 00128 const int j = mb_to_vtk_type[type][1]; // Index for quadratic type 00129 const int k = mb_to_vtk_type[type][2]; // Index for full quadratic type 00130 if( i ) // If element type is supported at all (if not linear then not quadratic either) 00131 { 00132 // If the linear type is requested (all polygons are linear 00133 // irrespective of the number of nodes), return that. 00134 if( type == MBPOLYGON || type == MBPOLYHEDRON || vtkElemTypes[i].num_nodes == num_nodes ) 00135 return vtkElemTypes + i; 00136 // Otherwise if there is a quadratic type and the number of 00137 // nodes specified corresponds to the quadratic type, return that. 00138 else if( j && vtkElemTypes[j].num_nodes == num_nodes ) 00139 return vtkElemTypes + j; 00140 // Otherwise if there is a full quadratic type and the number of 00141 // nodes specified corresponds to the quadratic type, return that. 00142 else if( k && vtkElemTypes[k].num_nodes == num_nodes ) 00143 return vtkElemTypes + k; 00144 } 00145 00146 return 0; 00147 } 00148 00149 } // namespace moab