00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <fvutils/draw/field.h>
00023
00024 #include <core/exceptions/software.h>
00025
00026 #include <cmath>
00027 #include <cstring>
00028 #include <stdio.h>
00029
00030 using namespace fawkes;
00031
00032 namespace firevision {
00033 #if 0
00034 }
00035 #endif
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 Field::Field(FieldLines *lines, bool manage_lines_memory)
00049 {
00050 __lines = lines;
00051 __manage_lines_memory = manage_lines_memory;
00052 }
00053
00054
00055
00056
00057 Field::~Field()
00058 {
00059 if (__manage_lines_memory) delete __lines;
00060 }
00061
00062
00063
00064
00065
00066
00067 float
00068 Field::get_field_length()const
00069 {
00070 return __lines->get_field_length();
00071 }
00072
00073
00074
00075
00076
00077
00078 float
00079 Field::get_field_width() const
00080 {
00081 return __lines->get_field_width();
00082 }
00083
00084
00085
00086
00087
00088
00089 void
00090 Field::print(bool in_mm) const
00091 {
00092 printf("Field lines (start-x -y end-x -y):\n==================================\n");
00093 for (FieldLines::const_iterator it = __lines->begin(); it != __lines->end(); ++it) {
00094 if (in_mm) printf("%d %d %d %d\n", static_cast<int>(it->start.x * 1000), static_cast<int>(it->start.y * 1000), static_cast<int>(it->end.x * 1000), static_cast<int>(it->end.y * 1000));
00095 else printf("%0.03f %0.03f %0.03f %0.03f\n", it->start.x, it->start.y, it->end.x, it->end.y);
00096 }
00097 printf("\n");
00098
00099 printf("Field circles (center-x/y radius start/end angle):\n=============================================\n");
00100 for (field_circles_t::const_iterator it = __lines->get_circles().begin(); it != __lines->get_circles().end(); ++it) {
00101 if (in_mm) printf("%d %d %d %0.03f %0.03f\n", static_cast<int>(it->center.x * 1000), static_cast<int>(it->center.y * 1000), static_cast<int>(it->radius * 1000), it->start_phi, it->end_phi);
00102 else printf("%0.03f %0.03f %0.03f %0.03f %0.03f\n", it->center.x, it->center.y, it->radius, it->start_phi, it->end_phi);
00103 }
00104 printf("\n\n");
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 Field*
00116 Field::field_for_name(std::string field_name, float field_length, float field_width)
00117 {
00118 if (field_name == "Field6x4") return new Field(new FieldLines6x4(field_length, field_width));
00119 else if (field_name == "FieldCityTower") return new Field(new FieldLinesCityTower(field_length, field_width));
00120 else if (field_name == "FieldCityTowerSeminar") return new Field(new FieldLinesCityTowerSeminar(field_length, field_width));
00121 else throw fawkes::IllegalArgumentException("Unknown field name! Please set field_name to a valid value (see field.h)");
00122 }
00123
00124 }