# 2. A simple 2D example¶

## 2.1. Installation¶

Before to start you need to add the geomIO src folders to your matlab path. To do that run the file

## 2.2. Drawing¶

Open Inkscape, draw one shape and save as an “Inkscape SVG” file (default file format). In this example I drew a rabbit which I called Lapinou. He’s gonna be our mascot through this tutorial.

Open the XML editor and add new attributes to assign a phase number (not optional) and a label (optional). This can be done by clicking on any attribute then overwrite the attribute name and value, then click ‘Set’.

## 2.3. Assigning phase to markers¶

In matlab, initialize geomIO and extract the coordinates:

opt                 = geomIO_Options();
opt.inputFileName   = ['./Input/LapinouAndFriends.svg'];
[PathCoord]         = run_geomIO(opt,'2D');


geomIO_Options() is a class containing information about the svg file, coordinate system, and various options. Details [here]. Here, a set of default values has been assigned to opt. In this example only opt.inputFileName must be specified, all other options can remain at their default value.

PathCoord is a struct that stores relevant information about the shapes drawn, such as coordinates, style (color, stroke, etc ...), phase, label, etc... A complete description of PathCoord can be found [here].

Next, define a set of markers as a set of three matrices containing X coordinate, Y coordinate and phase number of all markers, respectively. Here we will use the “paper sheet” from the svg file as our box.

xmin = 0; xmax = opt.svg.width;
ymin = 0; ymax = opt.svg.height;
[Xp,Yp]      = ndgrid(xmin:15:xmax,ymin:15:ymax);
Phase        = zeros(size(Xp));


Then assign a phase to each marker according to your drawing.

Phase = assignPhase2Markers(PathCoord, opt, Xp, Yp, Phase)


That’s it!

## 2.4. Multiple shapes¶

Draw multiples shapes. Don’t forget to add a phase and a label (optional) to each one of them (See section 1).

The code shown in the previous section works for multiple shapes as well!

note: transparency is taken into account by svgPlot by specifying the Alpha value of the fill color in Inkscape. (The opacity value set with the Opacity slider is however not read).

## 2.5. Plotting in Matlab¶

figure(1)
plotSVG(PathCoord,opt)


Then you can check if the phases were assigned properly.

figure(2)
scatter(Xp(:),Yp(:),10,Phase(:),'filled');
% imagesc(Xp(:,1),Yp(1,:),Phase'); % alternative plot
axis equal
axis([xmin xmax ymin ymax])


You can plot the contours of the drawing on top using:

hold on
plotSVG(PathCoord,opt,0)


You can also create a colormap according to the filling colors used in your drawing.

[CMAP, PhaseMax] = getColormapFromPathCoord(PathCoord,[.8 .8 .8]); % the second argument is optional and specifies to RGB color of phase 0 (if no shape with phase 0 is found), it is white by default
colormap(CMAP)
caxis([-.5 PhaseMax+.5]);  colorbar('YTick',0:PhaseMax)


The figure above shows the result of the function svgPlot (A) and a scatter plot of markers (B) with colors coding for the phase number.

# 5. Creating a body-fitted mesh

# 6. Mixing paths read from files and paths coded in Matlab

# 7. Note on compatibility

All present tutorials are specific to Inkscape. Illustrator is also supported by geomIO, however, due to the impossibility to edit the XML files directly in Illustrator, a few steps differ. See [this page] for details. geomIO has been tested with Matlab 2013a and more recent versions. All or part of geomIO might also be compatible with Octave, however this has not been tested. geomIO uses Matlab mex-files (C compiled code) for performance intensive operations. Mex-files would give lower performance in Octave.