<div dir="ltr">Thanks for your input. <div><div>Sorry, I am new to these so I need to take it slowly. </div><div><br></div><div>Let me clarify a few things:</div><div>1) by using your approach, i don't need to create the plane on the bottom of the object as a holder?</div><div>2) When you say "<span style="font-size:12.8px">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></div></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">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></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:Menlo;font-size:9pt">reader = vtk.vtkSTLReader()<br>reader.SetFileName(<span style="color:rgb(106,135,89)">'</span>path_to_stl<span style="color:rgb(106,135,89)">'</span>)<br>reader.Update()<br><br>triangleFilter = vtk.vtkTriangleFilter()<br>triangleFilter.SetInputConnection(reader.GetOutputPort())<br>triangleFilter.Update()<br><br><span style="color:rgb(128,128,128)"># ++++++++++++++++++ extract edges ++++++++++++++++++++++++++++++++++++<br></span><span style="color:rgb(128,128,128)"><br></span>featureEdges = vtk.vtkFeatureEdges()<br>featureEdges.SetInputData(triangleFilter.GetOutput())<br>featureEdges.SetBoundaryEdges(<span style="color:rgb(104,151,187)">1</span>)<span style="color:rgb(128,128,128)"><br></span>featureEdges.SetFeatureEdges(<span style="color:rgb(104,151,187)">0</span>)<br>featureEdges.SetNonManifoldEdges(<span style="color:rgb(104,151,187)">0</span>)<br>featureEdges.SetManifoldEdges(<span style="color:rgb(104,151,187)">0</span>)<br>featureEdges.Update()<br>boundaryMesh = featureEdges.GetOutput()<br>numberOfOpenEdges = featureEdges.GetOutput().GetNumberOfLines()<br><span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(106,135,89)">'number of lines: '</span><span style="color:rgb(204,120,50)">, </span>featureEdges.GetOutput().GetNumberOfLines())<br><span style="color:rgb(204,120,50)">for </span>i <span style="color:rgb(204,120,50)">in </span><span style="color:rgb(136,136,198)">range</span>(<span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">, </span>boundaryMesh.GetNumberOfLines()):<br>    cell = boundaryMesh.GetCell(i)<br>    cellPoints = cell.GetPoints()<br>    pointIds = cell.GetPointIds()<br>    <span style="color:rgb(204,120,50)">for </span>j <span style="color:rgb(204,120,50)">in </span><span style="color:rgb(136,136,198)">range</span>(<span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">, </span>pointIds.GetNumberOfIds()):<br>        <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(106,135,89)">'>>> point id: '</span><span style="color:rgb(204,120,50)">, </span>pointIds.GetId(j))<br>        <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(106,135,89)">'>>> coordinate: '</span><span style="color:rgb(204,120,50)">, </span>boundaryMesh.GetPoint(pointIds.GetId(j)))</pre><br></span></div><div><span style="font-size:12.8px">Thank you,</span></div><div><span style="font-size:12.8px"><br></span></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 13, 2018 at 10:10 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 dir="auto">
I would take a different approach. 
<div><br>
</div>
<div>I would look at all the edges that have only 1 cell attached, and these are your boundary edges. </div>
<div><br>
</div>
<div>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. </div>
<div><br>
</div>
<div>That approach will create quads all around your geometry connecting to the bottom but will leave the bottom hole open.</div>
<div><br>
</div>
<div>Next create a cell connecting all your z=0 points together. Make sure they are ordered in sequential order to create your contour loop.</div>
<div><br>
</div>
<div>Done</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div id="m_3919039928470042052AppleMailSignature">Sent from my iPhone</div>
<div><br>
On Jul 13, 2018, at 05:10, Jacky Nguyen <<a href="mailto:jackynguyen.km@gmail.com" target="_blank">jackynguyen.km@gmail.com</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<div dir="ltr"><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">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><br>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The
 code to create the planar:</span><br>
