[vtkusers] slice structured grid with polydata

Cory Quammen cory.quammen at kitware.com
Thu Mar 24 17:02:45 EDT 2016


Justin,

I just did some more digging. You might want to try

http://www.vtk.org/doc/nightly/html/classvtkTableBasedClipDataSet.html

The docs say it preserves the input cells whenever possible, which is what
you are looking for.

I think you should be able to just swap out your vtkClipDataSet variable
declaration with a vtkTableBasedClipDataSet variable declaration.

Cory

On Thu, Mar 24, 2016 at 4:40 PM, Justin Weber <onlyjus at gmail.com> wrote:

> Thanks for your help Cory.
>
> Justin
>
> On Thu, Mar 24, 2016 at 2:32 PM, Cory Quammen <cory.quammen at kitware.com>
> wrote:
>
>> I don't think there are options in VTK that will do what you want,
>> unfortunately. You would need to manually identify which hexahedra are not
>> cut and then create a new vtkUnstructuredGrid with those hexahedra as well
>> as the cut tetrahedra.
>>
>> On Thu, Mar 24, 2016 at 2:21 PM, Justin Weber <onlyjus at gmail.com> wrote:
>>
>>> It would be nice if the grid was not tetrahedralized first. I would
>>> like the original hexahedrons that are not sliced to be preserved.
>>>
>>> On Thu, Mar 24, 2016 at 11:59 AM, Cory Quammen <cory.quammen at kitware.com
>>> > wrote:
>>>
>>>> What do you want as output instead?
>>>>
>>>> On Thu, Mar 24, 2016 at 10:53 AM, Justin Weber <onlyjus at gmail.com>
>>>> wrote:
>>>> > I didn't realize this earlier but the vtkClipDataSet tetrahedralizes
>>>> the
>>>> > mesh before slicing? It seems that this is required for the
>>>> algorithm. Do
>>>> > you know of any ways to prevent this?
>>>> >
>>>> > BTW, here is the link to the example:
>>>> >
>>>> http://www.vtk.org/Wiki/VTK/Examples/Python/Meshes/vtkClipDataSetWithPolydata
>>>> >
>>>> > Justin
>>>> >
>>>> > On Mon, Mar 7, 2016 at 5:30 PM, Cory Quammen <
>>>> cory.quammen at kitware.com>
>>>> > wrote:
>>>> >>
>>>> >> That's great, Justin. Thanks for reporting back.
>>>> >>
>>>> >> Cory
>>>> >>
>>>> >> On Mon, Mar 7, 2016 at 4:04 PM, Justin Weber <onlyjus at gmail.com>
>>>> wrote:
>>>> >>>
>>>> >>> Cory,
>>>> >>>
>>>> >>> Thanks for your help. I got it working! I might put the code up as
>>>> an
>>>> >>> example.
>>>> >>>
>>>> >>>
>>>> >>> Justin
>>>> >>>
>>>> >>> On Thu, Feb 18, 2016 at 10:58 PM, Cory Quammen <
>>>> cory.quammen at kitware.com>
>>>> >>> wrote:
>>>> >>>>
>>>> >>>> Justin,
>>>> >>>>
>>>> >>>> There is nothing canned in VTK to do this, but with some work you
>>>> should
>>>> >>>> be able to get there using an implicit function created from your
>>>> STL file.
>>>> >>>> At a high level, what you would do is create an instance of
>>>> >>>> vtkImplicitPolyDataDistance. Set its input to the poly data from
>>>> the STL
>>>> >>>> file. Then, create a new point data array in your structured grid
>>>> that
>>>> >>>> stores the value from the implicit poly data distance filter.
>>>> Negative
>>>> >>>> values will be inside the poly data, positive values outside, and
>>>> 0 at the
>>>> >>>> surface. Finally, use vtkClipDataSet to clip the structured grid a
>>>> function
>>>> >>>> value 0. This should give you back an unstructured grid in
>>>> approximately the
>>>> >>>> shape of your input STL. It won't be exact because of the
>>>> interpolation used
>>>> >>>> by vtkClipDataSet, but it should be close.
>>>> >>>>
>>>> >>>> Hope that helps.
>>>> >>>>
>>>> >>>> Cory
>>>> >>>>
>>>> >>>> On Thu, Feb 18, 2016 at 10:08 PM, Justin Weber <onlyjus at gmail.com>
>>>> >>>> wrote:
>>>> >>>>>
>>>> >>>>> I would like to generate a "cutcell" mesh using vtk by slicing a
>>>> >>>>> structured grid with polydata loaded from a STL file. The
>>>> resulting mesh
>>>> >>>>> would be an unstructured grid.
>>>> >>>>>
>>>> >>>>> Are there any tools in vtk to accomplish this?
>>>> >>>>>
>>>> >>>>> I can create the structured grid and polydata successfully. Now I
>>>> just
>>>> >>>>> need an algorithm to slice the structured mesh with the polydata
>>>> surface.
>>>> >>>>>
>>>> >>>>> In my searching I could not find anything. However, I could
>>>> accomplish
>>>> >>>>> this by ray casting to find the intersections between the
>>>> structured grid
>>>> >>>>> and the polydata. Then using those points to create the
>>>> unstructured grid.
>>>> >>>>>
>>>> >>>>> See attached 2d sketch.
>>>> >>>>>
>>>> >>>>> Thanks!
>>>> >>>>> Justin
>>>> >>>>>
>>>> >>>>>
>>>> >>>>> _______________________________________________
>>>> >>>>> 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:
>>>> >>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>> >>>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>> --
>>>> >>>> Cory Quammen
>>>> >>>> R&D Engineer
>>>> >>>> Kitware, Inc.
>>>> >>>
>>>> >>>
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Cory Quammen
>>>> >> R&D Engineer
>>>> >> Kitware, Inc.
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Cory Quammen
>>>> R&D Engineer
>>>> Kitware, Inc.
>>>>
>>>
>>>
>>
>>
>> --
>> Cory Quammen
>> R&D Engineer
>> Kitware, Inc.
>>
>
>


-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160324/af909d0e/attachment.html>


More information about the vtkusers mailing list