FEM: vtk mesh builder, fix crash if SMESH grid has node gaps

This commit is contained in:
Bernd Hahnebach
2018-04-04 12:58:13 +02:00
parent d2ee3d2ac0
commit 6c60f60a05

View File

@@ -440,17 +440,15 @@ void FemVTKTools::exportVTKMesh(const FemMesh* mesh, vtkSmartPointer<vtkUnstruct
Base::Console().Message("Start: VTK mesh builder ======================\n");
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(mesh->getSMesh());
SMESHDS_Mesh* meshDS = smesh->GetMeshDS();
const SMDS_MeshInfo& info = meshDS->GetMeshInfo();
//start with the nodes
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
points->SetNumberOfPoints(info.NbNodes());
for(; aNodeIter->more(); ) {
const SMDS_MeshNode* node = aNodeIter->next(); // why float, not double?
double coords[3] = {double(node->X()*scale), double(node->Y()*scale), double(node->Z()*scale)};
points->SetPoint(node->GetID()-1, coords);
points->InsertPoint(node->GetID()-1, coords); // memory is allocated by VTK points size = max node id, points will be insterted in SMESH point gaps too
}
grid->SetPoints(points);
// faces