<div dir="ltr">Hi Patrick,<div><br></div><div>Thanks for the clarification. I have tried your approach, but however the wall was not covered up the entire boundary. The wall was stopped kinda half way. </div><div>Do you mind taking a look at my code to see what went wrong? I have created a gist here: <a href="https://gist.github.com/ngunhaSO/f3902fd34172a161b678b2a05a5c91fe">https://gist.github.com/ngunhaSO/f3902fd34172a161b678b2a05a5c91fe</a></div><div>I have also attached a stl file that i wanna manipulate and the screenshot of what i achieved here: <a href="https://github.com/ngunhaSO/misc">https://github.com/ngunhaSO/misc</a></div><div><br></div><div>Thank you!</div><div><br></div><div>Jacky</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 16, 2018 at 7:48 PM Patrick Bergeron <<a href="mailto:pbergeron@spiria.com">pbergeron@spiria.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-CA" link="blue" vlink="purple">
<div class="m_-2344812717380975168WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi Jacky<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Let me try to be clearer. Let’s say you have a surface floating in space, which seems to be your case.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">You can create a wall around your surface, by creating new geometry around your surface, which we will say is your wall. On the wall, you need to connect boundary edges with the floor (at z=0).
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">So set’s say you find a boundary edge with points a and b<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<ul style="margin-top:0cm" type="disc">
<li class="m_-2344812717380975168MsoListParagraph" style="margin-left:0cm"><span lang="EN-US">Add 2 points to your polydata. (xa, ya, 0),  (xb, yb, 0)<u></u><u></u></span></li></ul>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Then you create a quad that goes like this:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">(xa,ya,za), <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> (xb,yb,zb)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"></span>(xb,yb,0)<u></u><u></u></p>
<p class="MsoNormal">(xa,ya,0)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Or if you prefer you can create 2 triangles:<u></u><u></u></p>
<p class="MsoNormal">(xa,ya,za), <u></u><u></u></p>
<p class="MsoNormal"> (xb,yb,zb)<u></u><u></u></p>
<p class="MsoNormal">(xb,yb,0)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">(xb,yb,0)<u></u><u></u></p>
<p class="MsoNormal">(xa,ya,0)<u></u><u></u></p>
<p class="MsoNormal">(xa,ya,za), <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Anyway, after you create your walls at each boundary edge, you end up with walls that go all around your surface, but with no horizontal surface  at the bottom. Maybe this is important to you, maybe not.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">If it’s important, you can create a duplicate copy of your top surface, but in the copy, set all your point’s  Z to 0.0.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">This will flatten out the copy of your top surface and place it at Z=0, connecting to the bottom of your wall that you created all around your surface<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-US">You will end up with a volume with the sides and bottom capped off.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Patrick.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Jacky Nguyen <<a href="mailto:jackynguyen.km@gmail.com" target="_blank">jackynguyen.km@gmail.com</a>><br>
<b>Date: </b>Monday, July 16, 2018 at 5:12 AM<br>
<b>To: </b>Patrick Bergeron <<a href="mailto:pbergeron@spiria.com" target="_blank">pbergeron@spiria.com</a>><br>
<b>Cc: </b>"<a href="mailto:vtkusers@public.kitware.com" target="_blank">vtkusers@public.kitware.com</a>" <<a href="mailto:vtkusers@public.kitware.com" target="_blank">vtkusers@public.kitware.com</a>><br>
<b>Subject: </b>Re: [vtkusers] Close the gap between a mesh and a planar<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><a name="m_-2344812717380975168__MailOriginalBody">Thanks for your input.  <u></u><u></u></a></p>
<div>
<div>
<p class="MsoNormal"><span>Sorry, I am new to these so I need to take it slowly. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>Let me clarify a few things:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>1) by using your approach, i don't need to create the plane on the bottom of the object as a holder?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>2) When you say "</span><span><span style="font-size:9.5pt">For each boundary edge, create 2 triangles (a quad) with 1 or 2 points at z=0", does it matter
 which x and y coordinate to pick?</span></span><span><u></u><u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:9.5pt">I have added the following codes to extract the edges and find the pointID and point coordinate for each edge in the STL object. I trace through my console log,
 and there is no point that has z = 0</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<pre style="background:#2b2b2b"><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">reader = vtk.vtkSTLReader()<br>reader.SetFileName(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6a8759">'</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">path_to_stl</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6a8759">'</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">)<br>reader.Update()<br><br>triangleFilter = vtk.vtkTriangleFilter()<br>triangleFilter.SetInputConnection(reader.GetOutputPort())<br>triangleFilter.Update()<br><br></span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:gray"># ++++++++++++++++++ extract edges ++++++++++++++++++++++++++++++++++++<br><br></span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">featureEdges = vtk.vtkFeatureEdges()<br>featureEdges.SetInputData(triangleFilter.GetOutput())<br>featureEdges.SetBoundaryEdges(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6897bb">1</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">)</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:gray"><br></span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">featureEdges.SetFeatureEdges(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6897bb">0</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">)<br>featureEdges.SetNonManifoldEdges(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6897bb">0</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">)<br>featureEdges.SetManifoldEdges(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6897bb">0</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">)<br>featureEdges.Update()<br>boundaryMesh = featureEdges.GetOutput()<br>numberOfOpenEdges = featureEdges.GetOutput().GetNumberOfLines()<br></span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#8888c6">print</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6a8759">'number of lines: '</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">, </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">featureEdges.GetOutput().GetNumberOfLines())<br></span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">for </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">i </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">in </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#8888c6">range</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6897bb">0</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">, </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">boundaryMesh.GetNumberOfLines()):<br>    cell = boundaryMesh.GetCell(i)<br>    cellPoints = cell.GetPoints()<br>    pointIds = cell.GetPointIds()<br>    </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">for </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">j </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">in </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#8888c6">range</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6897bb">0</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">, </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">pointIds.GetNumberOfIds()):<br>        </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#8888c6">print</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6a8759">'>>> point id: '</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">, </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">pointIds.GetId(j))<br>        </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#8888c6">print</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">(</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#6a8759">'>>> coordinate: '</span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#cc7832">, </span></span><span><span style="font-size:9.0pt;font-family:Menlo;color:#a9b7c6">boundaryMesh.GetPoint(pointIds.GetId(j)))<u></u><u></u></span></span></pre>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:9.5pt">Thank you,</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span>On Fri, Jul 13, 2018 at 10:10 PM Patrick Bergeron <</span><a href="mailto:pbergeron@spiria.com" target="_blank"><span>pbergeron@spiria.com</span><span></span></a><span>>
 wrote:<u></u><u></u></span></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal"><span>I would take a different approach. 
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>I would look at all the edges that have only 1 cell attached, and these are your boundary edges. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>For each boundary edge, create 2 triangles (a quad) with 1 or 2 points at z=0. (Create 2 new points at z=0 for this purpose). If you already have a point at that z=0, then reuse it don’t create
 it. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>That approach will create quads all around your geometry connecting to the bottom but will leave the bottom hole open.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>Next create a cell connecting all your z=0 points together. Make sure they are ordered in sequential order to create your contour loop.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span>Done<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
