FEM: vtk mesh builder, add some logs and code improvements

This commit is contained in:
Bernd Hahnebach
2018-04-02 16:52:45 +02:00
parent 6c60f60a05
commit c5ef8a1ee1

View File

@@ -441,19 +441,29 @@ void FemVTKTools::exportVTKMesh(const FemMesh* mesh, vtkSmartPointer<vtkUnstruct
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(mesh->getSMesh());
SMESHDS_Mesh* meshDS = smesh->GetMeshDS();
//start with the nodes
// nodes
Base::Console().Message(" Start: VTK mesh builder nodes.\n");
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
for(; aNodeIter->more(); ) {
while (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->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);
// nodes debugging
const SMDS_MeshInfo& info = meshDS->GetMeshInfo();
Base::Console().Message(" Size of nodes in SMESH grid: %i.\n", info.NbNodes());
const vtkIdType nNodes = grid->GetNumberOfPoints();
Base::Console().Message(" Size of nodes in VTK grid: %i.\n", nNodes);
Base::Console().Message(" End: VTK mesh builder nodes.\n");
// faces
SMDS_FaceIteratorPtr aFaceIter = meshDS->facesIterator();
exportFemMeshFaces(grid, aFaceIter);
// volumes
SMDS_VolumeIteratorPtr aVolIter = meshDS->volumesIterator();
exportFemMeshCells(grid, aVolIter);
@@ -471,6 +481,7 @@ void FemVTKTools::writeVTKMesh(const char* filename, const FemMesh* mesh)
vtkSmartPointer<vtkUnstructuredGrid> grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
exportVTKMesh(mesh, grid);
//vtkSmartPointer<vtkDataSet> dataset = vtkDataSet::SafeDownCast(grid);
Base::Console().Message("Start: writeing mesh data ======================\n");
if(f.hasExtension("vtu")){
writeVTKFile<vtkXMLUnstructuredGridWriter>(filename, grid);
}