From: Maxime Chupin (escudo) Date: Wed, 23 Nov 2016 19:35:37 +0000 (+0100) Subject: Clean up du code luamesh.sty X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=commitdiff_plain;h=c1ef14a73d2abc89fce006d960288a9c8a0f82c3;p=delaunay.git Clean up du code luamesh.sty --- diff --git a/luamesh.sty b/luamesh.sty index ccb1863..006b254 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -36,70 +36,68 @@ %%%%%%%%%%%%%%%% the buildMesh command -%% engine of drawing -\newif\ifluameshengineMP% +%% the user can write code (tikz or MP) +%% before and after the generated code \define@boolkey{buildMeshInc}{tikz}[true]{}% %% show the bounding box for delaunay \define@choicekey*{buildMeshInc}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@bm@bbox{none}% + \def\luameshval@bmi@bbox{none}% \or% - \def\luameshval@bm@bbox{bbox}% + \def\luameshval@bmi@bbox{bbox}% \fi% }% %% the scale -\define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bm@scale{#1}}% +\define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bmi@scale{#1}}% %% print ponits ? \define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points}{% \ifcase\nr\relax% - \def\luameshval@bm@print{none}% + \def\luameshval@bmi@print{none}% \or% - \def\luameshval@bm@print{points}% + \def\luameshval@bmi@print{points}% \fi% }% %% the name of the point -\define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}% +\define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bmi@meshpoint{#1}}% %% the mode for reading the points \define@choicekey*{buildMeshInc}{mode}[\val\nr]{int, ext}{% \ifcase\nr\relax% - \def\luameshval@bm@mode{int}% + \def\luameshval@bmi@mode{int}% \or% - \def\luameshval@bm@mode{ext}% + \def\luameshval@bmi@mode{ext}% \fi% }% -% -%color %% the name of the color of drawing -\define@key{buildMeshInc}{color}[black]{\def\luameshval@bm@color{#1}}% +\define@key{buildMeshInc}{color}[black]{\def\luameshval@bmi@color{#1}}% %% the name of the color of drawing the bbox -\define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}% +\define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bmi@colorbbox{#1}}% % \presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% % -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition BW Bowyer and Watson algo \newcommand*{\buildMeshBWinc}[4][]{% - % #1 : the string containing the list of points - % (x1,y1);(x2,y2);... or the name file containing the points + % #1 : optionnal arguments + % #2 : the string containing the list of points + % (x1,y1);(x2,y2);... or the name file containing the points + % #3 : the code to place before the generated one + % #4 : the code to place after the generated one \setkeys{buildMesh}{#1} % - \def\MeshPoint{\luameshval@bm@meshpoint}% + \def\MeshPoint{\luameshval@bmi@meshpoint}% \ifKV@buildMesh@tikz% if we are using tikz \directlua{% - buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")% + buildMeshTikZ("#2","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","full","\luameshval@bmi@scale","\luameshval@bmi@color")% }% \else % we are using MP - \mplibcolor{\luameshmpcolor}{\luameshval@bm@color} - \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox} + \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox} \directlua{% - buildMeshMPBWinc("#2","#3","#4","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")% + buildMeshMPBWinc("#2","#3","#4","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale")% }% % \fi% }% % %%%%%%%%%%%%%%%% the buildMeshBW command -%% engine of drawing -\newif\ifluameshengineMP% +%% the code is complete and we don't have any callbacks \define@boolkey{buildMesh}{tikz}[true]{}% %% show the bounding box for delaunay \define@choicekey*{buildMesh}{bbox}[\val\nr]{none, show}{% @@ -129,8 +127,6 @@ \def\luameshval@bm@mode{ext}% \fi% }% -% -% color %% the name of the color of drawing \define@key{buildMesh}{color}[black]{\def\luameshval@bm@color{#1}}% %% the name of the color of drawing the bbox @@ -138,10 +134,9 @@ % \presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% % -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition BW Bowyer and Watson algo \newcommand{\buildMeshBW}[2][]{% - % #1 : the string containing the list of points + % #1 : optionnal arguments + % #2 : the string containing the list of points % (x1,y1);(x2,y2);... or the name file containing the points \setkeys{buildMesh}{#1} % \def\MeshPoint{\luameshval@bm@meshpoint}% @@ -159,9 +154,10 @@ \fi% }% % +% %%%%%%%%%%%%%%%%% the trace Points macro -%% engine of drawing -\newif\ifluameshengineMP% +%% plot the list of points given in argument +% the engine \define@boolkey{tracePoints}{tikz}[true]{}% %% show the bounding box for delaunay \define@choicekey*{tracePoints}{bbox}[\val\nr]{none, show}{% @@ -191,8 +187,6 @@ \def\luameshval@tp@mode{ext}% \fi% }% -% -% color %% the name of the color of drawing \define@key{tracePoints}{color}[black]{\def\luameshval@tp@color{#1}}% %% the name of the color of drawing the bbox @@ -200,10 +194,9 @@ % \presetkeys{tracePoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% % -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition BW Bowyer and Watson algo \newcommand{\tracePointsMesh}[2][]{% - % #1 : the string containing the list of points + % #1 : optionnal arguments + % #2 : the string containing the list of points % (x1,y1);(x2,y2);... or the name file containing the points \setkeys{tracePoints}{#1} % \def\MeshPoint{\luameshval@tp@meshpoint}% @@ -222,211 +215,213 @@ }% % -%%%%%%%%%%%%%%%% the trace Points macro inc +%%%%%%%%%%%%%%%% the trace Points macro inc with callbacks %% engine of drawing -\newif\ifluameshengineMP% \define@boolkey{tracePointsInc}{tikz}[true]{}% %% show the bounding box for delaunay \define@choicekey*{tracePointsInc}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@tp@bbox{none}% + \def\luameshval@tpi@bbox{none}% \or% - \def\luameshval@tp@bbox{bbox}% + \def\luameshval@tpi@bbox{bbox}% \fi% }% %% the scale -\define@key{tracePointsInc}{scale}[1cm]{\def\luameshval@tp@scale{#1}}% +\define@key{tracePointsInc}{scale}[1cm]{\def\luameshval@tpi@scale{#1}}% %% print points \define@choicekey*{tracePointsInc}{print}[\val\nr]{none, points}{% \ifcase\nr\relax% - \def\luameshval@tp@print{none}% + \def\luameshval@tpi@print{none}% \or% - \def\luameshval@tp@print{points}% + \def\luameshval@tpi@print{points}% \fi% }% %% the name of the point -\define@key{tracePointsInc}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}% +\define@key{tracePointsInc}{meshpoint}[P]{\def\luameshval@tpi@meshpoint{#1}}% %% the mode for reading the points \define@choicekey*{tracePointsInc}{mode}[\val\nr]{int, ext}{% \ifcase\nr\relax% - \def\luameshval@tp@mode{int}% + \def\luameshval@tpi@mode{int}% \or% - \def\luameshval@tp@mode{ext}% + \def\luameshval@tpi@mode{ext}% \fi% }% % % color %% the name of the color of drawing -\define@key{tracePointsInc}{color}[black]{\def\luameshval@tp@color{#1}}% +\define@key{tracePointsInc}{color}[black]{\def\luameshval@tpi@color{#1}}% %% the name of the color of drawing the bbox -\define@key{tracePointsInc}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}% +\define@key{tracePointsInc}{colorBbox}[black]{\def\luameshval@tpi@colorbbox{#1}}% % \presetkeys{tracePointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition BW Bowyer and Watson algo \newcommand*{\tracePointsMeshinc}[4][]{% - % #1 : the string containing the list of points + % #1 : optionnal arguments + % #2 : the string containing the list of points % (x1,y1);(x2,y2);... or the name file containing the points + % #3 : the code to place before the generated one + % #4 : the code to place after the generated one \setkeys{tracePointsInc}{#1} % - \def\MeshPoint{\luameshval@tp@meshpoint}% + \def\MeshPoint{\luameshval@tpi@meshpoint}% \ifKV@tracePointsInc@tikz% if we are using tikz \directlua{% - buildMeshTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","full","\luameshval@tp@sc%ale","\luameshval@tp@color")% + buildMeshTikZ("#2","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","full","\luameshval@tpi@sc%ale","\luameshval@tpi@color")% }% \else % we are using MP - \mplibcolor{\luameshmpcolor}{\luameshval@tp@color} - \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox} + \mplibcolor{\luameshmpcolor}{\luameshval@tpi@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox} \directlua{% - printPointsMPinc("#2","#3","#4","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")% + printPointsMPinc("#2","#3","#4","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")% }% \fi% }% % -% -%% -% -%%the meshAddOnePointBW commande +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% the meshAddOnePointBW commande %%engine of drawing -\newif\ifluameshengineMP% -\define@boolkey{MeshAddOne}{tikz}[true]{}% +\define@boolkey{MeshAddOneBW}{tikz}[true]{}% %% the scale -\define@key{MeshAddOne}{scale}[1cm]{\def\luameshval@scale{#1}}% +\define@key{MeshAddOneBW}{scale}[1cm]{\def\luameshval@ap@scale{#1}}% %% the name of the points -\define@key{MeshAddOne}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}% +\define@key{MeshAddOneBW}{meshpoint}[P]{\def\luameshval@ap@meshpoint{#1}}% %% the name of the new point -\define@key{MeshAddOne}{newpoint}[P]{\def\luameshval@newpoint{#1}}% +\define@key{MeshAddOneBW}{newpoint}[P]{\def\luameshval@ap@newpoint{#1}}% %% a complete picture or some code of the engine -\define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{% +\define@choicekey*{MeshAddOneBW}{step}[\val\nr]{badtriangles, cavity, newtriangles}{% \ifcase\nr\relax% - \def\luameshval@step{badT}% + \def\luameshval@ap@step{badT}% \or% - \def\luameshval@step{cavity}% + \def\luameshval@ap@step{cavity}% \or% - \def\luameshval@step{newT}% + \def\luameshval@ap@step{newT}% \fi% }% % color %% the color of drawing -\define@key{MeshAddOne}{color}[black]{\def\luameshval@color{#1}}% +\define@key{MeshAddOneBW}{color}[black]{\def\luameshval@ap@color{#1}}% %% the color of background of new element -\define@key{MeshAddOne}{colorBack}[black!20]{\def\luameshval@colorback{#1}}% +\define@key{MeshAddOneBW}{colorBack}[black!20]{\def\luameshval@ap@colorback{#1}}% %% the color of new element -\define@key{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}% +\define@key{MeshAddOneBW}{colorNew}[red]{\def\luameshval@ap@colornew{#1}}% %% the color of circoncircle -\define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}% +\define@key{MeshAddOneBW}{colorCircle}[green]{\def\luameshval@ap@colorcircle{#1}}% %% the name of the color of drawing the bbox -\define@key{MeshAddOne}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}% +\define@key{MeshAddOneBW}{colorBbox}[black]{\def\luameshval@ap@colorbbox{#1}}% % %% a complete picture or some code of the engine -\define@choicekey*{MeshAddOne}{mode}[\val\nr]{int, ext}{% +\define@choicekey*{MeshAddOneBW}{mode}[\val\nr]{int, ext}{% \ifcase\nr\relax% - \def\luameshval@mode{int}% + \def\luameshval@ap@mode{int}% \or% - \def\luameshval@mode{ext}% + \def\luameshval@ap@mode{ext}% \fi% }% -\define@choicekey*{MeshAddOne}{bbox}[\val\nr]{none, show}{% +\define@choicekey*{MeshAddOneBW}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@bbox{none}% + \def\luameshval@ap@bbox{none}% \or% - \def\luameshval@bbox{bbox}% + \def\luameshval@ap@bbox{bbox}% \fi% }% -\presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}% +\presetkeys{MeshAddOneBW}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition BW Bowyer and Watson algo \newcommand*{\meshAddPointBW}[3][]{% - % #1 : the string containing the list of points + % #1 : optionnal arguments + % #2 : the string containing the list of points % (x1,y1);(x2,y2);... or the name file containing the points - \setkeys{MeshAddOne}{#1} % - \def\MeshPoint{\luameshval@meshpoint}% - \def\NewPoint{\luameshval@newpoint}% + % #3 : the code to place before the generated one + % #4 : the code to place after the generated one + \setkeys{MeshAddOneBW}{#1} % + \def\MeshPoint{\luameshval@ap@meshpoint}% + \def\NewPoint{\luameshval@ap@newpoint}% \ifKV@MeshAddOne@tikz% if we are using tikz \directlua{% - buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")% + buildMeshTikZ("#2","\luameshval@ap@mode","\luameshval@ap@print","\luameshval@ap@bbox","full","\luameshval@ap@scale","\luameshval@ap@color")% }% \else % we are using MP - \mplibcolor{\luameshmpcolor}{\luameshval@color} - \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback} - \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew} - \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle} - \mplibcolor{\luameshmpcolorBbox}{\luameshval@colorbbox} + \mplibcolor{\luameshmpcolor}{\luameshval@ap@color} + \mplibcolor{\luameshmpcolorBack}{\luameshval@ap@colorback} + \mplibcolor{\luameshmpcolorNew}{\luameshval@ap@colornew} + \mplibcolor{\luameshmpcolorCircle}{\luameshval@ap@colorcircle} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@ap@colorbbox} \directlua{% - TeXOnePointMPBW("#2","#3","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")% + TeXOnePointMPBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox")% }% % \fi% }% -%%% the meshAddPointBWinc commande +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% the meshAddPointBWinc commande with callbacks %% engine of drawing -\newif\ifluameshengineMP% \define@boolkey{MeshAddOneBWinc}{tikz}[true]{}% %% the scale -\define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@scale{#1}}% +\define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@api@scale{#1}}% %% the name of the points -\define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}% +\define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@api@meshpoint{#1}}% %% the name of the new point -\define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@newpoint{#1}}% +\define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@api@newpoint{#1}}% %% a complete picture or some code of the engine \define@choicekey*{MeshAddOneBWinc}{step}[\val\nr]{badtriangles, cavity, newtriangles}{% \ifcase\nr\relax% - \def\luameshval@step{badT}% + \def\luameshval@api@step{badT}% \or% - \def\luameshval@step{cavity}% + \def\luameshval@api@step{cavity}% \or% - \def\luameshval@step{newT}% + \def\luameshval@api@step{newT}% \fi% }% % color %% the color of drawing -\define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@color{#1}}% +\define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@api@color{#1}}% %% the color of background of new element -\define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@colorback{#1}}% +\define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@api@colorback{#1}}% %% the color of new element -\define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@colornew{#1}}% +\define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@api@colornew{#1}}% %% the color of circoncircle -\define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}% -\define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}% +\define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@api@colorcircle{#1}}% +\define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@api@colorbbox{#1}}% % %% a complete picture or some code of the engine \define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{% \ifcase\nr\relax% - \def\luameshval@mode{int}% + \def\luameshval@api@mode{int}% \or% - \def\luameshval@mode{ext}% + \def\luameshval@api@mode{ext}% \fi% }% \define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@bbox{none}% + \def\luameshval@api@bbox{none}% \or% - \def\luameshval@bbox{bbox}% + \def\luameshval@api@bbox{bbox}% \fi% }% \presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition BW embedded code between the 2 last arguments \newcommand*{\meshAddPointBWinc}[5][]{% - % #1 : the string containing the list of points + % #1 : optionnal arguments + % #2 : the string containing the list of points % (x1,y1);(x2,y2);... or the name file containing the points + % #3 : the code to place before the generated one + % #4 : the code to place after the generated one \setkeys{MeshAddOneBWinc}{#1} % - \def\MeshPoint{\luameshval@meshpoint}% - \def\NewPoint{\luameshval@newpoint}% - \ifKV@MeshAddOne@tikz% if we are using tikz + \def\MeshPoint{\luameshval@api@meshpoint}% + \def\NewPoint{\luameshval@api@newpoint}% + \ifKV@MeshAddOneBWinc@tikz% if we are using tikz \directlua{% - buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")% + buildMeshTikZ("#2","\luameshval@api@mode","\luameshval@api@print","\luameshval@api@bbox","\luameshval@api@scale","\luameshval@api@color")% }% \else % we are using MP - \mplibcolor{\luameshmpcolor}{\luameshval@color} - \mplibcolor{\luameshmpcolorBack}{\luameshval@colorback} - \mplibcolor{\luameshmpcolorNew}{\luameshval@colornew} - \mplibcolor{\luameshmpcolorCircle}{\luameshval@colorcircle} - \mplibcolor{\luameshmpcolorBbox}{\luameshval@colorbbox} + \mplibcolor{\luameshmpcolor}{\luameshval@api@color} + \mplibcolor{\luameshmpcolorBack}{\luameshval@api@colorback} + \mplibcolor{\luameshmpcolorNew}{\luameshval@api@colornew} + \mplibcolor{\luameshmpcolorCircle}{\luameshval@api@colorcircle} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@api@colorbbox} \directlua{% - TeXOnePointMPBWinc("#2","#3","#4","#5","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")% + TeXOnePointMPBWinc("#2","#3","#4","#5","\luameshval@api@step","\luameshval@api@scale","\luameshval@api@mode","\luameshval@api@bbox")% }% % \fi%