<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I stumbled across a bug using vtkImplicitPlaneWidget by calling
    OutsideBoundsOff() that causes an access violation to occur as soon
    as the widget is enabled.<br>
    <br>
    I traced the code to here:<br>
    <title>Snippet</title>
    <pre style="font-family:Consolas;font-size:13;color:black;background:white;"><span style="color:blue;">
void</span>&nbsp;<span style="color:blue;">vtkImplicitPlaneWidget</span>::<span style="color:#880000;">UpdateRepresentation</span>()
{
&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(&nbsp;!&nbsp;<span style="color:blue;">this</span>-&gt;<span style="color:navy;">CurrentRenderer</span>&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>;
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;<span style="color:blue;">double</span>&nbsp;*<span style="color:navy;">origin</span>&nbsp;=&nbsp;<span style="color:blue;">this</span>-&gt;<span style="color:blue;">Plane</span>-&gt;<span style="color:#880000;">GetOrigin</span>();
&nbsp;&nbsp;<span style="color:blue;">double</span>&nbsp;*<span style="color:navy;">normal</span>&nbsp;=&nbsp;<span style="color:blue;">this</span>-&gt;<span style="color:blue;">Plane</span>-&gt;<span style="color:#880000;">GetNormal</span>();
&nbsp;&nbsp;<span style="color:blue;">double</span>&nbsp;<span style="color:navy;">p2</span>[3];
&nbsp;&nbsp;<span style="color:blue;">if</span>(&nbsp;!<span style="color:blue;">this</span>-&gt;<span style="color:navy;">OutsideBounds</span>&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">double</span>&nbsp;*<span style="color:navy;">bounds</span>&nbsp;=&nbsp;<span style="color:blue;">this</span>-&gt;<span style="color:#880000;">GetInput</span>()-&gt;<span style="color:#880000;">GetBounds</span>();
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">for</span>&nbsp;(<span style="color:blue;">int</span>&nbsp;<span style="color:navy;">i</span>=0;&nbsp;<span style="color:navy;">i</span>&lt;3;&nbsp;<span style="color:navy;">i</span>++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(&nbsp;<span style="color:navy;">origin</span>[<span style="color:navy;">i</span>]&nbsp;&lt;&nbsp;<span style="color:navy;">bounds</span>[2*<span style="color:navy;">i</span>]&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
...

</pre>
    It crashes because the widget is blindly getting the bounds of it's
    input that was never set. So the access violation happens in the
    call to GetBounds(). According to the documentation in vtk3DWidget:<br>
    <title>Snippet</title>
    <pre style="font-family:Consolas;font-size:13;color:black;background:white;">
&nbsp; <span style="color:green;">//&nbsp;Description:</span>
&nbsp;&nbsp;<span style="color:green;">//&nbsp;Specify&nbsp;the&nbsp;input&nbsp;dataset.&nbsp;This&nbsp;is&nbsp;not&nbsp;required,&nbsp;but&nbsp;if&nbsp;supplied,</span>
&nbsp;&nbsp;<span style="color:green;">//&nbsp;and&nbsp;no&nbsp;vtkProp3D&nbsp;is&nbsp;specified,&nbsp;it&nbsp;is&nbsp;used&nbsp;to&nbsp;initially&nbsp;position&nbsp;</span>
&nbsp;&nbsp;<span style="color:green;">//&nbsp;the&nbsp;widget.</span>
&nbsp;&nbsp;<span style="color:blue;">virtual</span>&nbsp;<span style="color:blue;">void</span>&nbsp;<span style="color:#880000;">SetInput</span>(<span style="color:blue;">vtkDataSet</span>*);
&nbsp;&nbsp;<span style="color:#a000a0;">vtkGetObjectMacro</span>(<span style="color:navy;">Input</span>,<span style="color:blue;">vtkDataSet</span>);

</pre>
    So shouldn't the code in UpdateRepresentation() check the return
    value of GetInput() before getting it's bounds?<br>
    In addition, the returned bounds might be NULL or not initialized.<br>
    Perhaps the code should be changed to something like this:<br>
    <pre style="font-family:Consolas;font-size:13;color:black;background:white;">
&nbsp; <span style="color:blue;">if</span>(&nbsp;!<span style="color:blue;">this</span>-&gt;<span style="color:navy;">OutsideBounds</span>&nbsp;)
&nbsp;&nbsp;&nbsp;&nbsp;{
    vtkDataSet *dataset = <span style="color:blue;">this</span>-&gt;<span style="color:#880000;">GetInput</span>();
&nbsp;&nbsp;&nbsp; <span style="color:blue;">double</span>&nbsp;*<span style="color:navy;">bounds</span>&nbsp;= dataset != NULL ? dataset-&gt;<span style="color:#880000;">GetBounds</span>() : NULL;
    if ( bounds != NULL &amp;&amp; vtkMath::AreBoundsInitialized(bounds) )
&nbsp;&nbsp;&nbsp;&nbsp;  {
        <span style="color:blue;">for</span>&nbsp;(<span style="color:blue;">int</span>&nbsp;<span style="color:navy;">i</span>=0;&nbsp;<span style="color:navy;">i</span>&lt;3;&nbsp;<span style="color:navy;">i</span>++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {
... 
</pre>
    <br>
    Question #1: Has anyone else seen this before?<br>
    Question #2: Can anyone else corroborate?<br>
    Question #3: Can a contributor make this (or an equivalent) fix? :-)<br>
    <br>
    I don't particularly need this for my application, but I thought
    that I'd report the problem to the group in the hopes that it gets
    fixed and for posterity in case someone searches for this in the
    future.<br>
    <div class="moz-signature">-- <br>
      <meta http-equiv="content-type" content="text/html;
        charset=ISO-8859-1">
      <title>Signature</title>
      <a href="http:://www.infolytica.com">www.infolytica.com </a><br>
      300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
      (514) 849-8752 x236, Fax: (514) 849-4239
    </div>
  </body>
</html>