... at IWR Heidelberg

3. Running the application

To run the application, you need the programs 'triangle' and 'terrain' (lying in the same folder). You can run the application within the command line.

Our program expects some additional input. The first input-data must be the name of the input-TIFF-file, which must be in the same folder aswell (e.g. 'terrain input.tif' @ command line). Following up, there are several switches, which are optional. The order of these doesn't matter.


Switches
  • -nopoints: Our program puts in some new points at the boundary of the image. This is appropriate in most cases. If you do not want the program to insert this points, use this switch. No matter if this switch is set or not, a point will be set into the four corners of the picture.
    If this switch is not set (that means do not add '-nopoints' at the program call), the density of the points are calculated by the values MAX_CORRECTION_RADIUS (standard-value 20) and POINT_DENSITY_AT_BORDER (standard-value 10). New points are set with a distance of the product of these two values, but not, if the point is too close to a corner.
    The standard-values of these two constants should fit in most cases. But, in some cases you might want to change them (these values are too big for smaller pictures with less than one million pixels). This can be done in the source code (lines 10 and 11). You have to recompile the program in that case.

  • -cortif: If you should set some points very close to each other, our program will fix this and delete all but one point. The minimum distance of two points is set with the constant MAX_CORRECTION_RADIUS (standard 20). You can change this value in the source code (line 10), but have to recompile the program in that case. The corrected version of your input-picture will be writen to disc (into the file 'corrected_input.tif'), if you set this switch.

  • -notif: The generated heightmap is saved into a 16bit-grayscale-TIFF-image ('heightmap.tif'). Prior versions of this picture will be overwriten! If you don't want our program to write this file, choose this switch.

  • -noasc: The generated heightmap is saved into a .asc-file ('heightmap.asc') aswell. If you don't need this output (it can get very large!), choose this switch. Since our major project task was to generated such a file, this output will be generated if you don't set the switch.

  • -nosquareasc: Same as '-noasc', but here the .asc-file ('heightmapsquare.asc') is filled with more content to generate a quadratic heightmap. The additional points are filled with '0'. We had to implement this output, since our testing software (TerrainViewer @ download-section) could only handle quadratic images.


Program speed
The slowest part of our program is the part when we have to determine in which triangle a specific point is. Doing this for several million points can be very slow. In our first version of the program, we just checked for each point each triangle and stopped if we found the triangle. On an pc with dual core 1,8GHz, 2GB Ram that took about 0.5 seconds for each pixel (!). Very very slow, since we had to solve a system of two equations for each tested triangle!
Our next step was to check, if the point is within the environmental rectangle of the triangle. This test is very easy compared to the solving of a system of two equations and only if this test is true, we check if the point is really within the given triangle. This took about 12 minutes on the above mentioned computer. Still a bit too long.
The next step was to sort all the triangles for there minimal x-coordinate and then generate an index. With that index we were able to specify a number of triangles at the beginning of the triangle list, in which the point couldn't be. You can read within the source code, how this index works. With this index included, it took about 3 minuites for the 31 million pixels. Because this index works with the x-coordinates, landscape formated pictures can be handled faster than upright formated pictures.
The last step was to check, if the point is within the same triangle as the last point. Only if this test fails, we start the procedure mentioned about (index, rectangle ...). This step brought us a runtime of about 7 seconds, since most points are obviously within the same triangle as the point before.