[vtkusers] spheres creating a scalar field of absorbed dose (possibly using vtkStructuredGrid)

mbcx9rb9 richard.j.brown at live.co.uk
Thu Apr 16 12:53:51 EDT 2015


Hello all,

I have several spheres containing radiation placed in a tumour and I want to
find out the absorbed dose in the tumour and the surrounding organs.

I know the absorbed dose as a function of distance, so I was hoping to
superimpose all these radiation points to create a scalar field containing
the distribution of absorbed dose.

After that I was hoping to intersect the scalar field with VOIs, which are
stored as 3D contours, to get the DVH, maximum absorbed dose and average
absorbed dose for each VOI.

As a bonus, I would also like to be able to drag and drop radiation spheres
and for the values to update in real time. If possible, I would like to be
able to update the scalar field instantaneously after altering the position
of the radiation spheres. That is, if I can avoid having to loop over every
voxel in my scan to calculate the absorbed dose distribution, it would be
preferable. 

I thought about creating a vtkStructuredGrid once, saving it then simply
loading it and adding all the spheres to a blank vtkStructuredGrid in the
relevant position. However, visualising the process below shows nothing. I'm
also not sure on how to superimpose points or what the canvas should be that
the vtkStructuredGrid for each sphere gets added to should be. I guess it
should have the same dimensions and spacing as my DICOMs - so does that mean
I should use vtkImageData? 

Any ideas?

    vtkSmartPointer<vtkPoints> points= vtkSmartPointer<vtkPoints>::New();
    vtkSmartPointer<vtkDoubleArray> absorbedDoses =
vtkSmartPointer<vtkDoubleArray>::New();
    absorbedDoses->SetNumberOfComponents(1); // 1=scalar, 3=vector
    double absorbedDose;
    double rMax = 6.65;
    double x,y,z;

    for (double r=0; r<=rMax; r+=0.05) { // I know absorbed dose to
precision of 0.05mm
         for (double theta=0; theta<2*vtkMath::Pi();
theta+=2*vtkMath::Pi()/18) {
              for (double phi=0; phi<vtkMath::Pi(); phi+=2*vtkMath::Pi()/18)
{
                  x = r * cos(theta) * sin(phi);
                  y = r * sin(theta) * sin(phi);
                  z = r * cos(phi);

                  points->InsertNextPoint(x,y,z);
                  absorbedDose = getAbsorbedDose(r);
                  absorbedDoses->InsertNextValue(absorbedDose);
              }
         }
    }

    vtkSmartPointer<vtkStructuredGrid> grid =
vtkSmartPointer<vtkStructuredGrid>::New();
    grid->SetPoints(points);
    grid->GetPointData()->AddArray(absorbedDoses);

    // save to file
    vtkSmartPointer<vtkXMLStructuredGridWriter> writer =
vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
    writer->SetFileName("output.vts");
    writer->SetInputData(grid);
    writer->Write();

    // render
    vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
    mapper->SetInputData(grid);

    vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
    actor->SetMapper(mapper);

    // Create a renderer, render window, and interactor
    vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
    vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
    renderWindow->AddRenderer(renderer);
    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
    renderWindowInteractor->SetRenderWindow(renderWindow);

    // Add the actor to the scene
    renderer->AddActor(actor);
    renderer->SetBackground(.3, .6, .3); // Background color green

    // Render and interact
    renderWindow->Render();
    renderWindowInteractor->Start();



--
View this message in context: http://vtk.1045678.n5.nabble.com/spheres-creating-a-scalar-field-of-absorbed-dose-possibly-using-vtkStructuredGrid-tp5731487.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list