Sample Project Example¶
Note
This example is specific to Linux. Windows and Mac projects will need to be modified accordingly to properly build and execute.
This example demonstrates a sample standalone C++ project
that uses Tracktable as a library. The sample project structure
and files can be found in the source code distribution in the
directory tracktable/Examples/Sample_Project
. To run the
commands below ensure that your current working directory is
tracktable/Examples/Sample_Project
.
This mini-project is not part of the tracktable build system. Instead, it is a template demonstrating how to create your own program using Tracktable as one of your libraries. Below you will find the sample project source code and the commands to build and execute it.
1 #include <tracktable/Core/PointCartesian.h>
2 #include <tracktable/Domain/Cartesian2D.h>
3
4 int main(int argc, char* argv[])
5 {
6 typedef tracktable::domain::cartesian2d::CartesianPoint2D MyPointType;
7
8 MyPointType point1(10, 10);
9 MyPointType point2(20, 20);
10 MyPointType point3;
11
12 point3 = tracktable::interpolate(point1, point2, 0.25);
13
14 std::cout << "Awesome point 1: " << point1 << std::endl
15 << "Awesome point 2 above point 1: " << point2 << std::endl
16 << "Cool interpolated point at 0.25 from 1 to 2: " << point3 << std::endl;
17
18 return 0;
19 }
This script will run all of the following commands with contextual output:
$ sh run-test.sh
This will make a build directory with:
$ mkdir build
Change into the build directory:
$ cd build
Create the makefiles:
$ cmake ..
Build the program:
$ make
And run the program:
$ ./coolprogram