[vtkusers] Cut a space with multiple objects
Q Wang
wangq1979 at outlook.com
Mon Jan 14 16:44:30 EST 2019
Thanks David for the tips.
I try the first tip with following code, but it shows nothing on the window. Any comments about the missing objects?
vtkNew<vtkMultiBlockDataSet> mbds;
mbds->SetNumberOfBlocks(spheres.size() + 2);
// add small bubbles
std::cout << "totally " << spheres.size() << " small bubbles are identified" << std::endl;
for (auto i = 0; i < spheres.size(); i++) {
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetThetaResolution(100);
sphereSource->SetPhiResolution(50);
... // set sphere here
mbds->SetBlock(i+1, sphereSource->GetOutput());
}
// Iso-surface using marching cubes
vtkSmartPointer<vtkMarchingCubes> contourFilter = vtkSmartPointer<vtkMarchingCubes>::New();
imageData->SetSpacing(pixelDim * scaleFactor, pixelDim * scaleFactor, pixelDim);
contourFilter->SetInputData(imageData);
contourFilter->ComputeNormalsOn();
contourFilter->SetValue(0, isoValue);
mbds->SetBlock(spheres.size()+1, contourFilter->GetOutput());
vtkNew<vtkCompositePolyDataMapper2> mapper;
mapper->SetInputData((vtkPolyData*)mbds.Get());
vtkNew<vtkCompositeDataDisplayAttributes> cdsa;
mapper->SetCompositeDataDisplayAttributes(cdsa.Get());
vtkNew<vtkActor> actor;
actor->GetProperty()->SetColor(bubbleColor[0], bubbleColor[1], bubbleColor[2]);
actor->GetProperty()->SetOpacity(bubbleColor[3]);
actor->SetMapper(mapper.Get());
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(1, 1, 1);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(1200, 600);
renderWindow->SetWindowName("Bubble Visualisation");
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow.Get());
renderer->AddActor(actor.Get());
renderWindow->Render();
renderWindowInteractor->Start();
In addition, could you shed more light on the second one since I am quite new to VTK?
Best wishes,
Chiang
________________________________
From: David E DeMarle <dave.demarle at kitware.com>
Sent: 14 January 2019 19:41
To: Q Wang
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Cut a space with multiple objects
2.5 strategies of the top of my head -
1) combine everything into a multiblock data set, rendered with the compositepolydatamapper and clip the multiblock.
2) use one plane fed simultaneously into all of the clip filters (<--- try this first)
2.5) use events/observers to make all of the planes follow the actions of one master
hth
David E DeMarle
Kitware, Inc.
Principal Engineer
On Sat, Jan 12, 2019 at 6:55 PM Q Wang <wangq1979 at outlook.com<mailto:wangq1979 at outlook.com>> wrote:
Hello vtkusers,
I use vtk to render a closed space, e.g. a cylinder, and there are numerous objects inside the cylinder, as in the attached figure. Every object inside the cylinder is rendered with its own actor and mapper, and so on. Now, I want to see the cross-sectional image of the cylinder at arbitary positions. I tried different ways, e.g. using a vtkplane to cut, but cannot get what I want since there are multiple objects at the cross-section.
Any suggestion would be appreciated!
Best wishes,
Chiang
_______________________________________________
Powered by www.kitware.com<http://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
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190114/787ada73/attachment.html>
More information about the vtkusers
mailing list