[vtkusers] How to create vtkActor2D from vtkContourFilter?

Luca Penasa luca.penasa at email.it
Thu Apr 8 10:55:01 EDT 2010


Il giorno gio, 08/04/2010 alle 17.49 +0400, Andrej Gluhov ha scritto:
> Hi, Eric.
> 
> Thanks for the response. "Images from vtkActor2D gets under 2D images"
> is a mistake. Of course, I meant vtkActor. The problem is that the
> contour is not visible when displaying, but if you stretch the window
> and then vtkActor2D remains in the lower left corner, and the Contours
> can be seen in the background (under vtkActor2D). I tried to change
> the position of the coordinate Z, but it does not yield results.
> vtkActor2D has only x,y coordinates.
> And the window I create in order to then attach vtkImageViewer2 in
> WindowsForm.
> 
> 8 апреля 2010 г. 17:16 пользователь Eric E. Monson
> <emonson at cs.duke.edu> написал:
>         Hey Andrej,
>         
>         I'm trying to understand your problem, but I'm not sure
>         exactly what you mean by "Images from vtkActor2D gets under 2D
>         images". If the problem is that your images show up in front
>         of your contour lines so that the contours are hidden, you can
>         use something like:
>         
>         actor.SetPosition(0, 0, 0.01);
>         
>         to move the contours out in front of the image, and not have
>         to change the polydata into imagedata.
>         
>         Also, you seem to be trying to create a vtkRenderWindow at the
>         beginning of your code but you are using the vtkImageViewer2
>         later. If you want to view all of your objects in one window,
>         you can use just one or the other (ImageViewer2 creates a
>         render window for you).
>         
>         If this doesn't address your problem, be sure to try again to
>         clarify the trouble you're having and I'm sure someone can
>         help.
>         
>         Talk to you later,
>         -Eric
>         
>         ------------------------------------------------------
>         Eric E Monson
>         Duke Visualization Technology Group
>         
>         
>         
>         On Apr 8, 2010, at 3:17 AM, Andrej Gluhov wrote:
>         
>         > Hi.
>         > I have this problem of combining vtkActor and vtkActor2D for
>         vtkImageViewer2D. Images from vtkActor2D gets under 2D images.
>         I understand that the problem is converting vtkPolyData to
>         vtkImageData, I could use vtkImageData, but do not know how to
>         create it on the contour points.
>         >
>         >             //Create the RenderWindow, Renderer and
>         RenderWindowInteractor
>         >             vtkRenderer ren1 = new vtkRenderer();
>         >             vtkRenderWindow renWin =
>         reWin.GetRenderWindow();
>         >             renWin.AddRenderer(ren1);
>         >             vtkRenderWindowInteractor iren = new
>         vtkRenderWindowInteractor();
>         >             iren.SetRenderWindow(renWin);
>         >
>         >             vtkDICOMImageReader DicomReader = new
>         vtkDICOMImageReader();
>         >             DicomReader.SetFileName(m_strFilePath);
>         >             DicomReader.Update();
>         >
>         >             vtkImageMapper DicomMapper = new
>         vtkImageMapper();
>         >
>         DicomMapper.SetInputConnection(DicomReader.GetOutputPort());
>         >             DicomMapper.SetColorWindow(255.0);
>         >             DicomMapper.SetColorLevel(127.5);
>         >
>         >             vtkActor2D DicomActor = new vtkActor2D();
>         >             DicomActor.SetMapper(DicomMapper);
>         >
>         >             vtkImageData vol = new vtkImageData();
>         >             vol.SetDimensions(512, 512, 1);
>         >             vol.SetSpacing(1, 1, 1);
>         >             vol.SetOrigin(0, 0, 0);
>         >             vol.SetScalarTypeToFloat();
>         >             vol.AllocateScalars();
>         >
>         >             vtkFloatArray scalars = new vtkFloatArray();
>         >             for (int i = 0; i < 512; i++)
>         >             {
>         >                 for (int j = 0; j < 512; j++)
>         >                 {
>         >                     scalars.InsertTuple1(i * 512 + j,
>         m_DoseMap[i * 512 + j]);
>         >                 }
>         >             }
>         >
>         >             vol.GetPointData().SetScalars(scalars);
>         >             vol.Update();
>         >
>         >             double[] DoseRange = vol.GetScalarRange();
>         >
>         >             vtkLookupTable LUT = new vtkLookupTable();
>         >             LUT.SetTableRange(DoseRange[0],
>         DoseRange[1]);//min dose,max dose
>         >             LUT.SetNumberOfColors(1000);
>         >             LUT.SetSaturationRange(1, 1);
>         >             LUT.SetHueRange(0.67, 0);//blue to red
>         >             LUT.SetAlphaRange(0, 0.3);//opacity
>         >             LUT.Build();
>         >
>         >             vtkImageMapToColors mapToRGBA = new
>         vtkImageMapToColors();
>         >             mapToRGBA.SetInput(vol);
>         >             mapToRGBA.SetOutputFormatToRGBA();
>         >             mapToRGBA.SetLookupTable(LUT);
>         >
>         >             vtkImageMapper ColorMapper = new
>         vtkImageMapper();
>         >
>         ColorMapper.SetInputConnection(mapToRGBA.GetOutputPort());
>         >             ColorMapper.SetColorWindow(255.0);
>         >             ColorMapper.SetColorLevel(127.5);
>         >
>         >             vtkActor2D ColorActor = new vtkActor2D();
>         >             ColorActor.SetMapper(ColorMapper);
>         >
>         >             vtkContourFilter cf = new vtkContourFilter();
>         >             cf.SetInput(vol);
>         >             //cf.SetValue(0,
>         Convert.ToDouble(dataGridViewIsodose.Rows[i].Cells[1].Value));
>         >             cf.SetValue(0, 100);
>         >             cf.Update();
>         >
>         >             vtkPolyDataMapper mapper = new
>         vtkPolyDataMapper();
>         >             mapper.SetInputConnection(cf.GetOutputPort());
>         >             mapper.ScalarVisibilityOff();
>         >
>         >             vtkActor actor = new vtkActor();
>         >             actor.SetMapper(mapper);
>         >             actor.GetProperty().SetColor(1, 0, 0);
>         >
>         >             vtkImageViewer2 viewer = new vtkImageViewer2();
>         >             viewer.SetupInteractor(iren);
>         >             viewer.GetRenderer().AddActor(DicomActor);
>         >             viewer.GetRenderer().AddActor(ColorActor);
>         >             viewer.GetRenderer().AddActor(actor);
>         >             viewer.GetRenderer().ResetCamera();
>         >             viewer.Render();
>         >
>         > Thanks in advance.
>         >
>         > --
>         > С Уважением,
>         > Андрей.
>         > Best regards, Andrew
>         
>         > _______________________________________________
>         > 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
>         
> 
> 
> 
> -- 
> С Уважением,
> Андрей.
> Best regards, Andrew
> _______________________________________________
> 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

 
 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f
 
 Sponsor:
 Apri Conto Arancio entro il 28 febbraio 2010 e ricevi 50 Euro da spendere presso Media World. Aprilo adesso
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=10035&d=8-4



More information about the vtkusers mailing list