Hey all,<br><br>   So I am experiencing an interesting error that I can not figure out. I am storing some data in some arrays and I am then printing out the average of those arrays by the following bit of code:<br> <br>       //this Sum array is in-bedded in a set of for loops where the iterators are i and n to fill it full of data<br>
       Sum[3] = 0;<br>       Average[3] = 0;<br>       Sum[0] += Angle-&gt;GetValue(i + (5*n) );<br>       Sum[1] += EdgeLength-&gt;GetValue( i + (5*n) );<br>       Sum[2] += EdgeLength_Horizontal-&gt;GetValue( i + (5*n) );<br>
       Sum[3] += EdgeLength_Vertical-&gt;GetValue( i + (5*n ) );<br><br>      //Once the Sum array is filled with data and the for loops are closed, this bit of code is enabled<br>      std::cout &lt;&lt; &quot;Average Angle: &quot; &lt;&lt; Sum[0] / <br>
                         (Output-&gt;GetNumberOfPoints() * 5) &lt;&lt; endl <br>                    &lt;&lt; &quot;Average Edge Length: &quot; &lt;&lt;  Sum[1] /<br>                         ( Output-&gt;GetNumberOfPoints() * 5 ) &lt;&lt; endl<br>
                    &lt;&lt; &quot;Average Horizontal Component of Edge Length: &quot; &lt;&lt; Sum[2] /<br>                         ( Output-&gt;GetNumberOfPoints() * 5 ) &lt;&lt; endl<br>                    &lt;&lt; &quot;Average Vertical Component of Edge Length: &quot; &lt;&lt; Sum[3] /<br>
                         ( Output-&gt;GetNumberOfPoints() * 5 ) &lt;&lt; endl &lt;&lt; endl;<br><br>What I am expericing is that when I add a renderer for a completely different set of arrays other than these Sum and Average arrays, the average values that are printed out onto my screen are changed to ridiculous numbers. When I uncomment out this bit of code, the average values that get printed out change from the values they should be to e^23 and -nan on two of the average values. Here is the bit of code that is causing me problems:<br>
