<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div>Thanks for your reply and help.</div><div><br></div><div>The following is my codes:</div><div><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'="">sphere = vtk.vtkSphereSource()<br>sphere.SetCenter(0, 0, 0)<br>sphere.SetRadius(5.0)<br>arrow = vtk.vtkArrowSource()<br>arrow.Update()</span></div><div><span></span><span style="font-family: "" microsoft="" yahei="" ui'";="" font-size:="" 14px;="" color:="" rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,="" font-weight:="" normal;="" font-style:="" normal;text-decoration:="" none;'=""><br>normals = vtk.vtkPolyDataNormals()<br>normals.SetInputConnection(sphere.GetOutputPort())<br><br>normals.ComputePointNormalsOff()<br>normals.ComputeCellNormalsOn()<br>normals.SplittingOff()<br>normals.FlipNormalsOff()<br>normals.ConsistencyOn()<br>normals.AutoOrientNormalsOn()<br>normals.Update()<br><br>mapper = vtk.vtkPolyDataMapper()<br>if vtk.VTK_MAJOR_VERSION <= 5:<br> mapper.SetInput(sphere.GetOutput())<br>else:<br> mapper.SetInputConnection(sphere.GetOutputPort())<br><br>glyph=vtk.vtkGlyph3D()<br><br>glyph.SetInputData(normals.GetOutput())<br>glyph.SetSourceData(arrow.GetOutput())<br>glyph.SetVectorModeToUseNormal()<br>glyph.SetScaleModeToScaleByVector()<br>glyph.SetScaleFactor(1)<br>glyph.OrientOn()<br>glyph.Update()<br>print (glyph)<br><br>glyph_mapper=vtk.vtkPolyDataMapper()<br>glyph_mapper.SetInputData(glyph.GetOutput())<br>glyph_mapper.ImmediateModeRenderingOn()<br>glyph_actor=vtk.vtkActor()<br>glyph_actor.SetMapper(glyph_mapper)<br>glyph_actor.GetProperty().SetColor(1,0.4,1)<br><br>actor = vtk.vtkActor()<br>actor.SetMapper(mapper)</span></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>woshizyc@gmail.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:cory.quammen@kitware.com">Cory Quammen</a></div><div><b>Date:</b> 2017-11-28 22:43</div><div><b>To:</b> <a href="mailto:woshizyc@gmail.com">woshizyc@gmail.com</a></div><div><b>CC:</b> <a href="mailto:vtkusers@vtk.org">vtkusers</a></div><div><b>Subject:</b> Re: [vtkusers] Visualize cell normal vector of polydata</div></div></div><div><div class="FoxDiv20171128233438317161"><div dir="ltr">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.<div><br></div><div>Thanks,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 28, 2017 at 8:20 AM, <a href="mailto:woshizyc@gmail.com">woshizyc@gmail.com</a> <span dir="ltr"><<a href="mailto:woshizyc@gmail.com" target="_blank">woshizyc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.5em; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div>
<div><span></span>Hi, experts,</div><div><br></div><div>I want to visualize the normal vectors of a polydata to be centered in the center of each triangle.</div><div>I tried to do this for a sphere generated from vtkSphereSource.</div><div><br></div><div>I used the following python codes to calculate the normal vectors of the sphere:</div><div><span>sphere = vtk.vtkSphereSource()<br>sphere.SetCenter(0, 0, 0)<br>sphere.SetRadius(5.0)<br>arrow = vtk.vtkArrowSource()<br>arrow.Update()<br><br>normals = vtk.<wbr>vtkPolyDataNormals()<br>normals.SetInputConnection(<wbr>sphere.GetOutputPort())<br><br>normals.<wbr>ComputePointNormalsOff()<br>normals.ComputeCellNormalsOn()<br>normals.SplittingOff()<br>normals.FlipNormalsOff()<br>normals.ConsistencyOn()<br>normals.AutoOrientNormalsOn()<br>normals.Update()</span></div><div><br></div><div>However, it seemed that I did not get the correct normal vectors of each triangle, as<span style="font-size:10.5pt;line-height:1.5;background-color:window"> you can see in the attached figure. </span></div><div>In addition, I also do not know how to move the vectors to the center of each triangle.</div><div><br></div><div>Could any experts give me some clue for solving this problem.</div><div><br></div><div>Are there any example for doing this?</div><div><br></div><div>Thanks in advance.</div><div><br></div><div>Best,</div><div><br></div><div>Yuanchao</div><div><span style="font-size:10.5pt;line-height:1.5;background-color:window"><br></span></div>
<div><br></div><hr style="width:210px;height:1px" color="#b5c4df" size="1" align="left"><span class="HOEnZb"><font color="#888888">
<div><span><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt"><div><a href="mailto:woshizyc@gmail.com" target="_blank">woshizyc@gmail.com</a></div></div></span></div>
</font></span></div><br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>
</div>
</div></div></blockquote>
</body></html>