[vtkusers] help with marchingcubes with dicom slices set

kingvsk at aol.com kingvsk at aol.com
Mon Nov 19 00:03:09 EST 2012


Hi

Try this code... It works fine for me...

<code>
private void DisplaySurface(int val, double opacityValue, double 
redValue, double greenValue, double blueValue) {
         reader = new vtkDICOMImageReader();
         if (new File(directoryName).isDirectory()) {
             reader.SetDirectoryName(directoryName);
             reader.Update();
         } else {
             LOG.log(Level.WARNING, "Please select a directory");
         }
         reader.GetOutput().ReleaseDataFlagOn();

         // For Outline...
         vtkOutlineFilter outline = new vtkOutlineFilter();
         outline.SetInput(reader.GetOutput());

         vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
         outlineMapper.SetInput(outline.GetOutput());

         vtkActor outlineActor = new vtkActor();
         outlineActor.SetMapper(outlineMapper);

         mCube = new vtkMarchingCubes();
         mCube.SetInput(reader.GetOutput());
         mCube.SetValue(0, val);
         mCube.ComputeNormalsOn();
         mCube.ComputeGradientsOff();
         mCube.UpdateWholeExtent();

         vtkPolyDataMapper pdMapper = new vtkPolyDataMapper();
         pdMapper.SetInput(mCube.GetOutput());
         pdMapper.ImmediateModeRenderingOn();
         pdMapper.ScalarVisibilityOff();

         // Create and Add Surface Actor...
         vtkActor actor = new vtkActor();
         actor.GetProperty().SetOpacity(opacityValue);
         actor.GetProperty().SetColor(redValue, greenValue, blueValue);
         actor.SetMapper(pdMapper);

         vtkCanvas vpanSurface = new vtkCanvas();
         vpanSurface.GetRenderer().AddActor(actor);
         vpanSurface.GetRenderWindow().StereoCapableWindowOn();
         //vpanSurface.GetRenderWindow().SetStereoTypeToAnaglyph();
vpanSurface.GetRenderWindow().SetStereoTypeToCrystalEyes();
         vpanSurface.GetRenderWindow().SetStereoRender(1);
vpanSurface.GetRenderWindow().AddRenderer(vpanSurface.GetRenderer());

         // Add the outline actor to the renderer and size...
// Here pnlSurfaceViewer is a JPanel...
         vpanSurface.GetRenderer().AddActor(outlineActor);
         vpanSurface.GetRenderer().ResetCamera();
         pnlSurfaceViewer.add(vpanSurface);
         pnlSurfaceViewer.setVisible(true);
     }
</code>

--
Sathish


On Saturday 17 November 2012 10:35 PM, Rodrigo Lovera wrote:
> I tried with your values, but now i'm getting a black screen, no 
> volume or shape at all.
>
>
>
> Rodrigo Lovera Sandoval
>
>
> 2012/11/16 kingvsk at aol.com <mailto:kingvsk at aol.com> <kingvsk at aol.com 
> <mailto:kingvsk at aol.com>>
>
>     Hi
>
>     Change the value in following line.
>     surface->SetValue(0, 5);
>
>     Instead of 5 you can use 500 (Bone) or -500 (Skin).
>
>     That is, try either *surface->SetValue(0, 500);* or
>     *surface->SetValue(0, -500); *
>
>     --
>     Sathish
>
>
>     On Saturday 17 November 2012 02:46 AM, Rodrigo Lovera wrote:
>>
>>     Hello everyone,
>>
>>     I've got a set of dicom slices which I use for rendering a
>>     volume, now I tried to apply marching cubes to try surface
>>     rendering buy i'm only getting some kind of box and not the head
>>     that shold be forming.
>>
>>     I'm using atm the following code
>>
>>     vtkSmartPointer< vtkDICOMImageReader > reader =
>>     vtkSmartPointer< vtkDICOMImageReader >::New();
>>     reader->SetDataByteOrderToLittleEndian();
>>     //reader->SetDirectoryName(argv[1]);
>>     reader->SetDirectoryName("C:\\VTK5.10\\DATA\\DICOM");
>>     reader->SetDataSpacing(1, 1, 1);
>>     reader->SetDataOrigin(0.0, 0.0, 0.0);
>>     reader->Update();
>>
>>     vtkSmartPointer< vtkMarchingCubes > surface =
>>     vtkSmartPointer< vtkMarchingCubes >::New();
>>     surface->SetInputConnection(reader->GetOutputPort());
>>     surface->ComputeNormalsOn();
>>     surface->SetValue(0, 5);
>>     vtkSmartPointer< vtkRenderer > surfacerenderer =
>>     vtkSmartPointer< vtkRenderer >::New();
>>     surfacerenderer->SetBackground(0.1, 0.2, 0.3);
>>
>>     vtkSmartPointer< vtkRenderWindow > renderwin =
>>     vtkSmartPointer< vtkRenderWindow >::New();
>>     renderwin->AddRenderer(surfacerenderer);
>>     vtkSmartPointer< vtkRenderWindowInteractor > intersurf =
>>     vtkSmartPointer< vtkRenderWindowInteractor >::New();
>>     intersurf->SetRenderWindow(renderwin);
>>
>>     vtkSmartPointer< vtkPolyDataNormals > premapper =
>>     vtkSmartPointer< vtkPolyDataNormals >::New();
>>     premapper->SetInputConnection(surface->GetOutputPort());
>>     premapper->ComputeCellNormalsOn();
>>     vtkSmartPointer< vtkPolyDataMapper > surfacemapper =
>>     vtkSmartPointer< vtkPolyDataMapper >::New();
>>     surfacemapper->SetInputConnection(premapper->GetOutputPort());
>>     //surfacemapper->SetInputConnection(surface->GetOutputPort());
>>
>>     vtkSmartPointer< vtkActor > actor =
>>     vtkSmartPointer< vtkActor >::New();
>>     actor->SetMapper(surfacemapper);
>>
>>     vtkSmartPointer< vtkProperty > backFaces =
>>     vtkSmartPointer< vtkProperty >::New();
>>     backFaces->SetSpecular(0.0);
>>     backFaces->SetDiffuse(0.0);
>>     backFaces->SetAmbient(1.0);
>>     backFaces->SetAmbientColor(1.0000, 0.3883, 0.2784);
>>     backFaces->SetOpacity(256);
>>
>>     actor->SetBackfaceProperty(backFaces);
>>
>>     surfacerenderer->AddActor(actor);
>>     renderwin->SetSize(800,600);
>>     //renderWindow->Render();
>>     intersurf->Start();
>>
>>     this->ui->vtksurface->GetRenderWindow()->AddRenderer(surfacerenderer);
>>
>>     I'd appreciate any kind of help, example code or advice. Thx in
>>     advance.
>>
>>     -- 
>>     *Rodrigo Lovera *
>>
>>
>>     _______________________________________________
>>     Powered bywww.kitware.com  <http://www.kitware.com>
>>
>>     Visit other Kitware open-source projects athttp://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
>
>
>
>
> -- 
> *Rodrigo aka WarHearT*

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121119/5a851730/attachment.htm>


More information about the vtkusers mailing list