Ajout de l'option bbox pour la macro \meshAddOnePoint
[delaunay.git] / luamesh.sty
1 \NeedsTeXFormat{LaTeX2e}%
2 \def\PackageName{luamesh}%
3 \def\fileversion{v0.1}%
4 \def\filedate{2016/11/20}%
5 \ProvidesPackage{luamesh}[\filedate\space\fileversion]%
6 %
7 % package to load
8 \RequirePackage{xkeyval,xcolor,ifthen}%
9 %% one global option: mp or tikz
10 %\newif\ifluameshmp%
11 %\define@key{luamesh.sty}{mp}[]{\luameshmptrue}%
12 %\define@key{luamesh.sty}{tikz}[]{\luameshmpfalse}%
13 %
14 \RequirePackage{etoolbox} % pour robustifier les commandes
15 %
16 %
17 %\ifluameshmp%
18    \RequirePackage{luamplib}%
19 %\else%
20    \RequirePackage{tikz}%
21 %\fi%
22 %
23 % load the lua code
24 \directlua{dofile("luamesh.lua")}%
25 %
26 % global def (default value)
27 \newcommand{\MeshPoint}{P}
28 \newcommand{\NewPoint}{P}
29 % for MetaPost (MP) (default value)
30 % default scale u:=1cm;
31 \newcommand\luaMeshScaleMP{1cm}
32 % default color for the plot of a global mesh
33 \newcommand\TeXCluaMeshMP{(0.,0.,0.)}
34 % default color for a new element
35 \newcommand\TeXCluaMeshNewMP{(0.5,0.1,0.1)}
36 % defaut color for the background of new element
37 \newcommand\TeXCluaMeshBackMP{(0.99,0.85,0.85)}
38 % default color for circoncircle
39 \newcommand\TeXCluaMeshCircleMP{(0.1,0.6,0.1)}
40 %%
41 % for tikz (default value)
42 % default color for the plot of a global mesh
43 \definecolor{TeXCluaMeshTikZ}{rgb}{0.,0.,0.}
44 % default color for a new element
45 \definecolor{TeXCluaMeshNewTikZ}{rgb}{0.5,0.1,0.1}
46 % defaut color for the background of new element
47 \definecolor{TeXCluaMeshBackTikZ}{rgb}{0.99,0.85,0.85}
48 % default color for circoncircle
49 \definecolor{TeXCluaMeshCircleTikZ}{rgb}{0.1,0.6,0.1}
50
51
52 %%%%%%%%%%%%%%%% the buildMesh command
53 %% engine of drawing
54 \newif\ifluameshengineMP%
55 \define@boolkey{buildMesh}{tikz}[true]{}%
56 %% show the bounding box for delaunay
57 \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{%
58   \ifcase\nr\relax%
59   \def\luameshval@bbox{none}%
60   \or%
61   \def\luameshval@bbox{bbox}%
62   \fi%
63 }%
64 %% the scale
65 \define@key{buildMesh}{scale}[1cm]{\def\luameshval@scale{#1}}%
66 %% print ponits ?
67 \define@choicekey*{buildMesh}{print}[\val\nr]{none, points}{%
68   \ifcase\nr\relax%
69   \def\luameshval@print{none}%
70   \or%
71   \def\luameshval@print{points}%
72   \fi%
73 }%
74 %% the name of the point
75 \define@key{buildMesh}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
76 %% the mode for reading the points
77 \define@choicekey*{buildMesh}{mode}[\val\nr]{int, ext}{%
78   \ifcase\nr\relax%
79   \def\luameshval@mode{int}%
80   \or%
81   \def\luameshval@mode{ext}%
82   \fi%
83 }%
84 %
85 %% a complete picture or some code of the engine
86 \define@choicekey*{buildMesh}{picture}[\val\nr]{full, embedded}{%
87   \ifcase\nr\relax%
88   \def\luameshval@picture{full}%
89   \or%
90   \def\luameshval@picture{embedded}%
91   \fi%
92 }%
93 %color
94 %% the name of the color of drawing
95 \define@key{buildMesh}{color}[black]{\def\luameshval@color{#1}}%
96
97 \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,picture=full,color}{}%
98 %
99 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 % the difinition
101 \newcommand{\buildMesh}[2][]{%
102   % #1 : the string containing the list of points
103   % (x1,y1);(x2,y2);... or the name file containing the points
104   \setkeys{buildMesh}{#1} %
105   \def\MeshPoint{\luameshval@meshpoint}%
106   \ifKV@buildMesh@tikz% if we are using tikz
107   \directlua{%
108     buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
109   }%
110   \else % we are using MP
111   \directlua{%
112     buildMeshMP("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
113   }%
114   %
115   \fi%
116 }%
117 %
118 %%
119 %
120 %%the meshAddOnePoint commande
121 %%engine of drawing
122 \newif\ifluameshengineMP%
123 \define@boolkey{MeshAddOne}{tikz}[true]{}%
124 %% the scale
125 \define@key{MeshAddOne}{scale}[1cm]{\def\luameshval@scale{#1}}%
126 %% the name of the points
127 \define@key{MeshAddOne}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}%
128 %% the name of the new point
129 \define@key{MeshAddOne}{newpoint}[P]{\def\luameshval@newpoint{#1}}%
130 %% a complete picture or some code of the engine
131 \define@choicekey*{MeshAddOne}{picture}[\val\nr]{full, simple}{%
132   \ifcase\nr\relax%
133   \def\luameshval@picture{full}%
134   \or%
135   \def\luameshval@picture{simple}%
136   \fi%
137 }%
138 %% a complete picture or some code of the engine
139 \define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{%
140   \ifcase\nr\relax%
141   \def\luameshval@step{badT}%
142   \or%
143   \def\luameshval@step{cavity}%
144   \or%
145   \def\luameshval@step{newT}%
146   \fi%
147 }%
148 % color
149 %% the color of drawing
150 \define@key{MeshAddOne}{color}[black]{\def\luameshval@color{#1}}%
151 %% the color of background of new element
152 \define@key{MeshAddOne}{colorBack}[black!20]{\def\luameshval@colorback{#1}}%
153 %% the color of new element
154 \define@key{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}%
155 %% the color of circoncircle
156 \define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}%
157 %
158 %% a complete picture or some code of the engine
159 \define@choicekey*{MeshAddOne}{mode}[\val\nr]{int, ext}{%
160   \ifcase\nr\relax%
161   \def\luameshval@mode{int}%
162   \or%
163   \def\luameshval@mode{ext}%
164   \fi%
165 }%
166 %% a complete picture or some code of the engine
167 \define@choicekey*{MeshAddOne}{picture}[\val\nr]{full, embedded}{%
168   \ifcase\nr\relax%
169   \def\luameshval@picture{full}%
170   \or%
171   \def\luameshval@picture{embedded}%
172   \fi%
173 }%
174 \define@choicekey*{MeshAddOne}{bbox}[\val\nr]{none, show}{%
175   \ifcase\nr\relax%
176   \def\luameshval@bbox{none}%
177   \or%
178   \def\luameshval@bbox{bbox}%
179   \fi%
180 }%
181 \presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,picture=full,bbox=none}{}%
182 %
183 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 % the difinition
185 \newcommand{\meshAddOnePoint}[3][]{%
186   % #1 : the string containing the list of points
187   % (x1,y1);(x2,y2);... or the name file containing the points
188   \setkeys{MeshAddOne}{#1} %
189   \def\MeshPoint{\luameshval@meshpoint}%
190   \def\NewPoint{\luameshval@newpoint}%
191   \ifKV@MeshAddOne@tikz% if we are using tikz
192   \directlua{%
193     buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")%
194   }%
195   \else % we are using MP
196   \directlua{%
197     TeXOnePointMP("#2","#3","\luameshval@step","\luameshval@color","\luameshval@colorback","\luameshval@colornew","\luameshval@colorcircle","\luameshval@scale","\luameshval@mode","\luameshval@picture","\luameshval@bbox")%
198   }%
199   %
200   \fi%
201 }%
202 %

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.