<meta http-equiv="content-type" content="text/html; charset=utf-8"><div>On Wed, Apr 14, 2010 at 9:37 PM, Erkang Cheng <span dir="ltr">&lt;<a href="mailto:ekyaya@gmail.com">ekyaya@gmail.com</a>&gt;</span> wrote:</div><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi all:<br><br>I have a question about drawing a line. <br>Actually, I want to draw a line in display window. But when I change these two points, the line doesn&#39;t looks correct.<br>
I follow the example :<br><br><pre><font style="font-family:arial,helvetica,sans-serif" size="2"><span>//create two points, P0 and P1</span><br>  <span>double</span> p0<span>[</span><span>3</span><span>]</span> <span>=</span> <span>{</span><span>1.0</span>, <span>0.0</span>, <span>0.0</span><span>}</span><span>;</span><br>

  <span>double</span> p1<span>[</span><span>3</span><span>]</span> <span>=</span> <span>{</span><span>0.0</span>, <span>1.0</span>, <span>0.0</span><span>}</span><span>;</span><br>
 <br>  vtkSmartPointer<span>&lt;</span>vtkLineSource<span>&gt;</span> lineSource <span>=</span> <br>      vtkSmartPointer<span>&lt;</span>vtkLineSource<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span><br>

  lineSource<span>-</span><span>&gt;</span>SetPoint1<span>(</span>p0<span>)</span><span>;</span><br>  lineSource<span>-</span><span>&gt;</span>SetPoint2<span>(</span>p1<span>)</span><span>;</span><br>
  lineSource<span>-</span><span>&gt;</span>Update<span>(</span><span>)</span><span>;</span><br> <br>  <span>//Create a mapper and actor</span><br>  vtkSmartPointer<span>&lt;</span>vtkPolyDataMapper<span>&gt;</span> mapper <span>=</span> <br>

      vtkSmartPointer<span>&lt;</span>vtkPolyDataMapper<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span><br>
  mapper<span>-</span><span>&gt;</span>SetInputConnection<span>(</span>lineSource<span>-</span><span>&gt;</span>GetOutputPort<span>(</span><span>)</span><span>)</span><span>;</span><br>
  vtkSmartPointer<span>&lt;</span>vtkActor<span>&gt;</span> actor <span>=</span> <br>      vtkSmartPointer<span>&lt;</span>vtkActor<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span><br>

  actor<span>-</span><span>&gt;</span>SetMapper<span>(</span>mapper<span>)</span><span>;</span><br> <br>  <span>//Create a renderer, render window, and interactor</span><br>
  vtkSmartPointer<span>&lt;</span>vtkRenderer<span>&gt;</span> renderer <span>=</span> <br>      vtkSmartPointer<span>&lt;</span>vtkRenderer<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span><br>

  vtkSmartPointer<span>&lt;</span>vtkRenderWindow<span>&gt;</span> renderWindow <span>=</span> <br>      vtkSmartPointer<span>&lt;</span>vtkRenderWindow<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span><br>

  renderWindow<span>-</span><span>&gt;</span>AddRenderer<span>(</span>renderer<span>)</span><span>;</span><br>  vtkSmartPointer<span>&lt;</span>vtkRenderWindowInteractor<span>&gt;</span> renderWindowInteractor <span>=</span> <br>

      vtkSmartPointer<span>&lt;</span>vtkRenderWindowInteractor<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span><br>
  renderWindowInteractor<span>-</span><span>&gt;</span>SetRenderWindow<span>(</span>renderWindow<span>)</span><span>;</span><br> <br>  <span>//Add the actor to the scene</span><br>
  renderer<span>-</span><span>&gt;</span>AddActor<span>(</span>actor<span>)</span><span>;</span><br> <br>  <span>//Render and interact</span><br>  renderWindow<span>-</span><span>&gt;</span>Render<span>(</span><span>)</span><span>;</span><br>

  renderWindowInteractor<span>-</span><span>&gt;</span>Start<span>(</span><span>)</span><span>;</span></font><br><br><font style="font-family:times new roman,serif" size="2"><b>But, when I change these two points as</b></font><br>

<br><font><font style="font-family:arial,helvetica,sans-serif" size="2"><span>double</span> p0<span>[</span><span>3</span><span>]</span> <span>=</span> <span>{</span><span>10.0</span>, <span>0.0</span>, <span>0.0</span><span>}</span><span>;</span><br>

  <span>double</span> p1<span>[</span><span>3</span><span>]</span> <span>=</span> <span>{</span><span>0.0</span>, <span>10.0</span>, <span>0.0</span><span>}</span><span>;</span></font></font><br>
<br><font style="font-family:times new roman,serif" size="2">The line doesn&#39;t change. <br><br>Could Anyone tell me what&#39;s the problem?<br>I want to draw a line in display coordinate.<br><br>Thanks<br>Best<br>Erkang</font><br>
</pre><pre><font style="font-family:times new roman,serif" size="2"><br></font></pre></blockquote>Erkang,</div><div class="gmail_quote"><br></div><div class="gmail_quote">The camera is automatically reset to &quot;fit&quot; the scene in the render window. If you want those two lines to appear different, you&#39;ll have to control the camera yourself:</div>
<div class="gmail_quote"><font class="Apple-style-span" color="#000000"><a href="http://www.vtk.org/Wiki/VTK/Examples/vtkCamera"><br class="Apple-interchange-newline"></a></font><a href="http://www.vtk.org/Wiki/VTK/Examples/vtkCamera">http://www.vtk.org/Wiki/VTK/Examples/vtkCamera</a></div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Add another object (say a sphere with radius 1) to the scene to convince yourself of what is happening. (You will see that the sphere is the same size as the line in your first example, but much smaller than the line in your second example)</div>
<div class="gmail_quote"><a href="http://www.vtk.org/Wiki/VTK/Examples/vtkCamera"></a><br clear="all">Thanks,<br><br>David</div>