[vtkusers] How to generate a surface normal glyph for a triangle cell
Elvis Dowson
elvis.dowson at mac.com
Wed Oct 8 11:38:10 EDT 2008
FYI,
the code that just uses the surface normal obtained from the
plane source is commented out, since it wasn't working.
# Specify the location of the glyph
#vtkPolyData arrowGlyphPolyData
#vtkPoints arrowGlyphPoints
#arrowGlyphPolyData SetPoints arrowGlyphPoints
#arrowGlyphPoints InsertNextPoint 1 1 0
#eval arrowGlyphPoints InsertNextPoint [planeSource GetNormal]
When I insert this as an input source to the 3D glyph, it gets
oriented the wrong way.
Best regards,
Elvis Dowson
On Oct 8, 2008, at 7:28 PM, Amy Squillacote wrote:
> Hi Elvis,
>
> I'm copying this back to the vtkusers list. Please keep the
> discussion on the list so other people can contribute to it and so
> it's archived for future reference.
>
> - Amy
>
> Elvis Dowson wrote:
>> Hi Amy,
>> Yes, I realized later that I had to turn orient
>> on. I have a very fundamental question, the sample that Miguel
>> pointed me to uses vtkPolyDataNormals to compute the normals of the
>> plane source, and since the plane source has four vertices, four
>> glyphs get generated.
>> However, the plane source has a GetNormal() method, which will
>> return the x, y, z coordinates of it's surface normal. I tried to
>> directly create a vktPolyData structure and inserted the plane
>> source normal and try to get it to display the surface normal, but
>> it kept orienting the wrong way, even after I turned orient on for
>> the 3D glyph.
>> Any ideas why?
>> The source code can be found below.
>>
>> Best regards,
>>
>> Elvis Dowson
>>
>> Begin forwarded message:
>>
>>> *From: *Elvis Dowson <elvis.dowson at mac.com <mailto:elvis.dowson at mac.com
>>> >>
>>> *Date: *October 8, 2008 3:49:33 PM GMT+04:00
>>> *To: *marf at itccanarias.org <mailto:marf at itccanarias.org>
>>> *Cc: *vtkusers at vtk.org <mailto:vtkusers at vtk.org>
>>> *Subject: **Re: [vtkusers] How to generate a surface normal glyph
>>> for a triangle cell*
>>>
>>> Hi Miguel,
>>> Thanks for the tip. It works when I use
>>> vtkPolyDataMapper as shown below. However, you the plane has a
>>> methods that returns the surface normal, which is a single surface
>>> normal. How can I pipe this surface normal data, directly to be
>>> generated as a single glyph?
>>> The spikeF.tcl example code uses vtkMaskPoints to reduce the
>>> number of sampled points for generating the surface normal.
>>>
>>> In my specific case of the plane source, the surface normal is
>>> already available to me. I don't need to use vtkPolyDataMapper to
>>> generate the surface normals. How can I use the existing surface
>>> normal information from the plane source to generate a single
>>> glyph that represents the surface normal?
>>>
>>> If I use vtkPolyDataMapper, it will generate 4 glyphs
>>> corresponding to the surface normals at each of the four vertices
>>> of the plane. I just want to render one glyph corresponding to the
>>> surface normal computed from the central surface of the plane
>>> source.
>>>
>>> Best regards,
>>>
>>> Elvis Dowson
>>> *Example TCL Code:*
>>>
>>> # This example shows how to manually construct a plane and display
>>> its surface normal # using Tcl. #
>>>
>>> package require vtk
>>> package require vtkinteraction
>>>
>>> # Create a plane source
>>> vtkPlaneSource planeSource
>>>
>>> vtkPolyDataNormals planeNormals
>>> planeNormals SetInputConnection [planeSource GetOutputPort]
>>> vtkDataSetMapper planeMapper
>>> planeMapper SetInputConnection [planeNormals GetOutputPort]
>>>
>>> vtkActor planeActor
>>> planeActor SetMapper planeMapper
>>>
>>> # Create an arrow glyph to represent the surface normal
>>> # -----------------------------------------------------
>>>
>>> # Specify the location of the glyph
>>> #vtkPolyData arrowGlyphPolyData
>>> #vtkPoints arrowGlyphPoints
>>> #arrowGlyphPolyData SetPoints arrowGlyphPoints
>>> #arrowGlyphPoints InsertNextPoint 1 1 0
>>> #eval arrowGlyphPoints InsertNextPoint [planeSource GetNormal]
>>>
>>> # Specify the shape of the glyph
>>> vtkArrowSource arrowSource
>>>
>>> vtkGlyph3D arrowGlyph
>>> arrowGlyph ScalingOn
>>> arrowGlyph SetScaleFactor 0.7
>>> arrowGlyph SetVectorModeToUseNormal
>>> arrowGlyph SetScaleModeToScaleByVector
>>> arrowGlyph OrientOn
>>> arrowGlyph SetSourceConnection [arrowSource GetOutputPort]
>>> arrowGlyph SetInputConnection [planeNormals GetOutputPort]
>>>
>>> vtkDataSetMapper arrowGlyphMapper
>>> arrowGlyphMapper SetInputConnection [arrowGlyph GetOutputPort]
>>>
>>> vtkActor glyphActor
>>> glyphActor SetMapper arrowGlyphMapper
>>>
>>>
>>> # Create the usual rendering stuff.
>>> vtkRenderer ren1
>>> vtkRenderWindow renWin
>>> renWin AddRenderer ren1
>>> renWin SetSize 300 150
>>> vtkRenderWindowInteractor iren
>>> iren SetRenderWindow renWin
>>>
>>> #ren1 SetBackground .1 .2 .4
>>>
>>> ren1 AddActor planeActor
>>> ren1 AddActor glyphActor
>>>
>>> ren1 ResetCamera
>>> ren1 ResetCameraClippingRange
>>>
>>> renWin Render
>>>
>>> # render the image
>>> #
>>> iren AddObserver UserEvent {wm deiconify .vtkInteract}
>>> iren Initialize
>>> wm withdraw .
>>>
>>>
>>>
>
> --
> Amy Squillacote Phone: (256) 726-4839
> Computer Scientist Fax: (256) 726-4806
> CFD Research Corporation Web: http://www.cfdrc.com
> 215 Wynn Drive, Suite 501
> Huntsville, AL 35805
>
>
More information about the vtkusers
mailing list