Skip to content

Instantly share code, notes, and snippets.

@pammacdotnet
Created September 20, 2019 07:51
Show Gist options
  • Save pammacdotnet/b0262adbb7d90732aaa5dcc45df116b6 to your computer and use it in GitHub Desktop.
Save pammacdotnet/b0262adbb7d90732aaa5dcc45df116b6 to your computer and use it in GitHub Desktop.

Revisions

  1. pammacdotnet created this gist Sep 20, 2019.
    38 changes: 38 additions & 0 deletions gvxrexample.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #include <cstdlib>
    #include <string>
    #include <iostream>
    #include <exception>
    #include "SimpleGVXR.h"
    int main(){
    // Create an OpenGL context
    createWindow();
    setWindowSize(512, 512);
    // Set the position of the X-ray source
    setSourcePosition(-40.0,0,0, "cm");
    // Set the shape of the X-ray source
    usePointSource();
    // The spectrum of the X-ray beam
    setMonoChromatic(0.08, "MeV", 1000);
    // Set the position of the detector
    setDetectorPosition(10.0,0, 0,"cm");
    // Set the orientation of the detector
    setDetectorUpVector(0, 0, -1);
    // Set the number of pixels of the detector
    setDetectorNumberOfPixels(640, 320);
    // Set the distance between two pixels
    setDetectorPixelSize(0.5, 0.5, "mm");
    // Load a polygon mesh from a STL file
    loadSceneGraph("dragon.stl", "mm");
    // Set the material properties
    for (unsigned int i = 0; i < getNumberOfChildren("root"); ++i)
    {
    std::string label = getChildLabel("root", i);
    moveToCentre(label);
    setHU(label, 1000);
    }
    // Compute an X-ray image
    computeXRayImage();
    // Save the image into a image file
    saveLastXRayImage("welsh-dragon-xray_cpp.tif");
    return EXIT_SUCCESS;
    }