[vtkusers] write points and normals to file

Kurt Sansom kayarre at gmail.com
Wed Oct 12 14:53:14 EDT 2016


I believe the issue is that the default behavior in Paraview is to not show
all the points.
"error between computer and chair"

The glyph Mask had to be changed to show all points. it makes sense for
something that has many points but my data only had three vectors to show
and the mask filter hid them all, so it seems to not non-issue.
I did beat my head over it a bit to much looking in the wrong place.

~Kurt

On Wed, Oct 12, 2016 at 9:02 AM, Cory Quammen <cory.quammen at kitware.com>
wrote:

> 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.vtkvmtkPolyDataNormalP
>> laneEstimator()
>>             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.
>



-- 
Kurt Sansom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161012/8a5b6a9a/attachment.html>


More information about the vtkusers mailing list