% ----------------------------------------------------------------------------
% function HfssCircle(fid, HName, HAxis, HCenter, HRadius, HUnits)
% 
% Popis funkce :
% -------------
% Vytvoreni m-file skriptu potrebny k vytvoreni kruhu v HFSS.
%
% Parametery :
% ------------
% fid     - file identifier of the HFSS script file.
% HName    - pojmenovani kruhu primo (v HFSS).
% HAxis    - vyber mezi 'X', 'Y', nebo 'Z' reprezentujici smer kruhu.
% HCenter  - stred kruhu (pouzity [x, y, z] format).
% HRadius  - radius kruhu.
% HUnits   - pouzite jednotky (jako napr. 'in', 'mm', 'meter'
%           nebo ostatni definovane (v HFSS).
% 
%
% Priklad pouziti funkce :
% ---------
% fid = fopen('antenna.m', 'wt');
% ... 
% HfssCircle(fid, 'C_Patch', 'Z', [10, 11, 12], 13, 'mm');
% ----------------------------------------------------------------------------

function HfssCircle(fid, HName, HAxis, HCenter, HRadius, HUnits, HcoverLines)
global Editor

if (nargin < 7)
	HcoverLines = [];
end;
if isempty(HcoverLines)
	HcoverLines = true;
end;
% Parameters.
if (HcoverLines)
    HTF = 'true';
else
    HTF = 'false';
end;

%zapis do souboru temp
fprintf(fid,'%% Vytvoreni kruhu\n');
fprintf(fid,'invoke(Editor,''CreateCircle'',...\n');
fprintf(fid,'{''NAME:CircleParameters'',...\n');
fprintf(fid,['''IsCovered:='',',HTF,',...\n']);
fprintf(fid,['''XCenter:='',''',[num2str(HCenter(1)),HUnits],''',...\n']);
fprintf(fid,['''YCenter:='',''',[num2str(HCenter(2)),HUnits],''',...\n']);
fprintf(fid,['''ZCenter:='',''',[num2str(HCenter(3)),HUnits],''',...\n']);
fprintf(fid,['''Radius:='',''',[num2str(HRadius),HUnits],''',...\n']);
fprintf(fid,['''WhichAxis:='',''',upper(HAxis),'''},...\n']);
fprintf(fid,'{''NAME:Attributes'',...\n');
fprintf(fid,['''Name:='',''',HName,''',...\n']);
fprintf(fid,'''Flags:='','''',...\n');
fprintf(fid,'''Color:='',''(132 132 193)'',...\n');
fprintf(fid,'''Transparency:='',0,...\n');
fprintf(fid,'''PartCoordinateSystem:='',''Global'',...\n');
fprintf(fid,'''MaterialName:='',''vacuum'',...\n');
fprintf(fid,'''SolveInside:='',true})\n\n');

%Prime vykonani v progrqamu Hfss
invoke(Editor,'CreateCircle',...
    {'NAME:CircleParameters',...
    'IsCovered:=',HTF,...
    'XCenter:=',[num2str(HCenter(1)),HUnits],...
    'YCenter:=',[num2str(HCenter(2)),HUnits],...
    'ZCenter:=',[num2str(HCenter(3)),HUnits],...
    'Radius:=',[num2str(HRadius),HUnits],...
    'WhichAxis:=',upper(HAxis)},...
    {'NAME:Attributes',...
    'Name:=',HName,...
    'Flags:=','',...
    'Color:=','(132 132 193)',...
    'Transparency:=',0,...
    'PartCoordinateSystem:=','Global',...
    'MaterialName:=','vacuum',...
    'SolveInside:=',true});
end