Commit 1c9b3b53 authored by Johan Richard's avatar Johan Richard
Browse files

First test on connecting the dots in criticnew

parent 4cc0cc1d
......@@ -33,6 +33,7 @@
static void snake(int verbose);
static void marchingSquares(int verbose);
static void cl_connectdots(int verbose);
void criticnew(int verbose)
{
......@@ -41,7 +42,10 @@ void criticnew(int verbose)
if ( !strcmp(CL.algorithm, "SNAKE") )
snake(verbose);
else
{
marchingSquares(verbose);
cl_connectdots(verbose);
}
}
......@@ -563,6 +567,86 @@ static void marchingSquares(int verbose)
}
}
static void cl_connectdots(int verbose)
{
extern struct g_cline CL;
extern struct biline radial[], tangent[];
extern int nrline, ntline;
//#ifdef DEBUG
fprintf( stderr, "I connect the dots here\n" );
//#endif
float currentdist,distmin;
struct biline zpos,currentpos;
int pos,minpos,iline;
iline=1;
currentpos=tangent[1]; // start with the first two points
for(int i=2;i<ntline;i++)
{
if(tangent[i].i==1) // start a new line
{
iline++;
currentpos=tangent[i];
continue;
}
pos=i;
distmin=-1;
minpos=i;
while((tangent[pos].i!=1)&&(pos<ntline))
{
currentdist=pow(currentpos.I.x-tangent[pos].I.x,2)+pow(currentpos.I.y-tangent[pos].I.y,2);
if((distmin<0)||(currentdist<distmin))
{
minpos=pos;
distmin=currentdist;
}
pos++;
}
//swap position i and minpos
zpos=tangent[i];
tangent[i]=tangent[minpos];
tangent[minpos]=zpos;
currentpos=tangent[i];
tangent[i].i=iline;
}
iline=1;
currentpos=radial[1]; // start with the first two points
for(int i=2;i<nrline;i++)
{
if(radial[i].i==1) // start a new line
{
iline++;
currentpos=radial[i];
continue;
}
pos=i;
distmin=-1;
minpos=i;
while((radial[pos].i!=1)&&(pos<nrline))
{
currentdist=pow(currentpos.I.x-radial[pos].I.x,2)+pow(currentpos.I.y-radial[pos].I.y,2);
if((distmin<0)||(currentdist<distmin))
{
minpos=pos;
distmin=currentdist;
}
pos++;
}
//swap position i and minpos
zpos=radial[i];
radial[i]=radial[minpos];
radial[minpos]=zpos;
currentpos=radial[i];
radial[i].i=iline;
}
}
/* Find the caustic/critical lines with the snake algorithm.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment