Mercurial > forge
changeset 10446:4bebf7cba94d octave-forge
geometry: applying Rafael's patch and changing all permissions and removing private folder from io/deprecated
author | jpicarbajal |
---|---|
date | Sat, 16 Jun 2012 09:34:54 +0000 |
parents | 7050d7679746 |
children | f551ca353061 |
files | main/geometry/inst/io/deprecated/SVGstrPath2SVGpath.m main/geometry/inst/io/deprecated/_parsePath.py main/geometry/inst/io/deprecated/formatSVGstr.m main/geometry/inst/io/deprecated/getSVGPaths_py.m main/geometry/inst/io/deprecated/getSVGdata.m main/geometry/inst/io/deprecated/getSVGstrPath.m main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m main/geometry/inst/io/deprecated/private/_parsePath.py main/geometry/inst/io/deprecated/private/formatSVGstr.m main/geometry/inst/io/deprecated/private/getSVGPaths_py.m main/geometry/inst/io/deprecated/private/getSVGdata.m main/geometry/inst/io/deprecated/private/getSVGstrPath.m |
diffstat | 12 files changed, 357 insertions(+), 357 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/inst/io/deprecated/SVGstrPath2SVGpath.m Sat Jun 16 09:34:54 2012 +0000 @@ -0,0 +1,103 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function SVGpath = SVGstrPath2SVGpath (SVGstrPath) + + nPaths = numel (SVGstrPath); + SVGpath = repmat (struct('coord', [], 'closed', [], 'id', []), 1, nPaths); + + for ip = 1:nPaths + path = SVGstrPath{ip}; + + % Match data + [s e te m] = regexpi (path, 'd="(?:(?!").)*'); + data=strtrim (m{1}); + % parse data + d = parsePathData (data); + SVGpath(ip).coord = d.coord; + SVGpath(ip).closed = d.closed; + + % Match id + [s e te m] = regexp (path, 'id="(?:(?!").)*'); + if ~isempty (m) + SVGpath(ip).id = strtrim (m{1}(5:end)); + end + end + +end + +function d = parsePathData (data) + + d = struct ('coord', [], 'closed', []); + + [s e te comm] = regexp (data, '[MmLlHhVvCcSsQqTtAaZz]{1}'); + % TODO + % This info could be used to preallocate d + [zcomm zpos] = ismember ({'Z','z'}, comm); + + if any (zcomm) + d.closed = true; + else + d.closed = false; + s(end+1) = length (data); + end + comm(zpos(zcomm)) = []; + ncomm = size (comm, 2); + for ic = 1:ncomm + + switch comm{ic} + case {'M','L'} + [x y] = strread (data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + coord = [x y]; + + case 'm' + [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + nc = size (x, 1); + coord = [x y]; + if ic == 1 + % relative moveto at begining of data. + % First coordinates are absolute, the rest are relative. + coord = cumsum (coord); + else + % Relative moveto. + % The coordinates are relative to the last one loaded + coord(1,:) =coord(1,:) + d.coord(end,:); + coord = cumsum(coord); + warning('svg2octWarning',['Relative moveto in path data.'... + ' May mean that the orginal path was not a simple polygon.' ... + ' If that is the case, the path will not display equally.']) + end + + case 'l' + % Relative lineto, coordinates are relative to last point loaded. + [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + nc = size (x, 1); + coord = [x y] + coord(1,:) =coord(1,:) + d.coord(end,:); + coord = cumsum(coord); + + otherwise + warning('svg2oct:Warning',... + 'Path data command "%s" not implemented yet.',comm{ic}); + end + + nc = size(coord,1); + d.coord(end+1:end+nc,:) = coord; + + end +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/inst/io/deprecated/_parsePath.py Sat Jun 16 09:34:54 2012 +0000 @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import inkex, simplepath +import sys +#import getopt + +def parsePaths (filen=None): + + svg = inkex.Effect () + svg.parse (filen) + + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) + for path in paths: + D = simplepath.parsePath (path.attrib['d']) + cmdlst = []; + parlst = []; + for cmd,params in D: + cmdlst.append(cmd) + parlst.append(params) + + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ + .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) + + print 'svgpathid = "{0}"; $'.format(path.attrib['id']) + + + +# ---------------------------- + +if __name__=="__main__": + ''' + try: + optlist,args = getopt.getopt(sys.argv[1:],"thdp") + except getopt.GetoptError: + usage() + sys.exit(2) + + doHelp = 0 + c = Context() + c.doPrint = 1 + for opt in optlist: + if opt[0] == "-d": c.debug = 1 + if opt[0] == "-p": c.plot = 1 + if opt[0] == "-t": c.triangulate = 1 + if opt[0] == "-h": doHelp = 1 + + if not doHelp: + pts = [] + fp = sys.stdin + if len(args) > 0: + fp = open(args[0],'r') + for line in fp: + fld = line.split() + x = float(fld[0]) + y = float(fld[1]) + pts.append(Site(x,y)) + if len(args) > 0: fp.close() + + if doHelp or len(pts) == 0: + usage() + sys.exit(2) + ''' + svg = sys.argv[1] + parsePaths(svg)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/inst/io/deprecated/formatSVGstr.m Sat Jun 16 09:34:54 2012 +0000 @@ -0,0 +1,24 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function svgF = formatSVGstr(svg) + + % Remove all newlines and tabs + svgF = strrep(svg,"\n",' '); + svgF = strrep(svgF,"\t",' '); + % Remove consecutive blanks + svgF = regexprep(svgF,' +',' '); + +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/inst/io/deprecated/getSVGPaths_py.m Sat Jun 16 09:34:54 2012 +0000 @@ -0,0 +1,113 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function Paths = getSVGPaths_py (svg, varargin) + + %% Call python script + if exist (svg,'file') + % read from file + [st str]=system (sprintf ('python parsePath.py %s', svg)); + + else + % inline SVG + [st str]=system (sprintf ('python parsePath.py < %s', svg)); + end + + %% Parse ouput + strpath = strsplit (str(1:end-1), '$', true); + + npaths = numel (strpath); + + %% Convert path data to polygons + for ip = 1:npaths + + eval (strpath{ip}); + %% FIXME: intialize struct with cell field + svgpath2.cmd = svgpath(1).cmd; + svgpath2.data = {svgpath.data}; + + nD = length(svgpath2.cmd); + pathdata = cell (nD-1,1); + + point_end=[]; + %% If the path is closed, last command is Z and we set initial point == final + if svgpath2.cmd(end) == 'Z' + nD -= 1; + point_end = svgpath2.data{1}; + end + + %% Initial point + points(1,:) = svgpath2.data{1}; + + for jp = 2:nD + switch svgpath2.cmd(jp) + case 'L' + %% Straigth segment to polygon + points(2,:) = svgpath2.data{jp}; + pp = [(points(2,:)-points(1,:))' points(1,:)']; + clear points + points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; + + case 'C' + %% Cubic bezier to polygon + points(2:4,:) = reshape (svgpath2.data{jp}, 2, 3).'; + pp = cbezier2poly (points); + clear points + points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; + end + + pathdata{jp-1} = pp; + end + + if ~isempty(point_end) + %% Straight segmet to close the path + points(2,:) = point_end; + pp = [(points(2,:)-points(1,:))' points(1,:)']; + + pathdata{end} = pp; + end + + Paths.(svgpathid).data = pathdata; + end +endfunction + +%!test +%! figure(1) +%! hold on +%! paths = getSVGPaths_py ('../drawing.svg'); +%! +%! % Get path ids +%! ids = fieldnames(paths); +%! npath = numel(ids); +%! +%! t = linspace (0, 1, 64); +%! +%! for i = 1:npath +%! x = []; y = []; +%! data = paths.(ids(i)).data; +%! +%! for j = 1:numel(data) +%! x = cat (2, x, polyval (data{j}(1,:),t)); +%! y = cat (2, y, polyval (data{j}(2,:),t)); +%! end +%! +%! plot(x,y,'-'); +%! end +%! axis ij +%! if strcmpi(input('You should see drawing.svg [y/n] ','s'),'n') +%! error ("didn't get what was expected."); +%! end +%! close +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/inst/io/deprecated/getSVGdata.m Sat Jun 16 09:34:54 2012 +0000 @@ -0,0 +1,33 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function svgData = getSVGdata(svg) + + svgData = struct('height',[],'width',[]); + attr = fieldnames(svgData); + nattr = numel(attr); + + [s e te data] = regexpi(svg,'<[ ]*svg(?:(?!>).)*>'); + data=strtrim(data{1}); + + for a = 1:nattr + pattr =sprintf('%s="(?:(?!").)*',attr{a}); + [s e te m] = regexpi(data,pattr); + m=strtrim(m{1}); + [dummy value] = strread(m,'%s%f','delimiter','"'); + svgData.(attr{a}) = value; + end + +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/inst/io/deprecated/getSVGstrPath.m Sat Jun 16 09:34:54 2012 +0000 @@ -0,0 +1,20 @@ +%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function strPath = getSVGstrPath(svg) + + [s e te strPath] = regexpi(svg,'<[ ]*path(?:(?!/>).)*/>'); + +end
--- a/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m Sat Jun 16 09:20:42 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function SVGpath = SVGstrPath2SVGpath (SVGstrPath) - - nPaths = numel (SVGstrPath); - SVGpath = repmat (struct('coord', [], 'closed', [], 'id', []), 1, nPaths); - - for ip = 1:nPaths - path = SVGstrPath{ip}; - - % Match data - [s e te m] = regexpi (path, 'd="(?:(?!").)*'); - data=strtrim (m{1}); - % parse data - d = parsePathData (data); - SVGpath(ip).coord = d.coord; - SVGpath(ip).closed = d.closed; - - % Match id - [s e te m] = regexp (path, 'id="(?:(?!").)*'); - if ~isempty (m) - SVGpath(ip).id = strtrim (m{1}(5:end)); - end - end - -end - -function d = parsePathData (data) - - d = struct ('coord', [], 'closed', []); - - [s e te comm] = regexp (data, '[MmLlHhVvCcSsQqTtAaZz]{1}'); - % TODO - % This info could be used to preallocate d - [zcomm zpos] = ismember ({'Z','z'}, comm); - - if any (zcomm) - d.closed = true; - else - d.closed = false; - s(end+1) = length (data); - end - comm(zpos(zcomm)) = []; - ncomm = size (comm, 2); - for ic = 1:ncomm - - switch comm{ic} - case {'M','L'} - [x y] = strread (data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - coord = [x y]; - - case 'm' - [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - nc = size (x, 1); - coord = [x y]; - if ic == 1 - % relative moveto at begining of data. - % First coordinates are absolute, the rest are relative. - coord = cumsum (coord); - else - % Relative moveto. - % The coordinates are relative to the last one loaded - coord(1,:) =coord(1,:) + d.coord(end,:); - coord = cumsum(coord); - warning('svg2octWarning',['Relative moveto in path data.'... - ' May mean that the orginal path was not a simple polygon.' ... - ' If that is the case, the path will not display equally.']) - end - - case 'l' - % Relative lineto, coordinates are relative to last point loaded. - [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - nc = size (x, 1); - coord = [x y] - coord(1,:) =coord(1,:) + d.coord(end,:); - coord = cumsum(coord); - - otherwise - warning('svg2oct:Warning',... - 'Path data command "%s" not implemented yet.',comm{ic}); - end - - nc = size(coord,1); - d.coord(end+1:end+nc,:) = coord; - - end -end
--- a/main/geometry/inst/io/deprecated/private/_parsePath.py Sat Jun 16 09:20:42 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import inkex, simplepath -import sys -#import getopt - -def parsePaths (filen=None): - - svg = inkex.Effect () - svg.parse (filen) - - paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) - for path in paths: - D = simplepath.parsePath (path.attrib['d']) - cmdlst = []; - parlst = []; - for cmd,params in D: - cmdlst.append(cmd) - parlst.append(params) - - print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ - .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) - - print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - - -# ---------------------------- - -if __name__=="__main__": - ''' - try: - optlist,args = getopt.getopt(sys.argv[1:],"thdp") - except getopt.GetoptError: - usage() - sys.exit(2) - - doHelp = 0 - c = Context() - c.doPrint = 1 - for opt in optlist: - if opt[0] == "-d": c.debug = 1 - if opt[0] == "-p": c.plot = 1 - if opt[0] == "-t": c.triangulate = 1 - if opt[0] == "-h": doHelp = 1 - - if not doHelp: - pts = [] - fp = sys.stdin - if len(args) > 0: - fp = open(args[0],'r') - for line in fp: - fld = line.split() - x = float(fld[0]) - y = float(fld[1]) - pts.append(Site(x,y)) - if len(args) > 0: fp.close() - - if doHelp or len(pts) == 0: - usage() - sys.exit(2) - ''' - svg = sys.argv[1] - parsePaths(svg)
--- a/main/geometry/inst/io/deprecated/private/formatSVGstr.m Sat Jun 16 09:20:42 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function svgF = formatSVGstr(svg) - - % Remove all newlines and tabs - svgF = strrep(svg,"\n",' '); - svgF = strrep(svgF,"\t",' '); - % Remove consecutive blanks - svgF = regexprep(svgF,' +',' '); - -end
--- a/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m Sat Jun 16 09:20:42 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function Paths = getSVGPaths_py (svg, varargin) - - %% Call python script - if exist (svg,'file') - % read from file - [st str]=system (sprintf ('python parsePath.py %s', svg)); - - else - % inline SVG - [st str]=system (sprintf ('python parsePath.py < %s', svg)); - end - - %% Parse ouput - strpath = strsplit (str(1:end-1), '$', true); - - npaths = numel (strpath); - - %% Convert path data to polygons - for ip = 1:npaths - - eval (strpath{ip}); - %% FIXME: intialize struct with cell field - svgpath2.cmd = svgpath(1).cmd; - svgpath2.data = {svgpath.data}; - - nD = length(svgpath2.cmd); - pathdata = cell (nD-1,1); - - point_end=[]; - %% If the path is closed, last command is Z and we set initial point == final - if svgpath2.cmd(end) == 'Z' - nD -= 1; - point_end = svgpath2.data{1}; - end - - %% Initial point - points(1,:) = svgpath2.data{1}; - - for jp = 2:nD - switch svgpath2.cmd(jp) - case 'L' - %% Straigth segment to polygon - points(2,:) = svgpath2.data{jp}; - pp = [(points(2,:)-points(1,:))' points(1,:)']; - clear points - points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; - - case 'C' - %% Cubic bezier to polygon - points(2:4,:) = reshape (svgpath2.data{jp}, 2, 3).'; - pp = cbezier2poly (points); - clear points - points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; - end - - pathdata{jp-1} = pp; - end - - if ~isempty(point_end) - %% Straight segmet to close the path - points(2,:) = point_end; - pp = [(points(2,:)-points(1,:))' points(1,:)']; - - pathdata{end} = pp; - end - - Paths.(svgpathid).data = pathdata; - end -endfunction - -%!test -%! figure(1) -%! hold on -%! paths = getSVGPaths_py ('../drawing.svg'); -%! -%! % Get path ids -%! ids = fieldnames(paths); -%! npath = numel(ids); -%! -%! t = linspace (0, 1, 64); -%! -%! for i = 1:npath -%! x = []; y = []; -%! data = paths.(ids(i)).data; -%! -%! for j = 1:numel(data) -%! x = cat (2, x, polyval (data{j}(1,:),t)); -%! y = cat (2, y, polyval (data{j}(2,:),t)); -%! end -%! -%! plot(x,y,'-'); -%! end -%! axis ij -%! if strcmpi(input('You should see drawing.svg [y/n] ','s'),'n') -%! error ("didn't get what was expected."); -%! end -%! close -
--- a/main/geometry/inst/io/deprecated/private/getSVGdata.m Sat Jun 16 09:20:42 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function svgData = getSVGdata(svg) - - svgData = struct('height',[],'width',[]); - attr = fieldnames(svgData); - nattr = numel(attr); - - [s e te data] = regexpi(svg,'<[ ]*svg(?:(?!>).)*>'); - data=strtrim(data{1}); - - for a = 1:nattr - pattr =sprintf('%s="(?:(?!").)*',attr{a}); - [s e te m] = regexpi(data,pattr); - m=strtrim(m{1}); - [dummy value] = strread(m,'%s%f','delimiter','"'); - svgData.(attr{a}) = value; - end - -end
--- a/main/geometry/inst/io/deprecated/private/getSVGstrPath.m Sat Jun 16 09:20:42 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% This program is free software: you can redistribute it and/or modify -%% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation, either version 3 of the License, or -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function strPath = getSVGstrPath(svg) - - [s e te strPath] = regexpi(svg,'<[ ]*path(?:(?!/>).)*/>'); - -end