<div dir="ltr">Hello. Thank you for your answer. The method 1 worked !<div>I don't like method 2 because it depends a lot on the input data, which can change... (that angle thing is a little too much for our case). </div><div>We'll use method 1 for the moment!</div><div>My problem was that the input of vtkCutter wasn't the output of vtkTableBasedClipDataSet but the original model itself, then the mesh in the cut got calculated twice and using different methods.</div><div><br></div><div>Thanks a lot!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 October 2017 at 08:04, 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">Hello,<br>
<br>
Firstly the cutting algorithms are different between<br>
vtkTableBasedClipDataSet and vtkCutter, thus in general the generated<br>
cross sections are quite different.<br>
<br>
I have no idea how to extract a section surface directly from output<br>
of vtkTableBasedClipDataSet, however here are two insufficient ways:<br>
1) vtkTableBasedClipDataSet -> vtkCutter (Cutter.tar.gz)<br>
2) vtkTableBasedClipDataSet -> vtkGeometryFilter -> vtkPolyDataNormals<br>
-> vtkConnectivityFilter (Cutter2.tar.gz)<br>
<br>
---<br>
1) This method conducts double cutting using the same plane in turn.<br>
But in order to avoid the broken polygons as output of vtkCutter, the<br>
position of a cutting plain need to be slightly shifted from the used<br>
in vtkTableBasedClipDataSet. This means good accuracy of results are<br>
not be retained.<br>
2) This method divides the surface by feature edges (vtkPolyDataNormals)<br>
and then selects the desired surface among them based on polygonal<br>
connectivity (vtkConnectivityFilter). Here, the origin of a cutting<br>
plane need to be known and be only on the cross section of objects so<br>
as to extract the cross section according to the criteria "extract the<br>
region closest to the origin". In addition, in vtkPolyDataNormals the<br>
feature angle to determine feature edges need to be adjusted in<br>
accordance with each dataset.<br>
<br>
I'm sorry for my poor English.<br>
<div class="HOEnZb"><div class="h5"><br>
2017-10-18 23:00 GMT+09:00 Fernando Nellmeldin<br>
<<a href="mailto:f.nellmeldin@open-engineering.com">f.nellmeldin@open-<wbr>engineering.com</a>>:<br>
> Hello, sorry for coming back to this topic, but I have found some cases<br>
> where this doesn't work.<br>
><br>
> I attached a screenshot.<br>
> On top is the 3d mesh cut by a plane parallel to the screen. We can see that<br>
> are some elements (hexahedrons) that got cut and they were split in sets of<br>
> tetrahedrons.<br>
> At the bottom, we see the result of calling vtkCutter -><br>
> vtkCleanUnstructuredGrid -> vtkXMLUnstructuredGridWriter. The result are all<br>
> quads and all the generated nodes by the cut are gone, and we see no<br>
> triangles.<br>
> I would expect to have the same result that we see on the top, but with 2d<br>
> elements instead of 3d.<br>
><br>
> Here's my code:<br>
><br>
> void cutModel(vtkSmartPointer<<wbr>vtkUnstructuredGrid> model, double normal[3])<br>
> {<br>
> vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::<wbr>New();<br>
> plane->SetOrigin(0.0, 0.0, 0.0);<br>
> plane->SetNormal(normal);<br>
><br>
> vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::<wbr>New();<br>
> cutter->SetCutFunction(plane);<br>
> cutter->SetInputData(model);<br>
> cutter->GenerateTrianglesOff()<wbr>;<br>
> cutter->Update();<br>
><br>
> vtkSmartPointer<<wbr>vtkCleanUnstructuredGrid> cleaner =<br>
> vtkSmartPointer<<wbr>vtkCleanUnstructuredGrid>::<wbr>New();<br>
> cleaner->SetInputConnection(<wbr>cutter->GetOutputPort());<br>
> cleaner->Update();<br>
> vtkSmartPointer<<wbr>vtkXMLUnstructuredGridWriter> writer =<br>
> vtkSmartPointer<<wbr>vtkXMLUnstructuredGridWriter>:<wbr>:New();<br>
> writer->SetFileName("planecut.<wbr>vtu");<br>
> writer->SetInputConnection(<wbr>cleaner->GetOutputPort());<br>
> writer->SetDataModeToAscii();<br>
> writer->Write();<br>
> }<br>
><br>
><br>
><br>
> Thank you.<br>
><br>
><br>
> On 29 September 2017 at 13:23, Fernando Nellmeldin<br>
> <<a href="mailto:f.nellmeldin@open-engineering.com">f.nellmeldin@open-<wbr>engineering.com</a>> wrote:<br>
>><br>
>> Hello, that worked as a charm, thank you very much for your time!!<br>
>><br>
>> On 29 September 2017 at 11:31, kenichiro yoshimi <<a href="mailto:rccm.kyoshimi@gmail.com">rccm.kyoshimi@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> 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>
>>><br>
>>> 2017-09-29 16:37 GMT+09:00 Fernando Nellmeldin<br>
>>> <<a href="mailto:f.nellmeldin@open-engineering.com">f.nellmeldin@open-<wbr>engineering.com</a>>:<br>
>>> > Hello. That did the job! (although I get a triangle mesh while the<br>
>>> > initial<br>
>>> > surface was full of sliced hexahedron (quads).<br>
>>> ><br>
>>> > Thank you!<br>
>>> ><br>
>>> > On 29 September 2017 at 04:05, kenichiro yoshimi<br>
>>> > <<a href="mailto:rccm.kyoshimi@gmail.com">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>::<wbr>New();<br>
>>> >>   cutter->SetCutFunction(plane);<br>
>>> >>   cutter->SetInputConnection(<wbr>model->GetOutputPort());<br>
>>> >><br>
>>> >>   // Convert polyData to unstructuredGrid<br>
>>> >>   vtkSmartPointer<<wbr>vtkDataSetTriangleFilter> triFilter =<br>
>>> >>     vtkSmartPointer<<wbr>vtkDataSetTriangleFilter>::<wbr>New();<br>
>>> >>   triFilter->SetInputConnection(<wbr>cutter->GetOutputPort());<br>
>>> >>   triFilter->Update();<br>
>>> >><br>
>>> >>   vtkSmartPointer<<wbr>vtkXMLUnstructuredGridWriter> writer =<br>
>>> >>     vtkSmartPointer<<wbr>vtkXMLUnstructuredGridWriter>:<wbr>:New();<br>
>>> >>   writer->SetFileName("<wbr>unstructuredGrid.vtu");<br>
>>> >>   writer->SetInputConnection(<wbr>triFilter->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">f.nellmeldin@open-<wbr>engineering.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,<br>
>>> >> > also as<br>
>>> >> > vtkUnstructuredGrid. This is working.<br>
>>> >> ><br>
>>> >> > Now, I would like to obtain ONLY the surface of the cut, than means:<br>
>>> >> > I<br>
>>> >> > want<br>
>>> >> > a vtkUnstructuredGrid with the nodes and faces being on the surface<br>
>>> >> > 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<br>
>>> >> > 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<<wbr>vtkUnstructuredGrid> model =<br>
>>> >> > vtkSmartPointer<<wbr>vtkUnstructuredGrid>::New();<br>
>>> >> > // fill the ugrid ...<br>
>>> >> ><br>
>>> >> > // Create The Plane to cut<br>
>>> >> > vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::<wbr>New();<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<<wbr>vtkTableBasedClipDataSet> clipDataSet =<br>
>>> >> > vtkSmartPointer<<wbr>vtkTableBasedClipDataSet>::<wbr>New();<br>
>>> >> > clipDataSet->SetClipFunction(<wbr>plane);<br>
>>> >> > clipDataSet->InsideOutOn();<br>
>>> >> > clipDataSet-><wbr>GenerateClippedOutputOn();<br>
>>> >> > clipDataSet-><wbr>SetInputConnection(model-><wbr>GetProducerPort());<br>
>>> >> > clipDataSet->Update();<br>
>>> >> ><br>
>>> >> > // This has half the model, this is Ok but not what I want<br>
>>> >> > vtkSmartPointer<<wbr>vtkUnstructuredGrid> halfModel =<br>
>>> >> > clipDataSet->GetOutput();<br>
>>> >> ><br>
>>> >> > ////****////<br>
>>> >> > // BEGINS code not working to extract the surface of the cut<br>
>>> >> > vtkSmartPointer<vtkCutter> cutter =<br>
>>> >> > vtkSmartPointer<vtkCutter>::<wbr>New();<br>
>>> >> > cutter->SetCutFunction(plane);<br>
>>> >> > cutter->SetInputConnection(<wbr>model->GetProducerPort());<br>
>>> >> > cutter->Update();<br>
>>> >> ><br>
>>> >> > vtkSmartPointer<vtkStripper> stripper =<br>
>>> >> > vtkSmartPointer<vtkStripper>::<wbr>New();<br>
>>> >> > stripper->SetInputConnection(<wbr>cutter->GetOutputPort());<br>
>>> >> > stripper->Update();<br>
>>> >> ><br>
>>> >> > vtkSmartPointer<vtkPolyData> pd =<br>
>>> >> > vtkSmartPointer<vtkPolyData>::<wbr>New();<br>
>>> >> > pd->SetPoints(stripper-><wbr>GetOutput()->GetPoints());<br>
>>> >> > pd->SetPolys(stripper-><wbr>GetOutput()->GetLines());<br>
>>> >> ><br>
>>> >> > vtkSmartPointer<<wbr>vtkUnstructuredGrid> clipped =<br>
>>> >> > vtkSmartPointer<<wbr>vtkUnstructuredGrid>::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<<wbr>vtkXMLUnstructuredGridWriter> writer =<br>
>>> >> > vtkSmartPointer<<wbr>vtkXMLUnstructuredGridWriter>:<wbr>:New();<br>
>>> >> > writer->SetFileName("d:/<wbr>unstructuredGrid.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/<wbr>opensource/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_<wbr>FAQ</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/<wbr>mailman/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.<wbr>com</a><br>
>>> > <a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" rel="noreferrer" target="_blank">https://www.linkedin.com/<wbr>company/open-engineering?trk=<wbr>biz-companies-cym</a><br>
>>> ><br>
>>> > ______________________________<wbr>______________________________<wbr>_____________<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.<wbr>com</a><br>
>> <a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" rel="noreferrer" target="_blank">https://www.linkedin.com/<wbr>company/open-engineering?trk=<wbr>biz-companies-cym</a><br>
>> ______________________________<wbr>______________________________<wbr>_____________<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.<wbr>com</a><br>
> <a href="https://www.linkedin.com/company/open-engineering?trk=biz-companies-cym" rel="noreferrer" target="_blank">https://www.linkedin.com/<wbr>company/open-engineering?trk=<wbr>biz-companies-cym</a><br>
> ______________________________<wbr>______________________________<wbr>_____________<br>
</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>