<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1670790460;
        mso-list-type:hybrid;
        mso-list-template-ids:-364743752 67567631 67567641 67567643 67567631 67567641 67567643 67567631 67567641 67567643;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi everyone,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I’m trying to compute and render normals of certain vertices of a mesh (in fact a Kinect mesh). I assume that I have to compute the normals via vtkPolyDataNormals and display them using a vtkGlyph3d? <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I observed some strange behavior which really confused me:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US>If I create a vtkPlaneSource or load a ball from hard disc and compute normals for that data, everything seems fine. If I load an “open” surface (my Kinect mesh), there are no normals displayed. The documentation says that SetAutoOrientNormals does only work with closed surfaces. But at the moment I don’t care about orientation. There should be normals for at least some vertices of an open mesh, shouldn’t there?<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US>If I load my Kinect mesh and make a new polydata which contains as much points at (0,0,0) as I have normals and set the normals for the new polydata, the glyph will produce arrows pointing from (0,0,0) to somewhere. This looks pretty good could but could be a random result with empty memory. <o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US>If I connect my vtkPlaneSource or the ball directly to the glyph (I skip the vtkPolyDataNormals), normals are still rendered correctly. Does this mean my vtkPlaneSource already contains them from the beginning? Are they computed in the background somewhere inside the glyph3d? Is the vtkPolyDataNormals even necessary? This only works for the plane and the ball - not for the Kinect mesh. I can imagine that a plane automatically computes its normal on Update(), but why does my ball have normals already?<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US><span style='mso-list:Ignore'>4.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US>How can I get the normal of a certain vertex Id? If I use vtkFloatArray::SafeDownCast(output->GetPointData()->GetNormals()) are Id’s equal to the vertex Id’s of the polydata? What happens if I turn splitting on and get multiple normals for each vertex? How is the mapping done?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>My code looks as follows:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>vtkSmartPointer<vtkPolyData> inputPolyData = //load some data<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> // Generate normals<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> vtkSmartPointer<vtkPolyDataNormals> normalGenerator = vtkSmartPointer<vtkPolyDataNormals>::New();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> normalGenerator->SetInput( inputPolyData );<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> normalGenerator->ComputePointNormalsOn();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> </span>normalGenerator->ComputeCellNormalsOff();<o:p></o:p></p><p class=MsoNormal><span lang=EN-US> normalGenerator->SetSplitting(0); //I want exactly one normal per vertex<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> normalGenerator->Update();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> </span>vtkSmartPointer<vtkPolyDataMapper> mapperNormals =<o:p></o:p></p><p class=MsoNormal> <span lang=EN-US>vtkSmartPointer<vtkPolyDataMapper>::New();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> //I chose arrows as representation<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> vtkSmartPointer<vtkArrowSource> arrow = vtkSmartPointer<vtkArrowSource>::New();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> arrow->Update();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//use the output of vtkPolyDataNormals as input for the glyph3d<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>vtkSmartPointer<vtkGlyph3D> glyph = vtkSmartPointer<vtkMaskedGlyph3D>::New();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> glyph->SetInput( normalGenerator->GetOutput() );<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> glyph->SetSourceConnection(arrow->GetOutputPort());<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> glyph->OrientOn();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> glyph->SetVectorModeToUseNormal();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> glyph->Update();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> mapperNormals->SetInputConnection(glyph->GetOutputPort());<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>//now follows standard code which could be taken from almost any example…<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> vtkSmartPointer<vtkActor> actorNormals =<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> vtkSmartPointer<vtkActor>::New();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> actorNormals->SetMapper(mapperNormals);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> // Create a renderer, render window, and interactor<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> </span>vtkSmartPointer<vtkRenderer> renderer =<o:p></o:p></p><p class=MsoNormal> vtkSmartPointer<vtkRenderer>::New();<o:p></o:p></p><p class=MsoNormal> vtkSmartPointer<vtkRenderWindow> renderWindow =<o:p></o:p></p><p class=MsoNormal> vtkSmartPointer<vtkRenderWindow>::New();<o:p></o:p></p><p class=MsoNormal> renderWindow->AddRenderer(renderer);<o:p></o:p></p><p class=MsoNormal> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<o:p></o:p></p><p class=MsoNormal> vtkSmartPointer<vtkRenderWindowInteractor>::New();<o:p></o:p></p><p class=MsoNormal> <span lang=EN-US>vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> renderWindowInteractor->SetInteractorStyle(style);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> renderWindowInteractor->SetRenderWindow(renderWindow);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> // Add the actor to the scene<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> renderer->AddActor(actorNormals);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US> // Render and interact<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> renderWindow->Render();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> renderWindowInteractor->Start();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thomas<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:DE'>Thomas Kilgus<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:DE'>German Cancer Research Center (DKFZ)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:DE'>Div. Medical and Biological Informatics <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:DE'>Junior group: Computer-assisted Interventions (E131)<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:DE'>Im Neuenheimer Feld 280<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:DE'>69120 Heidelberg, Germany<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:DE'>Phone: +49(0) 6221-42-3545<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>