<div dir="ltr">Hello, sorry for coming back to this topic, but I have found some cases where this doesn't work.<div><br></div><div>I attached a screenshot. <div>On top is the 3d mesh cut by a plane parallel to the screen. We can see that are some elements (hexahedrons) that got cut and they were split in sets of tetrahedrons.</div><div>At the bottom, we see the result of calling vtkCutter -> vtkCleanUnstructuredGrid -> vtkXMLUnstructuredGridWriter. The result are all quads and all the generated nodes by the cut are gone, and we see no triangles.</div><div>I would expect to have the same result that we see on the top, but with 2d elements instead of 3d.</div><div><br></div><div>Here's my code:</div><div><br></div><div><div><font face="monospace, monospace">void cutModel(vtkSmartPointer<vtkUnstructuredGrid> model, double normal[3])</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">        </span>plane->SetOrigin(0.0, 0.0, 0.0);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">    </span>plane->SetNormal(normal);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">   </span>vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>cutter->SetCutFunction(plane);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>cutter->SetInputData(model);</font></div><div><font face="monospace, monospace"><span style="white-space:pre">        </span>cutter->GenerateTrianglesOff();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">     </span>cutter->Update();</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span style="white-space:pre">   </span>vtkSmartPointer<vtkCleanUnstructuredGrid> cleaner = vtkSmartPointer<vtkCleanUnstructuredGrid>::New();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>cleaner->SetInputConnection(cutter->GetOutputPort());</font></div><div><font face="monospace, monospace"><span style="white-space:pre">    </span>cleaner->Update();</font></div><div><span style="white-space:pre"><font face="monospace, monospace">  </font></span></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>writer->SetFileName("planecut.vtu");</font></div><div><font face="monospace, monospace"><span style="white-space:pre">      </span>writer->SetInputConnection(cleaner->GetOutputPort());</font></div><div><font face="monospace, monospace"><span style="white-space:pre">    </span>writer->SetDataModeToAscii();</font></div><div><font face="monospace, monospace"><span style="white-space:pre">       </span>writer->Write();</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div><br></div><div><br></div><div>Thank you.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 September 2017 at 13:23, Fernando Nellmeldin <span dir="ltr"><<a href="mailto:f.nellmeldin@open-engineering.com" target="_blank">f.nellmeldin@open-engineering.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello, that worked as a charm, thank you very much for your time!!</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 29 September 2017 at 11:31, kenichiro yoshimi <span dir="ltr"><<a href="mailto:rccm.kyoshimi@gmail.com" target="_blank">rccm.kyoshimi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Fernando,<br>
<br>
This will be accomplished by using vtkCleanUnstructuredGrid class<br>
found in ParaView without triangulation. I have attached a simple<br>
code.<br>
<br>
Thanks<br>
<div class="m_-6479816957301548210HOEnZb"><div class="m_-6479816957301548210h5"><br>
2017-09-29 16:37 GMT+09:00 Fernando Nellmeldin<br>
<<a href="mailto:f.nellmeldin@open-engineering.com" target="_blank">f.nellmeldin@open-engineering<wbr>.com</a>>:<br>
> Hello. That did the job! (although I get a triangle mesh while the initial<br>
> surface was full of sliced hexahedron (quads).<br>
><br>
> Thank you!<br>
><br>
> On 29 September 2017 at 04:05, kenichiro yoshimi <<a href="mailto:rccm.kyoshimi@gmail.com" target="_blank">rccm.kyoshimi@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hello,<br>
>><br>
>> Using vtkDataSetTriangleFilter is a simple way which allows you to<br>
>> convert polyData to unstructuredGrid. Something like this (VTK-8.0.0):<br>
>> ---<br>
>>   // Create cutter<br>
>>   vtkSmartPointer<vtkCutter> cutter =<br>
>>     vtkSmartPointer<vtkCutter>::N<wbr>ew();<br>
>>   cutter->SetCutFunction(plane)<wbr>;<br>
>>   cutter->SetInputConnection(mo<wbr>del->GetOutputPort());<br>
>><br>
>>   // Convert polyData to unstructuredGrid<br>
>>   vtkSmartPointer<vtkDataSetTri<wbr>angleFilter> triFilter =<br>
>>     vtkSmartPointer<vtkDataSetTri<wbr>angleFilter>::New();<br>
>>   triFilter-><wbr>SetInputConnection(cutter-><wbr>GetOutputPort());<br>
>>   triFilter->Update();<br>
>><br>
>>   vtkSmartPointer<vtkXMLUnstruc<wbr>turedGridWriter> writer =<br>
>>     vtkSmartPointer<vtkXMLUnstruc<wbr>turedGridWriter>::New();<br>
>>   writer->SetFileName("unstruct<wbr>uredGrid.vtu");<br>
>>   writer->SetInputConnection(tr<wbr>iFilter->GetOutputPort());<br>
>>   writer->Write();<br>
>> ---<br>
>><br>
>> Regards<br>
>><br>
>> 2017-09-28 23:43 GMT+09:00 Fernando Nellmeldin<br>
>> <<a href="mailto:f.nellmeldin@open-engineering.com" target="_blank">f.nellmeldin@open-engineering<wbr>.com</a>>:<br>
>> > Hello.<br>
>> > I have a method to cut a volume in a vtkUnstructuredGrid given a<br>
>> > vtkPlane.<br>
>> > I'm using vtkTableBasedClipDataSet to extract half of the model, also as<br>
>> > vtkUnstructuredGrid. This is working.<br>
>> ><br>
>> > Now, I would like to obtain ONLY the surface of the cut, than means: I<br>
>> > want<br>
>> > a vtkUnstructuredGrid with the nodes and faces being on the surface of<br>
>> > the<br>
>> > cut.<br>
>> > How can this be achieved?<br>
>> ><br>
>> > I tried using vtkCutter with vtkStripper but the mesh I get doesn't have<br>
>> > any<br>
>> > cells, only the points and their associated data.<br>
>> ><br>
>> > Here's how my code looks like.<br>
>> ><br>
>> > Thank You!<br>
>> ><br>
>> > vtkSmartPointer<vtkUnstructure<wbr>dGrid> model =<br>
>> > vtkSmartPointer<vtkUnstructure<wbr>dGrid>::New();<br>
>> > // fill the ugrid ...<br>
>> ><br>
>> > // Create The Plane to cut<br>
>> > vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New<wbr>();<br>
>> > plane->SetOrigin(0.0, 0.0, 0.0);<br>
>> > plane->SetNormal(1.0, 0, 0);<br>
>> ><br>
>> > // Code to cut the model in half<br>
>> > vtkSmartPointer<vtkTableBasedC<wbr>lipDataSet> clipDataSet =<br>
>> > vtkSmartPointer<vtkTableBasedC<wbr>lipDataSet>::New();<br>
>> > clipDataSet->SetClipFunction(p<wbr>lane);<br>
>> > clipDataSet->InsideOutOn();<br>
>> > clipDataSet->GenerateClippedOu<wbr>tputOn();<br>
>> > clipDataSet->SetInputConnectio<wbr>n(model->GetProducerPort());<br>
>> > clipDataSet->Update();<br>
>> ><br>
>> > // This has half the model, this is Ok but not what I want<br>
>> > vtkSmartPointer<vtkUnstructure<wbr>dGrid> halfModel =<br>
>> > clipDataSet->GetOutput();<br>
>> ><br>
>> > ////****////<br>
>> > // BEGINS code not working to extract the surface of the cut<br>
>> > vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::Ne<wbr>w();<br>
>> > cutter->SetCutFunction(plane);<br>
>> > cutter->SetInputConnection(mod<wbr>el->GetProducerPort());<br>
>> > cutter->Update();<br>
>> ><br>
>> > vtkSmartPointer<vtkStripper> stripper =<br>
>> > vtkSmartPointer<vtkStripper>::<wbr>New();<br>
>> > stripper->SetInputConnection(c<wbr>utter->GetOutputPort());<br>
>> > stripper->Update();<br>
>> ><br>
>> > vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::<wbr>New();<br>
>> > pd->SetPoints(stripper->GetOut<wbr>put()->GetPoints());<br>
>> > pd->SetPolys(stripper->GetOutp<wbr>ut()->GetLines());<br>
>> ><br>
>> > vtkSmartPointer<vtkUnstructure<wbr>dGrid> clipped =<br>
>> > vtkSmartPointer<vtkUnstructure<wbr>dGrid>::New();<br>
>> > clipped->ShallowCopy(pd);<br>
>> ><br>
>> > // Here I see that there is no Cells<br>
>> > clipped->Print(std::cout);<br>
>> ><br>
>> > // ENDS code to extract the surface of the cut<br>
>> > ////****////<br>
>> ><br>
>> > // Write the unstructured grid<br>
>> > vtkSmartPointer<vtkXMLUnstruct<wbr>uredGridWriter> writer =<br>
>> > vtkSmartPointer<vtkXMLUnstruct<wbr>uredGridWriter>::New();<br>
>> > writer->SetFileName("d:/unstru<wbr>cturedGrid.vtu");<br>
>> > writer->SetInput(clipped);<br>
>> > writer->SetDataModeToAscii();<br>
>> > writer->Write();<br>
>> > // file doesnt have any cell, only points and pointdata<br>
>> ><br>
>> > ______________________________<wbr>_________________<br>
>> > Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the VTK FAQ at:<br>
>> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a><br>
>> ><br>
>> > Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a><br>
>> ><br>
><br>
><br>
><br>
><br>
> --<br>
> Fernando NELLMELDIN<br>
> Software Engineer<br>
> ______________________________<wbr>______________________________<wbr>___<br>
><br>
> Open Engineering s.a.<br>
><br>
> Rue Bois Saint-Jean 15/1<br>
> B-4102 Seraing (Belgium)<br>
> Tel: +32.4.353.30.34<br>
><br>
> <a href="http://www.open-engineering.com" rel="noreferrer" target="_blank">http://www.open-engineering.co<wbr>m</a><br>
> <a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" rel="noreferrer" target="_blank">https://www.linkedin.com/compa<wbr>ny/open-engineering?trk=biz-<wbr>companies-cym</a><br>
> ______________________________<wbr>______________________________<wbr>_____________<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-6479816957301548210gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><b>Fernando NELLMELDIN</b><br>Software Engineer<div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#cc0000">______________________________<wbr>______________________________<wbr>___</font></b><br></div><div><div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#000000"><br></font></b></div><div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#000000">O</font><font color="#cc0000">pen E</font><font color="#000000">ngineering s.a.</font></b><br></div><div style="font-size:12.8px"><font color="#000000"><br></font></div><div style="font-size:12.8px"><font color="#000000">Rue Bois Saint-Jean 15/1</font></div><div style="font-size:12.8px"><font color="#000000">B-4102 Seraing (Belgium)</font></div><div><font color="#000000" style="font-size:12.8px">Tel: </font>+32.4.353.30.34 </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><a href="http://www.open-engineering.com/" style="color:rgb(17,85,204)" target="_blank">http://www.open-engineering.<wbr>com</a></div><div style="font-size:12.8px"><a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" style="color:rgb(17,85,204)" target="_blank">https://www.linkedin.com/<wbr>company/open-engineering?trk=<wbr>biz-companies-cym</a><br></div><div style="font-size:12.8px"><b><font color="#cc0000"><span style="font-family:'arial black',sans-serif;font-size:12.8px">______________________________<wbr>______________________________<wbr>_____________<br></span></font></b></div></div></div></div></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><b>Fernando NELLMELDIN</b><br>Software Engineer<div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#cc0000">_______________________________________________________________</font></b><br></div><div><div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#000000"><br></font></b></div><div style="font-size:12.8px"><b style="font-size:12.8px"><font color="#000000">O</font><font color="#cc0000">pen E</font><font color="#000000">ngineering s.a.</font></b><br></div><div style="font-size:12.8px"><font color="#000000"><br></font></div><div style="font-size:12.8px"><font color="#000000">Rue Bois Saint-Jean 15/1</font></div><div style="font-size:12.8px"><font color="#000000">B-4102 Seraing (Belgium)</font></div><div><font color="#000000" style="font-size:12.8px">Tel: </font>+32.4.353.30.34 </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><a href="http://www.open-engineering.com/" style="color:rgb(17,85,204)" target="_blank">http://www.open-engineering.com</a></div><div style="font-size:12.8px"><a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" style="color:rgb(17,85,204)" target="_blank">https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym</a><br></div><div style="font-size:12.8px"><b><font color="#cc0000"><span style="font-family:'arial black',sans-serif;font-size:12.8px">_________________________________________________________________________<br></span></font></b></div></div></div></div></div></div></div>
</div></div>