#include VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { // This is a simple volume rendering example that // uses a vtkFixedPointVolumeRayCastMapper // Create the standard renderer, render window // and interactor vtkNew colors; vtkNew ren1; vtkNew renWin; renWin->AddRenderer(ren1); vtkNew iren; iren->SetRenderWindow(renWin); vtkNew reader; reader->SetFileName("C:/Users/v.legarrec/Desktop/fff/" "sequence_RCA_low_level_22pw_1Frame_IQ.vti"); reader->Update(); // filtre for absolute value. vtkNew imageMath; imageMath->SetOperationToAbsoluteValue(); imageMath->SetInputConnection(reader->GetOutputPort()); imageMath->Update(); vtkAlgorithmOutput *readerOutputPort = imageMath->GetOutputPort(); // Create transfer mapping scalar value to opacity vtkNew opacityTransferFunction; opacityTransferFunction->AddPoint(0, 0); // Show only value from 11 to 512 opacityTransferFunction->AddPoint(5618, 1); // Create transfer mapping scalar value to color vtkNew colorTransferFunction; colorTransferFunction->AddRGBPoint(0.0, 0.0, 0.0, 1.0); colorTransferFunction->AddRGBPoint(5618.0, 1.0, 0.0, 0.0); // Max Value colorTransferFunction->Build(); // The property describes how the data will look vtkNew volumeProperty; volumeProperty->SetColor(colorTransferFunction); volumeProperty->SetScalarOpacity(opacityTransferFunction); volumeProperty->ShadeOn(); volumeProperty->SetInterpolationTypeToLinear(); volumeProperty->SetScalarOpacityUnitDistance(0.0003); volumeProperty->Modified(); // None of three mapper show transparency. // The mapper / ray cast function know how to render the data // vtkNew volumeMapper; // vtkNew volumeMapper; // vtkNew volumeMapper; vtkNew volumeMapper; volumeMapper->SetInputConnection(readerOutputPort); // Doesn't work /* // volumeMapper->SetBlendModeToComposite(); // volumeMapper->SetScalarModeToUsePointData(); // volumeMapper->SetAutoAdjustSampleDistances(false); */ volumeMapper->SetSampleDistance(0.0001); // The volume holds the mapper and the property and // can be used to position/orient the volume vtkNew volume; volume->SetMapper(volumeMapper); volume->SetProperty(volumeProperty); ren1->AddViewProp(volume); ren1->SetBackground(colors->GetColor3d("Wheat").GetData()); ren1->GetActiveCamera()->Azimuth(45); ren1->GetActiveCamera()->Elevation(30); ren1->ResetCameraClippingRange(); ren1->ResetCamera(); // Doesn't work /* ren1->SetUseDepthPeeling(1); ren1->SetMaximumNumberOfPeels(100); */ renWin->SetSize(600, 600); renWin->SetWindowName("SimpleRayCast"); // Doesn't work /* renWin->SetAlphaBitPlanes(1); renWin->SetMultiSamples(0); */ renWin->Render(); iren->Start(); return EXIT_SUCCESS; }