From 2f2628468f7ba0714dd60a6f40f28b0bd72a2530 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Mon, 3 Dec 2012 10:29:04 +0100 Subject: [PATCH] resolved index error for triangle elements in legacy mesh import --- FileIO/Legacy/MeshIO.cpp | 12 ++++++------ Gui/VtkAct/VtkCustomInteractorStyle.cpp | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/FileIO/Legacy/MeshIO.cpp b/FileIO/Legacy/MeshIO.cpp index 8f137fecf6f..9dde28d1a0a 100644 --- a/FileIO/Legacy/MeshIO.cpp +++ b/FileIO/Legacy/MeshIO.cpp @@ -158,7 +158,7 @@ MeshLib::Element* MeshIO::readElement(const std::string& line, const std::vector ss >> idx[i]; MeshLib::Node** tri_nodes = new MeshLib::Node*[3]; for (unsigned k(0); k<3; k++) - tri_nodes[k] = nodes[idx[k]]; + tri_nodes[k] = nodes[idx[2-k]]; elem = new MeshLib::Tri(tri_nodes, patch_index); break; } @@ -167,7 +167,7 @@ MeshLib::Element* MeshIO::readElement(const std::string& line, const std::vector ss >> idx[i]; MeshLib::Node** quad_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k<4; k++) - quad_nodes[k] = nodes[idx[4-(k+1)]]; + quad_nodes[k] = nodes[idx[3-k]]; elem = new MeshLib::Quad(quad_nodes, patch_index); break; } @@ -176,7 +176,7 @@ MeshLib::Element* MeshIO::readElement(const std::string& line, const std::vector ss >> idx[i]; MeshLib::Node** tet_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k<4; k++) - tet_nodes[k] = nodes[idx[4-(k+1)]]; + tet_nodes[k] = nodes[idx[3-k]]; elem = new MeshLib::Tet(tet_nodes, patch_index); break; } @@ -185,7 +185,7 @@ MeshLib::Element* MeshIO::readElement(const std::string& line, const std::vector ss >> idx[i]; MeshLib::Node** hex_nodes = new MeshLib::Node*[8]; for (unsigned k(0); k<8; k++) - hex_nodes[k] = nodes[idx[8-(k+1)]]; + hex_nodes[k] = nodes[idx[7-k]]; elem = new MeshLib::Hex(hex_nodes, patch_index); break; } @@ -194,7 +194,7 @@ MeshLib::Element* MeshIO::readElement(const std::string& line, const std::vector ss >> idx[i]; MeshLib::Node** pyramid_nodes = new MeshLib::Node*[5]; for (unsigned k(0); k<5; k++) - pyramid_nodes[k] = nodes[idx[5-(k+1)]]; + pyramid_nodes[k] = nodes[idx[4-k]]; elem = new MeshLib::Pyramid(pyramid_nodes, patch_index); break; } @@ -203,7 +203,7 @@ MeshLib::Element* MeshIO::readElement(const std::string& line, const std::vector ss >> idx[i]; MeshLib::Node** prism_nodes = new MeshLib::Node*[6]; for (unsigned k(0); k<6; k++) - prism_nodes[k] = nodes[idx[6-(k+1)]]; + prism_nodes[k] = nodes[idx[5-k]]; elem = new MeshLib::Prism(prism_nodes, patch_index); break; } diff --git a/Gui/VtkAct/VtkCustomInteractorStyle.cpp b/Gui/VtkAct/VtkCustomInteractorStyle.cpp index 99526e87207..f59e2d954a5 100644 --- a/Gui/VtkAct/VtkCustomInteractorStyle.cpp +++ b/Gui/VtkAct/VtkCustomInteractorStyle.cpp @@ -34,6 +34,7 @@ #include <string> #include "VtkMeshSource.h" +#include "VtkCompositeSelectionFilter.h" vtkStandardNewMacro(VtkCustomInteractorStyle); @@ -182,24 +183,25 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() VtkMeshSource* source = dynamic_cast<VtkMeshSource*>(data_set); if (source) emit elementPicked(source->GetMesh(), picker->GetCellId()); -/* test for picking on selection filters +/* test for picking on selection filters else { - - vtkAlgorithm* data_set = picker->GetActor()->GetMapper()->GetInputConnection(0,0)->GetProducer() +/* + vtkAlgorithm* data_set2 = picker->GetActor()->GetMapper()->GetInputConnection(0,0)->GetProducer() ->GetInputConnection(0,0)->GetProducer() ->GetInputConnection(0,0)->GetProducer() ->GetInputConnection(0,0)->GetProducer() ->GetInputConnection(0,0)->GetProducer() ->GetInputConnection(0,0)->GetProducer(); - VtkMeshSource* source = dynamic_cast<VtkMeshSource*>(data_set); + + VtkCompositeSelectionFilter* source = dynamic_cast<VtkCompositeSelectionFilter*>(data_set->GetInputConnection(0,0)->GetProducer()->GetInputConnection(0,0)->GetProducer()->GetInputConnection(0,0)->GetProducer()); if (source) { vtkUnstructuredGridAlgorithm* data_set = vtkUnstructuredGridAlgorithm::SafeDownCast(picker->GetActor()->GetMapper()->GetInputConnection(0,0)->GetProducer()); vtkUnstructuredGrid* grid = vtkUnstructuredGrid::SafeDownCast(data_set->GetOutputDataObject(0)); vtkDataArray* scalar_array = grid->GetCellData()->GetArray("vtkIdFilter_Ids"); double test = scalar_array->GetTuple1(picker->GetCellId()); - emit elementPicked(source->GetMesh(), test); + //emit elementPicked(source->GetMesh(), test); } } */ -- GitLab