Cut a space with multiple objects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Cut a space with multiple objects

WangQ
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

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

strat-82.png (55K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Cut a space with multiple objects

VTK - Users mailing list
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 <[hidden email]> 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

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

_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Cut a space with multiple objects

WangQ
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 <[hidden email]>
Sent: 14 January 2019 19:41
To: Q Wang
Cc: [hidden email]
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 <[hidden email]> 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

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

_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers