% ----------------------------------------------------------------------------
% function HfssSphere(fid, HName, HCenter, HRadius, HUnits)
% 
% Popis funkce :
% -------------
% Vytvoreni m-file potrebny k vytvoreni koule v HFSS.
%
% Parametery :
% ------------
% fid     - soubor identifikujici HFSS script.
% Name    - jmeno koule (pouzite v HFSS).
% Center  - stred koule (specifikovane jako [cx, cy, cz])
% Radius  - radius koule (scalar)
% Units   - specifikovane jako 'in', 'm', 'meter' nebo ostatni definovane v
%           HFSS.
% 
%
% Priklad pouziti funkce :
% ---------
% fid = fopen('antenna.m', 'wt');
% ... 
% HfssSphere(fid, 'Sphere1', [0,0,0], 1, 'mm');
%
% ----------------------------------------------------------------------------

function HfssSphere(fid, HName, HCenter, HRadius, HUnits)
global Editor

%zapis do souboru temp
fprintf(fid,'%% Vytvoreni koule\n');
fprintf(fid,'invoke(Editor,''CreateSphere'',...\n');
fprintf(fid,'{''NAME:SphereParameters'',...\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,'{''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,'CreateSphere',...
    {'NAME:SphereParameters',...
    'XCenter:=',[num2str(HCenter(1)),HUnits],...
    'YCenter:=',[num2str(HCenter(2)),HUnits],...
    'ZCenter:=',[num2str(HCenter(3)),HUnits],...
    'Radius:=',[num2str(HRadius),HUnits]},...
    {'NAME:Attributes',...
    'Name:=',HName,...
    'Flags:=','',...
    'Color:=','(132 132 193)',...
    'Transparency:=',0,...
    'PartCoordinateSystem:=','Global',...
    'MaterialName:=','vacuum',...
    'SolveInside:=',true})
end