[Paraview] Multiple levels of vtkMultiBlockDataSets

Adriano Gagliardi agagliardi at ara.co.uk
Thu Jun 9 13:08:28 EDT 2011


Jean/Paul,

Ok, I found the issue and I've got it working now. Your responses got me
thinking and I finally found that the issue was with the smart pointer,
blocks. After using blocks for the structured grid, I did a bad thing and
re-used it for unstructured grids without calling delete which, for the unit
test I was running, did not exist. Because I wasn't handling the pointer
correctly and the unstructured block data was empty, this corrupted the
storage for both structured and unstructured blocks. I've switched to
ordinary pointers and just called delete when appropriate. The code is
below. 

Thanks for clearing that up!

Adriano

  output->SetNumberOfBlocks(2);
  vtkMultiBlockDataSet* blocks = vtkMultiBlockDataSet::New();

  blocks->SetNumberOfBlocks(structuredBlocks.size());
  vtkstd::map<vtkstd::string, vtkSmartPointer<vtkStructuredGrid> >::iterator
strIt;
  unsigned int counter = 0;
  for ( strIt = structuredBlocks.begin(); strIt != structuredBlocks.end();
++strIt ) {
    blocks->SetBlock(counter,(*strIt).second);
    blocks->GetMetaData(counter)->Set(vtkCompositeDataSet::NAME(),
(*strIt).first.c_str());
    counter++;
  }
  output->SetBlock((uint) 0, blocks);
  blocks->Delete();
  output->GetMetaData((uint) 0)->Set(vtkCompositeDataSet::NAME(),
"Structured");

  blocks = vtkMultiBlockDataSet::New();
  blocks->SetNumberOfBlocks(unstructuredBlocks.size());
  vtkstd::map<vtkstd::string, vtkSmartPointer<vtkUnstructuredGrid>
>::iterator unsIt;
  counter = 0;
  for ( unsIt = unstructuredBlocks.begin(); unsIt !=
unstructuredBlocks.end(); ++unsIt ) {
    blocks->SetBlock(counter,(*unsIt).second);
    blocks->GetMetaData(counter)->Set(vtkCompositeDataSet::NAME(),
(*unsIt).first.c_str());
    counter++;
  }
  output->SetBlock((uint) 1, blocks);
  blocks->Delete();
  output->GetMetaData((uint) 1)->Set(vtkCompositeDataSet::NAME(),
"Unstructured");

===================================

Adriano Gagliardi MEng PhD
Business Sector Leader
Computational Aerodynamics
Aircraft Research Association Ltd.
Manton Lane
Bedford

Tel: 01234 32 4644
E-mail: agagliardi at ara.co.uk
Url: www.ara.co.uk 
-----Original Message-----
From: Favre Jean [mailto:jfavre at cscs.ch] 
Sent: 09 June 2011 17:30
To: agagliardi at ara.co.uk; 'ParaView list'
Subject: RE: [Paraview] Multiple levels of vtkMultiBlockDataSets

Yes it is possible. I have it running since several years.

source code:

  vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::SafeDownCast(doOutput);

  vtkMultiBlockDataSet *volumes, *boundaries, *solid0, *solid1, *solid2,
*solid3;
  volumes = vtkMultiBlockDataSet::New();
  mb->SetBlock(0, volumes);
  volumes->Delete();
  mb->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(),
"volumes");

  boundaries = vtkMultiBlockDataSet::New();
  mb->SetBlock(1, boundaries);
  boundaries->Delete();
  mb->GetMetaData((unsigned int)1)->Set(vtkCompositeDataSet::NAME(),
"boundaries");
  if(boundaries)
    {
    solid0 = vtkMultiBlockDataSet::New();
    boundaries->SetBlock(0, solid0);
    solid0->Delete();
    boundaries->GetMetaData((unsigned
int)0)->Set(vtkCompositeDataSet::NAME(), "solid_wall");
   }


etc...
-----------------
Jean M. Favre
Swiss National Supercomputing Center
=


**********************************************************************
This email contains information that is private and confidential and is intended only for the addressee.
If you are not the intended recipient please delete it and notify us immediately by e-mailing the sender.
Note: All email sent to or from this address may be accessed by someone other than the recipient, for
system management and security reasons.
Aircraft Research Association Ltd.  Registered in England, Registration No 503668 Registered Office:
Manton Lane, Bedford MK41 7PF England VAT No GB 196351245

**********************************************************************


More information about the ParaView mailing list