X-Git-Url: https://melusine.eu.org/syracuse/G/git/?p=delaunay.git;a=blobdiff_plain;f=luamesh.sty;h=1e1a99e072986e97030abbae07984a925a3f011e;hp=9cc0b681e83d47f65528d75b3368460e25334c68;hb=c25242309db6a2554651e368376b07d30afc3601;hpb=99c7eb1c5fdd23d7617d3817806af416e4614d15 diff --git a/luamesh.sty b/luamesh.sty index 9cc0b68..1e1a99e 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -21,22 +21,8 @@ %\fi% % % load the lua code -\directlua{dofile("luamesh.lua")}% -% -% global def (default value) -\newcommand{\MeshPoint}{P} -\newcommand{\NewPoint}{P} -% for MetaPost (MP) (default value) -% default scale u:=1cm; -\newcommand\luaMeshScaleMP{1cm} -% default color for the plot of a global mesh -\newcommand\TeXCluaMeshMP{(0.,0.,0.)} -% default color for a new element -\newcommand\TeXCluaMeshNewMP{(0.5,0.1,0.1)} -% defaut color for the background of new element -\newcommand\TeXCluaMeshBackMP{(0.99,0.85,0.85)} -% default color for circoncircle -\newcommand\TeXCluaMeshCircleMP{(0.1,0.6,0.1)} +\directlua{require("luamesh.lua")}% +% %% % for tikz (default value) % default color for the plot of a global mesh @@ -50,136 +36,390 @@ %%%%%%%%%%%%%%%% 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@bmi@bbox{none}% + \or% + \def\luameshval@bmi@bbox{bbox}% + \fi% +}% +%% the scale +\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@bmi@print{none}% + \or% + \def\luameshval@bmi@print{points}% + \fi% +}% +%% the name of the point +\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@bmi@mode{int}% + \or% + \def\luameshval@bmi@mode{ext}% + \fi% +}% +%% the name of the color of drawing +\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@bmi@colorbbox{#1}}% +% +\presetkeys{buildMeshInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +\newcommand*{\buildMeshBWinc}[4][]{% + % #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{buildMeshInc}{#1} % + \def\MeshPoint{\luameshval@bmi@meshpoint}% + \ifKV@buildMeshInc@tikz% if we are using tikz + \directlua{% + buildMeshTikZBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale","\luameshval@bmi@color","\luameshval@bmi@colorbbox")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@bmi@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@bmi@colorbbox} + \directlua{% + buildMeshMPBWinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@bmi@mode","\luameshval@bmi@print","\luameshval@bmi@bbox","\luameshval@bmi@scale")% + }% + % + \fi% +}% +% +%%%%%%%%%%%%%%%% the buildMeshBW command +%% 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}{% \ifcase\nr\relax% - \def\luameshval@bbox{none}% + \def\luameshval@bm@bbox{none}% \or% - \def\luameshval@bbox{bbox}% + \def\luameshval@bm@bbox{bbox}% \fi% }% %% the scale -\define@key{buildMesh}{scale}[1cm]{\def\luameshval@scale{#1}}% -%% print ponits ? +\define@key{buildMesh}{scale}[1cm]{\def\luameshval@bm@scale{#1}}% +%% print points \define@choicekey*{buildMesh}{print}[\val\nr]{none, points}{% \ifcase\nr\relax% - \def\luameshval@print{none}% + \def\luameshval@bm@print{none}% \or% - \def\luameshval@print{points}% + \def\luameshval@bm@print{points}% \fi% }% %% the name of the point -\define@key{buildMesh}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}% +\define@key{buildMesh}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}% %% the mode for reading the points \define@choicekey*{buildMesh}{mode}[\val\nr]{int, ext}{% \ifcase\nr\relax% - \def\luameshval@mode{int}% + \def\luameshval@bm@mode{int}% \or% - \def\luameshval@mode{ext}% + \def\luameshval@bm@mode{ext}% \fi% }% +%% 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 +\define@key{buildMesh}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}% % -%% a complete picture or some code of the engine -\define@choicekey*{buildMesh}{picture}[\val\nr]{full, simple}{% +\presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +\newcommand{\buildMeshBW}[2][]{% + % #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}% + \ifKV@buildMesh@tikz% if we are using tikz + \directlua{% + buildMeshTikZBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale","\luameshval@bm@color","\luameshval@bm@colorbbox")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@bm@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox} + \directlua{% + buildMeshMPBW("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")% + }% + % + \fi% +}% +% +% +%%%%%%%%%%%%%%%%% the trace Points macro +%% 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}{% \ifcase\nr\relax% - \def\luameshval@picture{full}% + \def\luameshval@tp@bbox{none}% \or% - \def\luameshval@picture{simple}% + \def\luameshval@tp@bbox{bbox}% + \fi% +}% +%% the scale +\define@key{tracePoints}{scale}[1cm]{\def\luameshval@tp@scale{#1}}% +%% print points +\define@choicekey*{tracePoints}{print}[\val\nr]{none, points}{% + \ifcase\nr\relax% + \def\luameshval@tp@print{none}% + \or% + \def\luameshval@tp@print{points}% + \fi% +}% +%% the name of the point +\define@key{tracePoints}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}% +%% the mode for reading the points +\define@choicekey*{tracePoints}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@tp@mode{int}% + \or% + \def\luameshval@tp@mode{ext}% \fi% }% -%color %% the name of the color of drawing -\define@key{buildMesh}{color}[black]{\def\luameshval@color{#1}}% - -\presetkeys{buildMesh}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,picture=full,color}{}% +\define@key{tracePoints}{color}[black]{\def\luameshval@tp@color{#1}}% +%% the name of the color of drawing the bbox +\define@key{tracePoints}{colorBbox}[black]{\def\luameshval@tp@colorbbox{#1}}% % -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition -\newcommand{\buildMesh}[2][]{% - % #1 : the string containing the list of points +\presetkeys{tracePoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +\newcommand{\tracePointsMesh}[2][]{% + % #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@meshpoint}% - \ifKV@buildMesh@tikz% if we are using tikz + \setkeys{tracePoints}{#1} % + \def\MeshPoint{\luameshval@tp@meshpoint}% + \ifKV@tracePoints@tikz% if we are using tikz \directlua{% - buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")% + printPointsTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale","\luameshval@tp@color","\luameshval@tp@colorbbox")% }% \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@tp@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox} \directlua{% - buildMeshMP("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")% + printPointsMP("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")% }% % \fi% }% % -%% + +%%%%%%%%%%%%%%%% the trace Points macro inc with callbacks +%% engine of drawing +\define@boolkey{tracePointsInc}{tikz}[true]{}% +%% show the bounding box for delaunay +\define@choicekey*{tracePointsInc}{bbox}[\val\nr]{none, show}{% + \ifcase\nr\relax% + \def\luameshval@tpi@bbox{none}% + \or% + \def\luameshval@tpi@bbox{bbox}% + \fi% +}% +%% the scale +\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@tpi@print{none}% + \or% + \def\luameshval@tpi@print{points}% + \fi% +}% +%% the name of the point +\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@tpi@mode{int}% + \or% + \def\luameshval@tpi@mode{ext}% + \fi% +}% +% +% color +%% the name of the color of drawing +\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@tpi@colorbbox{#1}}% % -%%the meshAddOnePoint commande +\presetkeys{tracePointsInc}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand*{\tracePointsMeshinc}[4][]{% + % #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@tpi@meshpoint}% + \ifKV@tracePointsInc@tikz% if we are using tikz + \directlua{% + 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@tpi@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@tpi@colorbbox} + \directlua{% + printPointsMPinc("#2","\luaescapestring{\unexpanded{#3}}","\luaescapestring{\unexpanded{#4}}","\luameshval@tpi@mode","\luameshval@tpi@print","\luameshval@tpi@bbox","\luameshval@tpi@scale")% + }% + \fi% +}% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% 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*{MeshAddOneBW}{step}[\val\nr]{badtriangles, cavity, newtriangles}{% + \ifcase\nr\relax% + \def\luameshval@ap@step{badT}% + \or% + \def\luameshval@ap@step{cavity}% + \or% + \def\luameshval@ap@step{newT}% + \fi% +}% +% color +%% the color of drawing +\define@key{MeshAddOneBW}{color}[black]{\def\luameshval@ap@color{#1}}% +%% the color of background of new element +\define@key{MeshAddOneBW}{colorBack}[black!20]{\def\luameshval@ap@colorback{#1}}% +%% the color of new element +\define@key{MeshAddOneBW}{colorNew}[red]{\def\luameshval@ap@colornew{#1}}% +%% the color of circoncircle +\define@key{MeshAddOneBW}{colorCircle}[green]{\def\luameshval@ap@colorcircle{#1}}% +%% the name of the color of drawing the bbox +\define@key{MeshAddOneBW}{colorBbox}[black]{\def\luameshval@ap@colorbbox{#1}}% +% %% a complete picture or some code of the engine -\define@choicekey*{MeshAddOne}{picture}[\val\nr]{full, simple}{% +\define@choicekey*{MeshAddOneBW}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@ap@mode{int}% + \or% + \def\luameshval@ap@mode{ext}% + \fi% +}% +\define@choicekey*{MeshAddOneBW}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@picture{full}% + \def\luameshval@ap@bbox{none}% \or% - \def\luameshval@picture{simple}% + \def\luameshval@ap@bbox{bbox}% + \fi% +}% +\presetkeys{MeshAddOneBW}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}% +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand*{\meshAddPointBW}[3][]{% + % #1 : optionnal arguments + % #2 : the string containing the list of points + % (x1,y1);(x2,y2);... or the name file containing the points + \setkeys{MeshAddOneBW}{#1} % + \def\MeshPoint{\luameshval@ap@meshpoint}% + \def\NewPoint{\luameshval@ap@newpoint}% + \ifKV@MeshAddOneBW@tikz% if we are using tikz + \directlua{% + TeXOnePointTikZBW("#2","#3","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox","\luameshval@ap@color","\luameshval@ap@colorback","\luameshval@ap@colornew","\luameshval@ap@colorcircle","\luameshval@ap@colorbbox")% + }% + \else % we are using MP + \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@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox")% + }% + % \fi% }% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% the meshAddPointBWinc commande with callbacks +%% engine of drawing +\define@boolkey{MeshAddOneBWinc}{tikz}[true]{}% +%% the scale +\define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@api@scale{#1}}% +%% the name of the points +\define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@api@meshpoint{#1}}% +%% the name of the new point +\define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@api@newpoint{#1}}% %% a complete picture or some code of the engine -\define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{% +\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{MeshAddOne}{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{MeshAddOne}{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{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}% +\define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@api@colornew{#1}}% %% the color of circoncircle -\define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#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*{MeshAddOne}{mode}[\val\nr]{int, ext}{% +\define@choicekey*{MeshAddOneBWinc}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@api@mode{int}% + \or% + \def\luameshval@api@mode{ext}% + \fi% +}% +\define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@mode{int}% + \def\luameshval@api@bbox{none}% \or% - \def\luameshval@mode{ext}% + \def\luameshval@api@bbox{bbox}% \fi% }% -\presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int}{}% +\presetkeys{MeshAddOneBWinc}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition -\newcommand{\meshAddOnePoint}[3][]{% - % #1 : the string containing the list of points +\newcommand*{\meshAddPointBWinc}[5][]{% + % #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}% - \ifKV@MeshAddOne@tikz% if we are using tikz + % #3 : the code to place before the generated one + % #4 : the code to place after the generated one + \setkeys{MeshAddOneBWinc}{#1} % + \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")% + TeXOnePointTikZBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@ap@step","\luameshval@ap@scale","\luameshval@ap@mode","\luameshval@ap@bbox","\luameshval@ap@color","\luameshval@ap@colorback","\luameshval@ap@colornew","\luameshval@ap@colorcircle","\luameshval@ap@colorbbox")% }% \else % we are using MP + \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{% - TeXFullOnePointMP("#2","#3","\luameshval@step","\luameshval@color","\luameshval@colorback","\luameshval@colornew","\luameshval@colorcircle","\luameshval@scale","\luameshval@mode")% + TeXOnePointMPBWinc("#2","#3","\luaescapestring{\unexpanded{#4}}","\luaescapestring{\unexpanded{#5}}","\luameshval@api@step","\luameshval@api@scale","\luameshval@api@mode","\luameshval@api@bbox")% }% % \fi%