Discussion:
[vtkusers] Mesh cutting using freehand curve
Miguel Sotaquira
2012-05-22 03:45:41 UTC
Permalink
Hi everyone!

I have a 3D manifold mesh and I want to be able to cut it using a freehand
(drawn by user) contour. An example of such a mesh and the contour drawn by
the user is shown in this image: http://postimage.org/image/sbnmcoodj/. By
cutting I mean generating a 3D surface from the freehand contour and then
splitting the mesh in two parts.

Up to this point I've came up with this workflow for generating the
freehand contour: vtkContourWidget -> vtkPolygonalSurfacePointPlacer. With
this approach I'm able to draw the contour on the polydata mesh (see
previous figure) and extract the set of contour point coordinates.

However I'm lost from this point:
- How to generate the 3D cutting surface?
- Which would be the most adequate class to perform the cutting:
vtkClipPolyData, vtkCutter, vtkExtractPolyDataGeometry?
- In any of the previous classes I need a vtkImplicitFunction. How to
define a vtkImplicitFunction using the 3D cutting surface?

Thanks for any suggestions,
Miguel
Goodwin Lawlor
2012-05-22 06:16:58 UTC
Permalink
Hi Miguel,

Try out this pipeline:
(in Tcl but it's the same idea in any language)

vtkPoints selectionPoints
selectionPoints InsertNextPoint 1.0 1.0 1.0
# etc...

vtkSelectPolyData select
select SetLoop selectionPoints
# connect your data here
select SetInputConnection [mydataFilter GetOutputPort]
select GenerateSelectionScalarsOn
select SetSelectionModeToLargestRegion;

vtkClipPolyData selectclip
selectclip SetInputConnection [select GetOutputPort]
selectclip SetValue 0.0

It's not 100% robust but works for most meshes that have well behaved
topology...

hth

Goodwin
Post by Miguel Sotaquira
Hi everyone!
I have a 3D manifold mesh and I want to be able to cut it using a freehand
(drawn by user) contour. An example of such a mesh and the contour drawn by
the user is shown in this image: http://postimage.org/image/sbnmcoodj/. By
cutting I mean generating a 3D surface from the freehand contour and then
splitting the mesh in two parts.
Up to this point I've came up with this workflow for generating the
freehand contour: vtkContourWidget -> vtkPolygonalSurfacePointPlacer. With
this approach I'm able to draw the contour on the polydata mesh (see
previous figure) and extract the set of contour point coordinates.
- How to generate the 3D cutting surface?
vtkClipPolyData, vtkCutter, vtkExtractPolyDataGeometry?
- In any of the previous classes I need a vtkImplicitFunction. How to
define a vtkImplicitFunction using the 3D cutting surface?
Thanks for any suggestions,
Miguel
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.vtk.org/Wiki/VTK_FAQ
http://www.vtk.org/mailman/listinfo/vtkusers
Miguel Sotaquira
2012-05-22 12:38:46 UTC
Permalink
Hi Goodwin,

The filter vtkSelectPolyData doesn't require a closed loop to select the
region inside/outside the polygonal mesh? In my case I actually don't have
a closed contour, just a freehand line obtained using vtkContourWidget.

I was checking the documentation and there's this vtkImplicitSelectionLoop
that would be useful, although - again - it seems that only works with
closed contours. Isn't there something similar to vtkImplicitSelectionLoop
but that works with open selections?

Thanks again!
Miguel

On Tue, May 22, 2012 at 8:16 AM, Goodwin Lawlor <
Post by Goodwin Lawlor
Hi Miguel,
(in Tcl but it's the same idea in any language)
vtkPoints selectionPoints
selectionPoints InsertNextPoint 1.0 1.0 1.0
# etc...
vtkSelectPolyData select
select SetLoop selectionPoints
# connect your data here
select SetInputConnection [mydataFilter GetOutputPort]
select GenerateSelectionScalarsOn
select SetSelectionModeToLargestRegion;
vtkClipPolyData selectclip
selectclip SetInputConnection [select GetOutputPort]
selectclip SetValue 0.0
It's not 100% robust but works for most meshes that have well behaved
topology...
hth
Goodwin
Post by Miguel Sotaquira
Hi everyone!
I have a 3D manifold mesh and I want to be able to cut it using a
freehand (drawn by user) contour. An example of such a mesh and the contour
http://postimage.org/image/sbnmcoodj/. By cutting I mean generating a 3D
surface from the freehand contour and then splitting the mesh in two parts.
Up to this point I've came up with this workflow for generating the
freehand contour: vtkContourWidget -> vtkPolygonalSurfacePointPlacer. With
this approach I'm able to draw the contour on the polydata mesh (see
previous figure) and extract the set of contour point coordinates.
- How to generate the 3D cutting surface?
vtkClipPolyData, vtkCutter, vtkExtractPolyDataGeometry?
- In any of the previous classes I need a vtkImplicitFunction. How to
define a vtkImplicitFunction using the 3D cutting surface?
Thanks for any suggestions,
Miguel
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.vtk.org/Wiki/VTK_FAQ
http://www.vtk.org/mailman/listinfo/vtkusers
Goodwin Lawlor
2012-05-22 16:50:21 UTC
Permalink
Hi Miguel,

vtkSelectPolyData requires an almost closed loop - it closes the last and
first point for you.

Loading...