[vtkusers] SetAbortCheckMethod in VC++ doesn´t work!!!
Lisa Sobierajski Avila
lisa.avila at kitware.com
Thu Nov 29 23:26:08 EST 2001
Hello Jose,
Can you break on:
vis->GetParent())->SetAbortRender(1);
to be certain that your abort check method is being called, and that you
are finding an event to cause the render to abort?
Lisa
At 05:58 AM 11/28/2001, Jose Manjon wrote:
>Hi there,
>
>I am trying to use SetAbortCheckMethod() in VC++ but no way.
>
>program runs OK but I can not interact with volume in any time until last
>LOD is acheived (SetAbortCheckMethod doesn´t works)
>
>has anyone experience with this problem???
>
>how can I do it????
>
>jose
>
>The code is this:
>
>// Cheching abort
>
>void CheckAbort(void *arg)
>{
> C3DView * vis=(C3DView *)arg;
> int foo=((vtkRenderWindow*) vis->GetParent())->GetEventPending();
> if(foo!=0) ((vtkRenderWindow*) vis->GetParent())->SetAbortRender(1);
>}
>
>// Setting abortmethod and displaying data
>
>void C3DView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
>{
> C3DDoc *doc = (C3DDoc *) GetDocument();
> CXSEGDoc * pDoc=doc->pDoc;
>
> if(data==NULL)
> {
> CChildFrame *ven=(CChildFrame *)GetParentFrame();
> ven->m_estado.ShowWindow(SW_HIDE);
> ven->SetWindowPos(NULL, 0, 0,500,500,SWP_NOMOVE | SWP_NOZORDER);
>
> // leo los datos
>
> double factor=1;
> if(doc->subsampling) factor=0.5;
>
> data=vtkStructuredPoints::New();
>
>data->SetDimensions(pDoc->m_ani[0].Rows*factor,pDoc->m_ani[0].Columns*factor,pDoc->fuentes*doc->resz*factor);
> data->SetScalarType(VTK_UNSIGNED_SHORT);
> data->SetNumberOfScalarComponents(1);
> data->AllocateScalars();
>
> unsigned short * ptr=(unsigned short *) data->GetScalarPointer();
>
> int inc=1/factor;
> int ima=(factor==0.5 && pDoc->fuentes%2!=0)?pDoc->fuentes-1:pDoc->fuentes;
>
> for(int i=0;i<ima*doc->resz;i+=inc)
> for(int y=0;y<pDoc->m_ani[0].Columns;y+=inc)
> for(int x=0;x<pDoc->m_ani[0].Rows;x+=inc)
> {
> if(doc->objeto==0) *ptr++ =
> pDoc->m_ani[i/doc->resz].Bitmap[y*pDoc->m_ani[0].Rows+x];
> if(doc->objeto==1)
> {
>
>if(pDoc->m_ani[i/doc->resz].Mascara[y*pDoc->m_ani[0].Rows+x]>=1) *ptr++ =
>pDoc->m_ani[i/doc->resz].Bitmap[y*pDoc->m_ani[0].Rows+x];
> else *ptr++ =0;
> }
> if(doc->objeto==2)
> {
>
>if(pDoc->m_ani[i/doc->resz].Mascara[y*pDoc->m_ani[0].Rows+x]==0) *ptr++ =
>pDoc->m_ani[i/doc->resz].Bitmap[y*pDoc->m_ani[0].Rows+x];
> else *ptr++ =0;
> }
> }
>
> plano=vtkPlane::New();
>
>plano->SetOrigin(factor*pDoc->m_ani[0].Columns/2,factor*pDoc->m_ani[0].Rows/2,factor*pDoc->fuentes/2);
> plano->SetNormal(0,0,-1);
>
> ancho=factor*pDoc->m_ani[0].Columns;
> alto=factor*pDoc->m_ani[0].Rows;
> fuentes=factor*pDoc->fuentes;
>
> // creo el modelo
>
> volumeLOD=vtkLODProp3D::New();
>
> // Create a transfer function mapping scalar value to opacity
> vtkPiecewiseFunction *opacity = vtkPiecewiseFunction::New();
> opacity->AddPoint(30.0,0.0);
> opacity->AddPoint(255,1.0);
>
> vtkColorTransferFunction
> *colorTransferFunction=vtkColorTransferFunction::New();
> if(doc->color==1)
> {
> colorTransferFunction->AddRGBPoint(0.0,0.0,0.0,0.0);
> colorTransferFunction->AddRGBPoint(255.0,1.0,1.0,1.0);
> }
> else
> {
> colorTransferFunction->AddRGBPoint(0.0,0.0,0.0,0.0);
> colorTransferFunction->AddRGBPoint(30.0,0.0,0.0,0.0);
> colorTransferFunction->AddRGBPoint(60.0,0.7,0.5,0.0);
> colorTransferFunction->AddRGBPoint(255.0,1.0,1.0,1.0);
> }
>
> // Create a property for the volume and set the transfer functions.
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> volumeProperty->SetColor(colorTransferFunction);
> volumeProperty->SetScalarOpacity(opacity);
>
> // LOD Level of detail
>
> vtkImageResample *resampler1=vtkImageResample::New();
> resampler1->SetInput(data);
> resampler1->SetAxisMagnificationFactor(0,0.2);
> resampler1->SetAxisMagnificationFactor(1,0.2);
> resampler1->SetAxisMagnificationFactor(2,0.2);
>
> vtkImageResample *resampler2=vtkImageResample::New();
> resampler2->SetInput(data);
> resampler2->SetAxisMagnificationFactor(0,0.6);
> resampler2->SetAxisMagnificationFactor(1,0.6);
> resampler2->SetAxisMagnificationFactor(2,0.6);
>
> lowresMapper=vtkVolumeTextureMapper2D::New();
> lowresMapper->SetInput(resampler1->GetOutput());
>
> medresMapper=vtkVolumeTextureMapper2D::New();
> medresMapper->SetInput(resampler2->GetOutput());
>
> hiresMapper=vtkVolumeTextureMapper2D::New();
> hiresMapper->SetInput(data);
>
> // LOD
>
> id1=volumeLOD->AddLOD(lowresMapper,volumeProperty,0.0);
> id2=volumeLOD->AddLOD(medresMapper,volumeProperty,0.0);
> id3=volumeLOD->AddLOD(hiresMapper,volumeProperty,0.0);
>
> // check method
>
>
>
> ((vtkRenderWindow*)GetParent())->SetAbortCheckMethod(CheckAbort,this);
>
>
>
> // añado el modelo a la ventana
>
> this->Renderer->AddProp(volumeLOD);
> this->Renderer->ResetCamera();
> }
>
> this->vtkMFCRenderView::OnUpdate(pSender, lHint, pHint);
>}
>
>----------------------------------------------------------
>Jose Vicente Manjón Herrera
>GIM (Group of Medical Informatics)
>Applied Physics Department
>Technical University of Valencia
>46022 Valencia (SPAIN)
>----------------------------------------------------------
>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list