[vtkusers] Visualize cell normal vector of polydata
woshizyc at gmail.com
woshizyc at gmail.com
Tue Nov 28 11:07:07 EST 2017
Thanks for your reply and help.
The following is my codes:
sphere = vtk.vtkSphereSource()
sphere.SetCenter(0, 0, 0)
sphere.SetRadius(5.0)
arrow = vtk.vtkArrowSource()
arrow.Update()
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(sphere.GetOutputPort())
normals.ComputePointNormalsOff()
normals.ComputeCellNormalsOn()
normals.SplittingOff()
normals.FlipNormalsOff()
normals.ConsistencyOn()
normals.AutoOrientNormalsOn()
normals.Update()
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(sphere.GetOutput())
else:
mapper.SetInputConnection(sphere.GetOutputPort())
glyph=vtk.vtkGlyph3D()
glyph.SetInputData(normals.GetOutput())
glyph.SetSourceData(arrow.GetOutput())
glyph.SetVectorModeToUseNormal()
glyph.SetScaleModeToScaleByVector()
glyph.SetScaleFactor(1)
glyph.OrientOn()
glyph.Update()
print (glyph)
glyph_mapper=vtk.vtkPolyDataMapper()
glyph_mapper.SetInputData(glyph.GetOutput())
glyph_mapper.ImmediateModeRenderingOn()
glyph_actor=vtk.vtkActor()
glyph_actor.SetMapper(glyph_mapper)
glyph_actor.GetProperty().SetColor(1,0.4,1)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
woshizyc at gmail.com
From: Cory Quammen
Date: 2017-11-28 22:43
To: woshizyc at gmail.com
CC: vtkusers
Subject: Re: [vtkusers] Visualize cell normal vector of polydata
How did you generate the arrow glyphs? My guess is that the problem is there rather than in the generation of the cell normals, which appears to me to be correct.
Thanks,
Cory
On Tue, Nov 28, 2017 at 8:20 AM, woshizyc at gmail.com <woshizyc at gmail.com> wrote:
Hi, experts,
I want to visualize the normal vectors of a polydata to be centered in the center of each triangle.
I tried to do this for a sphere generated from vtkSphereSource.
I used the following python codes to calculate the normal vectors of the sphere:
sphere = vtk.vtkSphereSource()
sphere.SetCenter(0, 0, 0)
sphere.SetRadius(5.0)
arrow = vtk.vtkArrowSource()
arrow.Update()
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(sphere.GetOutputPort())
normals.ComputePointNormalsOff()
normals.ComputeCellNormalsOn()
normals.SplittingOff()
normals.FlipNormalsOff()
normals.ConsistencyOn()
normals.AutoOrientNormalsOn()
normals.Update()
However, it seemed that I did not get the correct normal vectors of each triangle, as you can see in the attached figure.
In addition, I also do not know how to move the vectors to the center of each triangle.
Could any experts give me some clue for solving this problem.
Are there any example for doing this?
Thanks in advance.
Best,
Yuanchao
woshizyc at gmail.com
_______________________________________________
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/20171129/8598d99c/attachment.html>
More information about the vtkusers
mailing list