[vtkusers] how to transfer vtkMultiBlockDataSet to vtkPolyData

Eric E. Monson emonson at cs.duke.edu
Sun Sep 26 08:05:56 EDT 2010


Hey Reece,

I don't know if this will accomplish everything you want to do, but the single block of data in your multi-block data set is an Unstructured Grid, which you can extract and it already contains points and cells and scalars (although the scalars aren't "active" yet). Then you can visualize the unstructured grid directly. You also don't need to create a camera manually. Here's a piece from the middle of your program that I modified:

  tecR->SetFileName(fileName);
  tecR->Update();

  //read from
  vtkMultiBlockDataSet *multiBDS =vtkMultiBlockDataSet::New ();
  multiBDS=tecR->GetOutput();

  vtkUnstructuredGrid *ug=vtkUnstructuredGrid::SafeDownCast(multiBDS->GetBlock(0));
  ug->GetPointData()->SetActiveScalars("H");

  // Now we'll look at it.
  vtkDataSetMapper *cubeMapper = vtkDataSetMapper::New();
      cubeMapper->SetInput(ug);
      cubeMapper->SetScalarRange(0,7);
  vtkActor *cubeActor = vtkActor::New();
      cubeActor->SetMapper(cubeMapper);

  vtkRenderer *renderer = vtkRenderer::New();
  	renderer->AddActor(cubeActor);
  	
  vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(renderer);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  renderer->AddActor(cubeActor);
      renderer->ResetCamera();
  
  renWin->SetSize(300,300);

  // interact with data
  renWin->Render();
  iren->Start();


This should at least be a start in the right direction,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Sep 26, 2010, at 3:36 AM, 赖瑞勋 wrote:

>   Hi! I am a novice at VTK.
> I want to read my Tecplot data and show it using VTK.The data file(old_bridge.plt) and the result had been adjoined into attachment.
> In the data file ,it has 8 nodes,6 cells with the type of triangle.
> My code(showBridge.cxx) adjoined into attachment.And my trouble is how to transfer vtkMultiBlockDataSet to vtkPolyData. This code is the modification from the book "The Visualization Toolkit  3rd" in chapter 5.
> Do you think my solution is right ? or there are some other ways to do this more effectively?
> The on line help "vtkTecplotReader Class Reference" says:"vtkTecplotReader parses an ASCII Tecplot file,and can  extract  vtkPointData and / or vtkCellData".Unfortunately,there are not have additional details of how to extract the pointdata and celldata.
> I have been puzzled by this problem for few days , after all,there are so many Classes similar in VTK.
> Any suggestions are very glad.
> Thanks!
> Reece
> 
> 
> 全国最低价,天天在家冲照片,24小时发货上门! <showBridge.cxx><old_bridge.plt><result.jpg>_______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100926/1ec8f8c9/attachment.htm>


More information about the vtkusers mailing list