summaryrefslogtreecommitdiffstats
path: root/matlab/tools/astra_plot_geom.m
blob: 291842de4f1f240fb27edf0ec78aabd078ea48f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
function [] = astra_plot_geom(geometry, varargin)
%--------------------------------------------------------------------------
% [] = astra_plot_geometry(geometry, varargin)
%
% plot an astra geometry
%
% geometry: any astra geometry, either volume geometry, projection
%           geometry or an *.stl file (powered by stlRead).
% varargin: supports a variable number of (ordered and unordered)
%           arguments.
%
%           the remaining arguments depend on the input:
%           if 'geometry' is
%           - a volume geometry
%             vx_size               voxel size in unit of preference. Must
%                                   be same unit that was used to scale the
%                                   projection geometry.
%            and as unorderd string-value-pairs
%             Magnification         magnification factor for the phantom.
%                                   For small phantoms it might be
%                                   necessary to scale the render up as 
%                                   otherwise it won't show up in the plot.
%                                   Default = 1
%             LineWidth             line width for the box wireframe.
%                                   Default = 2
%             Color                 color of the wireframe. Default = 'r'
%                  
%           - a projection geometry (as unordered string-value-pairs)
%             RotationAxis          if specified, will change the drawn
%                                   rotation axis to provided axis.
%                                   Must be 3-vector. Default value is
%                                   [NaN, NaN, NaN], (meaning do not draw).
%             RotationAxisOffset    if specified, will translate the drawn 
%                                   rotation axis by the provided vector.
%                                   Default = [0, 0, 0]
%             VectorIdx             index of the vector to visualize if 
%                                   vector geometry type. Default = 1
%             Color                 Color for all markers and lines if not 
%                                   otherwise specified
%             DetectorMarker        marker for the detector locations.
%                                   Default = '.'
%             DetectorMarkerColor   color specifier for the detector marker.
%                                   Default = 'k'
%             DetectorLineColor     color for the lines drawing the 
%                                   detector outline
%             DetectorLineWidth     line width of detector rectangle
%             SourceMarker          marker for the source locations
%             SourceMarkerColor     color specifier for the source marker
%             SourceDistance        (only for parallel3d and parallel3d_vec)
%                                   distance of source to origin
%             OpticalAxisColor      Color for drawing the optical axis
%                  
%           - a path to an *.stl file
%             magn    -             magnification factor for vertices in
%                                   CAD file. Default value = 1
%
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% This file is part of the ASTRA Toolbox
%
% Copyright: 2010-2021, imec Vision Lab, University of Antwerp
%            2014-2021, CWI, Amsterdam
% License: Open Source under GPLv3
% Contact: astra@astra-toolbox.com
% Website: http://www.astra-toolbox.com/
%--------------------------------------------------------------------------
    if exist('astra_create_example_cone') ~= 2
        error('Please add astra/algorithms/plot_geom to your path to use this function')
    end

    if is_vol_geom(geometry)
        draw.draw_vol_geom(geometry, varargin{:});
    elseif is_proj_geom(geometry)
        draw.draw_proj_geom(geometry, varargin{:});
    elseif ischar(geometry) % assume 'geometry' is a path to a CAD file
        draw.draw_cad_phantom(geometry, varargin{:});
    end

    % ---- helper functions ----
    function [ res ] = is_vol_geom(geom)
        res = false;
        if sum(isfield(geom, {'GridRowCount', 'GridColCount'})) == 2
            res = true;
        end
    end

    function [ res ] = is_proj_geom(geom)
        res = false;
        if isfield(geom, 'type')
            res = true;
        end
    end
end