<div>
<div id="m_-2344812717380975168m_3919039928470042052AppleMailSignature">
<p class="MsoNormal"><span>Sent from my iPhone<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span><br>
On Jul 13, 2018, at 05:10, Jacky Nguyen <</span><a href="mailto:jackynguyen.km@gmail.com" target="_blank"><span>jackynguyen.km@gmail.com</span><span></span></a><span>>
 wrote:<u></u><u></u></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">I have converted an .obj mesh file to .stl. I also created a planar geometry as a holder for the mesh object then merge
 them. However, it contains a gap. Any suggestion how to close the gap vertically so that it becomes a solid object, I have already tried vtkFillHolesFilter, but it won't fill the gap?</span></span><span><u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white">The code to create the planar:</span></span><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<pre style="background:#eff0f1;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;max-height:600px;word-wrap:normal;text-decoration-style:initial;text-decoration-color:initial;overflow:auto"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">implicitPolyDataDistance = vtk.vtkImplicitPolyDataDistance()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">implicitPolyDataDistance.SetInput(stl_poly_data)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">#create a grid<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">xCoords = vtk.vtkFloatArray()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">for x, i in enumerate(np.linspace(xmin, xmax,50)):<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">    xCoords.InsertNextValue(i)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">yCoords = vtk.vtkFloatArray()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">for y, i in enumerate(np.linspace(ymin, ymax, 50)):<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">    yCoords.InsertNextValue(i)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">zCoords = vtk.vtkFloatArray()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">for z, i in enumerate(np.linspace(zmin, zmin + 1, 50)):<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">    zCoords.InsertNextValue(i)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">rgrid = vtk.vtkRectilinearGrid()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">rgrid.SetDimensions(x + 1, y + 1 , z + 1)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">rgrid.SetXCoordinates(xCoords)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">rgrid.SetYCoordinates(yCoords)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">rgrid.SetZCoordinates(zCoords)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">signedDistances = vtk.vtkFloatArray()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">signedDistances.SetNumberOfComponents(1)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">signedDistances.SetName("SignedDistances")<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"># Evaluate the signed distance function at all of the grid points<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">for pointId in range(rgrid.GetNumberOfPoints()):<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">    p = rgrid.GetPoint(pointId)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">    signedDistance = implicitPolyDataDistance.EvaluateFunction(p)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">    signedDistances.InsertNextValue(signedDistance)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"># add the SignedDistances to the grid<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">rgrid.GetPointData().SetScalars(signedDistances)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"># geometry filter to view the background grid<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">geometryFilter = vtk.vtkRectilinearGridGeometryFilter()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">geometryFilter.SetInputData(rgrid)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">geometryFilter.SetExtent(0, x + 1, 0, y + 1, (z + 1) // 2, (z + 1) // 2)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">geometryFilter.Update()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"># ================ END creating a plane =======================</span></code></span><span><span style="font-family:Consolas;color:#242729;background:white"><u></u><u></u></span></span></pre>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white">The code that merge the stl poly data and the plane:<br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<pre style="background:#eff0f1;vertical-align:baseline;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;box-sizing:inherit;max-height:600px;word-wrap:normal;text-decoration-style:initial;text-decoration-color:initial;overflow:auto"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">meshAppend = vtk.vtkAppendPolyData()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">meshAppend.AddInputData(stl_poly_data)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">meshAppend.AddInputData(geometryFilter.GetOutput())<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">meshAppend.Update()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">boundaryClean = vtk.vtkCleanPolyData()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">boundaryClean.SetInputData(meshAppend.GetOutput())<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">boundaryClean.Update()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">out = vtk.vtkPolyData()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">out.DeepCopy(boundaryClean.GetOutput())<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">triangleTrans = vtk.vtkTriangleFilter()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">triangleTrans.SetInputData(out)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">triangleTrans.Update()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1"><u></u> <u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">fill = vtk.vtkFillHolesFilter()<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">fill.SetInputData(out)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">fill.SetHoleSize(1000000.0)<u></u><u></u></span></code></span></pre>
