[vtkusers] slice structured grid with polydata

Bill Lorensen bill.lorensen at gmail.com
Thu Mar 24 18:43:37 EDT 2016


I translated Justin's python to c++. See here:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/ClipDataSetWithPolyData

Interesting that the results are:
The clipped dataset contains a
vtkUnstructuredGrid that has 65317 cells
Cell type vtkTetra occurs 54690 times.
Cell type vtkWedge occurs 10627 times.

This seems odd to me.


On Thu, Mar 24, 2016 at 2:52 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> The interior cells should be untouched I think. At least that's the
> way the original clippers worked.
>
>
> On Thu, Mar 24, 2016 at 11:21 AM, 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.
>>
>>
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the vtkusers mailing list