<br>      vtkSmartPointer&lt;vtkFieldData&gt; Field1 =<br>    vtkSmartPointer&lt;vtkFieldData&gt;::New();<br>      vtkSmartPointer&lt;vtkFieldData&gt; Field2 =<br>    vtkSmartPointer&lt;vtkFieldData&gt;::New();<br>      vtkSmartPointer&lt;vtkFieldData&gt; Field3 =<br>
    vtkSmartPointer&lt;vtkFieldData&gt;::New();<br>      vtkSmartPointer&lt;vtkFieldData&gt; Field4 =<br>    vtkSmartPointer&lt;vtkFieldData&gt;::New();<br>      Field1-&gt;AddArray( AngleDecimated );<br>      Field2-&gt;AddArray( EdgeLengthDecimated );<br>
      Field3-&gt;AddArray( EdgeLengthHDecimated );<br>      Field4-&gt;AddArray( EdgeLengthVDecimated );<br>      <br>      vtkSmartPointer&lt;vtkDataObject&gt; DataObject1 = <br>        vtkSmartPointer&lt;vtkDataObject&gt;::New();<br>
      vtkSmartPointer&lt;vtkDataObject&gt; DataObject2 = <br>        vtkSmartPointer&lt;vtkDataObject&gt;::New();<br>      vtkSmartPointer&lt;vtkDataObject&gt; DataObject3 = <br>        vtkSmartPointer&lt;vtkDataObject&gt;::New();<br>
      vtkSmartPointer&lt;vtkDataObject&gt; DataObject4 = <br>        vtkSmartPointer&lt;vtkDataObject&gt;::New();<br>      DataObject1-&gt;SetFieldData( Field1 );<br>      DataObject2-&gt;SetFieldData( Field2 );<br>      DataObject3-&gt;SetFieldData( Field3 );<br>
      DataObject4-&gt;SetFieldData( Field4 );<br><br>      vtkSmartPointer&lt;vtkXYPlotActor&gt; Plot1 =<br>    vtkSmartPointer&lt;vtkXYPlotActor&gt;::New();<br>      vtkSmartPointer&lt;vtkXYPlotActor&gt; Plot2 =<br>    vtkSmartPointer&lt;vtkXYPlotActor&gt;::New();<br>
      vtkSmartPointer&lt;vtkXYPlotActor&gt; Plot3 =<br>    vtkSmartPointer&lt;vtkXYPlotActor&gt;::New();<br>      vtkSmartPointer&lt;vtkXYPlotActor&gt; Plot4 =<br>    vtkSmartPointer&lt;vtkXYPlotActor&gt;::New();<br>       Plot1-&gt;ExchangeAxesOff();<br>
       Plot1-&gt;SetLabelFormat( &quot;%g&quot; );<br>       Plot1-&gt;SetXTitle( &quot;Id Number&quot; );<br>       Plot1-&gt;SetYTitle( &quot;Angle&quot; );<br>       Plot1-&gt;SetXValuesToIndex();<br>       Plot1-&gt;AddDataObjectInput( DataObject1 );<br>
       Plot1-&gt;SetPlotColor(0,1,1,1);<br>       Plot2-&gt;ExchangeAxesOff();<br>       Plot2-&gt;SetLabelFormat( &quot;%g&quot; );<br>       Plot2-&gt;SetXTitle( &quot;Id Number&quot; );<br>       Plot2-&gt;SetYTitle( &quot;Edge Length&quot; );<br>
       Plot2-&gt;SetXValuesToIndex();<br>       Plot2-&gt;AddDataObjectInput( DataObject2 );<br>       Plot2-&gt;SetPlotColor(0,1,1,1);<br>       Plot3-&gt;ExchangeAxesOff();<br>       Plot3-&gt;SetLabelFormat( &quot;%g&quot; );<br>
       Plot3-&gt;SetXTitle( &quot;Id Number&quot; );<br>       Plot3-&gt;SetYTitle( &quot;H. Compon.&quot; );<br>       Plot3-&gt;SetXValuesToIndex();<br>       Plot3-&gt;AddDataObjectInput( DataObject3 );<br>       Plot3-&gt;SetPlotColor(0,1,1,1);<br>
       Plot4-&gt;ExchangeAxesOff();<br>       Plot4-&gt;SetLabelFormat( &quot;%g&quot; );<br>       Plot4-&gt;SetXTitle( &quot;Id Number&quot; );<br>       Plot4-&gt;SetYTitle( &quot;V. Compon&quot; );<br>       Plot4-&gt;SetXValuesToIndex();<br>
       Plot4-&gt;AddDataObjectInput( DataObject4 );<br>       Plot4-&gt;SetPlotColor(0,1,1,1);<br>       <br>       double UpperLeftViewport[4] = { 0.0,0.5,0.5,1.0 };<br>       double UpperRightViewport[4] = { 0.5,0.5,1.0,1.0 };<br>
       double LowerLeftViewport[4] = { 0.0,0.0,0.5,0.5 };<br>       double LowerRightViewport[4] = { 0.5,0.0,1.0,0.5 };<br>       <br>      // Visualize the histogram(s)<br>      vtkSmartPointer&lt;vtkRenderer&gt; UpperLeftRenderer = <br>
        vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>      vtkSmartPointer&lt;vtkRenderer&gt; UpperRightRenderer = <br>        vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>      vtkSmartPointer&lt;vtkRenderer&gt; LowerLeftRenderer = <br>
        vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>      vtkSmartPointer&lt;vtkRenderer&gt; LowerRightRenderer = <br>        vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>      UpperLeftRenderer-&gt;AddActor( Plot1 );<br>
      UpperLeftRenderer-&gt;SetViewport( UpperLeftViewport );<br>      UpperLeftRenderer-&gt;SetBackground( 0.1,0.2,0.3 );<br>      UpperLeftRenderer-&gt;ResetCamera();<br>      UpperRightRenderer-&gt;AddActor( Plot2 );<br>
      UpperRightRenderer-&gt;SetViewport( UpperRightViewport );<br>      UpperRightRenderer-&gt;SetBackground( 0.1,0.2,0.3 );<br>      UpperRightRenderer-&gt;ResetCamera();<br>      LowerLeftRenderer-&gt;AddActor( Plot3 );<br>
      LowerLeftRenderer-&gt;SetViewport( LowerLeftViewport );<br>      LowerLeftRenderer-&gt;SetBackground( 0.1,0.2,0.3 );<br>      LowerLeftRenderer-&gt;ResetCamera();<br>      LowerRightRenderer-&gt;AddActor( Plot1 );<br>
      LowerRightRenderer-&gt;SetViewport( LowerRightViewport );<br>      LowerRightRenderer-&gt;SetBackground( 0.1,0.2,0.3 );<br>      LowerRightRenderer-&gt;ResetCamera();<br>      <br>      vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow = <br>
        vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<br>      renderWindow-&gt;AddRenderer( UpperLeftRenderer );<br>      renderWindow-&gt;AddRenderer( UpperRightRenderer );<br>      renderWindow-&gt;AddRenderer( LowerLeftRenderer );<br>
      renderWindow-&gt;AddRenderer( LowerRightRenderer );<br>      renderWindow-&gt;SetSize( 800,600 );<br> <br>      vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; interactor =<br>        vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<br>
      interactor-&gt;SetRenderWindow( renderWindow );<br> <br>      // Initialize the event loop and then start it<br>      interactor-&gt;Initialize();<br>      interactor-&gt;Start();<br><br><br>So nowhere in this bit of code do I do any operations to the Sum or Average arrays but yet somehow this bit of code can alter the average values printed out? Another odd thing is that the Average and Sum arrays come before the whole rendering process I mentioned. So by my understanding is that anything behind where I print out the average values should not have an effect on the values but yet somehow it is...here are the values with the rendering code I have shown above commented out :<br>
<br>Average Angle: 0.646263<br>Average Edge Length: 0.525874<br>Average Horizontal Component of Edge Length: 0.400365<br>Average Vertical Component of Edge Length: 3.83892e-05<br><br><br>and here are the values when I uncomment out the above section of code:<br>
<br>Average Angle: -8.68697e+24<br>Average Edge Length: 0.525874<br>Average Horizontal Component of Edge Length: -nan<br>Average Vertical Component of Edge Length: 3.83892e-05<br><br><br>I am thinking that the /vtkXYPlotActor might have a bug in it like many of the other chart and plotting actors that is causing this but that is just a gut feeling. If anyone has any thoughts on this matter, please share them with me and the community.<br>
Thanks,<br>Luke H<br>