[vtkusers] write points and normals to file
Cory Quammen
cory.quammen at kitware.com
Wed Oct 12 12:02:04 EDT 2016
Kurt,
Nothing immediately jumps out at me as a problem in your code.
Do you have a small sample file that shows the problem that you can share?
Thanks,
Cory
On Tue, Oct 4, 2016 at 4:44 PM, Kurt Sansom <kayarre at gmail.com> wrote:
> Hi,
> I have some unstructured data, no triangles, just points and normals.
>
> I am trying to write those to a file in the vtp format using the python
> bindings and then load the data in paraview and apply a glyph filter to
> view the vectors. but the glyph filter doesn't appear to work eventhough
> the data looks alright in the vtp file, what am I missing?
>
> here is the code snippet.
>
> #write normals
> points = vtk.vtkPoints()
> verts = vtk.vtkCellArray()
> polydata_pts = vtk.vtkPolyData()
>
> pointNormalsArray = vtk.vtkDoubleArray()
> pointNormalsArray.SetNumberOfComponents(3)
>
> for i in range(clipSeedIds.GetNumberOfIds()):
>
> seedId = clipSeedIds.GetId(i)
>
> locator = vtk.vtkPointLocator()
> locator.SetDataSet(clippedSurface)
> locator.BuildLocator()
>
> seedPoint = self.Surface.GetPoint(seedId)
> seedPointId = locator.FindClosestPoint(seedPoint)
>
> planeEstimator = vtkvmtk.vtkvmtkPolyDataNormalPlaneEstimator()
> planeEstimator.SetInputData(clippedSurface)
> planeEstimator.SetOriginPointId(seedPointId)
> planeEstimator.Update()
>
> plane = vtk.vtkPlane()
> plane.SetOrigin(planeEstimator.GetOrigin())
> plane.SetNormal(planeEstimator.GetNormal())
>
> #testing the normal vector
>
> origin_pt = planeEstimator.GetOrigin()
> normal_pt = planeEstimator.GetNormal()
>
> id = points.InsertNextPoint(origin_pt)
> verts.InsertNextCell(1)
> verts.InsertCellPoint(id)
> pointNormalsArray.InsertNextTuple(normal_pt)
>
>
>
> #Add the points to the polydata container
> polydata_pts.SetPoints(points)
> polydata_pts.SetVerts(verts)
>
> # Add the normals to the points in the polydata
> #polydata_pts.GetCellData().SetNormals(pointNormalsArray)
> polydata_pts.GetPointData().SetNormals(pointNormalsArray)
> polydata_pts.Modified()
>
>
> writer = vtk.vtkXMLPolyDataWriter()
> writer.SetDataModeToAscii()
> writer.SetFileName(os.path.join(
> "/Users/sansomk/caseFiles/ultrasound/cases/DSI003LER/other",
> "pts_out.vtp"))
> writer.SetInputData(polydata_pts)
> writer.Write()
>
>
> ~Kurt
>
> --
> Kurt Sansom
>
> _______________________________________________
> Powered by 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:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161012/06a9eb8c/attachment.html>
More information about the vtkusers
mailing list