<pre style="background:#eff0f1;vertical-align:baseline"><span><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0cm;background:#eff0f1">fill.Update()</span></code></span><span><span style="font-family:Consolas;color:#242729;background:white"><u></u><u></u></span></span></pre>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white">A screenshot of what my current mesh is (note: the red line is where i want to close the gap vertically
 along the z axis: </span></span><a href="https://i.stack.imgur.com/F9w3c.png" target="_blank"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;background:white">https://i.stack.imgur.com/F9w3c.png</span></span><span></span></a><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white">Any suggestion to solve this problem?</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white"><br>
<br>
</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><span style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729;background:white">Thank you</span></span><span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
</div>
</div>
</div>
</blockquote>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span>_______________________________________________<br>
Powered by </span><a href="http://www.kitware.com" target="_blank"><span>www.kitware.com</span><span></span></a><span><br>
<br>
Visit other Kitware open-source projects at </span><a href="http://www.kitware.com/opensource/opensource.html" target="_blank"><span>http://www.kitware.com/opensource/opensource.html</span><span></span></a><span><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: </span><a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank"><span>http://www.vtk.org/Wiki/VTK_FAQ</span><span></span></a><span><br>
<br>
Search the list archives at: </span><a href="http://markmail.org/search/?q=vtkusers" target="_blank"><span>http://markmail.org/search/?q=vtkusers</span><span></span></a><span><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
</span><a href="https://public.kitware.com/mailman/listinfo/vtkusers" target="_blank"><span>https://public.kitware.com/mailman/listinfo/vtkusers</span><span></span></a><span><u></u><u></u></span></p>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div>
</div>

</blockquote></div>