0001 function [X,Y,S,T,R,P,bpmerrors]=GetExistingErrors(THERING,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if numel(varargin)==1
0012 indxerrors=varargin{1};
0013 else
0014 indxerrors=1:length(THERING);
0015 end
0016
0017 if nargout>=2
0018
0019 X=zeros(size(indxerrors));
0020 Y=zeros(size(indxerrors));
0021 t1=findcells(THERING(indxerrors),'T1');
0022 if ~isempty(t1)
0023 X(t1)=-getcellstruct(THERING(indxerrors),'T1',t1,1);
0024 Y(t1)=-getcellstruct(THERING(indxerrors),'T1',t1,3);
0025 end
0026 end
0027 if nargout>=3
0028
0029 S=zeros(size(indxerrors));
0030 s1=findcells(THERING(indxerrors),'DeltaS');
0031 if ~isempty(s1)
0032 S(s1)=-getcellstruct(THERING(indxerrors),'DeltaS',s1,1);
0033 end
0034 end
0035 if nargout>=4
0036
0037 T=zeros(size(indxerrors));
0038 tiltedelem=findcells(THERING(indxerrors),'RotAboutS');
0039 if ~isempty(tiltedelem)
0040 T(tiltedelem)=getcellstruct(THERING(indxerrors),'RotAboutS',tiltedelem);
0041 T(T<1e-7 & T>-1e-7)=0;
0042 end
0043 end
0044 if nargout>=5
0045
0046 R=zeros(size(indxerrors));
0047 tiltedelem=findcells(THERING(indxerrors),'RotAboutX');
0048 if ~isempty(tiltedelem)
0049 R(tiltedelem)=getcellstruct(THERING(indxerrors),'RotAboutX',tiltedelem);
0050 R(R<1e-7 & R>-1e-7)=0;
0051 end
0052 end
0053 if nargout>=6
0054
0055 P=zeros(size(indxerrors));
0056 tiltedelem=findcells(THERING(indxerrors),'RotAboutY');
0057 if ~isempty(tiltedelem)
0058 P(tiltedelem)=getcellstruct(THERING(indxerrors),'RotAboutY',tiltedelem);
0059 P(P<1e-7 & P>-1e-7)=0;
0060 end
0061 end
0062 if nargout>=7
0063 tiltedelem=findcells(THERING,'Class','Monitor');
0064 bpmerrors.offsetx=zeros(size(tiltedelem));
0065 bpmerrors.offsety=zeros(size(tiltedelem));
0066 bpmerrors.rotation=zeros(size(tiltedelem));
0067
0068 if ~isempty(tiltedelem)
0069
0070 try
0071 ox=cell2mat(cellfun(@(a)a.Offset(1,1),THERING(tiltedelem),'un',0));
0072 oy=cell2mat(cellfun(@(a)a.Offset(1,2),THERING(tiltedelem),'un',0));
0073 or=cell2mat(cellfun(@(a)a.Rotation(1,1),THERING(tiltedelem),'un',0));
0074 catch
0075 ox=zeros(size(tiltedelem));
0076 oy=zeros(size(tiltedelem));
0077 or=zeros(size(tiltedelem));
0078
0079 end
0080 ox(isnan(ox))=0;
0081 oy(isnan(oy))=0;
0082 or(isnan(or))=0;
0083
0084 bpmerrors.offsetx=ox(:)';
0085 bpmerrors.offsety=oy(:)';
0086 bpmerrors.rotation=or(:)';
0087
0088 end
0089 end
0090 return