<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><span style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);">Hello there, </span><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);">I am quite new to VTK, and I am trying to render a volume and an isosurface in one render window using viewpoint. I follow the example of <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/StructuredDataTypes" target="_blank" style="color: rgb(17, 85, 204);">http://www.vtk.org/Wiki/<wbr>VTK/Examples/Cxx/<wbr>Visualization/<wbr>StructuredDataTypes</a> but no luck so far. Here is the code I wrote. Could anyone help to figure out where is wrong? </div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);">Would appreciate any help.</div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8px; background-color: rgb(255, 255, 255);"><div><br></div><div>       </div><div>        // Create an image data</div><div>        vtkSmartPointer<vtkImageData> imageData =</div><div>            vtkSmartPointer<vtkImageData>:<wbr>:New();</div><div><span style="white-space: pre-wrap;">          </span></div><div><span style="white-space: pre-wrap;">               </span>// load data here</div><div><br></div><div>        // Define viewport ranges</div><div>        double upperViewport[4] = {0.0, 0.0, 1.0, 0.5};</div><div>        double centerViewport[4] = {0.0, 0.5, 1.0, 1.0};</div><div><br></div><div>        // create render window</div><div>        vtkSmartPointer<<wbr>vtkRenderWindow> renWin = vtkSmartPointer<<wbr>vtkRenderWindow>::New();</div><div>        vtkSmartPointer<<wbr>vtkRenderWindowInteractor> iren =</div><div>            vtkSmartPointer<<wbr>vtkRenderWindowInteractor>::<wbr>New();</div><div>        renWin->SetSize(1200, 600);</div><div>        renWin->Render();</div><div>        renWin->SetWindowName("Volume Clipping");</div><div>        iren->SetRenderWindow(renWin);</div><div><br></div><div>        /*****************************<wbr>******************************<wbr>*****</div><div>                 create volume renderer to render stacked tomograms</div><div>        ******************************<wbr>******************************<wbr>****/ </div><div>        vtkSmartPointer<<wbr>vtkSmartVolumeMapper> volumeMapper =</div><div>            vtkSmartPointer<<wbr>vtkSmartVolumeMapper>::New();</div><div>        volumeMapper-><wbr>SetBlendModeToComposite(); // composite first</div><div>        volumeMapper->SetInputData(<wbr>imageData);</div><div>        volumeMapper-><wbr>SetInterpolationModeToLinear()<wbr>;</div><div>        volumeMapper-><wbr>SetRequestedRenderModeToGPU();</div><div><br></div><div>        vtkSmartPointer<<wbr>vtkVolumeProperty> volumeProperty =</div><div>            vtkSmartPointer<<wbr>vtkVolumeProperty>::New();</div><div>        volumeProperty-><wbr>SetInterpolationType(VTK_<wbr>LINEAR_INTERPOLATION);</div><div>        volumeProperty->ShadeOff();</div><div><br></div><div>        vtkSmartPointer<<wbr>vtkColorTransferFunction> color =</div><div>            vtkSmartPointer<<wbr>vtkColorTransferFunction>::<wbr>New();</div><div>        //color->SetColorSpaceToRGB();</div><div>        color->AddRGBPoint(0.0, 0.0, 0.0, 1.0);</div><div>        color->AddRGBPoint(0.25, 0.0, 1.0, 1.0);</div><div>        color->AddRGBPoint(0.5, 0.0, 1.0, 0.0);</div><div>        color->AddRGBPoint(0.75, 1.0, 1.0, 0.0);</div><div>        color->AddRGBPoint(1.0, 1.0, 0.0, 0.0);</div><div>        color->SetScaleToLinear();</div><div>        volumeProperty->SetColor(<wbr>color);</div><div><br></div><div>        vtkSmartPointer<<wbr>vtkPiecewiseFunction> compositeOpacity =</div><div>            vtkSmartPointer<<wbr>vtkPiecewiseFunction>::New();</div><div>        compositeOpacity->AddPoint(-1.<wbr>0, 0.0);</div><div>        compositeOpacity->AddPoint(0.<wbr>0, 0.0);</div><div>        compositeOpacity->AddPoint(0.<wbr>39, 0.4);</div><div>        compositeOpacity->AddPoint(0.<wbr>4, 0.8);</div><div>        compositeOpacity->AddPoint(1.<wbr>0, 1.0);</div><div>        volumeProperty-><wbr>SetScalarOpacity(<wbr>compositeOpacity);</div><div><span style="white-space: pre-wrap;">                </span></div><div>        vtkSmartPointer<vtkVolume> volume =</div><div>            vtkSmartPointer<vtkVolume>::<wbr>New();</div><div>        volume->SetMapper(<wbr>volumeMapper);</div><div>        volume->SetProperty(<wbr>volumeProperty);</div><div><br></div><div>        vtkSmartPointer<vtkRenderer> volumeRenderer = vtkSmartPointer<vtkRenderer>::<wbr>New();</div><div>        renWin->AddRenderer(<wbr>volumeRenderer);</div><div>        volumeRenderer->SetViewPoint(<wbr>upperViewport); // position volume rendering at upper part</div><div>        volumeRenderer->SetBackground(<wbr>0.4, 0.5, 0.6);</div><div><br></div><div>        vtkSmartPointer<<wbr>vtkScalarBarWidget> scalarWidget =</div><div>            vtkSmartPointer<<wbr>vtkScalarBarWidget>::New();</div><div>        scalarWidget->SetInteractor(<wbr>iren);</div><div>        scalarWidget-><wbr>GetScalarBarActor()->SetTitle(<wbr>"Concentration");</div><div>        scalarWidget-><wbr>GetScalarBarActor()-><wbr>SetLookupTable(color);</div><div>        scalarWidget-><wbr>GetScalarBarActor()-><wbr>SetOrientationToHorizontal();</div><div>        scalarWidget-><wbr>RepositionableOn();</div><div>        scalarWidget->ResizableOn();</div><div>        scalarWidget->EnabledOn();</div><div><br></div><div>        vtkSmartPointer<vtkAxesActor> axes =</div><div>            vtkSmartPointer<vtkAxesActor>:<wbr>:New();</div><div>        axes->SetTotalLength(50.0, 50.0, 50.0);</div><div>        /*****************************<wbr>*****End of volume renderer**********************<wbr>***********/</div><div><br></div><div>        /*****************************<wbr>******************************<wbr>*****</div><div>        create contour renderer to contouring stacked tomograms</div><div>        ******************************<wbr>******************************<wbr>****/</div><div>        // Create an isosurface</div><div>        vtkSmartPointer<<wbr>vtkContourFilter> contourFilter =</div><div>            vtkSmartPointer<<wbr>vtkContourFilter>::New();</div><div>        contourFilter->SetInputData(<wbr>imageData);</div><div><span style="white-space: pre-wrap;">          </span></div><div>        const double isovalue = 0.6;</div><div>        contourFilter->GenerateValues(<wbr>1, isovalue, isovalue); // (numContours, rangeStart, rangeEnd)</div><div>        // Map the contours to graphical primitives</div><div>        vtkSmartPointer<<wbr>vtkPolyDataMapper> contourMapper =</div><div>            vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();</div><div>        contourMapper->SetInputData(<wbr>contourFilter->GetOutput());</div><div><br></div><div>        // Create an actor for the contours</div><div>        vtkSmartPointer<vtkActor> contourActor =</div><div>            vtkSmartPointer<vtkActor>::<wbr>New();</div><div>        contourActor->SetMapper(<wbr>contourMapper);</div><div><br></div><div>        // Create the outline</div><div>        vtkSmartPointer<<wbr>vtkOutlineFilter> outlineFilter =</div><div>            vtkSmartPointer<<wbr>vtkOutlineFilter>::New();</div><div>        outlineFilter->SetInputData(<wbr>imageData);</div><div><span style="white-space: pre-wrap;">           </span></div><div>        vtkSmartPointer<<wbr>vtkPolyDataMapper> outlineMapper =</div><div>            vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();</div><div>        outlineMapper->SetInputData(<wbr>outlineFilter->GetOutput());</div><div>        vtkSmartPointer<vtkActor> outlineActor =</div><div>            vtkSmartPointer<vtkActor>::<wbr>New();</div><div>        outlineActor->SetMapper(<wbr>outlineMapper);</div><div><br></div><div>        // Visualize</div><div>        vtkSmartPointer<vtkRenderer> contourRenderer =</div><div>            vtkSmartPointer<vtkRenderer>::<wbr>New();</div><div>        renWin->AddRenderer(<wbr>contourRenderer);</div><div>        contourRenderer->SetViewPoint(<wbr>centerViewport);</div><div>        contourRenderer-><wbr>SetBackground(0.5, .4, .6);</div><div>        /*****************************<wbr>*****End of contour renderer**********************<wbr>***********/</div><div><br></div><div>        volumeRenderer->AddActor(<wbr>volume);</div><div>        volumeRenderer->AddActor(axes)<wbr>;</div><div><br></div><div>        contourRenderer->AddActor(<wbr>contourActor);</div><div>        contourRenderer->AddActor(<wbr>outlineActor);</div><div><br></div><div>        contourRenderer-><wbr>SetActiveCamera(<wbr>volumeRenderer-><wbr>GetActiveCamera());</div><div>        volumeRenderer->ResetCamera();</div><div>        contourRenderer->ResetCamera()<wbr>;</div><div><br></div><div>        // Render composite. In default mode. For coverage.</div><div>        renWin->Render();</div><div>        iren->Start();</div></div>                                    </div></body>
</html>