[vtkusers] merging distributed datasets

Gerard Gorman g.gorman at imperial.ac.uk
Wed Mar 16 11:53:13 EST 2005


Hi

I have been trying to use vtkMergeCell to merge distributed vtu files. 
ie. I have myfile.pvtu and associated myfile_#.vtu files and I want a 
single vtu file with no cell or point duplicates (the overlap is one 
element deep). From my reading of docs vtkMergeCell seems to be what I 
am looking for. However the resulting dataset does not include any of 
the overlapping cells (ghost cells) - there is just a gap between the 
domains where there were once cells. Have I misunderstood the docs or is 
there something else going on here? The code is appended to this email 
and I have placed a sample distributed dataset in:

http://amcg.ese.ic.ac.uk/~gormo/vtkMergeCell/

I'm using yesterdays cvs version of vtk.

Suggestions appreciated,
Gerard.




#include <string>
#include <iostream>

#include <vtkMergeCells.h>
#include <vtkUnstructuredGrid.h>
#include <vtkXMLPUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridWriter.h>

using namespace std;

void usage(){
   cout<<"mergevtu <fluidity-project-name>\n";
   cout<<"\nMerge a .ptvu parallel unstructured grid file into a serial 
.vtu unstructured grid file. "
       <<"Serial fluidity dumps are named 
<fluidity-project-name>_<dump-id>.vtu "      <<"while parallel fluidity 
dumps consist of a metafile named "
       <<"<fluidity-project-name>_<dump-id>.pvtu, that has all the 
partition "
       <<"information, and an individual .vtu file for each of the 
partitions "
       <<"in the domains, <fluidity-project-name>_<dump-id>_<partition 
number>.vtu\n";
   return;
}

int main(int argv, char **argc){
   if(argv != 2){
     usage();
     exit(-1);
   }

   string project_name;
   project_name = getenv("PWD");
   project_name+="/";
   project_name+=argc[1];

   string filename = project_name+".pvtu";

   vtkXMLPUnstructuredGridReader *source = 
vtkXMLPUnstructuredGridReader::New();
   source->SetFileName(filename.c_str());
   source->Update();

   vtkMergeCells *merge = vtkMergeCells::New();

   vtkUnstructuredGrid *merged_data = vtkUnstructuredGrid::New();

   cout << "Number of Cells before merge  = " << 
source->GetOutput()->GetNumberOfCells();
   cout << "Number of Points before merge = " << 
source->GetOutput()->GetNumberOfPoints();

   merge->MergeDuplicatePointsOn();
   // merge->MergeDuplicatePointsOff();
   merge->SetTotalNumberOfCells(source->GetOutput()->GetNumberOfCells());
   merge->SetTotalNumberOfPoints(source->GetOutput()->GetNumberOfPoints());
   merge->SetTotalNumberOfDataSets(1);
   merge->SetUnstructuredGrid(merged_data);
   merge->MergeDataSet(source->GetOutput());

   merge->Finish();

   cout << "Number of Cells after merge  = " << 
merge->GetUnstructuredGrid()->GetNumberOfCells();
   cout << "Number of Points after merge = " << 
merge->GetUnstructuredGrid()->GetNumberOfPoints();

   vtkXMLUnstructuredGridWriter *writer = 
vtkXMLUnstructuredGridWriter::New();
   filename = "output.vtu";
   writer->SetFileName(filename.c_str());
   writer->SetInput(merge->GetUnstructuredGrid());
   writer->Update();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050316/9c293b50/attachment.pgp>


More information about the vtkusers mailing list