diff --git a/Applications/DataExplorer/VtkVis/VtkMeshSource.cpp b/Applications/DataExplorer/VtkVis/VtkMeshSource.cpp index 85f75df0bc09b36b184274dfdd53eb8567f8314c..0a4b46865dc0573df58bc34c5e13c79ceb9f9657 100644 --- a/Applications/DataExplorer/VtkVis/VtkMeshSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkMeshSource.cpp @@ -45,6 +45,8 @@ #include <vtkTriangle.h> #include <vtkWedge.h> // == Prism +#include "InSituLib/VtkOGSEnum.h" + vtkStandardNewMacro(VtkMeshSource); VtkMeshSource::VtkMeshSource() : @@ -144,39 +146,19 @@ int VtkMeshSource::RequestData( vtkInformation* request, for (unsigned j = 0; j < nElemNodes; ++j) point_ids->SetId(j, elem->getNode(j)->getID()); - switch (elem->getGeomType()) - { - case MeshElemType::LINE: - type = 3; - break; - case MeshElemType::TRIANGLE: - type = 5; - break; - case MeshElemType::QUAD: - type = 9; - break; - case MeshElemType::HEXAHEDRON: - type = 12; - break; - case MeshElemType::TETRAHEDRON: - type = 10; - break; - case MeshElemType::PRISM: - type = 13; + type = InSituLib::OGSToVtkCellType(elem->getCellType()); + if (type==0) { + ERR("VtkMeshSource::RequestData(): Unknown element type \"%s\".", + CellType2String(elem->getCellType()).c_str()); + return 0; + } + if (elem->getCellType() == CellType::PRISM6) { for (unsigned i=0; i<3; ++i) { const unsigned prism_swap_id = point_ids->GetId(i); point_ids->SetId(i, point_ids->GetId(i+3)); point_ids->SetId(i+3, prism_swap_id); } - break; - case MeshElemType::PYRAMID: - type = 14; - break; - default: // if none of the above can be applied - ERR("VtkMeshSource::RequestData(): Unknown element type \"%s\".", - MeshElemType2String(elem->getGeomType()).c_str()); - return 0; } output->InsertNextCell(type, point_ids); diff --git a/InSituLib/CMakeLists.txt b/InSituLib/CMakeLists.txt index 81fdeba345b6b8b66de7f1cd7ac5286fbcb04aab..f053282c447669e4495f41ec594414dae68c888f 100644 --- a/InSituLib/CMakeLists.txt +++ b/InSituLib/CMakeLists.txt @@ -10,6 +10,8 @@ add_library(InSituLib VtkMappedMesh.cpp VtkMappedMeshSource.h VtkMappedMeshSource.cpp + VtkOGSEnum.h + VtkOGSEnum.cpp ) include(AddCatalystDependency) diff --git a/InSituLib/VtkMappedMesh.cpp b/InSituLib/VtkMappedMesh.cpp index 78eaf1845afa4329fc4a9ed3d45c445d00c32edf..9672d07626fb37556516fe9dc09afdff190eb467 100644 --- a/InSituLib/VtkMappedMesh.cpp +++ b/InSituLib/VtkMappedMesh.cpp @@ -29,6 +29,8 @@ #include "MeshLib/Node.h" #include "MeshEnums.h" +#include "VtkOGSEnum.h" + namespace InSituLib { vtkStandardNewMacro(VtkMappedMesh) @@ -59,64 +61,7 @@ vtkIdType VtkMappedMeshImpl::GetNumberOfCells() int VtkMappedMeshImpl::GetCellType(vtkIdType cellId) { - int type = 0; - switch ((*_elements)[cellId]->getCellType()) - { - case CellType::INVALID: - break; - case CellType::LINE2: - type = VTK_LINE; - break; - case CellType::LINE3: - type = VTK_QUADRATIC_EDGE; - break; - case CellType::TRI3: - type = VTK_TRIANGLE; - break; - case CellType::TRI6: - type = VTK_QUADRATIC_TRIANGLE; - break; - case CellType::QUAD4: - type = VTK_QUAD; - break; - case CellType::QUAD8: - type = VTK_QUADRATIC_QUAD; - break; - case CellType::QUAD9: - type = VTK_BIQUADRATIC_QUAD; - break; - case CellType::HEX8: - type = VTK_HEXAHEDRON; - break; - case CellType::HEX20: - type = VTK_QUADRATIC_HEXAHEDRON; - break; - case CellType::HEX27: - type = VTK_TRIQUADRATIC_HEXAHEDRON; - break; - case CellType::TET4: - type = VTK_TETRA; - break; - case CellType::TET10: - type = VTK_QUADRATIC_TETRA; - break; - case CellType::PRISM6: - type = VTK_WEDGE; - break; - case CellType::PRISM15: - type = VTK_QUADRATIC_WEDGE; - break; - case CellType::PRISM18: - type = VTK_BIQUADRATIC_QUADRATIC_WEDGE; - break; - case CellType::PYRAMID5: - type = VTK_PYRAMID; - break; - case CellType::PYRAMID13: - type = VTK_QUADRATIC_PYRAMID; - break; - } - return type; + return OGSToVtkCellType((*_elements)[cellId]->getCellType()); } void VtkMappedMeshImpl::GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) diff --git a/InSituLib/VtkMappedMesh.h b/InSituLib/VtkMappedMesh.h index 26c20a7f445a5584bfdfb79fd53c29c1e6ff7e45..119b6a6669a824a4677e12d9cd746ff38993802f 100644 --- a/InSituLib/VtkMappedMesh.h +++ b/InSituLib/VtkMappedMesh.h @@ -70,69 +70,6 @@ private: const std::vector<MeshLib::Node*>* _nodes; const std::vector<MeshLib::Element*>* _elements; vtkIdType NumberOfCells; - - static CellType VtkCellTypeToOGS(int type) - { - CellType ogs; - switch (type) - { - case VTK_LINE: - ogs = CellType::LINE2; - break; - case VTK_QUADRATIC_EDGE: - ogs = CellType::LINE3; - break; - case VTK_TRIANGLE: - ogs = CellType::TRI3; - break; - case VTK_QUADRATIC_TRIANGLE: - ogs = CellType::TRI6; - break; - case VTK_QUAD: - ogs = CellType::QUAD4; - break; - case VTK_QUADRATIC_QUAD: - ogs = CellType::QUAD8; - break; - case VTK_BIQUADRATIC_QUAD: - ogs = CellType::QUAD9; - break; - case VTK_HEXAHEDRON: - ogs = CellType::HEX8; - break; - case VTK_QUADRATIC_HEXAHEDRON: - ogs = CellType::HEX20; - break; - case VTK_TRIQUADRATIC_HEXAHEDRON: - ogs = CellType::HEX27; - break; - case VTK_TETRA: - ogs = CellType::TET4; - break; - case VTK_QUADRATIC_TETRA: - ogs = CellType::TET10; - break; - case VTK_WEDGE: - ogs = CellType::PRISM6; - break; - case VTK_QUADRATIC_WEDGE: - ogs = CellType::PRISM15; - break; - case VTK_BIQUADRATIC_QUADRATIC_WEDGE: - ogs = CellType::PRISM18; - break; - case VTK_PYRAMID: - ogs = CellType::PYRAMID5; - break; - case VTK_QUADRATIC_PYRAMID: - ogs = CellType::PYRAMID13; - break; - default: - ogs = CellType::INVALID; - break; - } - return ogs; - } }; vtkMakeMappedUnstructuredGrid(VtkMappedMesh, VtkMappedMeshImpl) diff --git a/InSituLib/VtkOGSEnum.cpp b/InSituLib/VtkOGSEnum.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c74cf456d01b20bc1634941efcd507bc3d31e5e9 --- /dev/null +++ b/InSituLib/VtkOGSEnum.cpp @@ -0,0 +1,143 @@ +/** + * \copyright + * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "VtkOGSEnum.h" + +#include <vtkCellType.h> + +namespace InSituLib +{ + +CellType VtkCellTypeToOGS(int type) +{ + CellType ogs; + switch (type) + { + case VTK_LINE: + ogs = CellType::LINE2; + break; + case VTK_QUADRATIC_EDGE: + ogs = CellType::LINE3; + break; + case VTK_TRIANGLE: + ogs = CellType::TRI3; + break; + case VTK_QUADRATIC_TRIANGLE: + ogs = CellType::TRI6; + break; + case VTK_QUAD: + ogs = CellType::QUAD4; + break; + case VTK_QUADRATIC_QUAD: + ogs = CellType::QUAD8; + break; + case VTK_BIQUADRATIC_QUAD: + ogs = CellType::QUAD9; + break; + case VTK_HEXAHEDRON: + ogs = CellType::HEX8; + break; + case VTK_QUADRATIC_HEXAHEDRON: + ogs = CellType::HEX20; + break; + case VTK_TRIQUADRATIC_HEXAHEDRON: + ogs = CellType::HEX27; + break; + case VTK_TETRA: + ogs = CellType::TET4; + break; + case VTK_QUADRATIC_TETRA: + ogs = CellType::TET10; + break; + case VTK_WEDGE: + ogs = CellType::PRISM6; + break; + case VTK_QUADRATIC_WEDGE: + ogs = CellType::PRISM15; + break; + case VTK_BIQUADRATIC_QUADRATIC_WEDGE: + ogs = CellType::PRISM18; + break; + case VTK_PYRAMID: + ogs = CellType::PYRAMID5; + break; + case VTK_QUADRATIC_PYRAMID: + ogs = CellType::PYRAMID13; + break; + default: + ogs = CellType::INVALID; + break; + } + return ogs; +} + +int OGSToVtkCellType(CellType ogs) +{ + int type = 0; + switch (ogs) + { + case CellType::INVALID: + break; + case CellType::LINE2: + type = VTK_LINE; + break; + case CellType::LINE3: + type = VTK_QUADRATIC_EDGE; + break; + case CellType::TRI3: + type = VTK_TRIANGLE; + break; + case CellType::TRI6: + type = VTK_QUADRATIC_TRIANGLE; + break; + case CellType::QUAD4: + type = VTK_QUAD; + break; + case CellType::QUAD8: + type = VTK_QUADRATIC_QUAD; + break; + case CellType::QUAD9: + type = VTK_BIQUADRATIC_QUAD; + break; + case CellType::HEX8: + type = VTK_HEXAHEDRON; + break; + case CellType::HEX20: + type = VTK_QUADRATIC_HEXAHEDRON; + break; + case CellType::HEX27: + type = VTK_TRIQUADRATIC_HEXAHEDRON; + break; + case CellType::TET4: + type = VTK_TETRA; + break; + case CellType::TET10: + type = VTK_QUADRATIC_TETRA; + break; + case CellType::PRISM6: + type = VTK_WEDGE; + break; + case CellType::PRISM15: + type = VTK_QUADRATIC_WEDGE; + break; + case CellType::PRISM18: + type = VTK_BIQUADRATIC_QUADRATIC_WEDGE; + break; + case CellType::PYRAMID5: + type = VTK_PYRAMID; + break; + case CellType::PYRAMID13: + type = VTK_QUADRATIC_PYRAMID; + break; + } + return type; +} + +} // end namespace + diff --git a/InSituLib/VtkOGSEnum.h b/InSituLib/VtkOGSEnum.h new file mode 100644 index 0000000000000000000000000000000000000000..c8f86db385ebaa35c4f3c7fd2c1294e454febc31 --- /dev/null +++ b/InSituLib/VtkOGSEnum.h @@ -0,0 +1,24 @@ +/** + * \copyright + * Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef VTKOGSENUM_H_ +#define VTKOGSENUM_H_ + +#include "MeshEnums.h" + +namespace InSituLib +{ + +CellType VtkCellTypeToOGS(int type); + +int OGSToVtkCellType(CellType ogs); + +} // end namespace + +#endif // VTKOGSENUM_H_