<?PHP
// --- Convert RAW image airfoil into .DAT file - Caltabiano Salvatore - Frontier2 ---
// --- Convert RAW image airfoil shape into .DAT file ---
// --- By Caltabiano Salvatore - Frontier2 - 2006 September 06 - V 1.00 PHP Version ---
ini_set("memory_limit", "32M");
include "include/Airfoil.php";
if ( isset($_POST['send']) )
{
if ( intval($_POST['width'])<10 || intval($_POST['height'])<10 || $_FILES['fileraw']['name'] == "")
echo "Error: wrong values,<BR>\n try again.";
if ( intval($_POST['step']) < 1 || intval($_POST['step']) > 100 )
$step = 5;
else
$step = $_POST['step'];
if ( $_POST['ratio'] == "" || intval($_POST['ratio']) == 0 || intval($_POST['ratio']) < 1 || intval($_POST['ratio']) > intval($_POST['width']) );
else
$ratio = $_POST['ratio'];
$airfoil = new Airfoil();
$airfoil->filename = $_FILES['fileraw']['tmp_name'];
$airfoil->load();
$airfoil->info = $_POST['info'];
$airfoil->cols = intval($_POST['width']);
$airfoil->rows = intval($_POST['height']);
$airfoil->calculate();
$airfoil->sort2();
if ( isset($ratio) )
$airfoil->ratio = $ratio;
$airfoil->saveCoords($step);
$filenameapp = explode(".", $_FILES['fileraw']['name']);
$filenameout = $filenameapp[0].".DAT";
header('Content-type: text/plain');
header("Content-transfer-encoding: binary\n");
header("Content-Disposition: attachment; filename=".$filenameout);
$airfoil->displayCoords($step);
}
else
{
$datapage = "<HTML>
<HEAD>
<TITLE>Convert RAW image airfoil into .DAT file - Caltabiano Salvatore - Frontier2</TITLE>
</HEAD>
<BODY>
<H1>Convert RAW image airfoil shape into .DAT file</H1>
<P>By Caltabiano Salvatore - Frontier2 - 2006 September 06 - V 1.00 PHP Version</P>
<HR>
<P>This is an easy tool made by me (Caltabiano Salvatore - Frontier2), that allow you to convert an <B>image raw</B> made by a 2D Graphic programm into a <B>file .dat</B>.</P>
<P>The <B>file .dat</B> will have inside the coords of the image raw, the airfoil, that you can use after with a programm named <B>DesignFOIL</B>, a great programm to make airfoils and calculate varius parameters like lift, drag, wings, coefficients and others, it's great!</P>
<P>So at the end you will have a text file, with all the coordinates.</P>
<P>You can use this programm also if you want get coordinates of a shape, an image, example a fuselage plane.</P>
<P>The coordinates (x,y)(0,0) are on the left middle of the image and (x,y)(1,0) on the right middle of the image, but you can change this.</P>
<P>You must use for background a color different of #000000 (black), and use this for trace airfoil.</P>
<P>If an image raw is 1000 x 1000 pixels, the line ground of coords y 0 is at 499 pixel of height from top to bottom.</P>
<P>This programm still a beta version, you have right result using image raw pixels of 1000 x 1000, else you may have problem.</P>
<P><B>The image must be <U>raw</U> in <U>grey scale</U> and use black color #000000 for picture.</B></P>
<HR>
<H2>Fill the form below</H2>
<TABLE CELLSPACING=\"3\" CELLPADDING=\"3\" BORDER=\"0\" BGCOLOR=\"#CCCCCC\">
<FORM METHOD=\"POST\" ACTION=\"".basename($_SERVER['PHP_SELF'])."\" ENCTYPE=\"multipart/form-data\">
<TR>
<TD COLSPAN=\"4\" WIDTH=\"400\"><B>Convert RAW to DAT airfoil data</B></TD>
</TR>
<TR>
<TD WIDTH=\"150\">Information:</TD>
<TD COLSPAN=\"3\" WIDTH=\"250\"><INPUT TYPE=\"TEXT\" NAME=\"info\" VALUE=\"New Airfoil\" MAXLENGTH=\"32\" SIZE=\"32\"></TD>
</TR>
<TR>
<TD WIDTH=\"150\">FILE .RAW</TD>
<TD COLSPAN=\"3\" WIDTH=\"250\"><INPUT TYPE=\"FILE\" NAME=\"fileraw\"></TD>
</TR>
<TR>
<TD WIDTH=\"150\">WIDTH raw image:</TD>
<TD WIDTH=\"50\"><INPUT TYPE=\"TEXT\" NAME=\"width\" VALUE=\"1000\" MAXLENGTH=\"4\" SIZE=\"4\"></TD>
<TD WIDTH=\"150\">HEIGHT raw image:</TD>
<TD WIDTH=\"50\"><INPUT TYPE=\"TEXT\" NAME=\"height\" VALUE=\"1000\" MAXLENGTH=\"4\" SIZE=\"4\"></TD>
</TR>
<TR>
<TD WIDTH=\"150\">Coordinates Pixels Step Chunk</TD>
<TD COLSPAN=\"3\" WIDTH=\"250\"><INPUT TYPE=\"TEXT\" NAME=\"step\" VALUE=\"5\" SIZE=\"3\" MAXLENGTH=\"3\"> (range 1 ~ 100)</TD>
</TR>
<TR>
<TD WIDTH=\"150\">Width Pixel Ratio</TD>
<TD COLSPAN=\"3\" WIDTH=\"250\"><INPUT TYPE=\"TEXT\" NAME=\"ratio\" VALUE=\"0\" SIZE=\"3\" MAXLENGTH=\"3\"> (range 1 ~ WIDTH | 0 auto)</TD>
</TR>
<TR>
<TD COLSPAN=\"4\"><INPUT TYPE=\"reset\" VALUE=\"Reset\"> <INPUT TYPE=\"submit\" NAME=\"send\" VALUE=\"Send\"></TD>
</TR>
</FORM>
</TABLE>
<P>(*) Coordinates Pixels Step Chunk - Is the number of the pixels width that it jump from a coordinate to another, when this number is 1, you have the maximum coordinates, more precise, if the number is high, you will be less coordinates.
<P>(*) Width Pixel Ratio - Is the value of misure unit of the image, if you put 1, every pixel is a number integer of coords, if you let 0 the uniti will be the total lenght of image drawed.</P>
</BODY>
</HTML>";
echo $datapage;
}
?>