[vtkusers] volume mapper error

Franks masterwangzx at gmail.com
Thu Nov 15 00:34:43 EST 2018


I run the following program with my data and get no error. When I uncomment
out the code, I get the error as I said before. 


#include <vtkStructuredPointsReader.h>
#include <vtkSmartVolumeMapper.h>
#include <vtkSmartPointer.h>
#include <vtkFloatArray.h>
#include <vtkStructuredPoints.h>
#include <vtkDataSet.h>
#include <vtkPointData.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkVolume.h>
#include <vtkVolumeProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>


int main(int argc, char **argv) {
    auto reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
    reader->SetFileName("mummy.vtk");
    reader->Update();

//    auto tuples = vtkSmartPointer<vtkFloatArray>::New();
//    tuples->DeepCopy(reader->GetOutput()->GetPointData()->GetScalars());
//    tuples->SetNumberOfComponents(2);
//    for (int i = 0; i < tuples->GetNumberOfTuples(); ++i) {
//        tuples->SetTuple2(i,80,80);
//    }
//
//    reader->GetOutput()->GetPointData()->RemoveArray(0);
//    reader->GetOutput()->GetPointData()->SetScalars(tuples);

    auto volumeMapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
    volumeMapper->SetInputConnection(reader->GetOutputPort());

    auto volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();

    auto compositeOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
    compositeOpacity->AddPoint(40, 0.00);
    compositeOpacity->AddPoint(60, 0.40);
    volumeProperty->SetScalarOpacity(compositeOpacity);

    auto color = vtkSmartPointer<vtkColorTransferFunction>::New();
    color->AddRGBPoint(0.000, 0.00, 0.00, 0.00);
    color->AddRGBPoint(64.00, 1.00, 0.52, 0.30);
    volumeProperty->SetColor(color);

    auto volume = vtkSmartPointer<vtkVolume>::New();
    volume->SetMapper(volumeMapper);
    volume->SetProperty(volumeProperty);

    auto ren = vtkSmartPointer<vtkRenderer>::New();
    ren->AddViewProp(volume);
    ren->SetBackground(1, 1, 1);

    auto renWin = vtkSmartPointer<vtkRenderWindow>::New();
    renWin->AddRenderer(ren);

    auto style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
    auto iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    iren->SetRenderWindow(renWin);
    iren->SetInteractorStyle(style);

    iren->Initialize();
    iren->Start();

    return 0;
}




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list