</span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
<pre style="margin:0px 0px 1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;text-decoration-style:initial;text-decoration-color:initial"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;background-color:rgb(239,240,241);white-space:inherit">implicitPolyDataDistance = vtk.vtkImplicitPolyDataDistance()
implicitPolyDataDistance.SetInput(stl_poly_data)

#create a grid
xCoords = vtk.vtkFloatArray()
for x, i in enumerate(np.linspace(xmin, xmax,50)):
    xCoords.InsertNextValue(i)

yCoords = vtk.vtkFloatArray()
for y, i in enumerate(np.linspace(ymin, ymax, 50)):
    yCoords.InsertNextValue(i)

zCoords = vtk.vtkFloatArray()
for z, i in enumerate(np.linspace(zmin, zmin + 1, 50)):
    zCoords.InsertNextValue(i)

rgrid = vtk.vtkRectilinearGrid()
rgrid.SetDimensions(x + 1, y + 1 , z + 1)
rgrid.SetXCoordinates(xCoords)
rgrid.SetYCoordinates(yCoords)
rgrid.SetZCoordinates(zCoords)
signedDistances = vtk.vtkFloatArray()
signedDistances.SetNumberOfComponents(1)
signedDistances.SetName("SignedDistances")

# Evaluate the signed distance function at all of the grid points
for pointId in range(rgrid.GetNumberOfPoints()):
    p = rgrid.GetPoint(pointId)
    signedDistance = implicitPolyDataDistance.EvaluateFunction(p)
    signedDistances.InsertNextValue(signedDistance)

# add the SignedDistances to the grid
rgrid.GetPointData().SetScalars(signedDistances)

# geometry filter to view the background grid
geometryFilter = vtk.vtkRectilinearGridGeometryFilter()
geometryFilter.SetInputData(rgrid)
geometryFilter.SetExtent(0, x + 1, 0, y + 1, (z + 1) // 2, (z + 1) // 2)
geometryFilter.Update()
# ================ END creating a plane =======================</code></pre>
</span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The
 code that merge the stl poly data and the plane:</span><br>
</span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">
<pre style="margin:0px 0px 1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);word-wrap:normal;text-decoration-style:initial;text-decoration-color:initial"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;background-color:rgb(239,240,241);white-space:inherit">meshAppend = vtk.vtkAppendPolyData()
meshAppend.AddInputData(stl_poly_data)
meshAppend.AddInputData(geometryFilter.GetOutput())
meshAppend.Update()
boundaryClean = vtk.vtkCleanPolyData()
boundaryClean.SetInputData(meshAppend.GetOutput())
boundaryClean.Update()
out = vtk.vtkPolyData()
out.DeepCopy(boundaryClean.GetOutput())

triangleTrans = vtk.vtkTriangleFilter()
triangleTrans.SetInputData(out)
triangleTrans.Update()

fill = vtk.vtkFillHolesFilter()
fill.SetInputData(out)
fill.SetHoleSize(1000000.0)
fill.Update()</code></pre>
<br>
</span></span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">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: <a href="https://i.stack.imgur.com/F9w3c.png" target="_blank">https://i.stack.imgur.com/F9w3c.png</a></span></span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Any
 suggestion to solve this problem?</span></span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br>
</span></span></span></div>
<div><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px;text-align:left;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Thank
 you</span></span></span></div>
<div><br>
</div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div><span>_______________________________________________</span><br>
<span>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a></span><br>
<span></span><br>
<span>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">
http://www.kitware.com/opensource/opensource.html</a></span><br>
<span></span><br>
<span>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a></span><br>
<span></span><br>
<span>Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" target="_blank">
http://markmail.org/search/?q=vtkusers</a></span><br>
<span></span><br>
<span>Follow this link to subscribe/unsubscribe:</span><br>
<span><a href="https://public.kitware.com/mailman/listinfo/vtkusers" target="_blank">https://public.kitware.com/mailman/listinfo/vtkusers</a></span><br>
</div>
</blockquote>
</div>
</div>

</blockquote></div>