X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=blobdiff_plain;f=luamesh.sty;h=ccb1863f0910dbf57eb9abb87a7b54104be39def;hb=091530a7b134b2955272ad2ab217cf195233dc39;hp=9b326e50933448c60a9d6533708227b4edb8d6e0;hpb=cc95d9b8f7a859cf2f69b419e15bd1a8a2777289;p=delaunay.git diff --git a/luamesh.sty b/luamesh.sty index 9b326e5..ccb1863 100644 --- a/luamesh.sty +++ b/luamesh.sty @@ -23,20 +23,6 @@ % 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)} %% % for tikz (default value) % default color for the plot of a global mesh @@ -52,72 +38,255 @@ %%%%%%%%%%%%%%%% the buildMesh command %% engine of drawing \newif\ifluameshengineMP% +\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}% + \or% + \def\luameshval@bm@bbox{bbox}% + \fi% +}% +%% the scale +\define@key{buildMeshInc}{scale}[1cm]{\def\luameshval@bm@scale{#1}}% +%% print ponits ? +\define@choicekey*{buildMeshInc}{print}[\val\nr]{none, points}{% + \ifcase\nr\relax% + \def\luameshval@bm@print{none}% + \or% + \def\luameshval@bm@print{points}% + \fi% +}% +%% the name of the point +\define@key{buildMeshInc}{meshpoint}[P]{\def\luameshval@bm@meshpoint{#1}}% +%% the mode for reading the points +\define@choicekey*{buildMeshInc}{mode}[\val\nr]{int, ext}{% + \ifcase\nr\relax% + \def\luameshval@bm@mode{int}% + \or% + \def\luameshval@bm@mode{ext}% + \fi% +}% +% +%color +%% the name of the color of drawing +\define@key{buildMeshInc}{color}[black]{\def\luameshval@bm@color{#1}}% +%% the name of the color of drawing the bbox +\define@key{buildMeshInc}{colorBbox}[black]{\def\luameshval@bm@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 + \setkeys{buildMesh}{#1} % + \def\MeshPoint{\luameshval@bm@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")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@bm@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@bm@colorbbox} + \directlua{% + buildMeshMPBWinc("#2","#3","#4","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","\luameshval@bm@scale")% + }% + % + \fi% +}% +% +%%%%%%%%%%%%%%%% the buildMeshBW command +%% engine of drawing +\newif\ifluameshengineMP% \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% }% % -%% a complete picture or some code of the engine -\define@choicekey*{buildMesh}{picture}[\val\nr]{full, embedded}{% +% 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 +\define@key{buildMesh}{colorBbox}[black]{\def\luameshval@bm@colorbbox{#1}}% +% +\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 + % (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{% + buildMeshTikZ("#2","\luameshval@bm@mode","\luameshval@bm@print","\luameshval@bm@bbox","full","\luameshval@bm@scale","\luameshval@bm@color")% + }% + \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 +%% engine of drawing +\newif\ifluameshengineMP% +\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{embedded}% + \def\luameshval@tp@bbox{bbox}% \fi% }% -%color +%% 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}}% +% +\presetkeys{tracePoints}{tikz=false,bbox=none,scale, meshpoint,mode=int,print=none,color,colorBbox}{}% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition -\newcommand{\buildMesh}[2][]{% +% the difinition BW Bowyer and Watson algo +\newcommand{\tracePointsMesh}[2][]{% % #1 : 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}% + \setkeys{tracePoints}{#1} % + \def\MeshPoint{\luameshval@tp@meshpoint}% \ifKV@buildMesh@tikz% if we are using tikz \directlua{% - buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@color")% + % buildMeshTikZ("#2","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","full","\luameshval@tp@scale","\luameshval@tp@color")% }% \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 +%% 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}% + \or% + \def\luameshval@tp@bbox{bbox}% + \fi% +}% +%% the scale +\define@key{tracePointsInc}{scale}[1cm]{\def\luameshval@tp@scale{#1}}% +%% print points +\define@choicekey*{tracePointsInc}{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{tracePointsInc}{meshpoint}[P]{\def\luameshval@tp@meshpoint{#1}}% +%% the mode for reading the points +\define@choicekey*{tracePointsInc}{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{tracePointsInc}{color}[black]{\def\luameshval@tp@color{#1}}% +%% the name of the color of drawing the bbox +\define@key{tracePointsInc}{colorBbox}[black]{\def\luameshval@tp@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 + % (x1,y1);(x2,y2);... or the name file containing the points + \setkeys{tracePointsInc}{#1} % + \def\MeshPoint{\luameshval@tp@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")% + }% + \else % we are using MP + \mplibcolor{\luameshmpcolor}{\luameshval@tp@color} + \mplibcolor{\luameshmpcolorBbox}{\luameshval@tp@colorbbox} + \directlua{% + printPointsMPinc("#2","#3","#4","\luameshval@tp@mode","\luameshval@tp@print","\luameshval@tp@bbox","\luameshval@tp@scale")% + }% + \fi% +}% +% +% %% % -%%the meshAddOnePoint commande +%%the meshAddOnePointBW commande %%engine of drawing \newif\ifluameshengineMP% \define@boolkey{MeshAddOne}{tikz}[true]{}% @@ -128,14 +297,6 @@ %% the name of the new point \define@key{MeshAddOne}{newpoint}[P]{\def\luameshval@newpoint{#1}}% %% a complete picture or some code of the engine -\define@choicekey*{MeshAddOne}{picture}[\val\nr]{full, simple}{% - \ifcase\nr\relax% - \def\luameshval@picture{full}% - \or% - \def\luameshval@picture{simple}% - \fi% -}% -%% a complete picture or some code of the engine \define@choicekey*{MeshAddOne}{step}[\val\nr]{badtriangles, cavity, newtriangles}{% \ifcase\nr\relax% \def\luameshval@step{badT}% @@ -154,6 +315,8 @@ \define@key{MeshAddOne}{colorNew}[red]{\def\luameshval@colornew{#1}}% %% the color of circoncircle \define@key{MeshAddOne}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}% +%% the name of the color of drawing the bbox +\define@key{MeshAddOne}{colorBbox}[black]{\def\luameshval@colorbbox{#1}}% % %% a complete picture or some code of the engine \define@choicekey*{MeshAddOne}{mode}[\val\nr]{int, ext}{% @@ -163,19 +326,18 @@ \def\luameshval@mode{ext}% \fi% }% -%% a complete picture or some code of the engine -\define@choicekey*{MeshAddOne}{picture}[\val\nr]{full, embedded}{% +\define@choicekey*{MeshAddOne}{bbox}[\val\nr]{none, show}{% \ifcase\nr\relax% - \def\luameshval@picture{full}% + \def\luameshval@bbox{none}% \or% - \def\luameshval@picture{embedded}% + \def\luameshval@bbox{bbox}% \fi% }% -\presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,picture=full}{}% +\presetkeys{MeshAddOne}{tikz=false,scale, meshpoint,newpoint,color,colorBack,colorNew,colorCircle,step=badtriangles,mode=int,bbox=none,colorBbox}{}% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% the difinition -\newcommand{\meshAddOnePoint}[3][]{% +% the difinition BW Bowyer and Watson algo +\newcommand*{\meshAddPointBW}[3][]{% % #1 : the string containing the list of points % (x1,y1);(x2,y2);... or the name file containing the points \setkeys{MeshAddOne}{#1} % @@ -186,8 +348,85 @@ buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@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} + \directlua{% + TeXOnePointMPBW("#2","#3","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")% + }% + % + \fi% +}% +%%% the meshAddPointBWinc commande +%% engine of drawing +\newif\ifluameshengineMP% +\define@boolkey{MeshAddOneBWinc}{tikz}[true]{}% +%% the scale +\define@key{MeshAddOneBWinc}{scale}[1cm]{\def\luameshval@scale{#1}}% +%% the name of the points +\define@key{MeshAddOneBWinc}{meshpoint}[P]{\def\luameshval@meshpoint{#1}}% +%% the name of the new point +\define@key{MeshAddOneBWinc}{newpoint}[P]{\def\luameshval@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}% + \or% + \def\luameshval@step{cavity}% + \or% + \def\luameshval@step{newT}% + \fi% +}% +% color +%% the color of drawing +\define@key{MeshAddOneBWinc}{color}[black]{\def\luameshval@color{#1}}% +%% the color of background of new element +\define@key{MeshAddOneBWinc}{colorBack}[black!20]{\def\luameshval@colorback{#1}}% +%% the color of new element +\define@key{MeshAddOneBWinc}{colorNew}[red]{\def\luameshval@colornew{#1}}% +%% the color of circoncircle +\define@key{MeshAddOneBWinc}{colorCircle}[green]{\def\luameshval@colorcircle{#1}}% +\define@key{MeshAddOneBWinc}{colorBbox}[black]{\def\luameshval@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}% + \or% + \def\luameshval@mode{ext}% + \fi% +}% +\define@choicekey*{MeshAddOneBWinc}{bbox}[\val\nr]{none, show}{% + \ifcase\nr\relax% + \def\luameshval@bbox{none}% + \or% + \def\luameshval@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 + % (x1,y1);(x2,y2);... or the name file containing the points + \setkeys{MeshAddOneBWinc}{#1} % + \def\MeshPoint{\luameshval@meshpoint}% + \def\NewPoint{\luameshval@newpoint}% + \ifKV@MeshAddOne@tikz% if we are using tikz + \directlua{% + buildMeshTikZ("#2","\luameshval@mode","\luameshval@print","\luameshval@bbox","full","\luameshval@scale","\luameshval@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} \directlua{% - TeXOnePointMP("#2","#3","\luameshval@step","\luameshval@color","\luameshval@colorback","\luameshval@colornew","\luameshval@colorcircle","\luameshval@scale","\luameshval@mode","\luameshval@picture")% + TeXOnePointMPBWinc("#2","#3","#4","#5","\luameshval@step","\luameshval@scale","\luameshval@mode","\luameshval@bbox")% }% % \fi%