[vtkusers] Close the gap between a mesh and a planar
Patrick Bergeron
pbergeron at spiria.com
Fri Jul 13 10:10:39 EDT 2018
I would take a different approach.
I would look at all the edges that have only 1 cell attached, and these are your boundary edges.
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.
That approach will create quads all around your geometry connecting to the bottom but will leave the bottom hole open.
Next create a cell connecting all your z=0 points together. Make sure they are ordered in sequential order to create your contour loop.
Done
Sent from my iPhone
On Jul 13, 2018, at 05:10, Jacky Nguyen <jackynguyen.km at gmail.com<mailto:jackynguyen.km at gmail.com>> wrote:
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?
The code to create the planar:
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 =======================
The code that merge the stl poly data and the plane:
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()
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: https://i.stack.imgur.com/F9w3c.png
Any suggestion to solve this problem?
Thank you
_______________________________________________
Powered by www.kitware.com<http://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:
https://public.kitware.com/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180713/0b769884/attachment.html>
More information about the vtkusers
mailing list