From 9a05a7267b0827092d57e207fea0cafe6f84a3f3 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 13 Mar 2018 23:07:03 +0100 Subject: [PATCH] FEM: vtk tools, fix crash in mesh builder if not supported volume is used --- src/Mod/Fem/App/FemVTKTools.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index 0484d97459..ed84caf6de 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -270,6 +270,10 @@ void exportFemMeshFaces(vtkSmartPointer grid, const SMDS_Fa quadQuadArray->InsertNextCell(quad); } + else + { + throw std::runtime_error("Face not yet supported by FreeCADs VTK mesh builder\n"); + } } if(triangleArray->GetNumberOfCells()>0) grid->SetCells(VTK_TRIANGLE, triangleArray); @@ -300,8 +304,7 @@ void exportFemMeshCells(vtkSmartPointer grid, const SMDS_Vo { const SMDS_MeshVolume* aVol = aVolIter->next(); - //tetrahedra - if(aVol->NbNodes() == 4) { + if (aVol->NbNodes() == 4) { // tetrahedra vtkSmartPointer tetra = vtkSmartPointer::New(); tetra->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID()-1); tetra->GetPointIds()->SetId(1, aVol->GetNode(1)->GetID()-1); @@ -310,8 +313,7 @@ void exportFemMeshCells(vtkSmartPointer grid, const SMDS_Vo tetraArray->InsertNextCell(tetra); } - // common cell types for CFD - if(aVol->NbNodes() == 5) { + else if (aVol->NbNodes() == 5) { // common cell types for CFD vtkSmartPointer cell= vtkSmartPointer::New(); cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID()-1); cell->GetPointIds()->SetId(1, aVol->GetNode(1)->GetID()-1); @@ -321,7 +323,7 @@ void exportFemMeshCells(vtkSmartPointer grid, const SMDS_Vo pyramidArray->InsertNextCell(cell); } - if(aVol->NbNodes() == 6) { + else if (aVol->NbNodes() == 6) { vtkSmartPointer cell = vtkSmartPointer::New(); cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID()-1); cell->GetPointIds()->SetId(1, aVol->GetNode(1)->GetID()-1); @@ -332,7 +334,7 @@ void exportFemMeshCells(vtkSmartPointer grid, const SMDS_Vo wedgeArray->InsertNextCell(cell); } - if(aVol->NbNodes() == 8) { + else if (aVol->NbNodes() == 8) { vtkSmartPointer cell= vtkSmartPointer::New(); cell->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID()-1); cell->GetPointIds()->SetId(1, aVol->GetNode(1)->GetID()-1); @@ -345,8 +347,7 @@ void exportFemMeshCells(vtkSmartPointer grid, const SMDS_Vo hexaArray->InsertNextCell(cell); } - //quadratic tetrahedra - else if( aVol->NbNodes() == 10) { + else if ( aVol->NbNodes() == 10) { // quadratic tetrahedra vtkSmartPointer tetra = vtkSmartPointer::New(); for(int i=0; i<10; i++){ @@ -355,13 +356,16 @@ void exportFemMeshCells(vtkSmartPointer grid, const SMDS_Vo quadTetraArray->InsertNextCell(tetra); } - if(aVol->NbNodes() == 20) { // not tested, no sure about vertex sequence + else if (aVol->NbNodes() == 20) { // not tested, no sure about vertex sequence vtkSmartPointer cell= vtkSmartPointer::New(); for(int i=0; i<20; i++){ cell->GetPointIds()->SetId(i, aVol->GetNode(i)->GetID()-1); } hexaArray->InsertNextCell(cell); } + else { + throw std::runtime_error("Volume not yet supported by FreeCADs VTK mesh builder\n"); + } } if(tetraArray->GetNumberOfCells()>0)