diff --git a/matRad/doseCalc/+DoseEngines/@matRad_DoseEngineBase/matRad_DoseEngineBase.m b/matRad/doseCalc/+DoseEngines/@matRad_DoseEngineBase/matRad_DoseEngineBase.m index c1f9cda17..baf9b3c9f 100644 --- a/matRad/doseCalc/+DoseEngines/@matRad_DoseEngineBase/matRad_DoseEngineBase.m +++ b/matRad/doseCalc/+DoseEngines/@matRad_DoseEngineBase/matRad_DoseEngineBase.m @@ -322,13 +322,16 @@ function setDefaults(this) end - function progressUpdate(this,pos,total) + function progressUpdate(this,pos,total,linereset) % This function updates the progress of the dose calculation process. % It can handle both absolute and relative progress updates. % If only one argument is provided, it assumes a relative progress % update from 0 to 1000. If two arguments are provided, it uses the % actual values to calculate the progress percentage. - + if nargin < 4 + linereset = false; + end + % Default total value handling if nargin < 3 pos = pos*1000; % Assume pos is a relative progress if total is not provided @@ -348,7 +351,7 @@ function progressUpdate(this,pos,total) % Log progress if the log level is high enough % This allows for detailed tracking of the calculation progress in logs if matRad_cfg.logLevel > 2 - matRad_progress(pos,total); % Log the progress + matRad_progress(pos,total,linereset); % Log the progress end % Update the waitbar with the current progress if it exists diff --git a/matRad/doseCalc/+DoseEngines/matRad_PencilBeamEngineAbstract.m b/matRad/doseCalc/+DoseEngines/matRad_PencilBeamEngineAbstract.m index c835449cd..b81d1cd77 100644 --- a/matRad/doseCalc/+DoseEngines/matRad_PencilBeamEngineAbstract.m +++ b/matRad/doseCalc/+DoseEngines/matRad_PencilBeamEngineAbstract.m @@ -114,6 +114,7 @@ function setDefaults(this) %Initialize Beam Geometry currBeam = this.initBeam(dij,ct,cst,scenStf,i); + progressLineReset = true; %Keep tabs on bixels computed in this beam bixelBeamCounter = 0; @@ -151,7 +152,8 @@ function setDefaults(this) % Progress Update & Bookkeeping bixelCounter = bixelCounter + currRay.numOfBixels; bixelBeamCounter = bixelBeamCounter + currRay.numOfBixels; - this.progressUpdate(bixelCounter,dij.totalNumOfBixels); + this.progressUpdate(bixelCounter,dij.totalNumOfBixels,progressLineReset); + progressLineReset = false; end end end diff --git a/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m b/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m index a47dd0203..8cf5766e0 100644 --- a/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m +++ b/matRad/steering/matRad_StfGeneratorExternalRayBixelAbstract.m @@ -54,7 +54,7 @@ function setDefaults(this) nBeams = numel(this.gantryAngles); if nBeams ~= numel(this.couchAngles) matRad_cfg = MatRad_Config.instance(); - matRad_cfg.dispWarning('For some reason, we have a different number of beam and couch angles!'); + matRad_cfg.dispError('The number of gantry angles and couch angles must be equal.'); end end @@ -67,9 +67,13 @@ function setDefaults(this) if ~this.lockAngleUpdate this.lockAngleUpdate = true; if numel(this.gantryAngles) > numel(this.couchAngles) + matRad_cfg = MatRad_Config.instance(); + matRad_cfg.dispError('There are more gantry angles than couch angles. They have to have the same size.'); %Append Couch angles with zeros this.couchAngles = [this.couchAngles zeros(1,numel(this.gantryAngles)-numel(this.couchAngles))]; elseif numel(this.couchAngles) > numel(this.gantryAngles) + matRad_cfg = MatRad_Config.instance(); + matRad_cfg.dispError('There are more couch angles than gantry angles. They have to have the same size.'); %Try to identify the removed beam angles [removedAngles,ix] = setdiff(oldAngles,this.gantryAngles); @@ -381,11 +385,6 @@ function initialize(this) pause(1); end - - % Show progress - if matRad_cfg.logLevel > 2 - matRad_progress(i,length(this.gantryAngles)); - end end end diff --git a/matRad/util/matRad_progress.m b/matRad/util/matRad_progress.m index 6d16e5772..241511e97 100644 --- a/matRad/util/matRad_progress.m +++ b/matRad/util/matRad_progress.m @@ -1,5 +1,4 @@ -function matRad_progress(currentIndex, totalNumberOfEvaluations) -% matRad progress bar +function matRad_progress(currentIndex, totalNumberOfEvaluations, linereset) % % call: % matRad_progress(currentIndex, totalNumberOfEvaluations) @@ -7,6 +6,7 @@ function matRad_progress(currentIndex, totalNumberOfEvaluations) % input: % currentIndex: current iteration index % totalNumberOfEvaluations: maximum iteration index +% linereset: (optional) reset output to new line % % output: % graphical display of progess. make sure there is no other output @@ -27,15 +27,17 @@ function matRad_progress(currentIndex, totalNumberOfEvaluations) % LICENSE file. % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + +if nargin < 3 + linereset = false; +end + % If it's not the first step, erase the stuff printed before -if (currentIndex == 1) +if (currentIndex == 1 || linereset) fprintf('Progress: '); -end - -if (currentIndex > 1) - Length = numel(sprintf('%3.2f %%',(currentIndex-1)/totalNumberOfEvaluations*100)); - fprintf(repmat('\b',1,Length)); +else + length = numel(sprintf('%3.2f %%',(currentIndex-1)/totalNumberOfEvaluations*100)); + fprintf(repmat('\b',1,length)); end % Print the progress tool @@ -45,5 +47,7 @@ function matRad_progress(currentIndex, totalNumberOfEvaluations) if (currentIndex == totalNumberOfEvaluations) fprintf('\n'); end - + end + +