-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathOutputFormatText.cpp
More file actions
executable file
·64 lines (51 loc) · 1.8 KB
/
OutputFormatText.cpp
File metadata and controls
executable file
·64 lines (51 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "OutputFormatTypes.h"
#include "OutputFormatText.h"
void OutputFormatText::addPoint(OutputFeaturePoint newPoint) {
if (!this->outputFile) {
fprintf(stderr, "No output file is open for writing.");
return;
}
fprintf(this->outputFile, "POINT at (%f,%f)\n", newPoint.get_X(), newPoint.get_Y());
}
void OutputFormatText::addLine(OutputFeatureLine newLine) {
if (!this->outputFile) {
fprintf(stderr, "No output file is open for writing.");
return;
}
fprintf(this->outputFile, "LINE from (%f,%f) to (%f,%f)\n", newLine.get_X1(), newLine.get_Y1(), newLine.get_X2(), newLine.get_Y2());
}
void OutputFormatText::addPolyLine(std::vector<OutputFeaturePoint *> newPoints) {
if (!this->outputFile) {
fprintf(stderr, "No output file is open for writing.");
return;
}
fprintf(this->outputFile, "Polyline with Points:");
for (int i = 0; i < newPoints.size(); i++) {
fprintf(this->outputFile, " (%f,%f)", newPoints[i]->get_X(), newPoints[i]->get_Y());
}
fprintf(this->outputFile, "\n");
}
void OutputFormatText::addPolygon(std::vector<OutputFeaturePoint *> newPoints) {
if (!this->outputFile) {
fprintf(stderr, "No output file is open for writing.");
return;
}
fprintf(this->outputFile, "Polygon with Points:");
for (int i = 0; i < newPoints.size(); i++) {
fprintf(this->outputFile, " (%f,%f)", newPoints[i]->get_X(), newPoints[i]->get_Y());
}
fprintf(this->outputFile, "\n");
}
void OutputFormatText::addText(OutputFeaturePoint location, const char * text) {
if (!this->outputFile) {
fprintf(stderr, "No output file is open for writing.");
return;
}
fprintf(this->outputFile, "%s\n", text);
}
OutputFormatText::OutputFormatText(const char * filename) {
this->outputFile = fopen(filename, "w");
}
void OutputFormatText::finalizeOutput() {
if (this->outputFile) fclose(this->outputFile);
}