[vtkusers] Clip volume data

Jose Ignacio Prieto joseignacio.prieto at gmail.com
Thu Aug 22 14:06:55 EDT 2013


Hi, could you make it? I have not been able. I don't know what's wrong. The
box moves independently from the vtkvolume it is supposed to clip. Here is
my code

CALLBACK:
class vtkBoxCallback : public vtkCommand
{

public:
    static vtkBoxCallback *New()
    {
        return new vtkBoxCallback;
    }

    virtual void SetVolume(vtkVolume * vol)
    {
        volumen = vol;
    }


    void SetInteractor(vtkRenderWindowInteractor *interactor)
    {
        this->Interactor=interactor;
    }

    virtual void Execute(vtkObject *caller, unsigned long, void*)
    {
        vtkBoxWidget2 *boxWidget = reinterpret_cast<vtkBoxWidget2*>(caller);
        vtkBoxRepresentation * rep=
vtkBoxRepresentation::SafeDownCast(boxWidget->GetRepresentation());
        rep->GetPlanes(clippingPlanes);
        volumen->GetMapper()->SetClippingPlanes(clippingPlanes);
//        Interactor->Render();

//        volumen->Update();

    }
    vtkBoxCallback(){}
private:
    vtkVolume * volumen;
    vtkPlanes * clippingPlanes;
    vtkRenderWindowInteractor *Interactor;

};


MAIN:


    // Clipping box widget
    boxWidget = vtkBoxWidget2::New();
    boxWidget->SetInteractor(this->ui->qvtkWidget->GetInteractor());
    boxCallback =vtkBoxCallback::New();
    boxCallback->SetVolume(this->volumen[0]);
//    boxCallback->SetInteractor(this->ui->qvtkWidget->GetInteractor());
    boxWidget->AddObserver(vtkCommand::InteractionEvent, boxCallback);
    boxRepresentation = vtkSmartPointer<vtkBoxRepresentation>::New();
    boxWidget->SetRepresentation(boxRepresentation);

    boxWidget->On();





On Wed, Aug 21, 2013 at 11:23 AM, Weiguang Guan <guanw at rhpcs.mcmaster.ca>wrote:

>  Excellent solution! Thanks, Dean.
>
> Weiguang
>
>
> On 21/08/2013 9:28 AM, Dean Inglis wrote:
>
>  Hi Weiguang,
>
>  you can use non-axis aligned planes to crop a volume by retrieving the 6
> planes defining
> the box widget in a call back and passing them to your volume mapper:
>
>   vtkBoxWidget2 *self = reinterpret_cast<vtkBoxWidget2*>( caller );
>   vtkBoxRepresentation2* rep =
>       vtkBoxRepresentation2::SafeDownCast( self->GetRepresentation() );
>   rep->GetPlanes( this->Planes );
>   this->Volume->GetMapper()->SetClippingPlanes( this->Planes );
>
>  Dean
>
>
>
> On Tue, Aug 20, 2013 at 2:05 PM, Weiguang Guan <guanw at rhpcs.mcmaster.ca>wrote:
>
>> Hello,
>>
>> 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't be used. Can someone suggest a better solution for what I want to
>> do? Thanks.
>>
>> Best,
>> Weiguang
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
José Ignacio Prieto
celular(nuevo): 94348182
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130822/747e2a7b/attachment.htm>


More information about the vtkusers mailing list