<div dir="ltr"><div><div>Hi, could you make it? I have not been able. I don&#39;t know what&#39;s wrong. The box moves independently from the vtkvolume it is supposed to clip. Here is my code<br><br>CALLBACK:<br>class vtkBoxCallback : public vtkCommand<br>
{<br><br>public:<br>    static vtkBoxCallback *New()<br>    {<br>        return new vtkBoxCallback;<br>    }<br><br>    virtual void SetVolume(vtkVolume * vol)<br>    {<br>        volumen = vol;<br>    }<br><br><br>    void SetInteractor(vtkRenderWindowInteractor *interactor)<br>
    {<br>        this-&gt;Interactor=interactor;<br>    }<br><br>    virtual void Execute(vtkObject *caller, unsigned long, void*)<br>    {<br>        vtkBoxWidget2 *boxWidget = reinterpret_cast&lt;vtkBoxWidget2*&gt;(caller);<br>
        vtkBoxRepresentation * rep= vtkBoxRepresentation::SafeDownCast(boxWidget-&gt;GetRepresentation());<br>        rep-&gt;GetPlanes(clippingPlanes);<br>        volumen-&gt;GetMapper()-&gt;SetClippingPlanes(clippingPlanes);<br>
//        Interactor-&gt;Render();<br><br>//        volumen-&gt;Update();<br><br>    }<br>    vtkBoxCallback(){}<br>private:<br>    vtkVolume * volumen;<br>    vtkPlanes * clippingPlanes;<br>    vtkRenderWindowInteractor *Interactor;<br>
<br>};<br><br><br></div>MAIN:<br><br><br>    // Clipping box widget<br>    boxWidget = vtkBoxWidget2::New();<br>    boxWidget-&gt;SetInteractor(this-&gt;ui-&gt;qvtkWidget-&gt;GetInteractor());<br>    boxCallback =vtkBoxCallback::New();<br>
    boxCallback-&gt;SetVolume(this-&gt;volumen[0]);<br>//    boxCallback-&gt;SetInteractor(this-&gt;ui-&gt;qvtkWidget-&gt;GetInteractor());<br>    boxWidget-&gt;AddObserver(vtkCommand::InteractionEvent, boxCallback);<br>    boxRepresentation = vtkSmartPointer&lt;vtkBoxRepresentation&gt;::New();<br>
    boxWidget-&gt;SetRepresentation(boxRepresentation);<br><br>    boxWidget-&gt;On();<br><br><br></div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 21, 2013 at 11:23 AM, Weiguang Guan <span dir="ltr">&lt;<a href="mailto:guanw@rhpcs.mcmaster.ca" target="_blank">guanw@rhpcs.mcmaster.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Excellent solution! Thanks, Dean.<span class="HOEnZb"><font color="#888888"><br>
      <br>
      Weiguang</font></span><div><div class="h5"><br>
      <br>
      On 21/08/2013 9:28 AM, Dean Inglis wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">
        <div>
          <div>Hi Weiguang,<br>
            <br>
          </div>
          you can use non-axis aligned planes to crop a volume by
          retrieving the 6 planes defining<br>
          the box widget in a call back and passing them to your volume
          mapper:<br>
          <br>
            vtkBoxWidget2 *self =
          reinterpret_cast&lt;vtkBoxWidget2*&gt;( caller );<br>
            vtkBoxRepresentation2* rep =<br>
                vtkBoxRepresentation2::SafeDownCast(
          self-&gt;GetRepresentation() );<br>
            rep-&gt;GetPlanes( this-&gt;Planes );<br>
            this-&gt;Volume-&gt;GetMapper()-&gt;SetClippingPlanes(
          this-&gt;Planes );<br>
          <br>
        </div>
        Dean <br>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Tue, Aug 20, 2013 at 2:05 PM,
          Weiguang Guan <span dir="ltr">&lt;<a href="mailto:guanw@rhpcs.mcmaster.ca" target="_blank">guanw@rhpcs.mcmaster.ca</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
            <br>
            I have a volume data of vtkImageData type, and would like to
            do volume rendering of a portion of it, specified by a
            vtkBoxWidget. The box widget is rotation enabled so that the
            region of interest may not align with x-y-z axes. I hesitate
            to use vtkClipVolume because it would change the data to
            unstructured gird data and the fast texture-mapping based
            volume rendering couldn&#39;t be used. Can someone suggest a
            better solution for what I want to do? Thanks.<br>
            <br>
            Best,<br>
            Weiguang<br>
            _______________________________________________<br>
            Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
            <br>
            Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
            <br>
            Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
            <br>
            Follow this link to subscribe/unsubscribe:<br>
            <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>José Ignacio Prieto<br>celular(nuevo): 94348182
</div>